mancode 0.3.10 → 0.3.12
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 +138 -165
- package/README.md +121 -141
- package/dist/chunk-CFC3HBNA.js +1290 -0
- package/dist/chunk-CFC3HBNA.js.map +1 -0
- package/dist/cli.js +224 -84
- package/dist/cli.js.map +1 -1
- package/dist/{v3-adapter-3GJT3AID.js → v3-adapter-DDZB3Y6S.js} +18 -4
- package/package.json +1 -1
- package/dist/chunk-KEIW7AEP.js +0 -597
- package/dist/chunk-KEIW7AEP.js.map +0 -1
- /package/dist/{v3-adapter-3GJT3AID.js.map → v3-adapter-DDZB3Y6S.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
import {
|
|
3
3
|
VERSION
|
|
4
4
|
} from "./chunk-57PJQDQ3.js";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_MANCODE_END_MARKER,
|
|
7
|
+
DEFAULT_MANCODE_START_MARKER,
|
|
8
|
+
V3_ADAPTER_FILE_TARGETS,
|
|
9
|
+
V3_ADAPTER_VERSION,
|
|
10
|
+
applyV3AdapterFilePlan,
|
|
11
|
+
assertV3AdapterInstallable,
|
|
12
|
+
assertV3AdapterTargetSafe,
|
|
13
|
+
hasManagedBlock,
|
|
14
|
+
inspectV3Adapter,
|
|
15
|
+
inspectV3AdapterVersions,
|
|
16
|
+
installV3Adapter,
|
|
17
|
+
planV3AdapterFiles,
|
|
18
|
+
removeManagedBlock,
|
|
19
|
+
removeV3Adapter,
|
|
20
|
+
replaceManagedBlock,
|
|
21
|
+
stageV3Adapter,
|
|
22
|
+
v3AdapterTargetPath
|
|
23
|
+
} from "./chunk-CFC3HBNA.js";
|
|
5
24
|
import {
|
|
6
25
|
PROJECT_MANIFESTS,
|
|
7
26
|
V3ContextStore,
|
|
@@ -105,22 +124,6 @@ import {
|
|
|
105
124
|
writeOperationReservation,
|
|
106
125
|
writeProjectFacts
|
|
107
126
|
} from "./chunk-O3QAKAPJ.js";
|
|
108
|
-
import {
|
|
109
|
-
DEFAULT_MANCODE_END_MARKER,
|
|
110
|
-
DEFAULT_MANCODE_START_MARKER,
|
|
111
|
-
V3_ADAPTER_VERSION,
|
|
112
|
-
applyV3AdapterFilePlan,
|
|
113
|
-
hasManagedBlock,
|
|
114
|
-
inspectV3Adapter,
|
|
115
|
-
inspectV3AdapterVersions,
|
|
116
|
-
installV3Adapter,
|
|
117
|
-
planV3AdapterFiles,
|
|
118
|
-
removeManagedBlock,
|
|
119
|
-
removeV3Adapter,
|
|
120
|
-
replaceManagedBlock,
|
|
121
|
-
stageV3Adapter,
|
|
122
|
-
v3AdapterTargetPath
|
|
123
|
-
} from "./chunk-KEIW7AEP.js";
|
|
124
127
|
|
|
125
128
|
// src/cli.ts
|
|
126
129
|
import { program } from "commander";
|
|
@@ -1442,12 +1445,9 @@ function parseMigrationStageFileAction(value) {
|
|
|
1442
1445
|
targetContent
|
|
1443
1446
|
};
|
|
1444
1447
|
}
|
|
1445
|
-
var V3_ADAPTER_TARGETS =
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
"agents",
|
|
1449
|
-
"copilot-instructions"
|
|
1450
|
-
]);
|
|
1448
|
+
var V3_ADAPTER_TARGETS = new Set(
|
|
1449
|
+
V3_ADAPTER_FILE_TARGETS
|
|
1450
|
+
);
|
|
1451
1451
|
function parseV3AdapterFileAction(value) {
|
|
1452
1452
|
assertKnownKeys(
|
|
1453
1453
|
value,
|
|
@@ -11499,7 +11499,7 @@ async function activateLegacyMigration(input) {
|
|
|
11499
11499
|
for (const action of payload.actions.filter(
|
|
11500
11500
|
(action2) => action2.kind === "v3_adapter_file"
|
|
11501
11501
|
)) {
|
|
11502
|
-
const { applyV3AdapterFilePlan: applyV3AdapterFilePlan2 } = await import("./v3-adapter-
|
|
11502
|
+
const { applyV3AdapterFilePlan: applyV3AdapterFilePlan2 } = await import("./v3-adapter-DDZB3Y6S.js");
|
|
11503
11503
|
await applyV3AdapterFilePlan2(root, action);
|
|
11504
11504
|
}
|
|
11505
11505
|
journal = await completeActivationStep(
|
|
@@ -11645,6 +11645,7 @@ async function rollbackLegacyMigration(input) {
|
|
|
11645
11645
|
);
|
|
11646
11646
|
await rm7(target, { force: false });
|
|
11647
11647
|
} else if (action.kind === "v3_adapter_file") {
|
|
11648
|
+
await assertV3AdapterTargetSafe(root, action.target);
|
|
11648
11649
|
const target = v3AdapterTargetPath(root, action.target);
|
|
11649
11650
|
if (action.beforeContent === null) {
|
|
11650
11651
|
await rm7(target, { force: false });
|
|
@@ -11942,6 +11943,7 @@ async function assertActivationRollbackProof(projectRoot, localStore, coordinati
|
|
|
11942
11943
|
throw new Error("MANCODE_MIGRATION_ROLLBACK_FORBIDDEN");
|
|
11943
11944
|
}
|
|
11944
11945
|
} else if (action.kind === "v3_adapter_file") {
|
|
11946
|
+
await assertV3AdapterTargetSafe(projectRoot, action.target);
|
|
11945
11947
|
const current = await readTextOrNull(
|
|
11946
11948
|
v3AdapterTargetPath(projectRoot, action.target)
|
|
11947
11949
|
);
|
|
@@ -14214,6 +14216,7 @@ async function readMigrationStageFile(projectRoot, stageId) {
|
|
|
14214
14216
|
]);
|
|
14215
14217
|
}
|
|
14216
14218
|
async function readAdapterFile(projectRoot, target) {
|
|
14219
|
+
await assertV3AdapterTargetSafe(projectRoot, target);
|
|
14217
14220
|
const filePath = v3AdapterTargetPath(projectRoot, target);
|
|
14218
14221
|
try {
|
|
14219
14222
|
const entry = await lstat9(filePath);
|
|
@@ -24762,9 +24765,20 @@ var EXIT_NOT_A_PROJECT_DIR = 2;
|
|
|
24762
24765
|
var EXIT_USER_CANCEL = 3;
|
|
24763
24766
|
var EXIT_INIT_FAILED = 5;
|
|
24764
24767
|
var DEFAULT_INIT_PLATFORM = "claude-code";
|
|
24768
|
+
function resolveInitAuthority(options) {
|
|
24769
|
+
if (options.legacy) return "legacy";
|
|
24770
|
+
if (options.v3 || options.fromCli) return "v3";
|
|
24771
|
+
return "legacy";
|
|
24772
|
+
}
|
|
24765
24773
|
async function init(rootDir = process5.cwd(), options = {}) {
|
|
24774
|
+
if (options.v3 && options.legacy) {
|
|
24775
|
+
console.error("\u2717 --v3 and --legacy cannot be used together.");
|
|
24776
|
+
return EXIT_INIT_FAILED;
|
|
24777
|
+
}
|
|
24778
|
+
const authority = resolveInitAuthority(options);
|
|
24766
24779
|
const mancodeDir = path46.join(rootDir, ".mancode");
|
|
24767
24780
|
const stateFile = path46.join(mancodeDir, "state.json");
|
|
24781
|
+
const v3SchemaFile = path46.join(mancodeDir, "schema.json");
|
|
24768
24782
|
const wasInitialized = await pathExists6(stateFile);
|
|
24769
24783
|
let mutationSnapshots = [];
|
|
24770
24784
|
let directorySnapshots = [];
|
|
@@ -24774,7 +24788,16 @@ async function init(rootDir = process5.cwd(), options = {}) {
|
|
|
24774
24788
|
console.error(" Supported values: zh-CN, en");
|
|
24775
24789
|
return EXIT_INIT_FAILED;
|
|
24776
24790
|
}
|
|
24777
|
-
if (
|
|
24791
|
+
if (authority === "legacy" && await pathExists6(v3SchemaFile)) {
|
|
24792
|
+
console.error(
|
|
24793
|
+
"\u2717 V3 authority is already present; refusing to create legacy state.json."
|
|
24794
|
+
);
|
|
24795
|
+
console.error(
|
|
24796
|
+
" Use `mancode status` or `mancode install <platform>` to inspect or repair this project."
|
|
24797
|
+
);
|
|
24798
|
+
return EXIT_INIT_FAILED;
|
|
24799
|
+
}
|
|
24800
|
+
if (wasInitialized && authority === "legacy") {
|
|
24778
24801
|
if (!options.force) {
|
|
24779
24802
|
console.log(
|
|
24780
24803
|
localize(
|
|
@@ -24811,7 +24834,16 @@ async function init(rootDir = process5.cwd(), options = {}) {
|
|
|
24811
24834
|
);
|
|
24812
24835
|
return EXIT_NOT_A_PROJECT_DIR;
|
|
24813
24836
|
}
|
|
24814
|
-
if (
|
|
24837
|
+
if (authority === "v3") {
|
|
24838
|
+
if (options.fromCli) {
|
|
24839
|
+
const projectBoundaryExit = await validateV3CliProjectBoundary(
|
|
24840
|
+
rootDir,
|
|
24841
|
+
options,
|
|
24842
|
+
locale,
|
|
24843
|
+
wasInitialized
|
|
24844
|
+
);
|
|
24845
|
+
if (projectBoundaryExit !== null) return projectBoundaryExit;
|
|
24846
|
+
}
|
|
24815
24847
|
return initializeV3(rootDir, options);
|
|
24816
24848
|
}
|
|
24817
24849
|
const isGitRepo = await pathExists6(path46.join(rootDir, ".git"));
|
|
@@ -25188,13 +25220,69 @@ async function initializeV3(rootDir, options) {
|
|
|
25188
25220
|
);
|
|
25189
25221
|
return EXIT_INIT_FAILED;
|
|
25190
25222
|
}
|
|
25191
|
-
|
|
25223
|
+
if (options.style !== void 0) {
|
|
25224
|
+
console.error("\u2717 --style is only supported by `mancode init --legacy`.");
|
|
25225
|
+
console.error(
|
|
25226
|
+
" V3 detects project facts; run `mancode refresh-style` after initialization to refresh local style tokens."
|
|
25227
|
+
);
|
|
25228
|
+
return EXIT_INIT_FAILED;
|
|
25229
|
+
}
|
|
25230
|
+
const schemaPath = path46.join(rootDir, ".mancode", "schema.json");
|
|
25231
|
+
let existingV3 = false;
|
|
25232
|
+
if (await pathExists6(schemaPath)) {
|
|
25233
|
+
try {
|
|
25234
|
+
const manifest = parseSchemaManifest(
|
|
25235
|
+
JSON.parse(await fs4.readFile(schemaPath, "utf8"))
|
|
25236
|
+
);
|
|
25237
|
+
if (manifest.activationState !== "v3_active") {
|
|
25238
|
+
throw new Error(
|
|
25239
|
+
`MANCODE_V3_INIT_UNAVAILABLE_DURING_${manifest.activationState.toUpperCase()}`
|
|
25240
|
+
);
|
|
25241
|
+
}
|
|
25242
|
+
existingV3 = true;
|
|
25243
|
+
if (options.platform === void 0) {
|
|
25244
|
+
console.log("\u2139\uFE0F mancode V3 is already initialized.");
|
|
25245
|
+
return EXIT_ALREADY_INITIALIZED;
|
|
25246
|
+
}
|
|
25247
|
+
} catch (error) {
|
|
25248
|
+
printV3InitError(error);
|
|
25249
|
+
return EXIT_INIT_FAILED;
|
|
25250
|
+
}
|
|
25251
|
+
} else if ((await scanLegacyAuthority(rootDir)).authorityPresent) {
|
|
25252
|
+
printV3InitError(new Error("MANCODE_LEGACY_AUTHORITY_PRESENT"));
|
|
25253
|
+
return EXIT_INIT_FAILED;
|
|
25254
|
+
}
|
|
25255
|
+
const selectedPlatforms = options.platform !== void 0 ? parsePlatformSelection(options.platform) : options.fromCli ? await selectInitPlatforms({
|
|
25256
|
+
existingPlatform: null,
|
|
25257
|
+
hints: await detectPlatformHints(rootDir),
|
|
25258
|
+
interactive: options.interactive,
|
|
25259
|
+
prompter: options.prompter,
|
|
25260
|
+
locale: detectInitLocale(options.lang) ?? "en",
|
|
25261
|
+
yes: options.yes
|
|
25262
|
+
}) : [];
|
|
25192
25263
|
if (selectedPlatforms === null) {
|
|
25193
|
-
console.error(
|
|
25264
|
+
console.error(
|
|
25265
|
+
options.platform === void 0 ? "\u2717 No platform selected. Choose one interactively or pass --platform <name>." : `\u2717 Unsupported platform selection: ${options.platform}`
|
|
25266
|
+
);
|
|
25194
25267
|
console.error(" Use one or more supported platform names, or all.");
|
|
25195
25268
|
return EXIT_INIT_FAILED;
|
|
25196
25269
|
}
|
|
25197
25270
|
try {
|
|
25271
|
+
for (const platform of selectedPlatforms) {
|
|
25272
|
+
await assertV3AdapterInstallable(rootDir, platform);
|
|
25273
|
+
}
|
|
25274
|
+
if (existingV3) {
|
|
25275
|
+
for (const platform of selectedPlatforms) {
|
|
25276
|
+
await installV3Adapter(rootDir, platform);
|
|
25277
|
+
}
|
|
25278
|
+
console.log("\u2139\uFE0F mancode V3 is already initialized.");
|
|
25279
|
+
if (selectedPlatforms.length > 0) {
|
|
25280
|
+
console.log(
|
|
25281
|
+
` V3 bootstrap repaired: ${selectedPlatforms.join(", ")}`
|
|
25282
|
+
);
|
|
25283
|
+
}
|
|
25284
|
+
return EXIT_ALREADY_INITIALIZED;
|
|
25285
|
+
}
|
|
25198
25286
|
const result2 = await initializeV3Project({
|
|
25199
25287
|
projectRoot: rootDir,
|
|
25200
25288
|
teamPolicy: options.team === void 0 ? "auto" : options.team ? "on" : "off"
|
|
@@ -25219,14 +25307,17 @@ async function initializeV3(rootDir, options) {
|
|
|
25219
25307
|
}
|
|
25220
25308
|
return EXIT_OK;
|
|
25221
25309
|
} catch (error) {
|
|
25222
|
-
|
|
25223
|
-
console.error(`\u2717 ${message}`);
|
|
25224
|
-
if (message === "MANCODE_LEGACY_AUTHORITY_PRESENT") {
|
|
25225
|
-
console.error(" Run `mancode migrate context --dry-run` instead.");
|
|
25226
|
-
}
|
|
25310
|
+
printV3InitError(error);
|
|
25227
25311
|
return EXIT_INIT_FAILED;
|
|
25228
25312
|
}
|
|
25229
25313
|
}
|
|
25314
|
+
function printV3InitError(error) {
|
|
25315
|
+
const message = error instanceof Error ? error.message : "V3 initialization failed";
|
|
25316
|
+
console.error(`\u2717 ${message}`);
|
|
25317
|
+
if (message === "MANCODE_LEGACY_AUTHORITY_PRESENT") {
|
|
25318
|
+
console.error(" Run `mancode migrate context --dry-run` instead.");
|
|
25319
|
+
}
|
|
25320
|
+
}
|
|
25230
25321
|
async function updateConfigOptions(mancodeDir, patch, preserveInstalledPlatforms) {
|
|
25231
25322
|
const configPath = path46.join(mancodeDir, "config.json");
|
|
25232
25323
|
let config = {};
|
|
@@ -25346,6 +25437,28 @@ async function canInitializeGenericProject(rootDir) {
|
|
|
25346
25437
|
return { ok: false, reason: "unsafe" };
|
|
25347
25438
|
}
|
|
25348
25439
|
}
|
|
25440
|
+
async function validateV3CliProjectBoundary(rootDir, options, locale, legacyInitialized) {
|
|
25441
|
+
const isGitRepo = await pathExists6(path46.join(rootDir, ".git"));
|
|
25442
|
+
const hasManifest = await hasProjectManifest(rootDir);
|
|
25443
|
+
if (isGitRepo || hasManifest) return null;
|
|
25444
|
+
const v3Initialized = await pathExists6(
|
|
25445
|
+
path46.join(rootDir, ".mancode", "schema.json")
|
|
25446
|
+
);
|
|
25447
|
+
const legacyAuthorityPresent = legacyInitialized || (await scanLegacyAuthority(rootDir)).authorityPresent;
|
|
25448
|
+
const genericSafety = await canInitializeGenericProject(rootDir);
|
|
25449
|
+
if (!genericSafety.ok && !((legacyAuthorityPresent || v3Initialized) && genericSafety.reason === "nonempty")) {
|
|
25450
|
+
printNotProjectDirectory(rootDir, locale, genericSafety.reason);
|
|
25451
|
+
return EXIT_NOT_A_PROJECT_DIR;
|
|
25452
|
+
}
|
|
25453
|
+
if (legacyAuthorityPresent || v3Initialized) return null;
|
|
25454
|
+
const prompter = options.prompter ?? (options.interactive ? createTerminalPrompter() : null);
|
|
25455
|
+
const confirmed = options.empty || options.yes ? true : prompter ? await prompter.confirmGenericProject({ rootDir, locale }) : false;
|
|
25456
|
+
if (!confirmed) {
|
|
25457
|
+
printNotProjectDirectory(rootDir, locale, "empty");
|
|
25458
|
+
return EXIT_NOT_A_PROJECT_DIR;
|
|
25459
|
+
}
|
|
25460
|
+
return null;
|
|
25461
|
+
}
|
|
25349
25462
|
function printNotProjectDirectory(rootDir, locale, reason) {
|
|
25350
25463
|
if (locale === "zh-CN") {
|
|
25351
25464
|
console.error(`\u2717 \u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u53EF\u521D\u59CB\u5316\u7684\u9879\u76EE\u76EE\u5F55\uFF1A${rootDir}`);
|
|
@@ -25674,9 +25787,12 @@ async function installV3(rootDir, platform, options) {
|
|
|
25674
25787
|
}
|
|
25675
25788
|
const staged = await stageV3Adapter(rootDir, installer.name);
|
|
25676
25789
|
console.log(
|
|
25677
|
-
`\u2713 ${formatPlatformName(platform)} V3 bootstrap staged for shadow comparison.`
|
|
25790
|
+
`\u2713 ${formatPlatformName(platform)} V3 bootstrap and original mode entries staged for shadow comparison.`
|
|
25678
25791
|
);
|
|
25679
25792
|
console.log(` ${staged.stagingTarget}`);
|
|
25793
|
+
for (const entry of staged.modeEntries) {
|
|
25794
|
+
console.log(` ${entry.stagingTarget}`);
|
|
25795
|
+
}
|
|
25680
25796
|
return EXIT_OK2;
|
|
25681
25797
|
}
|
|
25682
25798
|
if (project.manifest.activationState !== "v3_active") {
|
|
@@ -25853,7 +25969,7 @@ function describePlatform(platform) {
|
|
|
25853
25969
|
}
|
|
25854
25970
|
|
|
25855
25971
|
// src/commands/manps.ts
|
|
25856
|
-
import { access as access4 } from "fs/promises";
|
|
25972
|
+
import { access as access4, readFile as readFile35 } from "fs/promises";
|
|
25857
25973
|
import path50 from "path";
|
|
25858
25974
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
25859
25975
|
|
|
@@ -25943,20 +26059,17 @@ var SCANNERS = [
|
|
|
25943
26059
|
scan: ({ projectRoot }) => scanArchitecture(projectRoot)
|
|
25944
26060
|
}
|
|
25945
26061
|
];
|
|
25946
|
-
async function runPreseasonScan(projectRoot, area = "all") {
|
|
26062
|
+
async function runPreseasonScan(projectRoot, area = "all", options = {}) {
|
|
25947
26063
|
const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
25948
26064
|
const normalizedArea = normalizeArea(area);
|
|
25949
26065
|
const pkg = await readPackageJson(projectRoot);
|
|
25950
26066
|
const needsFiles = normalizedArea === "all" || normalizedArea === "dead-code" || normalizedArea === "config";
|
|
25951
26067
|
const files = needsFiles ? await listProjectFiles(projectRoot) : [];
|
|
25952
26068
|
const issues = (await scanArea(projectRoot, normalizedArea, pkg, files)).slice(0, 20);
|
|
25953
|
-
const
|
|
26069
|
+
const storageRoot = options.storageRoot ?? path49.join(projectRoot, ".mancode");
|
|
26070
|
+
const reportDir = path49.join(storageRoot, "preseason-reports");
|
|
25954
26071
|
await mkdir31(reportDir, { recursive: true });
|
|
25955
|
-
const issueDbPath = path49.join(
|
|
25956
|
-
projectRoot,
|
|
25957
|
-
".mancode",
|
|
25958
|
-
"preseason-issues.json"
|
|
25959
|
-
);
|
|
26072
|
+
const issueDbPath = path49.join(storageRoot, "preseason-issues.json");
|
|
25960
26073
|
const reportPath = await allocateReportPath(
|
|
25961
26074
|
reportDir,
|
|
25962
26075
|
`${generatedAt.replace(/[:.]/g, "-")}-${normalizedArea}`
|
|
@@ -25972,7 +26085,7 @@ async function runPreseasonScan(projectRoot, area = "all") {
|
|
|
25972
26085
|
const database = await buildIssueDatabase(projectRoot, report);
|
|
25973
26086
|
await writeFile36(reportPath, renderPreseasonReport(report), "utf-8");
|
|
25974
26087
|
await writeFile36(
|
|
25975
|
-
path49.join(
|
|
26088
|
+
path49.join(storageRoot, "preseason-report.md"),
|
|
25976
26089
|
renderPreseasonReport(report),
|
|
25977
26090
|
"utf-8"
|
|
25978
26091
|
);
|
|
@@ -25980,11 +26093,7 @@ async function runPreseasonScan(projectRoot, area = "all") {
|
|
|
25980
26093
|
return report;
|
|
25981
26094
|
}
|
|
25982
26095
|
async function runPreseasonRemediation(projectRoot, issues, options = {}) {
|
|
25983
|
-
const issueDbPath = path49.join(
|
|
25984
|
-
projectRoot,
|
|
25985
|
-
".mancode",
|
|
25986
|
-
"preseason-issues.json"
|
|
25987
|
-
);
|
|
26096
|
+
const issueDbPath = options.issueDbPath ?? path49.join(projectRoot, ".mancode", "preseason-issues.json");
|
|
25988
26097
|
const database = await readIssueDatabase(issueDbPath);
|
|
25989
26098
|
const keys = new Set(issues.map((issue) => issueKey(issue)));
|
|
25990
26099
|
const targets = database.issues.filter(
|
|
@@ -26781,7 +26890,21 @@ var EXIT_NOT_INITIALIZED2 = 1;
|
|
|
26781
26890
|
var EXIT_SCAN_FAILED = 2;
|
|
26782
26891
|
var EXIT_INVALID_ARG = 3;
|
|
26783
26892
|
async function manps(rootDir, area = "all", options = {}) {
|
|
26784
|
-
|
|
26893
|
+
const v3SchemaPath = path50.join(rootDir, ".mancode", "schema.json");
|
|
26894
|
+
const v3Activation = await readV3ActivationState(v3SchemaPath);
|
|
26895
|
+
if (v3Activation !== null && v3Activation !== "v3_active" && v3Activation !== "dual_read") {
|
|
26896
|
+
const message = `manps is unavailable while V3 activation is ${v3Activation}`;
|
|
26897
|
+
if (options.json) {
|
|
26898
|
+
console.log(JSON.stringify({ error: "scan failed", message }, null, 2));
|
|
26899
|
+
} else {
|
|
26900
|
+
console.error("\u2717 mancode preseason scan is temporarily unavailable.");
|
|
26901
|
+
console.error(` ${message}`);
|
|
26902
|
+
}
|
|
26903
|
+
return EXIT_SCAN_FAILED;
|
|
26904
|
+
}
|
|
26905
|
+
const v3Initialized = v3Activation === "v3_active";
|
|
26906
|
+
const initialized = v3Initialized || await pathExists10(path50.join(rootDir, ".mancode", "state.json"));
|
|
26907
|
+
if (!initialized) {
|
|
26785
26908
|
if (options.json) {
|
|
26786
26909
|
console.log(JSON.stringify({ error: "not initialized" }, null, 2));
|
|
26787
26910
|
} else {
|
|
@@ -26792,7 +26915,9 @@ async function manps(rootDir, area = "all", options = {}) {
|
|
|
26792
26915
|
}
|
|
26793
26916
|
let report;
|
|
26794
26917
|
try {
|
|
26795
|
-
report = await runPreseasonScan(rootDir, area
|
|
26918
|
+
report = await runPreseasonScan(rootDir, area, {
|
|
26919
|
+
storageRoot: v3Initialized ? path50.join(rootDir, ".mancode", "local") : void 0
|
|
26920
|
+
});
|
|
26796
26921
|
} catch (err) {
|
|
26797
26922
|
const message = err instanceof Error ? err.message : String(err);
|
|
26798
26923
|
const invalidArg2 = message.startsWith("invalid area:");
|
|
@@ -26888,7 +27013,8 @@ async function runRemediation(rootDir, report, options, silent = false) {
|
|
|
26888
27013
|
if (options.answers) {
|
|
26889
27014
|
return runPreseasonRemediation(rootDir, report.issues, {
|
|
26890
27015
|
answers: options.answers,
|
|
26891
|
-
write: write2
|
|
27016
|
+
write: write2,
|
|
27017
|
+
issueDbPath: report.issueDbPath
|
|
26892
27018
|
});
|
|
26893
27019
|
}
|
|
26894
27020
|
if (!process.stdin.isTTY) {
|
|
@@ -26900,7 +27026,8 @@ async function runRemediation(rootDir, report, options, silent = false) {
|
|
|
26900
27026
|
}
|
|
26901
27027
|
return runPreseasonRemediation(rootDir, report.issues, {
|
|
26902
27028
|
answers,
|
|
26903
|
-
write: write2
|
|
27029
|
+
write: write2,
|
|
27030
|
+
issueDbPath: report.issueDbPath
|
|
26904
27031
|
});
|
|
26905
27032
|
}
|
|
26906
27033
|
const rl = createInterface2({
|
|
@@ -26910,7 +27037,8 @@ async function runRemediation(rootDir, report, options, silent = false) {
|
|
|
26910
27037
|
try {
|
|
26911
27038
|
return await runPreseasonRemediation(rootDir, report.issues, {
|
|
26912
27039
|
ask: (question) => rl.question(question),
|
|
26913
|
-
write: write2
|
|
27040
|
+
write: write2,
|
|
27041
|
+
issueDbPath: report.issueDbPath
|
|
26914
27042
|
});
|
|
26915
27043
|
} finally {
|
|
26916
27044
|
rl.close();
|
|
@@ -26931,9 +27059,20 @@ async function pathExists10(p) {
|
|
|
26931
27059
|
return false;
|
|
26932
27060
|
}
|
|
26933
27061
|
}
|
|
27062
|
+
async function readV3ActivationState(schemaPath) {
|
|
27063
|
+
if (!await pathExists10(schemaPath)) return null;
|
|
27064
|
+
try {
|
|
27065
|
+
const manifest = parseSchemaManifest(
|
|
27066
|
+
JSON.parse(await readFile35(schemaPath, "utf8"))
|
|
27067
|
+
);
|
|
27068
|
+
return manifest.activationState;
|
|
27069
|
+
} catch {
|
|
27070
|
+
return "invalid";
|
|
27071
|
+
}
|
|
27072
|
+
}
|
|
26934
27073
|
|
|
26935
27074
|
// src/commands/migrate.ts
|
|
26936
|
-
import { readFile as
|
|
27075
|
+
import { readFile as readFile36 } from "fs/promises";
|
|
26937
27076
|
import path51 from "path";
|
|
26938
27077
|
var EXIT_OK5 = 0;
|
|
26939
27078
|
var EXIT_INVALID_ARG2 = 2;
|
|
@@ -27067,7 +27206,7 @@ async function readScopeFile(rootDir, file) {
|
|
|
27067
27206
|
}
|
|
27068
27207
|
try {
|
|
27069
27208
|
return JSON.parse(
|
|
27070
|
-
await
|
|
27209
|
+
await readFile36(resolved, "utf8")
|
|
27071
27210
|
);
|
|
27072
27211
|
} catch (error) {
|
|
27073
27212
|
if (error instanceof SyntaxError) {
|
|
@@ -29742,7 +29881,7 @@ function isAlreadyExists21(error) {
|
|
|
29742
29881
|
}
|
|
29743
29882
|
|
|
29744
29883
|
// src/team/git-ref-handoff-repair.ts
|
|
29745
|
-
import { lstat as lstat19, mkdir as mkdir33, readFile as
|
|
29884
|
+
import { lstat as lstat19, mkdir as mkdir33, readFile as readFile37, readdir as readdir17, writeFile as writeFile38 } from "fs/promises";
|
|
29746
29885
|
import path56 from "path";
|
|
29747
29886
|
|
|
29748
29887
|
// src/team/git-ref-operation.ts
|
|
@@ -32474,7 +32613,7 @@ async function replaceJournal3(projectRoot, journal) {
|
|
|
32474
32613
|
async function requireJournal2(projectRoot, operationId) {
|
|
32475
32614
|
try {
|
|
32476
32615
|
return parseJournal3(
|
|
32477
|
-
JSON.parse(await
|
|
32616
|
+
JSON.parse(await readFile37(journalPath3(projectRoot, operationId), "utf8"))
|
|
32478
32617
|
);
|
|
32479
32618
|
} catch (error) {
|
|
32480
32619
|
if (error instanceof SyntaxError || isNotFound25(error)) {
|
|
@@ -32497,7 +32636,7 @@ async function listJournals2(projectRoot) {
|
|
|
32497
32636
|
journals.push(
|
|
32498
32637
|
parseJournal3(
|
|
32499
32638
|
JSON.parse(
|
|
32500
|
-
await
|
|
32639
|
+
await readFile37(
|
|
32501
32640
|
path56.join(journalDirectory2(projectRoot), entry),
|
|
32502
32641
|
"utf8"
|
|
32503
32642
|
)
|
|
@@ -32512,7 +32651,7 @@ async function readSafeFile2(target) {
|
|
|
32512
32651
|
if (!before.isFile() || before.isSymbolicLink()) {
|
|
32513
32652
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
32514
32653
|
}
|
|
32515
|
-
const content = await
|
|
32654
|
+
const content = await readFile37(target, "utf8");
|
|
32516
32655
|
const after = await lstat19(target);
|
|
32517
32656
|
if (!after.isFile() || after.isSymbolicLink() || before.dev !== after.dev || before.ino !== after.ino) {
|
|
32518
32657
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
@@ -32984,7 +33123,7 @@ function isNotFound26(error) {
|
|
|
32984
33123
|
import {
|
|
32985
33124
|
lstat as lstat21,
|
|
32986
33125
|
mkdir as mkdir35,
|
|
32987
|
-
readFile as
|
|
33126
|
+
readFile as readFile38,
|
|
32988
33127
|
readdir as readdir19,
|
|
32989
33128
|
rename as rename10,
|
|
32990
33129
|
unlink as unlink4,
|
|
@@ -35135,7 +35274,7 @@ function projectConfigPath2(projectRoot) {
|
|
|
35135
35274
|
async function readProjectConfigFile(projectRoot) {
|
|
35136
35275
|
try {
|
|
35137
35276
|
return parseProjectConfig(
|
|
35138
|
-
JSON.parse(await
|
|
35277
|
+
JSON.parse(await readFile38(projectConfigPath2(projectRoot), "utf8"))
|
|
35139
35278
|
);
|
|
35140
35279
|
} catch (error) {
|
|
35141
35280
|
if (error instanceof SyntaxError) {
|
|
@@ -35182,7 +35321,7 @@ async function readJsonOrNull5(target, parser, corruptCode) {
|
|
|
35182
35321
|
if (!before.isFile() || before.isSymbolicLink()) {
|
|
35183
35322
|
throw new Error("MANCODE_TRANSPORT_MIGRATION_STAGE_UNSAFE");
|
|
35184
35323
|
}
|
|
35185
|
-
const parsed = parser(JSON.parse(await
|
|
35324
|
+
const parsed = parser(JSON.parse(await readFile38(target, "utf8")));
|
|
35186
35325
|
const after = await lstat21(target);
|
|
35187
35326
|
if (!after.isFile() || after.isSymbolicLink() || before.dev !== after.dev || before.ino !== after.ino) {
|
|
35188
35327
|
throw new Error("MANCODE_TRANSPORT_MIGRATION_STAGE_UNSAFE");
|
|
@@ -36714,7 +36853,7 @@ function parsePositiveInteger5(value) {
|
|
|
36714
36853
|
}
|
|
36715
36854
|
|
|
36716
36855
|
// src/commands/uninstall.ts
|
|
36717
|
-
import { access as access5, readFile as
|
|
36856
|
+
import { access as access5, readFile as readFile39, rm as rm17, writeFile as writeFile41 } from "fs/promises";
|
|
36718
36857
|
import path59 from "path";
|
|
36719
36858
|
import process11 from "process";
|
|
36720
36859
|
var EXIT_OK9 = 0;
|
|
@@ -36823,7 +36962,7 @@ async function cleanClaudeSettings(rootDir) {
|
|
|
36823
36962
|
const settingsPath = path59.join(rootDir, ".claude", "settings.json");
|
|
36824
36963
|
let content;
|
|
36825
36964
|
try {
|
|
36826
|
-
content = await
|
|
36965
|
+
content = await readFile39(settingsPath, "utf-8");
|
|
36827
36966
|
} catch {
|
|
36828
36967
|
return;
|
|
36829
36968
|
}
|
|
@@ -36900,7 +37039,7 @@ async function uninstallCursor(rootDir) {
|
|
|
36900
37039
|
async function uninstallCodex(rootDir) {
|
|
36901
37040
|
const agentsPath = path59.join(rootDir, "AGENTS.md");
|
|
36902
37041
|
try {
|
|
36903
|
-
const content = await
|
|
37042
|
+
const content = await readFile39(agentsPath, "utf-8");
|
|
36904
37043
|
const cleaned = removeManagedBlock(content);
|
|
36905
37044
|
if (cleaned.trim()) {
|
|
36906
37045
|
await writeFile41(agentsPath, `${cleaned}
|
|
@@ -36919,7 +37058,7 @@ async function uninstallCopilot(rootDir) {
|
|
|
36919
37058
|
"copilot-instructions.md"
|
|
36920
37059
|
);
|
|
36921
37060
|
try {
|
|
36922
|
-
const content = await
|
|
37061
|
+
const content = await readFile39(instructionsPath, "utf-8");
|
|
36923
37062
|
const cleaned = removeManagedBlock(content);
|
|
36924
37063
|
if (cleaned.trim()) {
|
|
36925
37064
|
await writeFile41(instructionsPath, `${cleaned}
|
|
@@ -36934,7 +37073,7 @@ async function uninstallCopilot(rootDir) {
|
|
|
36934
37073
|
async function uninstallZcode(rootDir) {
|
|
36935
37074
|
const agentsPath = path59.join(rootDir, "AGENTS.md");
|
|
36936
37075
|
try {
|
|
36937
|
-
const content = await
|
|
37076
|
+
const content = await readFile39(agentsPath, "utf-8");
|
|
36938
37077
|
const cleaned = removeManagedBlock(
|
|
36939
37078
|
content,
|
|
36940
37079
|
ZCODE_MANCODE_START_MARKER,
|
|
@@ -36953,7 +37092,7 @@ async function uninstallZcode(rootDir) {
|
|
|
36953
37092
|
async function removeFromConfig(rootDir, platform) {
|
|
36954
37093
|
const configPath = path59.join(rootDir, ".mancode", "config.json");
|
|
36955
37094
|
try {
|
|
36956
|
-
const raw = await
|
|
37095
|
+
const raw = await readFile39(configPath, "utf-8");
|
|
36957
37096
|
const config = JSON.parse(raw);
|
|
36958
37097
|
if (Array.isArray(config.platforms)) {
|
|
36959
37098
|
config.platforms = config.platforms.filter((p) => p !== platform);
|
|
@@ -36998,7 +37137,7 @@ function version() {
|
|
|
36998
37137
|
}
|
|
36999
37138
|
|
|
37000
37139
|
// src/commands/workflow.ts
|
|
37001
|
-
import { access as access6, readFile as
|
|
37140
|
+
import { access as access6, readFile as readFile41, rm as rm19, writeFile as writeFile43 } from "fs/promises";
|
|
37002
37141
|
import path61 from "path";
|
|
37003
37142
|
|
|
37004
37143
|
// src/context/child-result-merge.ts
|
|
@@ -39456,7 +39595,7 @@ function updateMetadata4(previous, verification, operationId, updatedAt) {
|
|
|
39456
39595
|
import {
|
|
39457
39596
|
lstat as lstat22,
|
|
39458
39597
|
mkdir as mkdir36,
|
|
39459
|
-
readFile as
|
|
39598
|
+
readFile as readFile40,
|
|
39460
39599
|
rename as rename11,
|
|
39461
39600
|
rm as rm18,
|
|
39462
39601
|
writeFile as writeFile42
|
|
@@ -40241,7 +40380,7 @@ async function readStagedJson(stagingDirectory, fileName, parser) {
|
|
|
40241
40380
|
if (!before.isFile() || before.isSymbolicLink()) {
|
|
40242
40381
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
40243
40382
|
}
|
|
40244
|
-
const parsed = parser(JSON.parse(await
|
|
40383
|
+
const parsed = parser(JSON.parse(await readFile40(target, "utf8")));
|
|
40245
40384
|
const after = await lstat22(target);
|
|
40246
40385
|
if (!after.isFile() || after.isSymbolicLink() || before.dev !== after.dev || before.ino !== after.ino) {
|
|
40247
40386
|
throw new Error("MANCODE_ARTIFACT_PATH_UNSAFE");
|
|
@@ -41230,7 +41369,7 @@ var EXIT_OK10 = 0;
|
|
|
41230
41369
|
var EXIT_NOT_INITIALIZED7 = 1;
|
|
41231
41370
|
var EXIT_INVALID_ARG3 = 2;
|
|
41232
41371
|
async function workflow(rootDir, subcommand, args = [], options = {}) {
|
|
41233
|
-
const v3Activation = await
|
|
41372
|
+
const v3Activation = await readV3ActivationState2(rootDir);
|
|
41234
41373
|
if (v3Activation === "v3_active") {
|
|
41235
41374
|
return workflowV3(rootDir, subcommand, args, options);
|
|
41236
41375
|
}
|
|
@@ -42032,7 +42171,7 @@ function parseV3ParticipantActorIds(values) {
|
|
|
42032
42171
|
}
|
|
42033
42172
|
async function readWorkflowInputFile(projectRoot, value) {
|
|
42034
42173
|
const inputPath = path61.isAbsolute(value) ? value : path61.resolve(projectRoot, value);
|
|
42035
|
-
return
|
|
42174
|
+
return readFile41(inputPath, "utf8");
|
|
42036
42175
|
}
|
|
42037
42176
|
async function readWorkflowJsonInputFile(projectRoot, value) {
|
|
42038
42177
|
return JSON.parse(await readWorkflowInputFile(projectRoot, value));
|
|
@@ -42095,11 +42234,11 @@ async function workflowCreateV3(rootDir, args, options) {
|
|
|
42095
42234
|
);
|
|
42096
42235
|
}
|
|
42097
42236
|
}
|
|
42098
|
-
async function
|
|
42237
|
+
async function readV3ActivationState2(rootDir) {
|
|
42099
42238
|
try {
|
|
42100
42239
|
const manifest = parseSchemaManifest(
|
|
42101
42240
|
JSON.parse(
|
|
42102
|
-
await
|
|
42241
|
+
await readFile41(path61.join(rootDir, ".mancode", "schema.json"), "utf8")
|
|
42103
42242
|
)
|
|
42104
42243
|
);
|
|
42105
42244
|
return manifest.activationState === "v3_active" ? "v3_active" : "other";
|
|
@@ -42153,12 +42292,12 @@ async function workflowRequirements(rootDir, args, options) {
|
|
|
42153
42292
|
let originalMetadata;
|
|
42154
42293
|
try {
|
|
42155
42294
|
const inputPath = path61.isAbsolute(options.file) ? options.file : path61.resolve(rootDir, options.file);
|
|
42156
|
-
const input = await
|
|
42295
|
+
const input = await readFile41(inputPath, "utf-8");
|
|
42157
42296
|
const requirements = parseRequirementsLedger2(input);
|
|
42158
42297
|
[originalJson, originalMarkdown, originalMetadata] = await Promise.all([
|
|
42159
42298
|
readOptionalText2(jsonPath),
|
|
42160
42299
|
readOptionalText2(markdownPath),
|
|
42161
|
-
|
|
42300
|
+
readFile41(metadataPath3, "utf-8")
|
|
42162
42301
|
]);
|
|
42163
42302
|
await writeRequirementsArtifacts(rootDir, taskId, requirements);
|
|
42164
42303
|
await updateWorkflow(rootDir, taskId, {
|
|
@@ -42346,7 +42485,7 @@ async function commitVerificationTransition(rootDir, meta, ledger) {
|
|
|
42346
42485
|
const specPath = path61.join(rootDir, ".mancode", "memory", "spec.md");
|
|
42347
42486
|
const [originalLedger, originalMetadata, originalSpec] = await Promise.all([
|
|
42348
42487
|
readOptionalText2(ledgerPath),
|
|
42349
|
-
|
|
42488
|
+
readFile41(metadataPath3, "utf-8"),
|
|
42350
42489
|
readOptionalText2(specPath)
|
|
42351
42490
|
]);
|
|
42352
42491
|
const wasVerificationBlocked = meta.status === "blocked" && meta.blockingReason?.startsWith("[verification]");
|
|
@@ -42516,7 +42655,7 @@ async function commitReviewSkip(rootDir, meta, reason) {
|
|
|
42516
42655
|
);
|
|
42517
42656
|
const [originalLedger, originalMetadata] = await Promise.all([
|
|
42518
42657
|
readOptionalText2(ledgerPath),
|
|
42519
|
-
|
|
42658
|
+
readFile41(metadataPath3, "utf-8")
|
|
42520
42659
|
]);
|
|
42521
42660
|
try {
|
|
42522
42661
|
await initializeSkippedReview(rootDir, meta.taskId, reason);
|
|
@@ -42758,7 +42897,7 @@ async function workflowHandoff(rootDir, taskId, options) {
|
|
|
42758
42897
|
let originalState;
|
|
42759
42898
|
let state;
|
|
42760
42899
|
try {
|
|
42761
|
-
originalState = await
|
|
42900
|
+
originalState = await readFile41(statePath, "utf-8");
|
|
42762
42901
|
state = JSON.parse(originalState);
|
|
42763
42902
|
} catch {
|
|
42764
42903
|
return invalidArg(
|
|
@@ -42833,7 +42972,7 @@ async function workflowCompleteHandoff(rootDir, taskId, options) {
|
|
|
42833
42972
|
let originalState;
|
|
42834
42973
|
let state;
|
|
42835
42974
|
try {
|
|
42836
|
-
originalState = await
|
|
42975
|
+
originalState = await readFile41(statePath, "utf-8");
|
|
42837
42976
|
state = JSON.parse(originalState);
|
|
42838
42977
|
} catch {
|
|
42839
42978
|
return invalidArg(
|
|
@@ -42907,7 +43046,7 @@ async function workflowDecide(rootDir, taskId, options) {
|
|
|
42907
43046
|
let originalState;
|
|
42908
43047
|
let state;
|
|
42909
43048
|
try {
|
|
42910
|
-
originalState = await
|
|
43049
|
+
originalState = await readFile41(statePath, "utf-8");
|
|
42911
43050
|
state = JSON.parse(originalState);
|
|
42912
43051
|
} catch {
|
|
42913
43052
|
return invalidArg(
|
|
@@ -42970,7 +43109,7 @@ async function commitPlanningTransition(args) {
|
|
|
42970
43109
|
let originalMetadata;
|
|
42971
43110
|
let originalSpec;
|
|
42972
43111
|
try {
|
|
42973
|
-
originalMetadata = await
|
|
43112
|
+
originalMetadata = await readFile41(metadataPath3, "utf-8");
|
|
42974
43113
|
originalSpec = await readOptionalText2(specPath);
|
|
42975
43114
|
} catch (error) {
|
|
42976
43115
|
return error instanceof Error ? `unable to prepare planning transition: ${error.message}` : "unable to prepare planning transition";
|
|
@@ -43001,7 +43140,7 @@ async function commitPlanningTransition(args) {
|
|
|
43001
43140
|
}
|
|
43002
43141
|
async function readOptionalText2(filePath) {
|
|
43003
43142
|
try {
|
|
43004
|
-
return await
|
|
43143
|
+
return await readFile41(filePath, "utf-8");
|
|
43005
43144
|
} catch (error) {
|
|
43006
43145
|
if (isNodeError10(error) && error.code === "ENOENT") return null;
|
|
43007
43146
|
throw error;
|
|
@@ -43266,9 +43405,10 @@ async function pathExists16(p) {
|
|
|
43266
43405
|
program.name("mancode").description(
|
|
43267
43406
|
"AI coding agent harness. Modes: solo, man, manba, manteam, manps."
|
|
43268
43407
|
).version(VERSION);
|
|
43269
|
-
program.command("init").description("Initialize mancode in the current project").option("--force", "Reinstall even if already initialized").option("--yes", "Skip all confirmations (CI mode)").option("--team", "Force enable team mode (MVP-2)").option("--no-team", "Force disable team mode (MVP-2)").option("--style <name>", "Specify aesthetic style (MVP-2)").option("--platform <platforms>", "Adapters: comma-separated names or all").option("--empty", "Initialize a safe empty directory as a generic project").option("--v3", "Use the
|
|
43408
|
+
program.command("init").description("Initialize mancode in the current project").option("--force", "Reinstall even if already initialized").option("--yes", "Skip all confirmations (CI mode)").option("--team", "Force enable team mode (MVP-2)").option("--no-team", "Force disable team mode (MVP-2)").option("--style <name>", "Specify aesthetic style (MVP-2)").option("--platform <platforms>", "Adapters: comma-separated names or all").option("--empty", "Initialize a safe empty directory as a generic project").option("--v3", "Use V3 authority explicitly (the CLI default)").option("--legacy", "Use the legacy state.json initializer").option("--lang <locale>", "Initialization language: zh-CN or en").action(async (options) => {
|
|
43270
43409
|
const code = await init(process.cwd(), {
|
|
43271
43410
|
...options,
|
|
43411
|
+
fromCli: true,
|
|
43272
43412
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
43273
43413
|
});
|
|
43274
43414
|
process.exitCode = code;
|