gsd-pi 2.35.0 → 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
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test utilities for GSD extension tests.
|
|
3
|
+
*
|
|
4
|
+
* Provides cross-platform helpers for creating temporary git repos,
|
|
5
|
+
* safe cleanup, file creation, and shell-free git operations.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { git, makeTempRepo, cleanup, createFile } from "./test-utils.ts";
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
import {
|
|
13
|
+
existsSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
mkdtempSync,
|
|
16
|
+
readFileSync,
|
|
17
|
+
rmSync,
|
|
18
|
+
statSync,
|
|
19
|
+
writeFileSync,
|
|
20
|
+
} from "node:fs";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Shell-free git helper — uses execFileSync to bypass shell entirely.
|
|
26
|
+
* No quoting issues, no Windows cmd.exe incompatibilities.
|
|
27
|
+
*
|
|
28
|
+
* @param cwd - Working directory for git command
|
|
29
|
+
* @param args - Git arguments (e.g., "add", "-A")
|
|
30
|
+
* @returns trimmed stdout
|
|
31
|
+
*/
|
|
32
|
+
export function git(cwd: string, ...args: string[]): string {
|
|
33
|
+
return execFileSync("git", args, {
|
|
34
|
+
cwd,
|
|
35
|
+
encoding: "utf-8",
|
|
36
|
+
stdio: "pipe",
|
|
37
|
+
}).trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a temporary git repository with an initial commit.
|
|
42
|
+
* Configures user.email, user.name, and core.autocrlf=false for
|
|
43
|
+
* consistent behavior across platforms.
|
|
44
|
+
*
|
|
45
|
+
* @param prefix - Optional prefix for the temp directory name
|
|
46
|
+
* @returns absolute path to the temp repo
|
|
47
|
+
*/
|
|
48
|
+
export function makeTempRepo(prefix: string = "gsd-test-"): string {
|
|
49
|
+
const dir = mkdtempSync(join(tmpdir(), prefix));
|
|
50
|
+
git(dir, "init");
|
|
51
|
+
git(dir, "config", "user.email", "test@test.com");
|
|
52
|
+
git(dir, "config", "user.name", "Test");
|
|
53
|
+
git(dir, "config", "core.autocrlf", "false");
|
|
54
|
+
writeFileSync(join(dir, "README.md"), "# init\n");
|
|
55
|
+
git(dir, "add", "-A");
|
|
56
|
+
git(dir, "commit", "-m", "init");
|
|
57
|
+
git(dir, "branch", "-M", "main");
|
|
58
|
+
return dir;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Create a temporary directory (not a git repo).
|
|
63
|
+
*
|
|
64
|
+
* @param prefix - Optional prefix for the temp directory name
|
|
65
|
+
* @returns absolute path to the temp directory
|
|
66
|
+
*/
|
|
67
|
+
export function makeTempDir(prefix: string = "gsd-test-"): string {
|
|
68
|
+
return mkdtempSync(join(tmpdir(), prefix));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Safely clean up a temporary directory.
|
|
73
|
+
* Non-fatal — Windows may hold file descriptors briefly.
|
|
74
|
+
*/
|
|
75
|
+
export function cleanup(dir: string): void {
|
|
76
|
+
try {
|
|
77
|
+
rmSync(dir, { recursive: true, force: true });
|
|
78
|
+
} catch {
|
|
79
|
+
// ignore — Windows may hold file descriptors briefly after test
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create a file with intermediate directories.
|
|
85
|
+
*
|
|
86
|
+
* @param base - Base directory
|
|
87
|
+
* @param relativePath - Relative path within base (e.g., "src/index.ts")
|
|
88
|
+
* @param content - File content (defaults to empty string)
|
|
89
|
+
* @returns absolute path to the created file
|
|
90
|
+
*/
|
|
91
|
+
export function createFile(base: string, relativePath: string, content: string = ""): string {
|
|
92
|
+
const fullPath = join(base, relativePath);
|
|
93
|
+
mkdirSync(dirname(fullPath), { recursive: true });
|
|
94
|
+
writeFileSync(fullPath, content, "utf-8");
|
|
95
|
+
return fullPath;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Safely read a file, returning null if it doesn't exist or is a directory.
|
|
100
|
+
* Prevents EISDIR errors.
|
|
101
|
+
*/
|
|
102
|
+
export function safeReadFile(filePath: string): string | null {
|
|
103
|
+
try {
|
|
104
|
+
if (!existsSync(filePath)) return null;
|
|
105
|
+
if (!statSync(filePath).isFile()) return null;
|
|
106
|
+
return readFileSync(filePath, "utf-8");
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Create a minimal GSD milestone structure in a temp directory.
|
|
114
|
+
*
|
|
115
|
+
* @param base - Base directory (should have .gsd/ or be a temp repo)
|
|
116
|
+
* @param mid - Milestone ID (e.g., "M001")
|
|
117
|
+
* @param options - What to create
|
|
118
|
+
*/
|
|
119
|
+
export function writeMilestoneFixture(
|
|
120
|
+
base: string,
|
|
121
|
+
mid: string,
|
|
122
|
+
options: {
|
|
123
|
+
roadmap?: string;
|
|
124
|
+
context?: string;
|
|
125
|
+
summary?: string;
|
|
126
|
+
validation?: string;
|
|
127
|
+
slices?: Array<{
|
|
128
|
+
id: string;
|
|
129
|
+
plan?: string;
|
|
130
|
+
summary?: string;
|
|
131
|
+
uat?: string;
|
|
132
|
+
}>;
|
|
133
|
+
} = {},
|
|
134
|
+
): void {
|
|
135
|
+
const milestoneDir = join(base, ".gsd", "milestones", mid);
|
|
136
|
+
mkdirSync(milestoneDir, { recursive: true });
|
|
137
|
+
|
|
138
|
+
if (options.roadmap) {
|
|
139
|
+
writeFileSync(join(milestoneDir, `${mid}-ROADMAP.md`), options.roadmap);
|
|
140
|
+
}
|
|
141
|
+
if (options.context) {
|
|
142
|
+
writeFileSync(join(milestoneDir, `${mid}-CONTEXT.md`), options.context);
|
|
143
|
+
}
|
|
144
|
+
if (options.summary) {
|
|
145
|
+
writeFileSync(join(milestoneDir, `${mid}-SUMMARY.md`), options.summary);
|
|
146
|
+
}
|
|
147
|
+
if (options.validation) {
|
|
148
|
+
writeFileSync(join(milestoneDir, `${mid}-VALIDATION.md`), options.validation);
|
|
149
|
+
}
|
|
150
|
+
if (options.slices) {
|
|
151
|
+
for (const slice of options.slices) {
|
|
152
|
+
const sliceDir = join(milestoneDir, "slices", slice.id);
|
|
153
|
+
mkdirSync(sliceDir, { recursive: true });
|
|
154
|
+
if (slice.plan) {
|
|
155
|
+
writeFileSync(join(sliceDir, `${slice.id}-PLAN.md`), slice.plan);
|
|
156
|
+
}
|
|
157
|
+
if (slice.summary) {
|
|
158
|
+
writeFileSync(join(sliceDir, `${slice.id}-SUMMARY.md`), slice.summary);
|
|
159
|
+
}
|
|
160
|
+
if (slice.uat) {
|
|
161
|
+
writeFileSync(join(sliceDir, `${slice.id}-UAT.md`), slice.uat);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -101,6 +101,21 @@ test("validateDirectory: subdirectory of home is NOT blocked", () => {
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
// Regression test for #1317: GSD worktree inside $HOME must not be blocked even
|
|
105
|
+
// when the resolved project root equals $HOME (e.g. home dir is a git repo).
|
|
106
|
+
test("validateDirectory: GSD worktree path nested under home is NOT blocked (#1317)", () => {
|
|
107
|
+
const worktreePath = join(homedir(), ".gsd", "worktrees", "M001");
|
|
108
|
+
mkdirSync(worktreePath, { recursive: true });
|
|
109
|
+
try {
|
|
110
|
+
// The worktree CWD itself is a valid location — it must pass.
|
|
111
|
+
const result = validateDirectory(worktreePath);
|
|
112
|
+
assert.equal(result.safe, true, "GSD worktree path should be safe to run in");
|
|
113
|
+
assert.equal(result.severity, "ok");
|
|
114
|
+
} finally {
|
|
115
|
+
rmSync(join(homedir(), ".gsd", "worktrees", "M001"), { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
104
119
|
// ─── Temp directory root ─────────────────────────────────────────────────────────
|
|
105
120
|
|
|
106
121
|
test("validateDirectory: temp directory root is blocked", () => {
|
|
@@ -104,6 +104,11 @@ test("isValidationTerminal returns true for verdict: needs-remediation (#832)",
|
|
|
104
104
|
assert.equal(isValidationTerminal(content), true);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
+
test("isValidationTerminal returns true for verdict: passed (#1429)", () => {
|
|
108
|
+
const content = "---\nverdict: passed\nremediation_round: 0\n---\n\n# Validation";
|
|
109
|
+
assert.equal(isValidationTerminal(content), true);
|
|
110
|
+
});
|
|
111
|
+
|
|
107
112
|
test("isValidationTerminal returns false for missing frontmatter", () => {
|
|
108
113
|
const content = "# Validation\nNo frontmatter here.";
|
|
109
114
|
assert.equal(isValidationTerminal(content), false);
|
|
@@ -196,6 +201,7 @@ test("dispatch rule matches validating-milestone phase", async () => {
|
|
|
196
201
|
try {
|
|
197
202
|
// Set up minimal milestone structure for the prompt builder
|
|
198
203
|
writeRoadmap(base, "M001", ALL_DONE_ROADMAP);
|
|
204
|
+
writeSliceSummary(base, "M001", "S01", "# S01 Summary\nDone."); // Guard requires slice summaries (#1368)
|
|
199
205
|
|
|
200
206
|
const ctx: DispatchContext = {
|
|
201
207
|
basePath: base,
|
|
@@ -231,6 +237,7 @@ test("dispatch rule skips when skip_milestone_validation preference is set", asy
|
|
|
231
237
|
const base = makeTmpBase();
|
|
232
238
|
try {
|
|
233
239
|
writeRoadmap(base, "M001", ALL_DONE_ROADMAP);
|
|
240
|
+
writeSliceSummary(base, "M001", "S01", "# S01 Summary\nDone."); // Guard requires slice summaries (#1368)
|
|
234
241
|
|
|
235
242
|
const ctx: DispatchContext = {
|
|
236
243
|
basePath: base,
|
|
@@ -19,6 +19,7 @@ import { join } from 'node:path';
|
|
|
19
19
|
import { tmpdir } from 'node:os';
|
|
20
20
|
|
|
21
21
|
import { syncProjectRootToWorktree } from '../auto-worktree-sync.ts';
|
|
22
|
+
import { syncGsdStateToWorktree } from '../auto-worktree.ts';
|
|
22
23
|
import { createTestContext } from './test-helpers.ts';
|
|
23
24
|
|
|
24
25
|
const { assertTrue, report } = createTestContext();
|
|
@@ -148,6 +149,37 @@ async function main(): Promise<void> {
|
|
|
148
149
|
assertTrue(true, 'no crash on missing directories');
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
// ─── 7. milestones/ directory created in worktree when missing ────────
|
|
153
|
+
console.log('\n=== 7. milestones/ directory created in worktree when missing ===');
|
|
154
|
+
{
|
|
155
|
+
const mainBase = createBase('main');
|
|
156
|
+
const wtBase = mkdtempSync(join(tmpdir(), 'gsd-wt-sync-wt-'));
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
// Worktree has .gsd/ but NO milestones/ subdirectory
|
|
160
|
+
mkdirSync(join(wtBase, '.gsd'), { recursive: true });
|
|
161
|
+
|
|
162
|
+
// Main repo has M001
|
|
163
|
+
const m001Dir = join(mainBase, '.gsd', 'milestones', 'M001');
|
|
164
|
+
mkdirSync(m001Dir, { recursive: true });
|
|
165
|
+
writeFileSync(join(m001Dir, 'M001-CONTEXT.md'), '# M001 Context');
|
|
166
|
+
writeFileSync(join(m001Dir, 'M001-ROADMAP.md'), '# M001 Roadmap');
|
|
167
|
+
|
|
168
|
+
assertTrue(!existsSync(join(wtBase, '.gsd', 'milestones')), 'milestones/ missing before sync');
|
|
169
|
+
|
|
170
|
+
const result = syncGsdStateToWorktree(mainBase, wtBase);
|
|
171
|
+
|
|
172
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones')), 'milestones/ created in worktree');
|
|
173
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones', 'M001')), 'M001 synced to worktree');
|
|
174
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones', 'M001', 'M001-CONTEXT.md')), 'M001 CONTEXT synced');
|
|
175
|
+
assertTrue(existsSync(join(wtBase, '.gsd', 'milestones', 'M001', 'M001-ROADMAP.md')), 'M001 ROADMAP synced');
|
|
176
|
+
assertTrue(result.synced.length > 0, 'sync reported files');
|
|
177
|
+
} finally {
|
|
178
|
+
cleanup(mainBase);
|
|
179
|
+
rmSync(wtBase, { recursive: true, force: true });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
151
183
|
report();
|
|
152
184
|
}
|
|
153
185
|
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* `process.chdir()` internally — this class MUST NOT double-chdir.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import { existsSync, unlinkSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
16
18
|
import type { AutoSession } from "./auto/session.js";
|
|
17
19
|
import { debugLog } from "./debug-logger.js";
|
|
18
20
|
|
|
@@ -372,6 +374,15 @@ export class WorktreeResolver {
|
|
|
372
374
|
});
|
|
373
375
|
ctx.notify(`Milestone merge failed: ${msg}`, "warning");
|
|
374
376
|
|
|
377
|
+
// Clean up stale merge state left by failed squash-merge (#1389)
|
|
378
|
+
try {
|
|
379
|
+
const gitDir = join(originalBase || this.s.basePath, ".git");
|
|
380
|
+
for (const f of ["SQUASH_MSG", "MERGE_HEAD", "MERGE_MSG"]) {
|
|
381
|
+
const p = join(gitDir, f);
|
|
382
|
+
if (existsSync(p)) unlinkSync(p);
|
|
383
|
+
}
|
|
384
|
+
} catch { /* best-effort */ }
|
|
385
|
+
|
|
375
386
|
// Error recovery: always restore to project root
|
|
376
387
|
if (originalBase) {
|
|
377
388
|
try {
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import type { ExtensionAPI, ExtensionCommandContext } from "@gsd/pi-coding-agent";
|
|
6
6
|
import { AuthStorage } from "@gsd/pi-coding-agent";
|
|
7
|
-
import {
|
|
7
|
+
import { Editor, type EditorTheme, Key, matchesKey, truncateToWidth } from "@gsd/pi-tui";
|
|
8
8
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
9
9
|
import { dirname, join } from "node:path";
|
|
10
10
|
import { getGlobalGSDPreferencesPath, loadEffectiveGSDPreferences } from "../gsd/preferences.js";
|
|
11
11
|
import { getRemoteConfigStatus, isValidChannelId, resolveRemoteConfig } from "./config.js";
|
|
12
|
-
import { sanitizeError } from "../shared/
|
|
12
|
+
import { maskEditorLine, sanitizeError } from "../shared/mod.js";
|
|
13
13
|
import { getLatestPromptSummary } from "./status.js";
|
|
14
14
|
|
|
15
15
|
export async function handleRemote(
|
|
@@ -353,27 +353,6 @@ function removeRemoteQuestionsConfig(): void {
|
|
|
353
353
|
writeFileSync(prefsPath, next, "utf-8");
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
function maskEditorLine(line: string): string {
|
|
357
|
-
let output = "";
|
|
358
|
-
let i = 0;
|
|
359
|
-
while (i < line.length) {
|
|
360
|
-
if (line.startsWith(CURSOR_MARKER, i)) {
|
|
361
|
-
output += CURSOR_MARKER;
|
|
362
|
-
i += CURSOR_MARKER.length;
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
const ansiMatch = /^\x1b\[[0-9;]*m/.exec(line.slice(i));
|
|
366
|
-
if (ansiMatch) {
|
|
367
|
-
output += ansiMatch[0];
|
|
368
|
-
i += ansiMatch[0].length;
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
output += line[i] === " " ? " " : "*";
|
|
372
|
-
i += 1;
|
|
373
|
-
}
|
|
374
|
-
return output;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
356
|
async function promptMaskedInput(ctx: ExtensionCommandContext, label: string, hint: string): Promise<string | null> {
|
|
378
357
|
if (!ctx.hasUI) return null;
|
|
379
358
|
return ctx.ui.custom<string | null>((tui: any, theme: any, _kb: any, done: (r: string | null) => void) => {
|
|
@@ -28,6 +28,6 @@ export { showInterviewRound } from "./interview-ui.js";
|
|
|
28
28
|
export type { Question, QuestionOption, RoundResult } from "./interview-ui.js";
|
|
29
29
|
export { showNextAction } from "./next-action-ui.js";
|
|
30
30
|
export { showConfirm } from "./confirm-ui.js";
|
|
31
|
-
export { sanitizeError } from "./sanitize.js";
|
|
31
|
+
export { sanitizeError, maskEditorLine } from "./sanitize.js";
|
|
32
32
|
export { formatDateShort, truncateWithEllipsis } from "./format-utils.js";
|
|
33
33
|
export { splitFrontmatter, parseFrontmatterMap } from "./frontmatter.js";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sanitize error messages by redacting token-like strings before surfacing.
|
|
3
|
+
* Also provides maskEditorLine for masking sensitive TUI editor input.
|
|
3
4
|
*/
|
|
4
5
|
|
|
6
|
+
import { CURSOR_MARKER } from "@gsd/pi-tui";
|
|
7
|
+
|
|
5
8
|
const TOKEN_PATTERNS = [
|
|
6
9
|
/xoxb-[A-Za-z0-9\-]+/g, // Slack bot tokens
|
|
7
10
|
/xoxp-[A-Za-z0-9\-]+/g, // Slack user tokens
|
|
@@ -17,3 +20,36 @@ export function sanitizeError(msg: string): string {
|
|
|
17
20
|
}
|
|
18
21
|
return sanitized;
|
|
19
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Replace editor visible text with masked characters while preserving
|
|
26
|
+
* ANSI cursor/sequencer codes. Keeps border/metadata lines readable.
|
|
27
|
+
*/
|
|
28
|
+
export function maskEditorLine(line: string): string {
|
|
29
|
+
if (line.startsWith("─")) {
|
|
30
|
+
return line;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let output = "";
|
|
34
|
+
let i = 0;
|
|
35
|
+
while (i < line.length) {
|
|
36
|
+
if (line.startsWith(CURSOR_MARKER, i)) {
|
|
37
|
+
output += CURSOR_MARKER;
|
|
38
|
+
i += CURSOR_MARKER.length;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ansiMatch = /^\x1b\[[0-9;]*m/.exec(line.slice(i));
|
|
43
|
+
if (ansiMatch) {
|
|
44
|
+
output += ansiMatch[0];
|
|
45
|
+
i += ansiMatch[0].length;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const ch = line[i] as string;
|
|
50
|
+
output += ch === " " ? " " : "*";
|
|
51
|
+
i += 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
@@ -23,6 +23,7 @@ import { StringEnum } from "@gsd/pi-ai";
|
|
|
23
23
|
import { type ExtensionAPI, getMarkdownTheme } from "@gsd/pi-coding-agent";
|
|
24
24
|
import { Container, Markdown, Spacer, Text } from "@gsd/pi-tui";
|
|
25
25
|
import { Type } from "@sinclair/typebox";
|
|
26
|
+
import { formatTokenCount } from "../shared/mod.js";
|
|
26
27
|
import { type AgentConfig, type AgentScope, discoverAgents } from "./agents.js";
|
|
27
28
|
import {
|
|
28
29
|
type IsolationEnvironment,
|
|
@@ -76,13 +77,6 @@ async function stopLiveSubagents(): Promise<void> {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
function formatTokens(count: number): string {
|
|
80
|
-
if (count < 1000) return count.toString();
|
|
81
|
-
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
82
|
-
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
83
|
-
return `${(count / 1000000).toFixed(1)}M`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
function formatUsageStats(
|
|
87
81
|
usage: {
|
|
88
82
|
input: number;
|
|
@@ -97,13 +91,13 @@ function formatUsageStats(
|
|
|
97
91
|
): string {
|
|
98
92
|
const parts: string[] = [];
|
|
99
93
|
if (usage.turns) parts.push(`${usage.turns} turn${usage.turns > 1 ? "s" : ""}`);
|
|
100
|
-
if (usage.input) parts.push(`↑${
|
|
101
|
-
if (usage.output) parts.push(`↓${
|
|
102
|
-
if (usage.cacheRead) parts.push(`R${
|
|
103
|
-
if (usage.cacheWrite) parts.push(`W${
|
|
94
|
+
if (usage.input) parts.push(`↑${formatTokenCount(usage.input)}`);
|
|
95
|
+
if (usage.output) parts.push(`↓${formatTokenCount(usage.output)}`);
|
|
96
|
+
if (usage.cacheRead) parts.push(`R${formatTokenCount(usage.cacheRead)}`);
|
|
97
|
+
if (usage.cacheWrite) parts.push(`W${formatTokenCount(usage.cacheWrite)}`);
|
|
104
98
|
if (usage.cost) parts.push(`$${(Number(usage.cost) || 0).toFixed(4)}`);
|
|
105
99
|
if (usage.contextTokens && usage.contextTokens > 0) {
|
|
106
|
-
parts.push(`ctx:${
|
|
100
|
+
parts.push(`ctx:${formatTokenCount(usage.contextTokens)}`);
|
|
107
101
|
}
|
|
108
102
|
if (model) parts.push(model);
|
|
109
103
|
return parts.join(" ");
|
|
@@ -438,4 +438,4 @@ startTransition(() => setExpensiveState(newValue));
|
|
|
438
438
|
- [web.dev LCP](https://web.dev/articles/lcp)
|
|
439
439
|
- [web.dev INP](https://web.dev/articles/inp)
|
|
440
440
|
- [web.dev CLS](https://web.dev/articles/cls)
|
|
441
|
-
- [
|
|
441
|
+
- [Code Optimizer skill](../code-optimizer/SKILL.md)
|
|
@@ -42,7 +42,7 @@ The file must `export default function(pi: ExtensionAPI) { ... }`.
|
|
|
42
42
|
|
|
43
43
|
## Step 4: Check for Common Mistakes
|
|
44
44
|
|
|
45
|
-
Read
|
|
45
|
+
Read `../references/key-rules-gotchas.md` and verify each rule against the extension code.
|
|
46
46
|
|
|
47
47
|
## Step 5: Add Debugging
|
|
48
48
|
|
|
@@ -163,8 +163,6 @@ When performing an audit, structure findings as:
|
|
|
163
163
|
## References
|
|
164
164
|
|
|
165
165
|
For detailed guidelines on specific areas:
|
|
166
|
-
- [Performance Optimization](../performance/SKILL.md)
|
|
167
166
|
- [Core Web Vitals](../core-web-vitals/SKILL.md)
|
|
168
167
|
- [Accessibility](../accessibility/SKILL.md)
|
|
169
|
-
- [SEO](../seo/SKILL.md)
|
|
170
168
|
- [Best Practices](../best-practices/SKILL.md)
|