@punks/cli 2.1.3 → 2.1.4
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 +7 -3
- package/dist/index.js +769 -245
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10891,9 +10891,9 @@ 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
10897
|
|
|
10898
10898
|
// ../../node_modules/.bun/effect@3.21.2/node_modules/effect/dist/esm/Array.js
|
|
10899
10899
|
var exports_Array = {};
|
|
@@ -52405,7 +52405,7 @@ var recordProductTelemetryEvent = (options9) => exports_Effect.gen(function* ()
|
|
|
52405
52405
|
|
|
52406
52406
|
// package.json
|
|
52407
52407
|
var name = "@punks/cli";
|
|
52408
|
-
var version = "2.1.
|
|
52408
|
+
var version = "2.1.4";
|
|
52409
52409
|
// src/telemetry/product.ts
|
|
52410
52410
|
var git = (cwd, args2) => {
|
|
52411
52411
|
try {
|
|
@@ -52998,7 +52998,7 @@ var reportCommand = exports_Command.make("report", {
|
|
|
52998
52998
|
})).pipe(exports_Command.withDescription("Create a GitHub issue in the Harness Intelligence repository for maintainer triage."));
|
|
52999
52999
|
|
|
53000
53000
|
// src/cli/scaffold-command.ts
|
|
53001
|
-
import
|
|
53001
|
+
import path13 from "path";
|
|
53002
53002
|
|
|
53003
53003
|
// src/baseline/resolve.ts
|
|
53004
53004
|
import { createHash } from "crypto";
|
|
@@ -54487,9 +54487,9 @@ var PromptLive = exports_Effect.acquireRelease(exports_Effect.sync(() => createI
|
|
|
54487
54487
|
|
|
54488
54488
|
// src/scaffold/run.ts
|
|
54489
54489
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
54490
|
-
import { mkdirSync as mkdirSync3, writeFileSync as
|
|
54490
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
54491
54491
|
import { homedir as homedir2 } from "os";
|
|
54492
|
-
import
|
|
54492
|
+
import path11 from "path";
|
|
54493
54493
|
|
|
54494
54494
|
// src/content/packs.ts
|
|
54495
54495
|
var packContents = packCatalog;
|
|
@@ -54867,7 +54867,155 @@ var hasBackendWorkspaceName = (manifest) => {
|
|
|
54867
54867
|
var hasBackendSurface = (result) => exports_Array.some(result.detectedTechnologies, (technology) => technology === "better-auth" || technology === "drizzle" || technology === "elysia" || technology === "trpc") || result.manifests.some(hasBackendWorkspaceName);
|
|
54868
54868
|
|
|
54869
54869
|
// src/core/format-summary.ts
|
|
54870
|
+
import path8 from "path";
|
|
54871
|
+
|
|
54872
|
+
// src/core/tools.ts
|
|
54873
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
54874
|
+
import { accessSync, constants as constants2 } from "fs";
|
|
54875
|
+
import { homedir } from "os";
|
|
54870
54876
|
import path7 from "path";
|
|
54877
|
+
var commandExistsOnPath = (command, env2 = process.env, platform = process.platform) => {
|
|
54878
|
+
const pathValue = env2.PATH ?? env2.Path;
|
|
54879
|
+
if (pathValue === undefined || pathValue.length === 0) {
|
|
54880
|
+
return false;
|
|
54881
|
+
}
|
|
54882
|
+
const isWindows = platform === "win32";
|
|
54883
|
+
const pathSeparator = isWindows ? ";" : ":";
|
|
54884
|
+
const pathEntries = pathValue.split(pathSeparator).filter((entry) => entry.length > 0);
|
|
54885
|
+
const pathExtensions = isWindows ? (env2.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0) : [""];
|
|
54886
|
+
const commandExtensions = isWindows && path7.extname(command).length === 0 ? pathExtensions : [""];
|
|
54887
|
+
const hasPathSegment = command.includes("/") || command.includes("\\");
|
|
54888
|
+
const candidates = (hasPathSegment ? [""] : pathEntries).flatMap((entry) => commandExtensions.map((extension) => hasPathSegment ? `${command}${extension}` : path7.join(entry, `${command}${extension}`)));
|
|
54889
|
+
return candidates.some((candidate) => {
|
|
54890
|
+
try {
|
|
54891
|
+
accessSync(candidate, isWindows ? constants2.F_OK : constants2.X_OK);
|
|
54892
|
+
return true;
|
|
54893
|
+
} catch {
|
|
54894
|
+
return false;
|
|
54895
|
+
}
|
|
54896
|
+
});
|
|
54897
|
+
};
|
|
54898
|
+
var defaultRuntime3 = {
|
|
54899
|
+
cwd: homedir(),
|
|
54900
|
+
commandExists: commandExistsOnPath,
|
|
54901
|
+
execFile: (command, args2, options9) => {
|
|
54902
|
+
execFileSync4(command, [...args2], {
|
|
54903
|
+
cwd: options9?.cwd,
|
|
54904
|
+
stdio: options9?.stdio ?? "inherit"
|
|
54905
|
+
});
|
|
54906
|
+
}
|
|
54907
|
+
};
|
|
54908
|
+
var detectGlobalPackageManager = (runtime5) => {
|
|
54909
|
+
if (runtime5.commandExists("bun")) {
|
|
54910
|
+
return "bun";
|
|
54911
|
+
}
|
|
54912
|
+
if (runtime5.commandExists("pnpm")) {
|
|
54913
|
+
return "pnpm";
|
|
54914
|
+
}
|
|
54915
|
+
if (runtime5.commandExists("npm")) {
|
|
54916
|
+
return "npm";
|
|
54917
|
+
}
|
|
54918
|
+
return null;
|
|
54919
|
+
};
|
|
54920
|
+
var globalInstallCommandFor = (packageManager, packageName) => {
|
|
54921
|
+
switch (packageManager) {
|
|
54922
|
+
case "bun":
|
|
54923
|
+
return ["bun", "add", "-g", packageName];
|
|
54924
|
+
case "pnpm":
|
|
54925
|
+
return ["pnpm", "add", "-g", packageName];
|
|
54926
|
+
case "npm":
|
|
54927
|
+
return ["npm", "install", "-g", packageName];
|
|
54928
|
+
}
|
|
54929
|
+
};
|
|
54930
|
+
var ensureToolsInstalled = (toolIds, baseline = bundledBaseline, runtime5 = defaultRuntime3) => {
|
|
54931
|
+
const packageManager = detectGlobalPackageManager(runtime5);
|
|
54932
|
+
const statuses = [];
|
|
54933
|
+
const toolCatalogById = Object.fromEntries(baseline.tools.map((tool) => [tool.id, tool]));
|
|
54934
|
+
if (toolIds.length > 0 && packageManager === null) {
|
|
54935
|
+
throw new Error("Cannot install required tools because no supported global package manager was found on PATH. Install Bun, pnpm, or npm first.");
|
|
54936
|
+
}
|
|
54937
|
+
const globalPackageManager = packageManager;
|
|
54938
|
+
const cwd = runtime5.cwd ?? homedir();
|
|
54939
|
+
for (const toolId of toolIds) {
|
|
54940
|
+
const tool = toolCatalogById[toolId];
|
|
54941
|
+
if (tool === undefined) {
|
|
54942
|
+
throw new Error(`Unknown required tool \`${toolId}\` in baseline.`);
|
|
54943
|
+
}
|
|
54944
|
+
const missingPrerequisites = tool.requiredBins.filter((command) => !runtime5.commandExists(command));
|
|
54945
|
+
if (missingPrerequisites.length > 0) {
|
|
54946
|
+
throw new Error(`Cannot install required tool \`${toolId}\` because ${missingPrerequisites.join(", ")} is not available on PATH.`);
|
|
54947
|
+
}
|
|
54948
|
+
const alreadyPresent = runtime5.commandExists(toolId);
|
|
54949
|
+
if (!alreadyPresent) {
|
|
54950
|
+
const [command, ...args2] = globalInstallCommandFor(globalPackageManager, tool.packageName);
|
|
54951
|
+
runtime5.execFile(command, args2, {
|
|
54952
|
+
cwd,
|
|
54953
|
+
stdio: "inherit"
|
|
54954
|
+
});
|
|
54955
|
+
if (!runtime5.commandExists(toolId)) {
|
|
54956
|
+
throw new Error(`Tried to install required tool \`${toolId}\`, but the binary is still not available on PATH afterwards.`);
|
|
54957
|
+
}
|
|
54958
|
+
}
|
|
54959
|
+
for (const [command, ...args2] of tool.ensureCommands) {
|
|
54960
|
+
runtime5.execFile(command, args2, {
|
|
54961
|
+
cwd,
|
|
54962
|
+
stdio: "inherit"
|
|
54963
|
+
});
|
|
54964
|
+
}
|
|
54965
|
+
statuses.push({
|
|
54966
|
+
toolId,
|
|
54967
|
+
status: alreadyPresent ? "already-present" : "installed"
|
|
54968
|
+
});
|
|
54969
|
+
}
|
|
54970
|
+
return statuses;
|
|
54971
|
+
};
|
|
54972
|
+
var errorMessage = (cause3) => cause3 instanceof Error ? cause3.message : String(cause3);
|
|
54973
|
+
var errorStack = (cause3) => cause3 instanceof Error ? cause3.stack ?? cause3.message : String(cause3);
|
|
54974
|
+
var ensureToolsInstalledBestEffort = (toolIds, baseline = bundledBaseline, runtime5 = defaultRuntime3) => toolIds.flatMap((toolId) => {
|
|
54975
|
+
try {
|
|
54976
|
+
return ensureToolsInstalled([toolId], baseline, runtime5);
|
|
54977
|
+
} catch (cause3) {
|
|
54978
|
+
return [
|
|
54979
|
+
{
|
|
54980
|
+
toolId,
|
|
54981
|
+
status: "failed",
|
|
54982
|
+
errorMessage: errorMessage(cause3),
|
|
54983
|
+
errorStack: errorStack(cause3)
|
|
54984
|
+
}
|
|
54985
|
+
];
|
|
54986
|
+
}
|
|
54987
|
+
});
|
|
54988
|
+
var formatToolBootstrapStatus = (entry) => {
|
|
54989
|
+
switch (entry.status) {
|
|
54990
|
+
case "already-present":
|
|
54991
|
+
return "already present";
|
|
54992
|
+
case "installed":
|
|
54993
|
+
return "installed during scaffold";
|
|
54994
|
+
case "failed":
|
|
54995
|
+
return "bootstrap failed";
|
|
54996
|
+
}
|
|
54997
|
+
};
|
|
54998
|
+
var formatToolBootstrapFailureDetails = (statuses) => {
|
|
54999
|
+
const failures2 = statuses.filter((entry) => entry.status === "failed");
|
|
55000
|
+
if (failures2.length === 0)
|
|
55001
|
+
return null;
|
|
55002
|
+
return [
|
|
55003
|
+
"Required tool bootstrap failed, but scaffold/update output can still be written.",
|
|
55004
|
+
"",
|
|
55005
|
+
"Agent recovery prompt:",
|
|
55006
|
+
"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.",
|
|
55007
|
+
"",
|
|
55008
|
+
"Failure stack traces:",
|
|
55009
|
+
...failures2.flatMap((failure) => [
|
|
55010
|
+
"",
|
|
55011
|
+
`--- ${failure.toolId} ---`,
|
|
55012
|
+
failure.errorStack ?? failure.errorMessage ?? "Unknown tool bootstrap failure."
|
|
55013
|
+
])
|
|
55014
|
+
].join(`
|
|
55015
|
+
`);
|
|
55016
|
+
};
|
|
55017
|
+
|
|
55018
|
+
// src/core/format-summary.ts
|
|
54871
55019
|
var formatList = (values4) => values4.length === 0 ? [" \u2205"] : values4.map((value6) => ` \u2022 ${value6}`);
|
|
54872
55020
|
var wrapInlineValues = ({
|
|
54873
55021
|
values: values4,
|
|
@@ -54938,8 +55086,8 @@ var formatDetectionSummary = (detection) => [
|
|
|
54938
55086
|
`cwd: ${detection.cwd}`,
|
|
54939
55087
|
...section("detected languages:", formatList(detection.detectedLanguages)),
|
|
54940
55088
|
...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} (${
|
|
55089
|
+
...section("manifest files:", formatList(detection.manifests.map((manifest) => path8.relative(detection.cwd, manifest.path) || "package.json"))),
|
|
55090
|
+
...section("monorepo signals:", formatList(detection.monorepoSignals.map((signal) => `${signal.type} (${path8.relative(detection.cwd, signal.path) || "."})`)))
|
|
54943
55091
|
].join(`
|
|
54944
55092
|
`);
|
|
54945
55093
|
var formatConfirmationSummary = (result, baseline = bundledBaseline) => [
|
|
@@ -54969,7 +55117,7 @@ var formatConfirmationSummary = (result, baseline = bundledBaseline) => [
|
|
|
54969
55117
|
...maybeSection("hidden output directories:", formatList(result.hiddenOutputDirectories)),
|
|
54970
55118
|
...section("agent handoff file:", formatList([result.agentHandoffFile])),
|
|
54971
55119
|
...section("required tools file:", formatList([result.requiredToolsFile])),
|
|
54972
|
-
...maybeSection("tool bootstrap:", formatList(result.toolBootstrapStatuses.map((entry) => `${entry.toolId}: ${entry
|
|
55120
|
+
...maybeSection("tool bootstrap:", formatList(result.toolBootstrapStatuses.map((entry) => `${entry.toolId}: ${formatToolBootstrapStatus(entry)}`))),
|
|
54973
55121
|
...section("scaffold manifest:", formatList([result.scaffoldManifestFile]))
|
|
54974
55122
|
].join(`
|
|
54975
55123
|
`);
|
|
@@ -54985,9 +55133,15 @@ var formatAgentHandoffSummary = (result) => [
|
|
|
54985
55133
|
"",
|
|
54986
55134
|
...result.toolBootstrapStatuses.length === 0 ? [] : [
|
|
54987
55135
|
"Tool bootstrap status:",
|
|
54988
|
-
...result.toolBootstrapStatuses.map((entry) => ` \u2022 \`${entry.toolId}\`: ${entry
|
|
55136
|
+
...result.toolBootstrapStatuses.map((entry) => ` \u2022 \`${entry.toolId}\`: ${formatToolBootstrapStatus(entry)}`),
|
|
54989
55137
|
""
|
|
54990
55138
|
],
|
|
55139
|
+
...result.toolBootstrapStatuses.some((entry) => entry.status === "failed") ? [
|
|
55140
|
+
"Tool bootstrap recovery:",
|
|
55141
|
+
" \u2022 Read `.devpunks/required-tools.json` and manually verify every listed tool before deeper repo work.",
|
|
55142
|
+
" \u2022 Repair failed installs outside the scaffold command. For `agent-browser` Chromium failures, rerun `agent-browser install` after fixing the local browser dependency.",
|
|
55143
|
+
""
|
|
55144
|
+
] : [],
|
|
54991
55145
|
"What was scaffolded:",
|
|
54992
55146
|
" \u2022 final scoped/root prompt files were not written yet",
|
|
54993
55147
|
...formatList([
|
|
@@ -55044,6 +55198,47 @@ var formatResolvedPackSummary = (options9) => options9.optionalPacks.length ===
|
|
|
55044
55198
|
].join(`
|
|
55045
55199
|
`);
|
|
55046
55200
|
|
|
55201
|
+
// src/core/gitignore.ts
|
|
55202
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
55203
|
+
import path9 from "path";
|
|
55204
|
+
var harnessDirectories = new Set([".agents", ".claude", ".codex", ".cursor", ".opencode"]);
|
|
55205
|
+
var normalizeGitignorePattern = (line4) => {
|
|
55206
|
+
const trimmed2 = line4.trim();
|
|
55207
|
+
if (trimmed2 === "" || trimmed2.startsWith("#") || trimmed2.startsWith("!")) {
|
|
55208
|
+
return null;
|
|
55209
|
+
}
|
|
55210
|
+
return trimmed2.replace(/^\//, "").replace(/\/\*\*?$/, "").replace(/\/$/, "");
|
|
55211
|
+
};
|
|
55212
|
+
var isHarnessDirectoryIgnore = (line4) => {
|
|
55213
|
+
const normalized = normalizeGitignorePattern(line4);
|
|
55214
|
+
return normalized !== null && harnessDirectories.has(normalized);
|
|
55215
|
+
};
|
|
55216
|
+
var removeHarnessDirectoriesFromGitignore = (rootDirectory) => {
|
|
55217
|
+
const gitignorePath = path9.join(rootDirectory, ".gitignore");
|
|
55218
|
+
if (!existsSync4(gitignorePath)) {
|
|
55219
|
+
return { gitignorePath, removedPatterns: [] };
|
|
55220
|
+
}
|
|
55221
|
+
const original = readFileSync5(gitignorePath, "utf8");
|
|
55222
|
+
const hadFinalNewline = original.endsWith(`
|
|
55223
|
+
`);
|
|
55224
|
+
const removedPatterns = [];
|
|
55225
|
+
const keptLines = original.split(/\r?\n/).filter((line4, index, lines3) => {
|
|
55226
|
+
if (index === lines3.length - 1 && line4 === "")
|
|
55227
|
+
return false;
|
|
55228
|
+
if (!isHarnessDirectoryIgnore(line4))
|
|
55229
|
+
return true;
|
|
55230
|
+
removedPatterns.push(line4.trim());
|
|
55231
|
+
return false;
|
|
55232
|
+
});
|
|
55233
|
+
if (removedPatterns.length === 0) {
|
|
55234
|
+
return { gitignorePath, removedPatterns };
|
|
55235
|
+
}
|
|
55236
|
+
writeFileSync2(gitignorePath, `${keptLines.join(`
|
|
55237
|
+
`)}${hadFinalNewline ? `
|
|
55238
|
+
` : ""}`, "utf8");
|
|
55239
|
+
return { gitignorePath, removedPatterns };
|
|
55240
|
+
};
|
|
55241
|
+
|
|
55047
55242
|
// src/core/pack-registry.ts
|
|
55048
55243
|
var defaultPackIds2 = defaultPackIdsForBaseline();
|
|
55049
55244
|
var detectedPackIds2 = detectedPackIdsForBaseline();
|
|
@@ -55125,122 +55320,21 @@ var finalizePackSelection = (resolved, additions, removals) => {
|
|
|
55125
55320
|
};
|
|
55126
55321
|
var canRemovePack = (resolved, packId) => resolved.preselectedPacks.includes(packId) && !resolved.defaultPacks.includes(packId);
|
|
55127
55322
|
|
|
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
55323
|
// src/scaffold/output.ts
|
|
55230
55324
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
55231
55325
|
import { createHash as createHash2 } from "crypto";
|
|
55232
55326
|
import {
|
|
55233
55327
|
cpSync,
|
|
55234
|
-
existsSync as
|
|
55328
|
+
existsSync as existsSync5,
|
|
55235
55329
|
lstatSync,
|
|
55236
55330
|
mkdirSync as mkdirSync2,
|
|
55237
55331
|
readdirSync as readdirSync2,
|
|
55238
|
-
readFileSync as
|
|
55332
|
+
readFileSync as readFileSync6,
|
|
55239
55333
|
readlinkSync,
|
|
55240
55334
|
rmSync as rmSync2,
|
|
55241
|
-
writeFileSync as
|
|
55335
|
+
writeFileSync as writeFileSync3
|
|
55242
55336
|
} from "fs";
|
|
55243
|
-
import
|
|
55337
|
+
import path10 from "path";
|
|
55244
55338
|
|
|
55245
55339
|
// src/content/prompts.ts
|
|
55246
55340
|
var phaseSkillIds = [
|
|
@@ -55515,7 +55609,10 @@ var renderAgentHandoffMarkdown = ({
|
|
|
55515
55609
|
"- Subagent manifest scaffolding/specs under `.agents/subagents/` and `.devpunks/specs/subagents/`.",
|
|
55516
55610
|
`- Scaffold manifest at \`${scaffoldManifestFile}\`.`,
|
|
55517
55611
|
`- Required tools manifest at \`${requiredToolsFile}\`.`,
|
|
55518
|
-
...toolBootstrapStatuses.map((entry) => `- Tool bootstrap: \`${entry.toolId}\` was ${entry
|
|
55612
|
+
...toolBootstrapStatuses.map((entry) => `- Tool bootstrap: \`${entry.toolId}\` was ${formatToolBootstrapStatus(entry)}.`),
|
|
55613
|
+
...toolBootstrapStatuses.some((entry) => entry.status === "failed") ? [
|
|
55614
|
+
"- 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."
|
|
55615
|
+
] : [],
|
|
55519
55616
|
"",
|
|
55520
55617
|
"## Repo shape",
|
|
55521
55618
|
"",
|
|
@@ -55764,9 +55861,9 @@ var sortSubagentSpecialists = (spec) => ({
|
|
|
55764
55861
|
|
|
55765
55862
|
// src/scaffold/output.ts
|
|
55766
55863
|
var encodeJson = encodeSync(parseJson(Unknown));
|
|
55767
|
-
var toPosixPath = (value6) => value6.split(
|
|
55864
|
+
var toPosixPath = (value6) => value6.split(path10.sep).join("/");
|
|
55768
55865
|
var relativePosixPath = (from, to) => {
|
|
55769
|
-
const relativePath =
|
|
55866
|
+
const relativePath = path10.relative(from, to);
|
|
55770
55867
|
return relativePath === "" ? "." : toPosixPath(relativePath);
|
|
55771
55868
|
};
|
|
55772
55869
|
var specPathForPromptTarget = (relativePath) => {
|
|
@@ -55780,7 +55877,7 @@ var specPathForPromptTarget = (relativePath) => {
|
|
|
55780
55877
|
if (promptTargetPath === "docs/AGENTS.md") {
|
|
55781
55878
|
return ".devpunks/specs/prompts/docs.md";
|
|
55782
55879
|
}
|
|
55783
|
-
return
|
|
55880
|
+
return path10.posix.join(".devpunks/specs/prompts", path10.posix.dirname(promptTargetPath), "prompt.md");
|
|
55784
55881
|
};
|
|
55785
55882
|
var uniqueSorted = (values4) => [...new Set(values4)].toSorted();
|
|
55786
55883
|
var collectOpensrcReferences = (promptSpecs) => uniqueSorted(promptSpecs.flatMap((spec) => spec.opensrcReferences));
|
|
@@ -55789,7 +55886,7 @@ var detectionHasPackage = (detection, packageName) => detection.manifests.some((
|
|
|
55789
55886
|
var selectedSkills = (finalPacks, baseline) => uniqueSorted(finalPacks.flatMap((packId) => skillsForPack(packId, baseline)));
|
|
55790
55887
|
var selectedHookIds = (finalPacks, baseline) => uniqueSorted(finalPacks.flatMap((packId) => hooksForPack(packId, baseline)));
|
|
55791
55888
|
var oxlintConfigCandidates = [".oxlintrc.json", ".oxlintrc.jsonc", "oxlint.config.ts"];
|
|
55792
|
-
var existingOxlintConfigFiles = (scanDirectory) => oxlintConfigCandidates.filter((candidate) =>
|
|
55889
|
+
var existingOxlintConfigFiles = (scanDirectory) => oxlintConfigCandidates.filter((candidate) => existsSync5(path10.join(scanDirectory, candidate)));
|
|
55793
55890
|
var oxlintStarterConfig = {
|
|
55794
55891
|
$schema: "./node_modules/oxlint/configuration_schema.json",
|
|
55795
55892
|
env: {
|
|
@@ -55815,7 +55912,7 @@ var oxlintStarterConfig = {
|
|
|
55815
55912
|
],
|
|
55816
55913
|
overrides: []
|
|
55817
55914
|
};
|
|
55818
|
-
var detectedWorkspaces = (scanDirectory, detection) => detection.manifests.map((manifest) =>
|
|
55915
|
+
var detectedWorkspaces = (scanDirectory, detection) => detection.manifests.map((manifest) => path10.posix.dirname(relativePosixPath(scanDirectory, manifest.path))).filter((workspace) => workspace !== "" && workspace !== ".").toSorted();
|
|
55819
55916
|
var packsForWorkspace = ({
|
|
55820
55917
|
relativeWorkspacePath,
|
|
55821
55918
|
manifest,
|
|
@@ -55970,9 +56067,9 @@ var buildPromptSpec = ({
|
|
|
55970
56067
|
finalPacks,
|
|
55971
56068
|
baseline
|
|
55972
56069
|
}) => {
|
|
55973
|
-
const sourcePath =
|
|
55974
|
-
const source =
|
|
55975
|
-
const workspacePath = relativePath === ".agents/AGENTS.md" ? ".agents" : relativePath === "AGENTS.md" ? "." : relativePath === "docs/AGENTS.md" ? "docs" :
|
|
56070
|
+
const sourcePath = path10.join(scanDirectory, relativePath);
|
|
56071
|
+
const source = existsSync5(sourcePath) ? "copied" : "generated";
|
|
56072
|
+
const workspacePath = relativePath === ".agents/AGENTS.md" ? ".agents" : relativePath === "AGENTS.md" ? "." : relativePath === "docs/AGENTS.md" ? "docs" : path10.dirname(relativePath);
|
|
55976
56073
|
const packs = packsForWorkspace({
|
|
55977
56074
|
relativeWorkspacePath: workspacePath,
|
|
55978
56075
|
manifest,
|
|
@@ -56040,9 +56137,9 @@ var writeArtifact = ({
|
|
|
56040
56137
|
relativePath,
|
|
56041
56138
|
content
|
|
56042
56139
|
}) => {
|
|
56043
|
-
const absolutePath =
|
|
56044
|
-
mkdirSync2(
|
|
56045
|
-
|
|
56140
|
+
const absolutePath = path10.join(outputDirectory, relativePath);
|
|
56141
|
+
mkdirSync2(path10.dirname(absolutePath), { recursive: true });
|
|
56142
|
+
writeFileSync3(absolutePath, content, "utf8");
|
|
56046
56143
|
return relativePath;
|
|
56047
56144
|
};
|
|
56048
56145
|
var resolvePromptContent = ({
|
|
@@ -56053,9 +56150,9 @@ var resolvePromptContent = ({
|
|
|
56053
56150
|
baseline,
|
|
56054
56151
|
preserveExistingManagedFiles
|
|
56055
56152
|
}) => {
|
|
56056
|
-
const sourcePath =
|
|
56057
|
-
if (preserveExistingManagedFiles &&
|
|
56058
|
-
return
|
|
56153
|
+
const sourcePath = path10.join(scanDirectory, relativePath);
|
|
56154
|
+
if (preserveExistingManagedFiles && existsSync5(sourcePath)) {
|
|
56155
|
+
return readFileSync6(sourcePath, "utf8");
|
|
56059
56156
|
}
|
|
56060
56157
|
if (relativePath === ".agents/AGENTS.md") {
|
|
56061
56158
|
return sharedAgentsPromptTemplate;
|
|
@@ -56067,7 +56164,7 @@ var resolvePromptContent = ({
|
|
|
56067
56164
|
return docsPromptTemplate;
|
|
56068
56165
|
}
|
|
56069
56166
|
if (manifest) {
|
|
56070
|
-
const relativeWorkspacePath =
|
|
56167
|
+
const relativeWorkspacePath = path10.dirname(relativePath);
|
|
56071
56168
|
const packs = packsForWorkspace({
|
|
56072
56169
|
relativeWorkspacePath,
|
|
56073
56170
|
manifest,
|
|
@@ -56088,15 +56185,15 @@ var resolvePromptContent = ({
|
|
|
56088
56185
|
return "";
|
|
56089
56186
|
};
|
|
56090
56187
|
var collectRelativeFiles = (outputDirectory, relativeDirectory) => {
|
|
56091
|
-
const absoluteDirectory =
|
|
56092
|
-
if (!
|
|
56188
|
+
const absoluteDirectory = path10.join(outputDirectory, relativeDirectory);
|
|
56189
|
+
if (!existsSync5(absoluteDirectory)) {
|
|
56093
56190
|
return [];
|
|
56094
56191
|
}
|
|
56095
56192
|
const files = [];
|
|
56096
56193
|
const visit2 = (currentDirectory) => {
|
|
56097
56194
|
for (const entry of readdirSync2(currentDirectory, { withFileTypes: true })) {
|
|
56098
|
-
const absolutePath =
|
|
56099
|
-
const relativePath =
|
|
56195
|
+
const absolutePath = path10.join(currentDirectory, entry.name);
|
|
56196
|
+
const relativePath = path10.relative(outputDirectory, absolutePath).split(path10.sep).join("/");
|
|
56100
56197
|
const stat3 = lstatSync(absolutePath);
|
|
56101
56198
|
if (stat3.isSymbolicLink()) {
|
|
56102
56199
|
files.push(relativePath);
|
|
@@ -56151,8 +56248,8 @@ var managedKindForPath = (relativePath) => {
|
|
|
56151
56248
|
var expandManagedFiles = (outputDirectory, relativePaths) => {
|
|
56152
56249
|
const files = new Set;
|
|
56153
56250
|
for (const relativePath of relativePaths) {
|
|
56154
|
-
const absolutePath =
|
|
56155
|
-
if (!
|
|
56251
|
+
const absolutePath = path10.join(outputDirectory, relativePath);
|
|
56252
|
+
if (!existsSync5(absolutePath)) {
|
|
56156
56253
|
continue;
|
|
56157
56254
|
}
|
|
56158
56255
|
const stat3 = lstatSync(absolutePath);
|
|
@@ -56167,9 +56264,9 @@ var expandManagedFiles = (outputDirectory, relativePaths) => {
|
|
|
56167
56264
|
}
|
|
56168
56265
|
}
|
|
56169
56266
|
return [...files].toSorted().map((relativePath) => {
|
|
56170
|
-
const absolutePath =
|
|
56267
|
+
const absolutePath = path10.join(outputDirectory, relativePath);
|
|
56171
56268
|
const stat3 = lstatSync(absolutePath);
|
|
56172
|
-
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync(absolutePath)}` :
|
|
56269
|
+
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync(absolutePath)}` : readFileSync6(absolutePath);
|
|
56173
56270
|
return {
|
|
56174
56271
|
path: relativePath,
|
|
56175
56272
|
sha256: hashContent(content),
|
|
@@ -56182,7 +56279,7 @@ var promptTargetsForDetection = (scanDirectory, detection) => {
|
|
|
56182
56279
|
{ relativePath: ".agents/AGENTS.md", manifest: null },
|
|
56183
56280
|
{ relativePath: "AGENTS.md", manifest: null }
|
|
56184
56281
|
];
|
|
56185
|
-
if (
|
|
56282
|
+
if (existsSync5(path10.join(scanDirectory, "docs"))) {
|
|
56186
56283
|
targets.push({ relativePath: "docs/AGENTS.md", manifest: null });
|
|
56187
56284
|
}
|
|
56188
56285
|
if (!detection.monorepo) {
|
|
@@ -56194,7 +56291,7 @@ var promptTargetsForDetection = (scanDirectory, detection) => {
|
|
|
56194
56291
|
continue;
|
|
56195
56292
|
}
|
|
56196
56293
|
targets.push({
|
|
56197
|
-
relativePath:
|
|
56294
|
+
relativePath: path10.posix.join(path10.posix.dirname(relativeManifestPath), "AGENTS.md"),
|
|
56198
56295
|
manifest
|
|
56199
56296
|
});
|
|
56200
56297
|
}
|
|
@@ -56310,9 +56407,9 @@ var writeScaffoldOutput = ({
|
|
|
56310
56407
|
}
|
|
56311
56408
|
for (const skillId of finalSkills) {
|
|
56312
56409
|
const sourceDirectory = skillRegistryByIdForBaseline(baseline)[skillId].sourceDirectory;
|
|
56313
|
-
const targetDirectory =
|
|
56314
|
-
const absoluteTargetDirectory =
|
|
56315
|
-
mkdirSync2(
|
|
56410
|
+
const targetDirectory = path10.posix.join(".agents/skills", skillId);
|
|
56411
|
+
const absoluteTargetDirectory = path10.join(outputDirectory, targetDirectory);
|
|
56412
|
+
mkdirSync2(path10.join(outputDirectory, ".agents/skills"), { recursive: true });
|
|
56316
56413
|
rmSync2(absoluteTargetDirectory, { recursive: true, force: true });
|
|
56317
56414
|
cpSync(resolveBaselinePath({
|
|
56318
56415
|
baselineRoot: baseline.root,
|
|
@@ -56350,11 +56447,11 @@ var writeScaffoldOutput = ({
|
|
|
56350
56447
|
content: encodeJson(subagentManifestSpec)
|
|
56351
56448
|
}));
|
|
56352
56449
|
subagentFiles.push(subagentManifestSpec.specFile);
|
|
56353
|
-
const sourceManifestPath =
|
|
56450
|
+
const sourceManifestPath = path10.join(scanDirectory, ".agents/subagents/manifest.mjs");
|
|
56354
56451
|
generatedFiles.push(writeArtifact({
|
|
56355
56452
|
outputDirectory,
|
|
56356
56453
|
relativePath: ".agents/subagents/manifest.mjs",
|
|
56357
|
-
content: shouldPreserveExistingManagedFiles &&
|
|
56454
|
+
content: shouldPreserveExistingManagedFiles && existsSync5(sourceManifestPath) ? readFileSync6(sourceManifestPath, "utf8") : renderSubagentManifestModule({
|
|
56358
56455
|
spec: subagentManifestSpec,
|
|
56359
56456
|
baseline,
|
|
56360
56457
|
fallback: defaultSubagentManifestTemplate
|
|
@@ -56369,7 +56466,7 @@ var writeScaffoldOutput = ({
|
|
|
56369
56466
|
}));
|
|
56370
56467
|
hookFiles.push(hook.outputPath);
|
|
56371
56468
|
}
|
|
56372
|
-
execFileSync5(process.execPath, [
|
|
56469
|
+
execFileSync5(process.execPath, [path10.join(outputDirectory, syncScriptFile)], {
|
|
56373
56470
|
cwd: outputDirectory,
|
|
56374
56471
|
stdio: "ignore"
|
|
56375
56472
|
});
|
|
@@ -56489,9 +56586,9 @@ var writeAgentSystemPrompt = ({
|
|
|
56489
56586
|
outputDirectory,
|
|
56490
56587
|
content
|
|
56491
56588
|
}) => {
|
|
56492
|
-
const absolutePath =
|
|
56493
|
-
mkdirSync3(
|
|
56494
|
-
|
|
56589
|
+
const absolutePath = path11.join(outputDirectory, agentSystemPromptFile);
|
|
56590
|
+
mkdirSync3(path11.dirname(absolutePath), { recursive: true });
|
|
56591
|
+
writeFileSync4(absolutePath, `${content}
|
|
56495
56592
|
`, "utf8");
|
|
56496
56593
|
return agentSystemPromptFile;
|
|
56497
56594
|
};
|
|
@@ -56559,25 +56656,26 @@ var runScaffold = ({
|
|
|
56559
56656
|
outputDirectory,
|
|
56560
56657
|
ensureTools = true,
|
|
56561
56658
|
baseline = bundledBaseline,
|
|
56562
|
-
assumeYes = false
|
|
56659
|
+
assumeYes = false,
|
|
56660
|
+
toolRuntime
|
|
56563
56661
|
}) => exports_Effect.gen(function* () {
|
|
56564
56662
|
const baseRequiredTools = requiredToolsForSkills([], baseline);
|
|
56565
56663
|
let toolBootstrapStatuses = [];
|
|
56566
|
-
const resolvedOutputDirectory =
|
|
56664
|
+
const resolvedOutputDirectory = path11.resolve(outputDirectory ?? scanDirectory);
|
|
56567
56665
|
yield* prompt4.writeLine(renderScaffoldTitle());
|
|
56568
56666
|
yield* prompt4.writeLine("");
|
|
56569
56667
|
yield* prompt4.writeLine(renderSetupIntro());
|
|
56570
56668
|
if (ensureTools && baseRequiredTools.length > 0) {
|
|
56571
56669
|
yield* prompt4.writeLine("");
|
|
56572
56670
|
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(`
|
|
56671
|
+
toolBootstrapStatuses = ensureToolsInstalledBestEffort(baseRequiredTools, baseline, toolRuntime);
|
|
56672
|
+
yield* prompt4.writeLine(renderCommandSection("Base tool check", toolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${formatToolBootstrapStatus(entry)}`).join(`
|
|
56580
56673
|
`)));
|
|
56674
|
+
const failureDetails = formatToolBootstrapFailureDetails(toolBootstrapStatuses);
|
|
56675
|
+
if (failureDetails !== null) {
|
|
56676
|
+
yield* prompt4.writeLine("");
|
|
56677
|
+
yield* prompt4.writeLine(renderCommandSection("Tool Bootstrap Warning", failureDetails));
|
|
56678
|
+
}
|
|
56581
56679
|
}
|
|
56582
56680
|
const detection = applyRepoShapeMode(yield* detectRepository(scanDirectory), repoShapeMode);
|
|
56583
56681
|
const resolved = resolvePackSelection(detection, baseline);
|
|
@@ -56645,18 +56743,18 @@ var runScaffold = ({
|
|
|
56645
56743
|
if (ensureTools && remainingRequiredTools.length > 0) {
|
|
56646
56744
|
yield* prompt4.writeLine("");
|
|
56647
56745
|
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
|
-
});
|
|
56746
|
+
const remainingToolBootstrapStatuses = ensureToolsInstalledBestEffort(remainingRequiredTools, baseline, toolRuntime);
|
|
56654
56747
|
toolBootstrapStatuses = [
|
|
56655
56748
|
...toolBootstrapStatuses,
|
|
56656
56749
|
...remainingToolBootstrapStatuses
|
|
56657
56750
|
].toSorted((left3, right3) => left3.toolId.localeCompare(right3.toolId));
|
|
56658
|
-
yield* prompt4.writeLine(renderCommandSection("Tool bootstrap", remainingToolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${entry
|
|
56751
|
+
yield* prompt4.writeLine(renderCommandSection("Tool bootstrap", remainingToolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${formatToolBootstrapStatus(entry)}`).join(`
|
|
56659
56752
|
`)));
|
|
56753
|
+
const failureDetails = formatToolBootstrapFailureDetails(remainingToolBootstrapStatuses);
|
|
56754
|
+
if (failureDetails !== null) {
|
|
56755
|
+
yield* prompt4.writeLine("");
|
|
56756
|
+
yield* prompt4.writeLine(renderCommandSection("Tool Bootstrap Warning", failureDetails));
|
|
56757
|
+
}
|
|
56660
56758
|
}
|
|
56661
56759
|
const scaffoldOutput = yield* writeScaffoldOutput({
|
|
56662
56760
|
scanDirectory,
|
|
@@ -56667,6 +56765,7 @@ var runScaffold = ({
|
|
|
56667
56765
|
toolBootstrapStatuses,
|
|
56668
56766
|
baseline
|
|
56669
56767
|
});
|
|
56768
|
+
removeHarnessDirectoriesFromGitignore(scaffoldOutput.outputDirectory);
|
|
56670
56769
|
const renderedAgentSystemPrompt = formatAgentHandoffSummary({
|
|
56671
56770
|
cwd: scanDirectory,
|
|
56672
56771
|
repoShapeMode,
|
|
@@ -56787,8 +56886,17 @@ var runScaffold = ({
|
|
|
56787
56886
|
});
|
|
56788
56887
|
|
|
56789
56888
|
// src/scaffold/stage.ts
|
|
56790
|
-
import {
|
|
56791
|
-
|
|
56889
|
+
import {
|
|
56890
|
+
cpSync as cpSync2,
|
|
56891
|
+
existsSync as existsSync6,
|
|
56892
|
+
mkdirSync as mkdirSync4,
|
|
56893
|
+
readFileSync as readFileSync7,
|
|
56894
|
+
readdirSync as readdirSync3,
|
|
56895
|
+
rmSync as rmSync3,
|
|
56896
|
+
symlinkSync,
|
|
56897
|
+
writeFileSync as writeFileSync5
|
|
56898
|
+
} from "fs";
|
|
56899
|
+
import path12 from "path";
|
|
56792
56900
|
|
|
56793
56901
|
// src/content/wiki.ts
|
|
56794
56902
|
var makeWikiScaffoldTemplate = (wikiRoot) => ({
|
|
@@ -56933,9 +57041,9 @@ When processing source material into routed domain knowledge:
|
|
|
56933
57041
|
"version": "0.0.0",
|
|
56934
57042
|
"private": true,
|
|
56935
57043
|
"scripts": {
|
|
56936
|
-
"build": "fumadocs-mdx && next build",
|
|
57044
|
+
"build": "node ./scripts/sync-content.mjs && fumadocs-mdx && next build",
|
|
56937
57045
|
"check": "oxlint . && oxfmt --check .",
|
|
56938
|
-
"check-types": "fumadocs-mdx && next typegen && tsc --noEmit",
|
|
57046
|
+
"check-types": "node ./scripts/sync-content.mjs && fumadocs-mdx && next typegen && tsc --noEmit",
|
|
56939
57047
|
"dev": "next dev --turbopack --port=4000",
|
|
56940
57048
|
"postinstall": "fumadocs-mdx",
|
|
56941
57049
|
"start": "next start"
|
|
@@ -56984,6 +57092,210 @@ const config = {
|
|
|
56984
57092
|
};
|
|
56985
57093
|
|
|
56986
57094
|
export default withMDX(config);
|
|
57095
|
+
`
|
|
57096
|
+
},
|
|
57097
|
+
{
|
|
57098
|
+
path: "scripts/sync-content.mjs",
|
|
57099
|
+
content: `import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
57100
|
+
import path from "node:path";
|
|
57101
|
+
import { fileURLToPath } from "node:url";
|
|
57102
|
+
|
|
57103
|
+
const wikiRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
57104
|
+
const contentRoot = path.join(wikiRoot, "content", "docs");
|
|
57105
|
+
|
|
57106
|
+
const possibleRepoRoots = [
|
|
57107
|
+
path.resolve(wikiRoot, "..", ".."),
|
|
57108
|
+
path.resolve(wikiRoot, ".."),
|
|
57109
|
+
];
|
|
57110
|
+
|
|
57111
|
+
const repoRoot = possibleRepoRoots.find(
|
|
57112
|
+
(candidate) => existsSync(path.join(candidate, "docs")) || existsSync(path.join(candidate, "package.json")),
|
|
57113
|
+
);
|
|
57114
|
+
|
|
57115
|
+
const copiedTopLevelPages = new Set(["project"]);
|
|
57116
|
+
|
|
57117
|
+
syncTree(path.join(wikiRoot, "specs"), path.join(contentRoot, "project", "specs"), "Specs");
|
|
57118
|
+
syncTree(path.join(wikiRoot, "domains"), path.join(contentRoot, "wiki"), "Wiki");
|
|
57119
|
+
|
|
57120
|
+
if (repoRoot) {
|
|
57121
|
+
syncTree(path.join(repoRoot, "docs", "requirements"), path.join(contentRoot, "project", "requirements"), "Requirements");
|
|
57122
|
+
syncTree(path.join(repoRoot, "docs", "reference"), path.join(contentRoot, "project", "reference"), "Reference");
|
|
57123
|
+
syncTree(path.join(repoRoot, "docs", "runbooks"), path.join(contentRoot, "project", "runbooks"), "Runbooks");
|
|
57124
|
+
syncFile(path.join(repoRoot, "docs", "tech-decisions.md"), path.join(contentRoot, "project", "decisions", "tech-decisions.mdx"));
|
|
57125
|
+
}
|
|
57126
|
+
|
|
57127
|
+
mergeMeta(contentRoot, {
|
|
57128
|
+
title: "Project Docs",
|
|
57129
|
+
pages: Array.from(copiedTopLevelPages),
|
|
57130
|
+
});
|
|
57131
|
+
|
|
57132
|
+
mergeMeta(path.join(contentRoot, "project"), {
|
|
57133
|
+
title: "Project",
|
|
57134
|
+
description: "Internal project operations",
|
|
57135
|
+
pages: [
|
|
57136
|
+
"index",
|
|
57137
|
+
"grilling",
|
|
57138
|
+
"specs",
|
|
57139
|
+
"tech-debt",
|
|
57140
|
+
"maintenance",
|
|
57141
|
+
"runbooks",
|
|
57142
|
+
"decisions",
|
|
57143
|
+
"repo-guidance",
|
|
57144
|
+
...(existsSync(path.join(contentRoot, "project", "requirements")) ? ["requirements"] : []),
|
|
57145
|
+
...(existsSync(path.join(contentRoot, "project", "reference")) ? ["reference"] : []),
|
|
57146
|
+
],
|
|
57147
|
+
});
|
|
57148
|
+
|
|
57149
|
+
function syncTree(sourceDirectory, targetDirectory, title) {
|
|
57150
|
+
if (!existsSync(sourceDirectory)) return;
|
|
57151
|
+
|
|
57152
|
+
copyMarkdownTree(sourceDirectory, targetDirectory);
|
|
57153
|
+
writeMetaTree(targetDirectory, title);
|
|
57154
|
+
|
|
57155
|
+
const relativeTarget = path.relative(contentRoot, targetDirectory);
|
|
57156
|
+
const topLevel = relativeTarget.split(path.sep)[0];
|
|
57157
|
+
if (topLevel) copiedTopLevelPages.add(topLevel);
|
|
57158
|
+
}
|
|
57159
|
+
|
|
57160
|
+
function copyMarkdownTree(sourceDirectory, targetDirectory) {
|
|
57161
|
+
for (const entry of readdirSync(sourceDirectory, { withFileTypes: true })) {
|
|
57162
|
+
if (entry.name.startsWith(".")) continue;
|
|
57163
|
+
|
|
57164
|
+
const sourcePath = path.join(sourceDirectory, entry.name);
|
|
57165
|
+
const targetPath = path.join(targetDirectory, entry.name);
|
|
57166
|
+
|
|
57167
|
+
if (entry.isDirectory()) {
|
|
57168
|
+
copyMarkdownTree(sourcePath, targetPath);
|
|
57169
|
+
continue;
|
|
57170
|
+
}
|
|
57171
|
+
|
|
57172
|
+
if (!entry.isFile()) continue;
|
|
57173
|
+
if (!entry.name.endsWith(".md") && !entry.name.endsWith(".mdx")) continue;
|
|
57174
|
+
|
|
57175
|
+
syncFile(sourcePath, targetPath);
|
|
57176
|
+
}
|
|
57177
|
+
}
|
|
57178
|
+
|
|
57179
|
+
function syncFile(sourcePath, targetPath) {
|
|
57180
|
+
if (!existsSync(sourcePath)) return;
|
|
57181
|
+
if (existsSync(targetPath) && hasFrontmatter(readFileSync(targetPath, "utf8"))) return;
|
|
57182
|
+
|
|
57183
|
+
mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
57184
|
+
writeFileSync(targetPath, sanitizeMdx(readFileSync(sourcePath, "utf8"), targetPath));
|
|
57185
|
+
}
|
|
57186
|
+
|
|
57187
|
+
function hasFrontmatter(content) {
|
|
57188
|
+
return content.startsWith("---\\n");
|
|
57189
|
+
}
|
|
57190
|
+
|
|
57191
|
+
function writeMetaTree(directory, title) {
|
|
57192
|
+
if (!existsSync(directory)) return;
|
|
57193
|
+
|
|
57194
|
+
const entries = readdirSync(directory, { withFileTypes: true }).filter((entry) => !entry.name.startsWith("."));
|
|
57195
|
+
const files = entries
|
|
57196
|
+
.filter((entry) => entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".mdx")))
|
|
57197
|
+
.map((entry) => stripMarkdownExtension(entry.name))
|
|
57198
|
+
.filter((name) => name !== "meta");
|
|
57199
|
+
const folders = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
57200
|
+
const pages = orderPages([...files, ...folders]);
|
|
57201
|
+
|
|
57202
|
+
if (pages.length > 0) mergeMeta(directory, { title, pages });
|
|
57203
|
+
|
|
57204
|
+
for (const folder of folders) {
|
|
57205
|
+
writeMetaTree(path.join(directory, folder), titleFromSegment(folder));
|
|
57206
|
+
}
|
|
57207
|
+
}
|
|
57208
|
+
|
|
57209
|
+
function mergeMeta(directory, nextMeta) {
|
|
57210
|
+
mkdirSync(directory, { recursive: true });
|
|
57211
|
+
|
|
57212
|
+
const metaPath = path.join(directory, "meta.json");
|
|
57213
|
+
const existing = readJson(metaPath);
|
|
57214
|
+
const mergedPages = mergePages(existing.pages ?? [], nextMeta.pages);
|
|
57215
|
+
|
|
57216
|
+
writeFileSync(
|
|
57217
|
+
metaPath,
|
|
57218
|
+
formatMetaJson({
|
|
57219
|
+
...nextMeta,
|
|
57220
|
+
...existing,
|
|
57221
|
+
pages: mergedPages,
|
|
57222
|
+
}),
|
|
57223
|
+
);
|
|
57224
|
+
}
|
|
57225
|
+
|
|
57226
|
+
function formatMetaJson(meta) {
|
|
57227
|
+
const lines = Object.entries(meta).map(
|
|
57228
|
+
([key, value]) => " \\"" + key + "\\": " + JSON.stringify(value),
|
|
57229
|
+
);
|
|
57230
|
+
|
|
57231
|
+
return "{\\n" + lines.join(",\\n") + "\\n}\\n";
|
|
57232
|
+
}
|
|
57233
|
+
|
|
57234
|
+
function readJson(filePath) {
|
|
57235
|
+
if (!existsSync(filePath)) return {};
|
|
57236
|
+
|
|
57237
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
57238
|
+
}
|
|
57239
|
+
|
|
57240
|
+
function orderPages(pages) {
|
|
57241
|
+
return mergePages([], pages).sort((left, right) => {
|
|
57242
|
+
if (left === "index") return -1;
|
|
57243
|
+
if (right === "index") return 1;
|
|
57244
|
+
|
|
57245
|
+
return left.localeCompare(right);
|
|
57246
|
+
});
|
|
57247
|
+
}
|
|
57248
|
+
|
|
57249
|
+
function mergePages(existingPages, nextPages) {
|
|
57250
|
+
const existing = Array.isArray(existingPages) ? existingPages : [];
|
|
57251
|
+
const additions = nextPages.filter((page) => !existing.includes(page));
|
|
57252
|
+
const pages = [...existing, ...additions];
|
|
57253
|
+
|
|
57254
|
+
if (!pages.includes("index")) return pages;
|
|
57255
|
+
|
|
57256
|
+
return ["index", ...pages.filter((page) => page !== "index")];
|
|
57257
|
+
}
|
|
57258
|
+
|
|
57259
|
+
function stripMarkdownExtension(fileName) {
|
|
57260
|
+
return fileName.replace(/\\.mdx?$/, "");
|
|
57261
|
+
}
|
|
57262
|
+
|
|
57263
|
+
function titleFromSegment(segment) {
|
|
57264
|
+
return segment
|
|
57265
|
+
.split(/[-_]/)
|
|
57266
|
+
.filter(Boolean)
|
|
57267
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
57268
|
+
.join(" ");
|
|
57269
|
+
}
|
|
57270
|
+
|
|
57271
|
+
function sanitizeMdx(content, targetPath) {
|
|
57272
|
+
const sanitized = content.replace(/<([A-Z_][A-Z0-9_-]*)>/g, "\\\\<$1\\\\>");
|
|
57273
|
+
if (hasFrontmatter(sanitized)) return sanitized;
|
|
57274
|
+
|
|
57275
|
+
return [
|
|
57276
|
+
"---",
|
|
57277
|
+
"title: \\"" + titleFromDocument(sanitized, targetPath) + "\\"",
|
|
57278
|
+
"surface: project",
|
|
57279
|
+
"permission: project",
|
|
57280
|
+
"---",
|
|
57281
|
+
"",
|
|
57282
|
+
sanitized,
|
|
57283
|
+
].join("\\n");
|
|
57284
|
+
}
|
|
57285
|
+
|
|
57286
|
+
function titleFromDocument(content, targetPath) {
|
|
57287
|
+
const heading = content.match(/^#\\s+(.+)$/m)?.[1]?.trim();
|
|
57288
|
+
if (heading) return heading.replace(/"/g, "\\\\\\"");
|
|
57289
|
+
|
|
57290
|
+
return titleFromSegment(stripMarkdownExtension(path.basename(targetPath))).replace(/"/g, "\\\\\\"");
|
|
57291
|
+
}
|
|
57292
|
+
|
|
57293
|
+
if (repoRoot) {
|
|
57294
|
+
const displayedRoot = path.relative(wikiRoot, repoRoot) || ".";
|
|
57295
|
+
console.log(\`Synced wiki content from \${displayedRoot}\`);
|
|
57296
|
+
} else {
|
|
57297
|
+
console.log("No repository root detected; using checked-in wiki content.");
|
|
57298
|
+
}
|
|
56987
57299
|
`
|
|
56988
57300
|
},
|
|
56989
57301
|
{
|
|
@@ -57574,9 +57886,9 @@ var copySkillDirectory = ({
|
|
|
57574
57886
|
baseline
|
|
57575
57887
|
}) => {
|
|
57576
57888
|
const sourceDirectory = skillRegistryByIdForBaseline(baseline)[skillId].sourceDirectory;
|
|
57577
|
-
const targetDirectory =
|
|
57578
|
-
const absoluteTargetDirectory =
|
|
57579
|
-
mkdirSync4(
|
|
57889
|
+
const targetDirectory = path12.posix.join(".agents/skills", skillId);
|
|
57890
|
+
const absoluteTargetDirectory = path12.join(outputDirectory, targetDirectory);
|
|
57891
|
+
mkdirSync4(path12.join(outputDirectory, ".agents/skills"), { recursive: true });
|
|
57580
57892
|
rmSync3(absoluteTargetDirectory, { recursive: true, force: true });
|
|
57581
57893
|
cpSync2(resolveBaselinePath({
|
|
57582
57894
|
baselineRoot: baseline.root,
|
|
@@ -57585,19 +57897,77 @@ var copySkillDirectory = ({
|
|
|
57585
57897
|
}), absoluteTargetDirectory, { recursive: true });
|
|
57586
57898
|
return targetDirectory;
|
|
57587
57899
|
};
|
|
57588
|
-
var relativePosixPath2 = (from, to) =>
|
|
57900
|
+
var relativePosixPath2 = (from, to) => path12.relative(from, to).split(path12.sep).join("/");
|
|
57589
57901
|
var writeMissingFile = ({
|
|
57590
57902
|
outputDirectory,
|
|
57591
57903
|
targetPath,
|
|
57592
57904
|
content
|
|
57593
57905
|
}) => {
|
|
57594
|
-
if (
|
|
57906
|
+
if (existsSync6(targetPath)) {
|
|
57595
57907
|
return null;
|
|
57596
57908
|
}
|
|
57597
|
-
mkdirSync4(
|
|
57598
|
-
|
|
57909
|
+
mkdirSync4(path12.dirname(targetPath), { recursive: true });
|
|
57910
|
+
writeFileSync5(targetPath, content);
|
|
57599
57911
|
return relativePosixPath2(outputDirectory, targetPath);
|
|
57600
57912
|
};
|
|
57913
|
+
var directoryHasEntries = (directoryPath) => existsSync6(directoryPath) && readdirSync3(directoryPath).some((entry) => !entry.startsWith("."));
|
|
57914
|
+
var writeManagedFile = ({
|
|
57915
|
+
outputDirectory,
|
|
57916
|
+
targetPath,
|
|
57917
|
+
content
|
|
57918
|
+
}) => {
|
|
57919
|
+
if (existsSync6(targetPath) && readFileSync7(targetPath, "utf8") === content) {
|
|
57920
|
+
return null;
|
|
57921
|
+
}
|
|
57922
|
+
mkdirSync4(path12.dirname(targetPath), { recursive: true });
|
|
57923
|
+
writeFileSync5(targetPath, content);
|
|
57924
|
+
return relativePosixPath2(outputDirectory, targetPath);
|
|
57925
|
+
};
|
|
57926
|
+
var syncContentPrefix = "node ./scripts/sync-content.mjs && ";
|
|
57927
|
+
var withSyncContentPrefix = (script) => {
|
|
57928
|
+
if (typeof script !== "string")
|
|
57929
|
+
return script;
|
|
57930
|
+
if (script.includes("scripts/sync-content.mjs"))
|
|
57931
|
+
return script;
|
|
57932
|
+
return `${syncContentPrefix}${script}`;
|
|
57933
|
+
};
|
|
57934
|
+
var updateExistingWikiPackage = ({
|
|
57935
|
+
outputDirectory,
|
|
57936
|
+
packagePath
|
|
57937
|
+
}) => {
|
|
57938
|
+
if (!existsSync6(packagePath))
|
|
57939
|
+
return null;
|
|
57940
|
+
const packageJson = JSON.parse(readFileSync7(packagePath, "utf8"));
|
|
57941
|
+
const scripts = packageJson.scripts;
|
|
57942
|
+
if (!scripts)
|
|
57943
|
+
return null;
|
|
57944
|
+
const nextScripts = {
|
|
57945
|
+
...scripts,
|
|
57946
|
+
build: withSyncContentPrefix(scripts.build),
|
|
57947
|
+
"check-types": withSyncContentPrefix(scripts["check-types"]),
|
|
57948
|
+
"types:check": withSyncContentPrefix(scripts["types:check"])
|
|
57949
|
+
};
|
|
57950
|
+
const changed = Object.entries(nextScripts).some(([key, value6]) => scripts[key] !== value6);
|
|
57951
|
+
if (!changed)
|
|
57952
|
+
return null;
|
|
57953
|
+
writeFileSync5(packagePath, JSON.stringify({
|
|
57954
|
+
...packageJson,
|
|
57955
|
+
scripts: nextScripts
|
|
57956
|
+
}, null, 2) + `
|
|
57957
|
+
`);
|
|
57958
|
+
return relativePosixPath2(outputDirectory, packagePath);
|
|
57959
|
+
};
|
|
57960
|
+
var hasFlatRoutePage = (directoryPath) => existsSync6(`${directoryPath}.md`) || existsSync6(`${directoryPath}.mdx`);
|
|
57961
|
+
var isNestedRouteSeedBlockedByFlatPage = ({
|
|
57962
|
+
wikiDirectory,
|
|
57963
|
+
filePath
|
|
57964
|
+
}) => {
|
|
57965
|
+
const normalized = filePath.split(path12.sep).join(path12.posix.sep);
|
|
57966
|
+
const match19 = normalized.match(/^content\/docs\/project\/([^/]+)\/(?:index\.mdx|meta\.json)$/);
|
|
57967
|
+
if (!match19)
|
|
57968
|
+
return false;
|
|
57969
|
+
return hasFlatRoutePage(path12.join(wikiDirectory, "content", "docs", "project", match19[1]));
|
|
57970
|
+
};
|
|
57601
57971
|
var scaffoldWiki = ({
|
|
57602
57972
|
outputDirectory,
|
|
57603
57973
|
wikiRoot,
|
|
@@ -57605,41 +57975,58 @@ var scaffoldWiki = ({
|
|
|
57605
57975
|
}) => {
|
|
57606
57976
|
const template = makeWikiScaffoldTemplate(wikiRoot);
|
|
57607
57977
|
const createdFiles = [];
|
|
57608
|
-
const wikiDirectory =
|
|
57978
|
+
const wikiDirectory = path12.join(outputDirectory, targetRoot);
|
|
57609
57979
|
for (const directory3 of template.topLevelDirectories) {
|
|
57610
|
-
mkdirSync4(
|
|
57980
|
+
mkdirSync4(path12.join(wikiDirectory, directory3), { recursive: true });
|
|
57611
57981
|
}
|
|
57612
57982
|
for (const rawSubdirectory of template.rawSubdirectories) {
|
|
57613
|
-
mkdirSync4(
|
|
57983
|
+
mkdirSync4(path12.join(wikiDirectory, "raw", rawSubdirectory), {
|
|
57614
57984
|
recursive: true
|
|
57615
57985
|
});
|
|
57616
|
-
const keepFile =
|
|
57986
|
+
const keepFile = path12.join(wikiDirectory, "raw", rawSubdirectory, ".gitkeep");
|
|
57617
57987
|
const createdFile = writeMissingFile({ outputDirectory, targetPath: keepFile, content: "" });
|
|
57618
57988
|
if (createdFile !== null) {
|
|
57619
57989
|
createdFiles.push(createdFile);
|
|
57620
57990
|
}
|
|
57621
57991
|
}
|
|
57622
57992
|
const directoryKeepFiles = [
|
|
57623
|
-
|
|
57624
|
-
|
|
57993
|
+
path12.join(wikiDirectory, "content", "docs", "project", ".gitkeep"),
|
|
57994
|
+
path12.join(wikiDirectory, "specs", ".gitkeep")
|
|
57625
57995
|
];
|
|
57626
57996
|
for (const keepFile of directoryKeepFiles) {
|
|
57997
|
+
if (directoryHasEntries(path12.dirname(keepFile))) {
|
|
57998
|
+
continue;
|
|
57999
|
+
}
|
|
57627
58000
|
const createdFile = writeMissingFile({ outputDirectory, targetPath: keepFile, content: "" });
|
|
57628
58001
|
if (createdFile !== null) {
|
|
57629
58002
|
createdFiles.push(createdFile);
|
|
57630
58003
|
}
|
|
57631
58004
|
}
|
|
57632
58005
|
for (const file6 of template.files) {
|
|
57633
|
-
|
|
58006
|
+
if (isNestedRouteSeedBlockedByFlatPage({
|
|
58007
|
+
wikiDirectory,
|
|
58008
|
+
filePath: file6.path
|
|
58009
|
+
})) {
|
|
58010
|
+
continue;
|
|
58011
|
+
}
|
|
58012
|
+
const writeFile3 = file6.path === "scripts/sync-content.mjs" ? writeManagedFile : writeMissingFile;
|
|
58013
|
+
const createdFile = writeFile3({
|
|
57634
58014
|
outputDirectory,
|
|
57635
|
-
targetPath:
|
|
58015
|
+
targetPath: path12.join(wikiDirectory, file6.path),
|
|
57636
58016
|
content: file6.content
|
|
57637
58017
|
});
|
|
57638
58018
|
if (createdFile !== null) {
|
|
57639
58019
|
createdFiles.push(createdFile);
|
|
57640
58020
|
}
|
|
57641
58021
|
}
|
|
57642
|
-
const
|
|
58022
|
+
const updatedPackageFile = updateExistingWikiPackage({
|
|
58023
|
+
outputDirectory,
|
|
58024
|
+
packagePath: path12.join(wikiDirectory, "package.json")
|
|
58025
|
+
});
|
|
58026
|
+
if (updatedPackageFile !== null && !createdFiles.includes(updatedPackageFile)) {
|
|
58027
|
+
createdFiles.push(updatedPackageFile);
|
|
58028
|
+
}
|
|
58029
|
+
const agentsPath = path12.join(wikiDirectory, "AGENTS.md");
|
|
57643
58030
|
const agentsFile = writeMissingFile({
|
|
57644
58031
|
outputDirectory,
|
|
57645
58032
|
targetPath: agentsPath,
|
|
@@ -57648,12 +58035,12 @@ var scaffoldWiki = ({
|
|
|
57648
58035
|
if (agentsFile !== null) {
|
|
57649
58036
|
createdFiles.push(agentsFile);
|
|
57650
58037
|
}
|
|
57651
|
-
const claudePath =
|
|
57652
|
-
if (!
|
|
58038
|
+
const claudePath = path12.join(wikiDirectory, "CLAUDE.md");
|
|
58039
|
+
if (!existsSync6(claudePath)) {
|
|
57653
58040
|
symlinkSync("AGENTS.md", claudePath);
|
|
57654
58041
|
createdFiles.push(relativePosixPath2(outputDirectory, claudePath));
|
|
57655
58042
|
}
|
|
57656
|
-
const indexPath =
|
|
58043
|
+
const indexPath = path12.join(wikiDirectory, "index.md");
|
|
57657
58044
|
const indexFile = writeMissingFile({
|
|
57658
58045
|
outputDirectory,
|
|
57659
58046
|
targetPath: indexPath,
|
|
@@ -57662,7 +58049,7 @@ var scaffoldWiki = ({
|
|
|
57662
58049
|
if (indexFile !== null) {
|
|
57663
58050
|
createdFiles.push(indexFile);
|
|
57664
58051
|
}
|
|
57665
|
-
const logPath =
|
|
58052
|
+
const logPath = path12.join(wikiDirectory, "log.md");
|
|
57666
58053
|
const logFile = writeMissingFile({
|
|
57667
58054
|
outputDirectory,
|
|
57668
58055
|
targetPath: logPath,
|
|
@@ -57673,16 +58060,30 @@ var scaffoldWiki = ({
|
|
|
57673
58060
|
}
|
|
57674
58061
|
return createdFiles.toSorted();
|
|
57675
58062
|
};
|
|
58063
|
+
var scaffoldWikiForDirectory = ({
|
|
58064
|
+
outputDirectory,
|
|
58065
|
+
monorepo
|
|
58066
|
+
}) => {
|
|
58067
|
+
const wikiTarget = stageWikiTarget({
|
|
58068
|
+
outputDirectory,
|
|
58069
|
+
monorepo
|
|
58070
|
+
});
|
|
58071
|
+
return scaffoldWiki({
|
|
58072
|
+
outputDirectory,
|
|
58073
|
+
wikiRoot: wikiTarget.wikiRoot,
|
|
58074
|
+
targetRoot: wikiTarget.targetRoot
|
|
58075
|
+
});
|
|
58076
|
+
};
|
|
57676
58077
|
var isWikiOutputDirectory = (outputDirectory) => {
|
|
57677
|
-
const normalized =
|
|
57678
|
-
return
|
|
58078
|
+
const normalized = path12.resolve(outputDirectory);
|
|
58079
|
+
return path12.basename(normalized) === "wiki";
|
|
57679
58080
|
};
|
|
57680
58081
|
var stageWikiTarget = ({
|
|
57681
58082
|
outputDirectory,
|
|
57682
58083
|
monorepo
|
|
57683
58084
|
}) => {
|
|
57684
58085
|
if (isWikiOutputDirectory(outputDirectory)) {
|
|
57685
|
-
const parent =
|
|
58086
|
+
const parent = path12.basename(path12.dirname(path12.resolve(outputDirectory)));
|
|
57686
58087
|
return {
|
|
57687
58088
|
wikiRoot: parent === "apps" ? "apps/wiki" : "wiki",
|
|
57688
58089
|
targetRoot: "."
|
|
@@ -57701,20 +58102,20 @@ var runStageScaffold = ({
|
|
|
57701
58102
|
}) => exports_Effect.gen(function* () {
|
|
57702
58103
|
const stage = stageScaffoldById[commandId];
|
|
57703
58104
|
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
58105
|
const skillFiles = stage.skills.map((skillId) => copySkillDirectory({
|
|
57709
58106
|
outputDirectory,
|
|
57710
58107
|
skillId,
|
|
57711
58108
|
baseline
|
|
57712
58109
|
}));
|
|
58110
|
+
const wikiTarget = stageWikiTarget({
|
|
58111
|
+
outputDirectory,
|
|
58112
|
+
monorepo: detection?.monorepo === true
|
|
58113
|
+
});
|
|
57713
58114
|
const wikiFiles = scaffoldWiki({
|
|
57714
58115
|
outputDirectory,
|
|
57715
|
-
|
|
57716
|
-
targetRoot: wikiTarget.targetRoot
|
|
58116
|
+
...wikiTarget
|
|
57717
58117
|
});
|
|
58118
|
+
removeHarnessDirectoriesFromGitignore(outputDirectory);
|
|
57718
58119
|
const operatorPrompt = stage.renderPrompt({ wikiRoot: wikiTarget.wikiRoot });
|
|
57719
58120
|
yield* prompt4.writeLine(renderScaffoldTitle());
|
|
57720
58121
|
yield* prompt4.writeLine("");
|
|
@@ -57758,7 +58159,7 @@ var refreshBaselineOption = exports_Options.boolean("refresh-baseline").pipe(exp
|
|
|
57758
58159
|
var yesOption = exports_Options.boolean("yes").pipe(exports_Options.withDescription("Run non-interactively and accept the resolved default scaffold selection."));
|
|
57759
58160
|
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
58161
|
const prompt4 = yield* PromptLive;
|
|
57761
|
-
const outputDirectory =
|
|
58162
|
+
const outputDirectory = path13.resolve(process.cwd(), getOrElse(output2, () => "."));
|
|
57762
58163
|
const resolvedBaseline = yield* exports_Effect.promise(() => resolveBaseline(baselineResolveOptions(baseline, refreshBaseline, outputDirectory)));
|
|
57763
58164
|
yield* runStageScaffold({
|
|
57764
58165
|
commandId: id2,
|
|
@@ -57777,9 +58178,9 @@ var setupCommand = exports_Command.make("setup", {
|
|
|
57777
58178
|
yes: yesOption
|
|
57778
58179
|
}, ({ input: input2, output: output2, json: json2, repoShape, baseline, refreshBaseline, yes }) => exports_Effect.scoped(exports_Effect.gen(function* () {
|
|
57779
58180
|
const prompt4 = yield* PromptLive;
|
|
57780
|
-
const scanDirectory =
|
|
58181
|
+
const scanDirectory = path13.resolve(process.cwd(), getOrElse(input2, () => "."));
|
|
57781
58182
|
const resolvedBaseline = yield* exports_Effect.promise(() => resolveBaseline(baselineResolveOptions(baseline, refreshBaseline, scanDirectory)));
|
|
57782
|
-
const outputDirectory = map2(output2, (value6) =>
|
|
58183
|
+
const outputDirectory = map2(output2, (value6) => path13.resolve(process.cwd(), value6));
|
|
57783
58184
|
const resolvedRepoShape = getOrElse(repoShape, () => "auto");
|
|
57784
58185
|
yield* runScaffold(isSome2(outputDirectory) ? {
|
|
57785
58186
|
scanDirectory,
|
|
@@ -57811,23 +58212,25 @@ var scaffoldCommand = exports_Command.make("scaffold", {}, () => exports_Effect.
|
|
|
57811
58212
|
]));
|
|
57812
58213
|
|
|
57813
58214
|
// src/cli/update-command.ts
|
|
57814
|
-
import
|
|
58215
|
+
import path15 from "path";
|
|
57815
58216
|
|
|
57816
58217
|
// src/update/run.ts
|
|
57817
58218
|
import { createHash as createHash3 } from "crypto";
|
|
58219
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
57818
58220
|
import {
|
|
57819
58221
|
cpSync as cpSync3,
|
|
57820
|
-
existsSync as
|
|
58222
|
+
existsSync as existsSync7,
|
|
57821
58223
|
lstatSync as lstatSync2,
|
|
57822
58224
|
mkdirSync as mkdirSync5,
|
|
57823
58225
|
mkdtempSync as mkdtempSync2,
|
|
57824
|
-
|
|
58226
|
+
readdirSync as readdirSync4,
|
|
58227
|
+
readFileSync as readFileSync8,
|
|
57825
58228
|
readlinkSync as readlinkSync2,
|
|
57826
58229
|
rmSync as rmSync4,
|
|
57827
58230
|
symlinkSync as symlinkSync2
|
|
57828
58231
|
} from "fs";
|
|
57829
58232
|
import { tmpdir as tmpdir3 } from "os";
|
|
57830
|
-
import
|
|
58233
|
+
import path14 from "path";
|
|
57831
58234
|
|
|
57832
58235
|
// ../../node_modules/.bun/diff@9.0.0/node_modules/diff/libesm/diff/base.js
|
|
57833
58236
|
class Diff {
|
|
@@ -57929,16 +58332,16 @@ class Diff {
|
|
|
57929
58332
|
}
|
|
57930
58333
|
}
|
|
57931
58334
|
}
|
|
57932
|
-
addToPath(
|
|
57933
|
-
const last5 =
|
|
58335
|
+
addToPath(path14, added, removed, oldPosInc, options9) {
|
|
58336
|
+
const last5 = path14.lastComponent;
|
|
57934
58337
|
if (last5 && !options9.oneChangePerToken && last5.added === added && last5.removed === removed) {
|
|
57935
58338
|
return {
|
|
57936
|
-
oldPos:
|
|
58339
|
+
oldPos: path14.oldPos + oldPosInc,
|
|
57937
58340
|
lastComponent: { count: last5.count + 1, added, removed, previousComponent: last5.previousComponent }
|
|
57938
58341
|
};
|
|
57939
58342
|
} else {
|
|
57940
58343
|
return {
|
|
57941
|
-
oldPos:
|
|
58344
|
+
oldPos: path14.oldPos + oldPosInc,
|
|
57942
58345
|
lastComponent: { count: 1, added, removed, previousComponent: last5 }
|
|
57943
58346
|
};
|
|
57944
58347
|
}
|
|
@@ -58771,15 +59174,15 @@ var selectedSkills3 = (finalPacks, baseline) => [
|
|
|
58771
59174
|
...new Set(finalPacks.flatMap((packId) => skillsForPack(packId, baseline)))
|
|
58772
59175
|
].toSorted();
|
|
58773
59176
|
var readManifest = (rootDirectory) => {
|
|
58774
|
-
const manifestPath =
|
|
58775
|
-
if (!
|
|
59177
|
+
const manifestPath = path14.join(rootDirectory, scaffoldManifestFile);
|
|
59178
|
+
if (!existsSync7(manifestPath)) {
|
|
58776
59179
|
throw new Error(`Missing ${scaffoldManifestFile}. Run \`punks scaffold setup\` first.`);
|
|
58777
59180
|
}
|
|
58778
|
-
return parseManifest(
|
|
59181
|
+
return parseManifest(readFileSync8(manifestPath, "utf8"));
|
|
58779
59182
|
};
|
|
58780
59183
|
var contentForDiff = (rootDirectory, relativePath) => {
|
|
58781
|
-
const absolutePath =
|
|
58782
|
-
if (!
|
|
59184
|
+
const absolutePath = path14.join(rootDirectory, relativePath);
|
|
59185
|
+
if (!existsSync7(absolutePath)) {
|
|
58783
59186
|
return "";
|
|
58784
59187
|
}
|
|
58785
59188
|
const stat3 = lstatSync2(absolutePath);
|
|
@@ -58787,27 +59190,49 @@ var contentForDiff = (rootDirectory, relativePath) => {
|
|
|
58787
59190
|
return `symlink:${readlinkSync2(absolutePath)}
|
|
58788
59191
|
`;
|
|
58789
59192
|
}
|
|
58790
|
-
return
|
|
59193
|
+
return readFileSync8(absolutePath, "utf8");
|
|
58791
59194
|
};
|
|
58792
59195
|
var hashPath = (rootDirectory, relativePath) => {
|
|
58793
|
-
const absolutePath =
|
|
58794
|
-
if (!
|
|
59196
|
+
const absolutePath = path14.join(rootDirectory, relativePath);
|
|
59197
|
+
if (!existsSync7(absolutePath)) {
|
|
58795
59198
|
return null;
|
|
58796
59199
|
}
|
|
58797
59200
|
const stat3 = lstatSync2(absolutePath);
|
|
58798
|
-
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync2(absolutePath)}` :
|
|
59201
|
+
const content = stat3.isSymbolicLink() ? `symlink:${readlinkSync2(absolutePath)}` : readFileSync8(absolutePath);
|
|
58799
59202
|
return hashContent2(content);
|
|
58800
59203
|
};
|
|
59204
|
+
var collectRelativeFiles2 = (rootDirectory, relativeDirectory) => {
|
|
59205
|
+
const absoluteDirectory = path14.join(rootDirectory, relativeDirectory);
|
|
59206
|
+
if (!existsSync7(absoluteDirectory)) {
|
|
59207
|
+
return [];
|
|
59208
|
+
}
|
|
59209
|
+
const files = [];
|
|
59210
|
+
const visit2 = (currentDirectory) => {
|
|
59211
|
+
for (const entry of readdirSync4(currentDirectory, { withFileTypes: true })) {
|
|
59212
|
+
const absolutePath = path14.join(currentDirectory, entry.name);
|
|
59213
|
+
const relativePath = path14.relative(rootDirectory, absolutePath).split(path14.sep).join("/");
|
|
59214
|
+
if (entry.isDirectory()) {
|
|
59215
|
+
visit2(absolutePath);
|
|
59216
|
+
continue;
|
|
59217
|
+
}
|
|
59218
|
+
if (entry.isFile() || entry.isSymbolicLink()) {
|
|
59219
|
+
files.push(relativePath);
|
|
59220
|
+
}
|
|
59221
|
+
}
|
|
59222
|
+
};
|
|
59223
|
+
visit2(absoluteDirectory);
|
|
59224
|
+
return files.toSorted();
|
|
59225
|
+
};
|
|
58801
59226
|
var copyManagedFile = ({
|
|
58802
59227
|
fromDirectory,
|
|
58803
59228
|
toDirectory,
|
|
58804
59229
|
relativePath
|
|
58805
59230
|
}) => {
|
|
58806
|
-
const sourcePath =
|
|
58807
|
-
const targetPath =
|
|
59231
|
+
const sourcePath = path14.join(fromDirectory, relativePath);
|
|
59232
|
+
const targetPath = path14.join(toDirectory, relativePath);
|
|
58808
59233
|
const stat3 = lstatSync2(sourcePath);
|
|
58809
|
-
mkdirSync5(
|
|
58810
|
-
if (
|
|
59234
|
+
mkdirSync5(path14.dirname(targetPath), { recursive: true });
|
|
59235
|
+
if (existsSync7(targetPath)) {
|
|
58811
59236
|
rmSync4(targetPath, { recursive: true, force: true });
|
|
58812
59237
|
}
|
|
58813
59238
|
if (stat3.isSymbolicLink()) {
|
|
@@ -58895,6 +59320,78 @@ var buildChanges = ({
|
|
|
58895
59320
|
];
|
|
58896
59321
|
}).toSorted((left3, right3) => left3.path.localeCompare(right3.path));
|
|
58897
59322
|
};
|
|
59323
|
+
var copyIfExists = ({
|
|
59324
|
+
rootDirectory,
|
|
59325
|
+
targetDirectory,
|
|
59326
|
+
relativePath
|
|
59327
|
+
}) => {
|
|
59328
|
+
const sourcePath = path14.join(rootDirectory, relativePath);
|
|
59329
|
+
if (!existsSync7(sourcePath))
|
|
59330
|
+
return;
|
|
59331
|
+
const targetPath = path14.join(targetDirectory, relativePath);
|
|
59332
|
+
mkdirSync5(path14.dirname(targetPath), { recursive: true });
|
|
59333
|
+
cpSync3(sourcePath, targetPath, { recursive: true });
|
|
59334
|
+
};
|
|
59335
|
+
var buildWikiAlignment = ({
|
|
59336
|
+
rootDirectory,
|
|
59337
|
+
detection
|
|
59338
|
+
}) => {
|
|
59339
|
+
const expectedDirectory = mkdtempSync2(path14.join(tmpdir3(), "punks-wiki-update-"));
|
|
59340
|
+
const wikiRoot = detection.monorepo ? "apps/wiki" : "wiki";
|
|
59341
|
+
copyIfExists({ rootDirectory, targetDirectory: expectedDirectory, relativePath: wikiRoot });
|
|
59342
|
+
copyIfExists({ rootDirectory, targetDirectory: expectedDirectory, relativePath: "docs" });
|
|
59343
|
+
scaffoldWikiForDirectory({
|
|
59344
|
+
outputDirectory: expectedDirectory,
|
|
59345
|
+
monorepo: detection.monorepo
|
|
59346
|
+
});
|
|
59347
|
+
const syncScript = path14.join(expectedDirectory, wikiRoot, "scripts", "sync-content.mjs");
|
|
59348
|
+
if (existsSync7(syncScript)) {
|
|
59349
|
+
execFileSync7(process.execPath, [syncScript], {
|
|
59350
|
+
cwd: expectedDirectory,
|
|
59351
|
+
stdio: "ignore"
|
|
59352
|
+
});
|
|
59353
|
+
}
|
|
59354
|
+
const expectedFiles = collectRelativeFiles2(expectedDirectory, wikiRoot).map((relativePath) => ({
|
|
59355
|
+
path: relativePath,
|
|
59356
|
+
sha256: hashPath(expectedDirectory, relativePath) ?? "",
|
|
59357
|
+
kind: "harness"
|
|
59358
|
+
}));
|
|
59359
|
+
return {
|
|
59360
|
+
expectedDirectory,
|
|
59361
|
+
changes: buildChanges({
|
|
59362
|
+
rootDirectory,
|
|
59363
|
+
expectedDirectory,
|
|
59364
|
+
expectedFiles,
|
|
59365
|
+
previousFiles: []
|
|
59366
|
+
})
|
|
59367
|
+
};
|
|
59368
|
+
};
|
|
59369
|
+
var buildGitignoreCleanup = ({
|
|
59370
|
+
rootDirectory,
|
|
59371
|
+
expectedDirectory
|
|
59372
|
+
}) => {
|
|
59373
|
+
const relativePath = ".gitignore";
|
|
59374
|
+
if (!existsSync7(path14.join(rootDirectory, relativePath))) {
|
|
59375
|
+
return [];
|
|
59376
|
+
}
|
|
59377
|
+
copyManagedFile({ fromDirectory: rootDirectory, toDirectory: expectedDirectory, relativePath });
|
|
59378
|
+
const cleanup = removeHarnessDirectoriesFromGitignore(expectedDirectory);
|
|
59379
|
+
if (cleanup.removedPatterns.length === 0) {
|
|
59380
|
+
return [];
|
|
59381
|
+
}
|
|
59382
|
+
return buildChanges({
|
|
59383
|
+
rootDirectory,
|
|
59384
|
+
expectedDirectory,
|
|
59385
|
+
expectedFiles: [
|
|
59386
|
+
{
|
|
59387
|
+
path: relativePath,
|
|
59388
|
+
sha256: hashPath(expectedDirectory, relativePath) ?? "",
|
|
59389
|
+
kind: "harness"
|
|
59390
|
+
}
|
|
59391
|
+
],
|
|
59392
|
+
previousFiles: []
|
|
59393
|
+
});
|
|
59394
|
+
};
|
|
58898
59395
|
var runUpdate = ({
|
|
58899
59396
|
rootDirectory,
|
|
58900
59397
|
prompt: prompt4,
|
|
@@ -58903,7 +59400,8 @@ var runUpdate = ({
|
|
|
58903
59400
|
yes = false,
|
|
58904
59401
|
emitJson = false,
|
|
58905
59402
|
ensureTools = true,
|
|
58906
|
-
baseline = bundledBaseline
|
|
59403
|
+
baseline = bundledBaseline,
|
|
59404
|
+
toolRuntime
|
|
58907
59405
|
}) => exports_Effect.gen(function* () {
|
|
58908
59406
|
const manifest = yield* exports_Effect.try({
|
|
58909
59407
|
try: () => readManifest(rootDirectory),
|
|
@@ -58926,7 +59424,7 @@ var runUpdate = ({
|
|
|
58926
59424
|
const baselineDrift = typeof manifestBaseline?.version === "string" && manifestBaseline.version !== baseline.summary.version;
|
|
58927
59425
|
const resolvedPacks = resolved.preselectedPacks;
|
|
58928
59426
|
const packDrift = !comparePacks(finalPacks, resolvedPacks);
|
|
58929
|
-
const expectedDirectory = mkdtempSync2(
|
|
59427
|
+
const expectedDirectory = mkdtempSync2(path14.join(tmpdir3(), "punks-update-"));
|
|
58930
59428
|
const expected = yield* writeScaffoldOutput({
|
|
58931
59429
|
scanDirectory: rootDirectory,
|
|
58932
59430
|
detection,
|
|
@@ -58944,9 +59442,18 @@ var runUpdate = ({
|
|
|
58944
59442
|
expectedFiles: expected.managedFiles,
|
|
58945
59443
|
previousFiles
|
|
58946
59444
|
});
|
|
59445
|
+
const gitignoreChanges = buildGitignoreCleanup({
|
|
59446
|
+
rootDirectory,
|
|
59447
|
+
expectedDirectory
|
|
59448
|
+
});
|
|
59449
|
+
const wikiAlignment = buildWikiAlignment({
|
|
59450
|
+
rootDirectory,
|
|
59451
|
+
detection
|
|
59452
|
+
});
|
|
59453
|
+
const allChanges = [...changes2, ...gitignoreChanges, ...wikiAlignment.changes].toSorted((left3, right3) => left3.path.localeCompare(right3.path));
|
|
58947
59454
|
const expectedPaths = new Set(expected.managedFiles.map((file6) => file6.path));
|
|
58948
59455
|
const staleFiles = previousFiles.map((file6) => file6.path).filter((file6) => !expectedPaths.has(file6)).toSorted();
|
|
58949
|
-
const hasManagedUpdates =
|
|
59456
|
+
const hasManagedUpdates = allChanges.length > 0 || staleFiles.length > 0;
|
|
58950
59457
|
const needsAttention = hasManagedUpdates || packDrift || baselineDrift;
|
|
58951
59458
|
const driftPrompt = packDrift ? packDriftPrompt({ rootDirectory, finalPacks, resolvedPacks }) : null;
|
|
58952
59459
|
yield* prompt4.writeLine(renderCommandSection("Update Detection", formatDetectionSummary(detection)));
|
|
@@ -58980,17 +59487,17 @@ var runUpdate = ({
|
|
|
58980
59487
|
`)));
|
|
58981
59488
|
}
|
|
58982
59489
|
yield* prompt4.writeLine("");
|
|
58983
|
-
yield* prompt4.writeLine(renderCommandSection("Managed Changes", summarizeChanges(
|
|
59490
|
+
yield* prompt4.writeLine(renderCommandSection("Managed Changes", summarizeChanges(allChanges)));
|
|
58984
59491
|
if (staleFiles.length > 0) {
|
|
58985
59492
|
yield* prompt4.writeLine("");
|
|
58986
59493
|
yield* prompt4.writeLine(renderCommandSection("Stale Managed Files", summarizeStaleFiles(staleFiles)));
|
|
58987
59494
|
}
|
|
58988
|
-
const patchPreview = diffableChanges(
|
|
59495
|
+
const patchPreview = diffableChanges(allChanges);
|
|
58989
59496
|
if (patchPreview.length > 0) {
|
|
58990
59497
|
yield* prompt4.writeLine("");
|
|
58991
59498
|
yield* prompt4.writeLine(renderCommandSection("Diff Preview", [
|
|
58992
59499
|
...patchPreview.map((change) => change.patch),
|
|
58993
|
-
...
|
|
59500
|
+
...allChanges.length > patchPreview.length ? [
|
|
58994
59501
|
`Showing ${patchPreview.length} focused diffs. Full structured details are available with --json.`
|
|
58995
59502
|
] : []
|
|
58996
59503
|
].join(`
|
|
@@ -59003,13 +59510,14 @@ var runUpdate = ({
|
|
|
59003
59510
|
if (requiredTools.length > 0) {
|
|
59004
59511
|
yield* prompt4.writeLine("");
|
|
59005
59512
|
yield* prompt4.writeLine(renderHint(`Ensuring required tools: ${requiredTools.join(", ")}`));
|
|
59006
|
-
toolBootstrapStatuses =
|
|
59007
|
-
|
|
59008
|
-
|
|
59009
|
-
|
|
59010
|
-
|
|
59011
|
-
|
|
59012
|
-
|
|
59513
|
+
toolBootstrapStatuses = ensureToolsInstalledBestEffort(requiredTools, baseline, toolRuntime);
|
|
59514
|
+
yield* prompt4.writeLine(renderCommandSection("Tool bootstrap", toolBootstrapStatuses.map((entry) => `\u2022 ${entry.toolId}: ${formatToolBootstrapStatus(entry)}`).join(`
|
|
59515
|
+
`)));
|
|
59516
|
+
const failureDetails = formatToolBootstrapFailureDetails(toolBootstrapStatuses);
|
|
59517
|
+
if (failureDetails !== null) {
|
|
59518
|
+
yield* prompt4.writeLine("");
|
|
59519
|
+
yield* prompt4.writeLine(renderCommandSection("Tool Bootstrap Warning", failureDetails));
|
|
59520
|
+
}
|
|
59013
59521
|
}
|
|
59014
59522
|
}
|
|
59015
59523
|
if (shouldApply) {
|
|
@@ -59020,9 +59528,24 @@ var runUpdate = ({
|
|
|
59020
59528
|
relativePath: change.path
|
|
59021
59529
|
});
|
|
59022
59530
|
}
|
|
59531
|
+
for (const change of gitignoreChanges) {
|
|
59532
|
+
copyManagedFile({
|
|
59533
|
+
fromDirectory: expectedDirectory,
|
|
59534
|
+
toDirectory: rootDirectory,
|
|
59535
|
+
relativePath: change.path
|
|
59536
|
+
});
|
|
59537
|
+
}
|
|
59538
|
+
for (const change of wikiAlignment.changes) {
|
|
59539
|
+
copyManagedFile({
|
|
59540
|
+
fromDirectory: wikiAlignment.expectedDirectory,
|
|
59541
|
+
toDirectory: rootDirectory,
|
|
59542
|
+
relativePath: change.path
|
|
59543
|
+
});
|
|
59544
|
+
}
|
|
59023
59545
|
for (const staleFile of staleFiles) {
|
|
59024
|
-
rmSync4(
|
|
59546
|
+
rmSync4(path14.join(rootDirectory, staleFile), { recursive: true, force: true });
|
|
59025
59547
|
}
|
|
59548
|
+
removeHarnessDirectoriesFromGitignore(rootDirectory);
|
|
59026
59549
|
}
|
|
59027
59550
|
if (check2 && needsAttention) {
|
|
59028
59551
|
process.exitCode = 1;
|
|
@@ -59034,7 +59557,7 @@ var runUpdate = ({
|
|
|
59034
59557
|
finalPacks,
|
|
59035
59558
|
resolvedPacks,
|
|
59036
59559
|
packDrift,
|
|
59037
|
-
changedFiles:
|
|
59560
|
+
changedFiles: allChanges,
|
|
59038
59561
|
staleFiles,
|
|
59039
59562
|
applied: shouldApply,
|
|
59040
59563
|
checkFailed: check2 && needsAttention,
|
|
@@ -59045,7 +59568,7 @@ var runUpdate = ({
|
|
|
59045
59568
|
yield* prompt4.writeLine("");
|
|
59046
59569
|
yield* prompt4.writeLine(renderCommandSection("Update Complete", [
|
|
59047
59570
|
shouldApply ? "Managed scaffold files updated." : "No files were written.",
|
|
59048
|
-
`Changed files: ${
|
|
59571
|
+
`Changed files: ${allChanges.length}`,
|
|
59049
59572
|
`Stale files: ${staleFiles.length}`,
|
|
59050
59573
|
`Manifests scanned: ${manifestPaths(detection).join(", ") || "\u2205"}`,
|
|
59051
59574
|
"Guidance: keep phase skills out of scoped `AGENTS.md` primary-skill lines; invoke them from the parent goal/handoff flow."
|
|
@@ -59057,6 +59580,7 @@ var runUpdate = ({
|
|
|
59057
59580
|
yield* prompt4.writeLine(encodePrettyJson2(result));
|
|
59058
59581
|
}
|
|
59059
59582
|
rmSync4(expectedDirectory, { recursive: true, force: true });
|
|
59583
|
+
rmSync4(wikiAlignment.expectedDirectory, { recursive: true, force: true });
|
|
59060
59584
|
if (result.applied) {
|
|
59061
59585
|
yield* submitCliEventEffect("cli.scaffold.update.applied", {
|
|
59062
59586
|
cwd: rootDirectory,
|
|
@@ -59086,7 +59610,7 @@ var updateCommand = exports_Command.make("update", {
|
|
|
59086
59610
|
refreshBaseline: refreshBaselineOption2
|
|
59087
59611
|
}, ({ input: input2, check: check2, write: write4, yes, json: json2, baseline, refreshBaseline }) => exports_Effect.scoped(exports_Effect.gen(function* () {
|
|
59088
59612
|
const prompt4 = yield* PromptLive;
|
|
59089
|
-
const rootDirectory =
|
|
59613
|
+
const rootDirectory = path15.resolve(process.cwd(), getOrElse(input2, () => "."));
|
|
59090
59614
|
const resolvedBaseline = yield* exports_Effect.promise(() => resolveBaseline(baselineResolveOptions(baseline, refreshBaseline, rootDirectory)));
|
|
59091
59615
|
yield* runUpdate({
|
|
59092
59616
|
rootDirectory,
|
|
@@ -59512,7 +60036,7 @@ var startupCheckWorkerEnv = "DP_STARTUP_CHECK_WORKER";
|
|
|
59512
60036
|
var startupCheckCliEnv = "DP_STARTUP_CHECK_CLI";
|
|
59513
60037
|
var startupCheckSkillEnv = "DP_STARTUP_CHECK_SKILL";
|
|
59514
60038
|
var startupCheckIntervalMs = Number.parseInt(process.env.DP_STARTUP_CHECK_INTERVAL_MS ?? String(12 * 60 * 60 * 1000), 10);
|
|
59515
|
-
var startupCheckCacheFile =
|
|
60039
|
+
var startupCheckCacheFile = path16.join(homedir3(), ".cache", "punks", "startup-check.json");
|
|
59516
60040
|
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
60041
|
var cli = exports_Command.run(app, {
|
|
59518
60042
|
name: "punks",
|
|
@@ -59560,15 +60084,15 @@ var hasFreshStartupCheck = () => {
|
|
|
59560
60084
|
return false;
|
|
59561
60085
|
}
|
|
59562
60086
|
try {
|
|
59563
|
-
const parsed = JSON.parse(
|
|
60087
|
+
const parsed = JSON.parse(readFileSync9(startupCheckCacheFile, "utf8"));
|
|
59564
60088
|
return typeof parsed.checkedAt === "number" && Date.now() - parsed.checkedAt < startupCheckIntervalMs;
|
|
59565
60089
|
} catch {
|
|
59566
60090
|
return false;
|
|
59567
60091
|
}
|
|
59568
60092
|
};
|
|
59569
60093
|
var markStartupCheckStarted = () => {
|
|
59570
|
-
mkdirSync6(
|
|
59571
|
-
|
|
60094
|
+
mkdirSync6(path16.dirname(startupCheckCacheFile), { recursive: true });
|
|
60095
|
+
writeFileSync6(startupCheckCacheFile, JSON.stringify({ checkedAt: Date.now() }, null, 2));
|
|
59572
60096
|
};
|
|
59573
60097
|
var startBackgroundStartupChecks = () => {
|
|
59574
60098
|
const checkCli = shouldCheckSelfUpdate();
|
|
@@ -59577,7 +60101,7 @@ var startBackgroundStartupChecks = () => {
|
|
|
59577
60101
|
return;
|
|
59578
60102
|
}
|
|
59579
60103
|
const entrypoint = process.argv[1];
|
|
59580
|
-
if (entrypoint === undefined || !
|
|
60104
|
+
if (entrypoint === undefined || !existsSync8(entrypoint)) {
|
|
59581
60105
|
return;
|
|
59582
60106
|
}
|
|
59583
60107
|
markStartupCheckStarted();
|