gsd-pi 2.35.0-dev.cd3b7ea → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cli.js +7 -2
- package/dist/resource-loader.d.ts +1 -1
- package/dist/resource-loader.js +13 -1
- package/dist/resources/extensions/async-jobs/await-tool.js +0 -2
- package/dist/resources/extensions/async-jobs/job-manager.js +0 -6
- package/dist/resources/extensions/bg-shell/output-formatter.js +1 -19
- package/dist/resources/extensions/bg-shell/process-manager.js +0 -4
- package/dist/resources/extensions/bg-shell/types.js +0 -2
- package/dist/resources/extensions/context7/index.js +5 -0
- package/dist/resources/extensions/get-secrets-from-user.js +2 -30
- package/dist/resources/extensions/google-search/index.js +5 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +43 -1
- package/dist/resources/extensions/gsd/auto-loop.js +17 -3
- package/dist/resources/extensions/gsd/auto-model-selection.js +15 -3
- package/dist/resources/extensions/gsd/auto-recovery.js +35 -0
- package/dist/resources/extensions/gsd/auto-start.js +35 -2
- package/dist/resources/extensions/gsd/auto.js +59 -4
- package/dist/resources/extensions/gsd/commands-handlers.js +2 -2
- package/dist/resources/extensions/gsd/commands-inspect.js +10 -3
- package/dist/resources/extensions/gsd/commands-rate.js +31 -0
- package/dist/resources/extensions/gsd/commands.js +43 -1
- package/dist/resources/extensions/gsd/doctor-environment.js +26 -17
- package/dist/resources/extensions/gsd/files.js +11 -2
- package/dist/resources/extensions/gsd/gitignore.js +54 -7
- package/dist/resources/extensions/gsd/guided-flow.js +8 -2
- package/dist/resources/extensions/gsd/health-widget-core.js +96 -0
- package/dist/resources/extensions/gsd/health-widget.js +97 -46
- package/dist/resources/extensions/gsd/index.js +26 -33
- package/dist/resources/extensions/gsd/migrate-external.js +55 -2
- package/dist/resources/extensions/gsd/milestone-ids.js +3 -2
- package/dist/resources/extensions/gsd/paths.js +74 -7
- package/dist/resources/extensions/gsd/post-unit-hooks.js +4 -1
- package/dist/resources/extensions/gsd/preferences-validation.js +16 -1
- package/dist/resources/extensions/gsd/preferences.js +12 -0
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/dist/resources/extensions/gsd/roadmap-mutations.js +55 -0
- package/dist/resources/extensions/gsd/session-lock.js +53 -2
- package/dist/resources/extensions/gsd/state.js +2 -1
- package/dist/resources/extensions/gsd/templates/plan.md +8 -0
- package/dist/resources/extensions/gsd/worktree-resolver.js +12 -0
- package/dist/resources/extensions/remote-questions/remote-command.js +2 -22
- package/dist/resources/extensions/shared/mod.js +1 -1
- package/dist/resources/extensions/shared/sanitize.js +30 -0
- package/dist/resources/extensions/subagent/index.js +6 -14
- package/dist/resources/skills/core-web-vitals/SKILL.md +1 -1
- package/dist/resources/skills/create-gsd-extension/workflows/debug-extension.md +1 -1
- package/dist/resources/skills/github-workflows/SKILL.md +0 -2
- package/dist/resources/skills/web-quality-audit/SKILL.md +0 -2
- package/package.json +2 -1
- package/packages/pi-agent-core/dist/agent.d.ts +10 -2
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +19 -8
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/src/agent.ts +31 -10
- package/packages/pi-ai/dist/providers/openai-responses.js +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/packages/pi-ai/src/providers/openai-responses.ts +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +20 -4
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.js +13 -2
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +36 -12
- package/packages/pi-coding-agent/src/core/resource-loader.ts +13 -2
- package/pkg/package.json +1 -1
- package/src/resources/extensions/async-jobs/await-tool.ts +0 -2
- package/src/resources/extensions/async-jobs/job-manager.ts +0 -7
- package/src/resources/extensions/bg-shell/output-formatter.ts +0 -17
- package/src/resources/extensions/bg-shell/process-manager.ts +0 -4
- package/src/resources/extensions/bg-shell/types.ts +0 -12
- package/src/resources/extensions/context7/index.ts +7 -0
- package/src/resources/extensions/get-secrets-from-user.ts +2 -35
- package/src/resources/extensions/google-search/index.ts +7 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +49 -1
- package/src/resources/extensions/gsd/auto-loop.ts +22 -2
- package/src/resources/extensions/gsd/auto-model-selection.ts +23 -2
- package/src/resources/extensions/gsd/auto-recovery.ts +39 -0
- package/src/resources/extensions/gsd/auto-start.ts +42 -2
- package/src/resources/extensions/gsd/auto.ts +61 -3
- package/src/resources/extensions/gsd/commands-handlers.ts +2 -2
- package/src/resources/extensions/gsd/commands-inspect.ts +10 -3
- package/src/resources/extensions/gsd/commands-rate.ts +55 -0
- package/src/resources/extensions/gsd/commands.ts +43 -1
- package/src/resources/extensions/gsd/doctor-environment.ts +26 -16
- package/src/resources/extensions/gsd/files.ts +12 -2
- package/src/resources/extensions/gsd/gitignore.ts +54 -7
- package/src/resources/extensions/gsd/guided-flow.ts +8 -2
- package/src/resources/extensions/gsd/health-widget-core.ts +129 -0
- package/src/resources/extensions/gsd/health-widget.ts +103 -59
- package/src/resources/extensions/gsd/index.ts +30 -33
- package/src/resources/extensions/gsd/migrate-external.ts +47 -2
- package/src/resources/extensions/gsd/milestone-ids.ts +3 -2
- package/src/resources/extensions/gsd/paths.ts +73 -7
- package/src/resources/extensions/gsd/post-unit-hooks.ts +5 -1
- package/src/resources/extensions/gsd/preferences-validation.ts +16 -1
- package/src/resources/extensions/gsd/preferences.ts +14 -1
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +2 -0
- package/src/resources/extensions/gsd/roadmap-mutations.ts +66 -0
- package/src/resources/extensions/gsd/session-lock.ts +59 -2
- package/src/resources/extensions/gsd/state.ts +2 -1
- package/src/resources/extensions/gsd/templates/plan.md +8 -0
- package/src/resources/extensions/gsd/tests/commands-inspect-open-db.test.ts +46 -0
- package/src/resources/extensions/gsd/tests/files-loadfile-eisdir.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/gitignore-tracked-gsd.test.ts +214 -0
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +158 -0
- package/src/resources/extensions/gsd/tests/paths.test.ts +113 -0
- package/src/resources/extensions/gsd/tests/preferences.test.ts +12 -2
- package/src/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +26 -0
- package/src/resources/extensions/gsd/tests/test-utils.ts +165 -0
- package/src/resources/extensions/gsd/tests/validate-directory.test.ts +15 -0
- package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +7 -0
- package/src/resources/extensions/gsd/tests/worktree-sync-milestones.test.ts +32 -0
- package/src/resources/extensions/gsd/worktree-resolver.ts +11 -0
- package/src/resources/extensions/remote-questions/remote-command.ts +2 -23
- package/src/resources/extensions/shared/mod.ts +1 -1
- package/src/resources/extensions/shared/sanitize.ts +36 -0
- package/src/resources/extensions/subagent/index.ts +6 -12
- package/src/resources/skills/core-web-vitals/SKILL.md +1 -1
- package/src/resources/skills/create-gsd-extension/workflows/debug-extension.md +1 -1
- package/src/resources/skills/github-workflows/SKILL.md +0 -2
- package/src/resources/skills/web-quality-audit/SKILL.md +0 -2
- package/dist/resources/extensions/shared/wizard-ui.js +0 -478
- package/dist/resources/skills/swiftui/SKILL.md +0 -208
- package/dist/resources/skills/swiftui/references/animations.md +0 -921
- package/dist/resources/skills/swiftui/references/architecture.md +0 -1561
- package/dist/resources/skills/swiftui/references/layout-system.md +0 -1186
- package/dist/resources/skills/swiftui/references/navigation.md +0 -1492
- package/dist/resources/skills/swiftui/references/networking-async.md +0 -214
- package/dist/resources/skills/swiftui/references/performance.md +0 -1706
- package/dist/resources/skills/swiftui/references/platform-integration.md +0 -204
- package/dist/resources/skills/swiftui/references/state-management.md +0 -1443
- package/dist/resources/skills/swiftui/references/swiftdata.md +0 -297
- package/dist/resources/skills/swiftui/references/testing-debugging.md +0 -247
- package/dist/resources/skills/swiftui/references/uikit-appkit-interop.md +0 -218
- package/dist/resources/skills/swiftui/workflows/add-feature.md +0 -191
- package/dist/resources/skills/swiftui/workflows/build-new-app.md +0 -311
- package/dist/resources/skills/swiftui/workflows/debug-swiftui.md +0 -192
- package/dist/resources/skills/swiftui/workflows/optimize-performance.md +0 -197
- package/dist/resources/skills/swiftui/workflows/ship-app.md +0 -203
- package/dist/resources/skills/swiftui/workflows/write-tests.md +0 -235
- package/src/resources/extensions/shared/wizard-ui.ts +0 -551
- package/src/resources/skills/swiftui/SKILL.md +0 -208
- package/src/resources/skills/swiftui/references/animations.md +0 -921
- package/src/resources/skills/swiftui/references/architecture.md +0 -1561
- package/src/resources/skills/swiftui/references/layout-system.md +0 -1186
- package/src/resources/skills/swiftui/references/navigation.md +0 -1492
- package/src/resources/skills/swiftui/references/networking-async.md +0 -214
- package/src/resources/skills/swiftui/references/performance.md +0 -1706
- package/src/resources/skills/swiftui/references/platform-integration.md +0 -204
- package/src/resources/skills/swiftui/references/state-management.md +0 -1443
- package/src/resources/skills/swiftui/references/swiftdata.md +0 -297
- package/src/resources/skills/swiftui/references/testing-debugging.md +0 -247
- package/src/resources/skills/swiftui/references/uikit-appkit-interop.md +0 -218
- package/src/resources/skills/swiftui/workflows/add-feature.md +0 -191
- package/src/resources/skills/swiftui/workflows/build-new-app.md +0 -311
- package/src/resources/skills/swiftui/workflows/debug-swiftui.md +0 -192
- package/src/resources/skills/swiftui/workflows/optimize-performance.md +0 -197
- package/src/resources/skills/swiftui/workflows/ship-app.md +0 -203
- package/src/resources/skills/swiftui/workflows/write-tests.md +0 -235
|
@@ -48,6 +48,7 @@ import { computeProgressScore, formatProgressLine } from "./progress-score.js";
|
|
|
48
48
|
import { runEnvironmentChecks } from "./doctor-environment.js";
|
|
49
49
|
import { handleLogs } from "./commands-logs.js";
|
|
50
50
|
import { handleStart, handleTemplates, getTemplateCompletions } from "./commands-workflow-templates.js";
|
|
51
|
+
import { readSessionLockData, isSessionLockProcessAlive } from "./session-lock.js";
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
/** Resolve the effective project root, accounting for worktree paths. */
|
|
@@ -69,6 +70,39 @@ export function projectRoot(): string {
|
|
|
69
70
|
return root;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Check if another process holds the auto-mode session lock.
|
|
75
|
+
* Returns the lock data if a remote session is alive, null otherwise.
|
|
76
|
+
*/
|
|
77
|
+
function getRemoteAutoSession(basePath: string): { pid: number } | null {
|
|
78
|
+
const lockData = readSessionLockData(basePath);
|
|
79
|
+
if (!lockData) return null;
|
|
80
|
+
if (lockData.pid === process.pid) return null;
|
|
81
|
+
if (!isSessionLockProcessAlive(lockData)) return null;
|
|
82
|
+
return { pid: lockData.pid };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Show a steering menu when auto-mode is running in another process.
|
|
87
|
+
* Returns true if a remote session was detected (caller should return early).
|
|
88
|
+
*/
|
|
89
|
+
function notifyRemoteAutoActive(ctx: ExtensionCommandContext, basePath: string): boolean {
|
|
90
|
+
const remote = getRemoteAutoSession(basePath);
|
|
91
|
+
if (!remote) return false;
|
|
92
|
+
ctx.ui.notify(
|
|
93
|
+
`Auto-mode is running in another process (PID ${remote.pid}).\n` +
|
|
94
|
+
`Use these commands to interact with it:\n` +
|
|
95
|
+
` /gsd status — check progress\n` +
|
|
96
|
+
` /gsd discuss — discuss architecture decisions\n` +
|
|
97
|
+
` /gsd queue — queue the next milestone\n` +
|
|
98
|
+
` /gsd steer — apply an override to active work\n` +
|
|
99
|
+
` /gsd capture — fire-and-forget thought\n` +
|
|
100
|
+
` /gsd stop — stop auto-mode`,
|
|
101
|
+
"warning",
|
|
102
|
+
);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
72
106
|
export function registerGSDCommand(pi: ExtensionAPI): void {
|
|
73
107
|
pi.registerCommand("gsd", {
|
|
74
108
|
description: "GSD — Get Shit Done: /gsd help|start|templates|next|auto|stop|pause|status|visualize|queue|quick|capture|triage|dispatch|history|undo|skip|export|cleanup|mode|prefs|config|keys|hooks|run-hook|skill-health|doctor|forensics|changelog|migrate|remote|steer|knowledge|new-milestone|parallel|update",
|
|
@@ -89,6 +123,7 @@ export function registerGSDCommand(pi: ExtensionAPI): void {
|
|
|
89
123
|
{ cmd: "triage", desc: "Manually trigger triage of pending captures" },
|
|
90
124
|
{ cmd: "dispatch", desc: "Dispatch a specific phase directly" },
|
|
91
125
|
{ cmd: "history", desc: "View execution history" },
|
|
126
|
+
{ cmd: "rate", desc: "Rate last unit's model tier (over/ok/under) — improves adaptive routing" },
|
|
92
127
|
{ cmd: "undo", desc: "Revert last completed unit" },
|
|
93
128
|
{ cmd: "skip", desc: "Prevent a unit from auto-mode dispatch" },
|
|
94
129
|
{ cmd: "export", desc: "Export milestone/slice results" },
|
|
@@ -511,6 +546,7 @@ export async function handleGSDCommand(
|
|
|
511
546
|
await handleDryRun(ctx, projectRoot());
|
|
512
547
|
return;
|
|
513
548
|
}
|
|
549
|
+
if (notifyRemoteAutoActive(ctx, projectRoot())) return;
|
|
514
550
|
const verboseMode = trimmed.includes("--verbose");
|
|
515
551
|
const debugMode = trimmed.includes("--debug");
|
|
516
552
|
if (debugMode) enableDebug(projectRoot());
|
|
@@ -566,6 +602,12 @@ export async function handleGSDCommand(
|
|
|
566
602
|
return;
|
|
567
603
|
}
|
|
568
604
|
|
|
605
|
+
if (trimmed === "rate" || trimmed.startsWith("rate ")) {
|
|
606
|
+
const { handleRate } = await import("./commands-rate.js");
|
|
607
|
+
await handleRate(trimmed.replace(/^rate\s*/, "").trim(), ctx, projectRoot());
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
|
|
569
611
|
if (trimmed.startsWith("skip ")) {
|
|
570
612
|
await handleSkip(trimmed.replace(/^skip\s*/, "").trim(), ctx, projectRoot());
|
|
571
613
|
return;
|
|
@@ -899,7 +941,7 @@ Examples:
|
|
|
899
941
|
}
|
|
900
942
|
|
|
901
943
|
if (trimmed === "") {
|
|
902
|
-
|
|
944
|
+
if (notifyRemoteAutoActive(ctx, projectRoot())) return;
|
|
903
945
|
await startAuto(ctx, pi, projectRoot(), false, { step: true });
|
|
904
946
|
return;
|
|
905
947
|
}
|
|
@@ -180,26 +180,36 @@ function checkPortConflicts(basePath: string): EnvironmentCheckResult[] {
|
|
|
180
180
|
const portsToCheck = new Set<number>();
|
|
181
181
|
const pkgPath = join(basePath, "package.json");
|
|
182
182
|
|
|
183
|
-
if (existsSync(pkgPath)) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
if (!existsSync(pkgPath)) {
|
|
184
|
+
// No package.json — this isn't a Node.js project. Skip port checks
|
|
185
|
+
// entirely to avoid false positives from system services (e.g., macOS
|
|
186
|
+
// AirPlay Receiver on port 5000). (#1381)
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
192
|
+
const scripts = pkg.scripts ?? {};
|
|
193
|
+
const scriptText = Object.values(scripts).join(" ");
|
|
194
|
+
|
|
195
|
+
// Look for --port NNNN, -p NNNN, PORT=NNNN, :NNNN patterns
|
|
196
|
+
const portMatches = scriptText.matchAll(/(?:--port\s+|(?:^|[^a-z])PORT[=:]\s*|-p\s+|:)(\d{4,5})\b/gi);
|
|
197
|
+
for (const m of portMatches) {
|
|
198
|
+
const port = parseInt(m[1], 10);
|
|
199
|
+
if (port >= 1024 && port <= 65535) portsToCheck.add(port);
|
|
197
200
|
}
|
|
201
|
+
} catch {
|
|
202
|
+
// parse failed — skip port checks rather than using defaults
|
|
203
|
+
return [];
|
|
198
204
|
}
|
|
199
205
|
|
|
200
|
-
// If no ports found in scripts, check common defaults
|
|
206
|
+
// If no ports found in scripts, check common defaults.
|
|
207
|
+
// Filter out port 5000 on macOS — AirPlay Receiver uses it by default (#1381).
|
|
201
208
|
if (portsToCheck.size === 0) {
|
|
202
|
-
for (const p of DEFAULT_DEV_PORTS)
|
|
209
|
+
for (const p of DEFAULT_DEV_PORTS) {
|
|
210
|
+
if (p === 5000 && process.platform === "darwin") continue;
|
|
211
|
+
portsToCheck.add(p);
|
|
212
|
+
}
|
|
203
213
|
}
|
|
204
214
|
|
|
205
215
|
for (const port of portsToCheck) {
|
|
@@ -590,7 +590,8 @@ export async function loadFile(path: string): Promise<string | null> {
|
|
|
590
590
|
try {
|
|
591
591
|
return await fs.readFile(path, 'utf-8');
|
|
592
592
|
} catch (err: unknown) {
|
|
593
|
-
|
|
593
|
+
const code = (err as NodeJS.ErrnoException).code;
|
|
594
|
+
if (code === 'ENOENT' || code === 'EISDIR') return null;
|
|
594
595
|
throw err;
|
|
595
596
|
}
|
|
596
597
|
}
|
|
@@ -804,7 +805,7 @@ export async function inlinePriorMilestoneSummary(mid: string, base: string): Pr
|
|
|
804
805
|
* file not on disk) - callers can distinguish "no manifest" from "empty manifest".
|
|
805
806
|
*/
|
|
806
807
|
export async function getManifestStatus(
|
|
807
|
-
base: string, milestoneId: string,
|
|
808
|
+
base: string, milestoneId: string, projectRoot?: string,
|
|
808
809
|
): Promise<ManifestStatus | null> {
|
|
809
810
|
const resolvedPath = resolveMilestoneFile(base, milestoneId, 'SECRETS');
|
|
810
811
|
if (!resolvedPath) return null;
|
|
@@ -814,9 +815,18 @@ export async function getManifestStatus(
|
|
|
814
815
|
|
|
815
816
|
const manifest = parseSecretsManifest(content);
|
|
816
817
|
const keys = manifest.entries.map(e => e.key);
|
|
818
|
+
|
|
819
|
+
// Check both the base path .env AND the project root .env (#1387).
|
|
820
|
+
// In worktree mode, base is the worktree path which may not have .env.
|
|
821
|
+
// The project root's .env is where the user actually defined their keys.
|
|
817
822
|
const existingKeys = await checkExistingEnvKeys(keys, resolve(base, '.env'));
|
|
818
823
|
const existingSet = new Set(existingKeys);
|
|
819
824
|
|
|
825
|
+
if (projectRoot && projectRoot !== base) {
|
|
826
|
+
const rootKeys = await checkExistingEnvKeys(keys, resolve(projectRoot, '.env'));
|
|
827
|
+
for (const k of rootKeys) existingSet.add(k);
|
|
828
|
+
}
|
|
829
|
+
|
|
820
830
|
const result: ManifestStatus = {
|
|
821
831
|
pending: [],
|
|
822
832
|
collected: [],
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { join } from "node:path";
|
|
10
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
-
import { nativeRmCached } from "./native-git-bridge.js";
|
|
10
|
+
import { existsSync, lstatSync, readFileSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { nativeRmCached, nativeLsFiles } from "./native-git-bridge.js";
|
|
12
12
|
import { gsdRoot } from "./paths.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -79,12 +79,47 @@ const BASELINE_PATTERNS = [
|
|
|
79
79
|
];
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
82
|
+
* Check whether `.gsd/` contains files tracked by git.
|
|
83
|
+
* If so, the project intentionally keeps `.gsd/` in version control
|
|
84
|
+
* and we must NOT add `.gsd` to `.gitignore` or attempt migration.
|
|
85
|
+
*
|
|
86
|
+
* Returns true if git tracks at least one file under `.gsd/`.
|
|
87
|
+
* Returns false (safe to ignore) if:
|
|
88
|
+
* - Not a git repo
|
|
89
|
+
* - `.gsd/` is a symlink (external state, should be ignored)
|
|
90
|
+
* - `.gsd/` doesn't exist
|
|
91
|
+
* - No tracked files found under `.gsd/`
|
|
92
|
+
*/
|
|
93
|
+
export function hasGitTrackedGsdFiles(basePath: string): boolean {
|
|
94
|
+
const localGsd = join(basePath, ".gsd");
|
|
95
|
+
|
|
96
|
+
// If .gsd doesn't exist or is already a symlink, no tracked files concern
|
|
97
|
+
if (!existsSync(localGsd)) return false;
|
|
98
|
+
try {
|
|
99
|
+
if (lstatSync(localGsd).isSymbolicLink()) return false;
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Check if git tracks any files under .gsd/
|
|
105
|
+
try {
|
|
106
|
+
const tracked = nativeLsFiles(basePath, ".gsd");
|
|
107
|
+
return tracked.length > 0;
|
|
108
|
+
} catch {
|
|
109
|
+
// Not a git repo or git not available — safe to proceed
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Ensure basePath/.gitignore contains baseline ignore patterns.
|
|
116
|
+
* Creates the file if missing; appends missing patterns.
|
|
84
117
|
* Returns true if the file was created or modified, false if already complete.
|
|
85
118
|
*
|
|
86
|
-
* `.gsd/`
|
|
87
|
-
*
|
|
119
|
+
* **Safety check:** If `.gsd/` contains git-tracked files (i.e., the project
|
|
120
|
+
* intentionally keeps `.gsd/` in version control), the `.gsd` ignore pattern
|
|
121
|
+
* is excluded to prevent data loss. Only the `.gsd` pattern is affected —
|
|
122
|
+
* all other baseline patterns are still applied normally.
|
|
88
123
|
*/
|
|
89
124
|
export function ensureGitignore(
|
|
90
125
|
basePath: string,
|
|
@@ -108,8 +143,15 @@ export function ensureGitignore(
|
|
|
108
143
|
.filter((l) => l && !l.startsWith("#")),
|
|
109
144
|
);
|
|
110
145
|
|
|
146
|
+
// Determine which patterns to apply. If .gsd/ has tracked files,
|
|
147
|
+
// exclude the ".gsd" pattern to prevent deleting tracked state.
|
|
148
|
+
const gsdIsTracked = hasGitTrackedGsdFiles(basePath);
|
|
149
|
+
const patternsToApply = gsdIsTracked
|
|
150
|
+
? BASELINE_PATTERNS.filter((p) => p !== ".gsd")
|
|
151
|
+
: BASELINE_PATTERNS;
|
|
152
|
+
|
|
111
153
|
// Find patterns not yet present
|
|
112
|
-
const missing =
|
|
154
|
+
const missing = patternsToApply.filter((p) => !existingLines.has(p));
|
|
113
155
|
|
|
114
156
|
if (missing.length === 0) return false;
|
|
115
157
|
|
|
@@ -135,6 +177,11 @@ export function ensureGitignore(
|
|
|
135
177
|
* already in the index even after .gitignore is updated.
|
|
136
178
|
*
|
|
137
179
|
* Only removes from the index (`--cached`), never from disk. Idempotent.
|
|
180
|
+
*
|
|
181
|
+
* Note: These are strictly runtime/ephemeral paths (activity logs, lock files,
|
|
182
|
+
* metrics, STATE.md). They are always safe to untrack, even when the project
|
|
183
|
+
* intentionally keeps other `.gsd/` files (like PROJECT.md, milestones/) in
|
|
184
|
+
* version control.
|
|
138
185
|
*/
|
|
139
186
|
export function untrackRuntimeFiles(basePath: string): void {
|
|
140
187
|
const runtimePaths = GSD_RUNTIME_PATTERNS;
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from "./paths.js";
|
|
24
24
|
import { join } from "node:path";
|
|
25
25
|
import { readFileSync, existsSync, mkdirSync, readdirSync, rmSync, unlinkSync } from "node:fs";
|
|
26
|
+
import { readSessionLockData, isSessionLockProcessAlive } from "./session-lock.js";
|
|
26
27
|
import { nativeIsRepo, nativeInit } from "./native-git-bridge.js";
|
|
27
28
|
import { ensureGitignore, ensurePreferences, untrackRuntimeFiles } from "./gitignore.js";
|
|
28
29
|
import { loadEffectiveGSDPreferences } from "./preferences.js";
|
|
@@ -191,7 +192,7 @@ type UIContext = ExtensionContext;
|
|
|
191
192
|
* This is the only way the wizard triggers work — everything else is the LLM's job.
|
|
192
193
|
*/
|
|
193
194
|
function dispatchWorkflow(pi: ExtensionAPI, note: string, customType = "gsd-run"): void {
|
|
194
|
-
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(process.env.HOME ?? "~", ".
|
|
195
|
+
const workflowPath = process.env.GSD_WORKFLOW_PATH ?? join(process.env.HOME ?? "~", ".gsd", "agent", "GSD-WORKFLOW.md");
|
|
195
196
|
const workflow = readFileSync(workflowPath, "utf-8");
|
|
196
197
|
|
|
197
198
|
pi.sendMessage(
|
|
@@ -516,8 +517,13 @@ export async function showDiscuss(
|
|
|
516
517
|
// If all pending slices are discussed, notify and exit instead of looping
|
|
517
518
|
const allDiscussed = pendingSlices.every(s => discussedMap.get(s.id));
|
|
518
519
|
if (allDiscussed) {
|
|
520
|
+
const lockData = readSessionLockData(basePath);
|
|
521
|
+
const remoteAutoRunning = lockData && lockData.pid !== process.pid && isSessionLockProcessAlive(lockData);
|
|
522
|
+
const nextStep = remoteAutoRunning
|
|
523
|
+
? "Auto-mode is already running — use /gsd status to check progress."
|
|
524
|
+
: "Run /gsd to start planning.";
|
|
519
525
|
ctx.ui.notify(
|
|
520
|
-
`All ${pendingSlices.length} slices discussed.
|
|
526
|
+
`All ${pendingSlices.length} slices discussed. ${nextStep}`,
|
|
521
527
|
"info",
|
|
522
528
|
);
|
|
523
529
|
return;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure GSD health widget logic.
|
|
3
|
+
*
|
|
4
|
+
* Separates project-state detection and line rendering from the widget's
|
|
5
|
+
* runtime integrations so the regressions can be tested directly.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
9
|
+
import { gsdRoot } from "./paths.js";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import type { GSDState, Phase } from "./types.js";
|
|
12
|
+
|
|
13
|
+
export type HealthWidgetProjectState = "none" | "initialized" | "active";
|
|
14
|
+
|
|
15
|
+
export interface HealthWidgetData {
|
|
16
|
+
projectState: HealthWidgetProjectState;
|
|
17
|
+
budgetCeiling: number | undefined;
|
|
18
|
+
budgetSpent: number;
|
|
19
|
+
providerIssue: string | null;
|
|
20
|
+
environmentErrorCount: number;
|
|
21
|
+
environmentWarningCount: number;
|
|
22
|
+
lastRefreshed: number;
|
|
23
|
+
executionPhase?: Phase;
|
|
24
|
+
executionStatus?: string;
|
|
25
|
+
executionTarget?: string;
|
|
26
|
+
nextAction?: string;
|
|
27
|
+
blocker?: string | null;
|
|
28
|
+
activeMilestoneId?: string;
|
|
29
|
+
activeSliceId?: string;
|
|
30
|
+
activeTaskId?: string;
|
|
31
|
+
progress?: GSDState["progress"];
|
|
32
|
+
eta?: string | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function detectHealthWidgetProjectState(basePath: string): HealthWidgetProjectState {
|
|
36
|
+
const root = gsdRoot(basePath);
|
|
37
|
+
if (!existsSync(root)) return "none";
|
|
38
|
+
|
|
39
|
+
// Lightweight milestone count — avoids the full detectProjectState() scan
|
|
40
|
+
// (CI markers, Makefile targets, etc.) that is unnecessary on the 60s refresh.
|
|
41
|
+
try {
|
|
42
|
+
const milestonesDir = join(root, "milestones");
|
|
43
|
+
if (existsSync(milestonesDir)) {
|
|
44
|
+
const entries = readdirSync(milestonesDir, { withFileTypes: true });
|
|
45
|
+
if (entries.some(e => e.isDirectory())) return "active";
|
|
46
|
+
}
|
|
47
|
+
} catch { /* non-fatal */ }
|
|
48
|
+
|
|
49
|
+
return "initialized";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function formatCost(n: number): string {
|
|
53
|
+
return n >= 1 ? `$${n.toFixed(2)}` : `${(n * 100).toFixed(1)}¢`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function formatProgress(progress?: GSDState["progress"]): string | null {
|
|
57
|
+
if (!progress) return null;
|
|
58
|
+
|
|
59
|
+
const parts: string[] = [];
|
|
60
|
+
parts.push(`M ${progress.milestones.done}/${progress.milestones.total}`);
|
|
61
|
+
if (progress.slices) parts.push(`S ${progress.slices.done}/${progress.slices.total}`);
|
|
62
|
+
if (progress.tasks) parts.push(`T ${progress.tasks.done}/${progress.tasks.total}`);
|
|
63
|
+
return parts.length > 0 ? `Progress: ${parts.join(" · ")}` : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function formatEnvironmentSummary(errorCount: number, warningCount: number): string | null {
|
|
67
|
+
if (errorCount <= 0 && warningCount <= 0) return null;
|
|
68
|
+
|
|
69
|
+
const parts: string[] = [];
|
|
70
|
+
if (errorCount > 0) parts.push(`${errorCount} error${errorCount > 1 ? "s" : ""}`);
|
|
71
|
+
if (warningCount > 0) parts.push(`${warningCount} warning${warningCount > 1 ? "s" : ""}`);
|
|
72
|
+
return `Env: ${parts.join(", ")}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function formatBudgetSummary(data: HealthWidgetData): string | null {
|
|
76
|
+
if (data.budgetCeiling !== undefined && data.budgetCeiling > 0) {
|
|
77
|
+
const pct = Math.min(100, (data.budgetSpent / data.budgetCeiling) * 100);
|
|
78
|
+
return `Budget: ${formatCost(data.budgetSpent)}/${formatCost(data.budgetCeiling)} (${pct.toFixed(0)}%)`;
|
|
79
|
+
}
|
|
80
|
+
if (data.budgetSpent > 0) {
|
|
81
|
+
return `Spent: ${formatCost(data.budgetSpent)}`;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function buildExecutionHeadline(data: HealthWidgetData): string {
|
|
87
|
+
const status = data.executionStatus ?? "Active project";
|
|
88
|
+
const target = data.executionTarget ?? data.blocker ?? "loading status…";
|
|
89
|
+
return ` GSD ${status}${target ? ` - ${target}` : ""}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Build compact health lines for the widget.
|
|
94
|
+
* Returns a string array suitable for setWidget().
|
|
95
|
+
*/
|
|
96
|
+
export function buildHealthLines(data: HealthWidgetData): string[] {
|
|
97
|
+
if (data.projectState === "none") {
|
|
98
|
+
return [" GSD No project loaded — run /gsd to start"];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (data.projectState === "initialized") {
|
|
102
|
+
return [" GSD Project initialized — run /gsd to continue setup"];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const lines = [buildExecutionHeadline(data)];
|
|
106
|
+
const details: string[] = [];
|
|
107
|
+
|
|
108
|
+
const progress = formatProgress(data.progress);
|
|
109
|
+
if (progress) details.push(progress);
|
|
110
|
+
|
|
111
|
+
if (data.providerIssue) details.push(data.providerIssue);
|
|
112
|
+
|
|
113
|
+
const environment = formatEnvironmentSummary(
|
|
114
|
+
data.environmentErrorCount,
|
|
115
|
+
data.environmentWarningCount,
|
|
116
|
+
);
|
|
117
|
+
if (environment) details.push(environment);
|
|
118
|
+
|
|
119
|
+
const budget = formatBudgetSummary(data);
|
|
120
|
+
if (budget) details.push(budget);
|
|
121
|
+
|
|
122
|
+
if (data.eta) details.push(data.eta);
|
|
123
|
+
|
|
124
|
+
if (details.length > 0) {
|
|
125
|
+
lines.push(` ${details.join(" │ ")}`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return lines;
|
|
129
|
+
}
|
|
@@ -9,41 +9,37 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { ExtensionContext } from "@gsd/pi-coding-agent";
|
|
12
|
+
import type { GSDState } from "./types.js";
|
|
12
13
|
import { runProviderChecks, summariseProviderIssues } from "./doctor-providers.js";
|
|
13
14
|
import { runEnvironmentChecks } from "./doctor-environment.js";
|
|
14
15
|
import { loadEffectiveGSDPreferences } from "./preferences.js";
|
|
15
16
|
import { loadLedgerFromDisk, getProjectTotals } from "./metrics.js";
|
|
17
|
+
import { describeNextUnit, estimateTimeRemaining, updateSliceProgressCache } from "./auto-dashboard.js";
|
|
16
18
|
import { projectRoot } from "./commands.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
budgetSpent: number;
|
|
24
|
-
providerIssue: string | null; // compact summary from summariseProviderIssues()
|
|
25
|
-
environmentErrorCount: number;
|
|
26
|
-
environmentWarningCount: number;
|
|
27
|
-
lastRefreshed: number;
|
|
28
|
-
}
|
|
19
|
+
import { deriveState, invalidateStateCache } from "./state.js";
|
|
20
|
+
import {
|
|
21
|
+
buildHealthLines,
|
|
22
|
+
detectHealthWidgetProjectState,
|
|
23
|
+
type HealthWidgetData,
|
|
24
|
+
} from "./health-widget-core.js";
|
|
29
25
|
|
|
30
26
|
// ── Data loader ────────────────────────────────────────────────────────────────
|
|
31
27
|
|
|
32
|
-
function
|
|
33
|
-
let hasProject = false;
|
|
28
|
+
function loadBaseHealthWidgetData(basePath: string): HealthWidgetData {
|
|
34
29
|
let budgetCeiling: number | undefined;
|
|
35
30
|
let budgetSpent = 0;
|
|
36
31
|
let providerIssue: string | null = null;
|
|
37
32
|
let environmentErrorCount = 0;
|
|
38
33
|
let environmentWarningCount = 0;
|
|
39
34
|
|
|
35
|
+
const projectState = detectHealthWidgetProjectState(basePath);
|
|
36
|
+
|
|
40
37
|
try {
|
|
41
38
|
const prefs = loadEffectiveGSDPreferences();
|
|
42
39
|
budgetCeiling = prefs?.preferences?.budget_ceiling;
|
|
43
40
|
|
|
44
41
|
const ledger = loadLedgerFromDisk(basePath);
|
|
45
42
|
if (ledger) {
|
|
46
|
-
hasProject = true;
|
|
47
43
|
const totals = getProjectTotals(ledger.units ?? []);
|
|
48
44
|
budgetSpent = totals.cost;
|
|
49
45
|
}
|
|
@@ -63,7 +59,7 @@ function loadHealthWidgetData(basePath: string): HealthWidgetData {
|
|
|
63
59
|
} catch { /* non-fatal */ }
|
|
64
60
|
|
|
65
61
|
return {
|
|
66
|
-
|
|
62
|
+
projectState,
|
|
67
63
|
budgetCeiling,
|
|
68
64
|
budgetSpent,
|
|
69
65
|
providerIssue,
|
|
@@ -73,54 +69,88 @@ function loadHealthWidgetData(basePath: string): HealthWidgetData {
|
|
|
73
69
|
};
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return
|
|
72
|
+
function compactText(text: string, max = 64): string {
|
|
73
|
+
const trimmed = text.replace(/\s+/g, " ").trim();
|
|
74
|
+
if (trimmed.length <= max) return trimmed;
|
|
75
|
+
return `${trimmed.slice(0, max - 1).trimEnd()}…`;
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
function summarizeExecutionStatus(state: GSDState): string {
|
|
79
|
+
switch (state.phase) {
|
|
80
|
+
case "blocked": return "Blocked";
|
|
81
|
+
case "paused": return "Paused";
|
|
82
|
+
case "complete": return "Complete";
|
|
83
|
+
case "executing": return "Executing";
|
|
84
|
+
case "planning": return "Planning";
|
|
85
|
+
case "pre-planning": return "Pre-planning";
|
|
86
|
+
case "summarizing": return "Summarizing";
|
|
87
|
+
case "validating-milestone": return "Validating";
|
|
88
|
+
case "completing-milestone": return "Completing";
|
|
89
|
+
case "needs-discussion": return "Needs discussion";
|
|
90
|
+
case "replanning-slice": return "Replanning";
|
|
91
|
+
default: return "Active";
|
|
89
92
|
}
|
|
93
|
+
}
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
function summarizeExecutionTarget(state: GSDState): string {
|
|
96
|
+
switch (state.phase) {
|
|
97
|
+
case "needs-discussion":
|
|
98
|
+
return state.activeMilestone ? `Discuss ${state.activeMilestone.id}` : "Discuss milestone draft";
|
|
99
|
+
case "pre-planning":
|
|
100
|
+
return state.activeMilestone ? `Plan ${state.activeMilestone.id}` : "Research & plan milestone";
|
|
101
|
+
case "planning":
|
|
102
|
+
return state.activeSlice ? `Plan ${state.activeSlice.id}` : "Plan next slice";
|
|
103
|
+
case "executing":
|
|
104
|
+
return state.activeTask ? `Execute ${state.activeTask.id}` : "Execute next task";
|
|
105
|
+
case "summarizing":
|
|
106
|
+
return state.activeSlice ? `Complete ${state.activeSlice.id}` : "Complete current slice";
|
|
107
|
+
case "validating-milestone":
|
|
108
|
+
return state.activeMilestone ? `Validate ${state.activeMilestone.id}` : "Validate milestone";
|
|
109
|
+
case "completing-milestone":
|
|
110
|
+
return state.activeMilestone ? `Complete ${state.activeMilestone.id}` : "Complete milestone";
|
|
111
|
+
case "replanning-slice":
|
|
112
|
+
return state.activeSlice ? `Replan ${state.activeSlice.id}` : "Replan current slice";
|
|
113
|
+
case "blocked":
|
|
114
|
+
return `waiting on ${compactText(state.blockers[0] ?? state.nextAction, 56)}`;
|
|
115
|
+
case "paused":
|
|
116
|
+
return compactText(state.nextAction || "waiting to resume", 56);
|
|
117
|
+
case "complete":
|
|
118
|
+
return "All milestones complete";
|
|
119
|
+
default:
|
|
120
|
+
return compactText(describeNextUnit(state).label, 56);
|
|
101
121
|
}
|
|
122
|
+
}
|
|
102
123
|
|
|
103
|
-
|
|
104
|
-
if (
|
|
105
|
-
const pct = Math.min(100, (data.budgetSpent / data.budgetCeiling) * 100);
|
|
106
|
-
parts.push(`Budget: ${formatCost(data.budgetSpent)}/${formatCost(data.budgetCeiling)} (${pct.toFixed(0)}%)`);
|
|
107
|
-
} else if (data.budgetSpent > 0) {
|
|
108
|
-
parts.push(`Spent: ${formatCost(data.budgetSpent)}`);
|
|
109
|
-
}
|
|
124
|
+
async function enrichHealthWidgetData(basePath: string, baseData: HealthWidgetData): Promise<HealthWidgetData> {
|
|
125
|
+
if (baseData.projectState !== "active") return baseData;
|
|
110
126
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
127
|
+
try {
|
|
128
|
+
invalidateStateCache();
|
|
129
|
+
const state = await deriveState(basePath);
|
|
115
130
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
parts.push(`Env: ${data.environmentWarningCount} warning${data.environmentWarningCount > 1 ? "s" : ""}`);
|
|
121
|
-
}
|
|
131
|
+
if (state.activeMilestone) {
|
|
132
|
+
// Warm the slice-progress cache so estimateTimeRemaining() has data
|
|
133
|
+
updateSliceProgressCache(basePath, state.activeMilestone.id, state.activeSlice?.id);
|
|
134
|
+
}
|
|
122
135
|
|
|
123
|
-
|
|
136
|
+
return {
|
|
137
|
+
...baseData,
|
|
138
|
+
executionPhase: state.phase,
|
|
139
|
+
executionStatus: summarizeExecutionStatus(state),
|
|
140
|
+
executionTarget: summarizeExecutionTarget(state),
|
|
141
|
+
nextAction: state.nextAction,
|
|
142
|
+
blocker: state.blockers[0] ?? null,
|
|
143
|
+
activeMilestoneId: state.activeMilestone?.id,
|
|
144
|
+
activeSliceId: state.activeSlice?.id,
|
|
145
|
+
activeTaskId: state.activeTask?.id,
|
|
146
|
+
progress: state.progress,
|
|
147
|
+
eta: state.phase === "blocked" || state.phase === "paused" || state.phase === "complete"
|
|
148
|
+
? null
|
|
149
|
+
: estimateTimeRemaining(),
|
|
150
|
+
};
|
|
151
|
+
} catch {
|
|
152
|
+
return baseData;
|
|
153
|
+
}
|
|
124
154
|
}
|
|
125
155
|
|
|
126
156
|
// ── Widget init ────────────────────────────────────────────────────────────────
|
|
@@ -137,20 +167,34 @@ export function initHealthWidget(ctx: ExtensionContext): void {
|
|
|
137
167
|
const basePath = projectRoot();
|
|
138
168
|
|
|
139
169
|
// String-array fallback — used in RPC mode (factory is a no-op there)
|
|
140
|
-
const initialData =
|
|
170
|
+
const initialData = loadBaseHealthWidgetData(basePath);
|
|
141
171
|
ctx.ui.setWidget("gsd-health", buildHealthLines(initialData), { placement: "belowEditor" });
|
|
142
172
|
|
|
143
173
|
// Factory-based widget for TUI mode — replaces the string-array above
|
|
144
174
|
ctx.ui.setWidget("gsd-health", (_tui, _theme) => {
|
|
145
175
|
let data = initialData;
|
|
146
176
|
let cachedLines: string[] | undefined;
|
|
177
|
+
let refreshInFlight = false;
|
|
147
178
|
|
|
148
|
-
const
|
|
179
|
+
const refresh = async () => {
|
|
180
|
+
if (refreshInFlight) return;
|
|
181
|
+
refreshInFlight = true;
|
|
149
182
|
try {
|
|
150
|
-
|
|
183
|
+
const baseData = loadBaseHealthWidgetData(basePath);
|
|
184
|
+
data = await enrichHealthWidgetData(basePath, baseData);
|
|
151
185
|
cachedLines = undefined;
|
|
152
186
|
_tui.requestRender();
|
|
153
|
-
} catch { /* non-fatal */ }
|
|
187
|
+
} catch { /* non-fatal */ } finally {
|
|
188
|
+
refreshInFlight = false;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// Fire first enrichment immediately. requestRender() inside is a no-op
|
|
193
|
+
// if the widget has not yet rendered, so this is safe before factory return.
|
|
194
|
+
void refresh();
|
|
195
|
+
|
|
196
|
+
const refreshTimer = setInterval(() => {
|
|
197
|
+
void refresh();
|
|
154
198
|
}, REFRESH_INTERVAL_MS);
|
|
155
199
|
|
|
156
200
|
return {
|