gsd-pi 2.14.2 → 2.14.3
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.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* manages create, enter, detect, and teardown for auto-mode worktrees.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { existsSync, readFileSync, realpathSync, utimesSync } from "node:fs";
|
|
9
|
+
import { existsSync, cpSync, readFileSync, realpathSync, utimesSync } from "node:fs";
|
|
10
10
|
import { join, resolve } from "node:path";
|
|
11
11
|
import { execSync, execFileSync } from "node:child_process";
|
|
12
12
|
import {
|
|
@@ -90,6 +90,14 @@ export function autoWorktreeBranch(milestoneId: string): string {
|
|
|
90
90
|
export function createAutoWorktree(basePath: string, milestoneId: string): string {
|
|
91
91
|
const branch = autoWorktreeBranch(milestoneId);
|
|
92
92
|
const info = createWorktree(basePath, milestoneId, { branch });
|
|
93
|
+
|
|
94
|
+
// Copy .gsd/ planning artifacts from the source repo into the new worktree.
|
|
95
|
+
// Worktrees are fresh git checkouts — untracked files don't carry over.
|
|
96
|
+
// Planning artifacts may be untracked if the project's .gitignore had a
|
|
97
|
+
// blanket .gsd/ rule (pre-v2.14.0). Without this copy, auto-mode loops
|
|
98
|
+
// on plan-slice because the plan file doesn't exist in the worktree.
|
|
99
|
+
copyPlanningArtifacts(basePath, info.path);
|
|
100
|
+
|
|
93
101
|
const previousCwd = process.cwd();
|
|
94
102
|
|
|
95
103
|
try {
|
|
@@ -107,6 +115,36 @@ export function createAutoWorktree(basePath: string, milestoneId: string): strin
|
|
|
107
115
|
return info.path;
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Copy .gsd/ planning artifacts from source repo to a new worktree.
|
|
120
|
+
* Copies milestones/, DECISIONS.md, REQUIREMENTS.md, PROJECT.md, QUEUE.md.
|
|
121
|
+
* Skips runtime files (auto.lock, metrics.json, etc.) and the worktrees/ dir.
|
|
122
|
+
* Best-effort — failures are non-fatal since auto-mode can recreate artifacts.
|
|
123
|
+
*/
|
|
124
|
+
function copyPlanningArtifacts(srcBase: string, wtPath: string): void {
|
|
125
|
+
const srcGsd = join(srcBase, ".gsd");
|
|
126
|
+
const dstGsd = join(wtPath, ".gsd");
|
|
127
|
+
if (!existsSync(srcGsd)) return;
|
|
128
|
+
|
|
129
|
+
// Copy milestones/ directory (planning files, roadmaps, plans, research)
|
|
130
|
+
const srcMilestones = join(srcGsd, "milestones");
|
|
131
|
+
if (existsSync(srcMilestones)) {
|
|
132
|
+
try {
|
|
133
|
+
cpSync(srcMilestones, join(dstGsd, "milestones"), { recursive: true, force: true });
|
|
134
|
+
} catch { /* non-fatal */ }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Copy top-level planning files
|
|
138
|
+
for (const file of ["DECISIONS.md", "REQUIREMENTS.md", "PROJECT.md", "QUEUE.md"]) {
|
|
139
|
+
const src = join(srcGsd, file);
|
|
140
|
+
if (existsSync(src)) {
|
|
141
|
+
try {
|
|
142
|
+
cpSync(src, join(dstGsd, file), { force: true });
|
|
143
|
+
} catch { /* non-fatal */ }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
110
148
|
/**
|
|
111
149
|
* Teardown an auto-worktree: chdir back to original base, then remove
|
|
112
150
|
* the worktree and its branch.
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* manages create, enter, detect, and teardown for auto-mode worktrees.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { existsSync, readFileSync, realpathSync, utimesSync } from "node:fs";
|
|
9
|
+
import { existsSync, cpSync, readFileSync, realpathSync, utimesSync } from "node:fs";
|
|
10
10
|
import { join, resolve } from "node:path";
|
|
11
11
|
import { execSync, execFileSync } from "node:child_process";
|
|
12
12
|
import {
|
|
@@ -90,6 +90,14 @@ export function autoWorktreeBranch(milestoneId: string): string {
|
|
|
90
90
|
export function createAutoWorktree(basePath: string, milestoneId: string): string {
|
|
91
91
|
const branch = autoWorktreeBranch(milestoneId);
|
|
92
92
|
const info = createWorktree(basePath, milestoneId, { branch });
|
|
93
|
+
|
|
94
|
+
// Copy .gsd/ planning artifacts from the source repo into the new worktree.
|
|
95
|
+
// Worktrees are fresh git checkouts — untracked files don't carry over.
|
|
96
|
+
// Planning artifacts may be untracked if the project's .gitignore had a
|
|
97
|
+
// blanket .gsd/ rule (pre-v2.14.0). Without this copy, auto-mode loops
|
|
98
|
+
// on plan-slice because the plan file doesn't exist in the worktree.
|
|
99
|
+
copyPlanningArtifacts(basePath, info.path);
|
|
100
|
+
|
|
93
101
|
const previousCwd = process.cwd();
|
|
94
102
|
|
|
95
103
|
try {
|
|
@@ -107,6 +115,36 @@ export function createAutoWorktree(basePath: string, milestoneId: string): strin
|
|
|
107
115
|
return info.path;
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Copy .gsd/ planning artifacts from source repo to a new worktree.
|
|
120
|
+
* Copies milestones/, DECISIONS.md, REQUIREMENTS.md, PROJECT.md, QUEUE.md.
|
|
121
|
+
* Skips runtime files (auto.lock, metrics.json, etc.) and the worktrees/ dir.
|
|
122
|
+
* Best-effort — failures are non-fatal since auto-mode can recreate artifacts.
|
|
123
|
+
*/
|
|
124
|
+
function copyPlanningArtifacts(srcBase: string, wtPath: string): void {
|
|
125
|
+
const srcGsd = join(srcBase, ".gsd");
|
|
126
|
+
const dstGsd = join(wtPath, ".gsd");
|
|
127
|
+
if (!existsSync(srcGsd)) return;
|
|
128
|
+
|
|
129
|
+
// Copy milestones/ directory (planning files, roadmaps, plans, research)
|
|
130
|
+
const srcMilestones = join(srcGsd, "milestones");
|
|
131
|
+
if (existsSync(srcMilestones)) {
|
|
132
|
+
try {
|
|
133
|
+
cpSync(srcMilestones, join(dstGsd, "milestones"), { recursive: true, force: true });
|
|
134
|
+
} catch { /* non-fatal */ }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Copy top-level planning files
|
|
138
|
+
for (const file of ["DECISIONS.md", "REQUIREMENTS.md", "PROJECT.md", "QUEUE.md"]) {
|
|
139
|
+
const src = join(srcGsd, file);
|
|
140
|
+
if (existsSync(src)) {
|
|
141
|
+
try {
|
|
142
|
+
cpSync(src, join(dstGsd, file), { force: true });
|
|
143
|
+
} catch { /* non-fatal */ }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
110
148
|
/**
|
|
111
149
|
* Teardown an auto-worktree: chdir back to original base, then remove
|
|
112
150
|
* the worktree and its branch.
|