diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-25 21:45:12 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-25 21:45:12 +0200 |
| commit | 20d5b66ed17169d84fb303140e26a346e74164ee (patch) | |
| tree | c9ecf597ccf0190e9a1558983761c57be163c24d | |
| parent | ce63d2a10636490c1bdb1dedf36db093735a58e0 (diff) | |
loop-scheduler: fix PRESETS_FILE path using homedir() instead of import.meta.url
Pi bundles extensions so import.meta.url resolves to the wrong location,
causing loadPresets() to always return [] and autocomplete to fall back
to the filesystem. Switch to homedir()/.pi/extensions/loop-scheduler/
which reliably resolves to the correct path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | pi/agent/extensions/loop-scheduler/index.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pi/agent/extensions/loop-scheduler/index.ts b/pi/agent/extensions/loop-scheduler/index.ts index 356bccf..8dad0bf 100644 --- a/pi/agent/extensions/loop-scheduler/index.ts +++ b/pi/agent/extensions/loop-scheduler/index.ts @@ -1,6 +1,6 @@ import { readFileSync, writeFileSync, existsSync } from "node:fs"; import { spawnSync } from "node:child_process"; -import { fileURLToPath } from "node:url"; +import { homedir } from "node:os"; import path from "node:path"; import { randomUUID } from "node:crypto"; import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent"; @@ -8,8 +8,9 @@ import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-age const DEFAULT_INTERVAL_MS = 10 * 60 * 1000; const MAX_JOBS = 50; -// Path to the presets markdown file, stored alongside this extension. -const PRESETS_FILE = path.join(path.dirname(fileURLToPath(import.meta.url)), "loop-presets.md"); +// Path to the presets markdown file. Uses homedir() rather than import.meta.url +// because pi may bundle extensions, making import.meta.url unreliable. +const PRESETS_FILE = path.join(homedir(), ".pi", "extensions", "loop-scheduler", "loop-presets.md"); // Starter content written to the presets file if it doesn't exist yet. const PRESETS_TEMPLATE = `# Loop presets |
