gsd-pi 2.42.0-dev.97e9e30 → 2.42.0-dev.eedc83f
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 +23 -0
- package/dist/cli.js +15 -1
- package/dist/resource-loader.js +39 -6
- package/dist/resources/extensions/async-jobs/async-bash-tool.js +52 -4
- package/dist/resources/extensions/gsd/auto-prompts.js +1 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +11 -5
- package/dist/resources/extensions/gsd/detection.js +19 -0
- package/dist/resources/extensions/gsd/doctor-checks.js +31 -1
- package/dist/resources/extensions/gsd/doctor-providers.js +10 -0
- package/dist/resources/extensions/gsd/forensics.js +84 -0
- package/dist/resources/extensions/gsd/git-constants.js +1 -0
- package/dist/resources/extensions/gsd/git-service.js +68 -2
- package/dist/resources/extensions/gsd/native-git-bridge.js +1 -0
- package/dist/resources/extensions/gsd/preferences-types.js +1 -0
- package/dist/resources/extensions/gsd/preferences.js +59 -8
- package/dist/resources/extensions/gsd/prompts/forensics.md +12 -5
- package/dist/resources/extensions/gsd/repo-identity.js +46 -5
- package/dist/resources/extensions/gsd/service-tier.js +13 -4
- package/dist/resources/extensions/gsd/session-lock.js +2 -2
- package/dist/resources/extensions/gsd/worktree-resolver.js +2 -2
- package/dist/resources/extensions/mcp-client/index.js +2 -1
- package/dist/resources/extensions/search-the-web/tool-search.js +3 -3
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/git/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
- package/dist/web/standalone/.next/server/chunks/229.js +2 -2
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +2 -2
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/web-mode.d.ts +2 -0
- package/dist/web-mode.js +40 -4
- package/package.json +1 -1
- package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/agent.js +2 -0
- package/packages/pi-agent-core/dist/agent.js.map +1 -1
- package/packages/pi-agent-core/dist/types.d.ts +6 -0
- package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/types.js.map +1 -1
- package/packages/pi-agent-core/src/agent.test.ts +53 -0
- package/packages/pi-agent-core/src/agent.ts +3 -0
- package/packages/pi-agent-core/src/types.ts +6 -0
- package/packages/pi-agent-core/tsconfig.json +1 -1
- package/packages/pi-ai/dist/models.d.ts +5 -3
- package/packages/pi-ai/dist/models.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.d.ts +801 -1468
- package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.js +1135 -1588
- package/packages/pi-ai/dist/models.generated.js.map +1 -1
- package/packages/pi-ai/dist/models.js.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js +60 -2
- package/packages/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
- package/packages/pi-ai/scripts/generate-models.ts +1543 -0
- package/packages/pi-ai/src/models.generated.ts +1140 -1593
- package/packages/pi-ai/src/models.ts +7 -4
- package/packages/pi-ai/src/utils/oauth/github-copilot.ts +74 -2
- package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js +8 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +7 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.js +29 -2
- package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/auth-storage.test.js +60 -0
- package/packages/pi-coding-agent/dist/core/auth-storage.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/loader.js +18 -0
- package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.js +23 -0
- package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts +6 -0
- package/packages/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/package-manager.js +63 -11
- package/packages/pi-coding-agent/dist/core/package-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts +9 -0
- package/packages/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/resource-loader.js +20 -6
- package/packages/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/system-prompt.js +6 -5
- package/packages/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js +3 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +9 -6
- package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +30 -10
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +7 -1
- package/packages/pi-coding-agent/src/core/auth-storage.test.ts +68 -0
- package/packages/pi-coding-agent/src/core/auth-storage.ts +30 -2
- package/packages/pi-coding-agent/src/core/extensions/loader.ts +18 -0
- package/packages/pi-coding-agent/src/core/lsp/client.ts +29 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +3 -0
- package/packages/pi-coding-agent/src/core/package-manager.ts +99 -58
- package/packages/pi-coding-agent/src/core/resource-loader.ts +24 -6
- package/packages/pi-coding-agent/src/core/system-prompt.ts +6 -5
- package/packages/pi-coding-agent/src/modes/interactive/components/extension-editor.ts +3 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +10 -6
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +31 -11
- package/src/resources/extensions/async-jobs/async-bash-timeout.test.ts +122 -0
- package/src/resources/extensions/async-jobs/async-bash-tool.ts +40 -4
- package/src/resources/extensions/gsd/auto-prompts.ts +1 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +13 -5
- package/src/resources/extensions/gsd/detection.ts +19 -0
- package/src/resources/extensions/gsd/doctor-checks.ts +32 -1
- package/src/resources/extensions/gsd/doctor-providers.ts +13 -0
- package/src/resources/extensions/gsd/doctor-types.ts +1 -0
- package/src/resources/extensions/gsd/forensics.ts +92 -0
- package/src/resources/extensions/gsd/git-constants.ts +1 -0
- package/src/resources/extensions/gsd/git-service.ts +71 -2
- package/src/resources/extensions/gsd/native-git-bridge.ts +1 -0
- package/src/resources/extensions/gsd/preferences-types.ts +3 -0
- package/src/resources/extensions/gsd/preferences.ts +62 -6
- package/src/resources/extensions/gsd/prompts/forensics.md +12 -5
- package/src/resources/extensions/gsd/repo-identity.ts +48 -5
- package/src/resources/extensions/gsd/service-tier.ts +17 -4
- package/src/resources/extensions/gsd/session-lock.ts +2 -2
- package/src/resources/extensions/gsd/tests/activity-log.test.ts +31 -69
- package/src/resources/extensions/gsd/tests/forensics-dedup.test.ts +48 -0
- package/src/resources/extensions/gsd/tests/forensics-issue-routing.test.ts +43 -0
- package/src/resources/extensions/gsd/tests/git-locale.test.ts +133 -0
- package/src/resources/extensions/gsd/tests/git-service.test.ts +49 -0
- package/src/resources/extensions/gsd/tests/journal.test.ts +82 -127
- package/src/resources/extensions/gsd/tests/manifest-status.test.ts +73 -82
- package/src/resources/extensions/gsd/tests/service-tier.test.ts +30 -1
- package/src/resources/extensions/gsd/tests/symlink-numbered-variants.test.ts +151 -0
- package/src/resources/extensions/gsd/tests/verification-gate.test.ts +156 -263
- package/src/resources/extensions/gsd/tests/worktree-health-dispatch.test.ts +35 -78
- package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +81 -74
- package/src/resources/extensions/gsd/worktree-resolver.ts +2 -2
- package/src/resources/extensions/mcp-client/index.ts +5 -1
- package/src/resources/extensions/search-the-web/tool-search.ts +3 -3
- /package/dist/web/standalone/.next/static/{PXrI5DoWsm7rwAVnEU2rD → JUBX5FUR73jiViQU5a-Cx}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{PXrI5DoWsm7rwAVnEU2rD → JUBX5FUR73jiViQU5a-Cx}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests for #1997: git locale not forced to C.
|
|
3
|
+
*
|
|
4
|
+
* Validates that GIT_NO_PROMPT_ENV includes LC_ALL=C so git always produces
|
|
5
|
+
* English output, and that nativeMergeSquash passes the env to execFileSync.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync, readFileSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
|
|
13
|
+
import { GIT_NO_PROMPT_ENV } from "../git-constants.ts";
|
|
14
|
+
import { nativeAddAllWithExclusions } from "../native-git-bridge.ts";
|
|
15
|
+
import { RUNTIME_EXCLUSION_PATHS } from "../git-service.ts";
|
|
16
|
+
import { createTestContext } from "./test-helpers.ts";
|
|
17
|
+
|
|
18
|
+
const { assertEq, assertTrue, report } = createTestContext();
|
|
19
|
+
|
|
20
|
+
function git(cwd: string, ...args: string[]): string {
|
|
21
|
+
return execFileSync("git", args, { cwd, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8" }).trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function initTempRepo(): string {
|
|
25
|
+
const dir = mkdtempSync(join(tmpdir(), "gsd-locale-"));
|
|
26
|
+
git(dir, "init");
|
|
27
|
+
git(dir, "config", "user.email", "test@test.com");
|
|
28
|
+
git(dir, "config", "user.name", "Test");
|
|
29
|
+
// Initial commit so HEAD exists
|
|
30
|
+
writeFileSync(join(dir, "init.txt"), "init");
|
|
31
|
+
git(dir, "add", "-A");
|
|
32
|
+
git(dir, "commit", "-m", "init");
|
|
33
|
+
return dir;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createFile(base: string, relPath: string, content: string): void {
|
|
37
|
+
const full = join(base, relPath);
|
|
38
|
+
mkdirSync(join(full, ".."), { recursive: true });
|
|
39
|
+
writeFileSync(full, content);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function main(): Promise<void> {
|
|
43
|
+
// ─── GIT_NO_PROMPT_ENV includes LC_ALL=C ─────────────────────────────
|
|
44
|
+
|
|
45
|
+
console.log("\n=== GIT_NO_PROMPT_ENV includes LC_ALL=C ===");
|
|
46
|
+
|
|
47
|
+
assertEq(
|
|
48
|
+
GIT_NO_PROMPT_ENV.LC_ALL,
|
|
49
|
+
"C",
|
|
50
|
+
"GIT_NO_PROMPT_ENV must set LC_ALL to 'C' to force English git output"
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
assertTrue(
|
|
54
|
+
"GIT_TERMINAL_PROMPT" in GIT_NO_PROMPT_ENV,
|
|
55
|
+
"GIT_NO_PROMPT_ENV still contains GIT_TERMINAL_PROMPT"
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// ─── nativeAddAllWithExclusions: non-English locale does not throw ───
|
|
59
|
+
|
|
60
|
+
console.log("\n=== nativeAddAllWithExclusions: non-English locale does not throw ===");
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
// Simulate what happens on a German system: .gsd is gitignored,
|
|
64
|
+
// exclusion pathspecs trigger an advisory warning exit code 1.
|
|
65
|
+
// With LC_ALL=C the English stderr guard should match and suppress.
|
|
66
|
+
const repo = initTempRepo();
|
|
67
|
+
|
|
68
|
+
writeFileSync(join(repo, ".gitignore"), ".gsd\n");
|
|
69
|
+
createFile(repo, ".gsd/STATE.md", "# State");
|
|
70
|
+
createFile(repo, "src/app.ts", "export const x = 1;");
|
|
71
|
+
|
|
72
|
+
// Save original LC_ALL / LANG and force German locale env
|
|
73
|
+
const origLcAll = process.env.LC_ALL;
|
|
74
|
+
const origLang = process.env.LANG;
|
|
75
|
+
process.env.LANG = "de_DE.UTF-8";
|
|
76
|
+
delete process.env.LC_ALL;
|
|
77
|
+
|
|
78
|
+
let threw = false;
|
|
79
|
+
try {
|
|
80
|
+
nativeAddAllWithExclusions(repo, RUNTIME_EXCLUSION_PATHS);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
threw = true;
|
|
83
|
+
console.error(" unexpected error:", e);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Restore
|
|
87
|
+
if (origLcAll !== undefined) process.env.LC_ALL = origLcAll;
|
|
88
|
+
else delete process.env.LC_ALL;
|
|
89
|
+
if (origLang !== undefined) process.env.LANG = origLang;
|
|
90
|
+
else delete process.env.LANG;
|
|
91
|
+
|
|
92
|
+
assertTrue(
|
|
93
|
+
!threw,
|
|
94
|
+
"nativeAddAllWithExclusions must not throw on non-English locale when .gsd is gitignored (#1997)"
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const staged = git(repo, "diff", "--cached", "--name-only");
|
|
98
|
+
assertTrue(staged.includes("src/app.ts"), "real file staged despite German locale");
|
|
99
|
+
|
|
100
|
+
rmSync(repo, { recursive: true, force: true });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ─── nativeMergeSquash: env is passed (merge-squash stderr is English) ─
|
|
104
|
+
|
|
105
|
+
console.log("\n=== nativeMergeSquash fallback uses GIT_NO_PROMPT_ENV ===");
|
|
106
|
+
|
|
107
|
+
{
|
|
108
|
+
// We verify indirectly: the source code must pass env: GIT_NO_PROMPT_ENV.
|
|
109
|
+
// Read the source and check for the pattern. This is a static check.
|
|
110
|
+
const src = readFileSync(
|
|
111
|
+
join(import.meta.dirname, "..", "native-git-bridge.ts"),
|
|
112
|
+
"utf-8"
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Find the nativeMergeSquash function and check it uses GIT_NO_PROMPT_ENV
|
|
116
|
+
const fnStart = src.indexOf("export function nativeMergeSquash");
|
|
117
|
+
assertTrue(fnStart !== -1, "nativeMergeSquash function exists in source");
|
|
118
|
+
|
|
119
|
+
const fnBody = src.slice(fnStart, src.indexOf("\nexport function", fnStart + 1));
|
|
120
|
+
const hasEnv = fnBody.includes("env: GIT_NO_PROMPT_ENV");
|
|
121
|
+
assertTrue(
|
|
122
|
+
hasEnv,
|
|
123
|
+
"nativeMergeSquash fallback must pass env: GIT_NO_PROMPT_ENV to execFileSync (#1997)"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
report();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
main().catch((error) => {
|
|
131
|
+
console.error(error);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
});
|
|
@@ -1411,6 +1411,55 @@ async function main(): Promise<void> {
|
|
|
1411
1411
|
rmSync(repo, { recursive: true, force: true });
|
|
1412
1412
|
}
|
|
1413
1413
|
|
|
1414
|
+
// ─── autoCommit: symlinked .gsd stages new milestone artifacts (#2104) ──
|
|
1415
|
+
|
|
1416
|
+
console.log("\n=== autoCommit: symlinked .gsd stages new milestone artifacts (#2104) ===");
|
|
1417
|
+
|
|
1418
|
+
{
|
|
1419
|
+
// Reproduction: when .gsd is a symlink (external state project),
|
|
1420
|
+
// autoCommit silently fails to stage NEW .gsd/milestones/ files because:
|
|
1421
|
+
// 1. nativeAddAllWithExclusions falls back to plain `git add -A` (symlink)
|
|
1422
|
+
// 2. `.gsd` is in .gitignore → new .gsd/ files are invisible to `git add`
|
|
1423
|
+
// The fix: smartStage() force-adds .gsd/milestones/ after the normal staging.
|
|
1424
|
+
const repo = initTempRepo();
|
|
1425
|
+
|
|
1426
|
+
// Create an external .gsd directory and symlink it into the repo
|
|
1427
|
+
const externalGsd = mkdtempSync(join(tmpdir(), "gsd-external-symlink-"));
|
|
1428
|
+
mkdirSync(join(externalGsd, "milestones", "M009"), { recursive: true });
|
|
1429
|
+
mkdirSync(join(externalGsd, "activity"), { recursive: true });
|
|
1430
|
+
mkdirSync(join(externalGsd, "runtime"), { recursive: true });
|
|
1431
|
+
|
|
1432
|
+
symlinkSync(externalGsd, join(repo, ".gsd"));
|
|
1433
|
+
|
|
1434
|
+
// .gitignore blocks .gsd (as ensureGitignore would do for symlink projects)
|
|
1435
|
+
writeFileSync(join(repo, ".gitignore"), ".gsd\n");
|
|
1436
|
+
run("git add .gitignore && git commit -m 'add gitignore'", repo);
|
|
1437
|
+
|
|
1438
|
+
// Simulate new milestone artifacts created during execution
|
|
1439
|
+
writeFileSync(join(externalGsd, "milestones", "M009", "M009-SUMMARY.md"), "# M009 Summary");
|
|
1440
|
+
writeFileSync(join(externalGsd, "milestones", "M009", "S01-SUMMARY.md"), "# S01 Summary");
|
|
1441
|
+
writeFileSync(join(externalGsd, "milestones", "M009", "T01-VERIFY.json"), '{"passed":true}');
|
|
1442
|
+
|
|
1443
|
+
// Also create a normal source file change
|
|
1444
|
+
createFile(repo, "src/feature.ts", "export const feature = true;");
|
|
1445
|
+
|
|
1446
|
+
const svc = new GitServiceImpl(repo);
|
|
1447
|
+
const msg = svc.autoCommit("complete-milestone", "M009");
|
|
1448
|
+
assertTrue(msg !== null, "symlink autoCommit: commit succeeds");
|
|
1449
|
+
|
|
1450
|
+
const committed = run("git show --name-only HEAD", repo);
|
|
1451
|
+
assertTrue(committed.includes("src/feature.ts"), "symlink autoCommit: source file committed");
|
|
1452
|
+
assertTrue(committed.includes(".gsd/milestones/M009/M009-SUMMARY.md"),
|
|
1453
|
+
"symlink autoCommit: new M009-SUMMARY.md is committed (not silently dropped)");
|
|
1454
|
+
assertTrue(committed.includes(".gsd/milestones/M009/S01-SUMMARY.md"),
|
|
1455
|
+
"symlink autoCommit: new S01-SUMMARY.md is committed");
|
|
1456
|
+
assertTrue(committed.includes(".gsd/milestones/M009/T01-VERIFY.json"),
|
|
1457
|
+
"symlink autoCommit: new T01-VERIFY.json is committed");
|
|
1458
|
+
|
|
1459
|
+
try { rmSync(repo, { recursive: true, force: true }); } catch {}
|
|
1460
|
+
try { rmSync(externalGsd, { recursive: true, force: true }); } catch {}
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1414
1463
|
report();
|
|
1415
1464
|
}
|
|
1416
1465
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import test from "node:test";
|
|
1
|
+
import { describe, test, beforeEach, afterEach } from "node:test";
|
|
2
2
|
import assert from "node:assert/strict";
|
|
3
3
|
import {
|
|
4
4
|
mkdirSync,
|
|
@@ -46,9 +46,12 @@ function makeEntry(overrides: Partial<JournalEntry> = {}): JournalEntry {
|
|
|
46
46
|
|
|
47
47
|
// ─── emitJournalEvent ─────────────────────────────────────────────────────────
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
describe("emitJournalEvent", () => {
|
|
50
|
+
let base: string;
|
|
51
|
+
beforeEach(() => { base = makeTmpBase(); });
|
|
52
|
+
afterEach(() => { cleanup(base); });
|
|
53
|
+
|
|
54
|
+
test("creates journal directory and JSONL file", () => {
|
|
52
55
|
const entry = makeEntry();
|
|
53
56
|
emitJournalEvent(base, entry);
|
|
54
57
|
|
|
@@ -61,14 +64,9 @@ test("emitJournalEvent creates journal directory and JSONL file", () => {
|
|
|
61
64
|
assert.equal(parsed.flowId, entry.flowId);
|
|
62
65
|
assert.equal(parsed.seq, entry.seq);
|
|
63
66
|
assert.equal(parsed.eventType, entry.eventType);
|
|
64
|
-
}
|
|
65
|
-
cleanup(base);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
67
|
+
});
|
|
68
68
|
|
|
69
|
-
test("
|
|
70
|
-
const base = makeTmpBase();
|
|
71
|
-
try {
|
|
69
|
+
test("appends multiple lines to the same file", () => {
|
|
72
70
|
emitJournalEvent(base, makeEntry({ seq: 0 }));
|
|
73
71
|
emitJournalEvent(base, makeEntry({ seq: 1, eventType: "dispatch-match" }));
|
|
74
72
|
emitJournalEvent(base, makeEntry({ seq: 2, eventType: "unit-start" }));
|
|
@@ -82,26 +80,9 @@ test("emitJournalEvent appends multiple lines to the same file", () => {
|
|
|
82
80
|
assert.equal(parsed[1].seq, 1);
|
|
83
81
|
assert.equal(parsed[2].seq, 2);
|
|
84
82
|
assert.equal(parsed[1].eventType, "dispatch-match");
|
|
85
|
-
}
|
|
86
|
-
cleanup(base);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test("emitJournalEvent auto-creates nonexistent parent directory", () => {
|
|
91
|
-
const base = join(tmpdir(), `gsd-journal-test-${randomUUID()}`);
|
|
92
|
-
// Don't create .gsd/ — emitJournalEvent should handle it via mkdirSync recursive
|
|
93
|
-
try {
|
|
94
|
-
emitJournalEvent(base, makeEntry());
|
|
95
|
-
const filePath = join(base, ".gsd", "journal", "2025-03-21.jsonl");
|
|
96
|
-
assert.ok(existsSync(filePath), "File should exist even when parent dirs did not");
|
|
97
|
-
} finally {
|
|
98
|
-
cleanup(base);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
83
|
+
});
|
|
101
84
|
|
|
102
|
-
test("
|
|
103
|
-
const base = makeTmpBase();
|
|
104
|
-
try {
|
|
85
|
+
test("preserves optional fields (rule, causedBy, data)", () => {
|
|
105
86
|
const entry = makeEntry({
|
|
106
87
|
rule: "my-dispatch-rule",
|
|
107
88
|
causedBy: { flowId: "flow-prior", seq: 3 },
|
|
@@ -115,24 +96,12 @@ test("emitJournalEvent preserves optional fields (rule, causedBy, data)", () =>
|
|
|
115
96
|
assert.deepEqual(parsed.causedBy, { flowId: "flow-prior", seq: 3 });
|
|
116
97
|
assert.equal(parsed.data.unitId, "M001/S01/T01");
|
|
117
98
|
assert.equal(parsed.data.status, "ok");
|
|
118
|
-
} finally {
|
|
119
|
-
cleanup(base);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test("emitJournalEvent silently catches write errors (no throw)", () => {
|
|
124
|
-
// Use a path that can't be created — null bytes in path
|
|
125
|
-
assert.doesNotThrow(() => {
|
|
126
|
-
emitJournalEvent("/dev/null/impossible\0path", makeEntry());
|
|
127
99
|
});
|
|
128
|
-
});
|
|
129
100
|
|
|
130
|
-
test("
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
mkdirSync(journalDir, { recursive: true });
|
|
101
|
+
test("silently catches read-only directory errors", () => {
|
|
102
|
+
const journalDir = join(base, ".gsd", "journal");
|
|
103
|
+
mkdirSync(journalDir, { recursive: true });
|
|
134
104
|
|
|
135
|
-
try {
|
|
136
105
|
// Make the journal directory read-only
|
|
137
106
|
chmodSync(journalDir, 0o444);
|
|
138
107
|
|
|
@@ -140,22 +109,46 @@ test("emitJournalEvent silently catches read-only directory errors", () => {
|
|
|
140
109
|
assert.doesNotThrow(() => {
|
|
141
110
|
emitJournalEvent(base, makeEntry());
|
|
142
111
|
});
|
|
143
|
-
|
|
112
|
+
|
|
144
113
|
// Restore permissions for cleanup
|
|
145
114
|
try {
|
|
146
115
|
chmodSync(journalDir, 0o755);
|
|
147
116
|
} catch {
|
|
148
117
|
/* */
|
|
149
118
|
}
|
|
150
|
-
|
|
151
|
-
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("emitJournalEvent — auto-creates parent directory", () => {
|
|
123
|
+
let base: string;
|
|
124
|
+
beforeEach(() => {
|
|
125
|
+
base = join(tmpdir(), `gsd-journal-test-${randomUUID()}`);
|
|
126
|
+
// Don't create .gsd/ — emitJournalEvent should handle it via mkdirSync recursive
|
|
127
|
+
});
|
|
128
|
+
afterEach(() => { cleanup(base); });
|
|
129
|
+
|
|
130
|
+
test("auto-creates nonexistent parent directory", () => {
|
|
131
|
+
emitJournalEvent(base, makeEntry());
|
|
132
|
+
const filePath = join(base, ".gsd", "journal", "2025-03-21.jsonl");
|
|
133
|
+
assert.ok(existsSync(filePath), "File should exist even when parent dirs did not");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("emitJournalEvent silently catches write errors (no throw)", () => {
|
|
138
|
+
// Use a path that can't be created — null bytes in path
|
|
139
|
+
assert.doesNotThrow(() => {
|
|
140
|
+
emitJournalEvent("/dev/null/impossible\0path", makeEntry());
|
|
141
|
+
});
|
|
152
142
|
});
|
|
153
143
|
|
|
154
144
|
// ─── Daily Rotation ───────────────────────────────────────────────────────────
|
|
155
145
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
146
|
+
describe("daily rotation", () => {
|
|
147
|
+
let base: string;
|
|
148
|
+
beforeEach(() => { base = makeTmpBase(); });
|
|
149
|
+
afterEach(() => { cleanup(base); });
|
|
150
|
+
|
|
151
|
+
test("events with different dates go to different files", () => {
|
|
159
152
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-20T23:59:59.000Z" }));
|
|
160
153
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-21T00:00:01.000Z" }));
|
|
161
154
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-22T12:00:00.000Z" }));
|
|
@@ -172,16 +165,17 @@ test("daily rotation: events with different dates go to different files", () =>
|
|
|
172
165
|
.split("\n");
|
|
173
166
|
assert.equal(lines.length, 1, `${date}.jsonl should have 1 line`);
|
|
174
167
|
}
|
|
175
|
-
}
|
|
176
|
-
cleanup(base);
|
|
177
|
-
}
|
|
168
|
+
});
|
|
178
169
|
});
|
|
179
170
|
|
|
180
171
|
// ─── queryJournal ─────────────────────────────────────────────────────────────
|
|
181
172
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
173
|
+
describe("queryJournal", () => {
|
|
174
|
+
let base: string;
|
|
175
|
+
beforeEach(() => { base = makeTmpBase(); });
|
|
176
|
+
afterEach(() => { cleanup(base); });
|
|
177
|
+
|
|
178
|
+
test("returns all entries when no filters provided", () => {
|
|
185
179
|
emitJournalEvent(base, makeEntry({ seq: 0 }));
|
|
186
180
|
emitJournalEvent(base, makeEntry({ seq: 1, eventType: "dispatch-match" }));
|
|
187
181
|
|
|
@@ -189,14 +183,9 @@ test("queryJournal returns all entries when no filters provided", () => {
|
|
|
189
183
|
assert.equal(results.length, 2);
|
|
190
184
|
assert.equal(results[0].seq, 0);
|
|
191
185
|
assert.equal(results[1].seq, 1);
|
|
192
|
-
}
|
|
193
|
-
cleanup(base);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
186
|
+
});
|
|
196
187
|
|
|
197
|
-
test("
|
|
198
|
-
const base = makeTmpBase();
|
|
199
|
-
try {
|
|
188
|
+
test("filters by flowId", () => {
|
|
200
189
|
emitJournalEvent(base, makeEntry({ flowId: "flow-aaa", seq: 0 }));
|
|
201
190
|
emitJournalEvent(base, makeEntry({ flowId: "flow-bbb", seq: 1 }));
|
|
202
191
|
emitJournalEvent(base, makeEntry({ flowId: "flow-aaa", seq: 2 }));
|
|
@@ -204,14 +193,9 @@ test("queryJournal filters by flowId", () => {
|
|
|
204
193
|
const results = queryJournal(base, { flowId: "flow-aaa" });
|
|
205
194
|
assert.equal(results.length, 2);
|
|
206
195
|
assert.ok(results.every(e => e.flowId === "flow-aaa"));
|
|
207
|
-
}
|
|
208
|
-
cleanup(base);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
196
|
+
});
|
|
211
197
|
|
|
212
|
-
test("
|
|
213
|
-
const base = makeTmpBase();
|
|
214
|
-
try {
|
|
198
|
+
test("filters by eventType", () => {
|
|
215
199
|
emitJournalEvent(base, makeEntry({ eventType: "iteration-start", seq: 0 }));
|
|
216
200
|
emitJournalEvent(base, makeEntry({ eventType: "dispatch-match", seq: 1 }));
|
|
217
201
|
emitJournalEvent(base, makeEntry({ eventType: "unit-start", seq: 2 }));
|
|
@@ -220,14 +204,9 @@ test("queryJournal filters by eventType", () => {
|
|
|
220
204
|
const results = queryJournal(base, { eventType: "dispatch-match" });
|
|
221
205
|
assert.equal(results.length, 2);
|
|
222
206
|
assert.ok(results.every(e => e.eventType === "dispatch-match"));
|
|
223
|
-
}
|
|
224
|
-
cleanup(base);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
207
|
+
});
|
|
227
208
|
|
|
228
|
-
test("
|
|
229
|
-
const base = makeTmpBase();
|
|
230
|
-
try {
|
|
209
|
+
test("filters by unitId (from data.unitId)", () => {
|
|
231
210
|
emitJournalEvent(
|
|
232
211
|
base,
|
|
233
212
|
makeEntry({ seq: 0, data: { unitId: "M001/S01/T01" } }),
|
|
@@ -249,14 +228,9 @@ test("queryJournal filters by unitId (from data.unitId)", () => {
|
|
|
249
228
|
e => (e.data as Record<string, unknown>)?.unitId === "M001/S01/T01",
|
|
250
229
|
),
|
|
251
230
|
);
|
|
252
|
-
}
|
|
253
|
-
cleanup(base);
|
|
254
|
-
}
|
|
255
|
-
});
|
|
231
|
+
});
|
|
256
232
|
|
|
257
|
-
test("
|
|
258
|
-
const base = makeTmpBase();
|
|
259
|
-
try {
|
|
233
|
+
test("filters by time range (after/before)", () => {
|
|
260
234
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-20T08:00:00.000Z", seq: 0 }));
|
|
261
235
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-21T10:00:00.000Z", seq: 1 }));
|
|
262
236
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-21T15:00:00.000Z", seq: 2 }));
|
|
@@ -276,14 +250,9 @@ test("queryJournal filters by time range (after/before)", () => {
|
|
|
276
250
|
before: "2025-03-21T23:59:59.000Z",
|
|
277
251
|
});
|
|
278
252
|
assert.equal(rangeResults.length, 2, "2 entries within 2025-03-21");
|
|
279
|
-
}
|
|
280
|
-
cleanup(base);
|
|
281
|
-
}
|
|
282
|
-
});
|
|
253
|
+
});
|
|
283
254
|
|
|
284
|
-
test("
|
|
285
|
-
const base = makeTmpBase();
|
|
286
|
-
try {
|
|
255
|
+
test("combines multiple filters", () => {
|
|
287
256
|
emitJournalEvent(
|
|
288
257
|
base,
|
|
289
258
|
makeEntry({ flowId: "flow-aaa", eventType: "unit-start", seq: 0 }),
|
|
@@ -304,25 +273,9 @@ test("queryJournal combines multiple filters", () => {
|
|
|
304
273
|
assert.equal(results.length, 1);
|
|
305
274
|
assert.equal(results[0].flowId, "flow-aaa");
|
|
306
275
|
assert.equal(results[0].eventType, "unit-start");
|
|
307
|
-
}
|
|
308
|
-
cleanup(base);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
test("queryJournal on nonexistent directory returns empty array", () => {
|
|
313
|
-
const base = join(tmpdir(), `gsd-journal-test-${randomUUID()}`);
|
|
314
|
-
// Don't create anything
|
|
315
|
-
try {
|
|
316
|
-
const results = queryJournal(base);
|
|
317
|
-
assert.deepEqual(results, []);
|
|
318
|
-
} finally {
|
|
319
|
-
cleanup(base);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
276
|
+
});
|
|
322
277
|
|
|
323
|
-
test("
|
|
324
|
-
const base = makeTmpBase();
|
|
325
|
-
try {
|
|
278
|
+
test("skips malformed JSON lines gracefully", () => {
|
|
326
279
|
const journalDir = join(base, ".gsd", "journal");
|
|
327
280
|
mkdirSync(journalDir, { recursive: true });
|
|
328
281
|
|
|
@@ -335,14 +288,9 @@ test("queryJournal skips malformed JSON lines gracefully", () => {
|
|
|
335
288
|
assert.equal(results.length, 2, "Should skip the malformed line");
|
|
336
289
|
assert.equal(results[0].seq, 0);
|
|
337
290
|
assert.equal(results[1].seq, 1);
|
|
338
|
-
}
|
|
339
|
-
cleanup(base);
|
|
340
|
-
}
|
|
341
|
-
});
|
|
291
|
+
});
|
|
342
292
|
|
|
343
|
-
test("
|
|
344
|
-
const base = makeTmpBase();
|
|
345
|
-
try {
|
|
293
|
+
test("reads across multiple daily files", () => {
|
|
346
294
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-20T12:00:00.000Z", seq: 0 }));
|
|
347
295
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-21T12:00:00.000Z", seq: 1 }));
|
|
348
296
|
emitJournalEvent(base, makeEntry({ ts: "2025-03-22T12:00:00.000Z", seq: 2 }));
|
|
@@ -353,14 +301,9 @@ test("queryJournal reads across multiple daily files", () => {
|
|
|
353
301
|
assert.equal(results[0].ts, "2025-03-20T12:00:00.000Z");
|
|
354
302
|
assert.equal(results[1].ts, "2025-03-21T12:00:00.000Z");
|
|
355
303
|
assert.equal(results[2].ts, "2025-03-22T12:00:00.000Z");
|
|
356
|
-
}
|
|
357
|
-
cleanup(base);
|
|
358
|
-
}
|
|
359
|
-
});
|
|
304
|
+
});
|
|
360
305
|
|
|
361
|
-
test("
|
|
362
|
-
const base = makeTmpBase();
|
|
363
|
-
try {
|
|
306
|
+
test("filters by rule", () => {
|
|
364
307
|
emitJournalEvent(
|
|
365
308
|
base,
|
|
366
309
|
makeEntry({ seq: 0, eventType: "dispatch-match", rule: "dispatch-task" }),
|
|
@@ -380,7 +323,19 @@ test("queryJournal filters by rule", () => {
|
|
|
380
323
|
results.every(e => e.rule === "dispatch-task"),
|
|
381
324
|
"All results should have rule === 'dispatch-task'",
|
|
382
325
|
);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe("queryJournal — nonexistent directory", () => {
|
|
330
|
+
let base: string;
|
|
331
|
+
beforeEach(() => {
|
|
332
|
+
base = join(tmpdir(), `gsd-journal-test-${randomUUID()}`);
|
|
333
|
+
// Don't create anything
|
|
334
|
+
});
|
|
335
|
+
afterEach(() => { cleanup(base); });
|
|
336
|
+
|
|
337
|
+
test("on nonexistent directory returns empty array", () => {
|
|
338
|
+
const results = queryJournal(base);
|
|
339
|
+
assert.deepEqual(results, []);
|
|
340
|
+
});
|
|
386
341
|
});
|