@cleocode/cleo 2026.4.125 → 2026.4.127

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/index.js CHANGED
@@ -744,13 +744,6 @@ var init_operations = __esm({
744
744
  }
745
745
  });
746
746
 
747
- // packages/contracts/src/orchestration-hierarchy.ts
748
- var init_orchestration_hierarchy = __esm({
749
- "packages/contracts/src/orchestration-hierarchy.ts"() {
750
- "use strict";
751
- }
752
- });
753
-
754
747
  // packages/contracts/src/peer.ts
755
748
  var init_peer = __esm({
756
749
  "packages/contracts/src/peer.ts"() {
@@ -867,7 +860,6 @@ var init_src = __esm({
867
860
  init_lafs();
868
861
  init_operations();
869
862
  init_params();
870
- init_orchestration_hierarchy();
871
863
  init_peer();
872
864
  init_session2();
873
865
  init_status_registry();
@@ -4644,6 +4636,25 @@ var init_registry = __esm({
4644
4636
  requiredParams: [],
4645
4637
  params: []
4646
4638
  },
4639
+ // T1262 — memory-doctor read-only noise detector (E1-parallel per council verdict)
4640
+ {
4641
+ gateway: "query",
4642
+ domain: "memory",
4643
+ operation: "doctor",
4644
+ description: "memory.doctor (query) \u2014 read-only brain noise scan: detects duplicate-content, missing-type, missing-provenance, orphan-edge, low-confidence, stale-unverified patterns. Used as M7 assert-clean gate for Sentient v1 activation.",
4645
+ tier: 0,
4646
+ idempotent: true,
4647
+ sessionRequired: false,
4648
+ requiredParams: [],
4649
+ params: [
4650
+ {
4651
+ name: "assert-clean",
4652
+ type: "boolean",
4653
+ required: false,
4654
+ description: "If true, exit non-zero when any noise patterns are detected (M7 gate for Sentient v1)."
4655
+ }
4656
+ ]
4657
+ },
4647
4658
  // T791 — LLM extraction backend status
4648
4659
  {
4649
4660
  gateway: "query",
@@ -4840,12 +4851,13 @@ var init_registry = __esm({
4840
4851
  { name: "agent", type: "string", required: false, description: "Agent provenance" }
4841
4852
  ]
4842
4853
  },
4843
- // T792 — promote entry to verified=true (owner/cleo-prime only)
4854
+ // T792 — promote entry to verified=true (project-orchestrator or owner only)
4855
+ // T1258 E1 migration shim: 'cleo-prime' accepted as legacy alias for 'project-orchestrator'
4844
4856
  {
4845
4857
  gateway: "mutate",
4846
4858
  domain: "memory",
4847
4859
  operation: "verify",
4848
- description: "memory.verify (mutate) \u2014 flip verified=1 on a brain entry; requires cleo-prime or owner identity",
4860
+ description: "memory.verify (mutate) \u2014 flip verified=1 on a brain entry; requires project-orchestrator or owner identity",
4849
4861
  tier: 1,
4850
4862
  idempotent: true,
4851
4863
  sessionRequired: false,
@@ -4856,7 +4868,7 @@ var init_registry = __esm({
4856
4868
  name: "agent",
4857
4869
  type: "string",
4858
4870
  required: false,
4859
- description: "Caller identity ('cleo-prime' or 'owner'). Omit for terminal invocation."
4871
+ description: "Caller identity ('project-orchestrator' or 'owner'). Legacy alias 'cleo-prime' accepted per T1258 E1 migration shim. Omit for terminal invocation."
4860
4872
  }
4861
4873
  ]
4862
4874
  },
@@ -18430,6 +18442,29 @@ var init_memory2 = __esm({
18430
18442
  startTime
18431
18443
  );
18432
18444
  }
18445
+ // T1262 — brain noise detector (read-only, E1-parallel per council verdict)
18446
+ case "doctor": {
18447
+ const { scanBrainNoise } = await import("@cleocode/core/memory/brain-doctor.js");
18448
+ const result = await scanBrainNoise(projectRoot);
18449
+ const assertClean = params?.["assert-clean"];
18450
+ if (assertClean && !result.isClean) {
18451
+ return errorResult(
18452
+ "query",
18453
+ "memory",
18454
+ operation,
18455
+ "E_BRAIN_NOISE_DETECTED",
18456
+ `Brain noise detected: ${result.findings.length} pattern(s) across ${result.totalScanned} entries. ` + result.findings.map((f) => `${f.pattern}(${f.count})`).join(", ") + ". Run `cleo memory doctor` for details. Fix noise before enabling Sentient v1 (M7 gate).",
18457
+ startTime
18458
+ );
18459
+ }
18460
+ return wrapResult(
18461
+ { success: true, data: result },
18462
+ "query",
18463
+ "memory",
18464
+ operation,
18465
+ startTime
18466
+ );
18467
+ }
18433
18468
  // T791 — LLM extraction backend status
18434
18469
  case "llm-status": {
18435
18470
  const resolvedSource = resolveAnthropicApiKeySource();
@@ -19264,14 +19299,20 @@ var init_memory2 = __esm({
19264
19299
  startTime
19265
19300
  );
19266
19301
  }
19302
+ const VERIFY_PERMITTED_IDENTITIES = /* @__PURE__ */ new Set([
19303
+ "owner",
19304
+ "project-orchestrator",
19305
+ "cleo-prime"
19306
+ // legacy alias — see migration shim note above
19307
+ ]);
19267
19308
  const callerAgent = params?.agent;
19268
- if (callerAgent && callerAgent !== "cleo-prime" && callerAgent !== "owner") {
19309
+ if (callerAgent && !VERIFY_PERMITTED_IDENTITIES.has(callerAgent)) {
19269
19310
  return errorResult(
19270
19311
  "mutate",
19271
19312
  "memory",
19272
19313
  operation,
19273
19314
  "E_FORBIDDEN",
19274
- `verify requires agent identity 'cleo-prime' or 'owner'; got '${callerAgent}'`,
19315
+ `verify requires agent identity 'project-orchestrator' or 'owner'; got '${callerAgent}'`,
19275
19316
  startTime
19276
19317
  );
19277
19318
  }
@@ -19522,6 +19563,8 @@ var init_memory2 = __esm({
19522
19563
  "code.links",
19523
19564
  "code.memories-for-code",
19524
19565
  "code.for-memory",
19566
+ // T1262 — brain noise detector (E1-parallel, read-only)
19567
+ "doctor",
19525
19568
  // T791 — LLM extraction backend status
19526
19569
  "llm-status",
19527
19570
  // T792 — pending verification queue
@@ -33523,7 +33566,7 @@ agent ${agentId}:
33523
33566
  house: none
33524
33567
  allegiance: canon
33525
33568
  role: ${role}
33526
- parent: cleoos-opus-orchestrator
33569
+ parent: project-orchestrator
33527
33570
  description: "${displayName}"
33528
33571
 
33529
33572
  tone:
@@ -35654,6 +35697,126 @@ var createCommand = defineCommand({
35654
35697
  }
35655
35698
  }
35656
35699
  });
35700
+ var mintCommand = defineCommand({
35701
+ meta: {
35702
+ name: "mint",
35703
+ description: "Synthesize a project-specific agent from a .cant spec using agent-architect meta-agent"
35704
+ },
35705
+ args: {
35706
+ spec: {
35707
+ type: "positional",
35708
+ description: "Path to the .cant spec file describing the agent to synthesize",
35709
+ required: true
35710
+ },
35711
+ "output-dir": {
35712
+ type: "string",
35713
+ description: "Directory to write synthesized .cant files (defaults to .cleo/cant/agents/)"
35714
+ },
35715
+ "dry-run": {
35716
+ type: "boolean",
35717
+ description: "Preview invocation tokens without invoking agent-architect",
35718
+ default: false
35719
+ },
35720
+ json: {
35721
+ type: "boolean",
35722
+ description: "Emit result as LAFS JSON envelope",
35723
+ default: false
35724
+ }
35725
+ },
35726
+ async run({ args }) {
35727
+ try {
35728
+ const { existsSync: existsSync12, readFileSync: readFileSync15, mkdirSync: mkdirSync4 } = await import("node:fs");
35729
+ const { resolve: resolve5, join: join22 } = await import("node:path");
35730
+ const specPath = resolve5(args.spec);
35731
+ if (!existsSync12(specPath)) {
35732
+ const errEnv = {
35733
+ success: false,
35734
+ error: { code: "E_NOT_FOUND", message: `spec file not found: ${specPath}` },
35735
+ meta: { operation: "agent.mint", timestamp: (/* @__PURE__ */ new Date()).toISOString() }
35736
+ };
35737
+ if (args.json) {
35738
+ process.stdout.write(JSON.stringify(errEnv, null, 2) + "\n");
35739
+ } else {
35740
+ process.stderr.write(`error: spec file not found: ${specPath}
35741
+ `);
35742
+ }
35743
+ process.exitCode = 4;
35744
+ return;
35745
+ }
35746
+ const specContent = readFileSync15(specPath, "utf-8");
35747
+ const projectRoot = process.cwd();
35748
+ const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join22(projectRoot, ".cleo", "cant", "agents");
35749
+ mkdirSync4(outputDir, { recursive: true });
35750
+ if (args["dry-run"]) {
35751
+ const preview = {
35752
+ success: true,
35753
+ data: {
35754
+ dryRun: true,
35755
+ agentName: "agent-architect",
35756
+ specPath,
35757
+ outputDir,
35758
+ projectRoot,
35759
+ message: "Dry-run: would invoke agent-architect with the above tokens"
35760
+ },
35761
+ meta: { operation: "agent.mint", timestamp: (/* @__PURE__ */ new Date()).toISOString() }
35762
+ };
35763
+ process.stdout.write(JSON.stringify(preview, null, 2) + "\n");
35764
+ return;
35765
+ }
35766
+ const { invokeMetaAgent } = await import("@cleocode/core/agents/invoke-meta-agent");
35767
+ const result = await invokeMetaAgent({
35768
+ agentName: "agent-architect",
35769
+ projectRoot,
35770
+ tokens: {
35771
+ CANT_AGENTS_DIR: outputDir,
35772
+ // Pass spec content as PROJECT_CONTEXT to let agent-architect read it
35773
+ PROJECT_CONTEXT: specContent
35774
+ }
35775
+ });
35776
+ if (result.invoked) {
35777
+ const envelope = {
35778
+ success: true,
35779
+ data: {
35780
+ invoked: true,
35781
+ outputs: result.outputs ?? [],
35782
+ outputDir,
35783
+ message: `agent-architect synthesized ${result.outputs?.length ?? 0} agent(s)`
35784
+ },
35785
+ meta: { operation: "agent.mint", timestamp: (/* @__PURE__ */ new Date()).toISOString() }
35786
+ };
35787
+ if (args.json) {
35788
+ process.stdout.write(JSON.stringify(envelope, null, 2) + "\n");
35789
+ } else {
35790
+ process.stdout.write(`minted ${result.outputs?.length ?? 0} agent(s) to ${outputDir}
35791
+ `);
35792
+ for (const out of result.outputs ?? []) {
35793
+ process.stdout.write(` + ${out}
35794
+ `);
35795
+ }
35796
+ }
35797
+ } else {
35798
+ const fallbackMsg = `agent-architect unavailable: ${result.reason ?? "unknown"}. Run 'cleo agent create' for static scaffolding.`;
35799
+ const envelope = {
35800
+ success: false,
35801
+ error: { code: "E_META_AGENT_UNAVAILABLE", message: fallbackMsg },
35802
+ meta: { operation: "agent.mint", timestamp: (/* @__PURE__ */ new Date()).toISOString() }
35803
+ };
35804
+ if (args.json) {
35805
+ process.stdout.write(JSON.stringify(envelope, null, 2) + "\n");
35806
+ } else {
35807
+ process.stderr.write(`warn: ${fallbackMsg}
35808
+ `);
35809
+ }
35810
+ process.exitCode = 1;
35811
+ }
35812
+ } catch (err) {
35813
+ const message = err instanceof Error ? err.message : String(err);
35814
+ process.stderr.write(`error: agent mint failed: ${message}
35815
+ `);
35816
+ process.exitCode = 1;
35817
+ }
35818
+ }
35819
+ });
35657
35820
  var doctorCommand = defineCommand({
35658
35821
  meta: {
35659
35822
  name: "doctor",
@@ -35790,7 +35953,8 @@ var agentCommand = defineCommand({
35790
35953
  health: healthCommand3,
35791
35954
  install: installCommand,
35792
35955
  pack: packCommand,
35793
- create: createCommand
35956
+ create: createCommand,
35957
+ mint: mintCommand
35794
35958
  },
35795
35959
  async run({ cmd, rawArgs }) {
35796
35960
  const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
@@ -45267,6 +45431,31 @@ var importCommand3 = defineCommand({
45267
45431
  if (stats.errors > 0) process.exit(1);
45268
45432
  }
45269
45433
  });
45434
+ var doctorCommand3 = defineCommand({
45435
+ meta: {
45436
+ name: "doctor",
45437
+ description: "Read-only brain noise scan: detects duplicate-content, missing-type, missing-provenance, orphan-edge, low-confidence, and stale-unverified patterns. Use --assert-clean as the M7 entry gate before enabling Sentient v1 (`cleo sentient propose enable`)."
45438
+ },
45439
+ args: {
45440
+ "assert-clean": {
45441
+ type: "boolean",
45442
+ description: "Exit non-zero when any noise patterns are detected (M7 gate for Sentient v1)"
45443
+ },
45444
+ json: {
45445
+ type: "boolean",
45446
+ description: "Output as JSON"
45447
+ }
45448
+ },
45449
+ async run({ args }) {
45450
+ await dispatchFromCli(
45451
+ "query",
45452
+ "memory",
45453
+ "doctor",
45454
+ { "assert-clean": args["assert-clean"] },
45455
+ { command: "memory-doctor", operation: "memory.doctor" }
45456
+ );
45457
+ }
45458
+ });
45270
45459
  var llmStatusCommand = defineCommand({
45271
45460
  meta: {
45272
45461
  name: "llm-status",
@@ -46125,6 +46314,7 @@ var memoryCommand = defineCommand({
46125
46314
  reflect: reflectCommand,
46126
46315
  "dedup-scan": dedupScanCommand,
46127
46316
  import: importCommand3,
46317
+ doctor: doctorCommand3,
46128
46318
  "llm-status": llmStatusCommand,
46129
46319
  verify: verifyCommand,
46130
46320
  "pending-verify": pendingVerifyCommand,
@@ -52167,6 +52357,51 @@ var resumeCommand = defineCommand({
52167
52357
  );
52168
52358
  }
52169
52359
  });
52360
+ var createCommand2 = defineCommand({
52361
+ meta: {
52362
+ name: "create",
52363
+ description: "Scaffold a new .cantbook playbook (invokes playbook-architect meta-agent)"
52364
+ },
52365
+ args: {
52366
+ name: {
52367
+ type: "positional",
52368
+ description: 'Playbook name (kebab-case, e.g. "feature-ship")',
52369
+ required: true
52370
+ },
52371
+ description: {
52372
+ type: "string",
52373
+ description: "Plain-text description of what the playbook should do"
52374
+ },
52375
+ stages: {
52376
+ type: "string",
52377
+ description: "Comma-separated list of stage names to scaffold (auto-inferred if omitted)"
52378
+ },
52379
+ "output-dir": {
52380
+ type: "string",
52381
+ description: "Output directory for the .cantbook file (defaults to .cleo/cant/playbooks/)"
52382
+ },
52383
+ "dry-run": {
52384
+ type: "boolean",
52385
+ description: "Preview what would be created without writing files",
52386
+ default: false
52387
+ }
52388
+ },
52389
+ async run({ args }) {
52390
+ await dispatchFromCli(
52391
+ "mutate",
52392
+ "playbook",
52393
+ "create",
52394
+ {
52395
+ name: args.name,
52396
+ description: args.description,
52397
+ stages: args.stages,
52398
+ outputDir: args["output-dir"],
52399
+ dryRun: args["dry-run"]
52400
+ },
52401
+ { command: "playbook" }
52402
+ );
52403
+ }
52404
+ });
52170
52405
  var listCommand13 = defineCommand({
52171
52406
  meta: {
52172
52407
  name: "list",
@@ -52208,13 +52443,14 @@ var listCommand13 = defineCommand({
52208
52443
  var playbookCommand = defineCommand({
52209
52444
  meta: {
52210
52445
  name: "playbook",
52211
- description: "Playbook runtime operations (run, status, resume, list)"
52446
+ description: "Playbook runtime operations (run, status, resume, list, create)"
52212
52447
  },
52213
52448
  subCommands: {
52214
52449
  run: runCommand3,
52215
52450
  status: statusCommand10,
52216
52451
  resume: resumeCommand,
52217
- list: listCommand13
52452
+ list: listCommand13,
52453
+ create: createCommand2
52218
52454
  },
52219
52455
  async run({ cmd, rawArgs }) {
52220
52456
  const firstArg = rawArgs?.find((a) => !a.startsWith("-"));