@punks/cli 2.1.4 → 2.1.6

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/dist/index.js CHANGED
@@ -10894,6 +10894,7 @@ import { spawn as spawn2 } from "child_process";
10894
10894
  import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
10895
10895
  import { homedir as homedir3 } from "os";
10896
10896
  import path16 from "path";
10897
+ import { createInterface as createInterface3 } from "readline/promises";
10897
10898
 
10898
10899
  // ../../node_modules/.bun/effect@3.21.2/node_modules/effect/dist/esm/Array.js
10899
10900
  var exports_Array = {};
@@ -52336,7 +52337,8 @@ class ProjectUsageSummary extends exports_Schema.Class("ProjectUsageSummary")({
52336
52337
  }
52337
52338
 
52338
52339
  class ProjectUsageList extends exports_Schema.Class("ProjectUsageList")({
52339
- projects: exports_Schema.Array(ProjectUsageSummary)
52340
+ projects: exports_Schema.Array(ProjectUsageSummary),
52341
+ reports: exports_Schema.Array(HarnessReportSummary)
52340
52342
  }) {
52341
52343
  }
52342
52344
 
@@ -52405,7 +52407,7 @@ var recordProductTelemetryEvent = (options9) => exports_Effect.gen(function* ()
52405
52407
 
52406
52408
  // package.json
52407
52409
  var name = "@punks/cli";
52408
- var version = "2.1.4";
52410
+ var version = "2.1.6";
52409
52411
  // src/telemetry/product.ts
52410
52412
  var git = (cwd, args2) => {
52411
52413
  try {
@@ -52669,7 +52671,7 @@ var renderCommandGuide = () => [
52669
52671
  "usage:",
52670
52672
  " \u2022 agents should activate `$dp-cli` before acting on `.devpunks` output",
52671
52673
  " \u2022 start with `punks scaffold` to inspect the lifecycle",
52672
- " \u2022 use `punks scaffold init` for requirements grilling, backlog authoring, and wiki schema seeding",
52674
+ " \u2022 use `punks scaffold init` to choose the backlog provider and seed requirements/wiki output",
52673
52675
  " \u2022 reconcile the seeded wiki into the real repo layout before writing durable docs",
52674
52676
  " \u2022 use `punks scaffold setup` for repo-aware pack detection after repo boilerplate is ready",
52675
52677
  " \u2022 use `punks update` after setup to pull newer scaffolded skills/prompts/manifests/hooks",
@@ -52677,7 +52679,7 @@ var renderCommandGuide = () => [
52677
52679
  " \u2022 reports open GitHub issues; authenticate with `gh auth login` or `GITHUB_TOKEN`",
52678
52680
  "",
52679
52681
  "operator notes:",
52680
- " \u2022 init copies only requirements/backlog skills and the initial wiki structure",
52682
+ " \u2022 init copies only requirements/backlog skills, backlog-provider pin, and the initial wiki structure",
52681
52683
  " \u2022 `setup` remains the repo-aware pack-driven scaffold flow",
52682
52684
  " \u2022 each command prints an operator-facing next-step prompt"
52683
52685
  ].join(`
@@ -52698,7 +52700,7 @@ var renderStageIntro = ({
52698
52700
  "",
52699
52701
  "usage:",
52700
52702
  " \u2022 agents should activate `$dp-cli` before following generated output",
52701
- " \u2022 use this to scaffold requirements grill/backlog skills and seed the initial wiki tree",
52703
+ " \u2022 use this to choose the backlog provider, scaffold requirements/backlog skills, and seed the initial wiki tree",
52702
52704
  " \u2022 reconcile the wiki into the real repo layout, such as `apps/wiki` in a monorepo",
52703
52705
  " \u2022 rerunning this command overwrites only the files for this stage",
52704
52706
  " \u2022 read the generated prompt/output and follow it before running repo-aware setup"
@@ -52732,14 +52734,14 @@ var renderScaffoldGuide = () => [
52732
52734
  "",
52733
52735
  "commands:",
52734
52736
  " \u203A punks scaffold init",
52735
- " \u2514 requirements gate: scaffold `requirements-grill`, `write-backlog`, and seed the wiki tree",
52737
+ " \u2514 requirements gate: pick backlog provider, scaffold `requirements-grill`/`write-backlog`, seed wiki",
52736
52738
  " \u203A punks scaffold setup",
52737
52739
  " \u2514 repo-aware setup: detect packs, scaffold prompts/manifests/hooks",
52738
52740
  "",
52739
52741
  "operator notes:",
52740
52742
  " \u2022 agents should activate `$dp-cli` before acting on generated scaffold output",
52741
52743
  " \u2022 `init` overwrites only its scaffolded skill files on rerun",
52742
- " \u2022 `init` seeds a wiki root that agents must reconcile with the real repo layout",
52744
+ " \u2022 `init` pins the backlog provider and seeds a wiki root agents must reconcile with the real repo layout",
52743
52745
  " \u2022 `setup` is the first repo-aware command in the lifecycle",
52744
52746
  " \u2022 setup output must be followed from `.devpunks`, not summarized from terminal text alone"
52745
52747
  ].join(`
@@ -54364,6 +54366,44 @@ var renderChoices3 = (state, options9) => {
54364
54366
  }
54365
54367
  return vsep2(documents);
54366
54368
  };
54369
+ var visiblePromptLines = (message) => {
54370
+ const lines3 = message.split(/\r?\n/u);
54371
+ const [firstLine, ...rest] = lines3;
54372
+ return [`\u25C7 ${firstLine ?? ""}`, ...rest.map((line4) => `\u2502 ${line4}`), "\u2502 "];
54373
+ };
54374
+ var visibleChoiceLines = (state, options9) => {
54375
+ const allSelected = state.selectedIndices.size === options9.choices.length;
54376
+ const metaOptions = [
54377
+ { title: allSelected ? "Clear all selected packs" : options9.selectAll }
54378
+ ];
54379
+ const allChoices = [...metaOptions, ...options9.choices];
54380
+ const toDisplay = entriesToDisplay2(state.index, allChoices.length, options9.maxPerPage);
54381
+ const lines3 = [];
54382
+ for (let index = toDisplay.startIndex;index < toDisplay.endIndex; index++) {
54383
+ const choice4 = allChoices[index];
54384
+ let prefix = " ";
54385
+ if (index === toDisplay.startIndex && toDisplay.startIndex > 0) {
54386
+ prefix = "\u2191";
54387
+ } else if (index === toDisplay.endIndex - 1 && toDisplay.endIndex < allChoices.length) {
54388
+ prefix = "\u2193";
54389
+ } else {
54390
+ prefix = "\u2502";
54391
+ }
54392
+ if (index < metaOptionsCount2) {
54393
+ lines3.push(`${prefix} ${choice4.title}`);
54394
+ continue;
54395
+ }
54396
+ const choiceIndex = index - metaOptionsCount2;
54397
+ const packChoice = choice4;
54398
+ const selected = state.selectedIndices.has(choiceIndex);
54399
+ const checkbox = selected ? "\u2612" : "\u2610";
54400
+ const description = packChoice.description && state.index === index ? ` - ${packChoice.description}` : "";
54401
+ lines3.push(`${prefix} ${checkbox} ${packChoice.title} ${description}`);
54402
+ }
54403
+ return lines3;
54404
+ };
54405
+ var visibleFrameText = (state, options9) => [...visiblePromptLines(options9.message), ...visibleChoiceLines(state, options9)].join(`
54406
+ `);
54367
54407
  var renderNextFrame9 = (state, options9) => exports_Effect.gen(function* () {
54368
54408
  const terminal = yield* Terminal;
54369
54409
  const columns = yield* terminal.columns;
@@ -54378,11 +54418,10 @@ var renderSubmission9 = (state, options9) => exports_Effect.gen(function* () {
54378
54418
  const selectedChoices = Array.from(state.selectedIndices).sort(Order2).map((index) => options9.choices[index].title).join(", ");
54379
54419
  return renderOutput8(options9.message).pipe(cat2(annotate2(figures2.tick, green3)), cat2(space2), cat2(annotate2(text3(selectedChoices), white3)), cat2(hardLine2), render3({ style: "pretty", options: { lineWidth: columns } }));
54380
54420
  });
54381
- var clearPrompt = (options9) => exports_Effect.gen(function* () {
54421
+ var clearPrompt = (state, options9) => exports_Effect.gen(function* () {
54382
54422
  const terminal = yield* Terminal;
54383
54423
  const columns = yield* terminal.columns;
54384
- const text12 = `
54385
- `.repeat(Math.min(options9.choices.length + 1, options9.maxPerPage)) + options9.message;
54424
+ const text12 = visibleFrameText(state, options9);
54386
54425
  return eraseText2(text12, columns).pipe(cat2(eraseLine3), cat2(cursorLeft3), optimize3(Deep), render3({ style: "pretty", options: { lineWidth: columns } }));
54387
54426
  });
54388
54427
  var processSpace2 = (state, options9) => {
@@ -54454,26 +54493,36 @@ var localMultiSelect = (options9) => {
54454
54493
  return exports_Effect.succeed(Action2.Beep());
54455
54494
  }
54456
54495
  },
54457
- clear: () => clearPrompt(resolvedOptions)
54496
+ clear: (state) => clearPrompt(state, resolvedOptions)
54458
54497
  });
54459
54498
  return exports_Prompt.run(prompt4).pipe(exports_Effect.map((values4) => values4.toSorted()));
54460
54499
  };
54461
54500
 
54462
54501
  // src/scaffold/prompt.ts
54463
54502
  var isPromptQuitSignal = (cause3) => typeof cause3 === "object" && cause3 !== null && ("name" in cause3) && cause3.name === "QuitException";
54503
+ var restoreLineInput = (readline2) => {
54504
+ if (input.isTTY) {
54505
+ input.setRawMode(false);
54506
+ }
54507
+ input.resume();
54508
+ readline2.resume();
54509
+ };
54464
54510
  var PromptLive = exports_Effect.acquireRelease(exports_Effect.sync(() => createInterface2({ input, output })), (readline2) => exports_Effect.sync(() => readline2.close())).pipe(exports_Effect.map((readline2) => ({
54465
54511
  readLine: (question) => exports_Effect.tryPromise({
54466
- try: () => readline2.question(question),
54512
+ try: () => {
54513
+ restoreLineInput(readline2);
54514
+ return readline2.question(question);
54515
+ },
54467
54516
  catch: (cause3) => new CliPromptError({
54468
54517
  cause: cause3,
54469
54518
  message: "Failed to read CLI input."
54470
54519
  })
54471
54520
  }),
54472
- multiSelect: ({ message, choices, selectAll }) => localMultiSelect({
54521
+ multiSelect: ({ message, choices, selectAll }) => exports_Effect.sync(() => readline2.pause()).pipe(exports_Effect.zipRight(localMultiSelect({
54473
54522
  message,
54474
54523
  choices,
54475
54524
  ...selectAll ? { selectAll } : {}
54476
- }).pipe(exports_Effect.map((values4) => values4.toSorted()), exports_Effect.mapError((cause3) => new CliPromptError({
54525
+ })), exports_Effect.ensuring(exports_Effect.sync(() => restoreLineInput(readline2))), exports_Effect.map((values4) => values4.toSorted()), exports_Effect.mapError((cause3) => new CliPromptError({
54477
54526
  cause: cause3,
54478
54527
  message: "Failed to read checklist input."
54479
54528
  }))),
@@ -54535,9 +54584,13 @@ import path6 from "path";
54535
54584
  var ignoredDirectoryNames = new Set([
54536
54585
  ".git",
54537
54586
  ".agents",
54587
+ ".claude",
54588
+ ".codex",
54589
+ ".cursor",
54538
54590
  ".devpunks",
54539
54591
  ".devpunks-cache",
54540
54592
  ".next",
54593
+ ".opencode",
54541
54594
  ".source",
54542
54595
  ".turbo",
54543
54596
  "coverage",
@@ -54551,6 +54604,7 @@ var ignoredDirectoryNames = new Set([
54551
54604
  "skills",
54552
54605
  "test-fixtures",
54553
54606
  "tmp",
54607
+ "worktrees",
54554
54608
  ".venv",
54555
54609
  "venv",
54556
54610
  "__pycache__"
@@ -54901,7 +54955,7 @@ var defaultRuntime3 = {
54901
54955
  execFile: (command, args2, options9) => {
54902
54956
  execFileSync4(command, [...args2], {
54903
54957
  cwd: options9?.cwd,
54904
- stdio: options9?.stdio ?? "inherit"
54958
+ stdio: options9?.stdio === "inherit" ? ["ignore", "inherit", "inherit"] : "ignore"
54905
54959
  });
54906
54960
  }
54907
54961
  };
@@ -55884,6 +55938,54 @@ var collectOpensrcReferences = (promptSpecs) => uniqueSorted(promptSpecs.flatMap
55884
55938
  var opensrcReferencesForPacks = (packs) => uniqueSorted(packs.flatMap((packId) => exampleRepositoriesForPack(packId).map((repo) => repo.repo)));
55885
55939
  var detectionHasPackage = (detection, packageName) => detection.manifests.some((manifest) => manifest.dependencies.includes(packageName));
55886
55940
  var selectedSkills = (finalPacks, baseline) => uniqueSorted(finalPacks.flatMap((packId) => skillsForPack(packId, baseline)));
55941
+ var legacySkillDirectories = [
55942
+ ".claude/skills",
55943
+ ".codex/skills",
55944
+ ".cursor/skills",
55945
+ ".opencode/skills"
55946
+ ];
55947
+ var nextAvailableSkillDirectory = (sharedSkillsDirectory, skillName, reservedSkillNames) => {
55948
+ if (!reservedSkillNames.has(skillName) && !existsSync5(path10.join(sharedSkillsDirectory, skillName))) {
55949
+ return skillName;
55950
+ }
55951
+ let suffix = 1;
55952
+ while (true) {
55953
+ const candidate = suffix === 1 ? `${skillName}-local` : `${skillName}-local-${suffix}`;
55954
+ if (!reservedSkillNames.has(candidate) && !existsSync5(path10.join(sharedSkillsDirectory, candidate))) {
55955
+ return candidate;
55956
+ }
55957
+ suffix += 1;
55958
+ }
55959
+ };
55960
+ var migrateLegacySkillDirectories = ({
55961
+ outputDirectory,
55962
+ finalSkills
55963
+ }) => {
55964
+ const sharedSkillsDirectory = path10.join(outputDirectory, ".agents/skills");
55965
+ const reservedSkillNames = new Set(finalSkills);
55966
+ mkdirSync2(sharedSkillsDirectory, { recursive: true });
55967
+ for (const relativeDirectory of legacySkillDirectories) {
55968
+ const absoluteDirectory = path10.join(outputDirectory, relativeDirectory);
55969
+ if (!existsSync5(absoluteDirectory)) {
55970
+ continue;
55971
+ }
55972
+ const stat3 = lstatSync(absoluteDirectory);
55973
+ if (stat3.isSymbolicLink() || !stat3.isDirectory()) {
55974
+ continue;
55975
+ }
55976
+ for (const entry of readdirSync2(absoluteDirectory, { withFileTypes: true })) {
55977
+ if (!entry.isDirectory()) {
55978
+ continue;
55979
+ }
55980
+ const sourceDirectory = path10.join(absoluteDirectory, entry.name);
55981
+ const migratedName = nextAvailableSkillDirectory(sharedSkillsDirectory, entry.name, reservedSkillNames);
55982
+ const targetDirectory = path10.join(sharedSkillsDirectory, migratedName);
55983
+ cpSync(sourceDirectory, targetDirectory, { recursive: true });
55984
+ rmSync2(sourceDirectory, { recursive: true, force: true });
55985
+ }
55986
+ rmSync2(absoluteDirectory, { recursive: true, force: true });
55987
+ }
55988
+ };
55887
55989
  var selectedHookIds = (finalPacks, baseline) => uniqueSorted(finalPacks.flatMap((packId) => hooksForPack(packId, baseline)));
55888
55990
  var oxlintConfigCandidates = [".oxlintrc.json", ".oxlintrc.jsonc", "oxlint.config.ts"];
55889
55991
  var existingOxlintConfigFiles = (scanDirectory) => oxlintConfigCandidates.filter((candidate) => existsSync5(path10.join(scanDirectory, candidate)));
@@ -56405,6 +56507,7 @@ var writeScaffoldOutput = ({
56405
56507
  lintSpecFiles.push(lintStarterConfigFile);
56406
56508
  }
56407
56509
  }
56510
+ migrateLegacySkillDirectories({ outputDirectory, finalSkills });
56408
56511
  for (const skillId of finalSkills) {
56409
56512
  const sourceDirectory = skillRegistryByIdForBaseline(baseline)[skillId].sourceDirectory;
56410
56513
  const targetDirectory = path10.posix.join(".agents/skills", skillId);
@@ -56595,34 +56698,50 @@ var writeAgentSystemPrompt = ({
56595
56698
  var tryClipboardCommand = ({
56596
56699
  command,
56597
56700
  args: args2,
56598
- text: text12
56701
+ text: text12,
56702
+ runtime: runtime5
56599
56703
  }) => {
56600
- if (!commandExistsOnPath(command)) {
56704
+ if (!runtime5.commandExists(command)) {
56601
56705
  return { ok: false };
56602
56706
  }
56603
56707
  try {
56604
- execFileSync6(command, args2, {
56708
+ runtime5.execFile(command, args2, {
56605
56709
  cwd: clipboardWorkingDirectory,
56606
- input: text12,
56607
- stdio: ["pipe", "ignore", "ignore"]
56710
+ input: text12
56608
56711
  });
56609
56712
  return { ok: true, command };
56610
56713
  } catch {
56611
56714
  return { ok: false };
56612
56715
  }
56613
56716
  };
56614
- var copyToClipboard = (text12) => {
56615
- if (process.platform === "darwin") {
56616
- return tryClipboardCommand({ command: "pbcopy", args: [], text: text12 });
56717
+ var defaultClipboardExecFile = (command, args2, options9) => {
56718
+ execFileSync6(command, [...args2], {
56719
+ cwd: options9.cwd,
56720
+ input: options9.input,
56721
+ stdio: ["pipe", "ignore", "ignore"]
56722
+ });
56723
+ };
56724
+ var copyToClipboard = (text12, runtime5 = {}) => {
56725
+ const env2 = runtime5.env ?? process.env;
56726
+ if (env2.VITEST === "true" || env2.NODE_ENV === "test" || env2.DP_NO_CLIPBOARD === "1") {
56727
+ return { ok: false };
56728
+ }
56729
+ const commandRuntime = {
56730
+ commandExists: runtime5.commandExists ?? commandExistsOnPath,
56731
+ execFile: runtime5.execFile ?? defaultClipboardExecFile
56732
+ };
56733
+ const platform = runtime5.platform ?? process.platform;
56734
+ if (platform === "darwin") {
56735
+ return tryClipboardCommand({ command: "pbcopy", args: [], text: text12, runtime: commandRuntime });
56617
56736
  }
56618
- if (process.platform === "win32") {
56619
- return tryClipboardCommand({ command: "clip", args: [], text: text12 });
56737
+ if (platform === "win32") {
56738
+ return tryClipboardCommand({ command: "clip", args: [], text: text12, runtime: commandRuntime });
56620
56739
  }
56621
56740
  return [
56622
56741
  { command: "wl-copy", args: [] },
56623
56742
  { command: "xclip", args: ["-selection", "clipboard"] },
56624
56743
  { command: "xsel", args: ["--clipboard", "--input"] }
56625
- ].reduce((result, candidate) => result.ok ? result : tryClipboardCommand({ ...candidate, text: text12 }), { ok: false });
56744
+ ].reduce((result, candidate) => result.ok ? result : tryClipboardCommand({ ...candidate, text: text12, runtime: commandRuntime }), { ok: false });
56626
56745
  };
56627
56746
  var selectedSkills2 = (finalPacks, baseline) => [
56628
56747
  ...new Set(finalPacks.flatMap((packId) => skillsForPack(packId, baseline)))
@@ -56657,7 +56776,8 @@ var runScaffold = ({
56657
56776
  ensureTools = true,
56658
56777
  baseline = bundledBaseline,
56659
56778
  assumeYes = false,
56660
- toolRuntime
56779
+ toolRuntime,
56780
+ clipboardRuntime
56661
56781
  }) => exports_Effect.gen(function* () {
56662
56782
  const baseRequiredTools = requiredToolsForSkills([], baseline);
56663
56783
  let toolBootstrapStatuses = [];
@@ -56846,7 +56966,7 @@ var runScaffold = ({
56846
56966
  subagentManifestSpec: scaffoldOutput.subagentManifestSpec,
56847
56967
  generatedFiles: [...scaffoldOutput.generatedFiles, writtenAgentSystemPromptFile]
56848
56968
  };
56849
- const clipboardResult = copyToClipboard(renderedAgentSystemPrompt);
56969
+ const clipboardResult = copyToClipboard(renderedAgentSystemPrompt, clipboardRuntime);
56850
56970
  yield* prompt4.writeLine("");
56851
56971
  yield* prompt4.writeLine(renderCommandSection("Scaffold Complete", [
56852
56972
  "Scaffold files were written successfully.",
@@ -56914,6 +57034,7 @@ Primary skills here: \`create-spec\`, \`create-plan\`, \`implement-spec\`, \`sim
56914
57034
  - Use \`implement-spec\` to execute an approved spec folder. Choose the execution mode inside the skill: \`sequential\` or \`parallel\`.
56915
57035
  - Write canonical project operations under \`content/docs/project/\`.
56916
57036
  - Keep \`content/docs/project/\` as the default scaffolded route tree. Product/domain routes belong to the individual project and should be added only when the repo deliberately defines them.
57037
+ - Keep project-owned domain source indexes under \`content/docs/project/domains/\` when the repo defines routed domain surfaces.
56917
57038
  - Do not create or maintain a separate \`domains/\` article tree.
56918
57039
  - \`SPEC.md\` and \`IMPLEMENTATION-NOTES.md\` remain source material, but the ingest orchestrator may update their frontmatter/link bookkeeping (\`ingested\`, \`last_ingested\`, backlinks) as part of the pipeline.
56919
57040
 
@@ -57053,7 +57174,9 @@ When processing source material into routed domain knowledge:
57053
57174
  "fumadocs-mdx": "14.3.2",
57054
57175
  "fumadocs-ui": "16.8.7",
57055
57176
  "lucide-react": "^1.14.0",
57177
+ "mermaid": "11.15.0",
57056
57178
  "next": "16.2.4",
57179
+ "next-themes": "0.4.6",
57057
57180
  "react": "^19.2.5",
57058
57181
  "react-dom": "^19.2.5",
57059
57182
  "tailwind-merge": "^3.5.0",
@@ -57103,25 +57226,37 @@ import { fileURLToPath } from "node:url";
57103
57226
  const wikiRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
57104
57227
  const contentRoot = path.join(wikiRoot, "content", "docs");
57105
57228
 
57106
- const possibleRepoRoots = [
57107
- path.resolve(wikiRoot, "..", ".."),
57108
- path.resolve(wikiRoot, ".."),
57109
- ];
57229
+ const possibleRepoRoots = [path.resolve(wikiRoot, "..", ".."), path.resolve(wikiRoot, "..")];
57110
57230
 
57111
57231
  const repoRoot = possibleRepoRoots.find(
57112
- (candidate) => existsSync(path.join(candidate, "docs")) || existsSync(path.join(candidate, "package.json")),
57232
+ (candidate) =>
57233
+ existsSync(path.join(candidate, "docs")) || existsSync(path.join(candidate, "package.json")),
57113
57234
  );
57114
57235
 
57115
57236
  const copiedTopLevelPages = new Set(["project"]);
57116
57237
 
57117
57238
  syncTree(path.join(wikiRoot, "specs"), path.join(contentRoot, "project", "specs"), "Specs");
57118
- syncTree(path.join(wikiRoot, "domains"), path.join(contentRoot, "wiki"), "Wiki");
57119
57239
 
57120
57240
  if (repoRoot) {
57121
- syncTree(path.join(repoRoot, "docs", "requirements"), path.join(contentRoot, "project", "requirements"), "Requirements");
57122
- syncTree(path.join(repoRoot, "docs", "reference"), path.join(contentRoot, "project", "reference"), "Reference");
57123
- syncTree(path.join(repoRoot, "docs", "runbooks"), path.join(contentRoot, "project", "runbooks"), "Runbooks");
57124
- syncFile(path.join(repoRoot, "docs", "tech-decisions.md"), path.join(contentRoot, "project", "decisions", "tech-decisions.mdx"));
57241
+ syncTree(
57242
+ path.join(repoRoot, "docs", "requirements"),
57243
+ path.join(contentRoot, "project", "requirements"),
57244
+ "Requirements",
57245
+ );
57246
+ syncTree(
57247
+ path.join(repoRoot, "docs", "reference"),
57248
+ path.join(contentRoot, "project", "reference"),
57249
+ "Reference",
57250
+ );
57251
+ syncTree(
57252
+ path.join(repoRoot, "docs", "runbooks"),
57253
+ path.join(contentRoot, "project", "runbooks"),
57254
+ "Runbooks",
57255
+ );
57256
+ syncFile(
57257
+ path.join(repoRoot, "docs", "tech-decisions.md"),
57258
+ path.join(contentRoot, "project", "decisions", "tech-decisions.mdx"),
57259
+ );
57125
57260
  }
57126
57261
 
57127
57262
  mergeMeta(contentRoot, {
@@ -57134,6 +57269,7 @@ mergeMeta(path.join(contentRoot, "project"), {
57134
57269
  description: "Internal project operations",
57135
57270
  pages: [
57136
57271
  "index",
57272
+ "domains",
57137
57273
  "grilling",
57138
57274
  "specs",
57139
57275
  "tech-debt",
@@ -57191,9 +57327,13 @@ function hasFrontmatter(content) {
57191
57327
  function writeMetaTree(directory, title) {
57192
57328
  if (!existsSync(directory)) return;
57193
57329
 
57194
- const entries = readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith("."));
57330
+ const entries = readdirSync(directory, { withFileTypes: true }).filter(
57331
+ (entry) => !entry.name.startsWith("."),
57332
+ );
57195
57333
  const files = entries
57196
- .filter((entry) => entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".mdx")))
57334
+ .filter(
57335
+ (entry) => entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".mdx")),
57336
+ )
57197
57337
  .map((entry) => stripMarkdownExtension(entry.name))
57198
57338
  .filter((name) => name !== "meta");
57199
57339
  const folders = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
@@ -57225,7 +57365,7 @@ function mergeMeta(directory, nextMeta) {
57225
57365
 
57226
57366
  function formatMetaJson(meta) {
57227
57367
  const lines = Object.entries(meta).map(
57228
- ([key, value]) => " \\"" + key + "\\": " + JSON.stringify(value),
57368
+ ([key, value]) => ' "' + key + '": ' + JSON.stringify(value),
57229
57369
  );
57230
57370
 
57231
57371
  return "{\\n" + lines.join(",\\n") + "\\n}\\n";
@@ -57274,7 +57414,7 @@ function sanitizeMdx(content, targetPath) {
57274
57414
 
57275
57415
  return [
57276
57416
  "---",
57277
- "title: \\"" + titleFromDocument(sanitized, targetPath) + "\\"",
57417
+ 'title: "' + titleFromDocument(sanitized, targetPath) + '"',
57278
57418
  "surface: project",
57279
57419
  "permission: project",
57280
57420
  "---",
@@ -57285,9 +57425,9 @@ function sanitizeMdx(content, targetPath) {
57285
57425
 
57286
57426
  function titleFromDocument(content, targetPath) {
57287
57427
  const heading = content.match(/^#\\s+(.+)$/m)?.[1]?.trim();
57288
- if (heading) return heading.replace(/"/g, "\\\\\\"");
57428
+ if (heading) return heading.replace(/"/g, '\\\\"');
57289
57429
 
57290
- return titleFromSegment(stripMarkdownExtension(path.basename(targetPath))).replace(/"/g, "\\\\\\"");
57430
+ return titleFromSegment(stripMarkdownExtension(path.basename(targetPath))).replace(/"/g, '\\\\"');
57291
57431
  }
57292
57432
 
57293
57433
  if (repoRoot) {
@@ -57312,6 +57452,7 @@ export default config;
57312
57452
  {
57313
57453
  path: "source.config.ts",
57314
57454
  content: `import { metaSchema, pageSchema } from "fumadocs-core/source/schema";
57455
+ import { remarkMdxMermaid } from "fumadocs-core/mdx-plugins";
57315
57456
  import { defineConfig, defineDocs } from "fumadocs-mdx/config";
57316
57457
  import { z } from "zod";
57317
57458
 
@@ -57333,7 +57474,11 @@ export const docs = defineDocs({
57333
57474
  },
57334
57475
  });
57335
57476
 
57336
- export default defineConfig({});
57477
+ export default defineConfig({
57478
+ mdxOptions: {
57479
+ remarkPlugins: [remarkMdxMermaid],
57480
+ },
57481
+ });
57337
57482
  `
57338
57483
  },
57339
57484
  {
@@ -57539,9 +57684,12 @@ export const { GET } = createFromSource(source, {
57539
57684
  content: `import defaultMdxComponents from "fumadocs-ui/mdx";
57540
57685
  import type { MDXComponents } from "mdx/types";
57541
57686
 
57687
+ import { Mermaid } from "@/components/mdx/mermaid";
57688
+
57542
57689
  export function getMDXComponents(components?: MDXComponents) {
57543
57690
  return {
57544
57691
  ...defaultMdxComponents,
57692
+ Mermaid,
57545
57693
  ...components,
57546
57694
  } satisfies MDXComponents;
57547
57695
  }
@@ -57551,6 +57699,63 @@ export const useMDXComponents = getMDXComponents;
57551
57699
  declare global {
57552
57700
  type MDXProvidedComponents = ReturnType<typeof getMDXComponents>;
57553
57701
  }
57702
+ `
57703
+ },
57704
+ {
57705
+ path: "src/components/mdx/mermaid.tsx",
57706
+ content: `"use client";
57707
+
57708
+ import { use, useEffect, useId, useState } from "react";
57709
+ import { useTheme } from "next-themes";
57710
+
57711
+ const cache = new Map<string, Promise<unknown>>();
57712
+
57713
+ function cachePromise<T>(key: string, setPromise: () => Promise<T>): Promise<T> {
57714
+ const cached = cache.get(key);
57715
+ if (cached) return cached as Promise<T>;
57716
+
57717
+ const promise = setPromise();
57718
+ cache.set(key, promise);
57719
+ return promise;
57720
+ }
57721
+
57722
+ export function Mermaid({ chart }: { chart: string }) {
57723
+ const [mounted, setMounted] = useState(false);
57724
+
57725
+ useEffect(() => {
57726
+ setMounted(true);
57727
+ }, []);
57728
+
57729
+ if (!mounted) return null;
57730
+ return <MermaidContent chart={chart} />;
57731
+ }
57732
+
57733
+ function MermaidContent({ chart }: { chart: string }) {
57734
+ const id = \`mermaid-\${useId().replaceAll(":", "")}\`;
57735
+ const { resolvedTheme } = useTheme();
57736
+ const { default: mermaid } = use(cachePromise("mermaid", () => import("mermaid")));
57737
+
57738
+ mermaid.initialize({
57739
+ startOnLoad: false,
57740
+ securityLevel: "loose",
57741
+ fontFamily: "inherit",
57742
+ themeCSS: "margin: 1.5rem auto 0;",
57743
+ theme: resolvedTheme === "dark" ? "dark" : "default",
57744
+ });
57745
+
57746
+ const { svg, bindFunctions } = use(
57747
+ cachePromise(\`\${chart}-\${resolvedTheme}\`, () => mermaid.render(id, chart)),
57748
+ );
57749
+
57750
+ return (
57751
+ <div
57752
+ ref={(container) => {
57753
+ if (container) bindFunctions?.(container);
57754
+ }}
57755
+ dangerouslySetInnerHTML={{ __html: svg }}
57756
+ />
57757
+ );
57758
+ }
57554
57759
  `
57555
57760
  },
57556
57761
  {
@@ -57667,7 +57872,17 @@ export function getPageMarkdownUrl(page: (typeof source)["$inferPage"]) {
57667
57872
  content: `{
57668
57873
  "title": "Project",
57669
57874
  "description": "Internal project operations",
57670
- "pages": ["index", "grilling", "specs", "tech-debt", "maintenance", "runbooks", "decisions", "repo-guidance"]
57875
+ "pages": [
57876
+ "index",
57877
+ "domains",
57878
+ "grilling",
57879
+ "specs",
57880
+ "tech-debt",
57881
+ "maintenance",
57882
+ "runbooks",
57883
+ "decisions",
57884
+ "repo-guidance"
57885
+ ]
57671
57886
  }
57672
57887
  `
57673
57888
  },
@@ -57681,6 +57896,30 @@ permission: project
57681
57896
  ---
57682
57897
 
57683
57898
  This surface is for specs, implementation notes, maintenance logs, decisions, repo guidance, runbooks, and durable project context.
57899
+ `
57900
+ },
57901
+ {
57902
+ path: "content/docs/project/domains/meta.json",
57903
+ content: `{
57904
+ "title": "Domains",
57905
+ "pages": [
57906
+ "index"
57907
+ ]
57908
+ }
57909
+ `
57910
+ },
57911
+ {
57912
+ path: "content/docs/project/domains/index.mdx",
57913
+ content: `---
57914
+ title: Domains
57915
+ description: Project-owned domain source index
57916
+ surface: project
57917
+ permission: project
57918
+ ---
57919
+
57920
+ Use this section for project-side domain source indexes when the repo defines durable routed domain surfaces.
57921
+
57922
+ Readable domain articles should live at the project-owned routes the repo defines, such as \`/docs/cli\` or \`/docs/harness\`. Do not create \`${wikiRoot}/domains\`; domain source indexes belong here under \`${wikiRoot}/content/docs/project/domains\`.
57684
57923
  `
57685
57924
  },
57686
57925
  {
@@ -57844,13 +58083,20 @@ Append ingest activity here. Keep only the most recent 50 entries.
57844
58083
  });
57845
58084
 
57846
58085
  // src/content/stage-scaffold.ts
58086
+ var backlogProviderLabels = {
58087
+ "azure-devops": "Azure DevOps",
58088
+ github: "GitHub Projects and Issues",
58089
+ linear: "Linear",
58090
+ monday: "monday.com"
58091
+ };
57847
58092
  var stageScaffoldCatalog = [
57848
58093
  {
57849
58094
  id: "init",
57850
58095
  summary: "Requirements grill, backlog authoring, and wiki docs seed.",
57851
58096
  skills: ["requirements-grill", "write-backlog"],
57852
58097
  renderPrompt: ({
57853
- wikiRoot
58098
+ wikiRoot,
58099
+ backlogProvider
57854
58100
  }) => `You are the operator agent continuing a \`punks scaffold init\` run.
57855
58101
 
57856
58102
  Do not start requirements discovery by default. First reconcile the generated output with this repository.
@@ -57866,6 +58112,11 @@ Generated skills:
57866
58112
  - \`.agents/skills/requirements-grill\`
57867
58113
  - \`.agents/skills/write-backlog\`
57868
58114
 
58115
+ Backlog provider:
58116
+ - selected provider: ${backlogProviderLabels[backlogProvider]} (\`${backlogProvider}\`)
58117
+ - keep this provider pinned unless the user explicitly changes it
58118
+ - when backlog writing starts, use the matching \`write-backlog\` provider payload guidance
58119
+
57869
58120
  Post-command guidance:
57870
58121
  1. Read the repository guidance and inspect the generated files.
57871
58122
  2. Move, rename, or refactor the generated wiki and skill output when needed so it matches the actual repo layout.
@@ -57880,6 +58131,47 @@ When the generated init output matches the repo, the next CLI step is:
57880
58131
  var stageScaffoldById = Object.fromEntries(stageScaffoldCatalog.map((stage) => [stage.id, stage]));
57881
58132
 
57882
58133
  // src/scaffold/stage.ts
58134
+ var backlogProviderLabels2 = {
58135
+ "azure-devops": "Azure DevOps",
58136
+ github: "GitHub Projects and Issues",
58137
+ linear: "Linear",
58138
+ monday: "monday.com"
58139
+ };
58140
+ var backlogProviderAliases = {
58141
+ "1": "github",
58142
+ "2": "linear",
58143
+ "3": "azure-devops",
58144
+ "4": "monday",
58145
+ ado: "azure-devops",
58146
+ azure: "azure-devops",
58147
+ "azure devops": "azure-devops",
58148
+ "azure-devops": "azure-devops",
58149
+ gh: "github",
58150
+ github: "github",
58151
+ "github projects": "github",
58152
+ linear: "linear",
58153
+ monday: "monday",
58154
+ "monday.com": "monday"
58155
+ };
58156
+ var parseBacklogProvider = (value6) => backlogProviderAliases[value6.trim().toLowerCase()] ?? null;
58157
+ var promptBacklogProvider = ({
58158
+ prompt: prompt4
58159
+ }) => exports_Effect.gen(function* () {
58160
+ const answer = yield* prompt4.readLine("Backlog provider? [1 github/projects, 2 linear, 3 azure-devops, 4 monday] (default: 1): ");
58161
+ const parsed = parseBacklogProvider(answer);
58162
+ if (parsed !== null)
58163
+ return parsed;
58164
+ if (answer.trim() !== "") {
58165
+ yield* prompt4.writeLine("Unknown backlog provider. Defaulting to GitHub Projects and Issues.");
58166
+ }
58167
+ return "github";
58168
+ });
58169
+ var renderBacklogProviderMarkdown = (provider) => `# Backlog Provider
58170
+
58171
+ Selected backlog provider: ${backlogProviderLabels2[provider]} (\`${provider}\`).
58172
+
58173
+ Keep this provider pinned unless the user explicitly changes it. When requirements are ready for backlog writing, use \`write-backlog\` with the matching provider payload guidance.
58174
+ `;
57883
58175
  var copySkillDirectory = ({
57884
58176
  outputDirectory,
57885
58177
  skillId,
@@ -57939,20 +58231,27 @@ var updateExistingWikiPackage = ({
57939
58231
  return null;
57940
58232
  const packageJson = JSON.parse(readFileSync7(packagePath, "utf8"));
57941
58233
  const scripts = packageJson.scripts;
57942
- if (!scripts)
57943
- return null;
57944
- const nextScripts = {
58234
+ const dependencies = packageJson.dependencies ?? {};
58235
+ const nextDependencies = {
58236
+ ...dependencies,
58237
+ mermaid: dependencies.mermaid ?? "11.15.0",
58238
+ "next-themes": dependencies["next-themes"] ?? "0.4.6"
58239
+ };
58240
+ const nextScripts = scripts && {
57945
58241
  ...scripts,
57946
58242
  build: withSyncContentPrefix(scripts.build),
57947
58243
  "check-types": withSyncContentPrefix(scripts["check-types"]),
57948
58244
  "types:check": withSyncContentPrefix(scripts["types:check"])
57949
58245
  };
57950
- const changed = Object.entries(nextScripts).some(([key, value6]) => scripts[key] !== value6);
58246
+ const dependenciesChanged = Object.entries(nextDependencies).some(([key, value6]) => dependencies[key] !== value6);
58247
+ const scriptsChanged = nextScripts !== undefined && Object.entries(nextScripts).some(([key, value6]) => scripts?.[key] !== value6);
58248
+ const changed = dependenciesChanged || scriptsChanged;
57951
58249
  if (!changed)
57952
58250
  return null;
57953
58251
  writeFileSync5(packagePath, JSON.stringify({
57954
58252
  ...packageJson,
57955
- scripts: nextScripts
58253
+ dependencies: nextDependencies,
58254
+ ...nextScripts === undefined ? {} : { scripts: nextScripts }
57956
58255
  }, null, 2) + `
57957
58256
  `);
57958
58257
  return relativePosixPath2(outputDirectory, packagePath);
@@ -57971,7 +58270,8 @@ var isNestedRouteSeedBlockedByFlatPage = ({
57971
58270
  var scaffoldWiki = ({
57972
58271
  outputDirectory,
57973
58272
  wikiRoot,
57974
- targetRoot
58273
+ targetRoot,
58274
+ backlogProvider
57975
58275
  }) => {
57976
58276
  const template = makeWikiScaffoldTemplate(wikiRoot);
57977
58277
  const createdFiles = [];
@@ -58058,6 +58358,14 @@ var scaffoldWiki = ({
58058
58358
  if (logFile !== null) {
58059
58359
  createdFiles.push(logFile);
58060
58360
  }
58361
+ const backlogProviderFile = writeMissingFile({
58362
+ outputDirectory,
58363
+ targetPath: path12.join(wikiDirectory, "backlog-provider.md"),
58364
+ content: renderBacklogProviderMarkdown(backlogProvider)
58365
+ });
58366
+ if (backlogProviderFile !== null) {
58367
+ createdFiles.push(backlogProviderFile);
58368
+ }
58061
58369
  return createdFiles.toSorted();
58062
58370
  };
58063
58371
  var scaffoldWikiForDirectory = ({
@@ -58071,7 +58379,8 @@ var scaffoldWikiForDirectory = ({
58071
58379
  return scaffoldWiki({
58072
58380
  outputDirectory,
58073
58381
  wikiRoot: wikiTarget.wikiRoot,
58074
- targetRoot: wikiTarget.targetRoot
58382
+ targetRoot: wikiTarget.targetRoot,
58383
+ backlogProvider: "github"
58075
58384
  });
58076
58385
  };
58077
58386
  var isWikiOutputDirectory = (outputDirectory) => {
@@ -58101,6 +58410,7 @@ var runStageScaffold = ({
58101
58410
  baseline = bundledBaseline
58102
58411
  }) => exports_Effect.gen(function* () {
58103
58412
  const stage = stageScaffoldById[commandId];
58413
+ const backlogProvider = yield* promptBacklogProvider({ prompt: prompt4 });
58104
58414
  const detection = yield* detectRepository(outputDirectory).pipe(exports_Effect.catchAll(() => exports_Effect.succeed(null)));
58105
58415
  const skillFiles = stage.skills.map((skillId) => copySkillDirectory({
58106
58416
  outputDirectory,
@@ -58113,10 +58423,11 @@ var runStageScaffold = ({
58113
58423
  });
58114
58424
  const wikiFiles = scaffoldWiki({
58115
58425
  outputDirectory,
58116
- ...wikiTarget
58426
+ ...wikiTarget,
58427
+ backlogProvider
58117
58428
  });
58118
58429
  removeHarnessDirectoriesFromGitignore(outputDirectory);
58119
- const operatorPrompt = stage.renderPrompt({ wikiRoot: wikiTarget.wikiRoot });
58430
+ const operatorPrompt = stage.renderPrompt({ wikiRoot: wikiTarget.wikiRoot, backlogProvider });
58120
58431
  yield* prompt4.writeLine(renderScaffoldTitle());
58121
58432
  yield* prompt4.writeLine("");
58122
58433
  yield* prompt4.writeLine(renderStageIntro({
@@ -58135,6 +58446,8 @@ var runStageScaffold = ({
58135
58446
  yield* prompt4.writeLine("");
58136
58447
  yield* prompt4.writeLine(renderNotes([`Output directory: ${outputDirectory}`, "Hidden output directories: .agents"]));
58137
58448
  yield* prompt4.writeLine("");
58449
+ yield* prompt4.writeLine(renderCommandSection("Backlog provider", `${backlogProviderLabels2[backlogProvider]} (${backlogProvider})`));
58450
+ yield* prompt4.writeLine("");
58138
58451
  yield* prompt4.writeLine(renderCommandSection("Operator prompt", operatorPrompt));
58139
58452
  yield* submitCliEventEffect("cli.scaffold.init.completed", {
58140
58453
  cwd: outputDirectory,
@@ -58145,7 +58458,8 @@ var runStageScaffold = ({
58145
58458
  return {
58146
58459
  outputDirectory,
58147
58460
  skillFiles,
58148
- wikiFiles
58461
+ wikiFiles,
58462
+ backlogProvider
58149
58463
  };
58150
58464
  });
58151
58465
 
@@ -58167,7 +58481,12 @@ var stageCommand = (id2, description) => exports_Command.make(id2, { output: out
58167
58481
  prompt: prompt4,
58168
58482
  baseline: resolvedBaseline
58169
58483
  });
58170
- }))).pipe(exports_Command.withDescription(description));
58484
+ }).pipe(exports_Effect.catchTag("CliPromptError", (error4) => isPromptQuitSignal(error4.cause) ? exports_Effect.sync(() => {
58485
+ console.log(renderHint("Scaffold cancelled."));
58486
+ }) : exports_Effect.fail(new CliPromptError({
58487
+ cause: error4.cause,
58488
+ message: error4.message
58489
+ })))))).pipe(exports_Command.withDescription(description));
58171
58490
  var setupCommand = exports_Command.make("setup", {
58172
58491
  input: inputOption,
58173
58492
  output: outputOption,
@@ -59192,6 +59511,13 @@ var contentForDiff = (rootDirectory, relativePath) => {
59192
59511
  }
59193
59512
  return readFileSync8(absolutePath, "utf8");
59194
59513
  };
59514
+ var jsonContentEquals = (left3, right3) => {
59515
+ try {
59516
+ return JSON.stringify(JSON.parse(left3)) === JSON.stringify(JSON.parse(right3));
59517
+ } catch {
59518
+ return false;
59519
+ }
59520
+ };
59195
59521
  var hashPath = (rootDirectory, relativePath) => {
59196
59522
  const absolutePath = path14.join(rootDirectory, relativePath);
59197
59523
  if (!existsSync7(absolutePath)) {
@@ -59211,6 +59537,9 @@ var collectRelativeFiles2 = (rootDirectory, relativeDirectory) => {
59211
59537
  for (const entry of readdirSync4(currentDirectory, { withFileTypes: true })) {
59212
59538
  const absolutePath = path14.join(currentDirectory, entry.name);
59213
59539
  const relativePath = path14.relative(rootDirectory, absolutePath).split(path14.sep).join("/");
59540
+ if (relativePath.split("/").includes("node_modules")) {
59541
+ continue;
59542
+ }
59214
59543
  if (entry.isDirectory()) {
59215
59544
  visit2(absolutePath);
59216
59545
  continue;
@@ -59308,6 +59637,9 @@ var buildChanges = ({
59308
59637
  if (currentHash === expected.sha256) {
59309
59638
  return [];
59310
59639
  }
59640
+ if (currentHash !== null && expected.path.endsWith("meta.json") && jsonContentEquals(contentForDiff(rootDirectory, expected.path), contentForDiff(expectedDirectory, expected.path))) {
59641
+ return [];
59642
+ }
59311
59643
  const previous = previousByPath.get(expected.path);
59312
59644
  const status2 = currentHash === null ? "missing" : previous !== undefined && currentHash !== previous.sha256 ? "local-edited" : "changed";
59313
59645
  return [
@@ -59801,6 +60133,19 @@ var minimumReleaseAgeEnvironmentForPackageManager = (packageManager) => {
59801
60133
  return {};
59802
60134
  }
59803
60135
  };
60136
+ var runCliInstallCommand = ({
60137
+ command,
60138
+ environment: environment2
60139
+ }) => {
60140
+ const result = spawnSync(command[0], command.slice(1), {
60141
+ env: {
60142
+ ...process.env,
60143
+ ...environment2
60144
+ },
60145
+ stdio: "inherit"
60146
+ });
60147
+ return result.status === 0;
60148
+ };
59804
60149
  var autoUpdateCliIfStale = async ({
59805
60150
  currentVersion,
59806
60151
  packageName,
@@ -59868,14 +60213,7 @@ var upgradeCli = async ({
59868
60213
  tag: tag6
59869
60214
  });
59870
60215
  const environment2 = minimumReleaseAgeEnvironmentForPackageManager(packageManager);
59871
- const result = spawnSync(command[0], command.slice(1), {
59872
- env: {
59873
- ...process.env,
59874
- ...environment2
59875
- },
59876
- stdio: "inherit"
59877
- });
59878
- if (result.status === 0) {
60216
+ if (runCliInstallCommand({ command, environment: environment2 })) {
59879
60217
  return {
59880
60218
  status: "upgraded",
59881
60219
  check: check2,
@@ -60044,6 +60382,72 @@ var cli = exports_Command.run(app, {
60044
60382
  });
60045
60383
  var shouldCheckSelfUpdate = () => process.env.DP_NO_UPDATE_CHECK !== "1" && process.env.CI === undefined && process.argv.includes("--help") === false && process.argv.includes("-h") === false && process.argv.includes("--version") === false && process.argv.includes("-v") === false;
60046
60384
  var shouldCheckDpCliSkillUpdate = () => process.env.DP_NO_SKILL_UPDATE_CHECK !== "1" && process.env.CI === undefined && process.argv.includes("--help") === false && process.argv.includes("-h") === false && process.argv.includes("--version") === false && process.argv.includes("-v") === false;
60385
+ var shouldAskForSelfUpdate = () => shouldCheckSelfUpdate() && process.argv.slice(2).includes("upgrade") === false && process.stdin.isTTY === true && process.stdout.isTTY === true;
60386
+ var formatCommand2 = ({
60387
+ command,
60388
+ environment: environment2
60389
+ }) => {
60390
+ const envPrefix = environment2 === undefined ? [] : Object.entries(environment2).map(([key, value6]) => `${key}=${value6}`);
60391
+ return [...envPrefix, ...command].join(" ");
60392
+ };
60393
+ var askYesNo = async (question) => {
60394
+ const readline2 = createInterface3({ input: process.stdin, output: process.stdout });
60395
+ try {
60396
+ const answer = (await readline2.question(renderQuestion(`${question} [y/N]: `))).trim();
60397
+ return answer.toLowerCase() === "y" || answer.toLowerCase() === "yes";
60398
+ } finally {
60399
+ readline2.close();
60400
+ }
60401
+ };
60402
+ var runInteractiveCliUpdate = async () => {
60403
+ if (!shouldAskForSelfUpdate()) {
60404
+ return false;
60405
+ }
60406
+ const result = await autoUpdateCliIfStale({
60407
+ currentVersion: version,
60408
+ packageName: name,
60409
+ tag: process.env.DP_UPDATE_TAG ?? "latest",
60410
+ timeoutMs: 5000
60411
+ });
60412
+ if (result.status === "current" || result.status === "unavailable") {
60413
+ return false;
60414
+ }
60415
+ if (result.check === null) {
60416
+ return false;
60417
+ }
60418
+ if (result.status !== "available") {
60419
+ const command = "command" in result ? result.command : null;
60420
+ console.error(renderSelfUpdateNotice({
60421
+ currentVersion: result.check.currentVersion,
60422
+ latestVersion: result.check.latestVersion,
60423
+ packageName: result.check.packageName,
60424
+ command
60425
+ }));
60426
+ return false;
60427
+ }
60428
+ console.error(renderSelfUpdateNotice({
60429
+ currentVersion: result.check.currentVersion,
60430
+ latestVersion: result.check.latestVersion,
60431
+ packageName: result.check.packageName,
60432
+ command: result.command
60433
+ }));
60434
+ if (!await askYesNo("Update CLI before running this command?")) {
60435
+ return false;
60436
+ }
60437
+ if (runCliInstallCommand({ command: result.command, environment: result.environment })) {
60438
+ console.log(renderCommandSection("CLI upgraded", [
60439
+ `${result.check.packageName} ${result.check.currentVersion} -> ${result.check.latestVersion}`,
60440
+ `Installer: ${result.packageManager}`,
60441
+ `Command: ${formatCommand2(result)}`,
60442
+ "Re-run your command to use the upgraded CLI."
60443
+ ].join(`
60444
+ `)));
60445
+ return true;
60446
+ }
60447
+ console.error(renderCommandSection("CLI upgrade failed", `Command failed: ${formatCommand2({ command: result.command })}`));
60448
+ process.exitCode = 1;
60449
+ return true;
60450
+ };
60047
60451
  var runCliUpdateCheck = async () => {
60048
60452
  const result = await autoUpdateCliIfStale({
60049
60453
  currentVersion: version,
@@ -60095,7 +60499,7 @@ var markStartupCheckStarted = () => {
60095
60499
  writeFileSync6(startupCheckCacheFile, JSON.stringify({ checkedAt: Date.now() }, null, 2));
60096
60500
  };
60097
60501
  var startBackgroundStartupChecks = () => {
60098
- const checkCli = shouldCheckSelfUpdate();
60502
+ const checkCli = shouldCheckSelfUpdate() && !shouldAskForSelfUpdate();
60099
60503
  const checkSkill = shouldCheckDpCliSkillUpdate();
60100
60504
  if (!checkCli && !checkSkill || hasFreshStartupCheck()) {
60101
60505
  return;
@@ -60127,7 +60531,12 @@ if (process.env[startupCheckWorkerEnv] === "1") {
60127
60531
  });
60128
60532
  } else {
60129
60533
  try {
60130
- startBackgroundStartupChecks();
60131
- } catch {}
60132
- cli(process.argv).pipe(exports_Effect.provide(exports_Layer.mergeAll(exports_BunContext.layer)), exports_BunRuntime.runMain);
60534
+ const updated = await runInteractiveCliUpdate();
60535
+ if (!updated) {
60536
+ startBackgroundStartupChecks();
60537
+ cli(process.argv).pipe(exports_Effect.provide(exports_Layer.mergeAll(exports_BunContext.layer)), exports_BunRuntime.runMain);
60538
+ }
60539
+ } catch {
60540
+ cli(process.argv).pipe(exports_Effect.provide(exports_Layer.mergeAll(exports_BunContext.layer)), exports_BunRuntime.runMain);
60541
+ }
60133
60542
  }