gsd-pi 2.41.0-dev.3557dc4 → 2.41.0-dev.97349b1

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/web/standalone/.next/BUILD_ID +1 -1
  3. package/dist/web/standalone/.next/app-path-routes-manifest.json +12 -12
  4. package/dist/web/standalone/.next/build-manifest.json +2 -2
  5. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  6. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  7. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  8. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  11. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  12. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  13. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  15. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  16. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  17. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  18. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  19. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/index.html +1 -1
  23. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app-paths-manifest.json +12 -12
  30. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  31. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  32. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  33. package/package.json +1 -1
  34. package/src/resources/extensions/gsd/tests/auto-loop.test.ts +100 -118
  35. package/src/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +2 -2
  36. package/src/resources/extensions/gsd/tests/captures.test.ts +12 -1
  37. package/src/resources/extensions/gsd/tests/continue-here.test.ts +20 -20
  38. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +195 -105
  39. /package/dist/web/standalone/.next/static/{JBSIr4fSfHXs5g5x2ZBSC → ZrI3HOoXD7Fh84fAHZVxb}/_buildManifest.js +0 -0
  40. /package/dist/web/standalone/.next/static/{JBSIr4fSfHXs5g5x2ZBSC → ZrI3HOoXD7Fh84fAHZVxb}/_ssgManifest.js +0 -0
@@ -1,4 +1,6 @@
1
- import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync, readFileSync } from "node:fs";
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync } from "node:fs";
2
4
  import { join } from "node:path";
3
5
  import { tmpdir } from "node:os";
4
6
  import { execSync } from "node:child_process";
@@ -13,82 +15,42 @@ import {
13
15
  worktreeBranchName,
14
16
  worktreePath,
15
17
  } from "../worktree-manager.ts";
16
- import { createTestContext } from './test-helpers.ts';
17
18
 
18
- const { assertEq, assertTrue, report } = createTestContext();
19
19
  function run(command: string, cwd: string): string {
20
20
  return execSync(command, { cwd, stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8" }).trim();
21
21
  }
22
22
 
23
- // Set up a test repo
24
- const base = mkdtempSync(join(tmpdir(), "gsd-worktree-mgr-test-"));
25
- run("git init -b main", base);
26
- run('git config user.name "Pi Test"', base);
27
- run('git config user.email "pi@example.com"', base);
28
-
29
- // Create initial project structure
30
- mkdirSync(join(base, ".gsd", "milestones", "M001"), { recursive: true });
31
- writeFileSync(join(base, "README.md"), "# Test Project\n", "utf-8");
32
- writeFileSync(
33
- join(base, ".gsd", "milestones", "M001", "M001-ROADMAP.md"),
34
- "# M001: Demo\n\n## Slices\n- [ ] **S01: First** `risk:low` `depends:[]`\n > After this: it works\n",
35
- "utf-8",
36
- );
37
- run("git add .", base);
38
- run('git commit -m "chore: init"', base);
39
-
40
- async function main(): Promise<void> {
41
- console.log("\n=== worktreeBranchName ===");
42
- assertEq(worktreeBranchName("feature-x"), "worktree/feature-x", "branch name format");
43
-
44
- console.log("\n=== createWorktree ===");
45
- const info = createWorktree(base, "feature-x");
46
- assertTrue(info.name === "feature-x", "name matches");
47
- assertTrue(info.branch === "worktree/feature-x", "branch matches");
48
- assertTrue(info.exists, "worktree exists");
49
- assertTrue(existsSync(info.path), "worktree path exists on disk");
50
- assertTrue(existsSync(join(info.path, "README.md")), "README.md copied to worktree");
51
- assertTrue(existsSync(join(info.path, ".gsd", "milestones", "M001", "M001-ROADMAP.md")), ".gsd files copied");
52
-
53
- // Branch was created
54
- const branches = run("git branch", base);
55
- assertTrue(branches.includes("worktree/feature-x"), "branch was created");
56
-
57
- console.log("\n=== createWorktree — duplicate ===");
58
- let duplicateError = "";
59
- try {
60
- createWorktree(base, "feature-x");
61
- } catch (e) {
62
- duplicateError = (e as Error).message;
63
- }
64
- assertTrue(duplicateError.includes("already exists"), "duplicate creation fails");
23
+ function makeBaseRepo(): string {
24
+ const base = mkdtempSync(join(tmpdir(), "gsd-wt-test-"));
25
+ run("git init -b main", base);
26
+ run('git config user.name "Test User"', base);
27
+ run('git config user.email "test@example.com"', base);
28
+ mkdirSync(join(base, ".gsd", "milestones", "M001"), { recursive: true });
29
+ writeFileSync(join(base, "README.md"), "# Test Project\n", "utf-8");
30
+ writeFileSync(
31
+ join(base, ".gsd", "milestones", "M001", "M001-ROADMAP.md"),
32
+ "# M001: Demo\n\n## Slices\n- [ ] **S01: First** `risk:low` `depends:[]`\n > After this: it works\n",
33
+ "utf-8",
34
+ );
35
+ run("git add .", base);
36
+ run('git commit -m "chore: init"', base);
37
+ return base;
38
+ }
65
39
 
66
- console.log("\n=== createWorktree invalid name ===");
67
- let invalidError = "";
68
- try {
69
- createWorktree(base, "bad name!");
70
- } catch (e) {
71
- invalidError = (e as Error).message;
72
- }
73
- assertTrue(invalidError.includes("Invalid worktree name"), "invalid name rejected");
74
-
75
- console.log("\n=== listWorktrees ===");
76
- const list = listWorktrees(base);
77
- assertEq(list.length, 1, "one worktree listed");
78
- assertEq(list[0]!.name, "feature-x", "correct name");
79
- assertEq(list[0]!.branch, "worktree/feature-x", "correct branch");
80
- assertTrue(list[0]!.exists, "exists flag is true");
81
-
82
- console.log("\n=== make changes in worktree ===");
83
- const wtPath = worktreePath(base, "feature-x");
84
- // Add a new GSD artifact in the worktree
40
+ function makeRepoWithWorktree(worktreeName: string): { base: string; wtPath: string } {
41
+ const base = makeBaseRepo();
42
+ createWorktree(base, worktreeName);
43
+ return { base, wtPath: worktreePath(base, worktreeName) };
44
+ }
45
+
46
+ function makeRepoWithChanges(worktreeName: string): { base: string; wtPath: string } {
47
+ const { base, wtPath } = makeRepoWithWorktree(worktreeName);
85
48
  mkdirSync(join(wtPath, ".gsd", "milestones", "M002"), { recursive: true });
86
49
  writeFileSync(
87
50
  join(wtPath, ".gsd", "milestones", "M002", "M002-ROADMAP.md"),
88
51
  "# M002: New Feature\n\n## Slices\n- [ ] **S01: Setup** `risk:low` `depends:[]`\n > After this: new feature ready\n",
89
52
  "utf-8",
90
53
  );
91
- // Modify an existing artifact
92
54
  writeFileSync(
93
55
  join(wtPath, ".gsd", "milestones", "M001", "M001-ROADMAP.md"),
94
56
  "# M001: Demo (updated)\n\n## Slices\n- [x] **S01: First** `risk:low` `depends:[]`\n > Done\n",
@@ -96,46 +58,174 @@ async function main(): Promise<void> {
96
58
  );
97
59
  run("git add .", wtPath);
98
60
  run('git commit -m "feat: add M002 and update M001"', wtPath);
99
-
100
- console.log("\n=== diffWorktreeGSD ===");
101
- const diff = diffWorktreeGSD(base, "feature-x");
102
- assertTrue(diff.added.length > 0, "has added files");
103
- assertTrue(diff.added.some(f => f.includes("M002")), "M002 roadmap is in added");
104
- assertTrue(diff.modified.length > 0, "has modified files");
105
- assertTrue(diff.modified.some(f => f.includes("M001")), "M001 roadmap is in modified");
106
- assertEq(diff.removed.length, 0, "no removed files");
107
-
108
- console.log("\n=== getWorktreeGSDDiff ===");
109
- const fullDiff = getWorktreeGSDDiff(base, "feature-x");
110
- assertTrue(fullDiff.includes("M002"), "full diff mentions M002");
111
- assertTrue(fullDiff.includes("updated"), "full diff mentions update");
112
-
113
- console.log("\n=== getWorktreeLog ===");
114
- const log = getWorktreeLog(base, "feature-x");
115
- assertTrue(log.includes("add M002"), "log shows commit message");
116
-
117
- console.log("\n=== removeWorktree ===");
118
- removeWorktree(base, "feature-x", { deleteBranch: true });
119
- assertTrue(!existsSync(wtPath), "worktree directory removed");
120
- const branchesAfter = run("git branch", base);
121
- assertTrue(!branchesAfter.includes("worktree/feature-x"), "branch deleted");
122
-
123
- console.log("\n=== listWorktrees after removal ===");
124
- const listAfter = listWorktrees(base);
125
- assertEq(listAfter.length, 0, "no worktrees after removal");
126
-
127
- console.log("\n=== removeWorktree — already gone ===");
128
- // Should not throw
129
- removeWorktree(base, "feature-x", { deleteBranch: true });
130
- assertTrue(true, "removeWorktree on missing worktree does not throw");
131
-
132
- // Cleanup
133
- rmSync(base, { recursive: true, force: true });
134
-
135
- report();
61
+ return { base, wtPath };
136
62
  }
137
63
 
138
- main().catch((error) => {
139
- console.error(error);
140
- process.exit(1);
64
+ // ─── worktreeBranchName ───────────────────────────────────────────────────────
65
+
66
+ test("worktreeBranchName formats branch name", () => {
67
+ assert.strictEqual(
68
+ worktreeBranchName("feature-x"),
69
+ "worktree/feature-x",
70
+ "should prefix with worktree/",
71
+ );
72
+ });
73
+
74
+ // ─── createWorktree ───────────────────────────────────────────────────────────
75
+
76
+ test("createWorktree creates worktree with correct metadata", () => {
77
+ const base = makeBaseRepo();
78
+ try {
79
+ const info = createWorktree(base, "feature-x");
80
+ assert.strictEqual(info.name, "feature-x", "name should match");
81
+ assert.strictEqual(info.branch, "worktree/feature-x", "branch should be prefixed");
82
+ assert.ok(info.exists, "exists flag should be true");
83
+ assert.ok(existsSync(info.path), "worktree path should exist on disk");
84
+ assert.ok(existsSync(join(info.path, "README.md")), "README.md should be in worktree");
85
+ assert.ok(
86
+ existsSync(join(info.path, ".gsd", "milestones", "M001", "M001-ROADMAP.md")),
87
+ ".gsd files should be in worktree",
88
+ );
89
+ const branches = run("git branch", base);
90
+ assert.ok(branches.includes("worktree/feature-x"), "branch should be created in base repo");
91
+ } finally {
92
+ rmSync(base, { recursive: true, force: true });
93
+ }
94
+ });
95
+
96
+ test("createWorktree rejects duplicate name", () => {
97
+ const { base } = makeRepoWithWorktree("feature-x");
98
+ try {
99
+ assert.throws(
100
+ () => createWorktree(base, "feature-x"),
101
+ (err: Error) => {
102
+ assert.ok(
103
+ err.message.includes("already exists"),
104
+ `expected "already exists" in error, got: ${err.message}`,
105
+ );
106
+ return true;
107
+ },
108
+ "should throw on duplicate worktree name",
109
+ );
110
+ } finally {
111
+ rmSync(base, { recursive: true, force: true });
112
+ }
113
+ });
114
+
115
+ test("createWorktree rejects invalid name", () => {
116
+ const base = makeBaseRepo();
117
+ try {
118
+ assert.throws(
119
+ () => createWorktree(base, "bad name!"),
120
+ (err: Error) => {
121
+ assert.ok(
122
+ err.message.includes("Invalid worktree name"),
123
+ `expected "Invalid worktree name" in error, got: ${err.message}`,
124
+ );
125
+ return true;
126
+ },
127
+ "should throw on invalid worktree name",
128
+ );
129
+ } finally {
130
+ rmSync(base, { recursive: true, force: true });
131
+ }
132
+ });
133
+
134
+ // ─── listWorktrees ────────────────────────────────────────────────────────────
135
+
136
+ test("listWorktrees returns active worktrees", () => {
137
+ const { base } = makeRepoWithWorktree("feature-x");
138
+ try {
139
+ const list = listWorktrees(base);
140
+ assert.strictEqual(list.length, 1, "should list exactly one worktree");
141
+ assert.strictEqual(list[0]!.name, "feature-x", "name should match");
142
+ assert.strictEqual(list[0]!.branch, "worktree/feature-x", "branch should match");
143
+ assert.ok(list[0]!.exists, "exists flag should be true");
144
+ } finally {
145
+ rmSync(base, { recursive: true, force: true });
146
+ }
147
+ });
148
+
149
+ test("listWorktrees returns empty after removal", () => {
150
+ const { base } = makeRepoWithWorktree("feature-x");
151
+ try {
152
+ removeWorktree(base, "feature-x");
153
+ const list = listWorktrees(base);
154
+ assert.strictEqual(list.length, 0, "should have no worktrees after removal");
155
+ } finally {
156
+ rmSync(base, { recursive: true, force: true });
157
+ }
158
+ });
159
+
160
+ // ─── diffWorktreeGSD ─────────────────────────────────────────────────────────
161
+
162
+ test("diffWorktreeGSD detects added and modified GSD files", () => {
163
+ const { base } = makeRepoWithChanges("feature-x");
164
+ try {
165
+ const diff = diffWorktreeGSD(base, "feature-x");
166
+ assert.ok(diff.added.length > 0, "should have added files");
167
+ assert.ok(
168
+ diff.added.some((f) => f.includes("M002")),
169
+ "M002 roadmap should be in added files",
170
+ );
171
+ assert.ok(diff.modified.length > 0, "should have modified files");
172
+ assert.ok(
173
+ diff.modified.some((f) => f.includes("M001")),
174
+ "M001 roadmap should be in modified files",
175
+ );
176
+ assert.strictEqual(diff.removed.length, 0, "should have no removed files");
177
+ } finally {
178
+ rmSync(base, { recursive: true, force: true });
179
+ }
180
+ });
181
+
182
+ // ─── getWorktreeGSDDiff ───────────────────────────────────────────────────────
183
+
184
+ test("getWorktreeGSDDiff returns patch content", () => {
185
+ const { base } = makeRepoWithChanges("feature-x");
186
+ try {
187
+ const fullDiff = getWorktreeGSDDiff(base, "feature-x");
188
+ assert.ok(fullDiff.includes("M002"), "diff should mention M002");
189
+ assert.ok(fullDiff.includes("updated"), "diff should mention the update");
190
+ } finally {
191
+ rmSync(base, { recursive: true, force: true });
192
+ }
193
+ });
194
+
195
+ // ─── getWorktreeLog ───────────────────────────────────────────────────────────
196
+
197
+ test("getWorktreeLog shows commits", () => {
198
+ const { base } = makeRepoWithChanges("feature-x");
199
+ try {
200
+ const log = getWorktreeLog(base, "feature-x");
201
+ assert.ok(log.includes("add M002"), "log should include the commit message");
202
+ } finally {
203
+ rmSync(base, { recursive: true, force: true });
204
+ }
205
+ });
206
+
207
+ // ─── removeWorktree ───────────────────────────────────────────────────────────
208
+
209
+ test("removeWorktree removes directory and branch", () => {
210
+ const { base, wtPath } = makeRepoWithWorktree("feature-x");
211
+ try {
212
+ removeWorktree(base, "feature-x", { deleteBranch: true });
213
+ assert.ok(!existsSync(wtPath), "worktree directory should be gone");
214
+ const branches = run("git branch", base);
215
+ assert.ok(!branches.includes("worktree/feature-x"), "branch should be deleted");
216
+ } finally {
217
+ rmSync(base, { recursive: true, force: true });
218
+ }
219
+ });
220
+
221
+ test("removeWorktree on missing worktree does not throw", () => {
222
+ const base = makeBaseRepo();
223
+ try {
224
+ assert.doesNotThrow(
225
+ () => removeWorktree(base, "nonexistent"),
226
+ "should not throw when worktree does not exist",
227
+ );
228
+ } finally {
229
+ rmSync(base, { recursive: true, force: true });
230
+ }
141
231
  });