joycraft 0.7.13 → 0.7.14

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 (49) hide show
  1. package/README.md +25 -11
  2. package/dist/chunk-7BPB2IKY.js +255 -0
  3. package/dist/chunk-7BPB2IKY.js.map +1 -0
  4. package/dist/chunk-B73DPYYC.js +377 -0
  5. package/dist/chunk-B73DPYYC.js.map +1 -0
  6. package/dist/{chunk-EFHJI5KD.js → chunk-JYPBXPGD.js} +114 -112
  7. package/dist/chunk-JYPBXPGD.js.map +1 -0
  8. package/dist/{chunk-LKWD25KJ.js → chunk-KKDKC4FM.js} +8 -71
  9. package/dist/chunk-KKDKC4FM.js.map +1 -0
  10. package/dist/chunk-OMFGDJW4.js +97 -0
  11. package/dist/chunk-OMFGDJW4.js.map +1 -0
  12. package/dist/chunk-PR4QDKPL.js +3755 -0
  13. package/dist/chunk-PR4QDKPL.js.map +1 -0
  14. package/dist/chunk-Z5JFEGWG.js +563 -0
  15. package/dist/chunk-Z5JFEGWG.js.map +1 -0
  16. package/dist/cli.js +387 -54
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.d.ts +235 -1
  19. package/dist/index.js +691 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/init-S5JU5BHL.js +60 -0
  22. package/dist/init-S5JU5BHL.js.map +1 -0
  23. package/dist/{init-autofix-E7DSPUSC.js → init-autofix-WSKUT2HN.js} +4 -3
  24. package/dist/{init-autofix-E7DSPUSC.js.map → init-autofix-WSKUT2HN.js.map} +1 -1
  25. package/dist/install-manifest-EQHT4474.js +37 -0
  26. package/dist/joycraft-release.json +8 -0
  27. package/dist/release-artifact-4TL5L2ZY.js +14 -0
  28. package/dist/release-artifact-4TL5L2ZY.js.map +1 -0
  29. package/dist/release-resolver-P2H46QTU.js +293 -0
  30. package/dist/release-resolver-P2H46QTU.js.map +1 -0
  31. package/dist/update-HNTXCEKB.js +19 -0
  32. package/dist/update-HNTXCEKB.js.map +1 -0
  33. package/dist/update-check-YT765NE7.js +36 -0
  34. package/dist/update-check-YT765NE7.js.map +1 -0
  35. package/dist/upgrade-LZOND7OZ.js +28 -0
  36. package/dist/upgrade-LZOND7OZ.js.map +1 -0
  37. package/package.json +5 -2
  38. package/dist/chunk-EFHJI5KD.js.map +0 -1
  39. package/dist/chunk-J6GDQ55S.js +0 -91
  40. package/dist/chunk-J6GDQ55S.js.map +0 -1
  41. package/dist/chunk-LKWD25KJ.js.map +0 -1
  42. package/dist/chunk-Q2ZQ6RGD.js +0 -243
  43. package/dist/chunk-Q2ZQ6RGD.js.map +0 -1
  44. package/dist/init-YSFURLGT.js +0 -1330
  45. package/dist/init-YSFURLGT.js.map +0 -1
  46. package/dist/upgrade-PELFI26D.js +0 -650
  47. package/dist/upgrade-PELFI26D.js.map +0 -1
  48. package/dist/version-J7MOKNJR.js +0 -28
  49. /package/dist/{version-J7MOKNJR.js.map → install-manifest-EQHT4474.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -1,95 +1,428 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ resolveUpdatePath
4
+ } from "./chunk-OMFGDJW4.js";
2
5
  import {
3
6
  PRIVATE_DIRS_DISPLAY
4
- } from "./chunk-J6GDQ55S.js";
7
+ } from "./chunk-Z5JFEGWG.js";
8
+ import "./chunk-KKDKC4FM.js";
9
+ import "./chunk-B73DPYYC.js";
5
10
  import "./chunk-K4AI6FKB.js";
6
- import "./chunk-LKWD25KJ.js";
7
11
 
8
12
  // src/cli.ts
9
13
  import { Command } from "commander";
10
14
  import { readFileSync } from "fs";
11
15
  import { fileURLToPath } from "url";
12
- import { dirname, join } from "path";
13
- var __dirname = dirname(fileURLToPath(import.meta.url));
14
- var pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
16
+ import { dirname as dirname2, join as join2 } from "path";
17
+
18
+ // src/migration.ts
19
+ import {
20
+ cpSync,
21
+ existsSync,
22
+ lstatSync,
23
+ mkdirSync,
24
+ readdirSync,
25
+ renameSync,
26
+ rmSync
27
+ } from "fs";
28
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "path";
29
+ import { randomUUID } from "crypto";
30
+ var DATE_PREFIX_RE = /^\d{4}-\d{2}-\d{2}-(.+)$/;
31
+ function deriveSlug(filename) {
32
+ return filename.replace(/\.md$/, "");
33
+ }
34
+ function slugWithoutDate(slug) {
35
+ const m = slug.match(DATE_PREFIX_RE);
36
+ return m ? m[1] : null;
37
+ }
38
+ function listMdFiles(dir) {
39
+ if (!existsSync(dir)) return [];
40
+ try {
41
+ return readdirSync(dir).filter((f) => f.endsWith(".md"));
42
+ } catch {
43
+ return [];
44
+ }
45
+ }
46
+ function listSubdirs(dir) {
47
+ if (!existsSync(dir)) return [];
48
+ try {
49
+ return readdirSync(dir).filter((name) => {
50
+ try {
51
+ return lstatSync(join(dir, name)).isDirectory();
52
+ } catch {
53
+ return false;
54
+ }
55
+ });
56
+ } catch {
57
+ return [];
58
+ }
59
+ }
60
+ function destinationMove(from, to, kind) {
61
+ return { from, to, kind };
62
+ }
63
+ function planMigration(projectDir) {
64
+ const root = resolve(projectDir);
65
+ const briefsDir = join(root, "docs", "briefs");
66
+ const researchDir = join(root, "docs", "research");
67
+ const designsDir = join(root, "docs", "designs");
68
+ const specsDir = join(root, "docs", "specs");
69
+ const moves = [];
70
+ const skipped = [];
71
+ const slugSet = /* @__PURE__ */ new Set();
72
+ const addFileMoves = (dir, kind, targetName) => {
73
+ for (const file of listMdFiles(dir)) {
74
+ const slug = deriveSlug(file);
75
+ slugSet.add(slug);
76
+ const move = destinationMove(join(dir, file), join(root, "docs", "features", slug, targetName), kind);
77
+ (existsSync(move.to) ? skipped : moves).push(move);
78
+ }
79
+ };
80
+ addFileMoves(briefsDir, "brief", "brief.md");
81
+ addFileMoves(researchDir, "research", "research.md");
82
+ addFileMoves(designsDir, "design", "design.md");
83
+ const briefSlugs = Array.from(slugSet);
84
+ const orphanSpecsDirs = [];
85
+ for (const subdir of listSubdirs(specsDir)) {
86
+ const matchedSlug = briefSlugs.includes(subdir) ? subdir : briefSlugs.find((slug) => slugWithoutDate(slug) === subdir) ?? null;
87
+ const kind = matchedSlug ? "specs-dir" : "bugfix-dir";
88
+ const target = matchedSlug ? join(root, "docs", "features", matchedSlug, "specs") : join(root, "docs", "bugfixes", subdir);
89
+ const move = destinationMove(join(specsDir, subdir), target, kind);
90
+ if (!matchedSlug) orphanSpecsDirs.push(subdir);
91
+ (existsSync(move.to) ? skipped : moves).push(move);
92
+ }
93
+ const plan = { projectDir: root, moves, slugs: Array.from(slugSet), orphans: { specsDirs: orphanSpecsDirs } };
94
+ if (skipped.length > 0) plan.skipped = skipped;
95
+ return plan;
96
+ }
97
+ function relativePath(root, path) {
98
+ return relative(root, path).split("\\").join("/") || ".";
99
+ }
100
+ function pathSelection(root, selection) {
101
+ return isAbsolute(selection) ? resolve(selection) : resolve(root, selection);
102
+ }
103
+ function selectedCollision(root, move, selections) {
104
+ return selections.some((selection) => {
105
+ const selected = pathSelection(root, selection);
106
+ return selected === resolve(move.to) || selected === resolve(move.from) || selection === relativePath(root, move.to) || selection === relativePath(root, move.from);
107
+ });
108
+ }
109
+ function isInside(root, candidate) {
110
+ const rel = relative(root, candidate);
111
+ return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
112
+ }
113
+ function inspectPath(root, path, allowMissing) {
114
+ const rootAbsolute = resolve(root);
115
+ const candidate = resolve(path);
116
+ if (!isInside(rootAbsolute, candidate)) throw new Error(`Migration path escapes the project root: '${path}'.`);
117
+ const rel = relativePath(rootAbsolute, candidate);
118
+ if (rel === ".") return;
119
+ resolveUpdatePath(rootAbsolute, rel);
120
+ if (!allowMissing && !existsSync(candidate)) throw new Error(`Migration source is missing: '${path}'.`);
121
+ }
122
+ function unsafeTreeReason(path) {
123
+ let stat;
124
+ try {
125
+ stat = lstatSync(path);
126
+ } catch (error) {
127
+ const code = error.code;
128
+ return code === "ENOENT" ? void 0 : `Unable to inspect migration path '${path}': ${String(error)}`;
129
+ }
130
+ if (stat.isSymbolicLink()) return `Migration path traverses a symlink: '${path}'.`;
131
+ if (!stat.isDirectory()) return void 0;
132
+ let names;
133
+ try {
134
+ names = readdirSync(path);
135
+ } catch (error) {
136
+ return `Unable to inspect migration directory '${path}': ${String(error)}`;
137
+ }
138
+ for (const name of names) {
139
+ const reason = unsafeTreeReason(join(path, name));
140
+ if (reason) return reason;
141
+ }
142
+ return void 0;
143
+ }
144
+ function moveFsItem(from, to) {
145
+ mkdirSync(dirname(to), { recursive: true });
146
+ try {
147
+ renameSync(from, to);
148
+ } catch (err) {
149
+ if (err.code !== "EXDEV") throw err;
150
+ cpSync(from, to, { recursive: true, force: false, errorOnExist: true });
151
+ rmSync(from, { recursive: true, force: false });
152
+ }
153
+ }
154
+ function replaceMove(from, to, move) {
155
+ const displaced = `${to}.joycraft-migration-${randomUUID()}`;
156
+ let movedAside = false;
157
+ if (existsSync(to)) {
158
+ renameSync(to, displaced);
159
+ movedAside = true;
160
+ }
161
+ try {
162
+ move(from, to);
163
+ } catch (error) {
164
+ if (movedAside && existsSync(displaced)) {
165
+ if (existsSync(to)) {
166
+ throw new Error(`${String(error)}; original destination retained at '${displaced}', interrupted move content retained at '${to}'.`);
167
+ }
168
+ try {
169
+ renameSync(displaced, to);
170
+ } catch (restoreError) {
171
+ throw new Error(`${error instanceof Error ? error.message : String(error)}; original destination retained at '${displaced}' (${String(restoreError)}).`);
172
+ }
173
+ }
174
+ throw error;
175
+ }
176
+ if (movedAside) {
177
+ try {
178
+ rmSync(displaced, { recursive: true, force: false });
179
+ } catch (error) {
180
+ throw new Error(`Move applied; previous destination backup remains at '${displaced}': ${String(error)}`);
181
+ }
182
+ }
183
+ }
184
+ function emptyResult() {
185
+ return { status: "complete", applied: 0, skipped: 0, replaced: [], preserved: [], errors: [] };
186
+ }
187
+ function applyMigration(plan, options = {}) {
188
+ const root = resolve(plan.projectDir ?? inferProjectDir(plan));
189
+ const result = emptyResult();
190
+ const replacements = options.replaceCollisions ?? [];
191
+ const mover = options.move ?? moveFsItem;
192
+ const allMoves = [...plan.moves, ...plan.skipped ?? []];
193
+ for (const move of plan.preserved ?? []) {
194
+ result.skipped++;
195
+ result.preserved.push(move.from);
196
+ }
197
+ const seen = /* @__PURE__ */ new Set();
198
+ for (const move of allMoves) {
199
+ const key = `${move.from}\0${move.to}`;
200
+ if (seen.has(key)) continue;
201
+ seen.add(key);
202
+ try {
203
+ inspectPath(root, move.from, false);
204
+ inspectPath(root, move.to, true);
205
+ const unsafeSource = unsafeTreeReason(move.from);
206
+ const unsafeDestination = existsSync(move.to) ? unsafeTreeReason(move.to) : void 0;
207
+ if (unsafeSource || unsafeDestination) throw new Error(unsafeSource ?? unsafeDestination);
208
+ const collides = existsSync(move.to);
209
+ if (collides && !selectedCollision(root, move, replacements)) {
210
+ result.skipped++;
211
+ result.preserved.push(move.to);
212
+ continue;
213
+ }
214
+ if (collides) {
215
+ replaceMove(move.from, move.to, mover);
216
+ result.replaced.push(move.to);
217
+ } else {
218
+ mover(move.from, move.to);
219
+ }
220
+ result.applied++;
221
+ } catch (error) {
222
+ result.errors.push({ move, error: error instanceof Error ? error.message : String(error) });
223
+ }
224
+ }
225
+ result.status = result.errors.length > 0 ? "incomplete" : "complete";
226
+ return result;
227
+ }
228
+ function inferProjectDir(plan) {
229
+ const first = plan.moves[0] ?? plan.skipped?.[0];
230
+ if (!first) return process.cwd();
231
+ const marker = join("docs", "");
232
+ const index = first.from.lastIndexOf(marker);
233
+ return index >= 0 ? first.from.slice(0, index) : dirname(first.from);
234
+ }
235
+ function selectedPlan(root, raw, includeUnknown) {
236
+ const selections = Array.isArray(includeUnknown) ? includeUnknown : [];
237
+ const unknownCandidates = [...raw.moves, ...raw.skipped ?? []].filter((move) => move.kind === "bugfix-dir");
238
+ const acceptedUnknown = unknownCandidates.filter((move) => includeUnknown === true || selectedCollision(root, move, selections));
239
+ const unknown = unknownCandidates.filter((move) => !acceptedUnknown.includes(move));
240
+ const moves = [...raw.moves.filter((move) => move.kind !== "bugfix-dir"), ...acceptedUnknown];
241
+ const skipped = [...(raw.skipped ?? []).filter((move) => move.kind !== "bugfix-dir")];
242
+ return { ...raw, moves, skipped, preserved: [...raw.preserved ?? [], ...unknown] };
243
+ }
244
+ function runMigration(projectDir, options = {}) {
245
+ const root = resolve(projectDir);
246
+ const plan = selectedPlan(root, planMigration(root), options.includeUnknown);
247
+ if (options.dryRun) return { ...emptyResult(), skipped: (plan.skipped?.length ?? 0) + (plan.preserved?.length ?? 0), preserved: [...(plan.skipped ?? []).map((move) => move.to), ...(plan.preserved ?? []).map((move) => move.from)], plan };
248
+ return { ...applyMigration(plan, options), plan };
249
+ }
250
+ function formatMigrationPlan(plan) {
251
+ const root = plan.projectDir ?? inferProjectDir(plan);
252
+ const lines = ["Joycraft migration plan:"];
253
+ if (plan.moves.length === 0 && !plan.skipped?.length && !plan.preserved?.length) lines.push(" No migration candidates found.");
254
+ for (const move of plan.moves) lines.push(` ${relativePath(root, move.from)} \u2192 ${relativePath(root, move.to)}`);
255
+ for (const move of plan.skipped ?? []) lines.push(` Preserve collision: ${relativePath(root, move.to)} (source: ${relativePath(root, move.from)})`);
256
+ for (const move of plan.preserved ?? []) lines.push(` Preserve unowned document: ${relativePath(root, move.from)} (candidate: ${relativePath(root, move.to)})`);
257
+ return lines.join("\n");
258
+ }
259
+ function formatMigrationOutcome(result, json = false, includePlan = true) {
260
+ if (json) return JSON.stringify({ status: result.status, exitCode: result.status === "complete" ? 0 : 1, applied: result.applied, skipped: result.skipped, replaced: result.replaced, preserved: result.preserved, errors: result.errors, plan: result.plan });
261
+ const lines = [...includePlan ? [formatMigrationPlan(result.plan)] : [], `Migration ${result.status}.`];
262
+ if (result.applied) lines.push(` Applied: ${result.applied}`);
263
+ if (result.skipped) lines.push(` Preserved collisions: ${result.skipped}`);
264
+ for (const entry of result.errors) lines.push(` \u26A0 ${entry.error}`);
265
+ return lines.join("\n");
266
+ }
267
+
268
+ // src/cli.ts
269
+ var __dirname = dirname2(fileURLToPath(import.meta.url));
270
+ var pkg = JSON.parse(readFileSync(join2(__dirname, "..", "package.json"), "utf-8"));
15
271
  var GITIGNORE_OPTION_DESC = `Gitignore profile: 'shared' (commit skills) or 'private' (gitignore ${PRIVATE_DIRS_DISPLAY})`;
16
272
  var program = new Command();
17
- var suppressUpdateNudge = false;
18
273
  program.name("joycraft").description("Scaffold and upgrade AI development harnesses").version(pkg.version, "-v, --version");
19
- program.command("init").description("Scaffold the Joycraft harness into the current project").argument("[dir]", "Target directory", ".").option("--force", "Overwrite existing files").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).action(async (dir, opts) => {
20
- const { init } = await import("./init-YSFURLGT.js");
274
+ program.command("update").description("Safely install or update Joycraft in a project").argument("[dir]", "Target directory", ".").option("--harnesses <list>", "Harnesses to install (comma or space separated)").option("--yes", "Apply safe updates without prompting").option("--non-interactive", "Never prompt; apply safe actions only").option("--replace-customized <paths...>", "Explicitly replace these customized paths").option("--repair <paths...>", "Explicitly restore these missing managed files").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).option("--json", "Print a structured JSON outcome").option("--recover", "Recover the interrupted update transaction").option("--rollback", "Rollback the last successful update").option("--preview", "Show planned changes without applying them").option("--auto-safe", "Require local opt-in and verified automatic-update safety").action(async (dir, opts) => {
275
+ const { update, formatUpdateOutcome } = await import("./update-HNTXCEKB.js");
21
276
  try {
22
- await init(dir, { force: opts.force ?? false, gitignore: opts.gitignore });
277
+ let verifiedArtifact;
278
+ if (opts.autoSafe) {
279
+ if (opts.recover || opts.rollback || opts.repair?.length || opts.replaceCustomized?.length || opts.gitignore || opts.harnesses) {
280
+ throw new Error("Automatic updates cannot include recovery, configuration, or customization choices.");
281
+ }
282
+ const { readUpdatePolicy } = await import("./update-check-YT765NE7.js");
283
+ if (readUpdatePolicy(dir) !== "auto-safe") throw new Error("Automatic updates require the explicitly configured local auto-safe policy.");
284
+ const { readInstallationManifestInfo } = await import("./install-manifest-EQHT4474.js");
285
+ const authorities = ["shared", "private"].map((profile) => readInstallationManifestInfo(dir, profile));
286
+ if (authorities.filter((info) => info.status !== "missing").length !== 1 || !authorities.some((info) => info.status === "valid")) {
287
+ throw new Error("Automatic updates require one valid existing installation manifest; run an explicit update first.");
288
+ }
289
+ const { resolveExactRelease } = await import("./release-resolver-P2H46QTU.js");
290
+ const { fetchVerifiedReleaseArtifact } = await import("./release-artifact-4TL5L2ZY.js");
291
+ const resolution = await resolveExactRelease({ version: pkg.version });
292
+ if (!resolution.ok) throw new Error(resolution.error);
293
+ verifiedArtifact = await fetchVerifiedReleaseArtifact(resolution.release);
294
+ }
295
+ const result = await update(dir, {
296
+ harnesses: opts.harnesses,
297
+ yes: opts.yes ?? false,
298
+ nonInteractive: opts.nonInteractive ?? false,
299
+ replaceCustomized: opts.replaceCustomized,
300
+ repair: opts.repair,
301
+ gitignore: opts.gitignore,
302
+ recovery: opts.recover ? "recover" : opts.rollback ? "rollback" : void 0,
303
+ preview: opts.preview,
304
+ json: opts.json,
305
+ automatic: opts.autoSafe,
306
+ verifiedArtifact
307
+ });
308
+ if (opts.preview) {
309
+ const actions = result.plan?.actions.map(({ path, kind, selected, reason }) => ({ path, kind, selected, reason })) ?? [];
310
+ if (opts.json) console.log(JSON.stringify({ ...JSON.parse(formatUpdateOutcome(result, true)), preview: true, actions }));
311
+ else console.log(["Preview only; no files changed.", ...actions.map((action) => `${action.selected ? "Planned" : "Preserved"}: ${action.kind} ${action.path}`), ...result.diagnostics].join("\n"));
312
+ } else console.log(formatUpdateOutcome(result, opts.json === true));
313
+ process.exitCode = result.exitCode;
23
314
  } catch (err) {
24
- console.error(err instanceof Error ? err.message : String(err));
25
- process.exit(1);
315
+ const message = err instanceof Error ? err.message : String(err);
316
+ if (opts.json) console.log(JSON.stringify({ status: "failed", exitCode: 1, applied: [], preserved: [], conflicts: [], diagnostics: [message] }));
317
+ else console.error(message);
318
+ process.exitCode = 1;
26
319
  }
27
320
  });
28
- program.command("upgrade").description("Upgrade installed Joycraft templates and skills to latest").argument("[dir]", "Target directory", ".").option("--yes", "Auto-accept all updates").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).action(async (dir, opts) => {
29
- const { upgrade } = await import("./upgrade-PELFI26D.js");
321
+ program.command("init").description("Scaffold the Joycraft harness into the current project").argument("[dir]", "Target directory", ".").option("--force", "Overwrite existing files").option("--harnesses <list>", "Harnesses to install (comma or space separated)").option("--yes", "Apply safe updates without prompting").option("--non-interactive", "Never prompt; apply safe actions only").option("--replace-customized <paths...>", "Explicitly replace these customized paths").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).option("--json", "Print a structured JSON outcome").action(async (dir, opts) => {
322
+ const { init, formatInitOutcome } = await import("./init-S5JU5BHL.js");
30
323
  try {
31
- const result = await upgrade(dir, { yes: opts.yes ?? false, gitignore: opts.gitignore });
32
- suppressUpdateNudge = result.cliWasStale;
324
+ const result = await init(dir, {
325
+ force: opts.force ?? false,
326
+ harnesses: opts.harnesses,
327
+ yes: opts.yes ?? false,
328
+ nonInteractive: opts.nonInteractive ?? false,
329
+ replaceCustomized: opts.replaceCustomized,
330
+ gitignore: opts.gitignore,
331
+ json: opts.json
332
+ });
333
+ if (result) {
334
+ console.log(formatInitOutcome(result, opts.json === true));
335
+ if (!opts.json && opts.harnesses === void 0 && process.stdin.isTTY !== true) console.log(" Compatibility: init selected all harnesses for this non-interactive run.");
336
+ }
337
+ if (result) process.exitCode = result.exitCode;
33
338
  } catch (err) {
34
- console.error(err instanceof Error ? err.message : String(err));
35
- process.exit(1);
339
+ const message = err instanceof Error ? err.message : String(err);
340
+ if (opts.json) console.log(JSON.stringify({ status: "failed", exitCode: 1, applied: [], preserved: [], conflicts: [], diagnostics: [message] }));
341
+ else console.error(message);
342
+ process.exitCode = 1;
343
+ }
344
+ });
345
+ program.command("upgrade").description("Upgrade installed Joycraft templates and skills to latest").argument("[dir]", "Target directory", ".").option("--yes", "Apply safe updates and preserve customizations without prompting").option("--non-interactive", "Never prompt; apply safe actions only").option("--harnesses <list>", "Harnesses to update (comma or space separated)").option("--replace-customized <paths...>", "Explicitly replace these customized paths").option("--gitignore <profile>", GITIGNORE_OPTION_DESC).option("--json", "Print a structured JSON outcome").action(async (dir, opts) => {
346
+ const { upgrade } = await import("./upgrade-LZOND7OZ.js");
347
+ try {
348
+ const result = await upgrade(dir, { yes: opts.yes ?? false, nonInteractive: opts.nonInteractive ?? false, harnesses: opts.harnesses, replaceCustomized: opts.replaceCustomized, gitignore: opts.gitignore, json: opts.json });
349
+ if (!opts.json) {
350
+ const { formatUpdateOutcome } = await import("./update-HNTXCEKB.js");
351
+ console.log(formatUpdateOutcome(result, false));
352
+ } else {
353
+ const { formatUpdateOutcome } = await import("./update-HNTXCEKB.js");
354
+ console.log(formatUpdateOutcome(result, true));
355
+ }
356
+ process.exitCode = result.exitCode;
357
+ } catch (err) {
358
+ const message = err instanceof Error ? err.message : String(err);
359
+ if (opts.json) console.log(JSON.stringify({ status: "failed", exitCode: 1, applied: [], preserved: [], conflicts: [], diagnostics: [message] }));
360
+ else console.error(message);
361
+ process.exitCode = 1;
362
+ }
363
+ });
364
+ program.command("migrate").description("Preview or explicitly apply the flat-docs to per-feature migration").argument("[dir]", "Target directory", ".").option("--apply", "Apply the displayed migration plan").option("--replace-collision <paths...>", "Replace these existing destination paths explicitly").option("--include-unknown <paths...>", "Explicitly establish ownership for orphan spec directories").option("--json", "Print a structured JSON outcome").action((dir, opts) => {
365
+ try {
366
+ const preview = runMigration(dir, { dryRun: true, includeUnknown: opts.includeUnknown });
367
+ if (!opts.apply) {
368
+ if (opts.json) console.log(JSON.stringify({ status: "preview", exitCode: 0, plan: preview.plan }));
369
+ else console.log(formatMigrationPlan(preview.plan));
370
+ return;
371
+ }
372
+ if (!opts.json) console.log(formatMigrationPlan(preview.plan));
373
+ const applied = applyMigration(preview.plan, { replaceCollisions: opts.replaceCollision });
374
+ const result = { ...applied, plan: preview.plan };
375
+ console.log(formatMigrationOutcome(result, opts.json === true, false));
376
+ process.exitCode = result.status === "complete" ? 0 : 1;
377
+ } catch (err) {
378
+ const message = err instanceof Error ? err.message : String(err);
379
+ if (opts.json) console.log(JSON.stringify({ status: "incomplete", exitCode: 1, applied: 0, skipped: 0, replaced: [], preserved: [], errors: [message] }));
380
+ else console.error(message);
381
+ process.exitCode = 1;
36
382
  }
37
383
  });
38
384
  program.command("telemetry").description("Scan AI-harness transcripts into knowledge-layer read telemetry").argument("[dir]", "Target directory", ".").action(async (dir) => {
39
385
  const { runTelemetryScan, formatTelemetrySummary } = await import("./telemetry-store-IBO5GRTA.js");
40
- const { resolve } = await import("path");
386
+ const { resolve: resolve2 } = await import("path");
41
387
  try {
42
- const result = await runTelemetryScan(resolve(dir));
388
+ const result = await runTelemetryScan(resolve2(dir));
43
389
  console.log(formatTelemetrySummary(result));
44
390
  } catch (err) {
45
391
  console.error(err instanceof Error ? err.message : String(err));
46
392
  process.exit(1);
47
393
  }
48
394
  });
49
- program.command("init-autofix").description("Set up the Level 5 auto-fix loop with holdout scenarios").argument("[dir]", "Target directory", ".").option("--scenarios-repo <name>", "Name for scenarios repo").option("--app-id <id>", "GitHub App ID for Joycraft Autofix").option("--force", "Overwrite existing workflow files").option("--dry-run", "Show what would be created without creating it").action(async (dir, opts) => {
50
- const { initAutofix } = await import("./init-autofix-E7DSPUSC.js");
51
- await initAutofix(dir, opts);
52
- });
53
- program.command("check-version").description("Check if a newer version of Joycraft is available").action(async () => {
395
+ program.command("check").description("Check for a newer Joycraft release using local cached state").argument("[dir]", "Target directory", ".").option("--json", "Print a structured JSON result").option("--explicit", "Bypass local acknowledgement and postponement").option("--session <id>", "Reuse one conversation identity for update notices").action(async (dir, opts) => {
396
+ const { resolve: resolve2 } = await import("path");
397
+ const { acknowledgeUpdate, checkForUpdate, resolveCheckSessionId } = await import("./update-check-YT765NE7.js");
54
398
  try {
55
- const { readFileSync: readFileSync2, existsSync } = await import("fs");
56
- const { join: join2 } = await import("path");
57
- const { STATE_PATH, LEGACY_VERSION_FILE, LEGACY_CLAUDE_STATE_PATH } = await import("./version-J7MOKNJR.js");
58
- const candidates = [STATE_PATH, LEGACY_CLAUDE_STATE_PATH, LEGACY_VERSION_FILE];
59
- const statePath = candidates.map((p) => join2(process.cwd(), p)).find((p) => existsSync(p)) ?? join2(process.cwd(), STATE_PATH);
60
- const data = JSON.parse(readFileSync2(statePath, "utf-8"));
61
- const res = await fetch("https://registry.npmjs.org/joycraft/latest", { signal: AbortSignal.timeout(3e3) });
62
- if (res.ok) {
63
- const latest = (await res.json()).version;
64
- if (data.version !== latest) {
65
- console.log(`Joycraft ${latest} available (you have ${data.version}). Run: npx joycraft@latest upgrade`);
66
- }
399
+ const root = resolve2(dir);
400
+ const session = resolveCheckSessionId(opts.session);
401
+ const result = await checkForUpdate(root, { explicit: opts.explicit === true, sessionId: session });
402
+ if (opts.json) console.log(JSON.stringify(result));
403
+ else if (result.display && result.availableVersion) {
404
+ console.log(`Joycraft ${result.availableVersion} available (you have ${result.installedVersion ?? "unknown"}). Run: npx joycraft@${result.availableVersion} update`);
405
+ acknowledgeUpdate(root, { release: result.availableVersion, session });
67
406
  }
68
407
  } catch {
69
408
  }
70
409
  });
71
- var updateCheckPromise = (async () => {
410
+ program.command("init-autofix").description("Set up the Level 5 auto-fix loop with holdout scenarios").argument("[dir]", "Target directory", ".").option("--scenarios-repo <name>", "Name for scenarios repo").option("--app-id <id>", "GitHub App ID for Joycraft Autofix").option("--force", "Overwrite existing workflow files").option("--dry-run", "Show what would be created without creating it").action(async (dir, opts) => {
411
+ const { initAutofix } = await import("./init-autofix-WSKUT2HN.js");
412
+ await initAutofix(dir, opts);
413
+ });
414
+ program.command("check-version").description("Check if a newer version of Joycraft is available").action(async () => {
72
415
  try {
73
- const res = await fetch("https://registry.npmjs.org/joycraft/latest", {
74
- signal: AbortSignal.timeout(3e3)
75
- });
76
- if (res.ok) {
77
- const latest = (await res.json()).version;
78
- if (latest !== pkg.version) {
79
- return `
80
- Joycraft ${latest} available (you have ${pkg.version}). Run: npx joycraft@latest upgrade`;
81
- }
416
+ const { acknowledgeUpdate, checkForUpdate, resolveCheckSessionId } = await import("./update-check-YT765NE7.js");
417
+ const root = process.cwd();
418
+ const session = resolveCheckSessionId();
419
+ const result = await checkForUpdate(root, { explicit: true, sessionId: session });
420
+ if (result.display && result.availableVersion) {
421
+ console.log(`Joycraft ${result.availableVersion} available (you have ${result.installedVersion ?? "unknown"}). Run: npx joycraft@${result.availableVersion} update`);
422
+ acknowledgeUpdate(root, { release: result.availableVersion, session });
82
423
  }
83
424
  } catch {
84
425
  }
85
- return null;
86
- })();
87
- program.hook("postAction", async () => {
88
- if (suppressUpdateNudge) return;
89
- const message = await updateCheckPromise;
90
- if (message) {
91
- console.log(message);
92
- }
93
426
  });
94
427
  if (process.argv.length <= 2) {
95
428
  program.outputHelp();
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\nimport { PRIVATE_DIRS_DISPLAY } from './gitignore.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));\n\nconst GITIGNORE_OPTION_DESC = `Gitignore profile: 'shared' (commit skills) or 'private' (gitignore ${PRIVATE_DIRS_DISPLAY})`;\n\nconst program = new Command();\n\n// Set by the upgrade action when the stale-CLI guard already delegated to (or\n// pointed the user at) the latest version — the postAction nudge would only\n// contradict the upgrade that just ran.\nlet suppressUpdateNudge = false;\n\nprogram\n .name('joycraft')\n .description('Scaffold and upgrade AI development harnesses')\n .version(pkg.version, '-v, --version');\n\nprogram\n .command('init')\n .description('Scaffold the Joycraft harness into the current project')\n .argument('[dir]', 'Target directory', '.')\n .option('--force', 'Overwrite existing files')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .action(async (dir: string, opts: { force?: boolean; gitignore?: string }) => {\n const { init } = await import('./init.js');\n try {\n await init(dir, { force: opts.force ?? false, gitignore: opts.gitignore });\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('upgrade')\n .description('Upgrade installed Joycraft templates and skills to latest')\n .argument('[dir]', 'Target directory', '.')\n .option('--yes', 'Auto-accept all updates')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .action(async (dir: string, opts: { yes?: boolean; gitignore?: string }) => {\n const { upgrade } = await import('./upgrade.js');\n try {\n const result = await upgrade(dir, { yes: opts.yes ?? false, gitignore: opts.gitignore });\n suppressUpdateNudge = result.cliWasStale;\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('telemetry')\n .description('Scan AI-harness transcripts into knowledge-layer read telemetry')\n .argument('[dir]', 'Target directory', '.')\n .action(async (dir: string) => {\n const { runTelemetryScan, formatTelemetrySummary } = await import('./telemetry-store.js');\n const { resolve } = await import('node:path');\n try {\n const result = await runTelemetryScan(resolve(dir));\n console.log(formatTelemetrySummary(result));\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('init-autofix')\n .description('Set up the Level 5 auto-fix loop with holdout scenarios')\n .argument('[dir]', 'Target directory', '.')\n .option('--scenarios-repo <name>', 'Name for scenarios repo')\n .option('--app-id <id>', 'GitHub App ID for Joycraft Autofix')\n .option('--force', 'Overwrite existing workflow files')\n .option('--dry-run', 'Show what would be created without creating it')\n .action(async (dir: string, opts: { scenariosRepo?: string; appId?: string; force?: boolean; dryRun?: boolean }) => {\n const { initAutofix } = await import('./init-autofix.js');\n await initAutofix(dir, opts);\n });\n\nprogram\n .command('check-version')\n .description('Check if a newer version of Joycraft is available')\n .action(async () => {\n try {\n const { readFileSync, existsSync } = await import('node:fs');\n const { join } = await import('node:path');\n const { STATE_PATH, LEGACY_VERSION_FILE, LEGACY_CLAUDE_STATE_PATH } = await import('./version.js');\n // Prefer the current state; fall back through the legacy locations for\n // projects not yet upgraded (upgrade relocates them): the interim\n // .claude/.joycraft/state.json, then the original repo-root file.\n const candidates = [STATE_PATH, LEGACY_CLAUDE_STATE_PATH, LEGACY_VERSION_FILE];\n const statePath =\n candidates.map((p) => join(process.cwd(), p)).find((p) => existsSync(p)) ??\n join(process.cwd(), STATE_PATH);\n const data = JSON.parse(readFileSync(statePath, 'utf-8'));\n const res = await fetch('https://registry.npmjs.org/joycraft/latest', { signal: AbortSignal.timeout(3000) });\n if (res.ok) {\n const latest = ((await res.json()) as { version: string }).version;\n if (data.version !== latest) {\n console.log(`Joycraft ${latest} available (you have ${data.version}). Run: npx joycraft@latest upgrade`);\n }\n }\n } catch {\n // Silent — don't block session start\n }\n });\n\n// Start update check immediately so it runs in parallel with the command\nconst updateCheckPromise = (async (): Promise<string | null> => {\n try {\n const res = await fetch('https://registry.npmjs.org/joycraft/latest', {\n signal: AbortSignal.timeout(3000)\n });\n if (res.ok) {\n const latest = ((await res.json()) as { version: string }).version;\n if (latest !== pkg.version) {\n return `\\nJoycraft ${latest} available (you have ${pkg.version}). Run: npx joycraft@latest upgrade`;\n }\n }\n } catch {\n // Silent — don't block or error on network issues\n }\n return null;\n})();\n\n// Print update nudge after every command\nprogram.hook('postAction', async () => {\n if (suppressUpdateNudge) return;\n const message = await updateCheckPromise;\n if (message) {\n console.log(message);\n }\n});\n\n// Show help when no arguments provided\nif (process.argv.length <= 2) {\n program.outputHelp();\n process.exit(0);\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAG9B,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,IAAM,MAAM,KAAK,MAAM,aAAa,KAAK,WAAW,MAAM,cAAc,GAAG,OAAO,CAAC;AAEnF,IAAM,wBAAwB,uEAAuE,oBA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AM,UAAW,MAAM,IAAI,KAAK,GAA2B;AAC3D,UAAI,KAAK,YAAY,QAAQ;AAC3B,gBAAQ,IAAI,YAAY,MAAM,wBAAwB,KAAK,OAAO,qCAAqC;AAAA,MACzG;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACF,CAAC;AAGH,IAAM,sBAAsB,YAAoC;AAC9D,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,8CAA8C;AAAA,MACpE,QAAQ,YAAY,QAAQ,GAAI;AAAA,IAClC,CAAC;AACD,QAAI,IAAI,IAAI;AACV,YAAM,UAAW,MAAM,IAAI,KAAK,GAA2B;AAC3D,UAAI,WAAW,IAAI,SAAS;AAC1B,eAAO;AAAA,WAAc,MAAM,wBAAwB,IAAI,OAAO;AAAA,MAChE;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT,GAAG;AAGH,QAAQ,KAAK,cAAc,YAAY;AACrC,MAAI,oBAAqB;AACzB,QAAM,UAAU,MAAM;AACtB,MAAI,SAAS;AACX,YAAQ,IAAI,OAAO;AAAA,EACrB;AACF,CAAC;AAGD,IAAI,QAAQ,KAAK,UAAU,GAAG;AAC5B,UAAQ,WAAW;AACnB,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,MAAM;","names":["readFileSync","join"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/migration.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { fileURLToPath } from 'url';\nimport { dirname, join } from 'path';\nimport { PRIVATE_DIRS_DISPLAY } from './gitignore.js';\nimport { applyMigration, formatMigrationPlan, formatMigrationOutcome, runMigration } from './migration.js';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));\n\nconst GITIGNORE_OPTION_DESC = `Gitignore profile: 'shared' (commit skills) or 'private' (gitignore ${PRIVATE_DIRS_DISPLAY})`;\n\nconst program = new Command();\n\nprogram\n .name('joycraft')\n .description('Scaffold and upgrade AI development harnesses')\n .version(pkg.version, '-v, --version');\n\nprogram\n .command('update')\n .description('Safely install or update Joycraft in a project')\n .argument('[dir]', 'Target directory', '.')\n .option('--harnesses <list>', 'Harnesses to install (comma or space separated)')\n .option('--yes', 'Apply safe updates without prompting')\n .option('--non-interactive', 'Never prompt; apply safe actions only')\n .option('--replace-customized <paths...>', 'Explicitly replace these customized paths')\n .option('--repair <paths...>', 'Explicitly restore these missing managed files')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .option('--json', 'Print a structured JSON outcome')\n .option('--recover', 'Recover the interrupted update transaction')\n .option('--rollback', 'Rollback the last successful update')\n .option('--preview', 'Show planned changes without applying them')\n .option('--auto-safe', 'Require local opt-in and verified automatic-update safety')\n .action(async (dir: string, opts: {\n harnesses?: string;\n yes?: boolean;\n nonInteractive?: boolean;\n replaceCustomized?: string[];\n repair?: string[];\n gitignore?: string;\n json?: boolean;\n recover?: boolean;\n rollback?: boolean;\n preview?: boolean;\n autoSafe?: boolean;\n }) => {\n const { update, formatUpdateOutcome } = await import('./update.js');\n try {\n let verifiedArtifact;\n if (opts.autoSafe) {\n if (opts.recover || opts.rollback || opts.repair?.length || opts.replaceCustomized?.length || opts.gitignore || opts.harnesses) {\n throw new Error('Automatic updates cannot include recovery, configuration, or customization choices.');\n }\n const { readUpdatePolicy } = await import('./update-check.js');\n if (readUpdatePolicy(dir) !== 'auto-safe') throw new Error('Automatic updates require the explicitly configured local auto-safe policy.');\n const { readInstallationManifestInfo } = await import('./install-manifest.js');\n const authorities = ['shared', 'private'].map(profile => readInstallationManifestInfo(dir, profile as 'shared' | 'private'));\n if (authorities.filter(info => info.status !== 'missing').length !== 1 || !authorities.some(info => info.status === 'valid')) {\n throw new Error('Automatic updates require one valid existing installation manifest; run an explicit update first.');\n }\n const { resolveExactRelease } = await import('./release-resolver.js');\n const { fetchVerifiedReleaseArtifact } = await import('./release-artifact.js');\n // The agent selected this exact candidate before invoking its CLI.\n // Verify its artifact once; the update engine never resolves latest.\n const resolution = await resolveExactRelease({ version: pkg.version });\n if (!resolution.ok) throw new Error(resolution.error);\n verifiedArtifact = await fetchVerifiedReleaseArtifact(resolution.release);\n }\n const result = await update(dir, {\n harnesses: opts.harnesses,\n yes: opts.yes ?? false,\n nonInteractive: opts.nonInteractive ?? false,\n replaceCustomized: opts.replaceCustomized,\n repair: opts.repair,\n gitignore: opts.gitignore,\n recovery: opts.recover ? 'recover' : opts.rollback ? 'rollback' : undefined,\n preview: opts.preview,\n json: opts.json,\n automatic: opts.autoSafe,\n verifiedArtifact,\n });\n if (opts.preview) {\n const actions = result.plan?.actions.map(({ path, kind, selected, reason }) => ({ path, kind, selected, reason })) ?? [];\n if (opts.json) console.log(JSON.stringify({ ...JSON.parse(formatUpdateOutcome(result, true)), preview: true, actions }));\n else console.log(['Preview only; no files changed.', ...actions.map(action => `${action.selected ? 'Planned' : 'Preserved'}: ${action.kind} ${action.path}`), ...result.diagnostics].join('\\n'));\n } else console.log(formatUpdateOutcome(result, opts.json === true));\n process.exitCode = result.exitCode;\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (opts.json) console.log(JSON.stringify({ status: 'failed', exitCode: 1, applied: [], preserved: [], conflicts: [], diagnostics: [message] }));\n else console.error(message);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('init')\n .description('Scaffold the Joycraft harness into the current project')\n .argument('[dir]', 'Target directory', '.')\n .option('--force', 'Overwrite existing files')\n .option('--harnesses <list>', 'Harnesses to install (comma or space separated)')\n .option('--yes', 'Apply safe updates without prompting')\n .option('--non-interactive', 'Never prompt; apply safe actions only')\n .option('--replace-customized <paths...>', 'Explicitly replace these customized paths')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .option('--json', 'Print a structured JSON outcome')\n .action(async (dir: string, opts: { force?: boolean; harnesses?: string; yes?: boolean; nonInteractive?: boolean; replaceCustomized?: string[]; gitignore?: string; json?: boolean }) => {\n const { init, formatInitOutcome } = await import('./init.js');\n try {\n const result = await init(dir, {\n force: opts.force ?? false,\n harnesses: opts.harnesses,\n yes: opts.yes ?? false,\n nonInteractive: opts.nonInteractive ?? false,\n replaceCustomized: opts.replaceCustomized,\n gitignore: opts.gitignore,\n json: opts.json,\n });\n if (result) {\n console.log(formatInitOutcome(result, opts.json === true));\n if (!opts.json && opts.harnesses === undefined && process.stdin.isTTY !== true) console.log(' Compatibility: init selected all harnesses for this non-interactive run.');\n }\n if (result) process.exitCode = result.exitCode;\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (opts.json) console.log(JSON.stringify({ status: 'failed', exitCode: 1, applied: [], preserved: [], conflicts: [], diagnostics: [message] }));\n else console.error(message);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('upgrade')\n .description('Upgrade installed Joycraft templates and skills to latest')\n .argument('[dir]', 'Target directory', '.')\n .option('--yes', 'Apply safe updates and preserve customizations without prompting')\n .option('--non-interactive', 'Never prompt; apply safe actions only')\n .option('--harnesses <list>', 'Harnesses to update (comma or space separated)')\n .option('--replace-customized <paths...>', 'Explicitly replace these customized paths')\n .option('--gitignore <profile>', GITIGNORE_OPTION_DESC)\n .option('--json', 'Print a structured JSON outcome')\n .action(async (dir: string, opts: { yes?: boolean; nonInteractive?: boolean; harnesses?: string; replaceCustomized?: string[]; gitignore?: string; json?: boolean }) => {\n const { upgrade } = await import('./upgrade.js');\n try {\n const result = await upgrade(dir, { yes: opts.yes ?? false, nonInteractive: opts.nonInteractive ?? false, harnesses: opts.harnesses, replaceCustomized: opts.replaceCustomized, gitignore: opts.gitignore, json: opts.json });\n if (!opts.json) {\n const { formatUpdateOutcome } = await import('./update.js');\n console.log(formatUpdateOutcome(result, false));\n } else {\n const { formatUpdateOutcome } = await import('./update.js');\n console.log(formatUpdateOutcome(result, true));\n }\n process.exitCode = result.exitCode;\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (opts.json) console.log(JSON.stringify({ status: 'failed', exitCode: 1, applied: [], preserved: [], conflicts: [], diagnostics: [message] }));\n else console.error(message);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('migrate')\n .description('Preview or explicitly apply the flat-docs to per-feature migration')\n .argument('[dir]', 'Target directory', '.')\n .option('--apply', 'Apply the displayed migration plan')\n .option('--replace-collision <paths...>', 'Replace these existing destination paths explicitly')\n .option('--include-unknown <paths...>', 'Explicitly establish ownership for orphan spec directories')\n .option('--json', 'Print a structured JSON outcome')\n .action((dir: string, opts: { apply?: boolean; replaceCollision?: string[]; includeUnknown?: string[]; json?: boolean }) => {\n try {\n const preview = runMigration(dir, { dryRun: true, includeUnknown: opts.includeUnknown });\n if (!opts.apply) {\n if (opts.json) console.log(JSON.stringify({ status: 'preview', exitCode: 0, plan: preview.plan }));\n else console.log(formatMigrationPlan(preview.plan));\n return;\n }\n // Render the same plan that will be applied.\n if (!opts.json) console.log(formatMigrationPlan(preview.plan));\n const applied = applyMigration(preview.plan, { replaceCollisions: opts.replaceCollision });\n const result = { ...applied, plan: preview.plan };\n console.log(formatMigrationOutcome(result, opts.json === true, false));\n process.exitCode = result.status === 'complete' ? 0 : 1;\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (opts.json) console.log(JSON.stringify({ status: 'incomplete', exitCode: 1, applied: 0, skipped: 0, replaced: [], preserved: [], errors: [message] }));\n else console.error(message);\n process.exitCode = 1;\n }\n });\n\nprogram\n .command('telemetry')\n .description('Scan AI-harness transcripts into knowledge-layer read telemetry')\n .argument('[dir]', 'Target directory', '.')\n .action(async (dir: string) => {\n const { runTelemetryScan, formatTelemetrySummary } = await import('./telemetry-store.js');\n const { resolve } = await import('node:path');\n try {\n const result = await runTelemetryScan(resolve(dir));\n console.log(formatTelemetrySummary(result));\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exit(1);\n }\n });\n\nprogram\n .command('check')\n .description('Check for a newer Joycraft release using local cached state')\n .argument('[dir]', 'Target directory', '.')\n .option('--json', 'Print a structured JSON result')\n .option('--explicit', 'Bypass local acknowledgement and postponement')\n .option('--session <id>', 'Reuse one conversation identity for update notices')\n .action(async (dir: string, opts: { json?: boolean; explicit?: boolean; session?: string }) => {\n const { resolve } = await import('node:path');\n const { acknowledgeUpdate, checkForUpdate, resolveCheckSessionId } = await import('./update-check.js');\n try {\n const root = resolve(dir);\n const session = resolveCheckSessionId(opts.session);\n const result = await checkForUpdate(root, { explicit: opts.explicit === true, sessionId: session });\n if (opts.json) console.log(JSON.stringify(result));\n else if (result.display && result.availableVersion) {\n console.log(`Joycraft ${result.availableVersion} available (you have ${result.installedVersion ?? 'unknown'}). Run: npx joycraft@${result.availableVersion} update`);\n acknowledgeUpdate(root, { release: result.availableVersion, session });\n }\n } catch {\n // A check must never block the caller's requested work.\n }\n });\n\nprogram\n .command('init-autofix')\n .description('Set up the Level 5 auto-fix loop with holdout scenarios')\n .argument('[dir]', 'Target directory', '.')\n .option('--scenarios-repo <name>', 'Name for scenarios repo')\n .option('--app-id <id>', 'GitHub App ID for Joycraft Autofix')\n .option('--force', 'Overwrite existing workflow files')\n .option('--dry-run', 'Show what would be created without creating it')\n .action(async (dir: string, opts: { scenariosRepo?: string; appId?: string; force?: boolean; dryRun?: boolean }) => {\n const { initAutofix } = await import('./init-autofix.js');\n await initAutofix(dir, opts);\n });\n\nprogram\n .command('check-version')\n .description('Check if a newer version of Joycraft is available')\n .action(async () => {\n try {\n const { acknowledgeUpdate, checkForUpdate, resolveCheckSessionId } = await import('./update-check.js');\n const root = process.cwd();\n const session = resolveCheckSessionId();\n const result = await checkForUpdate(root, { explicit: true, sessionId: session });\n if (result.display && result.availableVersion) {\n console.log(`Joycraft ${result.availableVersion} available (you have ${result.installedVersion ?? 'unknown'}). Run: npx joycraft@${result.availableVersion} update`);\n acknowledgeUpdate(root, { release: result.availableVersion, session });\n }\n } catch {\n // Silent — don't block session start\n }\n });\n\n// Show help when no arguments provided\nif (process.argv.length <= 2) {\n program.outputHelp();\n process.exit(0);\n}\n\nprogram.parse();\n","// Explicit migration of the pre-feature docs layout. Routine bundle updates\n// deliberately do not call this module: moving project documents is a\n// separate, reviewable operation.\n\nimport {\n cpSync,\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n renameSync,\n rmSync,\n} from 'node:fs';\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport { randomUUID } from 'node:crypto';\nimport { resolveUpdatePath } from './update-paths.js';\n\nexport type MoveKind = 'brief' | 'research' | 'design' | 'specs-dir' | 'bugfix-dir';\n\nexport interface Move {\n from: string;\n to: string;\n kind: MoveKind;\n}\n\nexport interface MigrationPlan {\n /** Canonical project root, present on plans produced by planMigration. */\n projectDir?: string;\n moves: Move[];\n slugs: string[];\n orphans: { specsDirs: string[] };\n /** Existing destinations. They are retained for compatibility and are not overwritten by default. */\n skipped?: Move[];\n /** Candidates deliberately retained because ownership was not established. */\n preserved?: Move[];\n}\n\nexport interface MigrationApplyOptions {\n /** Destination (or source) paths selected for explicit replacement. */\n replaceCollisions?: readonly string[];\n /** Test and integration seam for a deterministic filesystem failure. */\n move?: (from: string, to: string) => void;\n}\n\nexport interface MigrationResult {\n status: 'complete' | 'incomplete';\n applied: number;\n skipped: number;\n replaced: string[];\n preserved: string[];\n errors: Array<{ move: Move; error: string }>;\n}\n\nexport interface MigrationOptions extends MigrationApplyOptions {\n /** Explicitly establish ownership for orphan/area directories. */\n includeUnknown?: boolean | readonly string[];\n /** Do not mutate; return the selected plan and a complete no-op result. */\n dryRun?: boolean;\n}\n\nexport interface MigrationOutcome extends MigrationResult {\n plan: MigrationPlan;\n}\n\nconst DATE_PREFIX_RE = /^\\d{4}-\\d{2}-\\d{2}-(.+)$/;\n\nfunction deriveSlug(filename: string): string { return filename.replace(/\\.md$/, ''); }\nfunction slugWithoutDate(slug: string): string | null {\n const m = slug.match(DATE_PREFIX_RE);\n return m ? m[1] : null;\n}\n\nfunction listMdFiles(dir: string): string[] {\n if (!existsSync(dir)) return [];\n try { return readdirSync(dir).filter((f) => f.endsWith('.md')); } catch { return []; }\n}\n\nfunction listSubdirs(dir: string): string[] {\n if (!existsSync(dir)) return [];\n try {\n return readdirSync(dir).filter((name) => {\n try { return lstatSync(join(dir, name)).isDirectory(); } catch { return false; }\n });\n } catch { return []; }\n}\n\nfunction destinationMove(from: string, to: string, kind: MoveKind): Move { return { from, to, kind }; }\n\nexport function planMigration(projectDir: string): MigrationPlan {\n const root = resolve(projectDir);\n const briefsDir = join(root, 'docs', 'briefs');\n const researchDir = join(root, 'docs', 'research');\n const designsDir = join(root, 'docs', 'designs');\n const specsDir = join(root, 'docs', 'specs');\n const moves: Move[] = [];\n const skipped: Move[] = [];\n const slugSet = new Set<string>();\n const addFileMoves = (dir: string, kind: 'brief' | 'research' | 'design', targetName: string): void => {\n for (const file of listMdFiles(dir)) {\n const slug = deriveSlug(file);\n slugSet.add(slug);\n const move = destinationMove(join(dir, file), join(root, 'docs', 'features', slug, targetName), kind);\n (existsSync(move.to) ? skipped : moves).push(move);\n }\n };\n addFileMoves(briefsDir, 'brief', 'brief.md');\n addFileMoves(researchDir, 'research', 'research.md');\n addFileMoves(designsDir, 'design', 'design.md');\n\n // Matching a discovered brief establishes feature ownership. Orphans stay\n // visible in the low-level plan for compatibility; runMigration requires an\n // explicit includeUnknown selection before moving them.\n const briefSlugs = Array.from(slugSet);\n const orphanSpecsDirs: string[] = [];\n for (const subdir of listSubdirs(specsDir)) {\n const matchedSlug = briefSlugs.includes(subdir)\n ? subdir\n : (briefSlugs.find((slug) => slugWithoutDate(slug) === subdir) ?? null);\n const kind: MoveKind = matchedSlug ? 'specs-dir' : 'bugfix-dir';\n const target = matchedSlug\n ? join(root, 'docs', 'features', matchedSlug, 'specs')\n : join(root, 'docs', 'bugfixes', subdir);\n const move = destinationMove(join(specsDir, subdir), target, kind);\n if (!matchedSlug) orphanSpecsDirs.push(subdir);\n (existsSync(move.to) ? skipped : moves).push(move);\n }\n const plan: MigrationPlan = { projectDir: root, moves, slugs: Array.from(slugSet), orphans: { specsDirs: orphanSpecsDirs } };\n if (skipped.length > 0) plan.skipped = skipped;\n return plan;\n}\n\nfunction relativePath(root: string, path: string): string {\n return relative(root, path).split('\\\\').join('/') || '.';\n}\n\nfunction pathSelection(root: string, selection: string): string {\n return isAbsolute(selection) ? resolve(selection) : resolve(root, selection);\n}\n\nfunction selectedCollision(root: string, move: Move, selections: readonly string[]): boolean {\n return selections.some((selection) => {\n const selected = pathSelection(root, selection);\n return selected === resolve(move.to) || selected === resolve(move.from)\n || selection === relativePath(root, move.to) || selection === relativePath(root, move.from);\n });\n}\n\nfunction isInside(root: string, candidate: string): boolean {\n const rel = relative(root, candidate);\n return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));\n}\n\nfunction inspectPath(root: string, path: string, allowMissing: boolean): void {\n const rootAbsolute = resolve(root);\n const candidate = resolve(path);\n if (!isInside(rootAbsolute, candidate)) throw new Error(`Migration path escapes the project root: '${path}'.`);\n const rel = relativePath(rootAbsolute, candidate);\n if (rel === '.') return;\n resolveUpdatePath(rootAbsolute, rel);\n if (!allowMissing && !existsSync(candidate)) throw new Error(`Migration source is missing: '${path}'.`);\n}\n\nfunction unsafeTreeReason(path: string): string | undefined {\n let stat;\n try { stat = lstatSync(path); } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n return code === 'ENOENT' ? undefined : `Unable to inspect migration path '${path}': ${String(error)}`;\n }\n if (stat.isSymbolicLink()) return `Migration path traverses a symlink: '${path}'.`;\n if (!stat.isDirectory()) return undefined;\n let names: string[];\n try { names = readdirSync(path); } catch (error) {\n return `Unable to inspect migration directory '${path}': ${String(error)}`;\n }\n for (const name of names) {\n const reason = unsafeTreeReason(join(path, name));\n if (reason) return reason;\n }\n return undefined;\n}\n\nfunction moveFsItem(from: string, to: string): void {\n mkdirSync(dirname(to), { recursive: true });\n try {\n renameSync(from, to);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== 'EXDEV') throw err;\n // Remove the source only after the copy has completed.\n cpSync(from, to, { recursive: true, force: false, errorOnExist: true });\n rmSync(from, { recursive: true, force: false });\n }\n}\n\nfunction replaceMove(from: string, to: string, move: (from: string, to: string) => void): void {\n const displaced = `${to}.joycraft-migration-${randomUUID()}`;\n let movedAside = false;\n if (existsSync(to)) {\n renameSync(to, displaced);\n movedAside = true;\n }\n try {\n move(from, to);\n } catch (error) {\n if (movedAside && existsSync(displaced)) {\n if (existsSync(to)) {\n throw new Error(`${String(error)}; original destination retained at '${displaced}', interrupted move content retained at '${to}'.`);\n }\n try {\n renameSync(displaced, to);\n } catch (restoreError) {\n throw new Error(`${error instanceof Error ? error.message : String(error)}; original destination retained at '${displaced}' (${String(restoreError)}).`);\n }\n }\n throw error;\n }\n if (movedAside) {\n try { rmSync(displaced, { recursive: true, force: false }); }\n catch (error) { throw new Error(`Move applied; previous destination backup remains at '${displaced}': ${String(error)}`); }\n }\n}\n\nfunction emptyResult(): MigrationResult {\n return { status: 'complete', applied: 0, skipped: 0, replaced: [], preserved: [], errors: [] };\n}\n\nexport function applyMigration(plan: MigrationPlan, options: MigrationApplyOptions = {}): MigrationResult {\n const root = resolve(plan.projectDir ?? inferProjectDir(plan));\n const result = emptyResult();\n const replacements = options.replaceCollisions ?? [];\n const mover = options.move ?? moveFsItem;\n const allMoves = [...plan.moves, ...(plan.skipped ?? [])];\n for (const move of plan.preserved ?? []) {\n result.skipped++;\n result.preserved.push(move.from);\n }\n const seen = new Set<string>();\n for (const move of allMoves) {\n const key = `${move.from}\\0${move.to}`;\n if (seen.has(key)) continue;\n seen.add(key);\n try {\n inspectPath(root, move.from, false);\n inspectPath(root, move.to, true);\n const unsafeSource = unsafeTreeReason(move.from);\n const unsafeDestination = existsSync(move.to) ? unsafeTreeReason(move.to) : undefined;\n if (unsafeSource || unsafeDestination) throw new Error(unsafeSource ?? unsafeDestination);\n const collides = existsSync(move.to);\n if (collides && !selectedCollision(root, move, replacements)) {\n result.skipped++;\n result.preserved.push(move.to);\n continue;\n }\n if (collides) {\n replaceMove(move.from, move.to, mover);\n result.replaced.push(move.to);\n } else {\n mover(move.from, move.to);\n }\n result.applied++;\n } catch (error) {\n result.errors.push({ move, error: error instanceof Error ? error.message : String(error) });\n }\n }\n result.status = result.errors.length > 0 ? 'incomplete' : 'complete';\n return result;\n}\n\nfunction inferProjectDir(plan: MigrationPlan): string {\n const first = plan.moves[0] ?? plan.skipped?.[0];\n if (!first) return process.cwd();\n const marker = join('docs', '');\n const index = first.from.lastIndexOf(marker);\n return index >= 0 ? first.from.slice(0, index) : dirname(first.from);\n}\n\nfunction selectedPlan(root: string, raw: MigrationPlan, includeUnknown: MigrationOptions['includeUnknown']): MigrationPlan {\n const selections: readonly string[] = Array.isArray(includeUnknown) ? includeUnknown : [];\n const unknownCandidates = [...raw.moves, ...(raw.skipped ?? [])].filter((move) => move.kind === 'bugfix-dir');\n const acceptedUnknown = unknownCandidates.filter((move) =>\n includeUnknown === true || selectedCollision(root, move, selections));\n const unknown = unknownCandidates.filter((move) => !acceptedUnknown.includes(move));\n const moves = [...raw.moves.filter((move) => move.kind !== 'bugfix-dir'), ...acceptedUnknown];\n const skipped = [...(raw.skipped ?? []).filter((move) => move.kind !== 'bugfix-dir')];\n return { ...raw, moves, skipped, preserved: [...(raw.preserved ?? []), ...unknown] };\n}\n\n/** Execute the deliberate project migration operation. */\nexport function runMigration(projectDir: string, options: MigrationOptions = {}): MigrationOutcome {\n const root = resolve(projectDir);\n const plan = selectedPlan(root, planMigration(root), options.includeUnknown);\n if (options.dryRun) return { ...emptyResult(), skipped: (plan.skipped?.length ?? 0) + (plan.preserved?.length ?? 0), preserved: [...(plan.skipped ?? []).map((move) => move.to), ...(plan.preserved ?? []).map((move) => move.from)], plan };\n return { ...applyMigration(plan, options), plan };\n}\n\nexport function formatMigrationPlan(plan: MigrationPlan): string {\n const root = plan.projectDir ?? inferProjectDir(plan);\n const lines = ['Joycraft migration plan:'];\n if (plan.moves.length === 0 && !plan.skipped?.length && !plan.preserved?.length) lines.push(' No migration candidates found.');\n for (const move of plan.moves) lines.push(` ${relativePath(root, move.from)} → ${relativePath(root, move.to)}`);\n for (const move of plan.skipped ?? []) lines.push(` Preserve collision: ${relativePath(root, move.to)} (source: ${relativePath(root, move.from)})`);\n for (const move of plan.preserved ?? []) lines.push(` Preserve unowned document: ${relativePath(root, move.from)} (candidate: ${relativePath(root, move.to)})`);\n return lines.join('\\n');\n}\n\nexport function formatMigrationOutcome(result: MigrationOutcome, json = false, includePlan = true): string {\n if (json) return JSON.stringify({ status: result.status, exitCode: result.status === 'complete' ? 0 : 1, applied: result.applied, skipped: result.skipped, replaced: result.replaced, preserved: result.preserved, errors: result.errors, plan: result.plan });\n const lines = [ ...(includePlan ? [formatMigrationPlan(result.plan)] : []), `Migration ${result.status}.`];\n if (result.applied) lines.push(` Applied: ${result.applied}`);\n if (result.skipped) lines.push(` Preserved collisions: ${result.skipped}`);\n for (const entry of result.errors) lines.push(` ⚠ ${entry.error}`);\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,WAAAA,UAAS,QAAAC,aAAY;;;ACC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS,YAAY,MAAM,UAAU,SAAS,WAAW;AAClE,SAAS,kBAAkB;AAkD3B,IAAM,iBAAiB;AAEvB,SAAS,WAAW,UAA0B;AAAE,SAAO,SAAS,QAAQ,SAAS,EAAE;AAAG;AACtF,SAAS,gBAAgB,MAA6B;AACpD,QAAM,IAAI,KAAK,MAAM,cAAc;AACnC,SAAO,IAAI,EAAE,CAAC,IAAI;AACpB;AAEA,SAAS,YAAY,KAAuB;AAC1C,MAAI,CAAC,WAAW,GAAG,EAAG,QAAO,CAAC;AAC9B,MAAI;AAAE,WAAO,YAAY,GAAG,EAAE,OAAO,CAAC,MAAM,EA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