mancode 0.5.0 → 0.5.1
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.en.md +24 -13
- package/README.md +21 -14
- package/dist/{chunk-73F46VQM.js → chunk-SOZ5OUAG.js} +199 -28
- package/dist/chunk-SOZ5OUAG.js.map +1 -0
- package/dist/{chunk-3FOBYCF4.js → chunk-VHZI2WKD.js} +4 -2
- package/dist/{chunk-3FOBYCF4.js.map → chunk-VHZI2WKD.js.map} +1 -1
- package/dist/cli.js +810 -467
- package/dist/cli.js.map +1 -1
- package/dist/{store-GCLUP5IO.js → store-EEWJJANB.js} +2 -2
- package/dist/{v3-adapter-7XYKHGTB.js → v3-adapter-CRSQO3XW.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-73F46VQM.js.map +0 -1
- /package/dist/{store-GCLUP5IO.js.map → store-EEWJJANB.js.map} +0 -0
- /package/dist/{v3-adapter-7XYKHGTB.js.map → v3-adapter-CRSQO3XW.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -111,7 +111,7 @@ import {
|
|
|
111
111
|
workflowMetadataDigest,
|
|
112
112
|
writeOperationReservation,
|
|
113
113
|
writeProjectFacts
|
|
114
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-VHZI2WKD.js";
|
|
115
115
|
import {
|
|
116
116
|
DEFAULT_MANCODE_END_MARKER,
|
|
117
117
|
DEFAULT_MANCODE_START_MARKER,
|
|
@@ -134,7 +134,7 @@ import {
|
|
|
134
134
|
stageV3AdapterUpgradeFiles,
|
|
135
135
|
v3AdapterTargetPath,
|
|
136
136
|
v3AdapterVersionsFromStatuses
|
|
137
|
-
} from "./chunk-
|
|
137
|
+
} from "./chunk-SOZ5OUAG.js";
|
|
138
138
|
|
|
139
139
|
// src/cli.ts
|
|
140
140
|
import { Option, program } from "commander";
|
|
@@ -9427,7 +9427,9 @@ var MANAGED_ADAPTERS = [
|
|
|
9427
9427
|
"codex",
|
|
9428
9428
|
"cursor",
|
|
9429
9429
|
"copilot",
|
|
9430
|
-
"zcode"
|
|
9430
|
+
"zcode",
|
|
9431
|
+
"kimi-code",
|
|
9432
|
+
"qoder"
|
|
9431
9433
|
];
|
|
9432
9434
|
var DIGEST_PATTERN5 = /^sha256:[a-f0-9]{64}$/;
|
|
9433
9435
|
var STAGE_STATES = /* @__PURE__ */ new Set([
|
|
@@ -9618,7 +9620,7 @@ async function activateLegacyMigration(input) {
|
|
|
9618
9620
|
if (session === null || session.status !== "active") {
|
|
9619
9621
|
throw new Error("MANCODE_SESSION_NOT_FOUND");
|
|
9620
9622
|
}
|
|
9621
|
-
const store = new (await import("./store-
|
|
9623
|
+
const store = new (await import("./store-EEWJJANB.js")).V3ContextStore(root);
|
|
9622
9624
|
const project = await store.readProjectSnapshot();
|
|
9623
9625
|
const stage = await readMigrationStage(root, input.stageId);
|
|
9624
9626
|
if (stage.state !== "staged" || stage.revision !== input.expectedStageRevision) {
|
|
@@ -9881,7 +9883,7 @@ async function activateLegacyMigration(input) {
|
|
|
9881
9883
|
for (const action of payload.actions.filter(
|
|
9882
9884
|
(action2) => action2.kind === "v3_adapter_file"
|
|
9883
9885
|
)) {
|
|
9884
|
-
const { applyV3AdapterFilePlan: applyV3AdapterFilePlan2 } = await import("./v3-adapter-
|
|
9886
|
+
const { applyV3AdapterFilePlan: applyV3AdapterFilePlan2 } = await import("./v3-adapter-CRSQO3XW.js");
|
|
9885
9887
|
await applyV3AdapterFilePlan2(root, action);
|
|
9886
9888
|
}
|
|
9887
9889
|
journal = await completeActivationStep(
|
|
@@ -13737,7 +13739,7 @@ async function upgradeV3Adapters(input) {
|
|
|
13737
13739
|
if (unfinished.length > 0) {
|
|
13738
13740
|
throw new Error("MANCODE_ADAPTER_UPGRADE_OPERATION_PENDING");
|
|
13739
13741
|
}
|
|
13740
|
-
const actualVersions = await import("./v3-adapter-
|
|
13742
|
+
const actualVersions = await import("./v3-adapter-CRSQO3XW.js").then(
|
|
13741
13743
|
({ inspectV3AdapterVersions: inspectV3AdapterVersions2 }) => inspectV3AdapterVersions2(
|
|
13742
13744
|
root,
|
|
13743
13745
|
managedAdapterNames(project.manifest.managedAdapters)
|
|
@@ -14149,7 +14151,7 @@ function primaryTargetForPlatform(platform) {
|
|
|
14149
14151
|
return platform === "claude-code" ? "claude-skill" : platform === "cursor" ? "cursor-rule" : platform === "copilot" ? "copilot-instructions" : "agents";
|
|
14150
14152
|
}
|
|
14151
14153
|
function modeTargetForPlatform(platform, mode) {
|
|
14152
|
-
const family = platform === "claude-code" ? "claude" : platform === "codex" || platform === "zcode" ? "agents" : platform;
|
|
14154
|
+
const family = platform === "claude-code" ? "claude" : platform === "codex" || platform === "zcode" || platform === "kimi-code" ? "agents" : platform;
|
|
14153
14155
|
return `${family}-mode-${mode}`;
|
|
14154
14156
|
}
|
|
14155
14157
|
function compareUtf88(left, right) {
|
|
@@ -16234,10 +16236,12 @@ var MODE_NAMES = [
|
|
|
16234
16236
|
var LEGACY_MODE_NAMES = ["mamba", "man8"];
|
|
16235
16237
|
var CODEX_SKILL_MANAGED_MARKER = "<!-- Managed by mancode:codex-skill. Do not edit this file manually. -->";
|
|
16236
16238
|
var ZCODE_SKILL_MANAGED_MARKER = "<!-- Managed by mancode:zcode-skill. Do not edit this file manually. -->";
|
|
16239
|
+
var KIMI_SKILL_MANAGED_MARKER = "<!-- Managed by mancode:kimi-skill. Do not edit this file manually. -->";
|
|
16237
16240
|
var MODE_FILE_MANAGED_MARKER = "<!-- Managed by mancode:mode-file. Do not edit this file manually. -->";
|
|
16238
16241
|
var MANCODE_AGENT_SKILL_MARKERS = [
|
|
16239
16242
|
CODEX_SKILL_MANAGED_MARKER,
|
|
16240
|
-
ZCODE_SKILL_MANAGED_MARKER
|
|
16243
|
+
ZCODE_SKILL_MANAGED_MARKER,
|
|
16244
|
+
KIMI_SKILL_MANAGED_MARKER
|
|
16241
16245
|
];
|
|
16242
16246
|
function renderModeSkill(mode, commandPrefix = "$") {
|
|
16243
16247
|
const meta = MODE_META[mode];
|
|
@@ -16344,6 +16348,37 @@ async function installZcodeSkills(projectRoot, minimal) {
|
|
|
16344
16348
|
}
|
|
16345
16349
|
await removeLegacyManagedSkills(skillsDir, MANCODE_AGENT_SKILL_MARKERS);
|
|
16346
16350
|
}
|
|
16351
|
+
async function installKimiSkills(projectRoot, minimal) {
|
|
16352
|
+
if (minimal) {
|
|
16353
|
+
await removeKimiSkills(projectRoot);
|
|
16354
|
+
return;
|
|
16355
|
+
}
|
|
16356
|
+
const skillsDir = path27.join(projectRoot, ".agents", "skills");
|
|
16357
|
+
for (const mode of MODE_NAMES) {
|
|
16358
|
+
const modeDir = path27.join(skillsDir, mode);
|
|
16359
|
+
await mkdir23(modeDir, { recursive: true });
|
|
16360
|
+
const meta = MODE_META[mode];
|
|
16361
|
+
const content = [
|
|
16362
|
+
"---",
|
|
16363
|
+
`name: ${mode}`,
|
|
16364
|
+
`description: ${JSON.stringify(meta.description)}`,
|
|
16365
|
+
"---",
|
|
16366
|
+
"",
|
|
16367
|
+
KIMI_SKILL_MANAGED_MARKER,
|
|
16368
|
+
"",
|
|
16369
|
+
renderModeSkill(mode, "/skill:"),
|
|
16370
|
+
""
|
|
16371
|
+
].join("\n");
|
|
16372
|
+
await writeManagedSkill(
|
|
16373
|
+
path27.join(modeDir, "SKILL.md"),
|
|
16374
|
+
content,
|
|
16375
|
+
KIMI_SKILL_MANAGED_MARKER,
|
|
16376
|
+
"Kimi Code",
|
|
16377
|
+
MANCODE_AGENT_SKILL_MARKERS
|
|
16378
|
+
);
|
|
16379
|
+
}
|
|
16380
|
+
await removeLegacyManagedSkills(skillsDir, MANCODE_AGENT_SKILL_MARKERS);
|
|
16381
|
+
}
|
|
16347
16382
|
async function installCursorCommands(projectRoot, minimal) {
|
|
16348
16383
|
if (minimal) {
|
|
16349
16384
|
await removeCursorCommands(projectRoot);
|
|
@@ -16373,6 +16408,47 @@ async function installCursorCommands(projectRoot, minimal) {
|
|
|
16373
16408
|
await removeManagedModeFile(path27.join(commandsDir, "mamba.md"), "mamba");
|
|
16374
16409
|
await removeLegacyGeneratedModeFile(path27.join(commandsDir, "man8.md"));
|
|
16375
16410
|
}
|
|
16411
|
+
var QODER_HOST_SCAN_GUIDANCE = [
|
|
16412
|
+
"## Qoder security scan interplay",
|
|
16413
|
+
"",
|
|
16414
|
+
"Qoder may inject L1/L2/L3 security scan findings as advisory context after",
|
|
16415
|
+
"code edits. Treat them as review input for the current step, never as",
|
|
16416
|
+
"authority to reopen completed reviews: in /man or /manteam, fold open",
|
|
16417
|
+
"findings into the single Step 9 remediation round. If any code changes",
|
|
16418
|
+
"after acceptance evidence was recorded, re-run and re-record the required",
|
|
16419
|
+
"checks before completing. Host scan findings never bypass the workflow",
|
|
16420
|
+
"record maintained through `mancode workflow`."
|
|
16421
|
+
].join("\n");
|
|
16422
|
+
async function installQoderCommands(projectRoot, minimal) {
|
|
16423
|
+
if (minimal) {
|
|
16424
|
+
await removeQoderCommands(projectRoot);
|
|
16425
|
+
return;
|
|
16426
|
+
}
|
|
16427
|
+
const commandsDir = path27.join(projectRoot, ".qoder", "commands");
|
|
16428
|
+
await mkdir23(commandsDir, { recursive: true });
|
|
16429
|
+
for (const mode of MODE_NAMES) {
|
|
16430
|
+
const meta = MODE_META[mode];
|
|
16431
|
+
const content = [
|
|
16432
|
+
"---",
|
|
16433
|
+
`name: ${mode}`,
|
|
16434
|
+
`description: ${JSON.stringify(meta.description)}`,
|
|
16435
|
+
"---",
|
|
16436
|
+
"",
|
|
16437
|
+
MODE_FILE_MANAGED_MARKER,
|
|
16438
|
+
"",
|
|
16439
|
+
renderModeSkill(mode, "/"),
|
|
16440
|
+
"",
|
|
16441
|
+
QODER_HOST_SCAN_GUIDANCE,
|
|
16442
|
+
""
|
|
16443
|
+
].join("\n");
|
|
16444
|
+
await writeManagedModeFile(
|
|
16445
|
+
path27.join(commandsDir, `${mode}.md`),
|
|
16446
|
+
content,
|
|
16447
|
+
mode,
|
|
16448
|
+
"Qoder"
|
|
16449
|
+
);
|
|
16450
|
+
}
|
|
16451
|
+
}
|
|
16376
16452
|
async function installCopilotPrompts(projectRoot, minimal) {
|
|
16377
16453
|
if (minimal) {
|
|
16378
16454
|
await removeCopilotPrompts(projectRoot);
|
|
@@ -16407,7 +16483,7 @@ async function installCopilotPrompts(projectRoot, minimal) {
|
|
|
16407
16483
|
await removeLegacyGeneratedModeFile(path27.join(promptsDir, "man8.prompt.md"));
|
|
16408
16484
|
}
|
|
16409
16485
|
async function removeCodexSkills(projectRoot) {
|
|
16410
|
-
if (!await
|
|
16486
|
+
if (!await anyPlatformNeedsSharedSkills(projectRoot, ["zcode", "kimi-code"])) {
|
|
16411
16487
|
await cleanManagedSkills(
|
|
16412
16488
|
path27.join(projectRoot, ".agents", "skills"),
|
|
16413
16489
|
MANCODE_AGENT_SKILL_MARKERS
|
|
@@ -16429,7 +16505,7 @@ async function cleanManagedSkills(skillsDir, markers) {
|
|
|
16429
16505
|
await removeIfEmpty2(skillsDir);
|
|
16430
16506
|
}
|
|
16431
16507
|
async function removeZcodeSkills(projectRoot) {
|
|
16432
|
-
if (!await
|
|
16508
|
+
if (!await anyPlatformNeedsSharedSkills(projectRoot, ["codex", "kimi-code"])) {
|
|
16433
16509
|
await cleanManagedSkills(
|
|
16434
16510
|
path27.join(projectRoot, ".agents", "skills"),
|
|
16435
16511
|
MANCODE_AGENT_SKILL_MARKERS
|
|
@@ -16439,6 +16515,20 @@ async function removeZcodeSkills(projectRoot) {
|
|
|
16439
16515
|
ZCODE_SKILL_MANAGED_MARKER
|
|
16440
16516
|
]);
|
|
16441
16517
|
}
|
|
16518
|
+
async function removeKimiSkills(projectRoot) {
|
|
16519
|
+
if (!await anyPlatformNeedsSharedSkills(projectRoot, ["codex", "zcode"])) {
|
|
16520
|
+
await cleanManagedSkills(
|
|
16521
|
+
path27.join(projectRoot, ".agents", "skills"),
|
|
16522
|
+
MANCODE_AGENT_SKILL_MARKERS
|
|
16523
|
+
);
|
|
16524
|
+
}
|
|
16525
|
+
}
|
|
16526
|
+
async function removeQoderCommands(projectRoot) {
|
|
16527
|
+
for (const mode of MODE_NAMES) {
|
|
16528
|
+
const filePath = path27.join(projectRoot, ".qoder", "commands", `${mode}.md`);
|
|
16529
|
+
await removeManagedModeFile(filePath, mode);
|
|
16530
|
+
}
|
|
16531
|
+
}
|
|
16442
16532
|
async function removeCursorCommands(projectRoot) {
|
|
16443
16533
|
for (const mode of [...MODE_NAMES, ...LEGACY_MODE_NAMES]) {
|
|
16444
16534
|
const filePath = path27.join(
|
|
@@ -16520,6 +16610,12 @@ async function isManagedByAnyMarker(skillPath, markers) {
|
|
|
16520
16610
|
const content = await readTextIfExists3(skillPath);
|
|
16521
16611
|
return content !== null && markers.some((marker) => content.includes(marker));
|
|
16522
16612
|
}
|
|
16613
|
+
async function anyPlatformNeedsSharedSkills(projectRoot, platforms) {
|
|
16614
|
+
for (const platform of platforms) {
|
|
16615
|
+
if (await platformNeedsSharedSkills(projectRoot, platform)) return true;
|
|
16616
|
+
}
|
|
16617
|
+
return false;
|
|
16618
|
+
}
|
|
16523
16619
|
async function platformNeedsSharedSkills(projectRoot, platform) {
|
|
16524
16620
|
try {
|
|
16525
16621
|
const raw = await readFile26(
|
|
@@ -16763,7 +16859,11 @@ function renderAesthetics(tokens) {
|
|
|
16763
16859
|
}
|
|
16764
16860
|
function renderModes(options) {
|
|
16765
16861
|
let commandLabel;
|
|
16766
|
-
if (options.
|
|
16862
|
+
if (options.platform === "kimi-code") {
|
|
16863
|
+
commandLabel = "Invoke mode skills with `/skill:man`, `/skill:manba`, `/skill:manteam`, `/skill:manps`, `/skill:mansolo`.";
|
|
16864
|
+
} else if (options.platform === "qoder") {
|
|
16865
|
+
commandLabel = "Invoke mode commands with `/man`, `/manba`, `/manteam`, `/manps`, `/mansolo`.";
|
|
16866
|
+
} else if (options.capabilities.skills === "agents-skills") {
|
|
16767
16867
|
commandLabel = "Invoke mode skills with `$man`, `$manba`, `$manteam`, `$manps`, `$mansolo`.";
|
|
16768
16868
|
} else if (options.capabilities.slashCommands === "native") {
|
|
16769
16869
|
commandLabel = "Use the named commands directly when available.";
|
|
@@ -17146,14 +17246,104 @@ function renderManpsRule() {
|
|
|
17146
17246
|
return renderModeSkill("manps", "/");
|
|
17147
17247
|
}
|
|
17148
17248
|
|
|
17149
|
-
// src/installers/
|
|
17249
|
+
// src/installers/kimi-code.ts
|
|
17150
17250
|
import { writeFile as writeFile29 } from "fs/promises";
|
|
17151
17251
|
import path32 from "path";
|
|
17252
|
+
var KIMI_MANCODE_START_MARKER = "<!-- mancode:kimi-code:start -->";
|
|
17253
|
+
var KIMI_MANCODE_END_MARKER = "<!-- mancode:kimi-code:end -->";
|
|
17254
|
+
async function installKimiCode(projectRoot, options) {
|
|
17255
|
+
await installMancodeCore(projectRoot);
|
|
17256
|
+
const agentsPath = path32.join(projectRoot, "AGENTS.md");
|
|
17257
|
+
const existing = await readTextIfExists(agentsPath);
|
|
17258
|
+
const sharedContent = await generateSharedContent(projectRoot, {
|
|
17259
|
+
platform: "kimi-code",
|
|
17260
|
+
displayName: "Kimi Code (desktop/CLI)",
|
|
17261
|
+
capabilities: {
|
|
17262
|
+
slashCommands: "partial",
|
|
17263
|
+
subagents: false,
|
|
17264
|
+
hooks: false,
|
|
17265
|
+
skills: "agents-skills"
|
|
17266
|
+
},
|
|
17267
|
+
minimal: options.minimal,
|
|
17268
|
+
techStack: options.techStack,
|
|
17269
|
+
uiLibrary: options.uiLibrary,
|
|
17270
|
+
projectProfile: options.projectProfile
|
|
17271
|
+
});
|
|
17272
|
+
const block = [
|
|
17273
|
+
KIMI_MANCODE_START_MARKER,
|
|
17274
|
+
"<!-- Managed by mancode. Do not edit this block manually. -->",
|
|
17275
|
+
"",
|
|
17276
|
+
"# mancode Configuration",
|
|
17277
|
+
"",
|
|
17278
|
+
sharedContent.trim(),
|
|
17279
|
+
KIMI_MANCODE_END_MARKER
|
|
17280
|
+
].join("\n");
|
|
17281
|
+
await writeFile29(
|
|
17282
|
+
agentsPath,
|
|
17283
|
+
replaceManagedBlock(
|
|
17284
|
+
existing,
|
|
17285
|
+
block,
|
|
17286
|
+
KIMI_MANCODE_START_MARKER,
|
|
17287
|
+
KIMI_MANCODE_END_MARKER
|
|
17288
|
+
),
|
|
17289
|
+
"utf-8"
|
|
17290
|
+
);
|
|
17291
|
+
await installKimiSkills(projectRoot, options.minimal ?? false);
|
|
17292
|
+
}
|
|
17293
|
+
|
|
17294
|
+
// src/installers/qoder.ts
|
|
17295
|
+
import { writeFile as writeFile30 } from "fs/promises";
|
|
17296
|
+
import path33 from "path";
|
|
17297
|
+
var QODER_MANCODE_START_MARKER = "<!-- mancode:qoder:start -->";
|
|
17298
|
+
var QODER_MANCODE_END_MARKER = "<!-- mancode:qoder:end -->";
|
|
17299
|
+
async function installQoder(projectRoot, options) {
|
|
17300
|
+
await installMancodeCore(projectRoot);
|
|
17301
|
+
const agentsPath = path33.join(projectRoot, "AGENTS.md");
|
|
17302
|
+
const existing = await readTextIfExists(agentsPath);
|
|
17303
|
+
const sharedContent = await generateSharedContent(projectRoot, {
|
|
17304
|
+
platform: "qoder",
|
|
17305
|
+
displayName: "Qoder (IDE/CLI)",
|
|
17306
|
+
capabilities: {
|
|
17307
|
+
slashCommands: "partial",
|
|
17308
|
+
subagents: false,
|
|
17309
|
+
hooks: false,
|
|
17310
|
+
skills: "rules"
|
|
17311
|
+
},
|
|
17312
|
+
minimal: options.minimal,
|
|
17313
|
+
techStack: options.techStack,
|
|
17314
|
+
uiLibrary: options.uiLibrary,
|
|
17315
|
+
projectProfile: options.projectProfile
|
|
17316
|
+
});
|
|
17317
|
+
const block = [
|
|
17318
|
+
QODER_MANCODE_START_MARKER,
|
|
17319
|
+
"<!-- Managed by mancode. Do not edit this block manually. -->",
|
|
17320
|
+
"",
|
|
17321
|
+
"# mancode Configuration",
|
|
17322
|
+
"",
|
|
17323
|
+
sharedContent.trim(),
|
|
17324
|
+
QODER_MANCODE_END_MARKER
|
|
17325
|
+
].join("\n");
|
|
17326
|
+
await writeFile30(
|
|
17327
|
+
agentsPath,
|
|
17328
|
+
replaceManagedBlock(
|
|
17329
|
+
existing,
|
|
17330
|
+
block,
|
|
17331
|
+
QODER_MANCODE_START_MARKER,
|
|
17332
|
+
QODER_MANCODE_END_MARKER
|
|
17333
|
+
),
|
|
17334
|
+
"utf-8"
|
|
17335
|
+
);
|
|
17336
|
+
await installQoderCommands(projectRoot, options.minimal ?? false);
|
|
17337
|
+
}
|
|
17338
|
+
|
|
17339
|
+
// src/installers/zcode.ts
|
|
17340
|
+
import { writeFile as writeFile31 } from "fs/promises";
|
|
17341
|
+
import path34 from "path";
|
|
17152
17342
|
var ZCODE_MANCODE_START_MARKER = "<!-- mancode:zcode:start -->";
|
|
17153
17343
|
var ZCODE_MANCODE_END_MARKER = "<!-- mancode:zcode:end -->";
|
|
17154
17344
|
async function installZcode(projectRoot, options) {
|
|
17155
17345
|
await installMancodeCore(projectRoot);
|
|
17156
|
-
const agentsPath =
|
|
17346
|
+
const agentsPath = path34.join(projectRoot, "AGENTS.md");
|
|
17157
17347
|
const existing = await readTextIfExists(agentsPath);
|
|
17158
17348
|
const sharedContent = await generateSharedContent(projectRoot, {
|
|
17159
17349
|
platform: "zcode",
|
|
@@ -17178,7 +17368,7 @@ async function installZcode(projectRoot, options) {
|
|
|
17178
17368
|
sharedContent.trim(),
|
|
17179
17369
|
ZCODE_MANCODE_END_MARKER
|
|
17180
17370
|
].join("\n");
|
|
17181
|
-
await
|
|
17371
|
+
await writeFile31(
|
|
17182
17372
|
agentsPath,
|
|
17183
17373
|
replaceManagedBlock(
|
|
17184
17374
|
existing,
|
|
@@ -17247,6 +17437,28 @@ var PLATFORM_INSTALLERS = {
|
|
|
17247
17437
|
skills: "agents-skills"
|
|
17248
17438
|
},
|
|
17249
17439
|
install: installZcode
|
|
17440
|
+
},
|
|
17441
|
+
"kimi-code": {
|
|
17442
|
+
name: "kimi-code",
|
|
17443
|
+
displayName: "Kimi Code (desktop/CLI)",
|
|
17444
|
+
capabilities: {
|
|
17445
|
+
slashCommands: "partial",
|
|
17446
|
+
subagents: false,
|
|
17447
|
+
hooks: false,
|
|
17448
|
+
skills: "agents-skills"
|
|
17449
|
+
},
|
|
17450
|
+
install: installKimiCode
|
|
17451
|
+
},
|
|
17452
|
+
qoder: {
|
|
17453
|
+
name: "qoder",
|
|
17454
|
+
displayName: "Qoder (IDE/CLI)",
|
|
17455
|
+
capabilities: {
|
|
17456
|
+
slashCommands: "partial",
|
|
17457
|
+
subagents: false,
|
|
17458
|
+
hooks: false,
|
|
17459
|
+
skills: "rules"
|
|
17460
|
+
},
|
|
17461
|
+
install: installQoder
|
|
17250
17462
|
}
|
|
17251
17463
|
};
|
|
17252
17464
|
function getPlatformInstaller(platform) {
|
|
@@ -17264,11 +17476,11 @@ function isPlatformName(platform) {
|
|
|
17264
17476
|
}
|
|
17265
17477
|
|
|
17266
17478
|
// src/commands/v3-support.ts
|
|
17267
|
-
import
|
|
17479
|
+
import path36 from "path";
|
|
17268
17480
|
|
|
17269
17481
|
// src/runtime/platform-spike-store.ts
|
|
17270
|
-
import { lstat as lstat11, mkdir as mkdir26, readFile as readFile29, rm as rm13, writeFile as
|
|
17271
|
-
import
|
|
17482
|
+
import { lstat as lstat11, mkdir as mkdir26, readFile as readFile29, rm as rm13, writeFile as writeFile32 } from "fs/promises";
|
|
17483
|
+
import path35 from "path";
|
|
17272
17484
|
|
|
17273
17485
|
// src/runtime/platform-spike.ts
|
|
17274
17486
|
var SESSION_SPIKE_PLATFORMS = [
|
|
@@ -17276,7 +17488,9 @@ var SESSION_SPIKE_PLATFORMS = [
|
|
|
17276
17488
|
"codex",
|
|
17277
17489
|
"cursor",
|
|
17278
17490
|
"copilot",
|
|
17279
|
-
"zcode"
|
|
17491
|
+
"zcode",
|
|
17492
|
+
"kimi-code",
|
|
17493
|
+
"qoder"
|
|
17280
17494
|
];
|
|
17281
17495
|
function createPlatformSessionSpike(input) {
|
|
17282
17496
|
assertSessionSpikePlatform(input.platform);
|
|
@@ -17648,7 +17862,7 @@ async function readPlatformSessionSpike(projectRoot, platform) {
|
|
|
17648
17862
|
if (directory === null) return null;
|
|
17649
17863
|
try {
|
|
17650
17864
|
const raw = await readSafeRegularFile(
|
|
17651
|
-
|
|
17865
|
+
path35.join(directory, `${platform}.json`)
|
|
17652
17866
|
);
|
|
17653
17867
|
return parsePlatformSessionSpike(JSON.parse(raw));
|
|
17654
17868
|
} catch (error) {
|
|
@@ -17678,13 +17892,13 @@ async function writePlatformSessionSpike(projectRoot, spike) {
|
|
|
17678
17892
|
if (directory === null) {
|
|
17679
17893
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
17680
17894
|
}
|
|
17681
|
-
const target =
|
|
17895
|
+
const target = path35.join(directory, `${parsed.platform}.json`);
|
|
17682
17896
|
await assertSafeReplacementTarget(target);
|
|
17683
|
-
const temporary =
|
|
17897
|
+
const temporary = path35.join(
|
|
17684
17898
|
directory,
|
|
17685
17899
|
`.${parsed.platform}.${process.pid}.${Date.now()}.tmp`
|
|
17686
17900
|
);
|
|
17687
|
-
await
|
|
17901
|
+
await writeFile32(temporary, `${JSON.stringify(parsed, null, 2)}
|
|
17688
17902
|
`, {
|
|
17689
17903
|
encoding: "utf8",
|
|
17690
17904
|
flag: "wx"
|
|
@@ -17699,9 +17913,9 @@ async function writePlatformSessionSpike(projectRoot, spike) {
|
|
|
17699
17913
|
return parsed;
|
|
17700
17914
|
}
|
|
17701
17915
|
async function safeEvidenceDirectory(projectRoot, create) {
|
|
17702
|
-
let current =
|
|
17916
|
+
let current = path35.resolve(projectRoot);
|
|
17703
17917
|
for (const segment of EVIDENCE_DIRECTORY_SEGMENTS) {
|
|
17704
|
-
const target =
|
|
17918
|
+
const target = path35.join(current, segment);
|
|
17705
17919
|
try {
|
|
17706
17920
|
await assertSafeDirectory2(target);
|
|
17707
17921
|
} catch (error) {
|
|
@@ -17844,7 +18058,7 @@ var EXIT_V3_OK = 0;
|
|
|
17844
18058
|
var EXIT_V3_INVALID_ARGUMENT = 2;
|
|
17845
18059
|
var EXIT_V3_BLOCKED = 3;
|
|
17846
18060
|
async function readV3CommandProject(projectRoot) {
|
|
17847
|
-
const root =
|
|
18061
|
+
const root = path36.resolve(projectRoot);
|
|
17848
18062
|
const runtime = await readProjectRuntimeContext(root);
|
|
17849
18063
|
const store = new V3ContextStore(root);
|
|
17850
18064
|
return {
|
|
@@ -17897,7 +18111,7 @@ async function resolveV3SessionCandidate(project, input, client) {
|
|
|
17897
18111
|
});
|
|
17898
18112
|
}
|
|
17899
18113
|
function platformForClient(client) {
|
|
17900
|
-
return client === "claude-code" || client === "codex" || client === "cursor" || client === "copilot" || client === "zcode" ? client : null;
|
|
18114
|
+
return client === "claude-code" || client === "codex" || client === "cursor" || client === "copilot" || client === "zcode" || client === "kimi-code" || client === "qoder" ? client : null;
|
|
17901
18115
|
}
|
|
17902
18116
|
function commandClient(value) {
|
|
17903
18117
|
const client = value ?? "mancode-cli";
|
|
@@ -18022,8 +18236,8 @@ function selectUpgradePlatforms(options) {
|
|
|
18022
18236
|
}
|
|
18023
18237
|
|
|
18024
18238
|
// src/context/publish-promote.ts
|
|
18025
|
-
import { lstat as lstat12, mkdir as mkdir27, rename as rename9, rm as rm14, writeFile as
|
|
18026
|
-
import
|
|
18239
|
+
import { lstat as lstat12, mkdir as mkdir27, rename as rename9, rm as rm14, writeFile as writeFile33 } from "fs/promises";
|
|
18240
|
+
import path37 from "path";
|
|
18027
18241
|
|
|
18028
18242
|
// src/context/task-mutation.ts
|
|
18029
18243
|
function markTaskReviewStale(previous, operationId, updatedAt) {
|
|
@@ -18755,7 +18969,7 @@ async function stageDestinationAuthority(projectRoot, destinationTaskRef, operat
|
|
|
18755
18969
|
const target = taskRootPath(projectRoot, destinationTaskRef);
|
|
18756
18970
|
const parent = await ensureSafeTaskParent2(projectRoot, destinationTaskRef);
|
|
18757
18971
|
await assertPathAbsent(target, "MANCODE_PROMOTION_DESTINATION_EXISTS");
|
|
18758
|
-
const staging =
|
|
18972
|
+
const staging = path37.join(
|
|
18759
18973
|
parent,
|
|
18760
18974
|
`.${destinationTaskRef.taskId}.${operationId}.staging`
|
|
18761
18975
|
);
|
|
@@ -18763,7 +18977,7 @@ async function stageDestinationAuthority(projectRoot, destinationTaskRef, operat
|
|
|
18763
18977
|
await mkdir27(staging);
|
|
18764
18978
|
try {
|
|
18765
18979
|
for (const [fileName, content] of Object.entries(contents)) {
|
|
18766
|
-
await
|
|
18980
|
+
await writeFile33(path37.join(staging, fileName), content, {
|
|
18767
18981
|
encoding: "utf8",
|
|
18768
18982
|
flag: "wx"
|
|
18769
18983
|
});
|
|
@@ -18779,7 +18993,7 @@ async function ensureSafeTaskParent2(projectRoot, taskRef) {
|
|
|
18779
18993
|
await assertSafeDirectory3(projectRoot);
|
|
18780
18994
|
let current = projectRoot;
|
|
18781
18995
|
for (const segment of [".mancode", taskRef.namespace, "workflows"]) {
|
|
18782
|
-
current =
|
|
18996
|
+
current = path37.join(current, segment);
|
|
18783
18997
|
const existing = await lstatOrNull2(current);
|
|
18784
18998
|
if (existing === null) {
|
|
18785
18999
|
try {
|
|
@@ -18964,19 +19178,19 @@ async function renewPromotionLocks(source) {
|
|
|
18964
19178
|
}
|
|
18965
19179
|
async function writePromotionQuarantine(projectRoot, operationId, candidate, contents) {
|
|
18966
19180
|
const directory = publishStagingDirectory(projectRoot, operationId);
|
|
18967
|
-
const parent =
|
|
19181
|
+
const parent = path37.dirname(directory);
|
|
18968
19182
|
await mkdir27(parent, { recursive: true });
|
|
18969
19183
|
await assertSafeDirectory3(parent);
|
|
18970
19184
|
await assertPathAbsent(directory, "MANCODE_PROMOTION_QUARANTINE_CONFLICT");
|
|
18971
19185
|
await mkdir27(directory);
|
|
18972
19186
|
try {
|
|
18973
|
-
await
|
|
18974
|
-
|
|
19187
|
+
await writeFile33(
|
|
19188
|
+
path37.join(directory, "candidate.json"),
|
|
18975
19189
|
serializeTaskAuthority(candidate),
|
|
18976
19190
|
{ encoding: "utf8", flag: "wx" }
|
|
18977
19191
|
);
|
|
18978
19192
|
for (const [fileName, content] of Object.entries(contents)) {
|
|
18979
|
-
await
|
|
19193
|
+
await writeFile33(path37.join(directory, fileName), content, {
|
|
18980
19194
|
encoding: "utf8",
|
|
18981
19195
|
flag: "wx"
|
|
18982
19196
|
});
|
|
@@ -18989,12 +19203,12 @@ async function writePromotionQuarantine(projectRoot, operationId, candidate, con
|
|
|
18989
19203
|
async function rewritePromotionQuarantine(projectRoot, operationId, candidate) {
|
|
18990
19204
|
const directory = publishStagingDirectory(projectRoot, operationId);
|
|
18991
19205
|
await assertSafeDirectory3(directory);
|
|
18992
|
-
const target =
|
|
18993
|
-
const temporary =
|
|
19206
|
+
const target = path37.join(directory, "candidate.json");
|
|
19207
|
+
const temporary = path37.join(
|
|
18994
19208
|
directory,
|
|
18995
19209
|
`.candidate.${process.pid}.${Date.now()}.tmp`
|
|
18996
19210
|
);
|
|
18997
|
-
await
|
|
19211
|
+
await writeFile33(temporary, serializeTaskAuthority(candidate), {
|
|
18998
19212
|
encoding: "utf8",
|
|
18999
19213
|
flag: "wx"
|
|
19000
19214
|
});
|
|
@@ -19812,7 +20026,7 @@ function compareUtf89(left, right) {
|
|
|
19812
20026
|
|
|
19813
20027
|
// src/context/task-head-reconcile.ts
|
|
19814
20028
|
import { execFile as execFileCallback4 } from "child_process";
|
|
19815
|
-
import
|
|
20029
|
+
import path39 from "path";
|
|
19816
20030
|
import { promisify as promisify4 } from "util";
|
|
19817
20031
|
|
|
19818
20032
|
// src/team/conflicts.ts
|
|
@@ -20012,9 +20226,9 @@ function unique(values) {
|
|
|
20012
20226
|
|
|
20013
20227
|
// src/team/git-ref-transport.ts
|
|
20014
20228
|
import { execFile as execFileCallback3 } from "child_process";
|
|
20015
|
-
import { mkdtemp, rm as rm15, writeFile as
|
|
20229
|
+
import { mkdtemp, rm as rm15, writeFile as writeFile34 } from "fs/promises";
|
|
20016
20230
|
import { tmpdir } from "os";
|
|
20017
|
-
import
|
|
20231
|
+
import path38 from "path";
|
|
20018
20232
|
import { promisify as promisify3 } from "util";
|
|
20019
20233
|
var execFile3 = promisify3(execFileCallback3);
|
|
20020
20234
|
var TEAM_REF = "refs/mancode/team";
|
|
@@ -20037,7 +20251,7 @@ async function resolveGitRefRemoteIdentityHash(projectRoot, remote) {
|
|
|
20037
20251
|
}
|
|
20038
20252
|
let configured = remote;
|
|
20039
20253
|
try {
|
|
20040
|
-
const output = await runGit2(
|
|
20254
|
+
const output = await runGit2(path38.resolve(projectRoot), [
|
|
20041
20255
|
"remote",
|
|
20042
20256
|
"get-url",
|
|
20043
20257
|
"--all",
|
|
@@ -20087,7 +20301,7 @@ var GitRefTeamManifestStore = class {
|
|
|
20087
20301
|
"git-ref configRevision"
|
|
20088
20302
|
);
|
|
20089
20303
|
parseOptionalDigest(options.configDigest, "git-ref configDigest");
|
|
20090
|
-
this.projectRoot =
|
|
20304
|
+
this.projectRoot = path38.resolve(options.projectRoot);
|
|
20091
20305
|
this.remote = options.remote;
|
|
20092
20306
|
this.workspaceId = options.workspaceId;
|
|
20093
20307
|
this.expectedHeader = {
|
|
@@ -21793,17 +22007,17 @@ function upsertActorProfile(profiles, profile) {
|
|
|
21793
22007
|
}
|
|
21794
22008
|
async function writeManifestCommit(projectRoot, parent, manifest, now) {
|
|
21795
22009
|
const temporaryDirectory = await mkdtemp(
|
|
21796
|
-
|
|
22010
|
+
path38.join(tmpdir(), "mancode-git-ref-")
|
|
21797
22011
|
);
|
|
21798
|
-
const manifestPath =
|
|
21799
|
-
const indexPath =
|
|
22012
|
+
const manifestPath = path38.join(temporaryDirectory, "manifest.json");
|
|
22013
|
+
const indexPath = path38.join(temporaryDirectory, "index");
|
|
21800
22014
|
try {
|
|
21801
22015
|
const serialized = `${JSON.stringify(manifest, null, 2)}
|
|
21802
22016
|
`;
|
|
21803
22017
|
if (Buffer.byteLength(serialized, "utf8") > MAX_MANIFEST_BYTES) {
|
|
21804
22018
|
throw new Error("MANCODE_TRANSPORT_MANIFEST_TOO_LARGE");
|
|
21805
22019
|
}
|
|
21806
|
-
await
|
|
22020
|
+
await writeFile34(manifestPath, serialized);
|
|
21807
22021
|
const blob = (await runGit2(projectRoot, ["hash-object", "-w", manifestPath])).trim();
|
|
21808
22022
|
const environment = { ...process.env, GIT_INDEX_FILE: indexPath };
|
|
21809
22023
|
await runGit2(projectRoot, ["read-tree", "--empty"], environment);
|
|
@@ -21917,7 +22131,7 @@ function normalizeRemoteIdentity(projectRoot, value) {
|
|
|
21917
22131
|
url.pathname = url.pathname.replace(/\/+$/g, "");
|
|
21918
22132
|
return url.toString();
|
|
21919
22133
|
} catch {
|
|
21920
|
-
return
|
|
22134
|
+
return path38.resolve(projectRoot, value).replaceAll("\\", "/");
|
|
21921
22135
|
}
|
|
21922
22136
|
}
|
|
21923
22137
|
function parseBundleCodeRef(value) {
|
|
@@ -22291,8 +22505,8 @@ function injectAfterReconcileStep(stepId) {
|
|
|
22291
22505
|
throwIfOperationCrashInjected("task_head_reconcile", stepId);
|
|
22292
22506
|
}
|
|
22293
22507
|
async function assertGitSourcedTaskAggregate(projectRoot, taskRoot2) {
|
|
22294
|
-
const relativeTaskRoot =
|
|
22295
|
-
if (!relativeTaskRoot ||
|
|
22508
|
+
const relativeTaskRoot = path39.relative(projectRoot, taskRoot2);
|
|
22509
|
+
if (!relativeTaskRoot || path39.isAbsolute(relativeTaskRoot) || relativeTaskRoot.split(path39.sep).some((part) => part === "..")) {
|
|
22296
22510
|
throw new Error("MANCODE_TASK_UNAVAILABLE");
|
|
22297
22511
|
}
|
|
22298
22512
|
const authorityFiles = [
|
|
@@ -22300,7 +22514,7 @@ async function assertGitSourcedTaskAggregate(projectRoot, taskRoot2) {
|
|
|
22300
22514
|
"requirements.json",
|
|
22301
22515
|
"review-ledger.json",
|
|
22302
22516
|
"verification-ledger.json"
|
|
22303
|
-
].map((file) =>
|
|
22517
|
+
].map((file) => path39.join(relativeTaskRoot, file));
|
|
22304
22518
|
try {
|
|
22305
22519
|
await execFile4("git", ["rev-parse", "--verify", "HEAD^{commit}"], {
|
|
22306
22520
|
cwd: projectRoot,
|
|
@@ -22518,16 +22732,18 @@ var BETA_PLATFORMS = [
|
|
|
22518
22732
|
"codex",
|
|
22519
22733
|
"cursor",
|
|
22520
22734
|
"copilot",
|
|
22521
|
-
"zcode"
|
|
22735
|
+
"zcode",
|
|
22736
|
+
"kimi-code",
|
|
22737
|
+
"qoder"
|
|
22522
22738
|
];
|
|
22523
22739
|
|
|
22524
22740
|
// src/runtime/retention.ts
|
|
22525
22741
|
import { lstat as lstat13, readFile as readFile30, readdir as readdir14, rm as rm16 } from "fs/promises";
|
|
22526
|
-
import
|
|
22742
|
+
import path40 from "path";
|
|
22527
22743
|
var TERMINAL_JOURNAL_RETENTION_DAYS = 30;
|
|
22528
22744
|
var RETAINED_NON_MILESTONE_CHECKPOINTS = 10;
|
|
22529
22745
|
async function planContextCompaction(input) {
|
|
22530
|
-
const root =
|
|
22746
|
+
const root = path40.resolve(input.projectRoot);
|
|
22531
22747
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
22532
22748
|
const store = new V3ContextStore(root);
|
|
22533
22749
|
const [project, runtime] = await Promise.all([
|
|
@@ -22600,7 +22816,7 @@ async function planLocalOverlayRetention(root, store, taskRefs, localRawArtifact
|
|
|
22600
22816
|
if (taskRef.namespace !== "shared") continue;
|
|
22601
22817
|
const task = await store.readTaskSnapshot(taskRef);
|
|
22602
22818
|
if (!isTerminalTaskStatus(task.metadata.status)) continue;
|
|
22603
|
-
const directory =
|
|
22819
|
+
const directory = path40.join(
|
|
22604
22820
|
root,
|
|
22605
22821
|
".mancode",
|
|
22606
22822
|
"local",
|
|
@@ -22609,7 +22825,7 @@ async function planLocalOverlayRetention(root, store, taskRefs, localRawArtifact
|
|
|
22609
22825
|
"artifacts"
|
|
22610
22826
|
);
|
|
22611
22827
|
for (const entry of await readDirectoryOrEmpty(directory)) {
|
|
22612
|
-
const target =
|
|
22828
|
+
const target = path40.join(directory, entry);
|
|
22613
22829
|
const metadata = await regularFileMetadataOrNull(target);
|
|
22614
22830
|
if (metadata === null || metadata.mtimeMs >= threshold) continue;
|
|
22615
22831
|
candidates.push({
|
|
@@ -22626,7 +22842,7 @@ async function planLocalOverlayRetention(root, store, taskRefs, localRawArtifact
|
|
|
22626
22842
|
}
|
|
22627
22843
|
async function planLocalCacheRetention(root, localCacheDays, now) {
|
|
22628
22844
|
const threshold = now.getTime() - localCacheDays * 864e5;
|
|
22629
|
-
const directory =
|
|
22845
|
+
const directory = path40.join(root, ".mancode", "local", "cache");
|
|
22630
22846
|
const candidates = [];
|
|
22631
22847
|
for (const target of await listRegularFilesRecursively(directory)) {
|
|
22632
22848
|
const metadata = await regularFileMetadataOrNull(target);
|
|
@@ -22689,7 +22905,7 @@ async function planCheckpointCompaction(store, coordinationStore, taskRefs, prot
|
|
|
22689
22905
|
}
|
|
22690
22906
|
candidates.push({
|
|
22691
22907
|
kind: "checkpoint",
|
|
22692
|
-
target:
|
|
22908
|
+
target: path40.join(
|
|
22693
22909
|
task.location.taskRoot,
|
|
22694
22910
|
"checkpoints",
|
|
22695
22911
|
`${checkpoint.checkpointId}.json`
|
|
@@ -22703,13 +22919,13 @@ async function planCheckpointCompaction(store, coordinationStore, taskRefs, prot
|
|
|
22703
22919
|
return { candidates, skippedReferencedCheckpoints };
|
|
22704
22920
|
}
|
|
22705
22921
|
async function planCompletedSessionRetention(root, completedSessionDays, now, protectedSessionIds) {
|
|
22706
|
-
const directory =
|
|
22922
|
+
const directory = path40.join(root, ".mancode", "local", "sessions");
|
|
22707
22923
|
const entries = await readDirectoryOrEmpty(directory);
|
|
22708
22924
|
const threshold = now.getTime() - completedSessionDays * 864e5;
|
|
22709
22925
|
const candidates = [];
|
|
22710
22926
|
for (const entry of entries) {
|
|
22711
22927
|
if (!entry.endsWith(".json")) continue;
|
|
22712
|
-
const target =
|
|
22928
|
+
const target = path40.join(directory, entry);
|
|
22713
22929
|
const session = parseSessionState(
|
|
22714
22930
|
JSON.parse(await readRegularFile(target))
|
|
22715
22931
|
);
|
|
@@ -22735,7 +22951,7 @@ async function planOperationRetention(stores, now) {
|
|
|
22735
22951
|
const entries = await readDirectoryOrEmpty(directory);
|
|
22736
22952
|
for (const entry of entries) {
|
|
22737
22953
|
if (!entry.endsWith(".json")) continue;
|
|
22738
|
-
const target =
|
|
22954
|
+
const target = path40.join(directory, entry);
|
|
22739
22955
|
const journal = parseOperationJournal(
|
|
22740
22956
|
JSON.parse(await readRegularFile(target))
|
|
22741
22957
|
);
|
|
@@ -22814,7 +23030,7 @@ function isTerminalTaskStatus(status2) {
|
|
|
22814
23030
|
async function listTaskRefs(root) {
|
|
22815
23031
|
const refs = [];
|
|
22816
23032
|
for (const namespace of ["local", "shared"]) {
|
|
22817
|
-
const directory =
|
|
23033
|
+
const directory = path40.join(root, ".mancode", namespace, "workflows");
|
|
22818
23034
|
for (const entry of await readDirectoryOrEmpty(directory)) {
|
|
22819
23035
|
if (!/^[0-9A-HJKMNP-TV-Z]{26}$/.test(entry)) continue;
|
|
22820
23036
|
refs.push({ namespace, taskId: entry });
|
|
@@ -22827,12 +23043,12 @@ async function listTaskRefs(root) {
|
|
|
22827
23043
|
);
|
|
22828
23044
|
}
|
|
22829
23045
|
async function listTaskCheckpoints(taskRoot2, taskRef) {
|
|
22830
|
-
const directory =
|
|
23046
|
+
const directory = path40.join(taskRoot2, "checkpoints");
|
|
22831
23047
|
const checkpoints = [];
|
|
22832
23048
|
for (const entry of await readDirectoryOrEmpty(directory)) {
|
|
22833
23049
|
if (!entry.endsWith(".json")) continue;
|
|
22834
23050
|
const checkpoint = parseCheckpoint(
|
|
22835
|
-
JSON.parse(await readRegularFile(
|
|
23051
|
+
JSON.parse(await readRegularFile(path40.join(directory, entry)))
|
|
22836
23052
|
);
|
|
22837
23053
|
if (!sameTaskRef(checkpoint.taskRef, taskRef) || entry !== `${checkpoint.checkpointId}.json`) {
|
|
22838
23054
|
throw new Error("MANCODE_RETENTION_CHECKPOINT_CORRUPT");
|
|
@@ -22871,7 +23087,7 @@ async function readDirectoryOrEmpty(directory) {
|
|
|
22871
23087
|
async function listRegularFilesRecursively(directory) {
|
|
22872
23088
|
const files = [];
|
|
22873
23089
|
for (const entry of await readDirectoryOrEmpty(directory)) {
|
|
22874
|
-
const target =
|
|
23090
|
+
const target = path40.join(directory, entry);
|
|
22875
23091
|
const metadata = await lstatOrNull3(target);
|
|
22876
23092
|
if (metadata === null) continue;
|
|
22877
23093
|
if (metadata.isSymbolicLink()) {
|
|
@@ -22935,8 +23151,8 @@ function isNotFound21(error) {
|
|
|
22935
23151
|
}
|
|
22936
23152
|
|
|
22937
23153
|
// src/team/git-ref-cache.ts
|
|
22938
|
-
import { lstat as lstat14, mkdir as mkdir28, readFile as readFile31, writeFile as
|
|
22939
|
-
import
|
|
23154
|
+
import { lstat as lstat14, mkdir as mkdir28, readFile as readFile31, writeFile as writeFile35 } from "fs/promises";
|
|
23155
|
+
import path41 from "path";
|
|
22940
23156
|
var DEFAULT_GIT_REF_FRESHNESS_TTL_MS = 5 * 60 * 1e3;
|
|
22941
23157
|
async function writeGitRefTeamCache(projectRoot, config, snapshot) {
|
|
22942
23158
|
const remote = gitRefRemote(config);
|
|
@@ -22952,11 +23168,11 @@ async function writeGitRefTeamCache(projectRoot, config, snapshot) {
|
|
|
22952
23168
|
});
|
|
22953
23169
|
const directory = await ensureSafeCacheDirectory(projectRoot);
|
|
22954
23170
|
const target = gitRefCachePath(projectRoot);
|
|
22955
|
-
const temporary =
|
|
23171
|
+
const temporary = path41.join(
|
|
22956
23172
|
directory,
|
|
22957
23173
|
`.snapshot.${process.pid}.${Date.now()}.tmp`
|
|
22958
23174
|
);
|
|
22959
|
-
await
|
|
23175
|
+
await writeFile35(temporary, `${JSON.stringify(cache, null, 2)}
|
|
22960
23176
|
`, {
|
|
22961
23177
|
encoding: "utf8",
|
|
22962
23178
|
flag: "wx"
|
|
@@ -23068,11 +23284,11 @@ function parseGitRefTeamCache(value) {
|
|
|
23068
23284
|
};
|
|
23069
23285
|
}
|
|
23070
23286
|
function gitRefCachePath(projectRoot) {
|
|
23071
|
-
return
|
|
23287
|
+
return path41.join(gitRefCacheDirectory(projectRoot), "snapshot.json");
|
|
23072
23288
|
}
|
|
23073
23289
|
function gitRefCacheDirectory(projectRoot) {
|
|
23074
|
-
return
|
|
23075
|
-
|
|
23290
|
+
return path41.join(
|
|
23291
|
+
path41.resolve(projectRoot),
|
|
23076
23292
|
".mancode",
|
|
23077
23293
|
"local",
|
|
23078
23294
|
"cache",
|
|
@@ -23118,10 +23334,10 @@ function parseReceiptOrNull(value) {
|
|
|
23118
23334
|
return value;
|
|
23119
23335
|
}
|
|
23120
23336
|
async function ensureSafeCacheDirectory(projectRoot) {
|
|
23121
|
-
const root =
|
|
23337
|
+
const root = path41.resolve(projectRoot);
|
|
23122
23338
|
let current = root;
|
|
23123
23339
|
for (const segment of [".mancode", "local", "cache", "git-ref"]) {
|
|
23124
|
-
current =
|
|
23340
|
+
current = path41.join(current, segment);
|
|
23125
23341
|
try {
|
|
23126
23342
|
await mkdir28(current);
|
|
23127
23343
|
} catch (error) {
|
|
@@ -23132,9 +23348,9 @@ async function ensureSafeCacheDirectory(projectRoot) {
|
|
|
23132
23348
|
return current;
|
|
23133
23349
|
}
|
|
23134
23350
|
async function assertSafeCacheDirectory(projectRoot) {
|
|
23135
|
-
let current =
|
|
23351
|
+
let current = path41.resolve(projectRoot);
|
|
23136
23352
|
for (const segment of [".mancode", "local", "cache", "git-ref"]) {
|
|
23137
|
-
current =
|
|
23353
|
+
current = path41.join(current, segment);
|
|
23138
23354
|
await assertDirectoryNotLinked(current);
|
|
23139
23355
|
}
|
|
23140
23356
|
}
|
|
@@ -23152,8 +23368,8 @@ function isAlreadyExists17(error) {
|
|
|
23152
23368
|
}
|
|
23153
23369
|
|
|
23154
23370
|
// src/team/git-ref-workflow-repair.ts
|
|
23155
|
-
import { lstat as lstat18, mkdir as mkdir32, readFile as readFile35, readdir as readdir17, writeFile as
|
|
23156
|
-
import
|
|
23371
|
+
import { lstat as lstat18, mkdir as mkdir32, readFile as readFile35, readdir as readdir17, writeFile as writeFile39 } from "fs/promises";
|
|
23372
|
+
import path45 from "path";
|
|
23157
23373
|
|
|
23158
23374
|
// src/team/git-ref-materialization.ts
|
|
23159
23375
|
import {
|
|
@@ -23162,14 +23378,14 @@ import {
|
|
|
23162
23378
|
readFile as readFile34,
|
|
23163
23379
|
readdir as readdir16,
|
|
23164
23380
|
unlink as unlink2,
|
|
23165
|
-
writeFile as
|
|
23381
|
+
writeFile as writeFile38
|
|
23166
23382
|
} from "fs/promises";
|
|
23167
|
-
import
|
|
23383
|
+
import path44 from "path";
|
|
23168
23384
|
|
|
23169
23385
|
// src/team/git-ref-bundle.ts
|
|
23170
23386
|
import { execFile as execFileCallback5 } from "child_process";
|
|
23171
|
-
import { lstat as lstat15, mkdir as mkdir29, readFile as readFile32, readdir as readdir15, writeFile as
|
|
23172
|
-
import
|
|
23387
|
+
import { lstat as lstat15, mkdir as mkdir29, readFile as readFile32, readdir as readdir15, writeFile as writeFile36 } from "fs/promises";
|
|
23388
|
+
import path42 from "path";
|
|
23173
23389
|
import { promisify as promisify5 } from "util";
|
|
23174
23390
|
var execFile5 = promisify5(execFileCallback5);
|
|
23175
23391
|
function createGitRefTaskBundle(input) {
|
|
@@ -23232,7 +23448,7 @@ async function assertGitRefBundleCodeReachable(projectRoot, bundle) {
|
|
|
23232
23448
|
"git",
|
|
23233
23449
|
["cat-file", "-e", `${parsed.codeRef.head}^{commit}`],
|
|
23234
23450
|
{
|
|
23235
|
-
cwd:
|
|
23451
|
+
cwd: path42.resolve(projectRoot),
|
|
23236
23452
|
windowsHide: true
|
|
23237
23453
|
}
|
|
23238
23454
|
);
|
|
@@ -23245,8 +23461,8 @@ async function quarantineGitRefTaskBundle(projectRoot, remoteRevision, bundle) {
|
|
|
23245
23461
|
throw new Error("MANCODE_TRANSPORT_REVISION_INVALID");
|
|
23246
23462
|
}
|
|
23247
23463
|
const parsed = parseGitRefTaskBundle(bundle);
|
|
23248
|
-
const directory =
|
|
23249
|
-
|
|
23464
|
+
const directory = path42.join(
|
|
23465
|
+
path42.resolve(projectRoot),
|
|
23250
23466
|
".mancode",
|
|
23251
23467
|
"local",
|
|
23252
23468
|
"quarantine",
|
|
@@ -23262,9 +23478,9 @@ async function quarantineGitRefTaskBundle(projectRoot, remoteRevision, bundle) {
|
|
|
23262
23478
|
parsed.taskRef.taskId,
|
|
23263
23479
|
String(remoteRevision)
|
|
23264
23480
|
]);
|
|
23265
|
-
const target =
|
|
23481
|
+
const target = path42.join(directory, `${parsed.bundleDigest.slice(7)}.json`);
|
|
23266
23482
|
try {
|
|
23267
|
-
await
|
|
23483
|
+
await writeFile36(target, `${JSON.stringify(parsed, null, 2)}
|
|
23268
23484
|
`, {
|
|
23269
23485
|
encoding: "utf8",
|
|
23270
23486
|
flag: "wx"
|
|
@@ -23279,8 +23495,8 @@ async function readQuarantinedGitRefTaskBundle(projectRoot, remoteRevision, task
|
|
|
23279
23495
|
throw new Error("MANCODE_TRANSPORT_REVISION_INVALID");
|
|
23280
23496
|
}
|
|
23281
23497
|
const parsedTaskRef = parseTaskRefValue(taskRef);
|
|
23282
|
-
const directory =
|
|
23283
|
-
|
|
23498
|
+
const directory = path42.join(
|
|
23499
|
+
path42.resolve(projectRoot),
|
|
23284
23500
|
".mancode",
|
|
23285
23501
|
"local",
|
|
23286
23502
|
"quarantine",
|
|
@@ -23306,7 +23522,7 @@ async function readQuarantinedGitRefTaskBundle(projectRoot, remoteRevision, task
|
|
|
23306
23522
|
const matches = [];
|
|
23307
23523
|
for (const entry of entries.sort()) {
|
|
23308
23524
|
if (!/^[a-f0-9]{64}\.json$/.test(entry)) continue;
|
|
23309
|
-
const target =
|
|
23525
|
+
const target = path42.join(directory, entry);
|
|
23310
23526
|
const before = await lstat15(target);
|
|
23311
23527
|
if (!before.isFile() || before.isSymbolicLink()) {
|
|
23312
23528
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
@@ -23343,9 +23559,9 @@ function parseCodeRef(value) {
|
|
|
23343
23559
|
return { branch: value.branch, head: value.head };
|
|
23344
23560
|
}
|
|
23345
23561
|
async function ensureFixedDirectory(projectRoot, segments) {
|
|
23346
|
-
let current =
|
|
23562
|
+
let current = path42.resolve(projectRoot);
|
|
23347
23563
|
for (const segment of segments) {
|
|
23348
|
-
current =
|
|
23564
|
+
current = path42.join(current, segment);
|
|
23349
23565
|
try {
|
|
23350
23566
|
await mkdir29(current);
|
|
23351
23567
|
} catch (error) {
|
|
@@ -23358,9 +23574,9 @@ async function ensureFixedDirectory(projectRoot, segments) {
|
|
|
23358
23574
|
}
|
|
23359
23575
|
}
|
|
23360
23576
|
async function assertFixedDirectory(projectRoot, segments) {
|
|
23361
|
-
let current =
|
|
23577
|
+
let current = path42.resolve(projectRoot);
|
|
23362
23578
|
for (const segment of segments) {
|
|
23363
|
-
current =
|
|
23579
|
+
current = path42.join(current, segment);
|
|
23364
23580
|
const entry = await lstat15(current);
|
|
23365
23581
|
if (!entry.isDirectory() || entry.isSymbolicLink()) {
|
|
23366
23582
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
@@ -23375,8 +23591,8 @@ function isNotFound23(error) {
|
|
|
23375
23591
|
}
|
|
23376
23592
|
|
|
23377
23593
|
// src/team/git-ref-task-base.ts
|
|
23378
|
-
import { lstat as lstat16, mkdir as mkdir30, readFile as readFile33, writeFile as
|
|
23379
|
-
import
|
|
23594
|
+
import { lstat as lstat16, mkdir as mkdir30, readFile as readFile33, writeFile as writeFile37 } from "fs/promises";
|
|
23595
|
+
import path43 from "path";
|
|
23380
23596
|
async function readGitRefTaskRemoteBase(projectRoot, taskRef) {
|
|
23381
23597
|
const parsedTaskRef = parseTaskRefValue(taskRef);
|
|
23382
23598
|
const runtime = await readProjectRuntimeContext(projectRoot);
|
|
@@ -23419,11 +23635,11 @@ async function recordGitRefTaskRemoteBase(projectRoot, remoteRevision, bundle) {
|
|
|
23419
23635
|
});
|
|
23420
23636
|
const directory = await ensureRemoteBaseDirectory(projectRoot);
|
|
23421
23637
|
const target = remoteBasePath(projectRoot, parsedBundle.taskRef);
|
|
23422
|
-
const temporary =
|
|
23638
|
+
const temporary = path43.join(
|
|
23423
23639
|
directory,
|
|
23424
23640
|
`.${parsedBundle.taskRef.taskId}.${process.pid}.${Date.now()}.tmp`
|
|
23425
23641
|
);
|
|
23426
|
-
await
|
|
23642
|
+
await writeFile37(temporary, `${JSON.stringify(state, null, 2)}
|
|
23427
23643
|
`, {
|
|
23428
23644
|
encoding: "utf8",
|
|
23429
23645
|
flag: "wx"
|
|
@@ -23456,7 +23672,7 @@ function parseGitRefTaskRemoteBase(value) {
|
|
|
23456
23672
|
};
|
|
23457
23673
|
}
|
|
23458
23674
|
async function ensureRemoteBaseDirectory(projectRoot) {
|
|
23459
|
-
let current =
|
|
23675
|
+
let current = path43.resolve(projectRoot);
|
|
23460
23676
|
for (const segment of [
|
|
23461
23677
|
".mancode",
|
|
23462
23678
|
"local",
|
|
@@ -23464,7 +23680,7 @@ async function ensureRemoteBaseDirectory(projectRoot) {
|
|
|
23464
23680
|
"git-ref",
|
|
23465
23681
|
"remote-bases"
|
|
23466
23682
|
]) {
|
|
23467
|
-
current =
|
|
23683
|
+
current = path43.join(current, segment);
|
|
23468
23684
|
try {
|
|
23469
23685
|
await mkdir30(current);
|
|
23470
23686
|
} catch (error) {
|
|
@@ -23478,7 +23694,7 @@ async function ensureRemoteBaseDirectory(projectRoot) {
|
|
|
23478
23694
|
return current;
|
|
23479
23695
|
}
|
|
23480
23696
|
async function assertRemoteBaseDirectory(projectRoot) {
|
|
23481
|
-
let current =
|
|
23697
|
+
let current = path43.resolve(projectRoot);
|
|
23482
23698
|
for (const segment of [
|
|
23483
23699
|
".mancode",
|
|
23484
23700
|
"local",
|
|
@@ -23486,7 +23702,7 @@ async function assertRemoteBaseDirectory(projectRoot) {
|
|
|
23486
23702
|
"git-ref",
|
|
23487
23703
|
"remote-bases"
|
|
23488
23704
|
]) {
|
|
23489
|
-
current =
|
|
23705
|
+
current = path43.join(current, segment);
|
|
23490
23706
|
const entry = await lstat16(current);
|
|
23491
23707
|
if (!entry.isDirectory() || entry.isSymbolicLink()) {
|
|
23492
23708
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
@@ -23495,8 +23711,8 @@ async function assertRemoteBaseDirectory(projectRoot) {
|
|
|
23495
23711
|
}
|
|
23496
23712
|
function remoteBasePath(projectRoot, taskRef) {
|
|
23497
23713
|
const parsed = parseTaskRefValue(taskRef);
|
|
23498
|
-
return
|
|
23499
|
-
|
|
23714
|
+
return path43.join(
|
|
23715
|
+
path43.resolve(projectRoot),
|
|
23500
23716
|
".mancode",
|
|
23501
23717
|
"local",
|
|
23502
23718
|
"cache",
|
|
@@ -23520,7 +23736,7 @@ function isNotFound24(error) {
|
|
|
23520
23736
|
|
|
23521
23737
|
// src/team/git-ref-materialization.ts
|
|
23522
23738
|
async function materializeGitRefTaskBundle(input) {
|
|
23523
|
-
const projectRoot =
|
|
23739
|
+
const projectRoot = path44.resolve(input.projectRoot);
|
|
23524
23740
|
const remoteRevision = positiveInteger3(
|
|
23525
23741
|
input.remoteRevision,
|
|
23526
23742
|
"git-ref materialization remoteRevision"
|
|
@@ -23826,7 +24042,7 @@ async function replaceVerifiedFile(taskRoot2, relativePath2, targetContent, pred
|
|
|
23826
24042
|
const target = safeTaskPath(taskRoot2, relativePath2);
|
|
23827
24043
|
await ensureSafeDirectory(
|
|
23828
24044
|
taskRoot2,
|
|
23829
|
-
|
|
24045
|
+
path44.dirname(relativePath2).split(path44.sep)
|
|
23830
24046
|
);
|
|
23831
24047
|
const current = await readSafeFileOrNull(target);
|
|
23832
24048
|
if (contentMatches(relativePath2, current, targetContent)) return;
|
|
@@ -23836,11 +24052,11 @@ async function replaceVerifiedFile(taskRoot2, relativePath2, targetContent, pred
|
|
|
23836
24052
|
if (current === null && (predecessorContent !== null || alternatePredecessorContent !== null) && relativePath2 !== "summary.md") {
|
|
23837
24053
|
throw new Error("MANCODE_SPLIT_BRAIN");
|
|
23838
24054
|
}
|
|
23839
|
-
const temporary =
|
|
23840
|
-
|
|
23841
|
-
`.${
|
|
24055
|
+
const temporary = path44.join(
|
|
24056
|
+
path44.dirname(target),
|
|
24057
|
+
`.${path44.basename(target)}.${process.pid}.${Date.now()}.tmp`
|
|
23842
24058
|
);
|
|
23843
|
-
await
|
|
24059
|
+
await writeFile38(temporary, targetContent, { encoding: "utf8", flag: "wx" });
|
|
23844
24060
|
await replaceFileAtomically(temporary, target);
|
|
23845
24061
|
}
|
|
23846
24062
|
function contentMatches(relativePath2, current, expected) {
|
|
@@ -23906,13 +24122,13 @@ async function readSafeFileOrNull(target) {
|
|
|
23906
24122
|
}
|
|
23907
24123
|
}
|
|
23908
24124
|
async function ensureSafeDirectory(root, segments) {
|
|
23909
|
-
let current =
|
|
24125
|
+
let current = path44.resolve(root);
|
|
23910
24126
|
for (const segment of segments) {
|
|
23911
24127
|
if (!segment || segment === ".") continue;
|
|
23912
24128
|
if (segment === ".." || segment.includes("/") || segment.includes("\\")) {
|
|
23913
24129
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
23914
24130
|
}
|
|
23915
|
-
current =
|
|
24131
|
+
current = path44.join(current, segment);
|
|
23916
24132
|
try {
|
|
23917
24133
|
await mkdir31(current);
|
|
23918
24134
|
} catch (error) {
|
|
@@ -23925,9 +24141,9 @@ async function ensureSafeDirectory(root, segments) {
|
|
|
23925
24141
|
}
|
|
23926
24142
|
}
|
|
23927
24143
|
function safeTaskPath(taskRoot2, relativePath2) {
|
|
23928
|
-
const target =
|
|
23929
|
-
const relative =
|
|
23930
|
-
if (!relative || relative.startsWith("..") ||
|
|
24144
|
+
const target = path44.resolve(taskRoot2, relativePath2);
|
|
24145
|
+
const relative = path44.relative(taskRoot2, target);
|
|
24146
|
+
if (!relative || relative.startsWith("..") || path44.isAbsolute(relative)) {
|
|
23931
24147
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
23932
24148
|
}
|
|
23933
24149
|
return target;
|
|
@@ -23939,7 +24155,7 @@ async function createJournal(projectRoot, journal) {
|
|
|
23939
24155
|
"journals",
|
|
23940
24156
|
"git-ref-materialize"
|
|
23941
24157
|
]);
|
|
23942
|
-
await
|
|
24158
|
+
await writeFile38(
|
|
23943
24159
|
journalPath(projectRoot, journal.operationId),
|
|
23944
24160
|
serialize11(journal),
|
|
23945
24161
|
{
|
|
@@ -23950,11 +24166,11 @@ async function createJournal(projectRoot, journal) {
|
|
|
23950
24166
|
}
|
|
23951
24167
|
async function replaceJournal(projectRoot, journal) {
|
|
23952
24168
|
const target = journalPath(projectRoot, journal.operationId);
|
|
23953
|
-
const temporary =
|
|
23954
|
-
|
|
24169
|
+
const temporary = path44.join(
|
|
24170
|
+
path44.dirname(target),
|
|
23955
24171
|
`.${journal.operationId}.${process.pid}.${Date.now()}.tmp`
|
|
23956
24172
|
);
|
|
23957
|
-
await
|
|
24173
|
+
await writeFile38(temporary, serialize11(journal), {
|
|
23958
24174
|
encoding: "utf8",
|
|
23959
24175
|
flag: "wx"
|
|
23960
24176
|
});
|
|
@@ -23983,7 +24199,7 @@ async function listJournals(projectRoot) {
|
|
|
23983
24199
|
const journals = [];
|
|
23984
24200
|
for (const entry of entries.sort()) {
|
|
23985
24201
|
if (!entry.endsWith(".json")) continue;
|
|
23986
|
-
journals.push(await readJournal(
|
|
24202
|
+
journals.push(await readJournal(path44.join(directory, entry)));
|
|
23987
24203
|
}
|
|
23988
24204
|
return journals;
|
|
23989
24205
|
}
|
|
@@ -24049,8 +24265,8 @@ function result(status2, bundle, localJournalPath, taskHeadFence) {
|
|
|
24049
24265
|
};
|
|
24050
24266
|
}
|
|
24051
24267
|
function journalDirectory(projectRoot) {
|
|
24052
|
-
return
|
|
24053
|
-
|
|
24268
|
+
return path44.join(
|
|
24269
|
+
path44.resolve(projectRoot),
|
|
24054
24270
|
".mancode",
|
|
24055
24271
|
"local",
|
|
24056
24272
|
"journals",
|
|
@@ -24059,7 +24275,7 @@ function journalDirectory(projectRoot) {
|
|
|
24059
24275
|
}
|
|
24060
24276
|
function journalPath(projectRoot, operationId) {
|
|
24061
24277
|
assertUlid(operationId, "git-ref materialization operationId");
|
|
24062
|
-
return
|
|
24278
|
+
return path44.join(journalDirectory(projectRoot), `${operationId}.json`);
|
|
24063
24279
|
}
|
|
24064
24280
|
function serialize11(value) {
|
|
24065
24281
|
return `${JSON.stringify(value, null, 2)}
|
|
@@ -24095,7 +24311,7 @@ function isNotFound25(error) {
|
|
|
24095
24311
|
|
|
24096
24312
|
// src/team/git-ref-workflow-repair.ts
|
|
24097
24313
|
async function prepareGitRefWorkflowRepair(input) {
|
|
24098
|
-
const root =
|
|
24314
|
+
const root = path45.resolve(input.projectRoot);
|
|
24099
24315
|
const prepared2 = parsePrepared(input.prepared);
|
|
24100
24316
|
const pendingMetadata = parseWorkflowMetadata(input.pendingMetadata);
|
|
24101
24317
|
assertPendingMetadata2(prepared2, pendingMetadata);
|
|
@@ -24130,7 +24346,7 @@ async function prepareGitRefWorkflowRepair(input) {
|
|
|
24130
24346
|
}
|
|
24131
24347
|
async function recoverGitRefWorkflowRepair(projectRoot, operationId, transportReceipt = null, options = {}) {
|
|
24132
24348
|
assertUlid(operationId, "git-ref workflow repair operationId");
|
|
24133
|
-
const root =
|
|
24349
|
+
const root = path45.resolve(projectRoot);
|
|
24134
24350
|
let journal = await requireJournal(root, operationId);
|
|
24135
24351
|
await assertRecoveryAuthorized(root, journal, options);
|
|
24136
24352
|
if (journal.state === "committed" || journal.state === "aborted") {
|
|
@@ -24497,7 +24713,7 @@ async function createJournal2(projectRoot, journal) {
|
|
|
24497
24713
|
await ensureJournalDirectory(projectRoot);
|
|
24498
24714
|
const target = gitRefWorkflowRepairJournalPath(projectRoot, journal.operationId);
|
|
24499
24715
|
try {
|
|
24500
|
-
await
|
|
24716
|
+
await writeFile39(target, serialize12(journal), {
|
|
24501
24717
|
encoding: "utf8",
|
|
24502
24718
|
flag: "wx"
|
|
24503
24719
|
});
|
|
@@ -24537,7 +24753,7 @@ function metadataFromBundle(bundle) {
|
|
|
24537
24753
|
return parseWorkflowMetadata(artifact2.content);
|
|
24538
24754
|
}
|
|
24539
24755
|
function metadataPath2(projectRoot, taskRef) {
|
|
24540
|
-
return
|
|
24756
|
+
return path45.join(taskRootPath(projectRoot, taskRef), "metadata.json");
|
|
24541
24757
|
}
|
|
24542
24758
|
async function readSafeFile(target) {
|
|
24543
24759
|
const before = await lstat18(target);
|
|
@@ -24552,17 +24768,17 @@ async function readSafeFile(target) {
|
|
|
24552
24768
|
return content;
|
|
24553
24769
|
}
|
|
24554
24770
|
async function atomicWrite(target, content) {
|
|
24555
|
-
const temporary =
|
|
24556
|
-
|
|
24557
|
-
`.${
|
|
24771
|
+
const temporary = path45.join(
|
|
24772
|
+
path45.dirname(target),
|
|
24773
|
+
`.${path45.basename(target)}.${process.pid}.${Date.now()}.tmp`
|
|
24558
24774
|
);
|
|
24559
|
-
await
|
|
24775
|
+
await writeFile39(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
24560
24776
|
await replaceFileAtomically(temporary, target);
|
|
24561
24777
|
}
|
|
24562
24778
|
async function ensureJournalDirectory(projectRoot) {
|
|
24563
|
-
let current =
|
|
24779
|
+
let current = path45.resolve(projectRoot);
|
|
24564
24780
|
for (const segment of [".mancode", "local", "journals", "git-ref-workflow"]) {
|
|
24565
|
-
current =
|
|
24781
|
+
current = path45.join(current, segment);
|
|
24566
24782
|
try {
|
|
24567
24783
|
await mkdir32(current);
|
|
24568
24784
|
} catch (error) {
|
|
@@ -25307,7 +25523,7 @@ function parseExpectedRevision2(value) {
|
|
|
25307
25523
|
|
|
25308
25524
|
// src/commands/design.ts
|
|
25309
25525
|
import { readFile as readFile37, stat as stat4 } from "fs/promises";
|
|
25310
|
-
import
|
|
25526
|
+
import path47 from "path";
|
|
25311
25527
|
import process2 from "process";
|
|
25312
25528
|
|
|
25313
25529
|
// src/context/design-policy.ts
|
|
@@ -25317,9 +25533,9 @@ import {
|
|
|
25317
25533
|
readFile as readFile36,
|
|
25318
25534
|
realpath as realpath2,
|
|
25319
25535
|
rm as rm17,
|
|
25320
|
-
writeFile as
|
|
25536
|
+
writeFile as writeFile40
|
|
25321
25537
|
} from "fs/promises";
|
|
25322
|
-
import
|
|
25538
|
+
import path46 from "path";
|
|
25323
25539
|
var DEFAULT_DESIGN_POLICY = {
|
|
25324
25540
|
schemaVersion: 1,
|
|
25325
25541
|
revision: 0,
|
|
@@ -25333,8 +25549,8 @@ var DEFAULT_DESIGN_POLICY = {
|
|
|
25333
25549
|
updatedAt: "1970-01-01T00:00:00.000Z"
|
|
25334
25550
|
};
|
|
25335
25551
|
function designPolicyPath(projectRoot) {
|
|
25336
|
-
return
|
|
25337
|
-
|
|
25552
|
+
return path46.join(
|
|
25553
|
+
path46.resolve(projectRoot),
|
|
25338
25554
|
".mancode",
|
|
25339
25555
|
"shared",
|
|
25340
25556
|
"context",
|
|
@@ -25422,7 +25638,7 @@ async function configureDesignPolicy(input) {
|
|
|
25422
25638
|
const operationId = input.operationId ?? createUlid();
|
|
25423
25639
|
assertUlid(operationId, "design policy operationId");
|
|
25424
25640
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
25425
|
-
const root =
|
|
25641
|
+
const root = path46.resolve(input.projectRoot);
|
|
25426
25642
|
const runtime = await readProjectRuntimeContext(root);
|
|
25427
25643
|
const store = resolveCoordinationEntityHomeStore(
|
|
25428
25644
|
runtime.entityHomeStoreContext
|
|
@@ -25477,12 +25693,12 @@ function isDesignBrowserValidation(value) {
|
|
|
25477
25693
|
}
|
|
25478
25694
|
async function writeDesignPolicy(projectRoot, policy) {
|
|
25479
25695
|
const target = designPolicyPath(projectRoot);
|
|
25480
|
-
await mkdir33(
|
|
25481
|
-
const temporary =
|
|
25482
|
-
|
|
25483
|
-
`.${
|
|
25696
|
+
await mkdir33(path46.dirname(target), { recursive: true });
|
|
25697
|
+
const temporary = path46.join(
|
|
25698
|
+
path46.dirname(target),
|
|
25699
|
+
`.${path46.basename(target)}.${process.pid}.${Date.now()}.tmp`
|
|
25484
25700
|
);
|
|
25485
|
-
await
|
|
25701
|
+
await writeFile40(temporary, `${JSON.stringify(policy, null, 2)}
|
|
25486
25702
|
`, {
|
|
25487
25703
|
encoding: "utf8",
|
|
25488
25704
|
flag: "wx"
|
|
@@ -25494,13 +25710,13 @@ async function writeDesignPolicy(projectRoot, policy) {
|
|
|
25494
25710
|
}
|
|
25495
25711
|
}
|
|
25496
25712
|
async function assertDesignPolicyPathSafe(projectRoot) {
|
|
25497
|
-
const root =
|
|
25713
|
+
const root = path46.resolve(projectRoot);
|
|
25498
25714
|
const policyPath = designPolicyPath(root);
|
|
25499
|
-
const contextDir =
|
|
25715
|
+
const contextDir = path46.dirname(policyPath);
|
|
25500
25716
|
try {
|
|
25501
25717
|
for (const directory of [
|
|
25502
|
-
|
|
25503
|
-
|
|
25718
|
+
path46.join(root, ".mancode"),
|
|
25719
|
+
path46.join(root, ".mancode", "shared"),
|
|
25504
25720
|
contextDir
|
|
25505
25721
|
]) {
|
|
25506
25722
|
const info = await lstat19(directory);
|
|
@@ -25512,8 +25728,8 @@ async function assertDesignPolicyPathSafe(projectRoot) {
|
|
|
25512
25728
|
realpath2(root),
|
|
25513
25729
|
realpath2(contextDir)
|
|
25514
25730
|
]);
|
|
25515
|
-
const relative =
|
|
25516
|
-
if (
|
|
25731
|
+
const relative = path46.relative(resolvedRoot, resolvedContextDir);
|
|
25732
|
+
if (path46.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path46.sep}`)) {
|
|
25517
25733
|
throw new Error("MANCODE_DESIGN_POLICY_PATH_UNSAFE");
|
|
25518
25734
|
}
|
|
25519
25735
|
try {
|
|
@@ -25757,7 +25973,7 @@ async function readProfile(rootDir, kind) {
|
|
|
25757
25973
|
try {
|
|
25758
25974
|
return JSON.parse(
|
|
25759
25975
|
await readFile37(
|
|
25760
|
-
|
|
25976
|
+
path47.join(rootDir, ".mancode", "project-profile.json"),
|
|
25761
25977
|
"utf8"
|
|
25762
25978
|
)
|
|
25763
25979
|
);
|
|
@@ -25766,7 +25982,7 @@ async function readProfile(rootDir, kind) {
|
|
|
25766
25982
|
}
|
|
25767
25983
|
}
|
|
25768
25984
|
async function readStyleSummary(rootDir, kind) {
|
|
25769
|
-
const cachePath = kind === "continuity" ?
|
|
25985
|
+
const cachePath = kind === "continuity" ? path47.join(rootDir, ".mancode", "local", "cache", "style-tokens.json") : path47.join(rootDir, ".mancode", "aesthetics", "style-tokens.json");
|
|
25770
25986
|
try {
|
|
25771
25987
|
const raw = JSON.parse(await readFile37(cachePath, "utf8"));
|
|
25772
25988
|
return sanitizeStyleSummary(rootDir, raw);
|
|
@@ -25807,7 +26023,7 @@ async function styleFreshness(rootDir, scopeRoot, lastScanned, sourceFiles) {
|
|
|
25807
26023
|
const scannedAt = Date.parse(lastScanned);
|
|
25808
26024
|
for (const file of sourceFiles) {
|
|
25809
26025
|
try {
|
|
25810
|
-
const info = await stat4(
|
|
26026
|
+
const info = await stat4(path47.resolve(rootDir, scopeRoot, file));
|
|
25811
26027
|
if (info.mtimeMs > scannedAt) return "stale";
|
|
25812
26028
|
} catch {
|
|
25813
26029
|
return "stale";
|
|
@@ -25877,10 +26093,10 @@ function emptyStyleSummary() {
|
|
|
25877
26093
|
};
|
|
25878
26094
|
}
|
|
25879
26095
|
async function initializedKind(rootDir) {
|
|
25880
|
-
if (await exists(
|
|
26096
|
+
if (await exists(path47.join(rootDir, ".mancode", "schema.json"))) {
|
|
25881
26097
|
return "continuity";
|
|
25882
26098
|
}
|
|
25883
|
-
if (await exists(
|
|
26099
|
+
if (await exists(path47.join(rootDir, ".mancode", "state.json")))
|
|
25884
26100
|
return "legacy";
|
|
25885
26101
|
return null;
|
|
25886
26102
|
}
|
|
@@ -25945,7 +26161,7 @@ function safeShortText(value) {
|
|
|
25945
26161
|
return typeof value === "string" && value.length <= 100 && /^[A-Za-z0-9@/_. -]+$/.test(value) ? value : null;
|
|
25946
26162
|
}
|
|
25947
26163
|
function isSafeRelativeFile(value) {
|
|
25948
|
-
return value.length <= 240 && !
|
|
26164
|
+
return value.length <= 240 && !path47.isAbsolute(value) && !value.includes("\0") && value.split(/[\\/]/).every((part) => part !== "" && part !== "." && part !== "..");
|
|
25949
26165
|
}
|
|
25950
26166
|
function parseNonNegativeInteger2(value) {
|
|
25951
26167
|
if (value === void 0 || !/^\d+$/.test(value)) return null;
|
|
@@ -25953,7 +26169,7 @@ function parseNonNegativeInteger2(value) {
|
|
|
25953
26169
|
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
25954
26170
|
}
|
|
25955
26171
|
function relativePath(rootDir, target) {
|
|
25956
|
-
return
|
|
26172
|
+
return path47.relative(path47.resolve(rootDir), target).split(path47.sep).join("/");
|
|
25957
26173
|
}
|
|
25958
26174
|
function isRecord6(value) {
|
|
25959
26175
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -25985,12 +26201,12 @@ function errorCode3(error, fallback) {
|
|
|
25985
26201
|
// src/commands/init.ts
|
|
25986
26202
|
import { promises as fs4 } from "fs";
|
|
25987
26203
|
import os from "os";
|
|
25988
|
-
import
|
|
26204
|
+
import path53 from "path";
|
|
25989
26205
|
import process6 from "process";
|
|
25990
26206
|
|
|
25991
26207
|
// src/installers/platform-status.ts
|
|
25992
26208
|
import { promises as fs } from "fs";
|
|
25993
|
-
import
|
|
26209
|
+
import path48 from "path";
|
|
25994
26210
|
async function checkPlatformStatus(rootDir, platform, installed) {
|
|
25995
26211
|
const readiness = await checkPlatformReadiness(rootDir, platform);
|
|
25996
26212
|
return {
|
|
@@ -26007,13 +26223,13 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26007
26223
|
if (platform === "claude-code") {
|
|
26008
26224
|
const [hasSoloSkill, registered, hasHookFiles] = await Promise.all([
|
|
26009
26225
|
fileMatches(
|
|
26010
|
-
|
|
26226
|
+
path48.join(rootDir, ".claude", "skills", "solo", "SKILL.md"),
|
|
26011
26227
|
(content) => isGeneratedClaudeSkill(content, "solo")
|
|
26012
26228
|
),
|
|
26013
26229
|
claudeHooksRegistered(rootDir),
|
|
26014
26230
|
pathsExist([
|
|
26015
|
-
|
|
26016
|
-
|
|
26231
|
+
path48.join(rootDir, ".mancode", "hooks", "session-start.mjs"),
|
|
26232
|
+
path48.join(rootDir, ".mancode", "hooks", "user-prompt-submit.mjs")
|
|
26017
26233
|
])
|
|
26018
26234
|
]);
|
|
26019
26235
|
const present = hasSoloSkill && registered && hasHookFiles;
|
|
@@ -26029,7 +26245,7 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26029
26245
|
if (platform === "cursor") {
|
|
26030
26246
|
const hasCoreRules = await allManagedSkills(
|
|
26031
26247
|
MANCODE_CURSOR_CORE_RULE_FILES.map(
|
|
26032
|
-
(file) =>
|
|
26248
|
+
(file) => path48.join(rootDir, ".cursor", "rules", file)
|
|
26033
26249
|
),
|
|
26034
26250
|
[CURSOR_RULE_MANAGED_MARKER]
|
|
26035
26251
|
);
|
|
@@ -26044,13 +26260,13 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26044
26260
|
const [hasRules, hasCommands] = await Promise.all([
|
|
26045
26261
|
allManagedSkills(
|
|
26046
26262
|
MANCODE_CURSOR_RULE_FILES.map(
|
|
26047
|
-
(file) =>
|
|
26263
|
+
(file) => path48.join(rootDir, ".cursor", "rules", file)
|
|
26048
26264
|
),
|
|
26049
26265
|
[CURSOR_RULE_MANAGED_MARKER]
|
|
26050
26266
|
),
|
|
26051
26267
|
allManagedSkills(
|
|
26052
26268
|
MODE_NAMES.map(
|
|
26053
|
-
(mode) =>
|
|
26269
|
+
(mode) => path48.join(rootDir, ".cursor", "commands", `${mode}.md`)
|
|
26054
26270
|
),
|
|
26055
26271
|
[MODE_FILE_MANAGED_MARKER]
|
|
26056
26272
|
)
|
|
@@ -26063,7 +26279,7 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26063
26279
|
};
|
|
26064
26280
|
}
|
|
26065
26281
|
if (platform === "codex") {
|
|
26066
|
-
const hasBlock2 = await fileHasManagedBlock(
|
|
26282
|
+
const hasBlock2 = await fileHasManagedBlock(path48.join(rootDir, "AGENTS.md"));
|
|
26067
26283
|
if (!hasBlock2) {
|
|
26068
26284
|
return {
|
|
26069
26285
|
present: false,
|
|
@@ -26080,9 +26296,9 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26080
26296
|
readyDetail: "managed block present"
|
|
26081
26297
|
};
|
|
26082
26298
|
}
|
|
26083
|
-
const skillsDir =
|
|
26299
|
+
const skillsDir = path48.join(rootDir, ".agents", "skills");
|
|
26084
26300
|
const hasSkills = await allManagedSkills(
|
|
26085
|
-
MODE_NAMES.map((mode) =>
|
|
26301
|
+
MODE_NAMES.map((mode) => path48.join(skillsDir, mode, "SKILL.md")),
|
|
26086
26302
|
MANCODE_AGENT_SKILL_MARKERS
|
|
26087
26303
|
);
|
|
26088
26304
|
return {
|
|
@@ -26094,7 +26310,7 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26094
26310
|
}
|
|
26095
26311
|
if (platform === "zcode") {
|
|
26096
26312
|
const hasBlock2 = await fileHasManagedBlock(
|
|
26097
|
-
|
|
26313
|
+
path48.join(rootDir, "AGENTS.md"),
|
|
26098
26314
|
ZCODE_MANCODE_START_MARKER,
|
|
26099
26315
|
ZCODE_MANCODE_END_MARKER
|
|
26100
26316
|
);
|
|
@@ -26114,9 +26330,43 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26114
26330
|
readyDetail: "managed block present"
|
|
26115
26331
|
};
|
|
26116
26332
|
}
|
|
26117
|
-
const skillsDir =
|
|
26333
|
+
const skillsDir = path48.join(rootDir, ".agents", "skills");
|
|
26334
|
+
const hasSkills = await allManagedSkills(
|
|
26335
|
+
MODE_NAMES.map((mode) => path48.join(skillsDir, mode, "SKILL.md")),
|
|
26336
|
+
MANCODE_AGENT_SKILL_MARKERS
|
|
26337
|
+
);
|
|
26338
|
+
return {
|
|
26339
|
+
present: true,
|
|
26340
|
+
ready: hasSkills,
|
|
26341
|
+
target: "AGENTS.md + .agents/skills/",
|
|
26342
|
+
readyDetail: hasSkills ? "managed block and skills present" : "mode skills are missing, incomplete, or user-authored"
|
|
26343
|
+
};
|
|
26344
|
+
}
|
|
26345
|
+
if (platform === "kimi-code") {
|
|
26346
|
+
const hasBlock2 = await fileHasManagedBlock(
|
|
26347
|
+
path48.join(rootDir, "AGENTS.md"),
|
|
26348
|
+
KIMI_MANCODE_START_MARKER,
|
|
26349
|
+
KIMI_MANCODE_END_MARKER
|
|
26350
|
+
);
|
|
26351
|
+
if (!hasBlock2) {
|
|
26352
|
+
return {
|
|
26353
|
+
present: false,
|
|
26354
|
+
ready: false,
|
|
26355
|
+
target: "AGENTS.md",
|
|
26356
|
+
readyDetail: "managed block missing"
|
|
26357
|
+
};
|
|
26358
|
+
}
|
|
26359
|
+
if (await isPlatformMinimal(rootDir, "kimi-code")) {
|
|
26360
|
+
return {
|
|
26361
|
+
present: true,
|
|
26362
|
+
ready: true,
|
|
26363
|
+
target: "AGENTS.md",
|
|
26364
|
+
readyDetail: "managed block present"
|
|
26365
|
+
};
|
|
26366
|
+
}
|
|
26367
|
+
const skillsDir = path48.join(rootDir, ".agents", "skills");
|
|
26118
26368
|
const hasSkills = await allManagedSkills(
|
|
26119
|
-
MODE_NAMES.map((mode) =>
|
|
26369
|
+
MODE_NAMES.map((mode) => path48.join(skillsDir, mode, "SKILL.md")),
|
|
26120
26370
|
MANCODE_AGENT_SKILL_MARKERS
|
|
26121
26371
|
);
|
|
26122
26372
|
return {
|
|
@@ -26126,8 +26376,42 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26126
26376
|
readyDetail: hasSkills ? "managed block and skills present" : "mode skills are missing, incomplete, or user-authored"
|
|
26127
26377
|
};
|
|
26128
26378
|
}
|
|
26379
|
+
if (platform === "qoder") {
|
|
26380
|
+
const hasBlock2 = await fileHasManagedBlock(
|
|
26381
|
+
path48.join(rootDir, "AGENTS.md"),
|
|
26382
|
+
QODER_MANCODE_START_MARKER,
|
|
26383
|
+
QODER_MANCODE_END_MARKER
|
|
26384
|
+
);
|
|
26385
|
+
if (!hasBlock2) {
|
|
26386
|
+
return {
|
|
26387
|
+
present: false,
|
|
26388
|
+
ready: false,
|
|
26389
|
+
target: "AGENTS.md",
|
|
26390
|
+
readyDetail: "managed block missing"
|
|
26391
|
+
};
|
|
26392
|
+
}
|
|
26393
|
+
if (await isPlatformMinimal(rootDir, "qoder")) {
|
|
26394
|
+
return {
|
|
26395
|
+
present: true,
|
|
26396
|
+
ready: true,
|
|
26397
|
+
target: "AGENTS.md",
|
|
26398
|
+
readyDetail: "managed block present"
|
|
26399
|
+
};
|
|
26400
|
+
}
|
|
26401
|
+
const commandsDir = path48.join(rootDir, ".qoder", "commands");
|
|
26402
|
+
const hasCommands = await allManagedSkills(
|
|
26403
|
+
MODE_NAMES.map((mode) => path48.join(commandsDir, `${mode}.md`)),
|
|
26404
|
+
[MODE_FILE_MANAGED_MARKER]
|
|
26405
|
+
);
|
|
26406
|
+
return {
|
|
26407
|
+
present: true,
|
|
26408
|
+
ready: hasCommands,
|
|
26409
|
+
target: "AGENTS.md + .qoder/commands/",
|
|
26410
|
+
readyDetail: hasCommands ? "managed block and commands present" : "mode commands are missing, incomplete, or user-authored"
|
|
26411
|
+
};
|
|
26412
|
+
}
|
|
26129
26413
|
const hasBlock = await fileHasManagedBlock(
|
|
26130
|
-
|
|
26414
|
+
path48.join(rootDir, ".github", "copilot-instructions.md")
|
|
26131
26415
|
);
|
|
26132
26416
|
if (!hasBlock) {
|
|
26133
26417
|
return {
|
|
@@ -26138,9 +26422,9 @@ async function checkPlatformReadiness(rootDir, platform) {
|
|
|
26138
26422
|
};
|
|
26139
26423
|
}
|
|
26140
26424
|
if (!await isPlatformMinimal(rootDir, "copilot")) {
|
|
26141
|
-
const promptsDir =
|
|
26425
|
+
const promptsDir = path48.join(rootDir, ".github", "prompts");
|
|
26142
26426
|
const hasPrompts = await allManagedSkills(
|
|
26143
|
-
MODE_NAMES.map((mode) =>
|
|
26427
|
+
MODE_NAMES.map((mode) => path48.join(promptsDir, `${mode}.prompt.md`)),
|
|
26144
26428
|
[MODE_FILE_MANAGED_MARKER]
|
|
26145
26429
|
);
|
|
26146
26430
|
return {
|
|
@@ -26173,13 +26457,13 @@ async function allManagedSkills(paths, markers) {
|
|
|
26173
26457
|
async function claudeFullContentReady(rootDir) {
|
|
26174
26458
|
const skillChecks = MVP2_SKILLS.map(
|
|
26175
26459
|
(skill) => fileMatches(
|
|
26176
|
-
|
|
26460
|
+
path48.join(rootDir, ".claude", "skills", skill.name, "SKILL.md"),
|
|
26177
26461
|
(content) => isGeneratedClaudeSkill(content, skill.name)
|
|
26178
26462
|
)
|
|
26179
26463
|
);
|
|
26180
26464
|
const agentChecks = ALL_AGENTS.map(
|
|
26181
26465
|
(agent) => fileMatches(
|
|
26182
|
-
|
|
26466
|
+
path48.join(rootDir, ".claude", "agents", `${agent.name}.md`),
|
|
26183
26467
|
(content) => isGeneratedClaudeAgent(content, agent.name)
|
|
26184
26468
|
)
|
|
26185
26469
|
);
|
|
@@ -26207,7 +26491,7 @@ async function fileHasAnyMarker(filePath, needles) {
|
|
|
26207
26491
|
async function isPlatformMinimal(rootDir, platform) {
|
|
26208
26492
|
try {
|
|
26209
26493
|
const raw = await fs.readFile(
|
|
26210
|
-
|
|
26494
|
+
path48.join(rootDir, ".mancode", "config.json"),
|
|
26211
26495
|
"utf-8"
|
|
26212
26496
|
);
|
|
26213
26497
|
const config = JSON.parse(raw);
|
|
@@ -26229,7 +26513,7 @@ async function fileHasManagedBlock(filePath, startMarker = DEFAULT_MANCODE_START
|
|
|
26229
26513
|
async function claudeHooksRegistered(rootDir) {
|
|
26230
26514
|
try {
|
|
26231
26515
|
const raw = await fs.readFile(
|
|
26232
|
-
|
|
26516
|
+
path48.join(rootDir, ".claude", "settings.json"),
|
|
26233
26517
|
"utf-8"
|
|
26234
26518
|
);
|
|
26235
26519
|
const settings = JSON.parse(raw);
|
|
@@ -26272,7 +26556,7 @@ function isRecord7(value) {
|
|
|
26272
26556
|
// src/system/detect-team.ts
|
|
26273
26557
|
import { execFile as execFile6 } from "child_process";
|
|
26274
26558
|
import { access as access2 } from "fs/promises";
|
|
26275
|
-
import
|
|
26559
|
+
import path49 from "path";
|
|
26276
26560
|
import process3 from "process";
|
|
26277
26561
|
import { promisify as promisify6 } from "util";
|
|
26278
26562
|
var execFileAsync = promisify6(execFile6);
|
|
@@ -26382,7 +26666,7 @@ async function anyPathExists(projectRoot, candidates) {
|
|
|
26382
26666
|
const results = await Promise.all(
|
|
26383
26667
|
candidates.map(async (candidate) => {
|
|
26384
26668
|
try {
|
|
26385
|
-
await access2(
|
|
26669
|
+
await access2(path49.join(projectRoot, candidate));
|
|
26386
26670
|
return true;
|
|
26387
26671
|
} catch {
|
|
26388
26672
|
return false;
|
|
@@ -26423,7 +26707,7 @@ async function detectSystemDeps(env = process4.env) {
|
|
|
26423
26707
|
// src/system/init-onboarding.ts
|
|
26424
26708
|
import { execFileSync } from "child_process";
|
|
26425
26709
|
import { promises as fs2 } from "fs";
|
|
26426
|
-
import
|
|
26710
|
+
import path50 from "path";
|
|
26427
26711
|
import process5 from "process";
|
|
26428
26712
|
import { stdin, stdout } from "process";
|
|
26429
26713
|
import { createInterface } from "readline/promises";
|
|
@@ -26528,7 +26812,7 @@ async function detectPlatformHints(rootDir, environment = process5.env) {
|
|
|
26528
26812
|
hints.add("copilot");
|
|
26529
26813
|
const exists2 = async (relative) => {
|
|
26530
26814
|
try {
|
|
26531
|
-
await fs2.access(
|
|
26815
|
+
await fs2.access(path50.join(rootDir, relative));
|
|
26532
26816
|
return true;
|
|
26533
26817
|
} catch {
|
|
26534
26818
|
return false;
|
|
@@ -26537,6 +26821,7 @@ async function detectPlatformHints(rootDir, environment = process5.env) {
|
|
|
26537
26821
|
if (await exists2(".claude")) hints.add("claude-code");
|
|
26538
26822
|
if (await exists2(".cursor")) hints.add("cursor");
|
|
26539
26823
|
if (await exists2(".github/copilot-instructions.md")) hints.add("copilot");
|
|
26824
|
+
if (await exists2(".qoder")) hints.add("qoder");
|
|
26540
26825
|
return ALL_PLATFORMS.filter((platform) => hints.has(platform));
|
|
26541
26826
|
}
|
|
26542
26827
|
function createTerminalPrompter() {
|
|
@@ -26604,7 +26889,7 @@ function createTerminalPrompter() {
|
|
|
26604
26889
|
|
|
26605
26890
|
// src/system/scan-aesthetics.ts
|
|
26606
26891
|
import { promises as fs3 } from "fs";
|
|
26607
|
-
import
|
|
26892
|
+
import path51 from "path";
|
|
26608
26893
|
var MAX_COMPONENT_SCAN_DEPTH = 12;
|
|
26609
26894
|
var MAX_COMPONENT_FILES = 2e3;
|
|
26610
26895
|
async function scanAesthetics(projectRoot, uiLibrary = null, scopeRoot = ".") {
|
|
@@ -26640,7 +26925,7 @@ async function scanAesthetics(projectRoot, uiLibrary = null, scopeRoot = ".") {
|
|
|
26640
26925
|
} else if (await hasTailwindDep(projectRoot) || uiLibrary) {
|
|
26641
26926
|
matchLevel = "low";
|
|
26642
26927
|
}
|
|
26643
|
-
if (uiLibrary && await pathExists5(
|
|
26928
|
+
if (uiLibrary && await pathExists5(path51.join(projectRoot, "package.json"))) {
|
|
26644
26929
|
sourceFiles.push("package.json");
|
|
26645
26930
|
}
|
|
26646
26931
|
sourceFiles.push(...cssScan.sourceFiles);
|
|
@@ -26666,7 +26951,7 @@ async function findTailwindConfig(projectRoot) {
|
|
|
26666
26951
|
"tailwind.config.mjs"
|
|
26667
26952
|
];
|
|
26668
26953
|
for (const name of candidates) {
|
|
26669
|
-
const absPath =
|
|
26954
|
+
const absPath = path51.join(projectRoot, name);
|
|
26670
26955
|
if (await pathExists5(absPath)) {
|
|
26671
26956
|
return { absPath, relPath: name };
|
|
26672
26957
|
}
|
|
@@ -26893,7 +27178,7 @@ async function scanComponents(projectRoot) {
|
|
|
26893
27178
|
const names = /* @__PURE__ */ new Set();
|
|
26894
27179
|
let visitedFiles = 0;
|
|
26895
27180
|
for (const relRoot of roots) {
|
|
26896
|
-
const absRoot =
|
|
27181
|
+
const absRoot = path51.join(projectRoot, relRoot);
|
|
26897
27182
|
if (!await pathExists5(absRoot)) continue;
|
|
26898
27183
|
visitedFiles = await collectComponentNames(absRoot, names, 0, visitedFiles);
|
|
26899
27184
|
if (visitedFiles >= MAX_COMPONENT_FILES) break;
|
|
@@ -26913,7 +27198,7 @@ async function collectComponentNames(dir, names, depth, visitedFiles) {
|
|
|
26913
27198
|
}
|
|
26914
27199
|
for (const entry of entries) {
|
|
26915
27200
|
if (fileCount >= MAX_COMPONENT_FILES) return fileCount;
|
|
26916
|
-
const abs =
|
|
27201
|
+
const abs = path51.join(dir, entry);
|
|
26917
27202
|
let info;
|
|
26918
27203
|
try {
|
|
26919
27204
|
info = await fs3.lstat(abs);
|
|
@@ -26934,7 +27219,7 @@ async function collectComponentNames(dir, names, depth, visitedFiles) {
|
|
|
26934
27219
|
""
|
|
26935
27220
|
);
|
|
26936
27221
|
if (base === "index") {
|
|
26937
|
-
base =
|
|
27222
|
+
base = path51.basename(dir);
|
|
26938
27223
|
}
|
|
26939
27224
|
if (base.startsWith(".")) continue;
|
|
26940
27225
|
const componentName = toPascalCase(base);
|
|
@@ -26956,7 +27241,7 @@ async function scanCssVariables(projectRoot) {
|
|
|
26956
27241
|
const variables = {};
|
|
26957
27242
|
const sourceFiles = [];
|
|
26958
27243
|
for (const relPath of candidates) {
|
|
26959
|
-
const absPath =
|
|
27244
|
+
const absPath = path51.join(projectRoot, relPath);
|
|
26960
27245
|
if (!await pathExists5(absPath)) continue;
|
|
26961
27246
|
const content = await fs3.readFile(absPath, "utf-8");
|
|
26962
27247
|
const found = extractCssVariables(content);
|
|
@@ -27002,7 +27287,7 @@ function toPascalCase(value) {
|
|
|
27002
27287
|
async function hasTailwindDep(projectRoot) {
|
|
27003
27288
|
try {
|
|
27004
27289
|
const raw = await fs3.readFile(
|
|
27005
|
-
|
|
27290
|
+
path51.join(projectRoot, "package.json"),
|
|
27006
27291
|
"utf-8"
|
|
27007
27292
|
);
|
|
27008
27293
|
const pkg = JSON.parse(raw);
|
|
@@ -27032,10 +27317,10 @@ import {
|
|
|
27032
27317
|
readFile as readFile38,
|
|
27033
27318
|
rename as rename10,
|
|
27034
27319
|
rm as rm18,
|
|
27035
|
-
writeFile as
|
|
27320
|
+
writeFile as writeFile41
|
|
27036
27321
|
} from "fs/promises";
|
|
27037
|
-
import
|
|
27038
|
-
var JOURNAL_RELATIVE_DIRECTORY =
|
|
27322
|
+
import path52 from "path";
|
|
27323
|
+
var JOURNAL_RELATIVE_DIRECTORY = path52.join(
|
|
27039
27324
|
"local",
|
|
27040
27325
|
"runtime",
|
|
27041
27326
|
"initialization"
|
|
@@ -27084,7 +27369,7 @@ async function stageGreenfieldInitialization(input) {
|
|
|
27084
27369
|
operationId: normalized.operationId,
|
|
27085
27370
|
workspaceId: normalized.workspaceId,
|
|
27086
27371
|
state: "staged",
|
|
27087
|
-
stagingDirectoryName:
|
|
27372
|
+
stagingDirectoryName: path52.basename(stagingRoot),
|
|
27088
27373
|
targetDirectoryName: ".mancode",
|
|
27089
27374
|
manifestDigest: digestCanonicalJson(manifest),
|
|
27090
27375
|
configDigest: digestCanonicalJson(config),
|
|
@@ -27115,7 +27400,7 @@ async function stageGreenfieldInitialization(input) {
|
|
|
27115
27400
|
return journal;
|
|
27116
27401
|
}
|
|
27117
27402
|
async function publishGreenfieldInitialization(input) {
|
|
27118
|
-
const root =
|
|
27403
|
+
const root = path52.resolve(input.projectRoot);
|
|
27119
27404
|
assertUlid(input.operationId, "greenfield operationId");
|
|
27120
27405
|
const stagingRoot = greenfieldStagingPath(root, input.operationId);
|
|
27121
27406
|
const targetRoot = greenfieldTargetPath(root);
|
|
@@ -27150,10 +27435,10 @@ async function initializeGreenfield(input, publication) {
|
|
|
27150
27435
|
}
|
|
27151
27436
|
function greenfieldStagingPath(projectRoot, operationId) {
|
|
27152
27437
|
assertUlid(operationId, "greenfield operationId");
|
|
27153
|
-
return
|
|
27438
|
+
return path52.join(path52.resolve(projectRoot), `.mancode.init-${operationId}`);
|
|
27154
27439
|
}
|
|
27155
27440
|
function greenfieldTargetPath(projectRoot) {
|
|
27156
|
-
return
|
|
27441
|
+
return path52.join(path52.resolve(projectRoot), ".mancode");
|
|
27157
27442
|
}
|
|
27158
27443
|
function parseGreenfieldInitializationJournal(value) {
|
|
27159
27444
|
assertRecord(value, "greenfield initialization journal");
|
|
@@ -27289,7 +27574,7 @@ async function finishPublishedInitialization(input, stagedJournal) {
|
|
|
27289
27574
|
activatedAt: (input.now ?? /* @__PURE__ */ new Date()).toISOString()
|
|
27290
27575
|
};
|
|
27291
27576
|
assertSchemaManifestTransition(manifest, activeManifest);
|
|
27292
|
-
await writeJson(
|
|
27577
|
+
await writeJson(path52.join(targetRoot, "schema.json"), activeManifest);
|
|
27293
27578
|
throwIfOperationCrashInjected(
|
|
27294
27579
|
"greenfield_initialize",
|
|
27295
27580
|
"activate-v3-manifest"
|
|
@@ -27305,46 +27590,46 @@ async function finishPublishedInitialization(input, stagedJournal) {
|
|
|
27305
27590
|
}
|
|
27306
27591
|
async function writeGreenfieldLayout(stagingRoot, manifest, config, policy, projectFacts, journal) {
|
|
27307
27592
|
await Promise.all([
|
|
27308
|
-
mkdir34(
|
|
27309
|
-
mkdir34(
|
|
27593
|
+
mkdir34(path52.join(stagingRoot, "shared", "context"), { recursive: true }),
|
|
27594
|
+
mkdir34(path52.join(stagingRoot, "shared", "memory", "decisions"), {
|
|
27310
27595
|
recursive: true
|
|
27311
27596
|
}),
|
|
27312
|
-
mkdir34(
|
|
27597
|
+
mkdir34(path52.join(stagingRoot, "shared", "team", "actors"), {
|
|
27313
27598
|
recursive: true
|
|
27314
27599
|
}),
|
|
27315
|
-
mkdir34(
|
|
27600
|
+
mkdir34(path52.join(stagingRoot, "shared", "team", "handoffs"), {
|
|
27316
27601
|
recursive: true
|
|
27317
27602
|
}),
|
|
27318
|
-
mkdir34(
|
|
27603
|
+
mkdir34(path52.join(stagingRoot, "shared", "team", "events"), {
|
|
27319
27604
|
recursive: true
|
|
27320
27605
|
}),
|
|
27321
|
-
mkdir34(
|
|
27606
|
+
mkdir34(path52.join(stagingRoot, "shared", "team", "transport"), {
|
|
27322
27607
|
recursive: true
|
|
27323
27608
|
}),
|
|
27324
|
-
mkdir34(
|
|
27325
|
-
mkdir34(
|
|
27609
|
+
mkdir34(path52.join(stagingRoot, "local", "sessions"), { recursive: true }),
|
|
27610
|
+
mkdir34(path52.join(stagingRoot, JOURNAL_RELATIVE_DIRECTORY), {
|
|
27326
27611
|
recursive: true
|
|
27327
27612
|
}),
|
|
27328
|
-
mkdir34(
|
|
27329
|
-
mkdir34(
|
|
27330
|
-
mkdir34(
|
|
27331
|
-
mkdir34(
|
|
27332
|
-
mkdir34(
|
|
27333
|
-
mkdir34(
|
|
27613
|
+
mkdir34(path52.join(stagingRoot, "local", "workflows"), { recursive: true }),
|
|
27614
|
+
mkdir34(path52.join(stagingRoot, "local", "overlays"), { recursive: true }),
|
|
27615
|
+
mkdir34(path52.join(stagingRoot, "local", "quarantine"), { recursive: true }),
|
|
27616
|
+
mkdir34(path52.join(stagingRoot, "local", "publish"), { recursive: true }),
|
|
27617
|
+
mkdir34(path52.join(stagingRoot, "local", "cache"), { recursive: true }),
|
|
27618
|
+
mkdir34(path52.join(stagingRoot, "runtime", "non-git", journal.workspaceId), {
|
|
27334
27619
|
recursive: true
|
|
27335
27620
|
})
|
|
27336
27621
|
]);
|
|
27337
27622
|
await Promise.all([
|
|
27338
|
-
writeJson(
|
|
27339
|
-
writeJson(
|
|
27340
|
-
writeJson(
|
|
27623
|
+
writeJson(path52.join(stagingRoot, "schema.json"), manifest),
|
|
27624
|
+
writeJson(path52.join(stagingRoot, "shared", "config.json"), config),
|
|
27625
|
+
writeJson(path52.join(stagingRoot, "shared", "team", "policy.json"), policy),
|
|
27341
27626
|
writeJson(
|
|
27342
|
-
|
|
27627
|
+
path52.join(stagingRoot, "shared", "context", "project.json"),
|
|
27343
27628
|
projectFacts
|
|
27344
27629
|
),
|
|
27345
27630
|
writeJson(journalPath2(stagingRoot, journal.operationId), journal),
|
|
27346
|
-
|
|
27347
|
-
|
|
27631
|
+
writeFile41(
|
|
27632
|
+
path52.join(stagingRoot, ".gitignore"),
|
|
27348
27633
|
`${V3_IGNORE.join("\n")}
|
|
27349
27634
|
`,
|
|
27350
27635
|
{ encoding: "utf8", flag: "wx" }
|
|
@@ -27369,7 +27654,7 @@ async function readGreenfieldJournal(root, operationId) {
|
|
|
27369
27654
|
async function readManifest(root) {
|
|
27370
27655
|
try {
|
|
27371
27656
|
return parseSchemaManifest(
|
|
27372
|
-
JSON.parse(await readFile38(
|
|
27657
|
+
JSON.parse(await readFile38(path52.join(root, "schema.json"), "utf8"))
|
|
27373
27658
|
);
|
|
27374
27659
|
} catch (error) {
|
|
27375
27660
|
if (error instanceof SyntaxError || isNotFound28(error)) {
|
|
@@ -27407,7 +27692,7 @@ async function readConfig(root) {
|
|
|
27407
27692
|
try {
|
|
27408
27693
|
config = parseProjectConfig(
|
|
27409
27694
|
JSON.parse(
|
|
27410
|
-
await readFile38(
|
|
27695
|
+
await readFile38(path52.join(root, "shared", "config.json"), "utf8")
|
|
27411
27696
|
)
|
|
27412
27697
|
);
|
|
27413
27698
|
} catch (error) {
|
|
@@ -27424,7 +27709,7 @@ async function readPolicy(root) {
|
|
|
27424
27709
|
policy = parseTeamPolicy(
|
|
27425
27710
|
JSON.parse(
|
|
27426
27711
|
await readFile38(
|
|
27427
|
-
|
|
27712
|
+
path52.join(root, "shared", "team", "policy.json"),
|
|
27428
27713
|
"utf8"
|
|
27429
27714
|
)
|
|
27430
27715
|
)
|
|
@@ -27442,7 +27727,7 @@ async function readProjectFactsAt(root) {
|
|
|
27442
27727
|
return parseProjectFacts(
|
|
27443
27728
|
JSON.parse(
|
|
27444
27729
|
await readFile38(
|
|
27445
|
-
|
|
27730
|
+
path52.join(root, "shared", "context", "project.json"),
|
|
27446
27731
|
"utf8"
|
|
27447
27732
|
)
|
|
27448
27733
|
)
|
|
@@ -27481,7 +27766,7 @@ function normalizeInput(input) {
|
|
|
27481
27766
|
parseSchemaManifest(manifest);
|
|
27482
27767
|
return {
|
|
27483
27768
|
...input,
|
|
27484
|
-
projectRoot:
|
|
27769
|
+
projectRoot: path52.resolve(input.projectRoot),
|
|
27485
27770
|
projectConfig: config,
|
|
27486
27771
|
teamPolicy: policy,
|
|
27487
27772
|
projectFacts: input.projectFacts === void 0 ? void 0 : parseProjectFacts(input.projectFacts)
|
|
@@ -27579,16 +27864,16 @@ function initializationProjectFacts(input, now) {
|
|
|
27579
27864
|
}
|
|
27580
27865
|
function journalPath2(root, operationId) {
|
|
27581
27866
|
assertUlid(operationId, "greenfield operationId");
|
|
27582
|
-
return
|
|
27867
|
+
return path52.join(root, JOURNAL_RELATIVE_DIRECTORY, `${operationId}.json`);
|
|
27583
27868
|
}
|
|
27584
27869
|
async function writeJson(target, value) {
|
|
27585
|
-
const directory =
|
|
27870
|
+
const directory = path52.dirname(target);
|
|
27586
27871
|
await mkdir34(directory, { recursive: true });
|
|
27587
|
-
const temporary =
|
|
27872
|
+
const temporary = path52.join(
|
|
27588
27873
|
directory,
|
|
27589
|
-
`.${
|
|
27874
|
+
`.${path52.basename(target)}.${process.pid}.${Date.now()}.tmp`
|
|
27590
27875
|
);
|
|
27591
|
-
await
|
|
27876
|
+
await writeFile41(temporary, `${JSON.stringify(value, null, 2)}
|
|
27592
27877
|
`, {
|
|
27593
27878
|
encoding: "utf8",
|
|
27594
27879
|
flag: "wx"
|
|
@@ -27706,9 +27991,9 @@ async function init(rootDir = process6.cwd(), options = {}) {
|
|
|
27706
27991
|
return EXIT_INIT_FAILED;
|
|
27707
27992
|
}
|
|
27708
27993
|
const authority = resolveInitAuthority(options);
|
|
27709
|
-
const mancodeDir =
|
|
27710
|
-
const stateFile =
|
|
27711
|
-
const v3SchemaFile =
|
|
27994
|
+
const mancodeDir = path53.join(rootDir, ".mancode");
|
|
27995
|
+
const stateFile = path53.join(mancodeDir, "state.json");
|
|
27996
|
+
const v3SchemaFile = path53.join(mancodeDir, "schema.json");
|
|
27712
27997
|
const wasInitialized = await pathExists6(stateFile);
|
|
27713
27998
|
let mutationSnapshots = [];
|
|
27714
27999
|
let directorySnapshots = [];
|
|
@@ -27776,7 +28061,7 @@ async function init(rootDir = process6.cwd(), options = {}) {
|
|
|
27776
28061
|
}
|
|
27777
28062
|
return initializeV3(rootDir, options);
|
|
27778
28063
|
}
|
|
27779
|
-
const isGitRepo = await pathExists6(
|
|
28064
|
+
const isGitRepo = await pathExists6(path53.join(rootDir, ".git"));
|
|
27780
28065
|
const hasManifest = await hasProjectManifest(rootDir);
|
|
27781
28066
|
let isGenericProject = false;
|
|
27782
28067
|
if (!isGitRepo && !hasManifest) {
|
|
@@ -27894,8 +28179,8 @@ async function init(rootDir = process6.cwd(), options = {}) {
|
|
|
27894
28179
|
const managedFiles = getInitManagedFilePaths(rootDir, selectedPlatforms);
|
|
27895
28180
|
mutationSnapshots = await snapshotFiles(managedFiles);
|
|
27896
28181
|
directorySnapshots = await snapshotDirectories(managedFiles, [
|
|
27897
|
-
|
|
27898
|
-
|
|
28182
|
+
path53.join(mancodeDir, "workflows"),
|
|
28183
|
+
path53.join(mancodeDir, "preseason-reports")
|
|
27899
28184
|
]);
|
|
27900
28185
|
const team = await detectTeamStatus(rootDir);
|
|
27901
28186
|
const platformMinimal = Object.fromEntries(
|
|
@@ -27956,7 +28241,7 @@ async function init(rootDir = process6.cwd(), options = {}) {
|
|
|
27956
28241
|
`;
|
|
27957
28242
|
await fs4.writeFile(stateFile, stateContent, "utf-8");
|
|
27958
28243
|
await fs4.writeFile(
|
|
27959
|
-
|
|
28244
|
+
path53.join(mancodeDir, "project-profile.json"),
|
|
27960
28245
|
`${JSON.stringify(profile, null, 2)}
|
|
27961
28246
|
`,
|
|
27962
28247
|
"utf-8"
|
|
@@ -27993,7 +28278,7 @@ async function init(rootDir = process6.cwd(), options = {}) {
|
|
|
27993
28278
|
)
|
|
27994
28279
|
);
|
|
27995
28280
|
const tokens = await scanAesthetics(rootDir, uiLibrary);
|
|
27996
|
-
const tokensPath =
|
|
28281
|
+
const tokensPath = path53.join(
|
|
27997
28282
|
mancodeDir,
|
|
27998
28283
|
"aesthetics",
|
|
27999
28284
|
"style-tokens.json"
|
|
@@ -28157,7 +28442,7 @@ async function initializeV3(rootDir, options) {
|
|
|
28157
28442
|
);
|
|
28158
28443
|
return EXIT_INIT_FAILED;
|
|
28159
28444
|
}
|
|
28160
|
-
const schemaPath =
|
|
28445
|
+
const schemaPath = path53.join(rootDir, ".mancode", "schema.json");
|
|
28161
28446
|
let existingV3 = false;
|
|
28162
28447
|
let registeredAdapters = /* @__PURE__ */ new Set();
|
|
28163
28448
|
if (await pathExists6(schemaPath)) {
|
|
@@ -28260,7 +28545,7 @@ function printV3InitError(error) {
|
|
|
28260
28545
|
}
|
|
28261
28546
|
}
|
|
28262
28547
|
async function updateConfigOptions(mancodeDir, patch, preserveInstalledPlatforms) {
|
|
28263
|
-
const configPath =
|
|
28548
|
+
const configPath = path53.join(mancodeDir, "config.json");
|
|
28264
28549
|
let config = {};
|
|
28265
28550
|
try {
|
|
28266
28551
|
config = JSON.parse(await fs4.readFile(configPath, "utf-8"));
|
|
@@ -28293,7 +28578,7 @@ async function updateConfigOptions(mancodeDir, patch, preserveInstalledPlatforms
|
|
|
28293
28578
|
async function readExistingInitPreferences(mancodeDir) {
|
|
28294
28579
|
try {
|
|
28295
28580
|
const config = JSON.parse(
|
|
28296
|
-
await fs4.readFile(
|
|
28581
|
+
await fs4.readFile(path53.join(mancodeDir, "config.json"), "utf-8")
|
|
28297
28582
|
);
|
|
28298
28583
|
const preferences = {
|
|
28299
28584
|
platforms: Array.isArray(config.platforms) ? config.platforms.filter(
|
|
@@ -28359,13 +28644,13 @@ async function selectInitPlatforms(input) {
|
|
|
28359
28644
|
}
|
|
28360
28645
|
async function hasProjectManifest(rootDir) {
|
|
28361
28646
|
for (const name of PROJECT_MANIFESTS) {
|
|
28362
|
-
if (await pathExists6(
|
|
28647
|
+
if (await pathExists6(path53.join(rootDir, name))) return true;
|
|
28363
28648
|
}
|
|
28364
28649
|
return false;
|
|
28365
28650
|
}
|
|
28366
28651
|
async function canInitializeGenericProject(rootDir) {
|
|
28367
|
-
const resolved =
|
|
28368
|
-
if (resolved ===
|
|
28652
|
+
const resolved = path53.resolve(rootDir);
|
|
28653
|
+
if (resolved === path53.parse(resolved).root || resolved === path53.resolve(os.homedir())) {
|
|
28369
28654
|
return { ok: false, reason: "unsafe" };
|
|
28370
28655
|
}
|
|
28371
28656
|
try {
|
|
@@ -28379,11 +28664,11 @@ async function canInitializeGenericProject(rootDir) {
|
|
|
28379
28664
|
}
|
|
28380
28665
|
}
|
|
28381
28666
|
async function validateV3CliProjectBoundary(rootDir, options, locale, legacyInitialized) {
|
|
28382
|
-
const isGitRepo = await pathExists6(
|
|
28667
|
+
const isGitRepo = await pathExists6(path53.join(rootDir, ".git"));
|
|
28383
28668
|
const hasManifest = await hasProjectManifest(rootDir);
|
|
28384
28669
|
if (isGitRepo || hasManifest) return null;
|
|
28385
28670
|
const v3Initialized = await pathExists6(
|
|
28386
|
-
|
|
28671
|
+
path53.join(rootDir, ".mancode", "schema.json")
|
|
28387
28672
|
);
|
|
28388
28673
|
const legacyAuthorityPresent = legacyInitialized || (await scanLegacyAuthority(rootDir)).authorityPresent;
|
|
28389
28674
|
const genericSafety = await canInitializeGenericProject(rootDir);
|
|
@@ -28480,7 +28765,7 @@ function getInitManagedFilePaths(rootDir, platforms) {
|
|
|
28480
28765
|
files.push(`.cursor/commands/${mode}.md`);
|
|
28481
28766
|
}
|
|
28482
28767
|
}
|
|
28483
|
-
if (platforms.includes("codex") || platforms.includes("zcode")) {
|
|
28768
|
+
if (platforms.includes("codex") || platforms.includes("zcode") || platforms.includes("kimi-code")) {
|
|
28484
28769
|
files.push(
|
|
28485
28770
|
"AGENTS.md",
|
|
28486
28771
|
".agents/skills/mamba/SKILL.md",
|
|
@@ -28502,6 +28787,12 @@ function getInitManagedFilePaths(rootDir, platforms) {
|
|
|
28502
28787
|
files.push(`.zcode/skills/${mode}/SKILL.md`);
|
|
28503
28788
|
}
|
|
28504
28789
|
}
|
|
28790
|
+
if (platforms.includes("qoder")) {
|
|
28791
|
+
files.push("AGENTS.md");
|
|
28792
|
+
for (const mode of MODE_NAMES) {
|
|
28793
|
+
files.push(`.qoder/commands/${mode}.md`);
|
|
28794
|
+
}
|
|
28795
|
+
}
|
|
28505
28796
|
if (platforms.includes("copilot")) {
|
|
28506
28797
|
files.push(
|
|
28507
28798
|
".github/copilot-instructions.md",
|
|
@@ -28512,7 +28803,7 @@ function getInitManagedFilePaths(rootDir, platforms) {
|
|
|
28512
28803
|
files.push(`.github/prompts/${mode}.prompt.md`);
|
|
28513
28804
|
}
|
|
28514
28805
|
}
|
|
28515
|
-
return [...new Set(files.map((file) =>
|
|
28806
|
+
return [...new Set(files.map((file) => path53.join(rootDir, file)))];
|
|
28516
28807
|
}
|
|
28517
28808
|
async function snapshotFiles(filePaths) {
|
|
28518
28809
|
return Promise.all(
|
|
@@ -28531,10 +28822,10 @@ async function snapshotFiles(filePaths) {
|
|
|
28531
28822
|
async function snapshotDirectories(filePaths, additionalDirectories = []) {
|
|
28532
28823
|
const directories = new Set(additionalDirectories);
|
|
28533
28824
|
for (const filePath of filePaths) {
|
|
28534
|
-
let current =
|
|
28535
|
-
while (current !==
|
|
28825
|
+
let current = path53.dirname(filePath);
|
|
28826
|
+
while (current !== path53.dirname(current)) {
|
|
28536
28827
|
directories.add(current);
|
|
28537
|
-
current =
|
|
28828
|
+
current = path53.dirname(current);
|
|
28538
28829
|
}
|
|
28539
28830
|
}
|
|
28540
28831
|
return Promise.all(
|
|
@@ -28550,7 +28841,7 @@ async function restoreFiles(snapshots) {
|
|
|
28550
28841
|
await fs4.rm(snapshot.filePath, { force: true });
|
|
28551
28842
|
continue;
|
|
28552
28843
|
}
|
|
28553
|
-
await fs4.mkdir(
|
|
28844
|
+
await fs4.mkdir(path53.dirname(snapshot.filePath), { recursive: true });
|
|
28554
28845
|
await fs4.writeFile(snapshot.filePath, snapshot.content, "utf-8");
|
|
28555
28846
|
}
|
|
28556
28847
|
}
|
|
@@ -28601,6 +28892,16 @@ function printPlatformCreatedFiles(platform, locale) {
|
|
|
28601
28892
|
console.log(" .agents/skills/ # ZCode mode skills");
|
|
28602
28893
|
return;
|
|
28603
28894
|
}
|
|
28895
|
+
if (platform === "kimi-code") {
|
|
28896
|
+
console.log(" AGENTS.md # Kimi Code managed block");
|
|
28897
|
+
console.log(" .agents/skills/ # Kimi Code mode skills");
|
|
28898
|
+
return;
|
|
28899
|
+
}
|
|
28900
|
+
if (platform === "qoder") {
|
|
28901
|
+
console.log(" AGENTS.md # Qoder managed block");
|
|
28902
|
+
console.log(" .qoder/commands/ # Qoder mode commands");
|
|
28903
|
+
return;
|
|
28904
|
+
}
|
|
28604
28905
|
console.log(" .github/copilot-instructions.md # Copilot instructions");
|
|
28605
28906
|
}
|
|
28606
28907
|
function localize(locale, chinese, english) {
|
|
@@ -28617,15 +28918,15 @@ async function pathExists6(p) {
|
|
|
28617
28918
|
|
|
28618
28919
|
// src/commands/install.ts
|
|
28619
28920
|
import { promises as fs5 } from "fs";
|
|
28620
|
-
import
|
|
28921
|
+
import path54 from "path";
|
|
28621
28922
|
import process7 from "process";
|
|
28622
28923
|
var EXIT_OK3 = 0;
|
|
28623
28924
|
var EXIT_NOT_INITIALIZED2 = 1;
|
|
28624
28925
|
var EXIT_UNSUPPORTED_PLATFORM = 2;
|
|
28625
28926
|
var EXIT_INSTALL_FAILED = 3;
|
|
28626
28927
|
async function install(rootDir = process7.cwd(), platform = "claude-code", options = {}) {
|
|
28627
|
-
const stateFile =
|
|
28628
|
-
const v3SchemaFile =
|
|
28928
|
+
const stateFile = path54.join(rootDir, ".mancode", "state.json");
|
|
28929
|
+
const v3SchemaFile = path54.join(rootDir, ".mancode", "schema.json");
|
|
28629
28930
|
if (await pathExists7(v3SchemaFile)) {
|
|
28630
28931
|
return installV3(rootDir, platform, options);
|
|
28631
28932
|
}
|
|
@@ -28786,7 +29087,7 @@ function printUnsupportedPlatform(platform) {
|
|
|
28786
29087
|
}
|
|
28787
29088
|
}
|
|
28788
29089
|
async function readConfig2(rootDir) {
|
|
28789
|
-
const configPath =
|
|
29090
|
+
const configPath = path54.join(rootDir, ".mancode", "config.json");
|
|
28790
29091
|
try {
|
|
28791
29092
|
const raw = await fs5.readFile(configPath, "utf-8");
|
|
28792
29093
|
return { config: JSON.parse(raw), valid: true };
|
|
@@ -28801,7 +29102,7 @@ function isNodeError7(err) {
|
|
|
28801
29102
|
return err instanceof Error && "code" in err;
|
|
28802
29103
|
}
|
|
28803
29104
|
async function updateConfig(rootDir, config) {
|
|
28804
|
-
const configPath =
|
|
29105
|
+
const configPath = path54.join(rootDir, ".mancode", "config.json");
|
|
28805
29106
|
const content = `${JSON.stringify(config, null, 2)}
|
|
28806
29107
|
`;
|
|
28807
29108
|
await fs5.writeFile(configPath, content, "utf-8");
|
|
@@ -28837,7 +29138,7 @@ function readConfiguredMinimal(value, platform) {
|
|
|
28837
29138
|
async function readStatePlatform(rootDir) {
|
|
28838
29139
|
try {
|
|
28839
29140
|
const raw = await fs5.readFile(
|
|
28840
|
-
|
|
29141
|
+
path54.join(rootDir, ".mancode", "state.json"),
|
|
28841
29142
|
"utf-8"
|
|
28842
29143
|
);
|
|
28843
29144
|
const state = JSON.parse(raw);
|
|
@@ -28860,11 +29161,11 @@ function isRecord9(value) {
|
|
|
28860
29161
|
|
|
28861
29162
|
// src/commands/list-platforms.ts
|
|
28862
29163
|
import { promises as fs6 } from "fs";
|
|
28863
|
-
import
|
|
29164
|
+
import path55 from "path";
|
|
28864
29165
|
import process8 from "process";
|
|
28865
29166
|
var EXIT_OK4 = 0;
|
|
28866
29167
|
async function listPlatforms(rootDir = process8.cwd()) {
|
|
28867
|
-
if (await pathExists8(
|
|
29168
|
+
if (await pathExists8(path55.join(rootDir, ".mancode", "schema.json"))) {
|
|
28868
29169
|
return listV3Platforms(rootDir);
|
|
28869
29170
|
}
|
|
28870
29171
|
const installed = new Set(await readInstalledPlatforms(rootDir));
|
|
@@ -28900,7 +29201,7 @@ async function listV3Platforms(rootDir) {
|
|
|
28900
29201
|
async function readInstalledPlatforms(rootDir) {
|
|
28901
29202
|
try {
|
|
28902
29203
|
const raw = await fs6.readFile(
|
|
28903
|
-
|
|
29204
|
+
path55.join(rootDir, ".mancode", "config.json"),
|
|
28904
29205
|
"utf-8"
|
|
28905
29206
|
);
|
|
28906
29207
|
const config = JSON.parse(raw);
|
|
@@ -28933,7 +29234,7 @@ function describePlatform(platform) {
|
|
|
28933
29234
|
|
|
28934
29235
|
// src/commands/manps.ts
|
|
28935
29236
|
import { access as access4, readFile as readFile40 } from "fs/promises";
|
|
28936
|
-
import
|
|
29237
|
+
import path57 from "path";
|
|
28937
29238
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
28938
29239
|
|
|
28939
29240
|
// src/system/preseason.ts
|
|
@@ -28947,9 +29248,9 @@ import {
|
|
|
28947
29248
|
readFile as readFile39,
|
|
28948
29249
|
readdir as readdir18,
|
|
28949
29250
|
rename as rename11,
|
|
28950
|
-
writeFile as
|
|
29251
|
+
writeFile as writeFile42
|
|
28951
29252
|
} from "fs/promises";
|
|
28952
|
-
import
|
|
29253
|
+
import path56 from "path";
|
|
28953
29254
|
var PRESEASON_AREAS = [
|
|
28954
29255
|
"all",
|
|
28955
29256
|
"deps",
|
|
@@ -29029,10 +29330,10 @@ async function runPreseasonScan(projectRoot, area = "all", options = {}) {
|
|
|
29029
29330
|
const needsFiles = normalizedArea === "all" || normalizedArea === "dead-code" || normalizedArea === "config";
|
|
29030
29331
|
const files = needsFiles ? await listProjectFiles(projectRoot) : [];
|
|
29031
29332
|
const issues = (await scanArea(projectRoot, normalizedArea, pkg, files)).slice(0, 20);
|
|
29032
|
-
const storageRoot = options.storageRoot ??
|
|
29033
|
-
const reportDir =
|
|
29333
|
+
const storageRoot = options.storageRoot ?? path56.join(projectRoot, ".mancode");
|
|
29334
|
+
const reportDir = path56.join(storageRoot, "preseason-reports");
|
|
29034
29335
|
await mkdir35(reportDir, { recursive: true });
|
|
29035
|
-
const issueDbPath =
|
|
29336
|
+
const issueDbPath = path56.join(storageRoot, "preseason-issues.json");
|
|
29036
29337
|
const reportPath = await allocateReportPath(
|
|
29037
29338
|
reportDir,
|
|
29038
29339
|
`${generatedAt.replace(/[:.]/g, "-")}-${normalizedArea}`
|
|
@@ -29046,9 +29347,9 @@ async function runPreseasonScan(projectRoot, area = "all", options = {}) {
|
|
|
29046
29347
|
issueDbPath
|
|
29047
29348
|
};
|
|
29048
29349
|
const database = await buildIssueDatabase(projectRoot, report);
|
|
29049
|
-
await
|
|
29050
|
-
await
|
|
29051
|
-
|
|
29350
|
+
await writeFile42(reportPath, renderPreseasonReport(report), "utf-8");
|
|
29351
|
+
await writeFile42(
|
|
29352
|
+
path56.join(storageRoot, "preseason-report.md"),
|
|
29052
29353
|
renderPreseasonReport(report),
|
|
29053
29354
|
"utf-8"
|
|
29054
29355
|
);
|
|
@@ -29056,7 +29357,7 @@ async function runPreseasonScan(projectRoot, area = "all", options = {}) {
|
|
|
29056
29357
|
return report;
|
|
29057
29358
|
}
|
|
29058
29359
|
async function runPreseasonRemediation(projectRoot, issues, options = {}) {
|
|
29059
|
-
const issueDbPath = options.issueDbPath ??
|
|
29360
|
+
const issueDbPath = options.issueDbPath ?? path56.join(projectRoot, ".mancode", "preseason-issues.json");
|
|
29060
29361
|
const database = await readIssueDatabase(issueDbPath);
|
|
29061
29362
|
const keys = new Set(issues.map((issue) => issueKey(issue)));
|
|
29062
29363
|
const targets = database.issues.filter(
|
|
@@ -29134,7 +29435,7 @@ async function runPreseasonRemediation(projectRoot, issues, options = {}) {
|
|
|
29134
29435
|
write2(" Decision: skipped.");
|
|
29135
29436
|
}
|
|
29136
29437
|
database.updatedAt = now;
|
|
29137
|
-
await
|
|
29438
|
+
await writeFile42(
|
|
29138
29439
|
issueDbPath,
|
|
29139
29440
|
`${JSON.stringify(database, null, 2)}
|
|
29140
29441
|
`,
|
|
@@ -29166,7 +29467,7 @@ async function scanArea(projectRoot, area, pkg, files) {
|
|
|
29166
29467
|
async function allocateReportPath(reportDir, baseName) {
|
|
29167
29468
|
for (let attempt = 0; attempt < 1e3; attempt++) {
|
|
29168
29469
|
const suffix = attempt === 0 ? "" : `-${attempt + 1}`;
|
|
29169
|
-
const candidate =
|
|
29470
|
+
const candidate = path56.join(reportDir, `${baseName}${suffix}.md`);
|
|
29170
29471
|
if (!existsSync(candidate)) return candidate;
|
|
29171
29472
|
}
|
|
29172
29473
|
throw new Error(`unable to allocate preseason report path: ${baseName}`);
|
|
@@ -29215,8 +29516,8 @@ async function walk(root, current, results, depth) {
|
|
|
29215
29516
|
}
|
|
29216
29517
|
for (const entry of entries) {
|
|
29217
29518
|
if (IGNORE_DIRS.has(entry)) continue;
|
|
29218
|
-
const abs =
|
|
29219
|
-
const rel =
|
|
29519
|
+
const abs = path56.join(current, entry);
|
|
29520
|
+
const rel = path56.relative(root, abs);
|
|
29220
29521
|
let info;
|
|
29221
29522
|
try {
|
|
29222
29523
|
info = await lstat21(abs);
|
|
@@ -29226,7 +29527,7 @@ async function walk(root, current, results, depth) {
|
|
|
29226
29527
|
if (info.isSymbolicLink()) continue;
|
|
29227
29528
|
if (info.isDirectory()) {
|
|
29228
29529
|
await walk(root, abs, results, depth + 1);
|
|
29229
|
-
} else if (SOURCE_EXTENSIONS.has(
|
|
29530
|
+
} else if (SOURCE_EXTENSIONS.has(path56.extname(entry)) || entry === "package.json") {
|
|
29230
29531
|
results.push(rel);
|
|
29231
29532
|
if (results.length >= MAX_PROJECT_FILES) return;
|
|
29232
29533
|
}
|
|
@@ -29234,7 +29535,7 @@ async function walk(root, current, results, depth) {
|
|
|
29234
29535
|
}
|
|
29235
29536
|
async function readPackageJson(projectRoot) {
|
|
29236
29537
|
try {
|
|
29237
|
-
const raw = await readFile39(
|
|
29538
|
+
const raw = await readFile39(path56.join(projectRoot, "package.json"), "utf-8");
|
|
29238
29539
|
return JSON.parse(raw);
|
|
29239
29540
|
} catch {
|
|
29240
29541
|
return null;
|
|
@@ -29327,7 +29628,7 @@ function scanTodos(projectRoot, files) {
|
|
|
29327
29628
|
const matches = [];
|
|
29328
29629
|
for (const file of files) {
|
|
29329
29630
|
if (matches.length >= 7) break;
|
|
29330
|
-
const abs =
|
|
29631
|
+
const abs = path56.join(projectRoot, file);
|
|
29331
29632
|
matches.push(...readTodoIssues(abs, file, matches.length));
|
|
29332
29633
|
}
|
|
29333
29634
|
return matches.slice(0, 7);
|
|
@@ -29368,7 +29669,7 @@ function scanTestGaps(files) {
|
|
|
29368
29669
|
if (sourceFiles.length === 0) return [];
|
|
29369
29670
|
const tests = new Set(files.filter((file) => file.startsWith("tests/")));
|
|
29370
29671
|
const missing = sourceFiles.filter((file) => {
|
|
29371
|
-
const base =
|
|
29672
|
+
const base = path56.basename(file).replace(/\.(ts|tsx|js|jsx)$/, "");
|
|
29372
29673
|
return !Array.from(tests).some((test) => test.includes(base));
|
|
29373
29674
|
}).slice(0, 4);
|
|
29374
29675
|
return missing.map((file, index) => ({
|
|
@@ -29377,13 +29678,13 @@ function scanTestGaps(files) {
|
|
|
29377
29678
|
type: "tests",
|
|
29378
29679
|
title: "Core source file has no obvious test",
|
|
29379
29680
|
file,
|
|
29380
|
-
detail: `No matching test file was found for ${
|
|
29681
|
+
detail: `No matching test file was found for ${path56.basename(file)}.`,
|
|
29381
29682
|
recommendation: "Add focused coverage for the public behavior or document why this module is exercised indirectly."
|
|
29382
29683
|
}));
|
|
29383
29684
|
}
|
|
29384
29685
|
function scanConfig(projectRoot, files) {
|
|
29385
29686
|
const issues = [];
|
|
29386
|
-
if (!files.includes(".gitignore") && !pathExistsSync(
|
|
29687
|
+
if (!files.includes(".gitignore") && !pathExistsSync(path56.join(projectRoot, ".gitignore"))) {
|
|
29387
29688
|
issues.push({
|
|
29388
29689
|
id: "config-gitignore",
|
|
29389
29690
|
severity: "P1",
|
|
@@ -29394,7 +29695,7 @@ function scanConfig(projectRoot, files) {
|
|
|
29394
29695
|
recommendation: "Add a .gitignore that excludes dependencies, build output, coverage, and local env files."
|
|
29395
29696
|
});
|
|
29396
29697
|
}
|
|
29397
|
-
if (!files.includes(".editorconfig") && !pathExistsSync(
|
|
29698
|
+
if (!files.includes(".editorconfig") && !pathExistsSync(path56.join(projectRoot, ".editorconfig"))) {
|
|
29398
29699
|
issues.push({
|
|
29399
29700
|
id: "config-editorconfig",
|
|
29400
29701
|
severity: "P2",
|
|
@@ -29413,7 +29714,7 @@ function scanAestheticDrift(projectRoot, files, pkg) {
|
|
|
29413
29714
|
for (const file of frontendFiles) {
|
|
29414
29715
|
let content;
|
|
29415
29716
|
try {
|
|
29416
|
-
content = readFileSyncSafe(
|
|
29717
|
+
content = readFileSyncSafe(path56.join(projectRoot, file));
|
|
29417
29718
|
} catch {
|
|
29418
29719
|
continue;
|
|
29419
29720
|
}
|
|
@@ -29464,7 +29765,7 @@ function detectedIconSystems(pkg) {
|
|
|
29464
29765
|
return systems.filter(([, pattern]) => packages.some((name) => pattern.test(name))).map(([name]) => name);
|
|
29465
29766
|
}
|
|
29466
29767
|
async function scanArchitecture(projectRoot) {
|
|
29467
|
-
const localBinary =
|
|
29768
|
+
const localBinary = path56.join(
|
|
29468
29769
|
projectRoot,
|
|
29469
29770
|
"node_modules",
|
|
29470
29771
|
".bin",
|
|
@@ -29512,7 +29813,7 @@ async function hasDependencyCruiserConfig(projectRoot) {
|
|
|
29512
29813
|
"dependency-cruiser.config.mjs"
|
|
29513
29814
|
];
|
|
29514
29815
|
const results = await Promise.all(
|
|
29515
|
-
files.map((file) => pathExists9(
|
|
29816
|
+
files.map((file) => pathExists9(path56.join(projectRoot, file)))
|
|
29516
29817
|
);
|
|
29517
29818
|
return results.some(Boolean);
|
|
29518
29819
|
}
|
|
@@ -29618,9 +29919,9 @@ function inferCommands(pkg) {
|
|
|
29618
29919
|
return ["lint", "test", "build"].filter((name) => scripts[name]).map((name) => `npm run ${name}`);
|
|
29619
29920
|
}
|
|
29620
29921
|
async function buildIssueDatabase(projectRoot, report) {
|
|
29621
|
-
const reportRef =
|
|
29922
|
+
const reportRef = path56.relative(projectRoot, report.reportPath);
|
|
29622
29923
|
const run = {
|
|
29623
|
-
id:
|
|
29924
|
+
id: path56.basename(report.reportPath, ".md"),
|
|
29624
29925
|
generatedAt: report.generatedAt,
|
|
29625
29926
|
area: report.area,
|
|
29626
29927
|
reportPath: reportRef,
|
|
@@ -29683,7 +29984,7 @@ async function readIssueDatabase(issueDbPath) {
|
|
|
29683
29984
|
}
|
|
29684
29985
|
async function writeJsonAtomic3(file, value) {
|
|
29685
29986
|
const tmp = `${file}.tmp-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
29686
|
-
await
|
|
29987
|
+
await writeFile42(tmp, `${JSON.stringify(value, null, 2)}
|
|
29687
29988
|
`, "utf-8");
|
|
29688
29989
|
await rename11(tmp, file);
|
|
29689
29990
|
}
|
|
@@ -29726,20 +30027,20 @@ function compareIssueRecords(a, b) {
|
|
|
29726
30027
|
}
|
|
29727
30028
|
async function applySafeRemediation(projectRoot, issue) {
|
|
29728
30029
|
if (issue.id === "config-gitignore" && issue.file === ".gitignore") {
|
|
29729
|
-
const gitignorePath =
|
|
30030
|
+
const gitignorePath = path56.join(projectRoot, ".gitignore");
|
|
29730
30031
|
if (pathExistsSync(gitignorePath)) {
|
|
29731
30032
|
return { applied: false };
|
|
29732
30033
|
}
|
|
29733
|
-
await
|
|
30034
|
+
await writeFile42(gitignorePath, `${DEFAULT_GITIGNORE}
|
|
29734
30035
|
`, "utf-8");
|
|
29735
30036
|
return { applied: true, action: "created .gitignore" };
|
|
29736
30037
|
}
|
|
29737
30038
|
if (issue.id === "config-editorconfig" && issue.file === ".editorconfig") {
|
|
29738
|
-
const editorconfigPath =
|
|
30039
|
+
const editorconfigPath = path56.join(projectRoot, ".editorconfig");
|
|
29739
30040
|
if (pathExistsSync(editorconfigPath)) {
|
|
29740
30041
|
return { applied: false };
|
|
29741
30042
|
}
|
|
29742
|
-
await
|
|
30043
|
+
await writeFile42(editorconfigPath, `${DEFAULT_EDITORCONFIG}
|
|
29743
30044
|
`, "utf-8");
|
|
29744
30045
|
return { applied: true, action: "created .editorconfig" };
|
|
29745
30046
|
}
|
|
@@ -29775,7 +30076,7 @@ async function inferSafePackageScript(projectRoot, scriptName) {
|
|
|
29775
30076
|
}
|
|
29776
30077
|
}
|
|
29777
30078
|
async function addPackageScript(projectRoot, scriptName, script) {
|
|
29778
|
-
const packagePath =
|
|
30079
|
+
const packagePath = path56.join(projectRoot, "package.json");
|
|
29779
30080
|
let pkg;
|
|
29780
30081
|
try {
|
|
29781
30082
|
pkg = JSON.parse(await readFile39(packagePath, "utf-8"));
|
|
@@ -29788,7 +30089,7 @@ async function addPackageScript(projectRoot, scriptName, script) {
|
|
|
29788
30089
|
...scripts,
|
|
29789
30090
|
[scriptName]: script
|
|
29790
30091
|
};
|
|
29791
|
-
await
|
|
30092
|
+
await writeFile42(packagePath, `${JSON.stringify(pkg, null, 2)}
|
|
29792
30093
|
`, "utf-8");
|
|
29793
30094
|
return true;
|
|
29794
30095
|
}
|
|
@@ -29888,7 +30189,7 @@ var EXIT_NOT_INITIALIZED3 = 1;
|
|
|
29888
30189
|
var EXIT_SCAN_FAILED = 2;
|
|
29889
30190
|
var EXIT_INVALID_ARG = 3;
|
|
29890
30191
|
async function manps(rootDir, area = "all", options = {}) {
|
|
29891
|
-
const v3SchemaPath =
|
|
30192
|
+
const v3SchemaPath = path57.join(rootDir, ".mancode", "schema.json");
|
|
29892
30193
|
const v3Activation = await readV3ActivationState(v3SchemaPath);
|
|
29893
30194
|
if (v3Activation !== null && v3Activation !== "v3_active" && v3Activation !== "dual_read") {
|
|
29894
30195
|
const message = `manps is unavailable while mancode activation is ${v3Activation}`;
|
|
@@ -29901,7 +30202,7 @@ async function manps(rootDir, area = "all", options = {}) {
|
|
|
29901
30202
|
return EXIT_SCAN_FAILED;
|
|
29902
30203
|
}
|
|
29903
30204
|
const v3Initialized = v3Activation === "v3_active";
|
|
29904
|
-
const initialized = v3Initialized || await pathExists10(
|
|
30205
|
+
const initialized = v3Initialized || await pathExists10(path57.join(rootDir, ".mancode", "state.json"));
|
|
29905
30206
|
if (!initialized) {
|
|
29906
30207
|
if (options.json) {
|
|
29907
30208
|
console.log(JSON.stringify({ error: "not initialized" }, null, 2));
|
|
@@ -29914,7 +30215,7 @@ async function manps(rootDir, area = "all", options = {}) {
|
|
|
29914
30215
|
let report;
|
|
29915
30216
|
try {
|
|
29916
30217
|
report = await runPreseasonScan(rootDir, area, {
|
|
29917
|
-
storageRoot: v3Initialized ?
|
|
30218
|
+
storageRoot: v3Initialized ? path57.join(rootDir, ".mancode", "local") : void 0
|
|
29918
30219
|
});
|
|
29919
30220
|
} catch (err) {
|
|
29920
30221
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -29983,8 +30284,8 @@ async function manps(rootDir, area = "all", options = {}) {
|
|
|
29983
30284
|
console.log(
|
|
29984
30285
|
`Issues: ${report.issues.length} total (P0 ${p0}, P1 ${p1}, P2 ${p2})`
|
|
29985
30286
|
);
|
|
29986
|
-
console.log(`Report: ${
|
|
29987
|
-
console.log(`Issue DB: ${
|
|
30287
|
+
console.log(`Report: ${path57.relative(rootDir, report.reportPath)}`);
|
|
30288
|
+
console.log(`Issue DB: ${path57.relative(rootDir, report.issueDbPath)}`);
|
|
29988
30289
|
if (report.issues.length > 0) {
|
|
29989
30290
|
console.log("");
|
|
29990
30291
|
for (const issue of report.issues.slice(0, 7)) {
|
|
@@ -30000,7 +30301,7 @@ async function manps(rootDir, area = "all", options = {}) {
|
|
|
30000
30301
|
console.log(` Skipped: ${remediation.skipped}`);
|
|
30001
30302
|
console.log(` Fixed: ${remediation.fixed}`);
|
|
30002
30303
|
console.log(
|
|
30003
|
-
` Issue DB: ${
|
|
30304
|
+
` Issue DB: ${path57.relative(rootDir, remediation.issueDbPath)}`
|
|
30004
30305
|
);
|
|
30005
30306
|
}
|
|
30006
30307
|
return EXIT_OK5;
|
|
@@ -30071,7 +30372,7 @@ async function readV3ActivationState(schemaPath) {
|
|
|
30071
30372
|
|
|
30072
30373
|
// src/commands/migrate.ts
|
|
30073
30374
|
import { readFile as readFile41 } from "fs/promises";
|
|
30074
|
-
import
|
|
30375
|
+
import path58 from "path";
|
|
30075
30376
|
var EXIT_OK6 = 0;
|
|
30076
30377
|
var EXIT_INVALID_ARG2 = 2;
|
|
30077
30378
|
var EXIT_MIGRATION_BLOCKED = 3;
|
|
@@ -30197,9 +30498,9 @@ async function readScopeFile(rootDir, file) {
|
|
|
30197
30498
|
if (!file.trim() || file.includes("\0")) {
|
|
30198
30499
|
throw new Error("MANCODE_MIGRATION_SCOPE_FILE_INVALID");
|
|
30199
30500
|
}
|
|
30200
|
-
const resolved =
|
|
30201
|
-
const relative =
|
|
30202
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
30501
|
+
const resolved = path58.resolve(rootDir, file);
|
|
30502
|
+
const relative = path58.relative(path58.resolve(rootDir), resolved);
|
|
30503
|
+
if (relative === ".." || relative.startsWith(`..${path58.sep}`) || path58.isAbsolute(relative)) {
|
|
30203
30504
|
throw new Error("MANCODE_MIGRATION_SCOPE_FILE_INVALID");
|
|
30204
30505
|
}
|
|
30205
30506
|
try {
|
|
@@ -30304,12 +30605,12 @@ async function runOperationMutation(rootDir, operationId, options, mode) {
|
|
|
30304
30605
|
}
|
|
30305
30606
|
|
|
30306
30607
|
// src/context/project-policy-upgrade.ts
|
|
30307
|
-
import { lstat as lstat22, mkdir as mkdir36, readFile as readFile42, rm as rm19, writeFile as
|
|
30308
|
-
import
|
|
30608
|
+
import { lstat as lstat22, mkdir as mkdir36, readFile as readFile42, rm as rm19, writeFile as writeFile43 } from "fs/promises";
|
|
30609
|
+
import path59 from "path";
|
|
30309
30610
|
var UPGRADE_OPERATION = "project_policy_upgrade";
|
|
30310
30611
|
async function dryRunProjectPolicyUpgrade(input) {
|
|
30311
30612
|
assertPolicyVersion(input.policyVersion);
|
|
30312
|
-
const root =
|
|
30613
|
+
const root = path59.resolve(input.projectRoot);
|
|
30313
30614
|
const project = await new V3ContextStore(root).readProjectSnapshot();
|
|
30314
30615
|
const beforeDigest = digestManifest(project.manifest);
|
|
30315
30616
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
@@ -30353,7 +30654,7 @@ async function dryRunProjectPolicyUpgrade(input) {
|
|
|
30353
30654
|
async function upgradeProjectPolicy(input) {
|
|
30354
30655
|
assertPolicyVersion(input.policyVersion);
|
|
30355
30656
|
assertUlid(input.sessionId, "project policy upgrade sessionId");
|
|
30356
|
-
const root =
|
|
30657
|
+
const root = path59.resolve(input.projectRoot);
|
|
30357
30658
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
30358
30659
|
const operationId = input.operationId;
|
|
30359
30660
|
if (operationId === void 0) {
|
|
@@ -30607,20 +30908,20 @@ function buildV2Manifest(manifest, operationId) {
|
|
|
30607
30908
|
return candidate;
|
|
30608
30909
|
}
|
|
30609
30910
|
async function readSchemaContent(root) {
|
|
30610
|
-
return readFile42(
|
|
30911
|
+
return readFile42(path59.join(root, ".mancode", "schema.json"), "utf8");
|
|
30611
30912
|
}
|
|
30612
30913
|
async function writeSchemaContent(root, operationId, content) {
|
|
30613
|
-
const directory =
|
|
30614
|
-
const target =
|
|
30914
|
+
const directory = path59.join(root, ".mancode");
|
|
30915
|
+
const target = path59.join(directory, "schema.json");
|
|
30615
30916
|
const stat5 = await lstat22(target);
|
|
30616
30917
|
if (!stat5.isFile() || stat5.isSymbolicLink()) {
|
|
30617
30918
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
30618
30919
|
}
|
|
30619
|
-
const temporary =
|
|
30920
|
+
const temporary = path59.join(
|
|
30620
30921
|
directory,
|
|
30621
30922
|
`.schema.json.${operationId}.${process.pid}.tmp`
|
|
30622
30923
|
);
|
|
30623
|
-
await
|
|
30924
|
+
await writeFile43(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
30624
30925
|
try {
|
|
30625
30926
|
await replaceFileAtomically(temporary, target);
|
|
30626
30927
|
} catch (error) {
|
|
@@ -30692,13 +30993,13 @@ async function releaseLocks3(locks) {
|
|
|
30692
30993
|
await Promise.allSettled([...locks].reverse().map((lock) => lock.release()));
|
|
30693
30994
|
}
|
|
30694
30995
|
function projectUpgradePreviewRoot(root, operationId) {
|
|
30695
|
-
return
|
|
30996
|
+
return path59.join(root, ".mancode", "staging", "project-upgrade", operationId);
|
|
30696
30997
|
}
|
|
30697
30998
|
async function stageProjectPolicyUpgrade(root, receipt, manifestContent) {
|
|
30698
30999
|
const directory = projectUpgradePreviewRoot(root, receipt.operationId);
|
|
30699
|
-
const receiptPath =
|
|
30700
|
-
const manifestPath =
|
|
30701
|
-
await mkdir36(
|
|
31000
|
+
const receiptPath = path59.join(directory, "preview.json");
|
|
31001
|
+
const manifestPath = path59.join(directory, "schema.json");
|
|
31002
|
+
await mkdir36(path59.dirname(directory), { recursive: true });
|
|
30702
31003
|
try {
|
|
30703
31004
|
await mkdir36(directory);
|
|
30704
31005
|
} catch (error) {
|
|
@@ -30708,12 +31009,12 @@ async function stageProjectPolicyUpgrade(root, receipt, manifestContent) {
|
|
|
30708
31009
|
throw error;
|
|
30709
31010
|
}
|
|
30710
31011
|
try {
|
|
30711
|
-
await
|
|
31012
|
+
await writeFile43(receiptPath, `${JSON.stringify(receipt, null, 2)}
|
|
30712
31013
|
`, {
|
|
30713
31014
|
encoding: "utf8",
|
|
30714
31015
|
flag: "wx"
|
|
30715
31016
|
});
|
|
30716
|
-
await
|
|
31017
|
+
await writeFile43(manifestPath, manifestContent, {
|
|
30717
31018
|
encoding: "utf8",
|
|
30718
31019
|
flag: "wx"
|
|
30719
31020
|
});
|
|
@@ -30725,8 +31026,8 @@ async function stageProjectPolicyUpgrade(root, receipt, manifestContent) {
|
|
|
30725
31026
|
async function assertProjectPolicyUpgradePreview(root, operationId, project) {
|
|
30726
31027
|
const directory = projectUpgradePreviewRoot(root, operationId);
|
|
30727
31028
|
const [receiptContent, manifestContent] = await Promise.all([
|
|
30728
|
-
readSafePreviewFile(
|
|
30729
|
-
readSafePreviewFile(
|
|
31029
|
+
readSafePreviewFile(path59.join(directory, "preview.json")),
|
|
31030
|
+
readSafePreviewFile(path59.join(directory, "schema.json"))
|
|
30730
31031
|
]);
|
|
30731
31032
|
let receipt;
|
|
30732
31033
|
try {
|
|
@@ -30842,16 +31143,16 @@ async function projectUpgrade(rootDir, options) {
|
|
|
30842
31143
|
// src/commands/refresh-project.ts
|
|
30843
31144
|
import { randomUUID } from "crypto";
|
|
30844
31145
|
import { promises as fs7 } from "fs";
|
|
30845
|
-
import
|
|
31146
|
+
import path60 from "path";
|
|
30846
31147
|
import process9 from "process";
|
|
30847
31148
|
var EXIT_OK7 = 0;
|
|
30848
31149
|
var EXIT_NOT_INITIALIZED4 = 1;
|
|
30849
31150
|
var EXIT_CORRUPT_STATE = 2;
|
|
30850
31151
|
var EXIT_REFRESH_FAILED = 3;
|
|
30851
31152
|
async function refreshProject(rootDir = process9.cwd()) {
|
|
30852
|
-
const mancodeDir =
|
|
30853
|
-
const statePath =
|
|
30854
|
-
if (await pathExists11(
|
|
31153
|
+
const mancodeDir = path60.join(rootDir, ".mancode");
|
|
31154
|
+
const statePath = path60.join(mancodeDir, "state.json");
|
|
31155
|
+
if (await pathExists11(path60.join(mancodeDir, "schema.json"))) {
|
|
30855
31156
|
return refreshV3Project(rootDir);
|
|
30856
31157
|
}
|
|
30857
31158
|
if (!await pathExists11(statePath)) {
|
|
@@ -30870,12 +31171,12 @@ async function refreshProject(rootDir = process9.cwd()) {
|
|
|
30870
31171
|
const [profile, team, hasGit, hasManifest] = await Promise.all([
|
|
30871
31172
|
detectProjectProfile(rootDir),
|
|
30872
31173
|
detectTeamStatus(rootDir),
|
|
30873
|
-
pathExists11(
|
|
31174
|
+
pathExists11(path60.join(rootDir, ".git")),
|
|
30874
31175
|
hasProjectManifest2(rootDir)
|
|
30875
31176
|
]);
|
|
30876
31177
|
const uiLibrary = primaryUiLibrary(profile);
|
|
30877
31178
|
const stack = [...profile.languages, ...profile.frameworks];
|
|
30878
|
-
const config = await readJson2(
|
|
31179
|
+
const config = await readJson2(path60.join(mancodeDir, "config.json"));
|
|
30879
31180
|
const configuredTeam = config.forceTeamMode === true ? true : config.teamMode === "on" ? true : config.teamMode === "off" ? false : team.isTeam;
|
|
30880
31181
|
const nextState = {
|
|
30881
31182
|
...state,
|
|
@@ -30887,7 +31188,7 @@ async function refreshProject(rootDir = process9.cwd()) {
|
|
|
30887
31188
|
};
|
|
30888
31189
|
await writeProjectFacts2(
|
|
30889
31190
|
statePath,
|
|
30890
|
-
|
|
31191
|
+
path60.join(mancodeDir, "project-profile.json"),
|
|
30891
31192
|
`${JSON.stringify(nextState, null, 2)}
|
|
30892
31193
|
`,
|
|
30893
31194
|
`${JSON.stringify(profile, null, 2)}
|
|
@@ -30954,7 +31255,7 @@ async function refreshV3Project(rootDir) {
|
|
|
30954
31255
|
}
|
|
30955
31256
|
async function hasProjectManifest2(rootDir) {
|
|
30956
31257
|
for (const manifest of PROJECT_MANIFESTS) {
|
|
30957
|
-
if (await pathExists11(
|
|
31258
|
+
if (await pathExists11(path60.join(rootDir, manifest))) return true;
|
|
30958
31259
|
}
|
|
30959
31260
|
return false;
|
|
30960
31261
|
}
|
|
@@ -31020,9 +31321,9 @@ async function readOptionalText(filePath) {
|
|
|
31020
31321
|
}
|
|
31021
31322
|
}
|
|
31022
31323
|
function temporaryPath(filePath) {
|
|
31023
|
-
return
|
|
31024
|
-
|
|
31025
|
-
`.${
|
|
31324
|
+
return path60.join(
|
|
31325
|
+
path60.dirname(filePath),
|
|
31326
|
+
`.${path60.basename(filePath)}.${process9.pid}.${randomUUID()}.tmp`
|
|
31026
31327
|
);
|
|
31027
31328
|
}
|
|
31028
31329
|
async function refreshStaticPlatforms(rootDir, config, fallbackPlatform, stack, uiLibrary, profile) {
|
|
@@ -31092,7 +31393,7 @@ async function pathExists11(filePath) {
|
|
|
31092
31393
|
|
|
31093
31394
|
// src/commands/refresh-style.ts
|
|
31094
31395
|
import { promises as fs8 } from "fs";
|
|
31095
|
-
import
|
|
31396
|
+
import path61 from "path";
|
|
31096
31397
|
import process10 from "process";
|
|
31097
31398
|
var EXIT_OK8 = 0;
|
|
31098
31399
|
var EXIT_NOT_INITIALIZED5 = 1;
|
|
@@ -31103,8 +31404,8 @@ async function refreshStyle(rootDir = process10.cwd(), options = {}) {
|
|
|
31103
31404
|
console.error("\u2717 style scan root must stay inside the project root.");
|
|
31104
31405
|
return EXIT_V3_REFRESH_FAILED;
|
|
31105
31406
|
}
|
|
31106
|
-
const stateFile =
|
|
31107
|
-
if (await pathExists12(
|
|
31407
|
+
const stateFile = path61.join(rootDir, ".mancode", "state.json");
|
|
31408
|
+
if (await pathExists12(path61.join(rootDir, ".mancode", "schema.json"))) {
|
|
31108
31409
|
return refreshV3Style(rootDir, scanTarget.root, scanTarget.scopeRoot);
|
|
31109
31410
|
}
|
|
31110
31411
|
if (!await pathExists12(stateFile)) {
|
|
@@ -31114,7 +31415,7 @@ async function refreshStyle(rootDir = process10.cwd(), options = {}) {
|
|
|
31114
31415
|
}
|
|
31115
31416
|
console.log("\u2713 \u5237\u65B0\u9879\u76EE profile...");
|
|
31116
31417
|
const profile = await detectProjectProfile(rootDir);
|
|
31117
|
-
const profilePath =
|
|
31418
|
+
const profilePath = path61.join(rootDir, ".mancode", "project-profile.json");
|
|
31118
31419
|
await fs8.writeFile(
|
|
31119
31420
|
profilePath,
|
|
31120
31421
|
`${JSON.stringify(profile, null, 2)}
|
|
@@ -31141,13 +31442,13 @@ async function refreshStyle(rootDir = process10.cwd(), options = {}) {
|
|
|
31141
31442
|
uiLibraryHint,
|
|
31142
31443
|
scanTarget.scopeRoot
|
|
31143
31444
|
);
|
|
31144
|
-
const tokensPath =
|
|
31445
|
+
const tokensPath = path61.join(
|
|
31145
31446
|
rootDir,
|
|
31146
31447
|
".mancode",
|
|
31147
31448
|
"aesthetics",
|
|
31148
31449
|
"style-tokens.json"
|
|
31149
31450
|
);
|
|
31150
|
-
await fs8.mkdir(
|
|
31451
|
+
await fs8.mkdir(path61.dirname(tokensPath), { recursive: true });
|
|
31151
31452
|
await fs8.writeFile(
|
|
31152
31453
|
tokensPath,
|
|
31153
31454
|
`${JSON.stringify(tokens, null, 2)}
|
|
@@ -31220,7 +31521,7 @@ async function refreshV3Style(rootDir, scanRoot, scopeRoot) {
|
|
|
31220
31521
|
console.log(
|
|
31221
31522
|
` \u7C7B\u578B: ${profile.projectKind} | UI: ${profile.uiAssets} | \u6D4F\u89C8\u5668: ${profile.browserAutomation}`
|
|
31222
31523
|
);
|
|
31223
|
-
const tokensPath =
|
|
31524
|
+
const tokensPath = path61.join(
|
|
31224
31525
|
rootDir,
|
|
31225
31526
|
".mancode",
|
|
31226
31527
|
"local",
|
|
@@ -31237,7 +31538,7 @@ async function refreshV3Style(rootDir, scanRoot, scopeRoot) {
|
|
|
31237
31538
|
}
|
|
31238
31539
|
console.log("\u2713 \u626B\u63CF\u9879\u76EE\u8BBE\u8BA1 token...");
|
|
31239
31540
|
const tokens = await scanAesthetics(scanRoot, uiLibraryHint, scopeRoot);
|
|
31240
|
-
await fs8.mkdir(
|
|
31541
|
+
await fs8.mkdir(path61.dirname(tokensPath), { recursive: true });
|
|
31241
31542
|
await fs8.writeFile(
|
|
31242
31543
|
tokensPath,
|
|
31243
31544
|
`${JSON.stringify(tokens, null, 2)}
|
|
@@ -31271,7 +31572,7 @@ async function printStaticPlatformRefreshHint(rootDir) {
|
|
|
31271
31572
|
);
|
|
31272
31573
|
}
|
|
31273
31574
|
async function refreshLegacyStateContext(rootDir, profile, uiLibrary) {
|
|
31274
|
-
const statePath =
|
|
31575
|
+
const statePath = path61.join(rootDir, ".mancode", "state.json");
|
|
31275
31576
|
try {
|
|
31276
31577
|
const state = JSON.parse(await fs8.readFile(statePath, "utf-8"));
|
|
31277
31578
|
const stack = [...profile.languages, ...profile.frameworks];
|
|
@@ -31295,7 +31596,7 @@ async function refreshLegacyStateContext(rootDir, profile, uiLibrary) {
|
|
|
31295
31596
|
async function readInstalledPlatforms2(rootDir) {
|
|
31296
31597
|
try {
|
|
31297
31598
|
const raw = await fs8.readFile(
|
|
31298
|
-
|
|
31599
|
+
path61.join(rootDir, ".mancode", "config.json"),
|
|
31299
31600
|
"utf-8"
|
|
31300
31601
|
);
|
|
31301
31602
|
const config = JSON.parse(raw);
|
|
@@ -31315,30 +31616,30 @@ async function pathExists12(p) {
|
|
|
31315
31616
|
}
|
|
31316
31617
|
}
|
|
31317
31618
|
async function resolveScanTarget(rootDir, requestedRoot) {
|
|
31318
|
-
const projectRoot = await fs8.realpath(
|
|
31619
|
+
const projectRoot = await fs8.realpath(path61.resolve(rootDir)).catch(() => null);
|
|
31319
31620
|
if (projectRoot === null) return null;
|
|
31320
31621
|
if (requestedRoot === void 0 || requestedRoot === ".") {
|
|
31321
31622
|
return { root: projectRoot, scopeRoot: "." };
|
|
31322
31623
|
}
|
|
31323
|
-
if (
|
|
31624
|
+
if (path61.isAbsolute(requestedRoot) || requestedRoot.includes("\0") || requestedRoot.split(/[\\/]/).some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
31324
31625
|
return null;
|
|
31325
31626
|
}
|
|
31326
|
-
const candidate = await fs8.realpath(
|
|
31627
|
+
const candidate = await fs8.realpath(path61.resolve(projectRoot, requestedRoot)).catch(() => null);
|
|
31327
31628
|
if (candidate === null) return null;
|
|
31328
|
-
const relative =
|
|
31329
|
-
if (relative.startsWith(`..${
|
|
31629
|
+
const relative = path61.relative(projectRoot, candidate);
|
|
31630
|
+
if (relative.startsWith(`..${path61.sep}`) || relative === ".." || path61.isAbsolute(relative)) {
|
|
31330
31631
|
return null;
|
|
31331
31632
|
}
|
|
31332
31633
|
return {
|
|
31333
31634
|
root: candidate,
|
|
31334
|
-
scopeRoot: relative.split(
|
|
31635
|
+
scopeRoot: relative.split(path61.sep).join("/") || "."
|
|
31335
31636
|
};
|
|
31336
31637
|
}
|
|
31337
31638
|
|
|
31338
31639
|
// src/commands/status.ts
|
|
31339
31640
|
import { spawn } from "child_process";
|
|
31340
31641
|
import { promises as fs9 } from "fs";
|
|
31341
|
-
import
|
|
31642
|
+
import path62 from "path";
|
|
31342
31643
|
import process11 from "process";
|
|
31343
31644
|
|
|
31344
31645
|
// src/team/assessment.ts
|
|
@@ -31494,8 +31795,8 @@ var EXIT_OK9 = 0;
|
|
|
31494
31795
|
var EXIT_NOT_INITIALIZED6 = 1;
|
|
31495
31796
|
var EXIT_CORRUPT_STATE2 = 2;
|
|
31496
31797
|
async function status(rootDir = process11.cwd(), options = {}) {
|
|
31497
|
-
const stateFile =
|
|
31498
|
-
const v3SchemaFile =
|
|
31798
|
+
const stateFile = path62.join(rootDir, ".mancode", "state.json");
|
|
31799
|
+
const v3SchemaFile = path62.join(rootDir, ".mancode", "schema.json");
|
|
31499
31800
|
if (await pathExists13(v3SchemaFile)) {
|
|
31500
31801
|
return statusV3(rootDir, options);
|
|
31501
31802
|
}
|
|
@@ -31740,10 +32041,10 @@ async function readV3StatusSession(rootDir) {
|
|
|
31740
32041
|
}
|
|
31741
32042
|
async function shouldRefreshProject(rootDir, state) {
|
|
31742
32043
|
if (state.projectMode !== "generic") return false;
|
|
31743
|
-
const hasGit = await pathExists13(
|
|
32044
|
+
const hasGit = await pathExists13(path62.join(rootDir, ".git"));
|
|
31744
32045
|
if (hasGit) return true;
|
|
31745
32046
|
for (const manifest of PROJECT_MANIFESTS) {
|
|
31746
|
-
if (await pathExists13(
|
|
32047
|
+
if (await pathExists13(path62.join(rootDir, manifest))) return true;
|
|
31747
32048
|
}
|
|
31748
32049
|
return false;
|
|
31749
32050
|
}
|
|
@@ -31787,19 +32088,19 @@ async function getCurrentWorkflow(rootDir, taskId) {
|
|
|
31787
32088
|
}
|
|
31788
32089
|
async function getProjectName(rootDir) {
|
|
31789
32090
|
try {
|
|
31790
|
-
const raw = await fs9.readFile(
|
|
32091
|
+
const raw = await fs9.readFile(path62.join(rootDir, "package.json"), "utf-8");
|
|
31791
32092
|
const pkg = JSON.parse(raw);
|
|
31792
32093
|
if (pkg.name && typeof pkg.name === "string") {
|
|
31793
32094
|
return pkg.name;
|
|
31794
32095
|
}
|
|
31795
32096
|
} catch {
|
|
31796
32097
|
}
|
|
31797
|
-
return
|
|
32098
|
+
return path62.basename(rootDir);
|
|
31798
32099
|
}
|
|
31799
32100
|
async function readConfig3(rootDir) {
|
|
31800
32101
|
try {
|
|
31801
32102
|
const raw = await fs9.readFile(
|
|
31802
|
-
|
|
32103
|
+
path62.join(rootDir, ".mancode", "config.json"),
|
|
31803
32104
|
"utf-8"
|
|
31804
32105
|
);
|
|
31805
32106
|
return JSON.parse(raw);
|
|
@@ -31827,9 +32128,9 @@ function getEffectiveTeamStatus(state, config, detected) {
|
|
|
31827
32128
|
}
|
|
31828
32129
|
async function checkHooks(rootDir) {
|
|
31829
32130
|
const [sessionStart, userPromptSubmit, registered] = await Promise.all([
|
|
31830
|
-
pathExists13(
|
|
32131
|
+
pathExists13(path62.join(rootDir, ".mancode", "hooks", "session-start.mjs")),
|
|
31831
32132
|
pathExists13(
|
|
31832
|
-
|
|
32133
|
+
path62.join(rootDir, ".mancode", "hooks", "user-prompt-submit.mjs")
|
|
31833
32134
|
),
|
|
31834
32135
|
isRegistered(rootDir)
|
|
31835
32136
|
]);
|
|
@@ -31838,7 +32139,7 @@ async function checkHooks(rootDir) {
|
|
|
31838
32139
|
async function isRegistered(rootDir) {
|
|
31839
32140
|
try {
|
|
31840
32141
|
const raw = await fs9.readFile(
|
|
31841
|
-
|
|
32142
|
+
path62.join(rootDir, ".claude", "settings.json"),
|
|
31842
32143
|
"utf-8"
|
|
31843
32144
|
);
|
|
31844
32145
|
const settings = JSON.parse(raw);
|
|
@@ -31867,7 +32168,7 @@ function hasHookCommand2(value, needle) {
|
|
|
31867
32168
|
});
|
|
31868
32169
|
}
|
|
31869
32170
|
async function estimateHookInjection(rootDir) {
|
|
31870
|
-
const hookPath =
|
|
32171
|
+
const hookPath = path62.join(
|
|
31871
32172
|
rootDir,
|
|
31872
32173
|
".mancode",
|
|
31873
32174
|
"hooks",
|
|
@@ -33364,8 +33665,8 @@ function assertPositiveRevision2(value, label) {
|
|
|
33364
33665
|
}
|
|
33365
33666
|
|
|
33366
33667
|
// src/team/git-ref-handoff-repair.ts
|
|
33367
|
-
import { lstat as lstat23, mkdir as mkdir37, readFile as readFile43, readdir as readdir19, writeFile as
|
|
33368
|
-
import
|
|
33668
|
+
import { lstat as lstat23, mkdir as mkdir37, readFile as readFile43, readdir as readdir19, writeFile as writeFile44 } from "fs/promises";
|
|
33669
|
+
import path63 from "path";
|
|
33369
33670
|
|
|
33370
33671
|
// src/team/git-ref-operation.ts
|
|
33371
33672
|
import { execFile as execFileCallback6 } from "child_process";
|
|
@@ -35943,7 +36244,7 @@ async function recoverGitRefHandoffRepairs(projectRoot) {
|
|
|
35943
36244
|
}
|
|
35944
36245
|
async function recoverGitRefHandoffRepair(projectRoot, operationId, transportReceipt) {
|
|
35945
36246
|
assertUlid(operationId, "git-ref handoff repair operationId");
|
|
35946
|
-
const root =
|
|
36247
|
+
const root = path63.resolve(projectRoot);
|
|
35947
36248
|
let journal = await requireJournal2(root, operationId);
|
|
35948
36249
|
if (journal.state === "committed" || journal.state === "aborted") {
|
|
35949
36250
|
return recoveryResult2(journal);
|
|
@@ -36022,7 +36323,7 @@ async function recoverGitRefHandoffRepair(projectRoot, operationId, transportRec
|
|
|
36022
36323
|
}
|
|
36023
36324
|
}
|
|
36024
36325
|
async function prepareHandoffRepairWhileTaskLocked(projectRoot, rawPrepared) {
|
|
36025
|
-
const root =
|
|
36326
|
+
const root = path63.resolve(projectRoot);
|
|
36026
36327
|
const prepared2 = parsePrepared2(rawPrepared);
|
|
36027
36328
|
const runtime = await readProjectRuntimeContext(root);
|
|
36028
36329
|
const previousMetadata = bundleMetadata2(prepared2.predecessorBundle);
|
|
@@ -36085,7 +36386,7 @@ async function restorePredecessorMetadata2(projectRoot, journal) {
|
|
|
36085
36386
|
);
|
|
36086
36387
|
}
|
|
36087
36388
|
async function replaceMetadataVerified(projectRoot, expected, targetMetadata, alternateExpected) {
|
|
36088
|
-
const target =
|
|
36389
|
+
const target = path63.join(
|
|
36089
36390
|
taskRootPath(projectRoot, targetMetadata.taskRef),
|
|
36090
36391
|
"metadata.json"
|
|
36091
36392
|
);
|
|
@@ -36211,7 +36512,7 @@ async function createJournal3(projectRoot, journal) {
|
|
|
36211
36512
|
await ensureJournalDirectory2(projectRoot);
|
|
36212
36513
|
const target = journalPath3(projectRoot, journal.operationId);
|
|
36213
36514
|
try {
|
|
36214
|
-
await
|
|
36515
|
+
await writeFile44(target, serialize13(journal), {
|
|
36215
36516
|
encoding: "utf8",
|
|
36216
36517
|
flag: "wx"
|
|
36217
36518
|
});
|
|
@@ -36254,7 +36555,7 @@ async function listJournals2(projectRoot) {
|
|
|
36254
36555
|
parseJournal3(
|
|
36255
36556
|
JSON.parse(
|
|
36256
36557
|
await readFile43(
|
|
36257
|
-
|
|
36558
|
+
path63.join(journalDirectory2(projectRoot), entry),
|
|
36258
36559
|
"utf8"
|
|
36259
36560
|
)
|
|
36260
36561
|
)
|
|
@@ -36276,17 +36577,17 @@ async function readSafeFile2(target) {
|
|
|
36276
36577
|
return content;
|
|
36277
36578
|
}
|
|
36278
36579
|
async function atomicWrite2(target, content) {
|
|
36279
|
-
const temporary =
|
|
36280
|
-
|
|
36281
|
-
`.${
|
|
36580
|
+
const temporary = path63.join(
|
|
36581
|
+
path63.dirname(target),
|
|
36582
|
+
`.${path63.basename(target)}.${process.pid}.${Date.now()}.tmp`
|
|
36282
36583
|
);
|
|
36283
|
-
await
|
|
36584
|
+
await writeFile44(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
36284
36585
|
await replaceFileAtomically(temporary, target);
|
|
36285
36586
|
}
|
|
36286
36587
|
async function ensureJournalDirectory2(projectRoot) {
|
|
36287
|
-
let current =
|
|
36588
|
+
let current = path63.resolve(projectRoot);
|
|
36288
36589
|
for (const segment of [".mancode", "local", "journals", "git-ref-handoff"]) {
|
|
36289
|
-
current =
|
|
36590
|
+
current = path63.join(current, segment);
|
|
36290
36591
|
try {
|
|
36291
36592
|
await mkdir37(current);
|
|
36292
36593
|
} catch (error) {
|
|
@@ -36299,8 +36600,8 @@ async function ensureJournalDirectory2(projectRoot) {
|
|
|
36299
36600
|
}
|
|
36300
36601
|
}
|
|
36301
36602
|
function journalDirectory2(projectRoot) {
|
|
36302
|
-
return
|
|
36303
|
-
|
|
36603
|
+
return path63.join(
|
|
36604
|
+
path63.resolve(projectRoot),
|
|
36304
36605
|
".mancode",
|
|
36305
36606
|
"local",
|
|
36306
36607
|
"journals",
|
|
@@ -36309,7 +36610,7 @@ function journalDirectory2(projectRoot) {
|
|
|
36309
36610
|
}
|
|
36310
36611
|
function journalPath3(projectRoot, operationId) {
|
|
36311
36612
|
assertUlid(operationId, "git-ref handoff repair operationId");
|
|
36312
|
-
return
|
|
36613
|
+
return path63.join(journalDirectory2(projectRoot), `${operationId}.json`);
|
|
36313
36614
|
}
|
|
36314
36615
|
function serialize13(value) {
|
|
36315
36616
|
return `${JSON.stringify(value, null, 2)}
|
|
@@ -36408,8 +36709,8 @@ function parseReceipt(value) {
|
|
|
36408
36709
|
}
|
|
36409
36710
|
|
|
36410
36711
|
// src/team/policy-operation.ts
|
|
36411
|
-
import { lstat as lstat24, mkdir as mkdir38, readdir as readdir20, unlink as unlink3, writeFile as
|
|
36412
|
-
import
|
|
36712
|
+
import { lstat as lstat24, mkdir as mkdir38, readdir as readdir20, unlink as unlink3, writeFile as writeFile45 } from "fs/promises";
|
|
36713
|
+
import path64 from "path";
|
|
36413
36714
|
async function updateTeamPolicy(input) {
|
|
36414
36715
|
const operationId = input.operationId ?? createUlid();
|
|
36415
36716
|
const eventId = createUlid();
|
|
@@ -36420,7 +36721,7 @@ async function updateTeamPolicy(input) {
|
|
|
36420
36721
|
throw new Error("MANCODE_TEAM_POLICY_INVALID");
|
|
36421
36722
|
}
|
|
36422
36723
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
36423
|
-
const root =
|
|
36724
|
+
const root = path64.resolve(input.projectRoot);
|
|
36424
36725
|
const runtime = await readProjectRuntimeContext(root);
|
|
36425
36726
|
const store = resolveCoordinationEntityHomeStore(
|
|
36426
36727
|
runtime.entityHomeStoreContext
|
|
@@ -36501,7 +36802,7 @@ async function applyTeamTransportSet(input, write2) {
|
|
|
36501
36802
|
}
|
|
36502
36803
|
const remote = transportRemote(input.mode, input.remote);
|
|
36503
36804
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
36504
|
-
const root =
|
|
36805
|
+
const root = path64.resolve(input.projectRoot);
|
|
36505
36806
|
const runtime = await readProjectRuntimeContext(root);
|
|
36506
36807
|
const store = resolveCoordinationEntityHomeStore(
|
|
36507
36808
|
runtime.entityHomeStoreContext
|
|
@@ -36634,9 +36935,9 @@ async function assertTransportAuthorityEmpty(projectRoot, store) {
|
|
|
36634
36935
|
listClaims(store),
|
|
36635
36936
|
listHandoffs(store),
|
|
36636
36937
|
directoryHasEntries(taskHeadDirectory(store)),
|
|
36637
|
-
directoryHasEntries(
|
|
36938
|
+
directoryHasEntries(path64.join(store.root, "transport-migrations")),
|
|
36638
36939
|
directoryHasEntries(
|
|
36639
|
-
|
|
36940
|
+
path64.join(projectRoot, ".mancode", "shared", "team", "transport")
|
|
36640
36941
|
),
|
|
36641
36942
|
pathExists14(gitRefCachePath(projectRoot))
|
|
36642
36943
|
]);
|
|
@@ -36666,21 +36967,21 @@ function assertPositiveRevision5(value, label) {
|
|
|
36666
36967
|
}
|
|
36667
36968
|
}
|
|
36668
36969
|
function teamPolicyPath(projectRoot) {
|
|
36669
|
-
return
|
|
36970
|
+
return path64.join(projectRoot, ".mancode", "shared", "team", "policy.json");
|
|
36670
36971
|
}
|
|
36671
36972
|
function projectConfigPath(projectRoot) {
|
|
36672
|
-
return
|
|
36973
|
+
return path64.join(projectRoot, ".mancode", "shared", "config.json");
|
|
36673
36974
|
}
|
|
36674
36975
|
async function writeJsonAtomic4(target, value) {
|
|
36675
|
-
await mkdir38(
|
|
36676
|
-
await assertPlainDirectory(
|
|
36976
|
+
await mkdir38(path64.dirname(target), { recursive: true });
|
|
36977
|
+
await assertPlainDirectory(path64.dirname(target));
|
|
36677
36978
|
await assertPlainFileOrMissing(target);
|
|
36678
|
-
const temporary =
|
|
36679
|
-
|
|
36680
|
-
`.${
|
|
36979
|
+
const temporary = path64.join(
|
|
36980
|
+
path64.dirname(target),
|
|
36981
|
+
`.${path64.basename(target)}.${process.pid}.${createUlid()}.tmp`
|
|
36681
36982
|
);
|
|
36682
36983
|
try {
|
|
36683
|
-
await
|
|
36984
|
+
await writeFile45(temporary, `${JSON.stringify(value, null, 2)}
|
|
36684
36985
|
`, {
|
|
36685
36986
|
encoding: "utf8",
|
|
36686
36987
|
flag: "wx"
|
|
@@ -36744,9 +37045,9 @@ import {
|
|
|
36744
37045
|
readdir as readdir21,
|
|
36745
37046
|
rename as rename12,
|
|
36746
37047
|
unlink as unlink4,
|
|
36747
|
-
writeFile as
|
|
37048
|
+
writeFile as writeFile46
|
|
36748
37049
|
} from "fs/promises";
|
|
36749
|
-
import
|
|
37050
|
+
import path65 from "path";
|
|
36750
37051
|
|
|
36751
37052
|
// src/team/transport-migration.ts
|
|
36752
37053
|
var DIGEST_PATTERN7 = /^sha256:[a-f0-9]{64}$/;
|
|
@@ -37818,7 +38119,7 @@ function compareUtf813(left, right) {
|
|
|
37818
38119
|
var STAGE_DIRECTORY = "transport-migrations";
|
|
37819
38120
|
var COLLECTIONS = ["claims", "handoffs", "task-heads"];
|
|
37820
38121
|
async function createTransportMigrationFileAdapters(input) {
|
|
37821
|
-
const projectRoot =
|
|
38122
|
+
const projectRoot = path65.resolve(input.projectRoot);
|
|
37822
38123
|
assertUlid(input.actorId, "transport migration adapter actorId");
|
|
37823
38124
|
if (input.operationId !== void 0) {
|
|
37824
38125
|
assertUlid(input.operationId, "transport migration adapter operationId");
|
|
@@ -37870,7 +38171,7 @@ async function createTransportMigrationFileAdapters(input) {
|
|
|
37870
38171
|
var FileSystemTransportMigrationConfigAdapter = class {
|
|
37871
38172
|
constructor(projectRoot, coordinationStore) {
|
|
37872
38173
|
this.coordinationStore = coordinationStore;
|
|
37873
|
-
this.projectRoot =
|
|
38174
|
+
this.projectRoot = path65.resolve(projectRoot);
|
|
37874
38175
|
}
|
|
37875
38176
|
projectRoot;
|
|
37876
38177
|
async read() {
|
|
@@ -38723,7 +39024,7 @@ async function publishMigrationActorProfiles(projectRoot, profiles) {
|
|
|
38723
39024
|
}
|
|
38724
39025
|
}
|
|
38725
39026
|
async function archiveLocalCoordinationCollections(store, operationId) {
|
|
38726
|
-
const archiveRoot =
|
|
39027
|
+
const archiveRoot = path65.join(
|
|
38727
39028
|
store.root,
|
|
38728
39029
|
STAGE_DIRECTORY,
|
|
38729
39030
|
"archive",
|
|
@@ -38736,14 +39037,14 @@ async function archiveLocalCoordinationCollections(store, operationId) {
|
|
|
38736
39037
|
"task-heads": taskHeadDirectory(store)
|
|
38737
39038
|
};
|
|
38738
39039
|
for (const name of COLLECTIONS) {
|
|
38739
|
-
const archived =
|
|
38740
|
-
const absent =
|
|
39040
|
+
const archived = path65.join(archiveRoot, name);
|
|
39041
|
+
const absent = path65.join(archiveRoot, `${name}.absent`);
|
|
38741
39042
|
if (await pathKind(archived) === "directory" || await pathKind(absent) === "file") {
|
|
38742
39043
|
continue;
|
|
38743
39044
|
}
|
|
38744
39045
|
const sourceKind = await pathKind(directories[name]);
|
|
38745
39046
|
if (sourceKind === null) {
|
|
38746
|
-
await
|
|
39047
|
+
await writeFile46(absent, "\n", { encoding: "utf8", flag: "wx" });
|
|
38747
39048
|
continue;
|
|
38748
39049
|
}
|
|
38749
39050
|
if (sourceKind !== "directory") {
|
|
@@ -38775,7 +39076,7 @@ async function listActorProfiles(projectRoot) {
|
|
|
38775
39076
|
return profiles;
|
|
38776
39077
|
}
|
|
38777
39078
|
async function listSharedTaskRefs(projectRoot) {
|
|
38778
|
-
const directory =
|
|
39079
|
+
const directory = path65.join(projectRoot, ".mancode", "shared", "workflows");
|
|
38779
39080
|
let entries;
|
|
38780
39081
|
try {
|
|
38781
39082
|
entries = await readdir21(directory);
|
|
@@ -38786,7 +39087,7 @@ async function listSharedTaskRefs(projectRoot) {
|
|
|
38786
39087
|
const refs = [];
|
|
38787
39088
|
for (const taskId of entries.sort(compareUtf814)) {
|
|
38788
39089
|
assertUlid(taskId, "shared workflow directory");
|
|
38789
|
-
const stat5 = await lstat25(
|
|
39090
|
+
const stat5 = await lstat25(path65.join(directory, taskId));
|
|
38790
39091
|
if (!stat5.isDirectory() || stat5.isSymbolicLink()) {
|
|
38791
39092
|
throw new Error("MANCODE_CONTEXT_PATH_UNSAFE");
|
|
38792
39093
|
}
|
|
@@ -38860,7 +39161,7 @@ async function readStagedRecord(store, operationId) {
|
|
|
38860
39161
|
);
|
|
38861
39162
|
}
|
|
38862
39163
|
function stagedPath(store, operationId) {
|
|
38863
|
-
return
|
|
39164
|
+
return path65.join(
|
|
38864
39165
|
store.root,
|
|
38865
39166
|
STAGE_DIRECTORY,
|
|
38866
39167
|
"staged",
|
|
@@ -38868,7 +39169,7 @@ function stagedPath(store, operationId) {
|
|
|
38868
39169
|
);
|
|
38869
39170
|
}
|
|
38870
39171
|
function establishedPath(store, operationId) {
|
|
38871
|
-
return
|
|
39172
|
+
return path65.join(
|
|
38872
39173
|
store.root,
|
|
38873
39174
|
STAGE_DIRECTORY,
|
|
38874
39175
|
"established",
|
|
@@ -38876,7 +39177,7 @@ function establishedPath(store, operationId) {
|
|
|
38876
39177
|
);
|
|
38877
39178
|
}
|
|
38878
39179
|
function projectConfigPath2(projectRoot) {
|
|
38879
|
-
return
|
|
39180
|
+
return path65.join(projectRoot, ".mancode", "shared", "config.json");
|
|
38880
39181
|
}
|
|
38881
39182
|
async function readProjectConfigFile(projectRoot) {
|
|
38882
39183
|
try {
|
|
@@ -38891,14 +39192,14 @@ async function readProjectConfigFile(projectRoot) {
|
|
|
38891
39192
|
}
|
|
38892
39193
|
}
|
|
38893
39194
|
async function writeJsonAtomic5(target, value) {
|
|
38894
|
-
await mkdir39(
|
|
38895
|
-
await assertPlainDirectory2(
|
|
38896
|
-
const temporary =
|
|
38897
|
-
|
|
38898
|
-
`.${
|
|
39195
|
+
await mkdir39(path65.dirname(target), { recursive: true });
|
|
39196
|
+
await assertPlainDirectory2(path65.dirname(target));
|
|
39197
|
+
const temporary = path65.join(
|
|
39198
|
+
path65.dirname(target),
|
|
39199
|
+
`.${path65.basename(target)}.${process.pid}.${createUlid()}.tmp`
|
|
38899
39200
|
);
|
|
38900
39201
|
try {
|
|
38901
|
-
await
|
|
39202
|
+
await writeFile46(temporary, serialize14(value), {
|
|
38902
39203
|
encoding: "utf8",
|
|
38903
39204
|
flag: "wx"
|
|
38904
39205
|
});
|
|
@@ -38909,10 +39210,10 @@ async function writeJsonAtomic5(target, value) {
|
|
|
38909
39210
|
}
|
|
38910
39211
|
}
|
|
38911
39212
|
async function writeJsonExclusiveOrEqual(target, value, parser, conflictCode) {
|
|
38912
|
-
await mkdir39(
|
|
38913
|
-
await assertPlainDirectory2(
|
|
39213
|
+
await mkdir39(path65.dirname(target), { recursive: true });
|
|
39214
|
+
await assertPlainDirectory2(path65.dirname(target));
|
|
38914
39215
|
try {
|
|
38915
|
-
await
|
|
39216
|
+
await writeFile46(target, serialize14(value), { encoding: "utf8", flag: "wx" });
|
|
38916
39217
|
} catch (error) {
|
|
38917
39218
|
if (!isAlreadyExists25(error)) throw error;
|
|
38918
39219
|
const existing = await readJsonOrNull5(target, parser, conflictCode);
|
|
@@ -40460,16 +40761,16 @@ function parsePositiveInteger6(value) {
|
|
|
40460
40761
|
}
|
|
40461
40762
|
|
|
40462
40763
|
// src/commands/uninstall.ts
|
|
40463
|
-
import { access as access5, readFile as readFile45, rm as rm20, writeFile as
|
|
40464
|
-
import
|
|
40764
|
+
import { access as access5, readFile as readFile45, rm as rm20, writeFile as writeFile47 } from "fs/promises";
|
|
40765
|
+
import path66 from "path";
|
|
40465
40766
|
import process12 from "process";
|
|
40466
40767
|
var EXIT_OK10 = 0;
|
|
40467
40768
|
var EXIT_NOT_INITIALIZED7 = 1;
|
|
40468
40769
|
var EXIT_UNSUPPORTED_PLATFORM2 = 2;
|
|
40469
40770
|
var EXIT_V3_AUTHORITY_PROTECTED = 3;
|
|
40470
40771
|
async function uninstall(rootDir = process12.cwd(), platform, options = {}) {
|
|
40471
|
-
const stateFile =
|
|
40472
|
-
const v3SchemaFile =
|
|
40772
|
+
const stateFile = path66.join(rootDir, ".mancode", "state.json");
|
|
40773
|
+
const v3SchemaFile = path66.join(rootDir, ".mancode", "schema.json");
|
|
40473
40774
|
if (await pathExists15(v3SchemaFile)) {
|
|
40474
40775
|
return uninstallV3(rootDir, platform, options);
|
|
40475
40776
|
}
|
|
@@ -40551,6 +40852,10 @@ async function uninstallPlatform(rootDir, platform) {
|
|
|
40551
40852
|
await uninstallCopilot(rootDir);
|
|
40552
40853
|
} else if (platform === "zcode") {
|
|
40553
40854
|
await uninstallZcode(rootDir);
|
|
40855
|
+
} else if (platform === "kimi-code") {
|
|
40856
|
+
await uninstallKimiCode(rootDir);
|
|
40857
|
+
} else if (platform === "qoder") {
|
|
40858
|
+
await uninstallQoder(rootDir);
|
|
40554
40859
|
}
|
|
40555
40860
|
await removeFromConfig(rootDir, platform);
|
|
40556
40861
|
}
|
|
@@ -40560,7 +40865,7 @@ async function uninstallAll(rootDir) {
|
|
|
40560
40865
|
await uninstallPlatform(rootDir, p);
|
|
40561
40866
|
}
|
|
40562
40867
|
console.log("\u2713 Removing .mancode/ directory...");
|
|
40563
|
-
await rm20(
|
|
40868
|
+
await rm20(path66.join(rootDir, ".mancode"), {
|
|
40564
40869
|
recursive: true,
|
|
40565
40870
|
force: true
|
|
40566
40871
|
});
|
|
@@ -40570,7 +40875,7 @@ async function uninstallClaudeCode(rootDir) {
|
|
|
40570
40875
|
await cleanClaudeSettings(rootDir);
|
|
40571
40876
|
}
|
|
40572
40877
|
async function cleanClaudeSettings(rootDir) {
|
|
40573
|
-
const settingsPath =
|
|
40878
|
+
const settingsPath = path66.join(rootDir, ".claude", "settings.json");
|
|
40574
40879
|
let content;
|
|
40575
40880
|
try {
|
|
40576
40881
|
content = await readFile45(settingsPath, "utf-8");
|
|
@@ -40599,7 +40904,7 @@ async function cleanClaudeSettings(rootDir) {
|
|
|
40599
40904
|
);
|
|
40600
40905
|
settings.skills = Object.keys(retainedSkills).length > 0 ? retainedSkills : void 0;
|
|
40601
40906
|
}
|
|
40602
|
-
await
|
|
40907
|
+
await writeFile47(
|
|
40603
40908
|
settingsPath,
|
|
40604
40909
|
`${JSON.stringify(settings, null, 2)}
|
|
40605
40910
|
`,
|
|
@@ -40648,12 +40953,12 @@ async function uninstallCursor(rootDir) {
|
|
|
40648
40953
|
await removeCursorCommands(rootDir);
|
|
40649
40954
|
}
|
|
40650
40955
|
async function uninstallCodex(rootDir) {
|
|
40651
|
-
const agentsPath =
|
|
40956
|
+
const agentsPath = path66.join(rootDir, "AGENTS.md");
|
|
40652
40957
|
try {
|
|
40653
40958
|
const content = await readFile45(agentsPath, "utf-8");
|
|
40654
40959
|
const cleaned = removeManagedBlock(content);
|
|
40655
40960
|
if (cleaned.trim()) {
|
|
40656
|
-
await
|
|
40961
|
+
await writeFile47(agentsPath, `${cleaned}
|
|
40657
40962
|
`, "utf-8");
|
|
40658
40963
|
} else {
|
|
40659
40964
|
await rm20(agentsPath, { force: true });
|
|
@@ -40663,7 +40968,7 @@ async function uninstallCodex(rootDir) {
|
|
|
40663
40968
|
await removeCodexSkills(rootDir);
|
|
40664
40969
|
}
|
|
40665
40970
|
async function uninstallCopilot(rootDir) {
|
|
40666
|
-
const instructionsPath =
|
|
40971
|
+
const instructionsPath = path66.join(
|
|
40667
40972
|
rootDir,
|
|
40668
40973
|
".github",
|
|
40669
40974
|
"copilot-instructions.md"
|
|
@@ -40672,7 +40977,7 @@ async function uninstallCopilot(rootDir) {
|
|
|
40672
40977
|
const content = await readFile45(instructionsPath, "utf-8");
|
|
40673
40978
|
const cleaned = removeManagedBlock(content);
|
|
40674
40979
|
if (cleaned.trim()) {
|
|
40675
|
-
await
|
|
40980
|
+
await writeFile47(instructionsPath, `${cleaned}
|
|
40676
40981
|
`, "utf-8");
|
|
40677
40982
|
} else {
|
|
40678
40983
|
await rm20(instructionsPath, { force: true });
|
|
@@ -40682,7 +40987,7 @@ async function uninstallCopilot(rootDir) {
|
|
|
40682
40987
|
await removeCopilotPrompts(rootDir);
|
|
40683
40988
|
}
|
|
40684
40989
|
async function uninstallZcode(rootDir) {
|
|
40685
|
-
const agentsPath =
|
|
40990
|
+
const agentsPath = path66.join(rootDir, "AGENTS.md");
|
|
40686
40991
|
try {
|
|
40687
40992
|
const content = await readFile45(agentsPath, "utf-8");
|
|
40688
40993
|
const cleaned = removeManagedBlock(
|
|
@@ -40691,7 +40996,7 @@ async function uninstallZcode(rootDir) {
|
|
|
40691
40996
|
ZCODE_MANCODE_END_MARKER
|
|
40692
40997
|
);
|
|
40693
40998
|
if (cleaned.trim()) {
|
|
40694
|
-
await
|
|
40999
|
+
await writeFile47(agentsPath, `${cleaned}
|
|
40695
41000
|
`, "utf-8");
|
|
40696
41001
|
} else {
|
|
40697
41002
|
await rm20(agentsPath, { force: true });
|
|
@@ -40700,8 +41005,46 @@ async function uninstallZcode(rootDir) {
|
|
|
40700
41005
|
}
|
|
40701
41006
|
await removeZcodeSkills(rootDir);
|
|
40702
41007
|
}
|
|
41008
|
+
async function uninstallKimiCode(rootDir) {
|
|
41009
|
+
const agentsPath = path66.join(rootDir, "AGENTS.md");
|
|
41010
|
+
try {
|
|
41011
|
+
const content = await readFile45(agentsPath, "utf-8");
|
|
41012
|
+
const cleaned = removeManagedBlock(
|
|
41013
|
+
content,
|
|
41014
|
+
KIMI_MANCODE_START_MARKER,
|
|
41015
|
+
KIMI_MANCODE_END_MARKER
|
|
41016
|
+
);
|
|
41017
|
+
if (cleaned.trim()) {
|
|
41018
|
+
await writeFile47(agentsPath, `${cleaned}
|
|
41019
|
+
`, "utf-8");
|
|
41020
|
+
} else {
|
|
41021
|
+
await rm20(agentsPath, { force: true });
|
|
41022
|
+
}
|
|
41023
|
+
} catch {
|
|
41024
|
+
}
|
|
41025
|
+
await removeKimiSkills(rootDir);
|
|
41026
|
+
}
|
|
41027
|
+
async function uninstallQoder(rootDir) {
|
|
41028
|
+
const agentsPath = path66.join(rootDir, "AGENTS.md");
|
|
41029
|
+
try {
|
|
41030
|
+
const content = await readFile45(agentsPath, "utf-8");
|
|
41031
|
+
const cleaned = removeManagedBlock(
|
|
41032
|
+
content,
|
|
41033
|
+
QODER_MANCODE_START_MARKER,
|
|
41034
|
+
QODER_MANCODE_END_MARKER
|
|
41035
|
+
);
|
|
41036
|
+
if (cleaned.trim()) {
|
|
41037
|
+
await writeFile47(agentsPath, `${cleaned}
|
|
41038
|
+
`, "utf-8");
|
|
41039
|
+
} else {
|
|
41040
|
+
await rm20(agentsPath, { force: true });
|
|
41041
|
+
}
|
|
41042
|
+
} catch {
|
|
41043
|
+
}
|
|
41044
|
+
await removeQoderCommands(rootDir);
|
|
41045
|
+
}
|
|
40703
41046
|
async function removeFromConfig(rootDir, platform) {
|
|
40704
|
-
const configPath =
|
|
41047
|
+
const configPath = path66.join(rootDir, ".mancode", "config.json");
|
|
40705
41048
|
try {
|
|
40706
41049
|
const raw = await readFile45(configPath, "utf-8");
|
|
40707
41050
|
const config = JSON.parse(raw);
|
|
@@ -40715,7 +41058,7 @@ async function removeFromConfig(rootDir, platform) {
|
|
|
40715
41058
|
);
|
|
40716
41059
|
config.platformOptions = Object.keys(platformOptions).length > 0 ? platformOptions : void 0;
|
|
40717
41060
|
}
|
|
40718
|
-
await
|
|
41061
|
+
await writeFile47(
|
|
40719
41062
|
configPath,
|
|
40720
41063
|
`${JSON.stringify(config, null, 2)}
|
|
40721
41064
|
`,
|
|
@@ -40748,8 +41091,8 @@ function version() {
|
|
|
40748
41091
|
}
|
|
40749
41092
|
|
|
40750
41093
|
// src/commands/workflow.ts
|
|
40751
|
-
import { access as access6, readFile as readFile47, rm as rm22, writeFile as
|
|
40752
|
-
import
|
|
41094
|
+
import { access as access6, readFile as readFile47, rm as rm22, writeFile as writeFile49 } from "fs/promises";
|
|
41095
|
+
import path68 from "path";
|
|
40753
41096
|
|
|
40754
41097
|
// src/context/child-result-merge.ts
|
|
40755
41098
|
async function mergeV3ChildResult(input) {
|
|
@@ -43813,9 +44156,9 @@ import {
|
|
|
43813
44156
|
readFile as readFile46,
|
|
43814
44157
|
rename as rename13,
|
|
43815
44158
|
rm as rm21,
|
|
43816
|
-
writeFile as
|
|
44159
|
+
writeFile as writeFile48
|
|
43817
44160
|
} from "fs/promises";
|
|
43818
|
-
import
|
|
44161
|
+
import path67 from "path";
|
|
43819
44162
|
|
|
43820
44163
|
// src/context/creation-resolution.ts
|
|
43821
44164
|
function resolveWorkflowCreation(request) {
|
|
@@ -43925,7 +44268,7 @@ function rejectConflict(provided, expected, label) {
|
|
|
43925
44268
|
|
|
43926
44269
|
// src/context/workflow-create.ts
|
|
43927
44270
|
async function createV3Workflow(input) {
|
|
43928
|
-
const projectRoot =
|
|
44271
|
+
const projectRoot = path67.resolve(requireProjectRoot2(input.projectRoot));
|
|
43929
44272
|
const task = requireText2(input.task, "workflow task");
|
|
43930
44273
|
const client = requireText2(input.client, "workflow client");
|
|
43931
44274
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
@@ -44110,8 +44453,8 @@ async function createV3Workflow(input) {
|
|
|
44110
44453
|
throw new Error("MANCODE_REVISION_CONFLICT");
|
|
44111
44454
|
}
|
|
44112
44455
|
const taskParent = await ensureSafeTaskParent3(projectRoot, taskRef);
|
|
44113
|
-
const targetDirectory =
|
|
44114
|
-
stagingDirectory =
|
|
44456
|
+
const targetDirectory = path67.join(taskParent, taskRef.taskId);
|
|
44457
|
+
stagingDirectory = path67.join(
|
|
44115
44458
|
taskParent,
|
|
44116
44459
|
`.${taskRef.taskId}.${operationId}.staging`
|
|
44117
44460
|
);
|
|
@@ -44560,7 +44903,7 @@ async function ensureSafeTaskParent3(projectRoot, taskRef) {
|
|
|
44560
44903
|
const segments = [".mancode", taskRef.namespace, "workflows"];
|
|
44561
44904
|
let current = projectRoot;
|
|
44562
44905
|
for (const segment of segments) {
|
|
44563
|
-
current =
|
|
44906
|
+
current = path67.join(current, segment);
|
|
44564
44907
|
const existing = await lstatOrNull5(current);
|
|
44565
44908
|
if (existing === null) {
|
|
44566
44909
|
await mkdir40(current);
|
|
@@ -44596,8 +44939,8 @@ async function writeStagedEntities(stagingDirectory, entities) {
|
|
|
44596
44939
|
}
|
|
44597
44940
|
async function writeStagedJson(stagingDirectory, fileName, value) {
|
|
44598
44941
|
await assertDirectory(stagingDirectory);
|
|
44599
|
-
const target =
|
|
44600
|
-
await
|
|
44942
|
+
const target = path67.join(stagingDirectory, fileName);
|
|
44943
|
+
await writeFile48(target, `${JSON.stringify(value, null, 2)}
|
|
44601
44944
|
`, {
|
|
44602
44945
|
encoding: "utf8",
|
|
44603
44946
|
flag: "wx"
|
|
@@ -44634,7 +44977,7 @@ async function validateStagedEntities(stagingDirectory) {
|
|
|
44634
44977
|
});
|
|
44635
44978
|
}
|
|
44636
44979
|
async function readStagedJson(stagingDirectory, fileName, parser) {
|
|
44637
|
-
const target =
|
|
44980
|
+
const target = path67.join(stagingDirectory, fileName);
|
|
44638
44981
|
const before = await lstat26(target);
|
|
44639
44982
|
if (!before.isFile() || before.isSymbolicLink()) {
|
|
44640
44983
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
@@ -45742,7 +46085,7 @@ async function workflow(rootDir, subcommand, args = [], options = {}) {
|
|
|
45742
46085
|
if (v3Activation === "v3_active") {
|
|
45743
46086
|
return workflowV3(rootDir, subcommand, args, options);
|
|
45744
46087
|
}
|
|
45745
|
-
if (!await pathExists16(
|
|
46088
|
+
if (!await pathExists16(path68.join(rootDir, ".mancode", "state.json"))) {
|
|
45746
46089
|
if (v3Activation !== null) {
|
|
45747
46090
|
return printV3Error(
|
|
45748
46091
|
options.json,
|
|
@@ -46834,7 +47177,7 @@ function parseV3ParticipantActorIds(values) {
|
|
|
46834
47177
|
return values;
|
|
46835
47178
|
}
|
|
46836
47179
|
async function readWorkflowInputFile(projectRoot, value) {
|
|
46837
|
-
const inputPath =
|
|
47180
|
+
const inputPath = path68.isAbsolute(value) ? value : path68.resolve(projectRoot, value);
|
|
46838
47181
|
return readFile47(inputPath, "utf8");
|
|
46839
47182
|
}
|
|
46840
47183
|
async function readWorkflowJsonInputFile(projectRoot, value) {
|
|
@@ -46908,7 +47251,7 @@ async function readV3ActivationState2(rootDir) {
|
|
|
46908
47251
|
try {
|
|
46909
47252
|
const manifest = parseSchemaManifest(
|
|
46910
47253
|
JSON.parse(
|
|
46911
|
-
await readFile47(
|
|
47254
|
+
await readFile47(path68.join(rootDir, ".mancode", "schema.json"), "utf8")
|
|
46912
47255
|
)
|
|
46913
47256
|
);
|
|
46914
47257
|
return manifest.activationState === "v3_active" ? "v3_active" : "other";
|
|
@@ -46953,15 +47296,15 @@ async function workflowRequirements(rootDir, args, options) {
|
|
|
46953
47296
|
"requirements can only be finalized for an in-progress man or manteam workflow at step 1 or 2"
|
|
46954
47297
|
);
|
|
46955
47298
|
}
|
|
46956
|
-
const workflowPath =
|
|
46957
|
-
const jsonPath =
|
|
46958
|
-
const markdownPath =
|
|
46959
|
-
const metadataPath3 =
|
|
47299
|
+
const workflowPath = path68.join(rootDir, ".mancode", "workflows", taskId);
|
|
47300
|
+
const jsonPath = path68.join(workflowPath, "requirements.json");
|
|
47301
|
+
const markdownPath = path68.join(workflowPath, "requirements.md");
|
|
47302
|
+
const metadataPath3 = path68.join(workflowPath, "metadata.json");
|
|
46960
47303
|
let originalJson;
|
|
46961
47304
|
let originalMarkdown;
|
|
46962
47305
|
let originalMetadata;
|
|
46963
47306
|
try {
|
|
46964
|
-
const inputPath =
|
|
47307
|
+
const inputPath = path68.isAbsolute(options.file) ? options.file : path68.resolve(rootDir, options.file);
|
|
46965
47308
|
const input = await readFile47(inputPath, "utf-8");
|
|
46966
47309
|
const requirements = parseRequirementsLedger2(input);
|
|
46967
47310
|
[originalJson, originalMarkdown, originalMetadata] = await Promise.all([
|
|
@@ -46997,7 +47340,7 @@ async function workflowRequirements(rootDir, args, options) {
|
|
|
46997
47340
|
const rollback = await Promise.allSettled([
|
|
46998
47341
|
restoreOptionalText(jsonPath, originalJson),
|
|
46999
47342
|
restoreOptionalText(markdownPath, originalMarkdown),
|
|
47000
|
-
|
|
47343
|
+
writeFile49(metadataPath3, originalMetadata, "utf-8")
|
|
47001
47344
|
]);
|
|
47002
47345
|
rollbackIncomplete = rollback.some(
|
|
47003
47346
|
(result2) => result2.status === "rejected"
|
|
@@ -47085,7 +47428,7 @@ async function workflowVerify(rootDir, args, options) {
|
|
|
47085
47428
|
);
|
|
47086
47429
|
}
|
|
47087
47430
|
if (options.evidenceFile) {
|
|
47088
|
-
const evidencePath =
|
|
47431
|
+
const evidencePath = path68.isAbsolute(options.evidenceFile) ? options.evidenceFile : path68.resolve(rootDir, options.evidenceFile);
|
|
47089
47432
|
if (!await pathExists16(evidencePath)) {
|
|
47090
47433
|
return invalidArg(
|
|
47091
47434
|
options,
|
|
@@ -47145,14 +47488,14 @@ async function workflowVerify(rootDir, args, options) {
|
|
|
47145
47488
|
}
|
|
47146
47489
|
async function commitVerificationTransition(rootDir, meta, ledger) {
|
|
47147
47490
|
const ledgerPath = verificationLedgerPath(rootDir, meta.taskId);
|
|
47148
|
-
const metadataPath3 =
|
|
47491
|
+
const metadataPath3 = path68.join(
|
|
47149
47492
|
rootDir,
|
|
47150
47493
|
".mancode",
|
|
47151
47494
|
"workflows",
|
|
47152
47495
|
meta.taskId,
|
|
47153
47496
|
"metadata.json"
|
|
47154
47497
|
);
|
|
47155
|
-
const specPath =
|
|
47498
|
+
const specPath = path68.join(rootDir, ".mancode", "memory", "spec.md");
|
|
47156
47499
|
const [originalLedger, originalMetadata, originalSpec] = await Promise.all([
|
|
47157
47500
|
readOptionalText2(ledgerPath),
|
|
47158
47501
|
readFile47(metadataPath3, "utf-8"),
|
|
@@ -47184,7 +47527,7 @@ async function commitVerificationTransition(rootDir, meta, ledger) {
|
|
|
47184
47527
|
} catch (error) {
|
|
47185
47528
|
const rollback = await Promise.allSettled([
|
|
47186
47529
|
restoreOptionalText(ledgerPath, originalLedger),
|
|
47187
|
-
|
|
47530
|
+
writeFile49(metadataPath3, originalMetadata, "utf-8"),
|
|
47188
47531
|
restoreOptionalText(specPath, originalSpec)
|
|
47189
47532
|
]);
|
|
47190
47533
|
const message = error instanceof Error ? error.message : "verification transition failed";
|
|
@@ -47316,7 +47659,7 @@ async function workflowReview(rootDir, args, options) {
|
|
|
47316
47659
|
}
|
|
47317
47660
|
async function commitReviewSkip(rootDir, meta, reason) {
|
|
47318
47661
|
const ledgerPath = reviewLedgerPath(rootDir, meta.taskId);
|
|
47319
|
-
const metadataPath3 =
|
|
47662
|
+
const metadataPath3 = path68.join(
|
|
47320
47663
|
rootDir,
|
|
47321
47664
|
".mancode",
|
|
47322
47665
|
"workflows",
|
|
@@ -47336,7 +47679,7 @@ async function commitReviewSkip(rootDir, meta, reason) {
|
|
|
47336
47679
|
} catch (error) {
|
|
47337
47680
|
const rollback = await Promise.allSettled([
|
|
47338
47681
|
restoreOptionalText(ledgerPath, originalLedger),
|
|
47339
|
-
|
|
47682
|
+
writeFile49(metadataPath3, originalMetadata, "utf-8")
|
|
47340
47683
|
]);
|
|
47341
47684
|
const message = error instanceof Error ? error.message : "review skip failed";
|
|
47342
47685
|
return rollback.some((result2) => result2.status === "rejected") ? `${message}; rollback was incomplete` : message;
|
|
@@ -47556,14 +47899,14 @@ async function workflowHandoff(rootDir, taskId, options) {
|
|
|
47556
47899
|
"solo handoff requires an undecided in-progress workflow at step 4 with ready requirements"
|
|
47557
47900
|
);
|
|
47558
47901
|
}
|
|
47559
|
-
const workflowPath =
|
|
47560
|
-
if (!await pathExists16(
|
|
47902
|
+
const workflowPath = path68.join(rootDir, ".mancode", "workflows", taskId);
|
|
47903
|
+
if (!await pathExists16(path68.join(workflowPath, "requirements.md")) || !await pathExists16(path68.join(workflowPath, "plan.md"))) {
|
|
47561
47904
|
return invalidArg(
|
|
47562
47905
|
options,
|
|
47563
47906
|
"solo handoff requires requirements.md and plan.md"
|
|
47564
47907
|
);
|
|
47565
47908
|
}
|
|
47566
|
-
const statePath =
|
|
47909
|
+
const statePath = path68.join(rootDir, ".mancode", "state.json");
|
|
47567
47910
|
let originalState;
|
|
47568
47911
|
let state;
|
|
47569
47912
|
try {
|
|
@@ -47638,7 +47981,7 @@ async function workflowCompleteHandoff(rootDir, taskId, options) {
|
|
|
47638
47981
|
`workflow is not an active solo handoff: ${taskId}`
|
|
47639
47982
|
);
|
|
47640
47983
|
}
|
|
47641
|
-
const statePath =
|
|
47984
|
+
const statePath = path68.join(rootDir, ".mancode", "state.json");
|
|
47642
47985
|
let originalState;
|
|
47643
47986
|
let state;
|
|
47644
47987
|
try {
|
|
@@ -47705,14 +48048,14 @@ async function workflowDecide(rootDir, taskId, options) {
|
|
|
47705
48048
|
`workflow is not ready for a plan-only decision: ${taskId}`
|
|
47706
48049
|
);
|
|
47707
48050
|
}
|
|
47708
|
-
const workflowPath =
|
|
47709
|
-
if (!await pathExists16(
|
|
48051
|
+
const workflowPath = path68.join(rootDir, ".mancode", "workflows", taskId);
|
|
48052
|
+
if (!await pathExists16(path68.join(workflowPath, "requirements.md")) || !await pathExists16(path68.join(workflowPath, "plan.md"))) {
|
|
47710
48053
|
return invalidArg(
|
|
47711
48054
|
options,
|
|
47712
48055
|
"plan-only requires requirements.md and plan.md"
|
|
47713
48056
|
);
|
|
47714
48057
|
}
|
|
47715
|
-
const statePath =
|
|
48058
|
+
const statePath = path68.join(rootDir, ".mancode", "state.json");
|
|
47716
48059
|
let originalState;
|
|
47717
48060
|
let state;
|
|
47718
48061
|
try {
|
|
@@ -47768,14 +48111,14 @@ async function workflowDecide(rootDir, taskId, options) {
|
|
|
47768
48111
|
return EXIT_OK11;
|
|
47769
48112
|
}
|
|
47770
48113
|
async function commitPlanningTransition(args) {
|
|
47771
|
-
const metadataPath3 =
|
|
48114
|
+
const metadataPath3 = path68.join(
|
|
47772
48115
|
args.rootDir,
|
|
47773
48116
|
".mancode",
|
|
47774
48117
|
"workflows",
|
|
47775
48118
|
args.taskId,
|
|
47776
48119
|
"metadata.json"
|
|
47777
48120
|
);
|
|
47778
|
-
const specPath =
|
|
48121
|
+
const specPath = path68.join(args.rootDir, ".mancode", "memory", "spec.md");
|
|
47779
48122
|
let originalMetadata;
|
|
47780
48123
|
let originalSpec;
|
|
47781
48124
|
try {
|
|
@@ -47786,7 +48129,7 @@ async function commitPlanningTransition(args) {
|
|
|
47786
48129
|
}
|
|
47787
48130
|
try {
|
|
47788
48131
|
await updateWorkflow(args.rootDir, args.taskId, args.workflowPatch);
|
|
47789
|
-
await
|
|
48132
|
+
await writeFile49(
|
|
47790
48133
|
args.statePath,
|
|
47791
48134
|
`${JSON.stringify(args.nextState, null, 2)}
|
|
47792
48135
|
`,
|
|
@@ -47800,9 +48143,9 @@ async function commitPlanningTransition(args) {
|
|
|
47800
48143
|
return null;
|
|
47801
48144
|
} catch (error) {
|
|
47802
48145
|
const rollback = await Promise.allSettled([
|
|
47803
|
-
|
|
47804
|
-
|
|
47805
|
-
originalSpec === null ? rm22(specPath, { force: true }) :
|
|
48146
|
+
writeFile49(metadataPath3, originalMetadata, "utf-8"),
|
|
48147
|
+
writeFile49(args.statePath, args.originalState, "utf-8"),
|
|
48148
|
+
originalSpec === null ? rm22(specPath, { force: true }) : writeFile49(specPath, originalSpec, "utf-8")
|
|
47806
48149
|
]);
|
|
47807
48150
|
const message = error instanceof Error ? error.message : "planning transition failed";
|
|
47808
48151
|
return rollback.some((result2) => result2.status === "rejected") ? `${message}; rollback was incomplete` : message;
|
|
@@ -47821,7 +48164,7 @@ async function restoreOptionalText(filePath, content) {
|
|
|
47821
48164
|
await rm22(filePath, { force: true });
|
|
47822
48165
|
return;
|
|
47823
48166
|
}
|
|
47824
|
-
await
|
|
48167
|
+
await writeFile49(filePath, content, "utf-8");
|
|
47825
48168
|
}
|
|
47826
48169
|
function readActiveSoloPlan(value) {
|
|
47827
48170
|
if (!value || typeof value !== "object") return null;
|
|
@@ -48084,7 +48427,7 @@ program.command("init").description("Initialize mancode in the current project")
|
|
|
48084
48427
|
process.exitCode = code;
|
|
48085
48428
|
});
|
|
48086
48429
|
program.command("install [platform]").description(
|
|
48087
|
-
"Install platform adapter (claude-code, cursor, codex, copilot, zcode)"
|
|
48430
|
+
"Install platform adapter (claude-code, cursor, codex, copilot, zcode, kimi-code, qoder)"
|
|
48088
48431
|
).option("--force", "Reinstall even if already installed").option("--minimal", "Minimal install (MVP-2)").option(
|
|
48089
48432
|
"--shadow",
|
|
48090
48433
|
"Stage a mancode bootstrap candidate without changing live files"
|
|
@@ -48171,7 +48514,7 @@ contextSessionProgram.command("show").description("Show one explicit session wit
|
|
|
48171
48514
|
});
|
|
48172
48515
|
contextSessionProgram.command("spike").description("Record real-host session evidence without persisting host keys").requiredOption(
|
|
48173
48516
|
"--platform <platform>",
|
|
48174
|
-
"claude-code, codex, cursor, copilot, or
|
|
48517
|
+
"claude-code, codex, cursor, copilot, zcode, kimi-code, or qoder"
|
|
48175
48518
|
).requiredOption("--session-mode <mode>", "Evidence path: host or explicit").requiredOption(
|
|
48176
48519
|
"--host-session-source <source>",
|
|
48177
48520
|
"hook_stdin, environment, api, or none for explicit sessions"
|