@punks/cli 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/index.js +967 -264
- package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +3 -3
- package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +33 -3
- package/dist/skills/agnostic/requirements/requirements-grill/references/wiki-output.md +6 -5
- package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +7 -5
- package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +2 -2
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +224 -0
- package/package.json +1 -1
- package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-issues-create-payload.md +0 -48
package/dist/index.js
CHANGED
|
@@ -10891,9 +10891,10 @@ var require_public_api = __commonJS((exports) => {
|
|
|
10891
10891
|
|
|
10892
10892
|
// src/index.ts
|
|
10893
10893
|
import { spawn as spawn2 } from "child_process";
|
|
10894
|
-
import { existsSync as
|
|
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
|
-
import
|
|
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 = {};
|
|
@@ -52405,7 +52406,7 @@ var recordProductTelemetryEvent = (options9) => exports_Effect.gen(function* ()
|
|
|
52405
52406
|
|
|
52406
52407
|
// package.json
|
|
52407
52408
|
var name = "@punks/cli";
|
|
52408
|
-
var version = "2.1.
|
|
52409
|
+
var version = "2.1.5";
|
|
52409
52410
|
// src/telemetry/product.ts
|
|
52410
52411
|
var git = (cwd, args2) => {
|
|
52411
52412
|
try {
|
|
@@ -52998,7 +52999,7 @@ var reportCommand = exports_Command.make("report", {
|
|
|
52998
52999
|
})).pipe(exports_Command.withDescription("Create a GitHub issue in the Harness Intelligence repository for maintainer triage."));
|
|
52999
53000
|
|
|
53000
53001
|
// src/cli/scaffold-command.ts
|
|
53001
|
-
import
|
|
53002
|
+
import path13 from "path";
|
|
53002
53003
|
|
|
53003
53004
|
// src/baseline/resolve.ts
|
|
53004
53005
|
import { createHash } from "crypto";
|
|
@@ -54364,6 +54365,44 @@ var renderChoices3 = (state, options9) => {
|
|
|
54364
54365
|
}
|
|
54365
54366
|
return vsep2(documents);
|
|
54366
54367
|
};
|
|
54368
|
+
var visiblePromptLines = (message) => {
|
|
54369
|
+
const lines3 = message.split(/\r?\n/u);
|
|
54370
|
+
const [firstLine, ...rest] = lines3;
|
|
54371
|
+
return [`\u25C7 ${firstLine ?? ""}`, ...rest.map((line4) => `\u2502 ${line4}`), "\u2502 "];
|
|
54372
|
+
};
|
|
54373
|
+
var visibleChoiceLines = (state, options9) => {
|
|
54374
|
+
const allSelected = state.selectedIndices.size === options9.choices.length;
|
|
54375
|
+
const metaOptions = [
|
|
54376
|
+
{ title: allSelected ? "Clear all selected packs" : options9.selectAll }
|
|
54377
|
+
];
|
|
54378
|
+
const allChoices = [...metaOptions, ...options9.choices];
|
|
54379
|
+
const toDisplay = entriesToDisplay2(state.index, allChoices.length, options9.maxPerPage);
|
|
54380
|
+
const lines3 = [];
|
|
54381
|
+
for (let index = toDisplay.startIndex;index < toDisplay.endIndex; index++) {
|
|
54382
|
+
const choice4 = allChoices[index];
|
|
54383
|
+
let prefix = " ";
|
|
54384
|
+
if (index === toDisplay.startIndex && toDisplay.startIndex > 0) {
|
|
54385
|
+
prefix = "\u2191";
|
|
54386
|
+
} else if (index === toDisplay.endIndex - 1 && toDisplay.endIndex < allChoices.length) {
|
|
54387
|
+
prefix = "\u2193";
|
|
54388
|
+
} else {
|
|
54389
|
+
prefix = "\u2502";
|
|
54390
|
+
}
|
|
54391
|
+
if (index < metaOptionsCount2) {
|
|
54392
|
+
lines3.push(`${prefix} ${choice4.title}`);
|
|
54393
|
+
continue;
|
|
54394
|
+
}
|
|
54395
|
+
const choiceIndex = index - metaOptionsCount2;
|
|
54396
|
+
const packChoice = choice4;
|
|
54397
|
+
const selected = state.selectedIndices.has(choiceIndex);
|
|
54398
|
+
const checkbox = selected ? "\u2612" : "\u2610";
|
|
54399
|
+
const description = packChoice.description && state.index === index ? ` - ${packChoice.description}` : "";
|
|
54400
|
+
lines3.push(`${prefix} ${checkbox} ${packChoice.title} ${description}`);
|
|
54401
|
+
}
|
|
54402
|
+
return lines3;
|
|
54403
|
+
};
|
|
54404
|
+
var visibleFrameText = (state, options9) => [...visiblePromptLines(options9.message), ...visibleChoiceLines(state, options9)].join(`
|
|
54405
|
+
`);
|
|
54367
54406
|
var renderNextFrame9 = (state, options9) => exports_Effect.gen(function* () {
|
|
54368
54407
|
const terminal = yield* Terminal;
|
|
54369
54408
|
const columns = yield* terminal.columns;
|
|
@@ -54378,11 +54417,10 @@ var renderSubmission9 = (state, options9) => exports_Effect.gen(function* () {
|
|
|
54378
54417
|
const selectedChoices = Array.from(state.selectedIndices).sort(Order2).map((index) => options9.choices[index].title).join(", ");
|
|
54379
54418
|
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
54419
|
});
|
|
54381
|
-
var clearPrompt = (options9) => exports_Effect.gen(function* () {
|
|
54420
|
+
var clearPrompt = (state, options9) => exports_Effect.gen(function* () {
|
|
54382
54421
|
const terminal = yield* Terminal;
|
|
54383
54422
|
const columns = yield* terminal.columns;
|
|
54384
|
-
const text12 =
|
|
54385
|
-
`.repeat(Math.min(options9.choices.length + 1, options9.maxPerPage)) + options9.message;
|
|
54423
|
+
const text12 = visibleFrameText(state, options9);
|
|
54386
54424
|
return eraseText2(text12, columns).pipe(cat2(eraseLine3), cat2(cursorLeft3), optimize3(Deep), render3({ style: "pretty", options: { lineWidth: columns } }));
|
|
54387
54425
|
});
|
|
54388
54426
|
var processSpace2 = (state, options9) => {
|
|
@@ -54454,26 +54492,36 @@ var localMultiSelect = (options9) => {
|
|
|
54454
54492
|
return exports_Effect.succeed(Action2.Beep());
|
|
54455
54493
|
}
|
|
54456
54494
|
},
|
|
54457
|
-
clear: () => clearPrompt(resolvedOptions)
|
|
54495
|
+
clear: (state) => clearPrompt(state, resolvedOptions)
|
|
54458
54496
|
});
|
|
54459
54497
|
return exports_Prompt.run(prompt4).pipe(exports_Effect.map((values4) => values4.toSorted()));
|
|
54460
54498
|
};
|
|
54461
54499
|
|
|
54462
54500
|
// src/scaffold/prompt.ts
|
|
54463
54501
|
var isPromptQuitSignal = (cause3) => typeof cause3 === "object" && cause3 !== null && ("name" in cause3) && cause3.name === "QuitException";
|
|
54502
|
+
var restoreLineInput = (readline2) => {
|
|
54503
|
+
if (input.isTTY) {
|
|
54504
|
+
input.setRawMode(false);
|
|
54505
|
+
}
|
|
54506
|
+
input.resume();
|
|
54507
|
+
readline2.resume();
|
|
54508
|
+
};
|
|
54464
54509
|
var PromptLive = exports_Effect.acquireRelease(exports_Effect.sync(() => createInterface2({ input, output })), (readline2) => exports_Effect.sync(() => readline2.close())).pipe(exports_Effect.map((readline2) => ({
|
|
54465
54510
|
readLine: (question) => exports_Effect.tryPromise({
|
|
54466
|
-
try: () =>
|
|
54511
|
+
try: () => {
|
|
54512
|
+
restoreLineInput(readline2);
|
|
54513
|
+
return readline2.question(question);
|
|
54514
|
+
},
|
|
54467
54515
|
catch: (cause3) => new CliPromptError({
|
|
54468
54516
|
cause: cause3,
|
|
54469
54517
|
message: "Failed to read CLI input."
|
|
54470
54518
|
})
|
|
54471
54519
|
}),
|
|
54472
|
-
multiSelect: ({ message, choices, selectAll }) => localMultiSelect({
|
|
54520
|
+
multiSelect: ({ message, choices, selectAll }) => exports_Effect.sync(() => readline2.pause()).pipe(exports_Effect.zipRight(localMultiSelect({
|
|
54473
54521
|
message,
|
|
54474
54522
|
choices,
|
|
54475
54523
|
...selectAll ? { selectAll } : {}
|
|
54476
|
-
}).
|
|
54524
|
+
})), exports_Effect.ensuring(exports_Effect.sync(() => restoreLineInput(readline2))), exports_Effect.map((values4) => values4.toSorted()), exports_Effect.mapError((cause3) => new CliPromptError({
|
|
54477
54525
|
cause: cause3,
|
|
54478
54526
|
message: "Failed to read checklist input."
|
|
54479
54527
|
}))),
|
|
@@ -54487,9 +54535,9 @@ var PromptLive = exports_Effect.acquireRelease(exports_Effect.sync(() => createI
|
|
|
54487
54535
|
|
|
54488
54536
|
// src/scaffold/run.ts
|
|
54489
54537
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
54490
|
-
import { mkdirSync as mkdirSync3, writeFileSync as
|
|
54538
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
54491
54539
|
import { homedir as homedir2 } from "os";
|
|
54492
|
-
import
|
|
54540
|
+
import path11 from "path";
|
|
54493
54541
|
|
|
54494
54542
|
// src/content/packs.ts
|
|
54495
54543
|
var packContents = packCatalog;
|
|
@@ -54535,9 +54583,13 @@ import path6 from "path";
|
|
|
54535
54583
|
var ignoredDirectoryNames = new Set([
|
|
54536
54584
|
".git",
|
|
54537
54585
|
".agents",
|
|
54586
|
+
".claude",
|
|
54587
|
+
".codex",
|
|
54588
|
+
".cursor",
|
|
54538
54589
|
".devpunks",
|
|
54539
54590
|
".devpunks-cache",
|
|
54540
54591
|
".next",
|
|
54592
|
+
".opencode",
|
|
54541
54593
|
".source",
|
|
54542
54594
|
".turbo",
|
|
54543
54595
|
"coverage",
|
|
@@ -54551,6 +54603,7 @@ var ignoredDirectoryNames = new Set([
|
|
|
54551
54603
|
"skills",
|
|
54552
54604
|
"test-fixtures",
|
|
54553
54605
|
"tmp",
|
|
54606
|
+
"worktrees",
|
|
54554
54607
|
".venv",
|
|
54555
54608
|
"venv",
|
|
54556
54609
|
"__pycache__"
|
|
@@ -54867,7 +54920,155 @@ var hasBackendWorkspaceName = (manifest) => {
|
|
|
54867
54920
|
var hasBackendSurface = (result) => exports_Array.some(result.detectedTechnologies, (technology) => technology === "better-auth" || technology === "drizzle" || technology === "elysia" || technology === "trpc") || result.manifests.some(hasBackendWorkspaceName);
|
|
54868
54921
|
|
|
54869
54922
|
// src/core/format-summary.ts
|
|
54923
|
+
import path8 from "path";
|
|
54924
|
+
|
|
54925
|
+
// src/core/tools.ts
|
|
54926
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
54927
|
+
import { accessSync, constants as constants2 } from "fs";
|
|
54928
|
+
import { homedir } from "os";
|
|
54870
54929
|
import path7 from "path";
|
|
54930
|
+
var commandExistsOnPath = (command, env2 = process.env, platform = process.platform) => {
|
|
54931
|
+
const pathValue = env2.PATH ?? env2.Path;
|
|
54932
|
+
if (pathValue === undefined || pathValue.length === 0) {
|
|
54933
|
+
return false;
|
|
54934
|
+
}
|
|
54935
|
+
const isWindows = platform === "win32";
|
|
54936
|
+
const pathSeparator = isWindows ? ";" : ":";
|
|
54937
|
+
const pathEntries = pathValue.split(pathSeparator).filter((entry) => entry.length > 0);
|
|
54938
|
+
const pathExtensions = isWindows ? (env2.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0) : [""];
|
|
54939
|
+
const commandExtensions = isWindows && path7.extname(command).length === 0 ? pathExtensions : [""];
|
|
54940
|
+
const hasPathSegment = command.includes("/") || command.includes("\\");
|
|
54941
|
+
const candidates = (hasPathSegment ? [""] : pathEntries).flatMap((entry) => commandExtensions.map((extension) => hasPathSegment ? `${command}${extension}` : path7.join(entry, `${command}${extension}`)));
|
|
54942
|
+
return candidates.some((candidate) => {
|
|
54943
|
+
try {
|
|
54944
|
+
accessSync(candidate, isWindows ? constants2.F_OK : constants2.X_OK);
|
|
54945
|
+
return true;
|
|
54946
|
+
} catch {
|
|
54947
|
+
return false;
|
|
54948
|
+
}
|
|
54949
|
+
});
|
|
54950
|
+
};
|
|
54951
|
+
var defaultRuntime3 = {
|
|
54952
|
+
cwd: homedir(),
|
|
54953
|
+
commandExists: commandExistsOnPath,
|
|
54954
|
+
execFile: (command, args2, options9) => {
|
|
54955
|
+
execFileSync4(command, [...args2], {
|
|
54956
|
+
cwd: options9?.cwd,
|
|
54957
|
+
stdio: options9?.stdio === "inherit" ? ["ignore", "inherit", "inherit"] : "ignore"
|
|
54958
|
+
});
|
|
54959
|
+
}
|
|
54960
|
+
};
|
|
54961
|
+
var detectGlobalPackageManager = (runtime5) => {
|
|
54962
|
+
if (runtime5.commandExists("bun")) {
|
|
54963
|
+
return "bun";
|
|
54964
|
+
}
|
|
54965
|
+
if (runtime5.commandExists("pnpm")) {
|
|
54966
|
+
return "pnpm";
|
|
54967
|
+
}
|
|
54968
|
+
if (runtime5.commandExists("npm")) {
|
|
54969
|
+
return "npm";
|
|
54970
|
+
}
|
|
54971
|
+
return null;
|
|
54972
|
+
};
|
|
54973
|
+
var globalInstallCommandFor = (packageManager, packageName) => {
|
|
54974
|
+
switch (packageManager) {
|
|
54975
|
+
case "bun":
|
|
54976
|
+
return ["bun", "add", "-g", packageName];
|
|
54977
|
+
case "pnpm":
|
|
54978
|
+
return ["pnpm", "add", "-g", packageName];
|
|
54979
|
+
case "npm":
|
|
54980
|
+
return ["npm", "install", "-g", packageName];
|
|
54981
|
+
}
|
|
54982
|
+
};
|
|
54983
|
+
var ensureToolsInstalled = (toolIds, baseline = bundledBaseline, runtime5 = defaultRuntime3) => {
|
|
54984
|
+
const packageManager = detectGlobalPackageManager(runtime5);
|
|
54985
|
+
const statuses = [];
|
|
54986
|
+
const toolCatalogById = Object.fromEntries(baseline.tools.map((tool) => [tool.id, tool]));
|
|
54987
|
+
if (toolIds.length > 0 && packageManager === null) {
|
|
54988
|
+
throw new Error("Cannot install required tools because no supported global package manager was found on PATH. Install Bun, pnpm, or npm first.");
|
|
54989
|
+
}
|
|
54990
|
+
const globalPackageManager = packageManager;
|
|
54991
|
+
const cwd = runtime5.cwd ?? homedir();
|
|
54992
|
+
for (const toolId of toolIds) {
|
|
54993
|
+
const tool = toolCatalogById[toolId];
|
|
54994
|
+
if (tool === undefined) {
|
|
54995
|
+
throw new Error(`Unknown required tool \`${toolId}\` in baseline.`);
|
|
54996
|
+
}
|
|
54997
|
+
const missingPrerequisites = tool.requiredBins.filter((command) => !runtime5.commandExists(command));
|
|
54998
|
+
if (missingPrerequisites.length > 0) {
|
|
54999
|
+
throw new Error(`Cannot install required tool \`${toolId}\` because ${missingPrerequisites.join(", ")} is not available on PATH.`);
|
|
55000
|
+
}
|
|
55001
|
+
const alreadyPresent = runtime5.commandExists(toolId);
|
|
55002
|
+
if (!alreadyPresent) {
|
|
55003
|
+
const [command, ...args2] = globalInstallCommandFor(globalPackageManager, tool.packageName);
|
|
55004
|
+
runtime5.execFile(command, args2, {
|
|
55005
|
+
cwd,
|
|
55006
|
+
stdio: "inherit"
|
|
55007
|
+
});
|
|
55008
|
+
if (!runtime5.commandExists(toolId)) {
|
|
55009
|
+
throw new Error(`Tried to install required tool \`${toolId}\`, but the binary is still not available on PATH afterwards.`);
|
|
55010
|
+
}
|
|
55011
|
+
}
|
|
55012
|
+
for (const [command, ...args2] of tool.ensureCommands) {
|
|
55013
|
+
runtime5.execFile(command, args2, {
|
|
55014
|
+
cwd,
|
|
55015
|
+
stdio: "inherit"
|
|
55016
|
+
});
|
|
55017
|
+
}
|
|
55018
|
+
statuses.push({
|
|
55019
|
+
toolId,
|
|
55020
|
+
status: alreadyPresent ? "already-present" : "installed"
|
|
55021
|
+
});
|
|
55022
|
+
}
|
|
55023
|
+
return statuses;
|
|
55024
|
+
};
|
|
55025
|
+
var errorMessage = (cause3) => cause3 instanceof Error ? cause3.message : String(cause3);
|
|
55026
|
+
var errorStack = (cause3) => cause3 instanceof Error ? cause3.stack ?? cause3.message : String(cause3);
|
|
55027
|
+
var ensureToolsInstalledBestEffort = (toolIds, baseline = bundledBaseline, runtime5 = defaultRuntime3) => toolIds.flatMap((toolId) => {
|
|
55028
|
+
try {
|
|
55029
|
+
return ensureToolsInstalled([toolId], baseline, runtime5);
|
|
55030
|
+
} catch (cause3) {
|
|
55031
|
+
return [
|
|
55032
|
+
{
|
|
55033
|
+
toolId,
|
|
55034
|
+
status: "failed",
|
|
55035
|
+
errorMessage: errorMessage(cause3),
|
|
55036
|
+
errorStack: errorStack(cause3)
|
|
55037
|
+
}
|
|
55038
|
+
];
|
|
55039
|
+
}
|
|
55040
|
+
});
|
|
55041
|
+
var formatToolBootstrapStatus = (entry) => {
|
|
55042
|
+
switch (entry.status) {
|
|
55043
|
+
case "already-present":
|
|
55044
|
+
return "already present";
|
|
55045
|
+
case "installed":
|
|
55046
|
+
return "installed during scaffold";
|
|
55047
|
+
case "failed":
|
|
55048
|
+
return "bootstrap failed";
|
|
55049
|
+
}
|
|
55050
|
+
};
|
|
55051
|
+
var formatToolBootstrapFailureDetails = (statuses) => {
|
|
55052
|
+
const failures2 = statuses.filter((entry) => entry.status === "failed");
|
|
55053
|
+
if (failures2.length === 0)
|
|
55054
|
+
return null;
|
|
55055
|
+
return [
|
|
55056
|
+
"Required tool bootstrap failed, but scaffold/update output can still be written.",
|
|
55057
|
+
"",
|
|
55058
|
+
"Agent recovery prompt:",
|
|
55059
|
+
"Read `.devpunks/required-tools.json`, verify each listed tool manually, then fix the failed install before deeper repo work. If `agent-browser` failed while installing Chromium, install or repair that browser dependency outside the scaffold command, then rerun `agent-browser install` or the documented tool check.",
|
|
55060
|
+
"",
|
|
55061
|
+
"Failure stack traces:",
|
|
55062
|
+
...failures2.flatMap((failure) => [
|
|
55063
|
+
"",
|
|
55064
|
+
`--- ${failure.toolId} ---`,
|
|
55065
|
+
failure.errorStack ?? failure.errorMessage ?? "Unknown tool bootstrap failure."
|
|
55066
|
+
])
|
|
55067
|
+
].join(`
|
|
55068
|
+
`);
|
|
55069
|
+
};
|
|
55070
|
+
|
|
55071
|
+
// src/core/format-summary.ts
|
|
54871
55072
|
var formatList = (values4) => values4.length === 0 ? [" \u2205"] : values4.map((value6) => ` \u2022 ${value6}`);
|
|
54872
55073
|
var wrapInlineValues = ({
|
|
54873
55074
|
values: values4,
|
|
@@ -54938,8 +55139,8 @@ var formatDetectionSummary = (detection) => [
|
|
|
54938
55139
|
`cwd: ${detection.cwd}`,
|
|
54939
55140
|
...section("detected languages:", formatList(detection.detectedLanguages)),
|
|
54940
55141
|
...section("detected technologies:", formatList(detection.detectedTechnologies)),
|
|
54941
|
-
...section("manifest files:", formatList(detection.manifests.map((manifest) =>
|
|
54942
|
-
...section("monorepo signals:", formatList(detection.monorepoSignals.map((signal) => `${signal.type} (${
|
|
55142
|
+
...section("manifest files:", formatList(detection.manifests.map((manifest) => path8.relative(detection.cwd, manifest.path) || "package.json"))),
|
|
55143
|
+
...section("monorepo signals:", formatList(detection.monorepoSignals.map((signal) => `${signal.type} (${path8.relative(detection.cwd, signal.path) || "."})`)))
|
|
54943
55144
|
].join(`
|
|
54944
55145
|
`);
|
|
54945
55146
|
var formatConfirmationSummary = (result, baseline = bundledBaseline) => [
|
|
@@ -54969,7 +55170,7 @@ var formatConfirmationSummary = (result, baseline = bundledBaseline) => [
|
|
|
54969
55170
|
...maybeSection("hidden output directories:", formatList(result.hiddenOutputDirectories)),
|
|
54970
55171
|
...section("agent handoff file:", formatList([result.agentHandoffFile])),
|
|
54971
55172
|
...section("required tools file:", formatList([result.requiredToolsFile])),
|
|
54972
|
-
...maybeSection("tool bootstrap:", formatList(result.toolBootstrapStatuses.map((entry) => `${entry.toolId}: ${entry
|
|
55173
|
+
...maybeSection("tool bootstrap:", formatList(result.toolBootstrapStatuses.map((entry) => `${entry.toolId}: ${formatToolBootstrapStatus(entry)}`))),
|
|
54973
55174
|
...section("scaffold manifest:", formatList([result.scaffoldManifestFile]))
|
|
54974
55175
|
].join(`
|
|
54975
55176
|
`);
|
|
@@ -54985,9 +55186,15 @@ var formatAgentHandoffSummary = (result) => [
|
|
|
54985
55186
|
"",
|
|
54986
55187
|
...result.toolBootstrapStatuses.length === 0 ? [] : [
|
|
54987
55188
|
"Tool bootstrap status:",
|
|
54988
|
-
...result.toolBootstrapStatuses.map((entry) => ` \u2022 \`${entry.toolId}\`: ${entry
|
|
55189
|
+
...result.toolBootstrapStatuses.map((entry) => ` \u2022 \`${entry.toolId}\`: ${formatToolBootstrapStatus(entry)}`),
|
|
54989
55190
|
""
|
|
54990
55191
|
],
|
|
55192
|
+
...result.toolBootstrapStatuses.some((entry) => entry.status === "failed") ? [
|
|
55193
|
+
"Tool bootstrap recovery:",
|
|
55194
|
+
" \u2022 Read `.devpunks/required-tools.json` and manually verify every listed tool before deeper repo work.",
|
|
55195
|
+
" \u2022 Repair failed installs outside the scaffold command. For `agent-browser` Chromium failures, rerun `agent-browser install` after fixing the local browser dependency.",
|
|
55196
|
+
""
|
|
55197
|
+
] : [],
|
|
54991
55198
|
"What was scaffolded:",
|
|
54992
55199
|
" \u2022 final scoped/root prompt files were not written yet",
|
|
54993
55200
|
...formatList([
|
|
@@ -55044,6 +55251,47 @@ var formatResolvedPackSummary = (options9) => options9.optionalPacks.length ===
|
|
|
55044
55251
|
].join(`
|
|
55045
55252
|
`);
|
|
55046
55253
|
|
|
55254
|
+
// src/core/gitignore.ts
|
|
55255
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
55256
|
+
import path9 from "path";
|
|
55257
|
+
var harnessDirectories = new Set([".agents", ".claude", ".codex", ".cursor", ".opencode"]);
|
|
55258
|
+
var normalizeGitignorePattern = (line4) => {
|
|
55259
|
+
const trimmed2 = line4.trim();
|
|
55260
|
+
if (trimmed2 === "" || trimmed2.startsWith("#") || trimmed2.startsWith("!")) {
|
|
55261
|
+
return null;
|
|
55262
|
+
}
|
|
55263
|
+
return trimmed2.replace(/^\//, "").replace(/\/\*\*?$/, "").replace(/\/$/, "");
|
|
55264
|
+
};
|
|
55265
|
+
var isHarnessDirectoryIgnore = (line4) => {
|
|
55266
|
+
const normalized = normalizeGitignorePattern(line4);
|
|
55267
|
+
return normalized !== null && harnessDirectories.has(normalized);
|
|
55268
|
+
};
|
|
55269
|
+
var removeHarnessDirectoriesFromGitignore = (rootDirectory) => {
|
|
55270
|
+
const gitignorePath = path9.join(rootDirectory, ".gitignore");
|
|
55271
|
+
if (!existsSync4(gitignorePath)) {
|
|
55272
|
+
return { gitignorePath, removedPatterns: [] };
|
|
55273
|
+
}
|
|
55274
|
+
const original = readFileSync5(gitignorePath, "utf8");
|
|
55275
|
+
const hadFinalNewline = original.endsWith(`
|
|
55276
|
+
`);
|
|
55277
|
+
const removedPatterns = [];
|
|
55278
|
+
const keptLines = original.split(/\r?\n/).filter((line4, index, lines3) => {
|
|
55279
|
+
if (index === lines3.length - 1 && line4 === "")
|
|
55280
|
+
return false;
|
|
55281
|
+
if (!isHarnessDirectoryIgnore(line4))
|
|
55282
|
+
return true;
|
|
55283
|
+
removedPatterns.push(line4.trim());
|
|
55284
|
+
return false;
|
|
55285
|
+
});
|
|
55286
|
+
if (removedPatterns.length === 0) {
|
|
55287
|
+
return { gitignorePath, removedPatterns };
|
|
55288
|
+
}
|
|
55289
|
+
writeFileSync2(gitignorePath, `${keptLines.join(`
|
|
55290
|
+
`)}${hadFinalNewline ? `
|
|
55291
|
+
` : ""}`, "utf8");
|
|
55292
|
+
return { gitignorePath, removedPatterns };
|
|
55293
|
+
};
|
|
55294
|
+
|
|
55047
55295
|
// src/core/pack-registry.ts
|
|
55048
55296
|
var defaultPackIds2 = defaultPackIdsForBaseline();
|
|
55049
55297
|
var detectedPackIds2 = detectedPackIdsForBaseline();
|
|
@@ -55125,122 +55373,21 @@ var finalizePackSelection = (resolved, additions, removals) => {
|
|
|
55125
55373
|
};
|
|
55126
55374
|
var canRemovePack = (resolved, packId) => resolved.preselectedPacks.includes(packId) && !resolved.defaultPacks.includes(packId);
|
|
55127
55375
|
|
|
55128
|
-
// src/core/tools.ts
|
|
55129
|
-
import { execFileSync as execFileSync4 } from "child_process";
|
|
55130
|
-
import { accessSync, constants as constants2 } from "fs";
|
|
55131
|
-
import { homedir } from "os";
|
|
55132
|
-
import path8 from "path";
|
|
55133
|
-
var commandExistsOnPath = (command, env2 = process.env, platform = process.platform) => {
|
|
55134
|
-
const pathValue = env2.PATH ?? env2.Path;
|
|
55135
|
-
if (pathValue === undefined || pathValue.length === 0) {
|
|
55136
|
-
return false;
|
|
55137
|
-
}
|
|
55138
|
-
const isWindows = platform === "win32";
|
|
55139
|
-
const pathSeparator = isWindows ? ";" : ":";
|
|
55140
|
-
const pathEntries = pathValue.split(pathSeparator).filter((entry) => entry.length > 0);
|
|
55141
|
-
const pathExtensions = isWindows ? (env2.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0) : [""];
|
|
55142
|
-
const commandExtensions = isWindows && path8.extname(command).length === 0 ? pathExtensions : [""];
|
|
55143
|
-
const hasPathSegment = command.includes("/") || command.includes("\\");
|
|
55144
|
-
const candidates = (hasPathSegment ? [""] : pathEntries).flatMap((entry) => commandExtensions.map((extension) => hasPathSegment ? `${command}${extension}` : path8.join(entry, `${command}${extension}`)));
|
|
55145
|
-
return candidates.some((candidate) => {
|
|
55146
|
-
try {
|
|
55147
|
-
accessSync(candidate, isWindows ? constants2.F_OK : constants2.X_OK);
|
|
55148
|
-
return true;
|
|
55149
|
-
} catch {
|
|
55150
|
-
return false;
|
|
55151
|
-
}
|
|
55152
|
-
});
|
|
55153
|
-
};
|
|
55154
|
-
var defaultRuntime3 = {
|
|
55155
|
-
cwd: homedir(),
|
|
55156
|
-
commandExists: commandExistsOnPath,
|
|
55157
|
-
execFile: (command, args2, options9) => {
|
|
55158
|
-
execFileSync4(command, [...args2], {
|
|
55159
|
-
cwd: options9?.cwd,
|
|
55160
|
-
stdio: options9?.stdio ?? "inherit"
|
|
55161
|
-
});
|
|
55162
|
-
}
|
|
55163
|
-
};
|
|
55164
|
-
var detectGlobalPackageManager = (runtime5) => {
|
|
55165
|
-
if (runtime5.commandExists("bun")) {
|
|
55166
|
-
return "bun";
|
|
55167
|
-
}
|
|
55168
|
-
if (runtime5.commandExists("pnpm")) {
|
|
55169
|
-
return "pnpm";
|
|
55170
|
-
}
|
|
55171
|
-
if (runtime5.commandExists("npm")) {
|
|
55172
|
-
return "npm";
|
|
55173
|
-
}
|
|
55174
|
-
return null;
|
|
55175
|
-
};
|
|
55176
|
-
var globalInstallCommandFor = (packageManager, packageName) => {
|
|
55177
|
-
switch (packageManager) {
|
|
55178
|
-
case "bun":
|
|
55179
|
-
return ["bun", "add", "-g", packageName];
|
|
55180
|
-
case "pnpm":
|
|
55181
|
-
return ["pnpm", "add", "-g", packageName];
|
|
55182
|
-
case "npm":
|
|
55183
|
-
return ["npm", "install", "-g", packageName];
|
|
55184
|
-
}
|
|
55185
|
-
};
|
|
55186
|
-
var ensureToolsInstalled = (toolIds, baseline = bundledBaseline, runtime5 = defaultRuntime3) => {
|
|
55187
|
-
const packageManager = detectGlobalPackageManager(runtime5);
|
|
55188
|
-
const statuses = [];
|
|
55189
|
-
const toolCatalogById = Object.fromEntries(baseline.tools.map((tool) => [tool.id, tool]));
|
|
55190
|
-
if (toolIds.length > 0 && packageManager === null) {
|
|
55191
|
-
throw new Error("Cannot install required tools because no supported global package manager was found on PATH. Install Bun, pnpm, or npm first.");
|
|
55192
|
-
}
|
|
55193
|
-
const globalPackageManager = packageManager;
|
|
55194
|
-
const cwd = runtime5.cwd ?? homedir();
|
|
55195
|
-
for (const toolId of toolIds) {
|
|
55196
|
-
const tool = toolCatalogById[toolId];
|
|
55197
|
-
if (tool === undefined) {
|
|
55198
|
-
throw new Error(`Unknown required tool \`${toolId}\` in baseline.`);
|
|
55199
|
-
}
|
|
55200
|
-
const missingPrerequisites = tool.requiredBins.filter((command) => !runtime5.commandExists(command));
|
|
55201
|
-
if (missingPrerequisites.length > 0) {
|
|
55202
|
-
throw new Error(`Cannot install required tool \`${toolId}\` because ${missingPrerequisites.join(", ")} is not available on PATH.`);
|
|
55203
|
-
}
|
|
55204
|
-
const alreadyPresent = runtime5.commandExists(toolId);
|
|
55205
|
-
if (!alreadyPresent) {
|
|
55206
|
-
const [command, ...args2] = globalInstallCommandFor(globalPackageManager, tool.packageName);
|
|
55207
|
-
runtime5.execFile(command, args2, {
|
|
55208
|
-
cwd,
|
|
55209
|
-
stdio: "inherit"
|
|
55210
|
-
});
|
|
55211
|
-
if (!runtime5.commandExists(toolId)) {
|
|
55212
|
-
throw new Error(`Tried to install required tool \`${toolId}\`, but the binary is still not available on PATH afterwards.`);
|
|
55213
|
-
}
|
|
55214
|
-
}
|
|
55215
|
-
for (const [command, ...args2] of tool.ensureCommands) {
|
|
55216
|
-
runtime5.execFile(command, args2, {
|
|
55217
|
-
cwd,
|
|
55218
|
-
stdio: "inherit"
|
|
55219
|
-
});
|
|
55220
|
-
}
|
|
55221
|
-
statuses.push({
|
|
55222
|
-
toolId,
|
|
55223
|
-
status: alreadyPresent ? "already-present" : "installed"
|
|
55224
|
-
});
|
|
55225
|
-
}
|
|
55226
|
-
return statuses;
|
|
55227
|
-
};
|
|
55228
|
-
|
|
55229
55376
|
// src/scaffold/output.ts
|
|
55230
55377
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
55231
55378
|
import { createHash as createHash2 } from "crypto";
|
|
55232
55379
|
import {
|
|
55233
55380
|
cpSync,
|
|
55234
|
-
existsSync as
|
|
55381
|
+
existsSync as existsSync5,
|
|
55235
55382
|
lstatSync,
|
|
55236
55383
|
mkdirSync as mkdirSync2,
|
|
55237
55384
|
readdirSync as readdirSync2,
|
|
55238
|
-
readFileSync as
|
|
55385
|
+
readFileSync as readFileSync6,
|
|
55239
55386
|
readlinkSync,
|
|
55240
55387
|
rmSync as rmSync2,
|
|
55241
|
-
writeFileSync as
|
|
55388
|
+
writeFileSync as writeFileSync3
|
|
55242
55389
|
} from "fs";
|
|
55243
|
-
import
|
|
55390
|
+
import path10 from "path";
|
|
55244
55391
|
|
|
55245
55392
|
// src/content/prompts.ts
|
|
55246
55393
|
var phaseSkillIds = [
|
|
@@ -55515,7 +55662,10 @@ var renderAgentHandoffMarkdown = ({
|
|
|
55515
55662
|
"- Subagent manifest scaffolding/specs under `.agents/subagents/` and `.devpunks/specs/subagents/`.",
|
|
55516
55663
|
`- Scaffold manifest at \`${scaffoldManifestFile}\`.`,
|
|
55517
55664
|
`- Required tools manifest at \`${requiredToolsFile}\`.`,
|
|
55518
|
-
...toolBootstrapStatuses.map((entry) => `- Tool bootstrap: \`${entry.toolId}\` was ${entry
|
|
55665
|
+
...toolBootstrapStatuses.map((entry) => `- Tool bootstrap: \`${entry.toolId}\` was ${formatToolBootstrapStatus(entry)}.`),
|
|
55666
|
+
...toolBootstrapStatuses.some((entry) => entry.status === "failed") ? [
|
|
55667
|
+
"- Tool bootstrap recovery: read `.devpunks/required-tools.json`, manually verify every listed tool, and repair failed installs before deeper repo work. For `agent-browser` Chromium failures, rerun `agent-browser install` after fixing the local browser dependency."
|
|
55668
|
+
] : [],
|
|
55519
55669
|
"",
|
|
55520
55670
|
"## Repo shape",
|
|
55521
55671
|
"",
|
|
@@ -55764,9 +55914,9 @@ var sortSubagentSpecialists = (spec) => ({
|
|
|
55764
55914
|
|
|
55765
55915
|
// src/scaffold/output.ts
|
|
55766
55916
|
var encodeJson = encodeSync(parseJson(Unknown));
|
|
55767
|
-
var toPosixPath = (value6) => value6.split(
|
|
55917
|
+
var toPosixPath = (value6) => value6.split(path10.sep).join("/");
|
|
55768
55918
|
var relativePosixPath = (from, to) => {
|
|
55769
|
-
const relativePath =
|
|
55919
|
+
const relativePath = path10.relative(from, to);
|
|
55770
55920
|
return relativePath === "" ? "." : toPosixPath(relativePath);
|
|
55771
55921
|
};
|
|
55772
55922
|
var specPathForPromptTarget = (relativePath) => {
|
|
@@ -55780,16 +55930,64 @@ var specPathForPromptTarget = (relativePath) => {
|
|
|
55780
55930
|
if (promptTargetPath === "docs/AGENTS.md") {
|
|
55781
55931
|
return ".devpunks/specs/prompts/docs.md";
|
|
55782
55932
|
}
|
|
55783
|
-
return
|
|
55933
|
+
return path10.posix.join(".devpunks/specs/prompts", path10.posix.dirname(promptTargetPath), "prompt.md");
|
|
55784
55934
|
};
|
|
55785
55935
|
var uniqueSorted = (values4) => [...new Set(values4)].toSorted();
|
|
55786
55936
|
var collectOpensrcReferences = (promptSpecs) => uniqueSorted(promptSpecs.flatMap((spec) => spec.opensrcReferences));
|
|
55787
55937
|
var opensrcReferencesForPacks = (packs) => uniqueSorted(packs.flatMap((packId) => exampleRepositoriesForPack(packId).map((repo) => repo.repo)));
|
|
55788
55938
|
var detectionHasPackage = (detection, packageName) => detection.manifests.some((manifest) => manifest.dependencies.includes(packageName));
|
|
55789
55939
|
var selectedSkills = (finalPacks, baseline) => uniqueSorted(finalPacks.flatMap((packId) => skillsForPack(packId, baseline)));
|
|
55940
|
+
var legacySkillDirectories = [
|
|
55941
|
+
".claude/skills",
|
|
55942
|
+
".codex/skills",
|
|
55943
|
+
".cursor/skills",
|
|
55944
|
+
".opencode/skills"
|
|
55945
|
+
];
|
|
55946
|
+
var nextAvailableSkillDirectory = (sharedSkillsDirectory, skillName, reservedSkillNames) => {
|
|
55947
|
+
if (!reservedSkillNames.has(skillName) && !existsSync5(path10.join(sharedSkillsDirectory, skillName))) {
|
|
55948
|
+
return skillName;
|
|
55949
|
+
}
|
|
55950
|
+
let suffix = 1;
|
|
55951
|
+
while (true) {
|
|
55952
|
+
const candidate = suffix === 1 ? `${skillName}-local` : `${skillName}-local-${suffix}`;
|
|
55953
|
+
if (!reservedSkillNames.has(candidate) && !existsSync5(path10.join(sharedSkillsDirectory, candidate))) {
|
|
55954
|
+
return candidate;
|
|
55955
|
+
}
|
|
55956
|
+
suffix += 1;
|
|
55957
|
+
}
|
|
55958
|
+
};
|
|
55959
|
+
var migrateLegacySkillDirectories = ({
|
|
55960
|
+
outputDirectory,
|
|
55961
|
+
finalSkills
|
|
55962
|
+
}) => {
|
|
55963
|
+
const sharedSkillsDirectory = path10.join(outputDirectory, ".agents/skills");
|
|
55964
|
+
const reservedSkillNames = new Set(finalSkills);
|
|
55965
|
+
mkdirSync2(sharedSkillsDirectory, { recursive: true });
|
|
55966
|
+
for (const relativeDirectory of legacySkillDirectories) {
|
|
55967
|
+
const absoluteDirectory = path10.join(outputDirectory, relativeDirectory);
|
|
55968
|
+
if (!existsSync5(absoluteDirectory)) {
|
|
55969
|
+
continue;
|
|
55970
|
+
}
|
|
55971
|
+
const stat3 = lstatSync(absoluteDirectory);
|
|
55972
|
+
if (stat3.isSymbolicLink() || !stat3.isDirectory()) {
|
|
55973
|
+
continue;
|
|
55974
|
+
}
|
|
55975
|
+
for (const entry of readdirSync2(absoluteDirectory, { withFileTypes: true })) {
|
|
55976
|
+
if (!entry.isDirectory()) {
|
|
55977
|
+
continue;
|
|
55978
|
+
}
|
|
55979
|
+
const sourceDirectory = path10.join(absoluteDirectory, entry.name);
|
|
55980
|
+
const migratedName = nextAvailableSkillDirectory(sharedSkillsDirectory, entry.name, reservedSkillNames);
|
|
55981
|
+
const targetDirectory = path10.join(sharedSkillsDirectory, migratedName);
|
|
55982
|
+
cpSync(sourceDirectory, targetDirectory, { recursive: true });
|
|
55983
|
+
rmSync2(sourceDirectory, { recursive: true, force: true });
|
|
55984
|
+
}
|
|
55985
|
+
rmSync2(absoluteDirectory, { recursive: true, force: true });
|
|
55986
|
+
}
|
|
55987
|
+
};
|
|
55790
55988
|
var selectedHookIds = (finalPacks, baseline) => uniqueSorted(finalPacks.flatMap((packId) => hooksForPack(packId, baseline)));
|
|
55791
55989
|
var oxlintConfigCandidates = [".oxlintrc.json", ".oxlintrc.jsonc", "oxlint.config.ts"];
|
|
55792
|
-
var existingOxlintConfigFiles = (scanDirectory) => oxlintConfigCandidates.filter((candidate) =>
|
|
55990
|
+
var existingOxlintConfigFiles = (scanDirectory) => oxlintConfigCandidates.filter((candidate) => existsSync5(path10.join(scanDirectory, candidate)));
|
|
55793
55991
|
var oxlintStarterConfig = {
|
|
55794
55992
|
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
55795
55993
|
env: {
|
|
@@ -55815,7 +56013,7 @@ var oxlintStarterConfig = {
|
|
|
55815
56013
|
],
|
|
55816
56014
|
overrides: []
|
|
55817
56015
|
};
|
|
55818
|
-
var detectedWorkspaces = (scanDirectory, detection) => detection.manifests.map((manifest) =>
|
|
56016
|
+
var detectedWorkspaces = (scanDirectory, detection) => detection.manifests.map((manifest) => path10.posix.dirname(relativePosixPath(scanDirectory, manifest.path))).filter((workspace) => workspace !== "" && workspace !== ".").toSorted();
|
|
55819
56017
|
var packsForWorkspace = ({
|
|
55820
56018
|
relativeWorkspacePath,
|
|
55821
56019
|
manifest,
|
|
@@ -55970,9 +56168,9 @@ var buildPromptSpec = ({
|
|
|
55970
56168
|
finalPacks,
|
|
55971
56169
|
baseline
|
|
55972
56170
|
}) => {
|
|
55973
|
-
const sourcePath =
|
|
55974
|
-
const source =
|
|
55975
|
-
const workspacePath = relativePath === ".agents/AGENTS.md" ? ".agents" : relativePath === "AGENTS.md" ? "." : relativePath === "docs/AGENTS.md" ? "docs" :
|
|
56171
|
+
const sourcePath = path10.join(scanDirectory, relativePath);
|
|
56172
|
+
const source = existsSync5(sourcePath) ? "copied" : "generated";
|
|
56173
|
+
const workspacePath = relativePath === ".agents/AGENTS.md" ? ".agents" : relativePath === "AGENTS.md" ? "." : relativePath === "docs/AGENTS.md" ? "docs" : path10.dirname(relativePath);
|
|
55976
56174
|
const packs = packsForWorkspace({
|
|
55977
56175
|
relativeWorkspacePath: workspacePath,
|
|
55978
56176
|
manifest,
|
|
@@ -56040,9 +56238,9 @@ var writeArtifact = ({
|
|
|
56040
56238
|
relativePath,
|
|
56041
56239
|
content
|
|
56042
56240
|
}) => {
|
|
56043
|
-
const absolutePath =
|
|
56044
|
-
mkdirSync2(
|
|
56045
|
-
|
|
56241
|
+
const absolutePath = path10.join(outputDirectory, relativePath);
|
|
56242
|
+
mkdirSync2(path10.dirname(absolutePath), { recursive: true });
|
|
56243
|
+
writeFileSync3(absolutePath, content, "utf8");
|
|
56046
56244
|
return relativePath;
|
|
56047
56245
|
};
|
|
56048
56246
|
var resolvePromptContent = ({
|
|
@@ -56053,9 +56251,9 @@ var resolvePromptContent = ({
|
|
|
56053
56251
|
baseline,
|
|
56054
56252
|
preserveExistingManagedFiles
|
|
56055
56253
|
}) => {
|
|
56056
|
-
const sourcePath =
|
|
56057
|
-
if (preserveExistingManagedFiles &&
|
|
56058
|
-
return
|
|
56254
|
+
const sourcePath = path10.join(scanDirectory, relativePath);
|
|
56255
|
+
if (preserveExistingManagedFiles && existsSync5(sourcePath)) {
|
|
56256
|
+
return readFileSync6(sourcePath, "utf8");
|
|
56059
56257
|
}
|
|
56060
56258
|
if (relativePath === ".agents/AGENTS.md") {
|
|
56061
56259
|
return sharedAgentsPromptTemplate;
|
|
@@ -56067,7 +56265,7 @@ var resolvePromptContent = ({
|
|
|
56067
56265
|
return docsPromptTemplate;
|
|
56068
56266
|
}
|
|
56069
56267
|
if (manifest) {
|
|
56070
|
-
const relativeWorkspacePath =
|
|
56268
|
+
const relativeWorkspacePath = path10.dirname(relativePath);
|
|
56071
56269
|
const packs = packsForWorkspace({
|
|
56072
56270
|
relativeWorkspacePath,
|
|
56073
56271
|
manifest,
|
|
@@ -56088,15 +56286,15 @@ var resolvePromptContent = ({
|
|
|
56088
56286
|
return "";
|
|
56089
56287
|
};
|
|
56090
56288
|
var collectRelativeFiles = (outputDirectory, relativeDirectory) => {
|
|
56091
|
-
const absoluteDirectory =
|
|
56092
|
-
if (!
|
|
56289
|
+
const absoluteDirectory = path10.join(outputDirectory, relativeDirectory);
|
|
56290
|
+
if (!existsSync5(absoluteDirectory)) {
|
|
56093
56291
|
return [];
|
|
56094
56292
|
}
|
|
56095
56293
|
const files = [];
|
|
56096
56294
|
const visit2 = (currentDirectory) => {
|
|
56097
56295
|
for (const entry of readdirSync2(currentDirectory, { withFileTypes: true })) {
|
|
56098
|
-
const absolutePath =
|
|
56099
|
-
const relativePath =
|
|
56296
|
+
const absolutePath = path10.join(currentDirectory, entry.name);
|
|
56297
|
+
const relativePath = path10.relative(outputDirectory, absolutePath).split(path10.sep).join("/");
|
|
56100
56298
|
const stat3 = lstatSync(absolutePath);
|
|
56101
56299
|
if (stat3.isSymbolicLink()) {
|
|
56102
56300
|
files.push(relativePath);
|
|
@@ -56151,8 +56349,8 @@ var managedKindForPath = (relativePath) => {
|
|
|
56151
56349
|
var expandManagedFiles = (outputDirectory, relativePaths) => {
|
|
56152
56350
|
const files = new Set;
|
|
56153
56351
|
for (const relativePath of relativePaths) {
|
|
56154
|
-
const absolutePath =
|
|
56155
|
-
if (!
|
|
56352
|
+
const absolutePath = path10.join(outputDirectory, relativePath);
|
|
56353
|
+
if (!existsSync5(absolutePath)) {
|
|
56156
56354
|
continue;
|
|
56157
56355
|
}
|
|
56158
56356
|
const stat3 = lstatSync(absolutePath);
|
|
@@ -56167,9 +56365,9 @@ var expandManagedFiles = (outputDirectory, relativePaths) => {
|
|
|
56167
56365
|
}
|
|
56168
56366
|
}
|
|
56169
56367
|
return [...files].toSorted().map((relativePath) => {
|
|
56170
|
-
const absolutePath =
|
|
56368
|
+
const absolutePath = path10.join(outputDirectory, relativePath);
|
|
56171
56369
|
const stat3 = lstatSync(absolutePath);
|
|
56172
|
-
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync(absolutePath)}` :
|
|
56370
|
+
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync(absolutePath)}` : readFileSync6(absolutePath);
|
|
56173
56371
|
return {
|
|
56174
56372
|
path: relativePath,
|
|
56175
56373
|
sha256: hashContent(content),
|
|
@@ -56182,7 +56380,7 @@ var promptTargetsForDetection = (scanDirectory, detection) => {
|
|
|
56182
56380
|
{ relativePath: ".agents/AGENTS.md", manifest: null },
|
|
56183
56381
|
{ relativePath: "AGENTS.md", manifest: null }
|
|
56184
56382
|
];
|
|
56185
|
-
if (
|
|
56383
|
+
if (existsSync5(path10.join(scanDirectory, "docs"))) {
|
|
56186
56384
|
targets.push({ relativePath: "docs/AGENTS.md", manifest: null });
|
|
56187
56385
|
}
|
|
56188
56386
|
if (!detection.monorepo) {
|
|
@@ -56194,7 +56392,7 @@ var promptTargetsForDetection = (scanDirectory, detection) => {
|
|
|
56194
56392
|
continue;
|
|
56195
56393
|
}
|
|
56196
56394
|
targets.push({
|
|
56197
|
-
relativePath:
|
|
56395
|
+
relativePath: path10.posix.join(path10.posix.dirname(relativeManifestPath), "AGENTS.md"),
|
|
56198
56396
|
manifest
|
|
56199
56397
|
});
|
|
56200
56398
|
}
|
|
@@ -56308,11 +56506,12 @@ var writeScaffoldOutput = ({
|
|
|
56308
56506
|
lintSpecFiles.push(lintStarterConfigFile);
|
|
56309
56507
|
}
|
|
56310
56508
|
}
|
|
56509
|
+
migrateLegacySkillDirectories({ outputDirectory, finalSkills });
|
|
56311
56510
|
for (const skillId of finalSkills) {
|
|
56312
56511
|
const sourceDirectory = skillRegistryByIdForBaseline(baseline)[skillId].sourceDirectory;
|
|
56313
|
-
const targetDirectory =
|
|
56314
|
-
const absoluteTargetDirectory =
|
|
56315
|
-
mkdirSync2(
|
|
56512
|
+
const targetDirectory = path10.posix.join(".agents/skills", skillId);
|
|
56513
|
+
const absoluteTargetDirectory = path10.join(outputDirectory, targetDirectory);
|
|
56514
|
+
mkdirSync2(path10.join(outputDirectory, ".agents/skills"), { recursive: true });
|
|
56316
56515
|
rmSync2(absoluteTargetDirectory, { recursive: true, force: true });
|
|
56317
56516
|
cpSync(resolveBaselinePath({
|
|
56318
56517
|
baselineRoot: baseline.root,
|
|
@@ -56350,11 +56549,11 @@ var writeScaffoldOutput = ({
|
|
|
56350
56549
|
content: encodeJson(subagentManifestSpec)
|
|
56351
56550
|
}));
|
|
56352
56551
|
subagentFiles.push(subagentManifestSpec.specFile);
|
|
56353
|
-
const sourceManifestPath =
|
|
56552
|
+
const sourceManifestPath = path10.join(scanDirectory, ".agents/subagents/manifest.mjs");
|
|
56354
56553
|
generatedFiles.push(writeArtifact({
|
|
56355
56554
|
outputDirectory,
|
|
56356
56555
|
relativePath: ".agents/subagents/manifest.mjs",
|
|
56357
|
-
content: shouldPreserveExistingManagedFiles &&
|
|
56556
|
+
content: shouldPreserveExistingManagedFiles && existsSync5(sourceManifestPath) ? readFileSync6(sourceManifestPath, "utf8") : renderSubagentManifestModule({
|
|
56358
56557
|
spec: subagentManifestSpec,
|
|
56359
56558
|
baseline,
|
|
56360
56559
|
fallback: defaultSubagentManifestTemplate
|
|
@@ -56369,7 +56568,7 @@ var writeScaffoldOutput = ({
|
|
|
56369
56568
|
}));
|
|
56370
56569
|
hookFiles.push(hook.outputPath);
|
|
56371
56570
|
}
|
|
56372
|
-
execFileSync5(process.execPath, [
|
|
56571
|
+
execFileSync5(process.execPath, [path10.join(outputDirectory, syncScriptFile)], {
|
|
56373
56572
|
cwd: outputDirectory,
|
|
56374
56573
|
stdio: "ignore"
|
|
56375
56574
|
});
|
|
@@ -56489,9 +56688,9 @@ var writeAgentSystemPrompt = ({
|
|
|
56489
56688
|
outputDirectory,
|
|
56490
56689
|
content
|
|
56491
56690
|
}) => {
|
|
56492
|
-
const absolutePath =
|
|
56493
|
-
mkdirSync3(
|
|
56494
|
-
|
|
56691
|
+
const absolutePath = path11.join(outputDirectory, agentSystemPromptFile);
|
|
56692
|
+
mkdirSync3(path11.dirname(absolutePath), { recursive: true });
|
|
56693
|
+
writeFileSync4(absolutePath, `${content}
|
|
56495
56694
|
`, "utf8");
|
|
56496
56695
|
return agentSystemPromptFile;
|
|
56497
56696
|
};
|
|
@@ -56559,25 +56758,26 @@ var runScaffold = ({
|
|
|
56559
56758
|
outputDirectory,
|
|
56560
56759
|
ensureTools = true,
|
|
56561
56760
|
baseline = bundledBaseline,
|
|
56562
|
-
assumeYes = false
|
|
56761
|
+
assumeYes = false,
|
|
56762
|
+
toolRuntime
|
|
56563
56763
|
}) => exports_Effect.gen(function* () {
|
|
56564
56764
|
const baseRequiredTools = requiredToolsForSkills([], baseline);
|
|
56565
56765
|
let toolBootstrapStatuses = [];
|
|
56566
|
-
const resolvedOutputDirectory =
|
|
56766
|
+
const resolvedOutputDirectory = path11.resolve(outputDirectory ?? scanDirectory);
|
|
56567
56767
|
yield* prompt4.writeLine(renderScaffoldTitle());
|
|
56568
56768
|
yield* prompt4.writeLine("");
|
|
56569
56769
|
yield* prompt4.writeLine(renderSetupIntro());
|
|
56570
56770
|
if (ensureTools && baseRequiredTools.length > 0) {
|
|
56571
56771
|
yield* prompt4.writeLine("");
|
|
56572
56772
|
yield* prompt4.writeLine(renderHint(`Checking base scaffold tools: ${baseRequiredTools.join(", ")}`));
|
|
56573
|
-
toolBootstrapStatuses =
|
|
56574
|
-
|
|
56575
|
-
catch: (cause3) => new CliValidationError({
|
|
56576
|
-
message: cause3 instanceof Error ? cause3.message : "Failed to install required base scaffold tools."
|
|
56577
|
-
})
|
|
56578
|
-
});
|
|
56579
|
-
yield* prompt4.writeLine(renderCommandSection("Base tool check", toolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${entry.status === "already-present" ? "already present" : "installed during scaffold"}`).join(`
|
|
56773
|
+
toolBootstrapStatuses = ensureToolsInstalledBestEffort(baseRequiredTools, baseline, toolRuntime);
|
|
56774
|
+
yield* prompt4.writeLine(renderCommandSection("Base tool check", toolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${formatToolBootstrapStatus(entry)}`).join(`
|
|
56580
56775
|
`)));
|
|
56776
|
+
const failureDetails = formatToolBootstrapFailureDetails(toolBootstrapStatuses);
|
|
56777
|
+
if (failureDetails !== null) {
|
|
56778
|
+
yield* prompt4.writeLine("");
|
|
56779
|
+
yield* prompt4.writeLine(renderCommandSection("Tool Bootstrap Warning", failureDetails));
|
|
56780
|
+
}
|
|
56581
56781
|
}
|
|
56582
56782
|
const detection = applyRepoShapeMode(yield* detectRepository(scanDirectory), repoShapeMode);
|
|
56583
56783
|
const resolved = resolvePackSelection(detection, baseline);
|
|
@@ -56645,18 +56845,18 @@ var runScaffold = ({
|
|
|
56645
56845
|
if (ensureTools && remainingRequiredTools.length > 0) {
|
|
56646
56846
|
yield* prompt4.writeLine("");
|
|
56647
56847
|
yield* prompt4.writeLine(renderHint(`Ensuring selected-pack tools: ${remainingRequiredTools.join(", ")}`));
|
|
56648
|
-
const remainingToolBootstrapStatuses =
|
|
56649
|
-
try: () => ensureToolsInstalled(remainingRequiredTools, baseline),
|
|
56650
|
-
catch: (cause3) => new CliValidationError({
|
|
56651
|
-
message: cause3 instanceof Error ? cause3.message : "Failed to install required scaffold tools."
|
|
56652
|
-
})
|
|
56653
|
-
});
|
|
56848
|
+
const remainingToolBootstrapStatuses = ensureToolsInstalledBestEffort(remainingRequiredTools, baseline, toolRuntime);
|
|
56654
56849
|
toolBootstrapStatuses = [
|
|
56655
56850
|
...toolBootstrapStatuses,
|
|
56656
56851
|
...remainingToolBootstrapStatuses
|
|
56657
56852
|
].toSorted((left3, right3) => left3.toolId.localeCompare(right3.toolId));
|
|
56658
|
-
yield* prompt4.writeLine(renderCommandSection("Tool bootstrap", remainingToolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${entry
|
|
56853
|
+
yield* prompt4.writeLine(renderCommandSection("Tool bootstrap", remainingToolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${formatToolBootstrapStatus(entry)}`).join(`
|
|
56659
56854
|
`)));
|
|
56855
|
+
const failureDetails = formatToolBootstrapFailureDetails(remainingToolBootstrapStatuses);
|
|
56856
|
+
if (failureDetails !== null) {
|
|
56857
|
+
yield* prompt4.writeLine("");
|
|
56858
|
+
yield* prompt4.writeLine(renderCommandSection("Tool Bootstrap Warning", failureDetails));
|
|
56859
|
+
}
|
|
56660
56860
|
}
|
|
56661
56861
|
const scaffoldOutput = yield* writeScaffoldOutput({
|
|
56662
56862
|
scanDirectory,
|
|
@@ -56667,6 +56867,7 @@ var runScaffold = ({
|
|
|
56667
56867
|
toolBootstrapStatuses,
|
|
56668
56868
|
baseline
|
|
56669
56869
|
});
|
|
56870
|
+
removeHarnessDirectoriesFromGitignore(scaffoldOutput.outputDirectory);
|
|
56670
56871
|
const renderedAgentSystemPrompt = formatAgentHandoffSummary({
|
|
56671
56872
|
cwd: scanDirectory,
|
|
56672
56873
|
repoShapeMode,
|
|
@@ -56787,8 +56988,17 @@ var runScaffold = ({
|
|
|
56787
56988
|
});
|
|
56788
56989
|
|
|
56789
56990
|
// src/scaffold/stage.ts
|
|
56790
|
-
import {
|
|
56791
|
-
|
|
56991
|
+
import {
|
|
56992
|
+
cpSync as cpSync2,
|
|
56993
|
+
existsSync as existsSync6,
|
|
56994
|
+
mkdirSync as mkdirSync4,
|
|
56995
|
+
readFileSync as readFileSync7,
|
|
56996
|
+
readdirSync as readdirSync3,
|
|
56997
|
+
rmSync as rmSync3,
|
|
56998
|
+
symlinkSync,
|
|
56999
|
+
writeFileSync as writeFileSync5
|
|
57000
|
+
} from "fs";
|
|
57001
|
+
import path12 from "path";
|
|
56792
57002
|
|
|
56793
57003
|
// src/content/wiki.ts
|
|
56794
57004
|
var makeWikiScaffoldTemplate = (wikiRoot) => ({
|
|
@@ -56933,9 +57143,9 @@ When processing source material into routed domain knowledge:
|
|
|
56933
57143
|
"version": "0.0.0",
|
|
56934
57144
|
"private": true,
|
|
56935
57145
|
"scripts": {
|
|
56936
|
-
"build": "fumadocs-mdx && next build",
|
|
57146
|
+
"build": "node ./scripts/sync-content.mjs && fumadocs-mdx && next build",
|
|
56937
57147
|
"check": "oxlint . && oxfmt --check .",
|
|
56938
|
-
"check-types": "fumadocs-mdx && next typegen && tsc --noEmit",
|
|
57148
|
+
"check-types": "node ./scripts/sync-content.mjs && fumadocs-mdx && next typegen && tsc --noEmit",
|
|
56939
57149
|
"dev": "next dev --turbopack --port=4000",
|
|
56940
57150
|
"postinstall": "fumadocs-mdx",
|
|
56941
57151
|
"start": "next start"
|
|
@@ -56984,6 +57194,210 @@ const config = {
|
|
|
56984
57194
|
};
|
|
56985
57195
|
|
|
56986
57196
|
export default withMDX(config);
|
|
57197
|
+
`
|
|
57198
|
+
},
|
|
57199
|
+
{
|
|
57200
|
+
path: "scripts/sync-content.mjs",
|
|
57201
|
+
content: `import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
57202
|
+
import path from "node:path";
|
|
57203
|
+
import { fileURLToPath } from "node:url";
|
|
57204
|
+
|
|
57205
|
+
const wikiRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
57206
|
+
const contentRoot = path.join(wikiRoot, "content", "docs");
|
|
57207
|
+
|
|
57208
|
+
const possibleRepoRoots = [
|
|
57209
|
+
path.resolve(wikiRoot, "..", ".."),
|
|
57210
|
+
path.resolve(wikiRoot, ".."),
|
|
57211
|
+
];
|
|
57212
|
+
|
|
57213
|
+
const repoRoot = possibleRepoRoots.find(
|
|
57214
|
+
(candidate) => existsSync(path.join(candidate, "docs")) || existsSync(path.join(candidate, "package.json")),
|
|
57215
|
+
);
|
|
57216
|
+
|
|
57217
|
+
const copiedTopLevelPages = new Set(["project"]);
|
|
57218
|
+
|
|
57219
|
+
syncTree(path.join(wikiRoot, "specs"), path.join(contentRoot, "project", "specs"), "Specs");
|
|
57220
|
+
syncTree(path.join(wikiRoot, "domains"), path.join(contentRoot, "wiki"), "Wiki");
|
|
57221
|
+
|
|
57222
|
+
if (repoRoot) {
|
|
57223
|
+
syncTree(path.join(repoRoot, "docs", "requirements"), path.join(contentRoot, "project", "requirements"), "Requirements");
|
|
57224
|
+
syncTree(path.join(repoRoot, "docs", "reference"), path.join(contentRoot, "project", "reference"), "Reference");
|
|
57225
|
+
syncTree(path.join(repoRoot, "docs", "runbooks"), path.join(contentRoot, "project", "runbooks"), "Runbooks");
|
|
57226
|
+
syncFile(path.join(repoRoot, "docs", "tech-decisions.md"), path.join(contentRoot, "project", "decisions", "tech-decisions.mdx"));
|
|
57227
|
+
}
|
|
57228
|
+
|
|
57229
|
+
mergeMeta(contentRoot, {
|
|
57230
|
+
title: "Project Docs",
|
|
57231
|
+
pages: Array.from(copiedTopLevelPages),
|
|
57232
|
+
});
|
|
57233
|
+
|
|
57234
|
+
mergeMeta(path.join(contentRoot, "project"), {
|
|
57235
|
+
title: "Project",
|
|
57236
|
+
description: "Internal project operations",
|
|
57237
|
+
pages: [
|
|
57238
|
+
"index",
|
|
57239
|
+
"grilling",
|
|
57240
|
+
"specs",
|
|
57241
|
+
"tech-debt",
|
|
57242
|
+
"maintenance",
|
|
57243
|
+
"runbooks",
|
|
57244
|
+
"decisions",
|
|
57245
|
+
"repo-guidance",
|
|
57246
|
+
...(existsSync(path.join(contentRoot, "project", "requirements")) ? ["requirements"] : []),
|
|
57247
|
+
...(existsSync(path.join(contentRoot, "project", "reference")) ? ["reference"] : []),
|
|
57248
|
+
],
|
|
57249
|
+
});
|
|
57250
|
+
|
|
57251
|
+
function syncTree(sourceDirectory, targetDirectory, title) {
|
|
57252
|
+
if (!existsSync(sourceDirectory)) return;
|
|
57253
|
+
|
|
57254
|
+
copyMarkdownTree(sourceDirectory, targetDirectory);
|
|
57255
|
+
writeMetaTree(targetDirectory, title);
|
|
57256
|
+
|
|
57257
|
+
const relativeTarget = path.relative(contentRoot, targetDirectory);
|
|
57258
|
+
const topLevel = relativeTarget.split(path.sep)[0];
|
|
57259
|
+
if (topLevel) copiedTopLevelPages.add(topLevel);
|
|
57260
|
+
}
|
|
57261
|
+
|
|
57262
|
+
function copyMarkdownTree(sourceDirectory, targetDirectory) {
|
|
57263
|
+
for (const entry of readdirSync(sourceDirectory, { withFileTypes: true })) {
|
|
57264
|
+
if (entry.name.startsWith(".")) continue;
|
|
57265
|
+
|
|
57266
|
+
const sourcePath = path.join(sourceDirectory, entry.name);
|
|
57267
|
+
const targetPath = path.join(targetDirectory, entry.name);
|
|
57268
|
+
|
|
57269
|
+
if (entry.isDirectory()) {
|
|
57270
|
+
copyMarkdownTree(sourcePath, targetPath);
|
|
57271
|
+
continue;
|
|
57272
|
+
}
|
|
57273
|
+
|
|
57274
|
+
if (!entry.isFile()) continue;
|
|
57275
|
+
if (!entry.name.endsWith(".md") && !entry.name.endsWith(".mdx")) continue;
|
|
57276
|
+
|
|
57277
|
+
syncFile(sourcePath, targetPath);
|
|
57278
|
+
}
|
|
57279
|
+
}
|
|
57280
|
+
|
|
57281
|
+
function syncFile(sourcePath, targetPath) {
|
|
57282
|
+
if (!existsSync(sourcePath)) return;
|
|
57283
|
+
if (existsSync(targetPath) && hasFrontmatter(readFileSync(targetPath, "utf8"))) return;
|
|
57284
|
+
|
|
57285
|
+
mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
57286
|
+
writeFileSync(targetPath, sanitizeMdx(readFileSync(sourcePath, "utf8"), targetPath));
|
|
57287
|
+
}
|
|
57288
|
+
|
|
57289
|
+
function hasFrontmatter(content) {
|
|
57290
|
+
return content.startsWith("---\\n");
|
|
57291
|
+
}
|
|
57292
|
+
|
|
57293
|
+
function writeMetaTree(directory, title) {
|
|
57294
|
+
if (!existsSync(directory)) return;
|
|
57295
|
+
|
|
57296
|
+
const entries = readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith("."));
|
|
57297
|
+
const files = entries
|
|
57298
|
+
.filter((entry) => entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".mdx")))
|
|
57299
|
+
.map((entry) => stripMarkdownExtension(entry.name))
|
|
57300
|
+
.filter((name) => name !== "meta");
|
|
57301
|
+
const folders = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
57302
|
+
const pages = orderPages([...files, ...folders]);
|
|
57303
|
+
|
|
57304
|
+
if (pages.length > 0) mergeMeta(directory, { title, pages });
|
|
57305
|
+
|
|
57306
|
+
for (const folder of folders) {
|
|
57307
|
+
writeMetaTree(path.join(directory, folder), titleFromSegment(folder));
|
|
57308
|
+
}
|
|
57309
|
+
}
|
|
57310
|
+
|
|
57311
|
+
function mergeMeta(directory, nextMeta) {
|
|
57312
|
+
mkdirSync(directory, { recursive: true });
|
|
57313
|
+
|
|
57314
|
+
const metaPath = path.join(directory, "meta.json");
|
|
57315
|
+
const existing = readJson(metaPath);
|
|
57316
|
+
const mergedPages = mergePages(existing.pages ?? [], nextMeta.pages);
|
|
57317
|
+
|
|
57318
|
+
writeFileSync(
|
|
57319
|
+
metaPath,
|
|
57320
|
+
formatMetaJson({
|
|
57321
|
+
...nextMeta,
|
|
57322
|
+
...existing,
|
|
57323
|
+
pages: mergedPages,
|
|
57324
|
+
}),
|
|
57325
|
+
);
|
|
57326
|
+
}
|
|
57327
|
+
|
|
57328
|
+
function formatMetaJson(meta) {
|
|
57329
|
+
const lines = Object.entries(meta).map(
|
|
57330
|
+
([key, value]) => " \\"" + key + "\\": " + JSON.stringify(value),
|
|
57331
|
+
);
|
|
57332
|
+
|
|
57333
|
+
return "{\\n" + lines.join(",\\n") + "\\n}\\n";
|
|
57334
|
+
}
|
|
57335
|
+
|
|
57336
|
+
function readJson(filePath) {
|
|
57337
|
+
if (!existsSync(filePath)) return {};
|
|
57338
|
+
|
|
57339
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
57340
|
+
}
|
|
57341
|
+
|
|
57342
|
+
function orderPages(pages) {
|
|
57343
|
+
return mergePages([], pages).sort((left, right) => {
|
|
57344
|
+
if (left === "index") return -1;
|
|
57345
|
+
if (right === "index") return 1;
|
|
57346
|
+
|
|
57347
|
+
return left.localeCompare(right);
|
|
57348
|
+
});
|
|
57349
|
+
}
|
|
57350
|
+
|
|
57351
|
+
function mergePages(existingPages, nextPages) {
|
|
57352
|
+
const existing = Array.isArray(existingPages) ? existingPages : [];
|
|
57353
|
+
const additions = nextPages.filter((page) => !existing.includes(page));
|
|
57354
|
+
const pages = [...existing, ...additions];
|
|
57355
|
+
|
|
57356
|
+
if (!pages.includes("index")) return pages;
|
|
57357
|
+
|
|
57358
|
+
return ["index", ...pages.filter((page) => page !== "index")];
|
|
57359
|
+
}
|
|
57360
|
+
|
|
57361
|
+
function stripMarkdownExtension(fileName) {
|
|
57362
|
+
return fileName.replace(/\\.mdx?$/, "");
|
|
57363
|
+
}
|
|
57364
|
+
|
|
57365
|
+
function titleFromSegment(segment) {
|
|
57366
|
+
return segment
|
|
57367
|
+
.split(/[-_]/)
|
|
57368
|
+
.filter(Boolean)
|
|
57369
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
57370
|
+
.join(" ");
|
|
57371
|
+
}
|
|
57372
|
+
|
|
57373
|
+
function sanitizeMdx(content, targetPath) {
|
|
57374
|
+
const sanitized = content.replace(/<([A-Z_][A-Z0-9_-]*)>/g, "\\\\<$1\\\\>");
|
|
57375
|
+
if (hasFrontmatter(sanitized)) return sanitized;
|
|
57376
|
+
|
|
57377
|
+
return [
|
|
57378
|
+
"---",
|
|
57379
|
+
"title: \\"" + titleFromDocument(sanitized, targetPath) + "\\"",
|
|
57380
|
+
"surface: project",
|
|
57381
|
+
"permission: project",
|
|
57382
|
+
"---",
|
|
57383
|
+
"",
|
|
57384
|
+
sanitized,
|
|
57385
|
+
].join("\\n");
|
|
57386
|
+
}
|
|
57387
|
+
|
|
57388
|
+
function titleFromDocument(content, targetPath) {
|
|
57389
|
+
const heading = content.match(/^#\\s+(.+)$/m)?.[1]?.trim();
|
|
57390
|
+
if (heading) return heading.replace(/"/g, "\\\\\\"");
|
|
57391
|
+
|
|
57392
|
+
return titleFromSegment(stripMarkdownExtension(path.basename(targetPath))).replace(/"/g, "\\\\\\"");
|
|
57393
|
+
}
|
|
57394
|
+
|
|
57395
|
+
if (repoRoot) {
|
|
57396
|
+
const displayedRoot = path.relative(wikiRoot, repoRoot) || ".";
|
|
57397
|
+
console.log(\`Synced wiki content from \${displayedRoot}\`);
|
|
57398
|
+
} else {
|
|
57399
|
+
console.log("No repository root detected; using checked-in wiki content.");
|
|
57400
|
+
}
|
|
56987
57401
|
`
|
|
56988
57402
|
},
|
|
56989
57403
|
{
|
|
@@ -57574,9 +57988,9 @@ var copySkillDirectory = ({
|
|
|
57574
57988
|
baseline
|
|
57575
57989
|
}) => {
|
|
57576
57990
|
const sourceDirectory = skillRegistryByIdForBaseline(baseline)[skillId].sourceDirectory;
|
|
57577
|
-
const targetDirectory =
|
|
57578
|
-
const absoluteTargetDirectory =
|
|
57579
|
-
mkdirSync4(
|
|
57991
|
+
const targetDirectory = path12.posix.join(".agents/skills", skillId);
|
|
57992
|
+
const absoluteTargetDirectory = path12.join(outputDirectory, targetDirectory);
|
|
57993
|
+
mkdirSync4(path12.join(outputDirectory, ".agents/skills"), { recursive: true });
|
|
57580
57994
|
rmSync3(absoluteTargetDirectory, { recursive: true, force: true });
|
|
57581
57995
|
cpSync2(resolveBaselinePath({
|
|
57582
57996
|
baselineRoot: baseline.root,
|
|
@@ -57585,19 +57999,77 @@ var copySkillDirectory = ({
|
|
|
57585
57999
|
}), absoluteTargetDirectory, { recursive: true });
|
|
57586
58000
|
return targetDirectory;
|
|
57587
58001
|
};
|
|
57588
|
-
var relativePosixPath2 = (from, to) =>
|
|
58002
|
+
var relativePosixPath2 = (from, to) => path12.relative(from, to).split(path12.sep).join("/");
|
|
57589
58003
|
var writeMissingFile = ({
|
|
57590
58004
|
outputDirectory,
|
|
57591
58005
|
targetPath,
|
|
57592
58006
|
content
|
|
57593
58007
|
}) => {
|
|
57594
|
-
if (
|
|
58008
|
+
if (existsSync6(targetPath)) {
|
|
58009
|
+
return null;
|
|
58010
|
+
}
|
|
58011
|
+
mkdirSync4(path12.dirname(targetPath), { recursive: true });
|
|
58012
|
+
writeFileSync5(targetPath, content);
|
|
58013
|
+
return relativePosixPath2(outputDirectory, targetPath);
|
|
58014
|
+
};
|
|
58015
|
+
var directoryHasEntries = (directoryPath) => existsSync6(directoryPath) && readdirSync3(directoryPath).some((entry) => !entry.startsWith("."));
|
|
58016
|
+
var writeManagedFile = ({
|
|
58017
|
+
outputDirectory,
|
|
58018
|
+
targetPath,
|
|
58019
|
+
content
|
|
58020
|
+
}) => {
|
|
58021
|
+
if (existsSync6(targetPath) && readFileSync7(targetPath, "utf8") === content) {
|
|
57595
58022
|
return null;
|
|
57596
58023
|
}
|
|
57597
|
-
mkdirSync4(
|
|
57598
|
-
|
|
58024
|
+
mkdirSync4(path12.dirname(targetPath), { recursive: true });
|
|
58025
|
+
writeFileSync5(targetPath, content);
|
|
57599
58026
|
return relativePosixPath2(outputDirectory, targetPath);
|
|
57600
58027
|
};
|
|
58028
|
+
var syncContentPrefix = "node ./scripts/sync-content.mjs && ";
|
|
58029
|
+
var withSyncContentPrefix = (script) => {
|
|
58030
|
+
if (typeof script !== "string")
|
|
58031
|
+
return script;
|
|
58032
|
+
if (script.includes("scripts/sync-content.mjs"))
|
|
58033
|
+
return script;
|
|
58034
|
+
return `${syncContentPrefix}${script}`;
|
|
58035
|
+
};
|
|
58036
|
+
var updateExistingWikiPackage = ({
|
|
58037
|
+
outputDirectory,
|
|
58038
|
+
packagePath
|
|
58039
|
+
}) => {
|
|
58040
|
+
if (!existsSync6(packagePath))
|
|
58041
|
+
return null;
|
|
58042
|
+
const packageJson = JSON.parse(readFileSync7(packagePath, "utf8"));
|
|
58043
|
+
const scripts = packageJson.scripts;
|
|
58044
|
+
if (!scripts)
|
|
58045
|
+
return null;
|
|
58046
|
+
const nextScripts = {
|
|
58047
|
+
...scripts,
|
|
58048
|
+
build: withSyncContentPrefix(scripts.build),
|
|
58049
|
+
"check-types": withSyncContentPrefix(scripts["check-types"]),
|
|
58050
|
+
"types:check": withSyncContentPrefix(scripts["types:check"])
|
|
58051
|
+
};
|
|
58052
|
+
const changed = Object.entries(nextScripts).some(([key, value6]) => scripts[key] !== value6);
|
|
58053
|
+
if (!changed)
|
|
58054
|
+
return null;
|
|
58055
|
+
writeFileSync5(packagePath, JSON.stringify({
|
|
58056
|
+
...packageJson,
|
|
58057
|
+
scripts: nextScripts
|
|
58058
|
+
}, null, 2) + `
|
|
58059
|
+
`);
|
|
58060
|
+
return relativePosixPath2(outputDirectory, packagePath);
|
|
58061
|
+
};
|
|
58062
|
+
var hasFlatRoutePage = (directoryPath) => existsSync6(`${directoryPath}.md`) || existsSync6(`${directoryPath}.mdx`);
|
|
58063
|
+
var isNestedRouteSeedBlockedByFlatPage = ({
|
|
58064
|
+
wikiDirectory,
|
|
58065
|
+
filePath
|
|
58066
|
+
}) => {
|
|
58067
|
+
const normalized = filePath.split(path12.sep).join(path12.posix.sep);
|
|
58068
|
+
const match19 = normalized.match(/^content\/docs\/project\/([^/]+)\/(?:index\.mdx|meta\.json)$/);
|
|
58069
|
+
if (!match19)
|
|
58070
|
+
return false;
|
|
58071
|
+
return hasFlatRoutePage(path12.join(wikiDirectory, "content", "docs", "project", match19[1]));
|
|
58072
|
+
};
|
|
57601
58073
|
var scaffoldWiki = ({
|
|
57602
58074
|
outputDirectory,
|
|
57603
58075
|
wikiRoot,
|
|
@@ -57605,41 +58077,58 @@ var scaffoldWiki = ({
|
|
|
57605
58077
|
}) => {
|
|
57606
58078
|
const template = makeWikiScaffoldTemplate(wikiRoot);
|
|
57607
58079
|
const createdFiles = [];
|
|
57608
|
-
const wikiDirectory =
|
|
58080
|
+
const wikiDirectory = path12.join(outputDirectory, targetRoot);
|
|
57609
58081
|
for (const directory3 of template.topLevelDirectories) {
|
|
57610
|
-
mkdirSync4(
|
|
58082
|
+
mkdirSync4(path12.join(wikiDirectory, directory3), { recursive: true });
|
|
57611
58083
|
}
|
|
57612
58084
|
for (const rawSubdirectory of template.rawSubdirectories) {
|
|
57613
|
-
mkdirSync4(
|
|
58085
|
+
mkdirSync4(path12.join(wikiDirectory, "raw", rawSubdirectory), {
|
|
57614
58086
|
recursive: true
|
|
57615
58087
|
});
|
|
57616
|
-
const keepFile =
|
|
58088
|
+
const keepFile = path12.join(wikiDirectory, "raw", rawSubdirectory, ".gitkeep");
|
|
57617
58089
|
const createdFile = writeMissingFile({ outputDirectory, targetPath: keepFile, content: "" });
|
|
57618
58090
|
if (createdFile !== null) {
|
|
57619
58091
|
createdFiles.push(createdFile);
|
|
57620
58092
|
}
|
|
57621
58093
|
}
|
|
57622
58094
|
const directoryKeepFiles = [
|
|
57623
|
-
|
|
57624
|
-
|
|
58095
|
+
path12.join(wikiDirectory, "content", "docs", "project", ".gitkeep"),
|
|
58096
|
+
path12.join(wikiDirectory, "specs", ".gitkeep")
|
|
57625
58097
|
];
|
|
57626
58098
|
for (const keepFile of directoryKeepFiles) {
|
|
58099
|
+
if (directoryHasEntries(path12.dirname(keepFile))) {
|
|
58100
|
+
continue;
|
|
58101
|
+
}
|
|
57627
58102
|
const createdFile = writeMissingFile({ outputDirectory, targetPath: keepFile, content: "" });
|
|
57628
58103
|
if (createdFile !== null) {
|
|
57629
58104
|
createdFiles.push(createdFile);
|
|
57630
58105
|
}
|
|
57631
58106
|
}
|
|
57632
58107
|
for (const file6 of template.files) {
|
|
57633
|
-
|
|
58108
|
+
if (isNestedRouteSeedBlockedByFlatPage({
|
|
58109
|
+
wikiDirectory,
|
|
58110
|
+
filePath: file6.path
|
|
58111
|
+
})) {
|
|
58112
|
+
continue;
|
|
58113
|
+
}
|
|
58114
|
+
const writeFile3 = file6.path === "scripts/sync-content.mjs" ? writeManagedFile : writeMissingFile;
|
|
58115
|
+
const createdFile = writeFile3({
|
|
57634
58116
|
outputDirectory,
|
|
57635
|
-
targetPath:
|
|
58117
|
+
targetPath: path12.join(wikiDirectory, file6.path),
|
|
57636
58118
|
content: file6.content
|
|
57637
58119
|
});
|
|
57638
58120
|
if (createdFile !== null) {
|
|
57639
58121
|
createdFiles.push(createdFile);
|
|
57640
58122
|
}
|
|
57641
58123
|
}
|
|
57642
|
-
const
|
|
58124
|
+
const updatedPackageFile = updateExistingWikiPackage({
|
|
58125
|
+
outputDirectory,
|
|
58126
|
+
packagePath: path12.join(wikiDirectory, "package.json")
|
|
58127
|
+
});
|
|
58128
|
+
if (updatedPackageFile !== null && !createdFiles.includes(updatedPackageFile)) {
|
|
58129
|
+
createdFiles.push(updatedPackageFile);
|
|
58130
|
+
}
|
|
58131
|
+
const agentsPath = path12.join(wikiDirectory, "AGENTS.md");
|
|
57643
58132
|
const agentsFile = writeMissingFile({
|
|
57644
58133
|
outputDirectory,
|
|
57645
58134
|
targetPath: agentsPath,
|
|
@@ -57648,12 +58137,12 @@ var scaffoldWiki = ({
|
|
|
57648
58137
|
if (agentsFile !== null) {
|
|
57649
58138
|
createdFiles.push(agentsFile);
|
|
57650
58139
|
}
|
|
57651
|
-
const claudePath =
|
|
57652
|
-
if (!
|
|
58140
|
+
const claudePath = path12.join(wikiDirectory, "CLAUDE.md");
|
|
58141
|
+
if (!existsSync6(claudePath)) {
|
|
57653
58142
|
symlinkSync("AGENTS.md", claudePath);
|
|
57654
58143
|
createdFiles.push(relativePosixPath2(outputDirectory, claudePath));
|
|
57655
58144
|
}
|
|
57656
|
-
const indexPath =
|
|
58145
|
+
const indexPath = path12.join(wikiDirectory, "index.md");
|
|
57657
58146
|
const indexFile = writeMissingFile({
|
|
57658
58147
|
outputDirectory,
|
|
57659
58148
|
targetPath: indexPath,
|
|
@@ -57662,7 +58151,7 @@ var scaffoldWiki = ({
|
|
|
57662
58151
|
if (indexFile !== null) {
|
|
57663
58152
|
createdFiles.push(indexFile);
|
|
57664
58153
|
}
|
|
57665
|
-
const logPath =
|
|
58154
|
+
const logPath = path12.join(wikiDirectory, "log.md");
|
|
57666
58155
|
const logFile = writeMissingFile({
|
|
57667
58156
|
outputDirectory,
|
|
57668
58157
|
targetPath: logPath,
|
|
@@ -57673,16 +58162,30 @@ var scaffoldWiki = ({
|
|
|
57673
58162
|
}
|
|
57674
58163
|
return createdFiles.toSorted();
|
|
57675
58164
|
};
|
|
58165
|
+
var scaffoldWikiForDirectory = ({
|
|
58166
|
+
outputDirectory,
|
|
58167
|
+
monorepo
|
|
58168
|
+
}) => {
|
|
58169
|
+
const wikiTarget = stageWikiTarget({
|
|
58170
|
+
outputDirectory,
|
|
58171
|
+
monorepo
|
|
58172
|
+
});
|
|
58173
|
+
return scaffoldWiki({
|
|
58174
|
+
outputDirectory,
|
|
58175
|
+
wikiRoot: wikiTarget.wikiRoot,
|
|
58176
|
+
targetRoot: wikiTarget.targetRoot
|
|
58177
|
+
});
|
|
58178
|
+
};
|
|
57676
58179
|
var isWikiOutputDirectory = (outputDirectory) => {
|
|
57677
|
-
const normalized =
|
|
57678
|
-
return
|
|
58180
|
+
const normalized = path12.resolve(outputDirectory);
|
|
58181
|
+
return path12.basename(normalized) === "wiki";
|
|
57679
58182
|
};
|
|
57680
58183
|
var stageWikiTarget = ({
|
|
57681
58184
|
outputDirectory,
|
|
57682
58185
|
monorepo
|
|
57683
58186
|
}) => {
|
|
57684
58187
|
if (isWikiOutputDirectory(outputDirectory)) {
|
|
57685
|
-
const parent =
|
|
58188
|
+
const parent = path12.basename(path12.dirname(path12.resolve(outputDirectory)));
|
|
57686
58189
|
return {
|
|
57687
58190
|
wikiRoot: parent === "apps" ? "apps/wiki" : "wiki",
|
|
57688
58191
|
targetRoot: "."
|
|
@@ -57701,20 +58204,20 @@ var runStageScaffold = ({
|
|
|
57701
58204
|
}) => exports_Effect.gen(function* () {
|
|
57702
58205
|
const stage = stageScaffoldById[commandId];
|
|
57703
58206
|
const detection = yield* detectRepository(outputDirectory).pipe(exports_Effect.catchAll(() => exports_Effect.succeed(null)));
|
|
57704
|
-
const wikiTarget = stageWikiTarget({
|
|
57705
|
-
outputDirectory,
|
|
57706
|
-
monorepo: detection?.monorepo === true
|
|
57707
|
-
});
|
|
57708
58207
|
const skillFiles = stage.skills.map((skillId) => copySkillDirectory({
|
|
57709
58208
|
outputDirectory,
|
|
57710
58209
|
skillId,
|
|
57711
58210
|
baseline
|
|
57712
58211
|
}));
|
|
58212
|
+
const wikiTarget = stageWikiTarget({
|
|
58213
|
+
outputDirectory,
|
|
58214
|
+
monorepo: detection?.monorepo === true
|
|
58215
|
+
});
|
|
57713
58216
|
const wikiFiles = scaffoldWiki({
|
|
57714
58217
|
outputDirectory,
|
|
57715
|
-
|
|
57716
|
-
targetRoot: wikiTarget.targetRoot
|
|
58218
|
+
...wikiTarget
|
|
57717
58219
|
});
|
|
58220
|
+
removeHarnessDirectoriesFromGitignore(outputDirectory);
|
|
57718
58221
|
const operatorPrompt = stage.renderPrompt({ wikiRoot: wikiTarget.wikiRoot });
|
|
57719
58222
|
yield* prompt4.writeLine(renderScaffoldTitle());
|
|
57720
58223
|
yield* prompt4.writeLine("");
|
|
@@ -57758,7 +58261,7 @@ var refreshBaselineOption = exports_Options.boolean("refresh-baseline").pipe(exp
|
|
|
57758
58261
|
var yesOption = exports_Options.boolean("yes").pipe(exports_Options.withDescription("Run non-interactively and accept the resolved default scaffold selection."));
|
|
57759
58262
|
var stageCommand = (id2, description) => exports_Command.make(id2, { output: outputOption, baseline: baselineOption, refreshBaseline: refreshBaselineOption }, ({ output: output2, baseline, refreshBaseline }) => exports_Effect.scoped(exports_Effect.gen(function* () {
|
|
57760
58263
|
const prompt4 = yield* PromptLive;
|
|
57761
|
-
const outputDirectory =
|
|
58264
|
+
const outputDirectory = path13.resolve(process.cwd(), getOrElse(output2, () => "."));
|
|
57762
58265
|
const resolvedBaseline = yield* exports_Effect.promise(() => resolveBaseline(baselineResolveOptions(baseline, refreshBaseline, outputDirectory)));
|
|
57763
58266
|
yield* runStageScaffold({
|
|
57764
58267
|
commandId: id2,
|
|
@@ -57777,9 +58280,9 @@ var setupCommand = exports_Command.make("setup", {
|
|
|
57777
58280
|
yes: yesOption
|
|
57778
58281
|
}, ({ input: input2, output: output2, json: json2, repoShape, baseline, refreshBaseline, yes }) => exports_Effect.scoped(exports_Effect.gen(function* () {
|
|
57779
58282
|
const prompt4 = yield* PromptLive;
|
|
57780
|
-
const scanDirectory =
|
|
58283
|
+
const scanDirectory = path13.resolve(process.cwd(), getOrElse(input2, () => "."));
|
|
57781
58284
|
const resolvedBaseline = yield* exports_Effect.promise(() => resolveBaseline(baselineResolveOptions(baseline, refreshBaseline, scanDirectory)));
|
|
57782
|
-
const outputDirectory = map2(output2, (value6) =>
|
|
58285
|
+
const outputDirectory = map2(output2, (value6) => path13.resolve(process.cwd(), value6));
|
|
57783
58286
|
const resolvedRepoShape = getOrElse(repoShape, () => "auto");
|
|
57784
58287
|
yield* runScaffold(isSome2(outputDirectory) ? {
|
|
57785
58288
|
scanDirectory,
|
|
@@ -57811,23 +58314,25 @@ var scaffoldCommand = exports_Command.make("scaffold", {}, () => exports_Effect.
|
|
|
57811
58314
|
]));
|
|
57812
58315
|
|
|
57813
58316
|
// src/cli/update-command.ts
|
|
57814
|
-
import
|
|
58317
|
+
import path15 from "path";
|
|
57815
58318
|
|
|
57816
58319
|
// src/update/run.ts
|
|
57817
58320
|
import { createHash as createHash3 } from "crypto";
|
|
58321
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
57818
58322
|
import {
|
|
57819
58323
|
cpSync as cpSync3,
|
|
57820
|
-
existsSync as
|
|
58324
|
+
existsSync as existsSync7,
|
|
57821
58325
|
lstatSync as lstatSync2,
|
|
57822
58326
|
mkdirSync as mkdirSync5,
|
|
57823
58327
|
mkdtempSync as mkdtempSync2,
|
|
57824
|
-
|
|
58328
|
+
readdirSync as readdirSync4,
|
|
58329
|
+
readFileSync as readFileSync8,
|
|
57825
58330
|
readlinkSync as readlinkSync2,
|
|
57826
58331
|
rmSync as rmSync4,
|
|
57827
58332
|
symlinkSync as symlinkSync2
|
|
57828
58333
|
} from "fs";
|
|
57829
58334
|
import { tmpdir as tmpdir3 } from "os";
|
|
57830
|
-
import
|
|
58335
|
+
import path14 from "path";
|
|
57831
58336
|
|
|
57832
58337
|
// ../../node_modules/.bun/diff@9.0.0/node_modules/diff/libesm/diff/base.js
|
|
57833
58338
|
class Diff {
|
|
@@ -57929,16 +58434,16 @@ class Diff {
|
|
|
57929
58434
|
}
|
|
57930
58435
|
}
|
|
57931
58436
|
}
|
|
57932
|
-
addToPath(
|
|
57933
|
-
const last5 =
|
|
58437
|
+
addToPath(path14, added, removed, oldPosInc, options9) {
|
|
58438
|
+
const last5 = path14.lastComponent;
|
|
57934
58439
|
if (last5 && !options9.oneChangePerToken && last5.added === added && last5.removed === removed) {
|
|
57935
58440
|
return {
|
|
57936
|
-
oldPos:
|
|
58441
|
+
oldPos: path14.oldPos + oldPosInc,
|
|
57937
58442
|
lastComponent: { count: last5.count + 1, added, removed, previousComponent: last5.previousComponent }
|
|
57938
58443
|
};
|
|
57939
58444
|
} else {
|
|
57940
58445
|
return {
|
|
57941
|
-
oldPos:
|
|
58446
|
+
oldPos: path14.oldPos + oldPosInc,
|
|
57942
58447
|
lastComponent: { count: 1, added, removed, previousComponent: last5 }
|
|
57943
58448
|
};
|
|
57944
58449
|
}
|
|
@@ -58771,15 +59276,15 @@ var selectedSkills3 = (finalPacks, baseline) => [
|
|
|
58771
59276
|
...new Set(finalPacks.flatMap((packId) => skillsForPack(packId, baseline)))
|
|
58772
59277
|
].toSorted();
|
|
58773
59278
|
var readManifest = (rootDirectory) => {
|
|
58774
|
-
const manifestPath =
|
|
58775
|
-
if (!
|
|
59279
|
+
const manifestPath = path14.join(rootDirectory, scaffoldManifestFile);
|
|
59280
|
+
if (!existsSync7(manifestPath)) {
|
|
58776
59281
|
throw new Error(`Missing ${scaffoldManifestFile}. Run \`punks scaffold setup\` first.`);
|
|
58777
59282
|
}
|
|
58778
|
-
return parseManifest(
|
|
59283
|
+
return parseManifest(readFileSync8(manifestPath, "utf8"));
|
|
58779
59284
|
};
|
|
58780
59285
|
var contentForDiff = (rootDirectory, relativePath) => {
|
|
58781
|
-
const absolutePath =
|
|
58782
|
-
if (!
|
|
59286
|
+
const absolutePath = path14.join(rootDirectory, relativePath);
|
|
59287
|
+
if (!existsSync7(absolutePath)) {
|
|
58783
59288
|
return "";
|
|
58784
59289
|
}
|
|
58785
59290
|
const stat3 = lstatSync2(absolutePath);
|
|
@@ -58787,27 +59292,49 @@ var contentForDiff = (rootDirectory, relativePath) => {
|
|
|
58787
59292
|
return `symlink:${readlinkSync2(absolutePath)}
|
|
58788
59293
|
`;
|
|
58789
59294
|
}
|
|
58790
|
-
return
|
|
59295
|
+
return readFileSync8(absolutePath, "utf8");
|
|
58791
59296
|
};
|
|
58792
59297
|
var hashPath = (rootDirectory, relativePath) => {
|
|
58793
|
-
const absolutePath =
|
|
58794
|
-
if (!
|
|
59298
|
+
const absolutePath = path14.join(rootDirectory, relativePath);
|
|
59299
|
+
if (!existsSync7(absolutePath)) {
|
|
58795
59300
|
return null;
|
|
58796
59301
|
}
|
|
58797
59302
|
const stat3 = lstatSync2(absolutePath);
|
|
58798
|
-
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync2(absolutePath)}` :
|
|
59303
|
+
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync2(absolutePath)}` : readFileSync8(absolutePath);
|
|
58799
59304
|
return hashContent2(content);
|
|
58800
59305
|
};
|
|
59306
|
+
var collectRelativeFiles2 = (rootDirectory, relativeDirectory) => {
|
|
59307
|
+
const absoluteDirectory = path14.join(rootDirectory, relativeDirectory);
|
|
59308
|
+
if (!existsSync7(absoluteDirectory)) {
|
|
59309
|
+
return [];
|
|
59310
|
+
}
|
|
59311
|
+
const files = [];
|
|
59312
|
+
const visit2 = (currentDirectory) => {
|
|
59313
|
+
for (const entry of readdirSync4(currentDirectory, { withFileTypes: true })) {
|
|
59314
|
+
const absolutePath = path14.join(currentDirectory, entry.name);
|
|
59315
|
+
const relativePath = path14.relative(rootDirectory, absolutePath).split(path14.sep).join("/");
|
|
59316
|
+
if (entry.isDirectory()) {
|
|
59317
|
+
visit2(absolutePath);
|
|
59318
|
+
continue;
|
|
59319
|
+
}
|
|
59320
|
+
if (entry.isFile() || entry.isSymbolicLink()) {
|
|
59321
|
+
files.push(relativePath);
|
|
59322
|
+
}
|
|
59323
|
+
}
|
|
59324
|
+
};
|
|
59325
|
+
visit2(absoluteDirectory);
|
|
59326
|
+
return files.toSorted();
|
|
59327
|
+
};
|
|
58801
59328
|
var copyManagedFile = ({
|
|
58802
59329
|
fromDirectory,
|
|
58803
59330
|
toDirectory,
|
|
58804
59331
|
relativePath
|
|
58805
59332
|
}) => {
|
|
58806
|
-
const sourcePath =
|
|
58807
|
-
const targetPath =
|
|
59333
|
+
const sourcePath = path14.join(fromDirectory, relativePath);
|
|
59334
|
+
const targetPath = path14.join(toDirectory, relativePath);
|
|
58808
59335
|
const stat3 = lstatSync2(sourcePath);
|
|
58809
|
-
mkdirSync5(
|
|
58810
|
-
if (
|
|
59336
|
+
mkdirSync5(path14.dirname(targetPath), { recursive: true });
|
|
59337
|
+
if (existsSync7(targetPath)) {
|
|
58811
59338
|
rmSync4(targetPath, { recursive: true, force: true });
|
|
58812
59339
|
}
|
|
58813
59340
|
if (stat3.isSymbolicLink()) {
|
|
@@ -58895,6 +59422,78 @@ var buildChanges = ({
|
|
|
58895
59422
|
];
|
|
58896
59423
|
}).toSorted((left3, right3) => left3.path.localeCompare(right3.path));
|
|
58897
59424
|
};
|
|
59425
|
+
var copyIfExists = ({
|
|
59426
|
+
rootDirectory,
|
|
59427
|
+
targetDirectory,
|
|
59428
|
+
relativePath
|
|
59429
|
+
}) => {
|
|
59430
|
+
const sourcePath = path14.join(rootDirectory, relativePath);
|
|
59431
|
+
if (!existsSync7(sourcePath))
|
|
59432
|
+
return;
|
|
59433
|
+
const targetPath = path14.join(targetDirectory, relativePath);
|
|
59434
|
+
mkdirSync5(path14.dirname(targetPath), { recursive: true });
|
|
59435
|
+
cpSync3(sourcePath, targetPath, { recursive: true });
|
|
59436
|
+
};
|
|
59437
|
+
var buildWikiAlignment = ({
|
|
59438
|
+
rootDirectory,
|
|
59439
|
+
detection
|
|
59440
|
+
}) => {
|
|
59441
|
+
const expectedDirectory = mkdtempSync2(path14.join(tmpdir3(), "punks-wiki-update-"));
|
|
59442
|
+
const wikiRoot = detection.monorepo ? "apps/wiki" : "wiki";
|
|
59443
|
+
copyIfExists({ rootDirectory, targetDirectory: expectedDirectory, relativePath: wikiRoot });
|
|
59444
|
+
copyIfExists({ rootDirectory, targetDirectory: expectedDirectory, relativePath: "docs" });
|
|
59445
|
+
scaffoldWikiForDirectory({
|
|
59446
|
+
outputDirectory: expectedDirectory,
|
|
59447
|
+
monorepo: detection.monorepo
|
|
59448
|
+
});
|
|
59449
|
+
const syncScript = path14.join(expectedDirectory, wikiRoot, "scripts", "sync-content.mjs");
|
|
59450
|
+
if (existsSync7(syncScript)) {
|
|
59451
|
+
execFileSync7(process.execPath, [syncScript], {
|
|
59452
|
+
cwd: expectedDirectory,
|
|
59453
|
+
stdio: "ignore"
|
|
59454
|
+
});
|
|
59455
|
+
}
|
|
59456
|
+
const expectedFiles = collectRelativeFiles2(expectedDirectory, wikiRoot).map((relativePath) => ({
|
|
59457
|
+
path: relativePath,
|
|
59458
|
+
sha256: hashPath(expectedDirectory, relativePath) ?? "",
|
|
59459
|
+
kind: "harness"
|
|
59460
|
+
}));
|
|
59461
|
+
return {
|
|
59462
|
+
expectedDirectory,
|
|
59463
|
+
changes: buildChanges({
|
|
59464
|
+
rootDirectory,
|
|
59465
|
+
expectedDirectory,
|
|
59466
|
+
expectedFiles,
|
|
59467
|
+
previousFiles: []
|
|
59468
|
+
})
|
|
59469
|
+
};
|
|
59470
|
+
};
|
|
59471
|
+
var buildGitignoreCleanup = ({
|
|
59472
|
+
rootDirectory,
|
|
59473
|
+
expectedDirectory
|
|
59474
|
+
}) => {
|
|
59475
|
+
const relativePath = ".gitignore";
|
|
59476
|
+
if (!existsSync7(path14.join(rootDirectory, relativePath))) {
|
|
59477
|
+
return [];
|
|
59478
|
+
}
|
|
59479
|
+
copyManagedFile({ fromDirectory: rootDirectory, toDirectory: expectedDirectory, relativePath });
|
|
59480
|
+
const cleanup = removeHarnessDirectoriesFromGitignore(expectedDirectory);
|
|
59481
|
+
if (cleanup.removedPatterns.length === 0) {
|
|
59482
|
+
return [];
|
|
59483
|
+
}
|
|
59484
|
+
return buildChanges({
|
|
59485
|
+
rootDirectory,
|
|
59486
|
+
expectedDirectory,
|
|
59487
|
+
expectedFiles: [
|
|
59488
|
+
{
|
|
59489
|
+
path: relativePath,
|
|
59490
|
+
sha256: hashPath(expectedDirectory, relativePath) ?? "",
|
|
59491
|
+
kind: "harness"
|
|
59492
|
+
}
|
|
59493
|
+
],
|
|
59494
|
+
previousFiles: []
|
|
59495
|
+
});
|
|
59496
|
+
};
|
|
58898
59497
|
var runUpdate = ({
|
|
58899
59498
|
rootDirectory,
|
|
58900
59499
|
prompt: prompt4,
|
|
@@ -58903,7 +59502,8 @@ var runUpdate = ({
|
|
|
58903
59502
|
yes = false,
|
|
58904
59503
|
emitJson = false,
|
|
58905
59504
|
ensureTools = true,
|
|
58906
|
-
baseline = bundledBaseline
|
|
59505
|
+
baseline = bundledBaseline,
|
|
59506
|
+
toolRuntime
|
|
58907
59507
|
}) => exports_Effect.gen(function* () {
|
|
58908
59508
|
const manifest = yield* exports_Effect.try({
|
|
58909
59509
|
try: () => readManifest(rootDirectory),
|
|
@@ -58926,7 +59526,7 @@ var runUpdate = ({
|
|
|
58926
59526
|
const baselineDrift = typeof manifestBaseline?.version === "string" && manifestBaseline.version !== baseline.summary.version;
|
|
58927
59527
|
const resolvedPacks = resolved.preselectedPacks;
|
|
58928
59528
|
const packDrift = !comparePacks(finalPacks, resolvedPacks);
|
|
58929
|
-
const expectedDirectory = mkdtempSync2(
|
|
59529
|
+
const expectedDirectory = mkdtempSync2(path14.join(tmpdir3(), "punks-update-"));
|
|
58930
59530
|
const expected = yield* writeScaffoldOutput({
|
|
58931
59531
|
scanDirectory: rootDirectory,
|
|
58932
59532
|
detection,
|
|
@@ -58944,9 +59544,18 @@ var runUpdate = ({
|
|
|
58944
59544
|
expectedFiles: expected.managedFiles,
|
|
58945
59545
|
previousFiles
|
|
58946
59546
|
});
|
|
59547
|
+
const gitignoreChanges = buildGitignoreCleanup({
|
|
59548
|
+
rootDirectory,
|
|
59549
|
+
expectedDirectory
|
|
59550
|
+
});
|
|
59551
|
+
const wikiAlignment = buildWikiAlignment({
|
|
59552
|
+
rootDirectory,
|
|
59553
|
+
detection
|
|
59554
|
+
});
|
|
59555
|
+
const allChanges = [...changes2, ...gitignoreChanges, ...wikiAlignment.changes].toSorted((left3, right3) => left3.path.localeCompare(right3.path));
|
|
58947
59556
|
const expectedPaths = new Set(expected.managedFiles.map((file6) => file6.path));
|
|
58948
59557
|
const staleFiles = previousFiles.map((file6) => file6.path).filter((file6) => !expectedPaths.has(file6)).toSorted();
|
|
58949
|
-
const hasManagedUpdates =
|
|
59558
|
+
const hasManagedUpdates = allChanges.length > 0 || staleFiles.length > 0;
|
|
58950
59559
|
const needsAttention = hasManagedUpdates || packDrift || baselineDrift;
|
|
58951
59560
|
const driftPrompt = packDrift ? packDriftPrompt({ rootDirectory, finalPacks, resolvedPacks }) : null;
|
|
58952
59561
|
yield* prompt4.writeLine(renderCommandSection("Update Detection", formatDetectionSummary(detection)));
|
|
@@ -58980,17 +59589,17 @@ var runUpdate = ({
|
|
|
58980
59589
|
`)));
|
|
58981
59590
|
}
|
|
58982
59591
|
yield* prompt4.writeLine("");
|
|
58983
|
-
yield* prompt4.writeLine(renderCommandSection("Managed Changes", summarizeChanges(
|
|
59592
|
+
yield* prompt4.writeLine(renderCommandSection("Managed Changes", summarizeChanges(allChanges)));
|
|
58984
59593
|
if (staleFiles.length > 0) {
|
|
58985
59594
|
yield* prompt4.writeLine("");
|
|
58986
59595
|
yield* prompt4.writeLine(renderCommandSection("Stale Managed Files", summarizeStaleFiles(staleFiles)));
|
|
58987
59596
|
}
|
|
58988
|
-
const patchPreview = diffableChanges(
|
|
59597
|
+
const patchPreview = diffableChanges(allChanges);
|
|
58989
59598
|
if (patchPreview.length > 0) {
|
|
58990
59599
|
yield* prompt4.writeLine("");
|
|
58991
59600
|
yield* prompt4.writeLine(renderCommandSection("Diff Preview", [
|
|
58992
59601
|
...patchPreview.map((change) => change.patch),
|
|
58993
|
-
...
|
|
59602
|
+
...allChanges.length > patchPreview.length ? [
|
|
58994
59603
|
`Showing ${patchPreview.length} focused diffs. Full structured details are available with --json.`
|
|
58995
59604
|
] : []
|
|
58996
59605
|
].join(`
|
|
@@ -59003,13 +59612,14 @@ var runUpdate = ({
|
|
|
59003
59612
|
if (requiredTools.length > 0) {
|
|
59004
59613
|
yield* prompt4.writeLine("");
|
|
59005
59614
|
yield* prompt4.writeLine(renderHint(`Ensuring required tools: ${requiredTools.join(", ")}`));
|
|
59006
|
-
toolBootstrapStatuses =
|
|
59007
|
-
|
|
59008
|
-
|
|
59009
|
-
|
|
59010
|
-
|
|
59011
|
-
|
|
59012
|
-
|
|
59615
|
+
toolBootstrapStatuses = ensureToolsInstalledBestEffort(requiredTools, baseline, toolRuntime);
|
|
59616
|
+
yield* prompt4.writeLine(renderCommandSection("Tool bootstrap", toolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${formatToolBootstrapStatus(entry)}`).join(`
|
|
59617
|
+
`)));
|
|
59618
|
+
const failureDetails = formatToolBootstrapFailureDetails(toolBootstrapStatuses);
|
|
59619
|
+
if (failureDetails !== null) {
|
|
59620
|
+
yield* prompt4.writeLine("");
|
|
59621
|
+
yield* prompt4.writeLine(renderCommandSection("Tool Bootstrap Warning", failureDetails));
|
|
59622
|
+
}
|
|
59013
59623
|
}
|
|
59014
59624
|
}
|
|
59015
59625
|
if (shouldApply) {
|
|
@@ -59020,9 +59630,24 @@ var runUpdate = ({
|
|
|
59020
59630
|
relativePath: change.path
|
|
59021
59631
|
});
|
|
59022
59632
|
}
|
|
59633
|
+
for (const change of gitignoreChanges) {
|
|
59634
|
+
copyManagedFile({
|
|
59635
|
+
fromDirectory: expectedDirectory,
|
|
59636
|
+
toDirectory: rootDirectory,
|
|
59637
|
+
relativePath: change.path
|
|
59638
|
+
});
|
|
59639
|
+
}
|
|
59640
|
+
for (const change of wikiAlignment.changes) {
|
|
59641
|
+
copyManagedFile({
|
|
59642
|
+
fromDirectory: wikiAlignment.expectedDirectory,
|
|
59643
|
+
toDirectory: rootDirectory,
|
|
59644
|
+
relativePath: change.path
|
|
59645
|
+
});
|
|
59646
|
+
}
|
|
59023
59647
|
for (const staleFile of staleFiles) {
|
|
59024
|
-
rmSync4(
|
|
59648
|
+
rmSync4(path14.join(rootDirectory, staleFile), { recursive: true, force: true });
|
|
59025
59649
|
}
|
|
59650
|
+
removeHarnessDirectoriesFromGitignore(rootDirectory);
|
|
59026
59651
|
}
|
|
59027
59652
|
if (check2 && needsAttention) {
|
|
59028
59653
|
process.exitCode = 1;
|
|
@@ -59034,7 +59659,7 @@ var runUpdate = ({
|
|
|
59034
59659
|
finalPacks,
|
|
59035
59660
|
resolvedPacks,
|
|
59036
59661
|
packDrift,
|
|
59037
|
-
changedFiles:
|
|
59662
|
+
changedFiles: allChanges,
|
|
59038
59663
|
staleFiles,
|
|
59039
59664
|
applied: shouldApply,
|
|
59040
59665
|
checkFailed: check2 && needsAttention,
|
|
@@ -59045,7 +59670,7 @@ var runUpdate = ({
|
|
|
59045
59670
|
yield* prompt4.writeLine("");
|
|
59046
59671
|
yield* prompt4.writeLine(renderCommandSection("Update Complete", [
|
|
59047
59672
|
shouldApply ? "Managed scaffold files updated." : "No files were written.",
|
|
59048
|
-
`Changed files: ${
|
|
59673
|
+
`Changed files: ${allChanges.length}`,
|
|
59049
59674
|
`Stale files: ${staleFiles.length}`,
|
|
59050
59675
|
`Manifests scanned: ${manifestPaths(detection).join(", ") || "\u2205"}`,
|
|
59051
59676
|
"Guidance: keep phase skills out of scoped `AGENTS.md` primary-skill lines; invoke them from the parent goal/handoff flow."
|
|
@@ -59057,6 +59682,7 @@ var runUpdate = ({
|
|
|
59057
59682
|
yield* prompt4.writeLine(encodePrettyJson2(result));
|
|
59058
59683
|
}
|
|
59059
59684
|
rmSync4(expectedDirectory, { recursive: true, force: true });
|
|
59685
|
+
rmSync4(wikiAlignment.expectedDirectory, { recursive: true, force: true });
|
|
59060
59686
|
if (result.applied) {
|
|
59061
59687
|
yield* submitCliEventEffect("cli.scaffold.update.applied", {
|
|
59062
59688
|
cwd: rootDirectory,
|
|
@@ -59086,7 +59712,7 @@ var updateCommand = exports_Command.make("update", {
|
|
|
59086
59712
|
refreshBaseline: refreshBaselineOption2
|
|
59087
59713
|
}, ({ input: input2, check: check2, write: write4, yes, json: json2, baseline, refreshBaseline }) => exports_Effect.scoped(exports_Effect.gen(function* () {
|
|
59088
59714
|
const prompt4 = yield* PromptLive;
|
|
59089
|
-
const rootDirectory =
|
|
59715
|
+
const rootDirectory = path15.resolve(process.cwd(), getOrElse(input2, () => "."));
|
|
59090
59716
|
const resolvedBaseline = yield* exports_Effect.promise(() => resolveBaseline(baselineResolveOptions(baseline, refreshBaseline, rootDirectory)));
|
|
59091
59717
|
yield* runUpdate({
|
|
59092
59718
|
rootDirectory,
|
|
@@ -59277,6 +59903,19 @@ var minimumReleaseAgeEnvironmentForPackageManager = (packageManager) => {
|
|
|
59277
59903
|
return {};
|
|
59278
59904
|
}
|
|
59279
59905
|
};
|
|
59906
|
+
var runCliInstallCommand = ({
|
|
59907
|
+
command,
|
|
59908
|
+
environment: environment2
|
|
59909
|
+
}) => {
|
|
59910
|
+
const result = spawnSync(command[0], command.slice(1), {
|
|
59911
|
+
env: {
|
|
59912
|
+
...process.env,
|
|
59913
|
+
...environment2
|
|
59914
|
+
},
|
|
59915
|
+
stdio: "inherit"
|
|
59916
|
+
});
|
|
59917
|
+
return result.status === 0;
|
|
59918
|
+
};
|
|
59280
59919
|
var autoUpdateCliIfStale = async ({
|
|
59281
59920
|
currentVersion,
|
|
59282
59921
|
packageName,
|
|
@@ -59344,14 +59983,7 @@ var upgradeCli = async ({
|
|
|
59344
59983
|
tag: tag6
|
|
59345
59984
|
});
|
|
59346
59985
|
const environment2 = minimumReleaseAgeEnvironmentForPackageManager(packageManager);
|
|
59347
|
-
|
|
59348
|
-
env: {
|
|
59349
|
-
...process.env,
|
|
59350
|
-
...environment2
|
|
59351
|
-
},
|
|
59352
|
-
stdio: "inherit"
|
|
59353
|
-
});
|
|
59354
|
-
if (result.status === 0) {
|
|
59986
|
+
if (runCliInstallCommand({ command, environment: environment2 })) {
|
|
59355
59987
|
return {
|
|
59356
59988
|
status: "upgraded",
|
|
59357
59989
|
check: check2,
|
|
@@ -59512,7 +60144,7 @@ var startupCheckWorkerEnv = "DP_STARTUP_CHECK_WORKER";
|
|
|
59512
60144
|
var startupCheckCliEnv = "DP_STARTUP_CHECK_CLI";
|
|
59513
60145
|
var startupCheckSkillEnv = "DP_STARTUP_CHECK_SKILL";
|
|
59514
60146
|
var startupCheckIntervalMs = Number.parseInt(process.env.DP_STARTUP_CHECK_INTERVAL_MS ?? String(12 * 60 * 60 * 1000), 10);
|
|
59515
|
-
var startupCheckCacheFile =
|
|
60147
|
+
var startupCheckCacheFile = path16.join(homedir3(), ".cache", "punks", "startup-check.json");
|
|
59516
60148
|
var app = exports_Command.make("punks", {}, () => exports_Effect.sync(() => console.log(renderCommandGuide()))).pipe(exports_Command.withDescription("Harness Intelligence CLI. Agents: activate $dp-cli before acting on generated .devpunks output."), exports_Command.withSubcommands([reportCommand, scaffoldCommand, updateCommand, upgradeCommand]));
|
|
59517
60149
|
var cli = exports_Command.run(app, {
|
|
59518
60150
|
name: "punks",
|
|
@@ -59520,6 +60152,72 @@ var cli = exports_Command.run(app, {
|
|
|
59520
60152
|
});
|
|
59521
60153
|
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;
|
|
59522
60154
|
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;
|
|
60155
|
+
var shouldAskForSelfUpdate = () => shouldCheckSelfUpdate() && process.argv.slice(2).includes("upgrade") === false && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
60156
|
+
var formatCommand2 = ({
|
|
60157
|
+
command,
|
|
60158
|
+
environment: environment2
|
|
60159
|
+
}) => {
|
|
60160
|
+
const envPrefix = environment2 === undefined ? [] : Object.entries(environment2).map(([key, value6]) => `${key}=${value6}`);
|
|
60161
|
+
return [...envPrefix, ...command].join(" ");
|
|
60162
|
+
};
|
|
60163
|
+
var askYesNo = async (question) => {
|
|
60164
|
+
const readline2 = createInterface3({ input: process.stdin, output: process.stdout });
|
|
60165
|
+
try {
|
|
60166
|
+
const answer = (await readline2.question(renderQuestion(`${question} [y/N]: `))).trim();
|
|
60167
|
+
return answer.toLowerCase() === "y" || answer.toLowerCase() === "yes";
|
|
60168
|
+
} finally {
|
|
60169
|
+
readline2.close();
|
|
60170
|
+
}
|
|
60171
|
+
};
|
|
60172
|
+
var runInteractiveCliUpdate = async () => {
|
|
60173
|
+
if (!shouldAskForSelfUpdate()) {
|
|
60174
|
+
return false;
|
|
60175
|
+
}
|
|
60176
|
+
const result = await autoUpdateCliIfStale({
|
|
60177
|
+
currentVersion: version,
|
|
60178
|
+
packageName: name,
|
|
60179
|
+
tag: process.env.DP_UPDATE_TAG ?? "latest",
|
|
60180
|
+
timeoutMs: 5000
|
|
60181
|
+
});
|
|
60182
|
+
if (result.status === "current" || result.status === "unavailable") {
|
|
60183
|
+
return false;
|
|
60184
|
+
}
|
|
60185
|
+
if (result.check === null) {
|
|
60186
|
+
return false;
|
|
60187
|
+
}
|
|
60188
|
+
if (result.status !== "available") {
|
|
60189
|
+
const command = "command" in result ? result.command : null;
|
|
60190
|
+
console.error(renderSelfUpdateNotice({
|
|
60191
|
+
currentVersion: result.check.currentVersion,
|
|
60192
|
+
latestVersion: result.check.latestVersion,
|
|
60193
|
+
packageName: result.check.packageName,
|
|
60194
|
+
command
|
|
60195
|
+
}));
|
|
60196
|
+
return false;
|
|
60197
|
+
}
|
|
60198
|
+
console.error(renderSelfUpdateNotice({
|
|
60199
|
+
currentVersion: result.check.currentVersion,
|
|
60200
|
+
latestVersion: result.check.latestVersion,
|
|
60201
|
+
packageName: result.check.packageName,
|
|
60202
|
+
command: result.command
|
|
60203
|
+
}));
|
|
60204
|
+
if (!await askYesNo("Update CLI before running this command?")) {
|
|
60205
|
+
return false;
|
|
60206
|
+
}
|
|
60207
|
+
if (runCliInstallCommand({ command: result.command, environment: result.environment })) {
|
|
60208
|
+
console.log(renderCommandSection("CLI upgraded", [
|
|
60209
|
+
`${result.check.packageName} ${result.check.currentVersion} -> ${result.check.latestVersion}`,
|
|
60210
|
+
`Installer: ${result.packageManager}`,
|
|
60211
|
+
`Command: ${formatCommand2(result)}`,
|
|
60212
|
+
"Re-run your command to use the upgraded CLI."
|
|
60213
|
+
].join(`
|
|
60214
|
+
`)));
|
|
60215
|
+
return true;
|
|
60216
|
+
}
|
|
60217
|
+
console.error(renderCommandSection("CLI upgrade failed", `Command failed: ${formatCommand2({ command: result.command })}`));
|
|
60218
|
+
process.exitCode = 1;
|
|
60219
|
+
return true;
|
|
60220
|
+
};
|
|
59523
60221
|
var runCliUpdateCheck = async () => {
|
|
59524
60222
|
const result = await autoUpdateCliIfStale({
|
|
59525
60223
|
currentVersion: version,
|
|
@@ -59560,24 +60258,24 @@ var hasFreshStartupCheck = () => {
|
|
|
59560
60258
|
return false;
|
|
59561
60259
|
}
|
|
59562
60260
|
try {
|
|
59563
|
-
const parsed = JSON.parse(
|
|
60261
|
+
const parsed = JSON.parse(readFileSync9(startupCheckCacheFile, "utf8"));
|
|
59564
60262
|
return typeof parsed.checkedAt === "number" && Date.now() - parsed.checkedAt < startupCheckIntervalMs;
|
|
59565
60263
|
} catch {
|
|
59566
60264
|
return false;
|
|
59567
60265
|
}
|
|
59568
60266
|
};
|
|
59569
60267
|
var markStartupCheckStarted = () => {
|
|
59570
|
-
mkdirSync6(
|
|
59571
|
-
|
|
60268
|
+
mkdirSync6(path16.dirname(startupCheckCacheFile), { recursive: true });
|
|
60269
|
+
writeFileSync6(startupCheckCacheFile, JSON.stringify({ checkedAt: Date.now() }, null, 2));
|
|
59572
60270
|
};
|
|
59573
60271
|
var startBackgroundStartupChecks = () => {
|
|
59574
|
-
const checkCli = shouldCheckSelfUpdate();
|
|
60272
|
+
const checkCli = shouldCheckSelfUpdate() && !shouldAskForSelfUpdate();
|
|
59575
60273
|
const checkSkill = shouldCheckDpCliSkillUpdate();
|
|
59576
60274
|
if (!checkCli && !checkSkill || hasFreshStartupCheck()) {
|
|
59577
60275
|
return;
|
|
59578
60276
|
}
|
|
59579
60277
|
const entrypoint = process.argv[1];
|
|
59580
|
-
if (entrypoint === undefined || !
|
|
60278
|
+
if (entrypoint === undefined || !existsSync8(entrypoint)) {
|
|
59581
60279
|
return;
|
|
59582
60280
|
}
|
|
59583
60281
|
markStartupCheckStarted();
|
|
@@ -59603,7 +60301,12 @@ if (process.env[startupCheckWorkerEnv] === "1") {
|
|
|
59603
60301
|
});
|
|
59604
60302
|
} else {
|
|
59605
60303
|
try {
|
|
59606
|
-
|
|
59607
|
-
|
|
59608
|
-
|
|
60304
|
+
const updated = await runInteractiveCliUpdate();
|
|
60305
|
+
if (!updated) {
|
|
60306
|
+
startBackgroundStartupChecks();
|
|
60307
|
+
cli(process.argv).pipe(exports_Effect.provide(exports_Layer.mergeAll(exports_BunContext.layer)), exports_BunRuntime.runMain);
|
|
60308
|
+
}
|
|
60309
|
+
} catch {
|
|
60310
|
+
cli(process.argv).pipe(exports_Effect.provide(exports_Layer.mergeAll(exports_BunContext.layer)), exports_BunRuntime.runMain);
|
|
60311
|
+
}
|
|
59609
60312
|
}
|