gsd-pi 2.35.0 → 2.36.0-dev.d612764
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/cmux/index.js +321 -0
- 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-dashboard.js +334 -104
- package/dist/resources/extensions/gsd/auto-dispatch.js +43 -1
- package/dist/resources/extensions/gsd/auto-loop.js +28 -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 +75 -4
- package/dist/resources/extensions/gsd/commands-cmux.js +120 -0
- 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-prefs-wizard.js +1 -1
- package/dist/resources/extensions/gsd/commands-rate.js +31 -0
- package/dist/resources/extensions/gsd/commands.js +94 -2
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +25 -0
- 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 +31 -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/notifications.js +10 -1
- 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-types.js +2 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +45 -1
- package/dist/resources/extensions/gsd/preferences.js +15 -0
- package/dist/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
- package/dist/resources/extensions/gsd/prompts/research-milestone.md +4 -3
- package/dist/resources/extensions/gsd/prompts/research-slice.md +3 -2
- 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/templates/preferences.md +6 -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/search-the-web/native-search.js +45 -4
- package/dist/resources/extensions/shared/mod.js +1 -1
- package/dist/resources/extensions/shared/sanitize.js +30 -0
- package/dist/resources/extensions/shared/terminal.js +5 -0
- package/dist/resources/extensions/subagent/index.js +186 -74
- 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/packages/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/packages/pi-tui/dist/terminal-image.js +4 -0
- package/packages/pi-tui/dist/terminal-image.js.map +1 -1
- package/packages/pi-tui/src/terminal-image.ts +5 -0
- 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/cmux/index.ts +384 -0
- 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-dashboard.ts +363 -116
- package/src/resources/extensions/gsd/auto-dispatch.ts +49 -1
- package/src/resources/extensions/gsd/auto-loop.ts +64 -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 +82 -3
- package/src/resources/extensions/gsd/commands-cmux.ts +143 -0
- 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-prefs-wizard.ts +1 -1
- package/src/resources/extensions/gsd/commands-rate.ts +55 -0
- package/src/resources/extensions/gsd/commands.ts +97 -2
- package/src/resources/extensions/gsd/docs/preferences-reference.md +25 -0
- 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 +37 -32
- 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/notifications.ts +10 -1
- 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-types.ts +13 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +42 -1
- package/src/resources/extensions/gsd/preferences.ts +18 -1
- package/src/resources/extensions/gsd/prompts/complete-milestone.md +2 -0
- package/src/resources/extensions/gsd/prompts/research-milestone.md +4 -3
- package/src/resources/extensions/gsd/prompts/research-slice.md +3 -2
- 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/templates/preferences.md +6 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/cmux.test.ts +98 -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 +35 -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/search-the-web/native-search.ts +50 -4
- package/src/resources/extensions/shared/mod.ts +1 -1
- package/src/resources/extensions/shared/sanitize.ts +36 -0
- package/src/resources/extensions/shared/terminal.ts +5 -0
- package/src/resources/extensions/subagent/index.ts +242 -91
- 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) => {
|
|
@@ -16,6 +16,16 @@ export const CUSTOM_SEARCH_TOOL_NAMES = ["search-the-web", "search_and_read", "g
|
|
|
16
16
|
/** Thinking block types that require signature validation by the API */
|
|
17
17
|
const THINKING_TYPES = new Set(["thinking", "redacted_thinking"]);
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Maximum number of native web searches allowed per session (agent unit).
|
|
21
|
+
* The Anthropic API's `max_uses` is per-request — it resets on each API call.
|
|
22
|
+
* When `pause_turn` triggers a resubmit, the model gets a fresh budget.
|
|
23
|
+
* This session-level cap prevents unbounded search accumulation (#1309).
|
|
24
|
+
*
|
|
25
|
+
* 15 = 3 full turns of 5 searches each — generous for research, but bounded.
|
|
26
|
+
*/
|
|
27
|
+
export const MAX_NATIVE_SEARCHES_PER_SESSION = 15;
|
|
28
|
+
|
|
19
29
|
/** When true, skip native web search injection and keep Brave/custom tools active on Anthropic. */
|
|
20
30
|
export function preferBraveSearch(): boolean {
|
|
21
31
|
// preferences.md takes priority over env var
|
|
@@ -74,6 +84,11 @@ export function registerNativeSearchHooks(pi: NativeSearchPI): { getIsAnthropic:
|
|
|
74
84
|
let isAnthropicProvider = false;
|
|
75
85
|
let modelSelectFired = false;
|
|
76
86
|
|
|
87
|
+
// Session-level native search counter (#1309).
|
|
88
|
+
// Tracks cumulative web_search_tool_result blocks across all turns in a session.
|
|
89
|
+
// Reset on session_start. Used to compute remaining budget for max_uses.
|
|
90
|
+
let sessionSearchCount = 0;
|
|
91
|
+
|
|
77
92
|
// Track provider changes via model selection — also handles diagnostics
|
|
78
93
|
// since model_select fires AFTER session_start and knows the provider.
|
|
79
94
|
pi.on("model_select", async (event: any, ctx: any) => {
|
|
@@ -161,13 +176,41 @@ export function registerNativeSearchHooks(pi: NativeSearchPI): { getIsAnthropic:
|
|
|
161
176
|
);
|
|
162
177
|
payload.tools = tools;
|
|
163
178
|
|
|
179
|
+
// ── Session-level search budget (#1309) ──────────────────────────────
|
|
180
|
+
// Count web_search_tool_result blocks in the conversation history to
|
|
181
|
+
// determine how many native searches have already been used this session.
|
|
182
|
+
// The Anthropic API's max_uses resets per request, so without this guard,
|
|
183
|
+
// pause_turn → resubmit cycles allow unlimited total searches.
|
|
184
|
+
if (Array.isArray(messages)) {
|
|
185
|
+
let historySearchCount = 0;
|
|
186
|
+
for (const msg of messages) {
|
|
187
|
+
const content = msg.content;
|
|
188
|
+
if (!Array.isArray(content)) continue;
|
|
189
|
+
for (const block of content) {
|
|
190
|
+
if ((block as any)?.type === "web_search_tool_result") {
|
|
191
|
+
historySearchCount++;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Sync counter from history (handles session restore / context replay)
|
|
196
|
+
sessionSearchCount = historySearchCount;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const remaining = Math.max(0, MAX_NATIVE_SEARCHES_PER_SESSION - sessionSearchCount);
|
|
200
|
+
|
|
201
|
+
if (remaining <= 0) {
|
|
202
|
+
// Budget exhausted — don't inject the search tool at all.
|
|
203
|
+
// The model will proceed without web search capability.
|
|
204
|
+
return payload;
|
|
205
|
+
}
|
|
206
|
+
|
|
164
207
|
tools.push({
|
|
165
208
|
type: "web_search_20250305",
|
|
166
209
|
name: "web_search",
|
|
167
|
-
// Cap
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
max_uses: 5,
|
|
210
|
+
// Cap per-request searches to the lesser of 5 (per-turn cap) or the
|
|
211
|
+
// remaining session budget (#1309). This prevents the model from
|
|
212
|
+
// consuming unlimited searches via pause_turn → resubmit cycles.
|
|
213
|
+
max_uses: Math.min(5, remaining),
|
|
171
214
|
});
|
|
172
215
|
|
|
173
216
|
return payload;
|
|
@@ -175,6 +218,9 @@ export function registerNativeSearchHooks(pi: NativeSearchPI): { getIsAnthropic:
|
|
|
175
218
|
|
|
176
219
|
// Basic startup diagnostics — provider-specific info comes from model_select
|
|
177
220
|
pi.on("session_start", async (_event: any, ctx: any) => {
|
|
221
|
+
// Reset session-level search budget (#1309)
|
|
222
|
+
sessionSearchCount = 0;
|
|
223
|
+
|
|
178
224
|
const hasBrave = !!process.env.BRAVE_API_KEY;
|
|
179
225
|
const hasJina = !!process.env.JINA_API_KEY;
|
|
180
226
|
const hasAnswers = !!process.env.BRAVE_ANSWERS_KEY;
|
|
@@ -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
|
+
}
|
|
@@ -7,9 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
const UNSUPPORTED_TERMS = ["apple_terminal", "warpterm"];
|
|
9
9
|
|
|
10
|
+
export function isCmuxTerminal(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
11
|
+
return Boolean(env.CMUX_WORKSPACE_ID && env.CMUX_SURFACE_ID);
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export function supportsCtrlAltShortcuts(): boolean {
|
|
11
15
|
const term = (process.env.TERM_PROGRAM || "").toLowerCase();
|
|
12
16
|
const jetbrains = (process.env.TERMINAL_EMULATOR || "").toLowerCase().includes("jetbrains");
|
|
17
|
+
if (isCmuxTerminal()) return true;
|
|
13
18
|
return !UNSUPPORTED_TERMS.some((t) => term.includes(t)) && !jetbrains;
|
|
14
19
|
}
|
|
15
20
|
|