mancode 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -114,7 +114,7 @@ import {
114
114
  workflowMetadataDigest,
115
115
  writeOperationReservation,
116
116
  writeProjectFacts
117
- } from "./chunk-YWHFHZ4A.js";
117
+ } from "./chunk-M5CWWECP.js";
118
118
  import {
119
119
  DEFAULT_MANCODE_END_MARKER,
120
120
  DEFAULT_MANCODE_START_MARKER,
@@ -142,7 +142,9 @@ import {
142
142
  } from "./chunk-AWOIP2LC.js";
143
143
 
144
144
  // src/cli.ts
145
- import { Option, program } from "commander";
145
+ import { realpathSync } from "fs";
146
+ import { fileURLToPath } from "url";
147
+ import { Command, Option } from "commander";
146
148
 
147
149
  // src/installers/adapter-upgrade.ts
148
150
  import {
@@ -6551,6 +6553,20 @@ async function validateParentTask(projectRoot, mode, parentTaskId, requireStepSi
6551
6553
  }
6552
6554
  }
6553
6555
  async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6556
+ validateImmutableWorkflowFields(updated, existing);
6557
+ validateWorkflowShapeAndSkipPolicy(updated);
6558
+ validateWorkflowLifecycle(updated, existing);
6559
+ validateWorkflowOutcome(updated);
6560
+ validateWorkflowPolicyVersions(updated);
6561
+ validateWorkflowPolicyState(updated);
6562
+ validatePlanDecisionTransition(updated, existing);
6563
+ await validatePlanningArtifactGate(projectRoot, updated);
6564
+ await validateVerificationGate(projectRoot, updated, existing, options);
6565
+ validatePlanVersionTransition(updated, existing);
6566
+ await validateWorkflowFamilyState(projectRoot, updated);
6567
+ await validateWorkflowCompletionGates(projectRoot, updated);
6568
+ }
6569
+ function validateImmutableWorkflowFields(updated, existing) {
6554
6570
  if (updated.mode !== existing.mode) {
6555
6571
  throw new Error("workflow mode cannot be changed");
6556
6572
  }
@@ -6574,6 +6590,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6574
6590
  if (updated.verificationPolicyVersion !== existing.verificationPolicyVersion) {
6575
6591
  throw new Error("workflow verification policy version cannot be changed");
6576
6592
  }
6593
+ }
6594
+ function validateWorkflowShapeAndSkipPolicy(updated) {
6577
6595
  if (!Number.isInteger(updated.currentStep) || updated.currentStep < 1 || updated.currentStep > maxWorkflowStep(updated.mode)) {
6578
6596
  throw new Error(`invalid workflow step: ${updated.currentStep}`);
6579
6597
  }
@@ -6590,6 +6608,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6590
6608
  "workflow policy v2 only allows skipping clarification or review"
6591
6609
  );
6592
6610
  }
6611
+ }
6612
+ function validateWorkflowLifecycle(updated, existing) {
6593
6613
  if (!canTransition(existing.status, updated.status)) {
6594
6614
  throw new Error(
6595
6615
  `invalid workflow status transition: ${existing.status} -> ${updated.status}`
@@ -6616,6 +6636,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6616
6636
  } else if (updated.blockingReason !== void 0) {
6617
6637
  throw new Error("only blocked workflows can have a blocking reason");
6618
6638
  }
6639
+ }
6640
+ function validateWorkflowOutcome(updated) {
6619
6641
  if (updated.mode !== "mamba" && updated.outcome !== void 0) {
6620
6642
  throw new Error("only manba workflows can have an outcome");
6621
6643
  }
@@ -6628,6 +6650,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6628
6650
  if (updated.mode === "mamba" && updated.status === "completed" && !updated.outcome) {
6629
6651
  throw new Error("completed manba workflows require an outcome");
6630
6652
  }
6653
+ }
6654
+ function validateWorkflowPolicyVersions(updated) {
6631
6655
  if (updated.mode === "mamba" && updated.planVersion !== void 0) {
6632
6656
  throw new Error("manba workflows cannot have a plan version");
6633
6657
  }
@@ -6651,6 +6675,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6651
6675
  "manba workflows cannot have a verification policy version"
6652
6676
  );
6653
6677
  }
6678
+ }
6679
+ function validateWorkflowPolicyState(updated) {
6654
6680
  if (updated.verificationStatus !== void 0 && !isVerificationStatus(updated.verificationStatus)) {
6655
6681
  throw new Error("invalid workflow verification status");
6656
6682
  }
@@ -6675,12 +6701,16 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6675
6701
  if (updated.mode === "mamba" && updated.planDecision !== void 0) {
6676
6702
  throw new Error("manba workflows cannot have a plan decision");
6677
6703
  }
6704
+ }
6705
+ function validatePlanDecisionTransition(updated, existing) {
6678
6706
  if (updated.planDecision !== existing.planDecision && existing.planDecision !== void 0) {
6679
6707
  throw new Error("workflow plan decision cannot be changed");
6680
6708
  }
6681
6709
  if (updated.planDecision !== existing.planDecision && existing.currentStep !== 4) {
6682
6710
  throw new Error("workflow plan decision can only be set at step 4");
6683
6711
  }
6712
+ }
6713
+ async function validatePlanningArtifactGate(projectRoot, updated) {
6684
6714
  if (updated.planningPolicyVersion === 1 || updated.planningPolicyVersion === 2) {
6685
6715
  if (updated.currentStep >= 3) {
6686
6716
  if (updated.requirementsStatus !== "ready") {
@@ -6717,6 +6747,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6717
6747
  throw new Error("governed execution must be confirmed before step 5");
6718
6748
  }
6719
6749
  }
6750
+ }
6751
+ async function validateVerificationGate(projectRoot, updated, existing, options) {
6720
6752
  if (updated.verificationPolicyVersion === 1 && updated.currentStep >= 7 && updated.planDecision !== "solo_handoff" && !options.allowIncompleteVerification && !await verificationCanAdvance(
6721
6753
  projectRoot,
6722
6754
  updated.taskId,
@@ -6731,6 +6763,8 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6731
6763
  "verification-blocked workflows must resume through verify"
6732
6764
  );
6733
6765
  }
6766
+ }
6767
+ function validatePlanVersionTransition(updated, existing) {
6734
6768
  if (updated.planVersion !== void 0 && (!Number.isInteger(updated.planVersion) || updated.planVersion < 1)) {
6735
6769
  throw new Error("workflow plan version must be a positive integer");
6736
6770
  }
@@ -6740,10 +6774,14 @@ async function validateWorkflowMeta(projectRoot, updated, existing, options) {
6740
6774
  if (updated.planVersion !== existing.planVersion && updated.currentStep !== 4) {
6741
6775
  throw new Error("workflow plan version can only change at step 4");
6742
6776
  }
6777
+ }
6778
+ async function validateWorkflowFamilyState(projectRoot, updated) {
6743
6779
  await validateParentTask(projectRoot, updated.mode, updated.parentTaskId);
6744
6780
  if ((isTerminalWorkflowStatus(updated.status) || updated.status === "planned") && (await listActiveMambaChildren(projectRoot, updated.taskId)).length > 0) {
6745
6781
  throw new Error("cannot finish workflow with an active manba child");
6746
6782
  }
6783
+ }
6784
+ async function validateWorkflowCompletionGates(projectRoot, updated) {
6747
6785
  if (updated.status === "completed" && updated.reviewPolicyVersion === 1 && updated.planDecision !== "solo_handoff" && !reviewWasExplicitlySkipped(updated) && !await reviewCanComplete(projectRoot, updated.taskId)) {
6748
6786
  throw new Error("workflow review is incomplete or still has open blockers");
6749
6787
  }
@@ -9638,7 +9676,7 @@ async function activateLegacyMigration(input) {
9638
9676
  if (session === null || session.status !== "active") {
9639
9677
  throw new Error("MANCODE_SESSION_NOT_FOUND");
9640
9678
  }
9641
- const store = new (await import("./store-DREAZNIX.js")).V3ContextStore(root);
9679
+ const store = new (await import("./store-Z53OE53A.js")).V3ContextStore(root);
9642
9680
  const project = await store.readProjectSnapshot();
9643
9681
  const stage = await readMigrationStage(root, input.stageId);
9644
9682
  if (stage.state !== "staged" || stage.revision !== input.expectedStageRevision) {
@@ -23100,7 +23138,7 @@ async function planContextCompaction(input) {
23100
23138
  ...gitRefWorkflowRepairPlan.protectedTaskRefs
23101
23139
  ]);
23102
23140
  const taskRefs = input.taskRef === void 0 ? await listTaskRefs(root) : [parseTaskRefValue(input.taskRef)];
23103
- const [checkpointPlan, sessions, overlays, cache] = await Promise.all([
23141
+ const [checkpointPlan, sessions, cache] = await Promise.all([
23104
23142
  planCheckpointCompaction(
23105
23143
  store,
23106
23144
  coordinationStore,
@@ -23113,13 +23151,6 @@ async function planContextCompaction(input) {
23113
23151
  now,
23114
23152
  protectedSessionIds
23115
23153
  ),
23116
- planLocalOverlayRetention(
23117
- root,
23118
- store,
23119
- taskRefs,
23120
- project.policy.retention.localRawArtifactDays,
23121
- now
23122
- ),
23123
23154
  planLocalCacheRetention(root, project.policy.retention.localCacheDays, now)
23124
23155
  ]);
23125
23156
  return {
@@ -23130,7 +23161,6 @@ async function planContextCompaction(input) {
23130
23161
  ...operationPlan.candidates,
23131
23162
  ...gitRefWorkflowRepairPlan.candidates,
23132
23163
  ...checkpointPlan.candidates,
23133
- ...overlays,
23134
23164
  ...cache
23135
23165
  ].sort(
23136
23166
  (left, right) => Buffer.from(left.target, "utf8").compare(
@@ -23140,37 +23170,6 @@ async function planContextCompaction(input) {
23140
23170
  skippedReferencedCheckpoints: checkpointPlan.skippedReferencedCheckpoints
23141
23171
  };
23142
23172
  }
23143
- async function planLocalOverlayRetention(root, store, taskRefs, localRawArtifactDays, now) {
23144
- const threshold = now.getTime() - localRawArtifactDays * 864e5;
23145
- const candidates = [];
23146
- for (const taskRef of taskRefs) {
23147
- if (taskRef.namespace !== "shared") continue;
23148
- const task = await store.readTaskSnapshot(taskRef);
23149
- if (!isTerminalTaskStatus(task.metadata.status)) continue;
23150
- const directory = path41.join(
23151
- root,
23152
- ".mancode",
23153
- "local",
23154
- "overlays",
23155
- taskRef.taskId,
23156
- "artifacts"
23157
- );
23158
- for (const entry of await readDirectoryOrEmpty(directory)) {
23159
- const target = path41.join(directory, entry);
23160
- const metadata = await regularFileMetadataOrNull(target);
23161
- if (metadata === null || metadata.mtimeMs >= threshold) continue;
23162
- candidates.push({
23163
- kind: "local_overlay_artifact",
23164
- target,
23165
- reason: `terminal task raw artifact exceeds ${localRawArtifactDays} day retention`,
23166
- // The artifact is local-only even though it is grouped by shared task.
23167
- taskRef: null,
23168
- relatedTargets: []
23169
- });
23170
- }
23171
- }
23172
- return candidates;
23173
- }
23174
23173
  async function planLocalCacheRetention(root, localCacheDays, now) {
23175
23174
  const threshold = now.getTime() - localCacheDays * 864e5;
23176
23175
  const directory = path41.join(root, ".mancode", "local", "cache");
@@ -23355,9 +23354,6 @@ function taskRefKeyFromEntityKey(entityKey) {
23355
23354
  );
23356
23355
  return match === null ? null : `${match[1]}:${match[2]}`;
23357
23356
  }
23358
- function isTerminalTaskStatus(status2) {
23359
- return status2 === "completed" || status2 === "abandoned" || status2 === "superseded";
23360
- }
23361
23357
  async function listTaskRefs(root) {
23362
23358
  const refs = [];
23363
23359
  for (const namespace of ["local", "shared"]) {
@@ -28061,7 +28057,6 @@ async function writeGreenfieldLayout(stagingRoot, manifest, config, policy, proj
28061
28057
  recursive: true
28062
28058
  }),
28063
28059
  mkdir35(path53.join(stagingRoot, "local", "workflows"), { recursive: true }),
28064
- mkdir35(path53.join(stagingRoot, "local", "overlays"), { recursive: true }),
28065
28060
  mkdir35(path53.join(stagingRoot, "local", "quarantine"), { recursive: true }),
28066
28061
  mkdir35(path53.join(stagingRoot, "local", "publish"), { recursive: true }),
28067
28062
  mkdir35(path53.join(stagingRoot, "local", "cache"), { recursive: true }),
@@ -41540,6 +41535,30 @@ function version() {
41540
41535
  console.log(platform);
41541
41536
  }
41542
41537
 
41538
+ // src/commands/workflow-subcommands.ts
41539
+ var WORKFLOW_SUBCOMMANDS = [
41540
+ "create",
41541
+ "list",
41542
+ "show",
41543
+ "update",
41544
+ "requirements",
41545
+ "plan",
41546
+ "review",
41547
+ "verify",
41548
+ "complete",
41549
+ "scope",
41550
+ "reframe",
41551
+ "archive",
41552
+ "checkpoint",
41553
+ "child",
41554
+ "promote",
41555
+ "handoff"
41556
+ ];
41557
+ var WORKFLOW_SUBCOMMAND_SET = new Set(
41558
+ WORKFLOW_SUBCOMMANDS
41559
+ );
41560
+ var CONTINUITY_COMPATIBILITY_SUBCOMMANDS = /* @__PURE__ */ new Set(["clean"]);
41561
+
41543
41562
  // src/commands/workflow.ts
41544
41563
  import { access as access6, readFile as readFile48, rm as rm23, writeFile as writeFile50 } from "fs/promises";
41545
41564
  import path69 from "path";
@@ -46757,60 +46776,43 @@ async function workflow(rootDir, subcommand, args = [], options = {}) {
46757
46776
  return EXIT_INVALID_ARG3;
46758
46777
  }
46759
46778
  }
46779
+ var WORKFLOW_V3_HANDLERS = {
46780
+ create: workflowCreateV3,
46781
+ list: workflowListV3,
46782
+ show: workflowShowV3,
46783
+ update: workflowUpdateV3,
46784
+ requirements: workflowRequirementsV3,
46785
+ plan: workflowPlanV3,
46786
+ review: workflowReviewV3,
46787
+ verify: workflowVerifyV3,
46788
+ complete: workflowCompleteV3,
46789
+ scope: workflowScopeChangeV3,
46790
+ reframe: workflowReframeV3,
46791
+ archive: (rootDir, args, options) => workflowArtifactShowV3(rootDir, "archive", args, options),
46792
+ checkpoint: (rootDir, args, options) => workflowArtifactShowV3(rootDir, "checkpoint", args, options),
46793
+ child: workflowChildResultMergeV3,
46794
+ promote: workflowPromoteV3,
46795
+ handoff: workflowSoloHandoffV3
46796
+ };
46797
+ var CONTINUITY_COMPATIBILITY_HANDLERS = {
46798
+ clean: (_rootDir, _args, options) => workflowCleanV3(options)
46799
+ };
46760
46800
  async function workflowV3(rootDir, subcommand, args, options) {
46761
- if (subcommand === "list") {
46762
- return workflowListV3(rootDir, args, options);
46763
- }
46764
- if (subcommand === "show") {
46765
- return workflowShowV3(rootDir, args, options);
46766
- }
46767
- if (subcommand === "clean") {
46768
- return workflowCleanV3(options);
46769
- }
46770
- if (subcommand === "create") {
46771
- return workflowCreateV3(rootDir, args, options);
46772
- }
46773
- if (subcommand === "update") {
46774
- return workflowUpdateV3(rootDir, args, options);
46775
- }
46776
- if (subcommand === "requirements") {
46777
- return workflowRequirementsV3(rootDir, args, options);
46778
- }
46779
- if (subcommand === "plan") {
46780
- return workflowPlanV3(rootDir, args, options);
46781
- }
46782
- if (subcommand === "review") {
46783
- return workflowReviewV3(rootDir, args, options);
46784
- }
46785
- if (subcommand === "verify") {
46786
- return workflowVerifyV3(rootDir, args, options);
46787
- }
46788
- if (subcommand === "complete") {
46789
- return workflowCompleteV3(rootDir, args, options);
46790
- }
46791
- if (subcommand === "scope") {
46792
- return workflowScopeChangeV3(rootDir, args, options);
46793
- }
46794
- if (subcommand === "reframe") {
46795
- return workflowReframeV3(rootDir, args, options);
46796
- }
46797
- if (subcommand === "archive" || subcommand === "checkpoint") {
46798
- return workflowArtifactShowV3(rootDir, subcommand, args, options);
46799
- }
46800
- if (subcommand === "child") {
46801
- return workflowChildResultMergeV3(rootDir, args, options);
46802
- }
46803
- if (subcommand === "promote") {
46804
- return workflowPromoteV3(rootDir, args, options);
46801
+ if (!WORKFLOW_SUBCOMMAND_SET.has(subcommand) && !CONTINUITY_COMPATIBILITY_SUBCOMMANDS.has(subcommand)) {
46802
+ return printV3Error(
46803
+ options.json,
46804
+ "MANCODE_V3_OPERATION_NOT_IMPLEMENTED",
46805
+ `Unknown workflow subcommand: ${subcommand}. Use one of: ${WORKFLOW_SUBCOMMANDS.join(", ")}.`
46806
+ );
46805
46807
  }
46806
- if (subcommand === "handoff") {
46807
- return workflowSoloHandoffV3(rootDir, args, options);
46808
+ if (WORKFLOW_SUBCOMMAND_SET.has(subcommand)) {
46809
+ return WORKFLOW_V3_HANDLERS[subcommand](
46810
+ rootDir,
46811
+ args,
46812
+ options
46813
+ );
46808
46814
  }
46809
- return printV3Error(
46810
- options.json,
46811
- "MANCODE_V3_OPERATION_NOT_IMPLEMENTED",
46812
- `workflow ${subcommand} is not yet implemented for mancode authority.`
46813
- );
46815
+ return CONTINUITY_COMPATIBILITY_HANDLERS[subcommand](rootDir, args, options);
46814
46816
  }
46815
46817
  async function workflowListV3(rootDir, args, options) {
46816
46818
  if (args.length !== 0) {
@@ -49041,445 +49043,528 @@ async function pathExists16(p) {
49041
49043
  }
49042
49044
 
49043
49045
  // src/cli.ts
49044
- program.name("mancode").description(
49045
- "AI coding agent harness. Modes: solo, man, manba, manteam, manps."
49046
- ).version(VERSION);
49047
- 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").addOption(new Option("--v3").hideHelp()).option("--legacy", "Use the legacy state.json initializer").option("--lang <locale>", "Initialization language: zh-CN or en").action(async (options) => {
49048
- const code = await init(process.cwd(), {
49049
- ...options,
49050
- fromCli: true,
49051
- interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
49052
- });
49053
- process.exitCode = code;
49054
- });
49055
- program.command("install [platform]").description(
49056
- "Install platform adapter (claude-code, cursor, codex, copilot, zcode, kimi-code, qoder)"
49057
- ).option("--force", "Reinstall even if already installed").option("--minimal", "Minimal install (MVP-2)").option(
49058
- "--shadow",
49059
- "Stage a mancode bootstrap candidate without changing live files"
49060
- ).option("--confirm", "Confirm a journaled adapter install or repair").option("--operation-id <id>", "Operation ID returned by adapter dry-run").option("--session <id>", "mancode session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").action(async (platform, options) => {
49061
- const code = await install(
49062
- process.cwd(),
49063
- platform ?? "claude-code",
49064
- options
49065
- );
49066
- process.exitCode = code;
49067
- });
49068
- var adapterProgram = program.command("adapter").description("Inspect and explicitly upgrade managed platform adapters");
49069
- adapterProgram.command("status").description("Inspect managed adapter content on disk").option("--platform <platform>", "Inspect one platform adapter").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49070
- process.exitCode = await adapterStatus(process.cwd(), options);
49071
- });
49072
- adapterProgram.command("upgrade").description("Preview or repair managed adapter content").option("--all", "Upgrade all platform adapters").option("--platform <platform>", "Upgrade one platform adapter").option("--dry-run", "Stage and report changes without writing live targets").option("--confirm", "Confirm the journaled adapter upgrade").option("--operation-id <id>", "Operation ID returned by adapter dry-run").option("--session <id>", "mancode session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49073
- process.exitCode = await adapterUpgrade(process.cwd(), options);
49074
- });
49075
- program.command("status").description("Show current mancode project status").option("--json", "Output as JSON (for scripts)").option("--brief", "Output compact mancode Continuity runtime status").action(async (options) => {
49076
- const code = await status(process.cwd(), options);
49077
- process.exitCode = code;
49078
- });
49079
- var projectProgram = program.command("project").description("Manage project-level mancode policy and compatibility");
49080
- projectProgram.command("upgrade").description("Upgrade project governance policy explicitly").requiredOption("--policy <version>", "Target planning policy version (2)").option("--dry-run", "Preview the upgrade without writing").option("--operation-id <id>", "Operation ID returned by project dry-run").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49081
- process.exitCode = await projectUpgrade(process.cwd(), options);
49082
- });
49083
- program.command("list-platforms").description("List available and installed mancode platform adapters").action(async () => {
49084
- const code = await listPlatforms(process.cwd());
49085
- process.exitCode = code;
49086
- });
49087
- program.command("uninstall [platform]").description("Remove platform adapter or all mancode artifacts").option("--force", "Skip confirmation message").option("--all", "Remove everything including .mancode/ directory").action(async (platform, options) => {
49088
- const code = await uninstall(process.cwd(), platform, options);
49089
- process.exitCode = code;
49090
- });
49091
- program.command("workflow <subcommand> [args...]").description("Manage mancode workflows").option("--dry-run", "Preview clean without deleting").option("--older-than <duration>", "Clean workflows older than (e.g. 30d)").option("--step <n>", "Update workflow current step").option("--status <status>", "Update workflow status").option(
49092
- "--parent-task <taskId>",
49093
- "Parent /man or /manteam workflow for manba"
49094
- ).option("--parent <namespace:id>", "Parent TaskRef for a manba child").option(
49095
- "--participant <actorId>",
49096
- "Invite a joined team participant",
49097
- collectOption,
49098
- []
49099
- ).option("--visibility <visibility>", "Task visibility: local or shared").option("--coordination <coordination>", "Task coordination: single or team").option("--session <id>", "mancode session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--expected-revision <n>", "Expected task revision for mutations").option("--checkpoint-id <id>", "Checkpoint ID for a requirements reframe").option("--child-revision <n>", "Expected child task revision for merge").option("--summary <text>", "Privacy-screened child result summary").option("--next-action <text>", "Next parent action after a child merge").option("--sync", "Publish shared mutations through git-ref transport").option(
49100
- "--confirm-shared",
49101
- "Confirm that task metadata may enter shared mancode authority"
49102
- ).option("--blocking-reason <reason>", "Explain why a workflow is blocked").option("--outcome <outcome>", "Set manba outcome when completing a task").option("--plan-version <n>", "Set the next man/manteam plan revision").option(
49103
- "--requirements-status <status>",
49104
- "Planning readiness: ready or needs_clarification"
49105
- ).option(
49106
- "--plan-decision <decision>",
49107
- "Plan gate choice: plan_only or governed_execution"
49108
- ).option("--to <mode>", "Workflow handoff target (solo)").option("--complete", "Complete an active solo handoff").option(
49109
- "--skipped <steps>",
49110
- "Policy v2: clarification only; use workflow review skip for review"
49111
- ).option("--review-depth <depth>", "Review depth: targeted or full").option("--review-domain <domain>", "Review domain: quality or security").option(
49112
- "--report <path>",
49113
- "Relative Markdown report path for a review domain"
49114
- ).option("--blockers <ids>", "Comma-separated blocker ids found by a review").option(
49115
- "--resolved <ids>",
49116
- "Comma-separated blocker ids resolved in remediation"
49117
- ).option(
49118
- "--file <path>",
49119
- "Semantic requirements JSON, plan Markdown, or ledger input file"
49120
- ).option(
49121
- "--scope-file <path>",
49122
- "Plan implementation scope JSON {include,exclude,modules}"
49123
- ).option("--acceptance <id>", "Acceptance criterion id (for example AC-1)").option("--method <method>", "Verification method: automated or manual").option("--result <result>", "Verification result").option("--evidence <text>", "Verification evidence or user confirmation").option("--command <command>", "Command used for automated verification").option("--exit-code <code>", "Exit code from automated verification").option("--evidence-file <path>", "Existing verification report or artifact").option("--reason <reason>", "Reason for an explicit review skip").option("--json", "Output as JSON (for scripts)").action(async (subcommand, args, options) => {
49124
- const code = await workflow(process.cwd(), subcommand, args ?? [], {
49125
- ...options,
49126
- participants: options.participant.length === 0 ? void 0 : options.participant
49127
- });
49128
- process.exitCode = code;
49129
- });
49130
- var contextProgram = program.command("context").description("Resolve mancode task context and manage explicit sessions");
49131
- contextProgram.command("show").description("Resolve one mancode Context Pack").option("--task <namespace:id>", "Explicit TaskRef").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--level <level>", "bootstrap, task, or full").option(
49132
- "--purpose <purpose>",
49133
- "orient, plan, implement, review, verify, or handoff"
49134
- ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49135
- process.exitCode = await contextShow(process.cwd(), options);
49136
- });
49137
- var contextSessionProgram = contextProgram.command("session").description("Manage mancode session identities");
49138
- contextSessionProgram.command("new").description("Create an explicit bootstrap session").requiredOption("--client <name>", "Client identity").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49139
- process.exitCode = await contextSessionNew(process.cwd(), options);
49140
- });
49141
- contextSessionProgram.command("show").description("Show one explicit session without changing it").requiredOption("--session <id>", "Session ID").option("--client <name>", "Expected client identity").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49142
- process.exitCode = await contextSessionShow(process.cwd(), options);
49143
- });
49144
- contextSessionProgram.command("spike").description("Record real-host session evidence without persisting host keys").requiredOption(
49145
- "--platform <platform>",
49146
- "claude-code, codex, cursor, copilot, zcode, kimi-code, or qoder"
49147
- ).requiredOption("--session-mode <mode>", "Evidence path: host or explicit").requiredOption(
49148
- "--host-session-source <source>",
49149
- "hook_stdin, environment, api, or none for explicit sessions"
49150
- ).requiredOption(
49151
- "--command-propagation <status>",
49152
- "Real host child-command result: proven, not_proven, not_tested, or not_applicable"
49153
- ).requiredOption(
49154
- "--subagent-inheritance <status>",
49155
- "Real host child-agent result: proven, not_proven, not_tested, or not_applicable"
49156
- ).option(
49157
- "--subagent-inheritance-reason <reason>",
49158
- "Required when child-agent inheritance is not applicable"
49159
- ).option(
49160
- "--hook-approval <status>",
49161
- "approved, unapproved, unknown, or not_applicable"
49162
- ).requiredOption(
49163
- "--host-version <version>",
49164
- "Installed host version used for the spike"
49165
- ).requiredOption(
49166
- "--release-candidate <id>",
49167
- "Immutable mancode release candidate or source commit identifier"
49168
- ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49169
- process.exitCode = await contextSessionSpike(process.cwd(), options);
49170
- });
49171
- contextProgram.command("resume <namespace:id>").description("Validate and bind the current session to a mancode TaskRef").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish shared mutations through git-ref transport").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49172
- process.exitCode = await contextResume(process.cwd(), task, options);
49173
- });
49174
- contextProgram.command("close").description("Close one explicit session without affecting other sessions").requiredOption("--session <id>", "Session ID").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49175
- process.exitCode = await contextClose(process.cwd(), options);
49176
- });
49177
- contextProgram.command("doctor").description("Inspect unfinished mancode operations or repair one explicitly").option(
49178
- "--repair <operationId>",
49179
- "Repair this operation with its original session"
49180
- ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49181
- process.exitCode = await contextDoctor(process.cwd(), options);
49182
- });
49183
- contextProgram.command("diagnostics [action]").description("Show or configure local aggregate diagnostics").option("--json", "Output as JSON (for scripts)").action(async (action, options) => {
49184
- process.exitCode = await contextDiagnostics(process.cwd(), action, options);
49185
- });
49186
- contextProgram.command("compact").description("List and remove eligible mancode runtime retention candidates").option("--task <namespace:id>", "Compact checkpoints for one completed task").option("--dry-run", "Show the deletion list without changing files").option("--apply-shared", "Permit deletion for shared completed tasks").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49187
- process.exitCode = await contextCompact(process.cwd(), options);
49188
- });
49189
- contextProgram.command("beta", { hidden: true }).description("Evaluate internal release-evidence gates").requiredOption(
49190
- "--release-candidate <id>",
49191
- "Release candidate that must match every platform evidence record"
49192
- ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49193
- process.exitCode = await contextBeta(process.cwd(), options);
49194
- });
49195
- contextProgram.command("publish <local:id>").description("Create a privacy-screened shared man successor").requiredOption("--expected-revision <n>", "Current local task revision").requiredOption(
49196
- "--confirm-shared",
49197
- "Confirm that the screened task authority may enter shared storage"
49198
- ).option("--dry-run", "Validate the publish preflight without writing").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49199
- process.exitCode = await contextPublish(process.cwd(), task, options);
49200
- });
49201
- contextProgram.command("reconcile-task-head <shared:id>").description(
49202
- "Adopt a Git-sourced shared aggregate through an explicit fence CAS"
49203
- ).requiredOption(
49204
- "--expected-fence-revision <n>",
49205
- "Current shared task-head fence revision"
49206
- ).requiredOption(
49207
- "--from-git",
49208
- "Confirm the checked-out aggregate came from Git"
49209
- ).option("--dry-run", "Validate adoption without changing the task-head fence").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49210
- process.exitCode = await contextReconcileTaskHead(
49211
- process.cwd(),
49212
- task,
49213
- options
49214
- );
49215
- });
49216
- contextProgram.command("glossary <action>").description("Manage the user-confirmed shared project glossary").option("--term <term>", "Glossary term (add, update, remove)").option("--definition <text>", "Term definition (add, update)").option(
49217
- "--alias <alias>",
49218
- "Term alias; repeat for multiple aliases (add, update)",
49219
- (value, previous) => [...previous, value],
49220
- []
49221
- ).option("--task <namespace:id>", "Source shared TaskRef (add, update)").option(
49222
- "--expected-revision <n>",
49223
- "Current glossary revision (0 for an empty glossary)"
49224
- ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (action, options) => {
49225
- process.exitCode = await contextGlossary(process.cwd(), action, options);
49226
- });
49227
- var contextWorktreeProgram = contextProgram.command("worktree").description("Register and inspect the current mancode checkout binding");
49228
- contextWorktreeProgram.command("register").description(
49229
- "Register this linked worktree before using mancode coordination"
49230
- ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49231
- process.exitCode = await contextWorktreeRegister(process.cwd(), options);
49232
- });
49233
- var operationProgram = program.command("operation").description("Inspect and recover durable mancode operations");
49234
- operationProgram.command("show <operationId>").description("Show one operation journal and its recovery disposition").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49235
- process.exitCode = await operationShow(process.cwd(), operationId, options);
49236
- });
49237
- operationProgram.command("repair <operationId>").description("Repair an operation using its original actor and session").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49238
- process.exitCode = await operationRepair(
49239
- process.cwd(),
49240
- operationId,
49241
- options
49242
- );
49243
- });
49244
- operationProgram.command("abort <operationId>").description(
49245
- "Abort only an operation proven to have no visible business write"
49246
- ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49247
- process.exitCode = await operationAbort(
49248
- process.cwd(),
49249
- operationId,
49250
- options
49251
- );
49252
- });
49253
- var teamProgram = program.command("team").description("Manage mancode local identity and local-team membership");
49254
- teamProgram.command("status").description("Show mancode team policy, transport, and local identity state").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49255
- process.exitCode = await teamStatus(process.cwd(), options);
49256
- });
49257
- teamProgram.command("policy <mode>").description("Set the mancode team recommendation policy with a revision CAS").requiredOption("--expected-revision <n>", "Current team policy revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (policy, options) => {
49258
- process.exitCode = await teamPolicy(process.cwd(), {
49259
- ...options,
49260
- policy
49046
+ function createCliProgram() {
49047
+ const program = new Command();
49048
+ program.name("mancode").description(
49049
+ "AI coding agent harness. Modes: solo, man, manba, manteam, manps."
49050
+ ).version(VERSION);
49051
+ 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").option("--no-team", "Force disable team mode").option(
49052
+ "--style <name>",
49053
+ "Legacy aesthetic style (only supported with mancode init --legacy)"
49054
+ ).option("--platform <platforms>", "Adapters: comma-separated names or all").option("--empty", "Initialize a safe empty directory as a generic project").addOption(new Option("--v3").hideHelp()).option("--legacy", "Use the legacy state.json initializer").option("--lang <locale>", "Initialization language: zh-CN or en").action(async (options) => {
49055
+ const code = await init(process.cwd(), {
49056
+ ...options,
49057
+ fromCli: true,
49058
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
49059
+ });
49060
+ process.exitCode = code;
49061
+ });
49062
+ program.command("install [platform]").description(
49063
+ "Install platform adapter (claude-code, cursor, codex, copilot, zcode, kimi-code, qoder)"
49064
+ ).option("--force", "Reinstall even if already installed").option(
49065
+ "--minimal",
49066
+ "Retained for legacy compatibility; Continuity bootstrap is already minimal"
49067
+ ).option(
49068
+ "--shadow",
49069
+ "Stage a mancode bootstrap candidate without changing live files"
49070
+ ).option("--confirm", "Confirm a journaled adapter install or repair").option("--operation-id <id>", "Operation ID returned by adapter dry-run").option(
49071
+ "--session <id>",
49072
+ "mancode session ID (otherwise MANCODE_SESSION_ID)"
49073
+ ).option("--client <name>", "Client identity (default: mancode-cli)").action(async (platform, options) => {
49074
+ const code = await install(
49075
+ process.cwd(),
49076
+ platform ?? "claude-code",
49077
+ options
49078
+ );
49079
+ process.exitCode = code;
49080
+ });
49081
+ const adapterProgram = program.command("adapter").description("Inspect and explicitly upgrade managed platform adapters");
49082
+ adapterProgram.command("status").description("Inspect managed adapter content on disk").option("--platform <platform>", "Inspect one platform adapter").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49083
+ process.exitCode = await adapterStatus(process.cwd(), options);
49084
+ });
49085
+ adapterProgram.command("upgrade").description("Preview or repair managed adapter content").option("--all", "Upgrade all platform adapters").option("--platform <platform>", "Upgrade one platform adapter").option(
49086
+ "--dry-run",
49087
+ "Stage and report changes without writing live targets"
49088
+ ).option("--confirm", "Confirm the journaled adapter upgrade").option("--operation-id <id>", "Operation ID returned by adapter dry-run").option(
49089
+ "--session <id>",
49090
+ "mancode session ID (otherwise MANCODE_SESSION_ID)"
49091
+ ).option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49092
+ process.exitCode = await adapterUpgrade(process.cwd(), options);
49093
+ });
49094
+ program.command("status").description("Show current mancode project status").option("--json", "Output as JSON (for scripts)").option("--brief", "Output compact mancode Continuity runtime status").action(async (options) => {
49095
+ const code = await status(process.cwd(), options);
49096
+ process.exitCode = code;
49097
+ });
49098
+ const projectProgram = program.command("project").description("Manage project-level mancode policy and compatibility");
49099
+ projectProgram.command("upgrade").description("Upgrade project governance policy explicitly").requiredOption("--policy <version>", "Target planning policy version (2)").option("--dry-run", "Preview the upgrade without writing").option("--operation-id <id>", "Operation ID returned by project dry-run").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49100
+ process.exitCode = await projectUpgrade(process.cwd(), options);
49101
+ });
49102
+ program.command("list-platforms").description("List available and installed mancode platform adapters").action(async () => {
49103
+ const code = await listPlatforms(process.cwd());
49104
+ process.exitCode = code;
49105
+ });
49106
+ program.command("uninstall [platform]").description("Remove platform adapter or all mancode artifacts").option("--force", "Skip confirmation message").option("--all", "Remove everything including .mancode/ directory").action(async (platform, options) => {
49107
+ const code = await uninstall(process.cwd(), platform, options);
49108
+ process.exitCode = code;
49109
+ });
49110
+ program.command("workflow <subcommand> [args...]").description("Manage mancode workflows").addHelpText(
49111
+ "after",
49112
+ `
49113
+ Public Continuity subcommands:
49114
+ ${WORKFLOW_SUBCOMMANDS.join(", ")}
49115
+ `
49116
+ ).option("--dry-run", "Preview clean without deleting").option("--older-than <duration>", "Clean workflows older than (e.g. 30d)").option("--step <n>", "Update workflow current step").option("--status <status>", "Update workflow status").option(
49117
+ "--parent-task <taskId>",
49118
+ "Parent /man or /manteam workflow for manba"
49119
+ ).option("--parent <namespace:id>", "Parent TaskRef for a manba child").option(
49120
+ "--participant <actorId>",
49121
+ "Invite a joined team participant",
49122
+ collectOption,
49123
+ []
49124
+ ).option("--visibility <visibility>", "Task visibility: local or shared").option(
49125
+ "--coordination <coordination>",
49126
+ "Task coordination: single or team"
49127
+ ).option(
49128
+ "--session <id>",
49129
+ "mancode session ID (otherwise MANCODE_SESSION_ID)"
49130
+ ).option("--client <name>", "Client identity (default: mancode-cli)").option("--expected-revision <n>", "Expected task revision for mutations").option("--checkpoint-id <id>", "Checkpoint ID for a requirements reframe").option("--child-revision <n>", "Expected child task revision for merge").option("--summary <text>", "Privacy-screened child result summary").option("--next-action <text>", "Next parent action after a child merge").option("--sync", "Publish shared mutations through git-ref transport").option(
49131
+ "--confirm-shared",
49132
+ "Confirm that task metadata may enter shared mancode authority"
49133
+ ).option("--blocking-reason <reason>", "Explain why a workflow is blocked").option("--outcome <outcome>", "Set manba outcome when completing a task").option("--plan-version <n>", "Set the next man/manteam plan revision").option(
49134
+ "--requirements-status <status>",
49135
+ "Planning readiness: ready or needs_clarification"
49136
+ ).option(
49137
+ "--plan-decision <decision>",
49138
+ "Plan gate choice: plan_only or governed_execution"
49139
+ ).option("--to <mode>", "Workflow handoff target (solo)").option("--complete", "Complete an active solo handoff").option(
49140
+ "--skipped <steps>",
49141
+ "Policy v2: clarification only; use workflow review skip for review"
49142
+ ).option("--review-depth <depth>", "Review depth: targeted or full").option("--review-domain <domain>", "Review domain: quality or security").option(
49143
+ "--report <path>",
49144
+ "Relative Markdown report path for a review domain"
49145
+ ).option("--blockers <ids>", "Comma-separated blocker ids found by a review").option(
49146
+ "--resolved <ids>",
49147
+ "Comma-separated blocker ids resolved in remediation"
49148
+ ).option(
49149
+ "--file <path>",
49150
+ "Semantic requirements JSON, plan Markdown, or ledger input file"
49151
+ ).option(
49152
+ "--scope-file <path>",
49153
+ "Plan implementation scope JSON {include,exclude,modules}"
49154
+ ).option("--acceptance <id>", "Acceptance criterion id (for example AC-1)").option("--method <method>", "Verification method: automated or manual").option("--result <result>", "Verification result").option("--evidence <text>", "Verification evidence or user confirmation").option("--command <command>", "Command used for automated verification").option("--exit-code <code>", "Exit code from automated verification").option(
49155
+ "--evidence-file <path>",
49156
+ "Existing verification report or artifact"
49157
+ ).option("--reason <reason>", "Reason for an explicit review skip").option("--json", "Output as JSON (for scripts)").action(async (subcommand, args, options) => {
49158
+ const code = await workflow(process.cwd(), subcommand, args ?? [], {
49159
+ ...options,
49160
+ participants: options.participant.length === 0 ? void 0 : options.participant
49161
+ });
49162
+ process.exitCode = code;
49163
+ });
49164
+ const contextProgram = program.command("context").description("Resolve mancode task context and manage explicit sessions");
49165
+ contextProgram.command("show").description("Resolve one mancode Context Pack").option("--task <namespace:id>", "Explicit TaskRef").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--level <level>", "bootstrap, task, or full").option(
49166
+ "--purpose <purpose>",
49167
+ "orient, plan, implement, review, verify, or handoff"
49168
+ ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49169
+ process.exitCode = await contextShow(process.cwd(), options);
49170
+ });
49171
+ const contextSessionProgram = contextProgram.command("session").description("Manage mancode session identities");
49172
+ contextSessionProgram.command("new").description("Create an explicit bootstrap session").requiredOption("--client <name>", "Client identity").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49173
+ process.exitCode = await contextSessionNew(process.cwd(), options);
49174
+ });
49175
+ contextSessionProgram.command("show").description("Show one explicit session without changing it").requiredOption("--session <id>", "Session ID").option("--client <name>", "Expected client identity").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49176
+ process.exitCode = await contextSessionShow(process.cwd(), options);
49177
+ });
49178
+ contextSessionProgram.command("spike").description(
49179
+ "Record real-host session evidence without persisting host keys"
49180
+ ).requiredOption(
49181
+ "--platform <platform>",
49182
+ "claude-code, codex, cursor, copilot, zcode, kimi-code, or qoder"
49183
+ ).requiredOption("--session-mode <mode>", "Evidence path: host or explicit").requiredOption(
49184
+ "--host-session-source <source>",
49185
+ "hook_stdin, environment, api, or none for explicit sessions"
49186
+ ).requiredOption(
49187
+ "--command-propagation <status>",
49188
+ "Real host child-command result: proven, not_proven, not_tested, or not_applicable"
49189
+ ).requiredOption(
49190
+ "--subagent-inheritance <status>",
49191
+ "Real host child-agent result: proven, not_proven, not_tested, or not_applicable"
49192
+ ).option(
49193
+ "--subagent-inheritance-reason <reason>",
49194
+ "Required when child-agent inheritance is not applicable"
49195
+ ).option(
49196
+ "--hook-approval <status>",
49197
+ "approved, unapproved, unknown, or not_applicable"
49198
+ ).requiredOption(
49199
+ "--host-version <version>",
49200
+ "Installed host version used for the spike"
49201
+ ).requiredOption(
49202
+ "--release-candidate <id>",
49203
+ "Immutable mancode release candidate or source commit identifier"
49204
+ ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49205
+ process.exitCode = await contextSessionSpike(process.cwd(), options);
49206
+ });
49207
+ contextProgram.command("resume <namespace:id>").description("Validate and bind the current session to a mancode TaskRef").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish shared mutations through git-ref transport").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49208
+ process.exitCode = await contextResume(process.cwd(), task, options);
49209
+ });
49210
+ contextProgram.command("close").description("Close one explicit session without affecting other sessions").requiredOption("--session <id>", "Session ID").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49211
+ process.exitCode = await contextClose(process.cwd(), options);
49212
+ });
49213
+ contextProgram.command("doctor").description(
49214
+ "Inspect unfinished mancode operations or repair one explicitly"
49215
+ ).option(
49216
+ "--repair <operationId>",
49217
+ "Repair this operation with its original session"
49218
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49219
+ process.exitCode = await contextDoctor(process.cwd(), options);
49220
+ });
49221
+ contextProgram.command("diagnostics [action]").description("Show or configure local aggregate diagnostics").option("--json", "Output as JSON (for scripts)").action(async (action, options) => {
49222
+ process.exitCode = await contextDiagnostics(
49223
+ process.cwd(),
49224
+ action,
49225
+ options
49226
+ );
49227
+ });
49228
+ contextProgram.command("compact").description(
49229
+ "List and remove eligible mancode runtime retention candidates"
49230
+ ).option(
49231
+ "--task <namespace:id>",
49232
+ "Compact checkpoints for one completed task"
49233
+ ).option("--dry-run", "Show the deletion list without changing files").option("--apply-shared", "Permit deletion for shared completed tasks").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49234
+ process.exitCode = await contextCompact(process.cwd(), options);
49235
+ });
49236
+ contextProgram.command("beta", { hidden: true }).description("Evaluate internal release-evidence gates").requiredOption(
49237
+ "--release-candidate <id>",
49238
+ "Release candidate that must match every platform evidence record"
49239
+ ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49240
+ process.exitCode = await contextBeta(process.cwd(), options);
49241
+ });
49242
+ contextProgram.command("publish <local:id>").description("Create a privacy-screened shared man successor").requiredOption("--expected-revision <n>", "Current local task revision").requiredOption(
49243
+ "--confirm-shared",
49244
+ "Confirm that the screened task authority may enter shared storage"
49245
+ ).option("--dry-run", "Validate the publish preflight without writing").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49246
+ process.exitCode = await contextPublish(process.cwd(), task, options);
49247
+ });
49248
+ contextProgram.command("reconcile-task-head <shared:id>").description(
49249
+ "Adopt a Git-sourced shared aggregate through an explicit fence CAS"
49250
+ ).requiredOption(
49251
+ "--expected-fence-revision <n>",
49252
+ "Current shared task-head fence revision"
49253
+ ).requiredOption(
49254
+ "--from-git",
49255
+ "Confirm the checked-out aggregate came from Git"
49256
+ ).option(
49257
+ "--dry-run",
49258
+ "Validate adoption without changing the task-head fence"
49259
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49260
+ process.exitCode = await contextReconcileTaskHead(
49261
+ process.cwd(),
49262
+ task,
49263
+ options
49264
+ );
49265
+ });
49266
+ contextProgram.command("glossary <action>").description("Manage the user-confirmed shared project glossary").option("--term <term>", "Glossary term (add, update, remove)").option("--definition <text>", "Term definition (add, update)").option(
49267
+ "--alias <alias>",
49268
+ "Term alias; repeat for multiple aliases (add, update)",
49269
+ (value, previous) => [...previous, value],
49270
+ []
49271
+ ).option("--task <namespace:id>", "Source shared TaskRef (add, update)").option(
49272
+ "--expected-revision <n>",
49273
+ "Current glossary revision (0 for an empty glossary)"
49274
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (action, options) => {
49275
+ process.exitCode = await contextGlossary(process.cwd(), action, options);
49276
+ });
49277
+ const contextWorktreeProgram = contextProgram.command("worktree").description("Register and inspect the current mancode checkout binding");
49278
+ contextWorktreeProgram.command("register").description(
49279
+ "Register this linked worktree before using mancode coordination"
49280
+ ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49281
+ process.exitCode = await contextWorktreeRegister(process.cwd(), options);
49282
+ });
49283
+ const operationProgram = program.command("operation").description("Inspect and recover durable mancode operations");
49284
+ operationProgram.command("show <operationId>").description("Show one operation journal and its recovery disposition").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49285
+ process.exitCode = await operationShow(
49286
+ process.cwd(),
49287
+ operationId,
49288
+ options
49289
+ );
49261
49290
  });
49262
- });
49263
- teamProgram.command("conflicts").description(
49264
- "Inspect local claim conflicts and handoffs without mutating coordination"
49265
- ).option("--task <namespace:id>", "Narrow the report to one shared TaskRef").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49266
- process.exitCode = await teamConflicts(process.cwd(), options);
49267
- });
49268
- var teamTransportProgram = teamProgram.command("transport").description("Inspect and migrate the coordination authority");
49269
- teamTransportProgram.command("status").description("Show active coordination transport and freshness").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49270
- process.exitCode = await teamTransportStatus(process.cwd(), options);
49271
- });
49272
- teamTransportProgram.command("set <mode>").description(
49273
- "Switch an empty coordination authority; otherwise use transport migrate"
49274
- ).requiredOption(
49275
- "--expected-config-revision <n>",
49276
- "Current project config revision"
49277
- ).option(
49278
- "--remote <name>",
49279
- "Git remote for a git-ref target (default: origin)"
49280
- ).option("--dry-run", "Validate the empty-authority switch without writing").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (mode, options) => {
49281
- process.exitCode = await teamTransportSet(process.cwd(), {
49282
- ...options,
49283
- mode
49291
+ operationProgram.command("repair <operationId>").description("Repair an operation using its original actor and session").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49292
+ process.exitCode = await operationRepair(
49293
+ process.cwd(),
49294
+ operationId,
49295
+ options
49296
+ );
49284
49297
  });
49285
- });
49286
- teamTransportProgram.command("migrate").description("Journal a single-authority local/git-ref transport switch").requiredOption("--to <mode>", "Target authority: local or git-ref").requiredOption(
49287
- "--expected-config-revision <n>",
49288
- "Current project config revision"
49289
- ).option(
49290
- "--remote <name>",
49291
- "Git remote for a git-ref target (default: origin)"
49292
- ).option("--dry-run", "Validate and preview without writing authority state").option("--confirm", "Explicitly confirm the authority migration").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49293
- process.exitCode = await teamTransportMigrate(process.cwd(), options);
49294
- });
49295
- teamTransportProgram.command("recover <operationId>").description("Repair forward or safely abort a transport migration").requiredOption("--to <mode>", "Original target authority: local or git-ref").option("--remote <name>", "Original Git remote for a git-ref target").option("--abort", "Abort only before the target authority is established").option("--session <id>", "Original migration session ID").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49296
- process.exitCode = await teamTransportRecover(
49297
- process.cwd(),
49298
- operationId,
49299
- options
49300
- );
49301
- });
49302
- var teamSyncProgram = teamProgram.command("sync").description("Explicitly synchronize the git-ref coordination authority");
49303
- teamSyncProgram.command("pull").description("Fetch, validate, and cache refs/mancode/team").option("--task <namespace:id>", "Narrow output to one shared TaskRef").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49304
- process.exitCode = await teamSyncPull(process.cwd(), options);
49305
- });
49306
- teamSyncProgram.command("push <namespace:id>").description("Publish one task bundle through a fresh ownership fence CAS").requiredOption(
49307
- "--expected-task-revision <n>",
49308
- "Current shared task revision"
49309
- ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49310
- process.exitCode = await teamSyncPush(process.cwd(), {
49311
- ...options,
49312
- task
49298
+ operationProgram.command("abort <operationId>").description(
49299
+ "Abort only an operation proven to have no visible business write"
49300
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49301
+ process.exitCode = await operationAbort(
49302
+ process.cwd(),
49303
+ operationId,
49304
+ options
49305
+ );
49313
49306
  });
49314
- });
49315
- var teamIdentityProgram = teamProgram.command("identity").description("Manage the machine-local actor identity");
49316
- teamIdentityProgram.command("create").description("Create one local actor identity").requiredOption("--name <displayName>", "Display name").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49317
- process.exitCode = await teamIdentityCreate(process.cwd(), options);
49318
- });
49319
- teamIdentityProgram.command("show").description("Show local identity and whether it is joined").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49320
- process.exitCode = await teamIdentityShow(process.cwd(), options);
49321
- });
49322
- var teamDecisionProgram = teamProgram.command("decision").description("Publish explicitly confirmed, privacy-safe shared decisions");
49323
- teamDecisionProgram.command("publish").description("Publish one immutable confirmed decision").requiredOption("--title <text>", "Short decision title").requiredOption("--statement <text>", "Confirmed decision statement").option("--task <namespace:id>", "Optional shared TaskRef that produced it").requiredOption("--confirm", "Confirm this decision may enter shared memory").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49324
- process.exitCode = await teamDecisionPublish(process.cwd(), options);
49325
- });
49326
- teamProgram.command("join").description(
49327
- "Publish the approved shared actor profile after explicit confirmation"
49328
- ).requiredOption("--name <displayName>", "Must match the local actor identity").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Request explicit remote sync when transport supports it").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49329
- process.exitCode = await teamJoin(process.cwd(), options);
49330
- });
49331
- teamProgram.command("checkpoint <namespace:id>").description("Create a journaled immutable checkpoint for a shared task").requiredOption(
49332
- "--expected-task-revision <n>",
49333
- "Current shared task revision"
49334
- ).requiredOption("--kind <kind>", "Checkpoint kind").requiredOption("--summary <text>", "Privacy-safe checkpoint summary").option("--next-action <text>", "Next action for the receiving workflow").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49335
- process.exitCode = await teamCheckpoint(process.cwd(), {
49336
- ...options,
49337
- task
49307
+ const teamProgram = program.command("team").description("Manage mancode local identity and local-team membership");
49308
+ teamProgram.command("status").description(
49309
+ "Show mancode team policy, transport, and local identity state"
49310
+ ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49311
+ process.exitCode = await teamStatus(process.cwd(), options);
49338
49312
  });
49339
- });
49340
- teamProgram.command("claim <namespace:id>").description("Acquire a scoped claim for a shared task").requiredOption(
49341
- "--expected-task-revision <n>",
49342
- "Current shared task revision"
49343
- ).option("--path <glob>", "Repository-relative path glob", collectOption, []).option("--module <name>", "Implementation module", collectOption, []).option("--api <name>", "Public API boundary", collectOption, []).option("--schema <name>", "Shared schema boundary", collectOption, []).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49344
- process.exitCode = await teamClaim(process.cwd(), {
49345
- ...options,
49346
- task,
49347
- paths: options.path,
49348
- modules: options.module,
49349
- apis: options.api,
49350
- schemas: options.schema
49313
+ teamProgram.command("policy <mode>").description(
49314
+ "Set the mancode team recommendation policy with a revision CAS"
49315
+ ).requiredOption("--expected-revision <n>", "Current team policy revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (policy, options) => {
49316
+ process.exitCode = await teamPolicy(process.cwd(), {
49317
+ ...options,
49318
+ policy
49319
+ });
49320
+ });
49321
+ teamProgram.command("conflicts").description(
49322
+ "Inspect local claim conflicts and handoffs without mutating coordination"
49323
+ ).option("--task <namespace:id>", "Narrow the report to one shared TaskRef").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49324
+ process.exitCode = await teamConflicts(process.cwd(), options);
49325
+ });
49326
+ const teamTransportProgram = teamProgram.command("transport").description("Inspect and migrate the coordination authority");
49327
+ teamTransportProgram.command("status").description("Show active coordination transport and freshness").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49328
+ process.exitCode = await teamTransportStatus(process.cwd(), options);
49329
+ });
49330
+ teamTransportProgram.command("set <mode>").description(
49331
+ "Switch an empty coordination authority; otherwise use transport migrate"
49332
+ ).requiredOption(
49333
+ "--expected-config-revision <n>",
49334
+ "Current project config revision"
49335
+ ).option(
49336
+ "--remote <name>",
49337
+ "Git remote for a git-ref target (default: origin)"
49338
+ ).option("--dry-run", "Validate the empty-authority switch without writing").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (mode, options) => {
49339
+ process.exitCode = await teamTransportSet(process.cwd(), {
49340
+ ...options,
49341
+ mode
49342
+ });
49351
49343
  });
49352
- });
49353
- teamProgram.command("renew <claimId>").description("Renew one fresh claim lease").requiredOption("--expected-revision <n>", "Current claim revision").option("--ttl <duration>", "Lease duration: ms, s, m, h, or d").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49354
- process.exitCode = await teamClaimRenew(process.cwd(), {
49355
- ...options,
49356
- claimId
49344
+ teamTransportProgram.command("migrate").description("Journal a single-authority local/git-ref transport switch").requiredOption("--to <mode>", "Target authority: local or git-ref").requiredOption(
49345
+ "--expected-config-revision <n>",
49346
+ "Current project config revision"
49347
+ ).option(
49348
+ "--remote <name>",
49349
+ "Git remote for a git-ref target (default: origin)"
49350
+ ).option("--dry-run", "Validate and preview without writing authority state").option("--confirm", "Explicitly confirm the authority migration").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49351
+ process.exitCode = await teamTransportMigrate(process.cwd(), options);
49352
+ });
49353
+ teamTransportProgram.command("recover <operationId>").description("Repair forward or safely abort a transport migration").requiredOption(
49354
+ "--to <mode>",
49355
+ "Original target authority: local or git-ref"
49356
+ ).option("--remote <name>", "Original Git remote for a git-ref target").option("--abort", "Abort only before the target authority is established").option("--session <id>", "Original migration session ID").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (operationId, options) => {
49357
+ process.exitCode = await teamTransportRecover(
49358
+ process.cwd(),
49359
+ operationId,
49360
+ options
49361
+ );
49357
49362
  });
49358
- });
49359
- teamProgram.command("release <claimId>").description("Release one claim").requiredOption("--expected-revision <n>", "Current claim revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49360
- process.exitCode = await teamClaimRelease(process.cwd(), {
49361
- ...options,
49362
- claimId
49363
+ const teamSyncProgram = teamProgram.command("sync").description("Explicitly synchronize the git-ref coordination authority");
49364
+ teamSyncProgram.command("pull").description("Fetch, validate, and cache refs/mancode/team").option("--task <namespace:id>", "Narrow output to one shared TaskRef").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49365
+ process.exitCode = await teamSyncPull(process.cwd(), options);
49363
49366
  });
49364
- });
49365
- teamProgram.command("transfer <claimId>").description("Transfer a claim through a new successor identity").requiredOption("--to <actorId>", "Receiving joined participant actor ID").requiredOption("--expected-revision <n>", "Current claim revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49366
- process.exitCode = await teamClaimTransfer(process.cwd(), {
49367
- ...options,
49368
- claimId
49367
+ teamSyncProgram.command("push <namespace:id>").description("Publish one task bundle through a fresh ownership fence CAS").requiredOption(
49368
+ "--expected-task-revision <n>",
49369
+ "Current shared task revision"
49370
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49371
+ process.exitCode = await teamSyncPush(process.cwd(), {
49372
+ ...options,
49373
+ task
49374
+ });
49375
+ });
49376
+ const teamIdentityProgram = teamProgram.command("identity").description("Manage the machine-local actor identity");
49377
+ teamIdentityProgram.command("create").description("Create one local actor identity").requiredOption("--name <displayName>", "Display name").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49378
+ process.exitCode = await teamIdentityCreate(process.cwd(), options);
49379
+ });
49380
+ teamIdentityProgram.command("show").description("Show local identity and whether it is joined").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49381
+ process.exitCode = await teamIdentityShow(process.cwd(), options);
49382
+ });
49383
+ const teamDecisionProgram = teamProgram.command("decision").description("Publish explicitly confirmed, privacy-safe shared decisions");
49384
+ teamDecisionProgram.command("publish").description("Publish one immutable confirmed decision").requiredOption("--title <text>", "Short decision title").requiredOption("--statement <text>", "Confirmed decision statement").option("--task <namespace:id>", "Optional shared TaskRef that produced it").requiredOption(
49385
+ "--confirm",
49386
+ "Confirm this decision may enter shared memory"
49387
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49388
+ process.exitCode = await teamDecisionPublish(process.cwd(), options);
49389
+ });
49390
+ teamProgram.command("join").description(
49391
+ "Publish the approved shared actor profile after explicit confirmation"
49392
+ ).requiredOption(
49393
+ "--name <displayName>",
49394
+ "Must match the local actor identity"
49395
+ ).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Request explicit remote sync when transport supports it").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49396
+ process.exitCode = await teamJoin(process.cwd(), options);
49397
+ });
49398
+ teamProgram.command("checkpoint <namespace:id>").description("Create a journaled immutable checkpoint for a shared task").requiredOption(
49399
+ "--expected-task-revision <n>",
49400
+ "Current shared task revision"
49401
+ ).requiredOption("--kind <kind>", "Checkpoint kind").requiredOption("--summary <text>", "Privacy-safe checkpoint summary").option("--next-action <text>", "Next action for the receiving workflow").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49402
+ process.exitCode = await teamCheckpoint(process.cwd(), {
49403
+ ...options,
49404
+ task
49405
+ });
49369
49406
  });
49370
- });
49371
- teamProgram.command("reclaim <claimId>").description("Explicitly mark an expired claim terminal").requiredOption("--expected-revision <n>", "Current claim revision").requiredOption("--reason <text>", "Privacy-safe expiry reclaim reason").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49372
- process.exitCode = await teamClaimReclaim(process.cwd(), {
49373
- ...options,
49374
- claimId
49407
+ teamProgram.command("claim <namespace:id>").description("Acquire a scoped claim for a shared task").requiredOption(
49408
+ "--expected-task-revision <n>",
49409
+ "Current shared task revision"
49410
+ ).option("--path <glob>", "Repository-relative path glob", collectOption, []).option("--module <name>", "Implementation module", collectOption, []).option("--api <name>", "Public API boundary", collectOption, []).option("--schema <name>", "Shared schema boundary", collectOption, []).option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49411
+ process.exitCode = await teamClaim(process.cwd(), {
49412
+ ...options,
49413
+ task,
49414
+ paths: options.path,
49415
+ modules: options.module,
49416
+ apis: options.api,
49417
+ schemas: options.schema
49418
+ });
49375
49419
  });
49376
- });
49377
- teamProgram.command("revalidate <claimId>").description("Refresh one claim after task or code snapshot drift").requiredOption("--expected-revision <n>", "Current claim revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49378
- process.exitCode = await teamClaimRevalidate(process.cwd(), {
49379
- ...options,
49380
- claimId
49420
+ teamProgram.command("renew <claimId>").description("Renew one fresh claim lease").requiredOption("--expected-revision <n>", "Current claim revision").option("--ttl <duration>", "Lease duration: ms, s, m, h, or d").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49421
+ process.exitCode = await teamClaimRenew(process.cwd(), {
49422
+ ...options,
49423
+ claimId
49424
+ });
49381
49425
  });
49382
- });
49383
- var teamHandoffProgram = teamProgram.command("handoff").description("Create and transition journaled ownership handoffs");
49384
- teamHandoffProgram.command("draft <namespace:id>").description("Create a checkpoint-backed named handoff draft").requiredOption(
49385
- "--expected-task-revision <n>",
49386
- "Current shared task revision"
49387
- ).requiredOption("--to <actorId>", "Receiving joined participant actor ID").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49388
- process.exitCode = await teamHandoffDraft(process.cwd(), {
49389
- ...options,
49390
- task
49426
+ teamProgram.command("release <claimId>").description("Release one claim").requiredOption("--expected-revision <n>", "Current claim revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49427
+ process.exitCode = await teamClaimRelease(process.cwd(), {
49428
+ ...options,
49429
+ claimId
49430
+ });
49391
49431
  });
49392
- });
49393
- teamHandoffProgram.command("offer <handoffId>").description("Offer a handoff draft to its receiving actor").requiredOption("--expected-revision <n>", "Current handoff revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49394
- process.exitCode = await teamHandoffOffer(process.cwd(), {
49395
- ...options,
49396
- handoffId
49432
+ teamProgram.command("transfer <claimId>").description("Transfer a claim through a new successor identity").requiredOption("--to <actorId>", "Receiving joined participant actor ID").requiredOption("--expected-revision <n>", "Current claim revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49433
+ process.exitCode = await teamClaimTransfer(process.cwd(), {
49434
+ ...options,
49435
+ claimId
49436
+ });
49397
49437
  });
49398
- });
49399
- teamHandoffProgram.command("accept <handoffId>").description("Accept an offered handoff and transfer ownership atomically").requiredOption("--expected-revision <n>", "Current handoff revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49400
- process.exitCode = await teamHandoffAccept(process.cwd(), {
49401
- ...options,
49402
- handoffId
49438
+ teamProgram.command("reclaim <claimId>").description("Explicitly mark an expired claim terminal").requiredOption("--expected-revision <n>", "Current claim revision").requiredOption("--reason <text>", "Privacy-safe expiry reclaim reason").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49439
+ process.exitCode = await teamClaimReclaim(process.cwd(), {
49440
+ ...options,
49441
+ claimId
49442
+ });
49403
49443
  });
49404
- });
49405
- teamHandoffProgram.command("reject <handoffId>").description("Reject an offered handoff with a durable reason").requiredOption("--expected-revision <n>", "Current handoff revision").requiredOption("--reason <text>", "Reason for rejecting the handoff").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49406
- process.exitCode = await teamHandoffReject(process.cwd(), {
49407
- ...options,
49408
- handoffId
49444
+ teamProgram.command("revalidate <claimId>").description("Refresh one claim after task or code snapshot drift").requiredOption("--expected-revision <n>", "Current claim revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (claimId, options) => {
49445
+ process.exitCode = await teamClaimRevalidate(process.cwd(), {
49446
+ ...options,
49447
+ claimId
49448
+ });
49409
49449
  });
49410
- });
49411
- teamHandoffProgram.command("cancel <handoffId>").description("Cancel a draft or offered handoff").requiredOption("--expected-revision <n>", "Current handoff revision").option("--reason <text>", "Optional cancellation reason").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49412
- process.exitCode = await teamHandoffCancel(process.cwd(), {
49413
- ...options,
49414
- handoffId
49450
+ const teamHandoffProgram = teamProgram.command("handoff").description("Create and transition journaled ownership handoffs");
49451
+ teamHandoffProgram.command("draft <namespace:id>").description("Create a checkpoint-backed named handoff draft").requiredOption(
49452
+ "--expected-task-revision <n>",
49453
+ "Current shared task revision"
49454
+ ).requiredOption("--to <actorId>", "Receiving joined participant actor ID").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (task, options) => {
49455
+ process.exitCode = await teamHandoffDraft(process.cwd(), {
49456
+ ...options,
49457
+ task
49458
+ });
49415
49459
  });
49416
- });
49417
- var migrateProgram = program.command("migrate").description("Inspect and migrate legacy context into mancode staging");
49418
- var migrateContextProgram = migrateProgram.command("context").description("Manage the isolated legacy-to-mancode context migration stage").option("--dry-run", "Inspect legacy authority without writing files").option("--stage", "Create or refresh an isolated local migration stage").option("--status", "Show local migration stages").option("--activate", "Attempt the journaled mancode activation").option(
49419
- "--rollback <operationId>",
49420
- "Roll back an untouched mancode activation"
49421
- ).option("--stage-id <id>", "Migration stage ID (required if more than one)").option(
49422
- "--expected-stage-revision <n>",
49423
- "Expected stage revision for activation"
49424
- ).option("--session <id>", "Active session required for activation").option("--confirm", "Explicitly confirm the mancode cutover").option("--confirm-shared", "Confirm promotion of staged shared authority").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49425
- const code = await migrateContext(process.cwd(), options);
49426
- process.exitCode = code;
49427
- });
49428
- migrateContextProgram.command("resolve <legacyTaskId>").description("Resolve missing owner or implementation scope in one stage").requiredOption(
49429
- "--expected-stage-revision <n>",
49430
- "Expected local migration stage revision"
49431
- ).option("--stage-id <id>", "Migration stage ID (required if more than one)").option("--owner <actorId>", "Explicit owner actor ID").option(
49432
- "--scope-file <path>",
49433
- "JSON implementation scope {include,exclude,modules}"
49434
- ).option("--json", "Output as JSON (for scripts)").action(async (legacyTaskId, options) => {
49435
- const code = await migrateContextResolve(
49436
- process.cwd(),
49437
- legacyTaskId,
49438
- options
49439
- );
49440
- process.exitCode = code;
49441
- });
49442
- program.command("manps [area]").description("Run deterministic preseason health scan").option("--json", "Output as JSON (for scripts)").option("--remediate", "Review scan issues with y/n/skip prompts").action(async (area, options) => {
49443
- const code = await manps(process.cwd(), area ?? "all", options);
49444
- process.exitCode = code;
49445
- });
49446
- var designProgram = program.command("design").description("Inspect and configure project UI design policy");
49447
- designProgram.command("status").description("Show the configured and effective project design policy").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49448
- process.exitCode = await designStatus(process.cwd(), options);
49449
- });
49450
- designProgram.command("context").description("Emit bounded UI design context for coding agents").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49451
- process.exitCode = await designContext(process.cwd(), options);
49452
- });
49453
- designProgram.command("configure").description("CAS-update the optional project design policy").requiredOption(
49454
- "--expected-revision <n>",
49455
- "Current policy revision; use 0 when absent"
49456
- ).option("--preset <preset>", "preserve, refine, or experimental").option("--icons <policy>", "existing-first or lucide").option(
49457
- "--emoji <policy>",
49458
- "forbid-as-interface-icon; legacy allow is normalized"
49459
- ).option("--motion <policy>", "minimal or purposeful").option("--browser-validation <mode>", "off, when-available, or required").option("--confirm-experimental", "Explicitly allow the experimental preset").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49460
- process.exitCode = await designConfigure(process.cwd(), options);
49461
- });
49462
- designProgram.command("disable").description("Disable the project design policy without deleting it").requiredOption("--expected-revision <n>", "Current policy revision").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49463
- process.exitCode = await designDisable(process.cwd(), options);
49464
- });
49465
- program.command("refresh-style").description("Refresh project profile and rescan applicable design tokens").option("--root <path>", "Repository-relative UI project root").action(async (options) => {
49466
- const code = await refreshStyle(process.cwd(), options);
49467
- process.exitCode = code;
49468
- });
49469
- program.command("refresh-project").description(
49470
- "Refresh detected project facts after adding Git or project files"
49471
- ).action(async () => {
49472
- const code = await refreshProject(process.cwd());
49473
- process.exitCode = code;
49474
- });
49475
- program.command("version").description("Show version, node version, and platform").action(() => {
49476
- version();
49477
- });
49478
- program.parse();
49460
+ teamHandoffProgram.command("offer <handoffId>").description("Offer a handoff draft to its receiving actor").requiredOption("--expected-revision <n>", "Current handoff revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49461
+ process.exitCode = await teamHandoffOffer(process.cwd(), {
49462
+ ...options,
49463
+ handoffId
49464
+ });
49465
+ });
49466
+ teamHandoffProgram.command("accept <handoffId>").description("Accept an offered handoff and transfer ownership atomically").requiredOption("--expected-revision <n>", "Current handoff revision").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49467
+ process.exitCode = await teamHandoffAccept(process.cwd(), {
49468
+ ...options,
49469
+ handoffId
49470
+ });
49471
+ });
49472
+ teamHandoffProgram.command("reject <handoffId>").description("Reject an offered handoff with a durable reason").requiredOption("--expected-revision <n>", "Current handoff revision").requiredOption("--reason <text>", "Reason for rejecting the handoff").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49473
+ process.exitCode = await teamHandoffReject(process.cwd(), {
49474
+ ...options,
49475
+ handoffId
49476
+ });
49477
+ });
49478
+ teamHandoffProgram.command("cancel <handoffId>").description("Cancel a draft or offered handoff").requiredOption("--expected-revision <n>", "Current handoff revision").option("--reason <text>", "Optional cancellation reason").option("--session <id>", "Session ID (otherwise MANCODE_SESSION_ID)").option("--client <name>", "Client identity (default: mancode-cli)").option("--sync", "Publish through the active git-ref authority").option("--json", "Output as JSON (for scripts)").action(async (handoffId, options) => {
49479
+ process.exitCode = await teamHandoffCancel(process.cwd(), {
49480
+ ...options,
49481
+ handoffId
49482
+ });
49483
+ });
49484
+ const migrateProgram = program.command("migrate").description("Inspect and migrate legacy context into mancode staging");
49485
+ const migrateContextProgram = migrateProgram.command("context").description(
49486
+ "Manage the isolated legacy-to-mancode context migration stage"
49487
+ ).option("--dry-run", "Inspect legacy authority without writing files").option("--stage", "Create or refresh an isolated local migration stage").option("--status", "Show local migration stages").option("--activate", "Attempt the journaled mancode activation").option(
49488
+ "--rollback <operationId>",
49489
+ "Roll back an untouched mancode activation"
49490
+ ).option("--stage-id <id>", "Migration stage ID (required if more than one)").option(
49491
+ "--expected-stage-revision <n>",
49492
+ "Expected stage revision for activation"
49493
+ ).option("--session <id>", "Active session required for activation").option("--confirm", "Explicitly confirm the mancode cutover").option("--confirm-shared", "Confirm promotion of staged shared authority").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49494
+ const code = await migrateContext(process.cwd(), options);
49495
+ process.exitCode = code;
49496
+ });
49497
+ migrateContextProgram.command("resolve <legacyTaskId>").description("Resolve missing owner or implementation scope in one stage").requiredOption(
49498
+ "--expected-stage-revision <n>",
49499
+ "Expected local migration stage revision"
49500
+ ).option("--stage-id <id>", "Migration stage ID (required if more than one)").option("--owner <actorId>", "Explicit owner actor ID").option(
49501
+ "--scope-file <path>",
49502
+ "JSON implementation scope {include,exclude,modules}"
49503
+ ).option("--json", "Output as JSON (for scripts)").action(async (legacyTaskId, options) => {
49504
+ const code = await migrateContextResolve(
49505
+ process.cwd(),
49506
+ legacyTaskId,
49507
+ options
49508
+ );
49509
+ process.exitCode = code;
49510
+ });
49511
+ program.command("manps [area]").description("Run deterministic preseason health scan").option("--json", "Output as JSON (for scripts)").option("--remediate", "Review scan issues with y/n/skip prompts").action(async (area, options) => {
49512
+ const code = await manps(process.cwd(), area ?? "all", options);
49513
+ process.exitCode = code;
49514
+ });
49515
+ const designProgram = program.command("design").description("Inspect and configure project UI design policy");
49516
+ designProgram.command("status").description("Show the configured and effective project design policy").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49517
+ process.exitCode = await designStatus(process.cwd(), options);
49518
+ });
49519
+ designProgram.command("context").description("Emit bounded UI design context for coding agents").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49520
+ process.exitCode = await designContext(process.cwd(), options);
49521
+ });
49522
+ designProgram.command("configure").description("CAS-update the optional project design policy").requiredOption(
49523
+ "--expected-revision <n>",
49524
+ "Current policy revision; use 0 when absent"
49525
+ ).option("--preset <preset>", "preserve, refine, or experimental").option("--icons <policy>", "existing-first or lucide").option(
49526
+ "--emoji <policy>",
49527
+ "forbid-as-interface-icon; legacy allow is normalized"
49528
+ ).option("--motion <policy>", "minimal or purposeful").option("--browser-validation <mode>", "off, when-available, or required").option(
49529
+ "--confirm-experimental",
49530
+ "Explicitly allow the experimental preset"
49531
+ ).option("--json", "Output as JSON (for scripts)").action(async (options) => {
49532
+ process.exitCode = await designConfigure(process.cwd(), options);
49533
+ });
49534
+ designProgram.command("disable").description("Disable the project design policy without deleting it").requiredOption("--expected-revision <n>", "Current policy revision").option("--json", "Output as JSON (for scripts)").action(async (options) => {
49535
+ process.exitCode = await designDisable(process.cwd(), options);
49536
+ });
49537
+ program.command("refresh-style").description("Refresh project profile and rescan applicable design tokens").option("--root <path>", "Repository-relative UI project root").action(async (options) => {
49538
+ const code = await refreshStyle(process.cwd(), options);
49539
+ process.exitCode = code;
49540
+ });
49541
+ program.command("refresh-project").description(
49542
+ "Refresh detected project facts after adding Git or project files"
49543
+ ).action(async () => {
49544
+ const code = await refreshProject(process.cwd());
49545
+ process.exitCode = code;
49546
+ });
49547
+ program.command("version").description("Show version, node version, and platform").action(() => {
49548
+ version();
49549
+ });
49550
+ return program;
49551
+ }
49552
+ if (isDirectExecution()) {
49553
+ createCliProgram().parse();
49554
+ }
49555
+ function isDirectExecution() {
49556
+ const entrypoint = process.argv[1];
49557
+ if (entrypoint === void 0) return false;
49558
+ try {
49559
+ return realpathSync(entrypoint) === realpathSync(fileURLToPath(import.meta.url));
49560
+ } catch {
49561
+ return false;
49562
+ }
49563
+ }
49479
49564
  function collectOption(value, previous) {
49480
49565
  return [...previous, value];
49481
49566
  }
49482
49567
  export {
49483
- program as cliProgram
49568
+ createCliProgram
49484
49569
  };
49485
49570
  //# sourceMappingURL=cli.js.map