@event4u/agent-config 9.28.0 → 9.30.0

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.
Files changed (209) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/AGENTS.md +6 -6
  3. package/CHANGELOG.md +172 -5
  4. package/README.md +2 -1
  5. package/agents/templates/.ai-council.yml.example +55 -24
  6. package/dist/agent-src/commands/analyze/inbox.md +22 -1
  7. package/dist/agent-src/commands/cost/report.md +2 -2
  8. package/dist/agent-src/commands/explain-run.md +31 -1
  9. package/dist/agent-src/commands/team/adversarial.md +8 -7
  10. package/dist/agent-src/commands/team/delegate.md +14 -12
  11. package/dist/agent-src/commands/team/review.md +9 -8
  12. package/dist/agent-src/commands/team/status.md +9 -8
  13. package/dist/agent-src/commands/team.md +29 -19
  14. package/dist/agent-src/contexts/execution/auto-dispatch-classification.md +88 -2
  15. package/dist/agent-src/contexts/execution/auto-orchestration-activation.md +29 -21
  16. package/dist/agent-src/contexts/execution/host-capability-manifest.md +26 -15
  17. package/dist/agent-src/contexts/execution/orchestration-telemetry.md +22 -1
  18. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +17 -0
  19. package/dist/agent-src/contexts/execution/subagent-response-contract.md +65 -1
  20. package/dist/agent-src/contexts/execution/subagent-routing.md +13 -11
  21. package/dist/agent-src/contexts/execution/subagent-spawn-contract.md +25 -0
  22. package/dist/agent-src/contexts/execution/subagent-steering.md +6 -3
  23. package/dist/agent-src/rules/delegation-policy.md +11 -7
  24. package/dist/agent-src/rules/preservation-guard.md +9 -0
  25. package/dist/agent-src/rules/settings-ask-protocol.md +8 -7
  26. package/dist/agent-src/rules/token-budget-discipline.md +1 -1
  27. package/dist/agent-src/scripts/roadmap_gates.ts +312 -0
  28. package/dist/agent-src/scripts/update_roadmap_progress.ts +72 -4
  29. package/dist/agent-src/skills/forensics-report/SKILL.md +114 -0
  30. package/dist/agent-src/skills/forensics-report/evals/triggers.json +17 -0
  31. package/dist/agent-src/skills/premortem/SKILL.md +30 -1
  32. package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +2 -1
  33. package/dist/agent-src/skills/subagent-orchestration/SKILL.md +17 -5
  34. package/dist/agent-src/skills/subagent-orchestration/schemas/subagent-status.json +61 -3
  35. package/dist/agent-src/skills/test-case-discovery/SKILL.md +1 -1
  36. package/dist/agent-src/templates/AGENTS.md +4 -4
  37. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  38. package/dist/agent-src/templates/roadmaps.md +23 -0
  39. package/dist/cli/registry.js +2 -0
  40. package/dist/cli/registry.js.map +1 -1
  41. package/dist/cli-delegate/{chunk-22GCIJ2O.js → chunk-66OVWGB5.js} +1 -1
  42. package/dist/cli-delegate/{chunk-7OMQCH4V.js → chunk-BTJNRUX3.js} +22 -35
  43. package/dist/cli-delegate/{chunk-DVRS2KVR.js → chunk-DDUNNFYX.js} +24 -17
  44. package/dist/cli-delegate/{chunk-PQSAQKHW.js → chunk-EQY4FLJB.js} +3 -3
  45. package/dist/cli-delegate/{chunk-2BE5I2MN.js → chunk-IYTGIG2Y.js} +155 -91
  46. package/dist/cli-delegate/{chunk-GB2FSUEE.js → chunk-LCFJIQ4J.js} +32 -0
  47. package/dist/cli-delegate/{chunk-VSYT7OHO.js → chunk-LVRYBKTI.js} +31 -2
  48. package/dist/cli-delegate/chunk-MMJL4TIX.js +18 -0
  49. package/dist/cli-delegate/{chunk-JXARCGVN.js → chunk-MP3JT3IU.js} +1 -1
  50. package/dist/cli-delegate/chunk-O3CO5BFB.js +161 -0
  51. package/dist/cli-delegate/{chunk-REKCMYOU.js → chunk-PFBV6XRT.js} +36 -20
  52. package/dist/cli-delegate/chunk-RVGBH4XK.js +142 -0
  53. package/dist/cli-delegate/cmd_analyze_session.js +1 -1
  54. package/dist/cli-delegate/cmd_brand_status.js +1 -1
  55. package/dist/cli-delegate/cmd_conformance.js +2803 -137
  56. package/dist/cli-delegate/cmd_doctor.js +10 -5
  57. package/dist/cli-delegate/cmd_explain.js +2 -2
  58. package/dist/cli-delegate/cmd_export.js +4 -4
  59. package/dist/cli-delegate/cmd_handoff.js +88 -8
  60. package/dist/cli-delegate/cmd_mcp_available.js +1 -1
  61. package/dist/cli-delegate/cmd_migrate.js +2 -2
  62. package/dist/cli-delegate/cmd_packs_active.js +2 -2
  63. package/dist/cli-delegate/cmd_prune.js +4 -4
  64. package/dist/cli-delegate/cmd_route_audit.js +3 -2
  65. package/dist/cli-delegate/cmd_route_explain.js +1 -1
  66. package/dist/cli-delegate/cmd_session_recycle.js +177 -0
  67. package/dist/cli-delegate/cmd_settings_get.js +2 -8
  68. package/dist/cli-delegate/cmd_settings_migrate.js +4 -4
  69. package/dist/cli-delegate/cmd_settings_set.js +2 -2
  70. package/dist/cli-delegate/cmd_sync.js +4 -4
  71. package/dist/cli-delegate/cmd_uninstall.js +4 -4
  72. package/dist/cli-delegate/cmd_update.js +1 -1
  73. package/dist/cli-delegate/cmd_upgrade.js +1 -1
  74. package/dist/cli-delegate/cmd_validate.js +4 -4
  75. package/dist/cli-delegate/cmd_versions.js +1 -1
  76. package/dist/discovery/deprecation-report.md +1 -1
  77. package/dist/discovery/discovery-manifest.json +72 -23
  78. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  79. package/dist/discovery/discovery-manifest.summary.md +3 -2
  80. package/dist/discovery/orphan-report.md +1 -1
  81. package/dist/discovery/packs.json +39 -2
  82. package/dist/discovery/trust-report.md +2 -2
  83. package/dist/discovery/workspaces.json +12 -4
  84. package/dist/hooks/dispatch.js +2278 -611
  85. package/dist/install/install.mjs +56 -17
  86. package/dist/mcp/registry-manifest.json +3 -3
  87. package/dist/mcp/server.json +2 -2
  88. package/dist/mcp/server.mjs +4122 -699
  89. package/dist/router.json +1 -1
  90. package/dist/scripts/_lib/agent_settings.js +54 -0
  91. package/dist/scripts/_lib/agent_settings.js.map +1 -1
  92. package/dist/scripts/condense.js +147 -2
  93. package/dist/scripts/condense.js.map +1 -1
  94. package/dist/server/schemas/settings.js +12 -7
  95. package/dist/server/schemas/settings.js.map +1 -1
  96. package/dist/shared/settingsCarveOut.js +0 -9
  97. package/dist/shared/settingsCarveOut.js.map +1 -1
  98. package/dist/shared/settingsClasses.js +11 -9
  99. package/dist/shared/settingsClasses.js.map +1 -1
  100. package/dist/ui/assets/index-B5qGYOJo.js +26 -0
  101. package/dist/ui/assets/index-B5qGYOJo.js.map +1 -0
  102. package/dist/ui/index.html +1 -1
  103. package/docs/contracts/settings-classes.md +58 -12
  104. package/package.json +1 -1
  105. package/src/agent-src/scripts/roadmap_gates.ts +312 -0
  106. package/src/agent-src/scripts/update_roadmap_progress.ts +72 -4
  107. package/src/agent-src/templates/AGENTS.md +4 -4
  108. package/src/config/agent-settings.template.yml +88 -66
  109. package/src/config/discovery/packs.yml +11 -0
  110. package/src/config/discovery/workspaces.yml +1 -1
  111. package/src/config/dispatch-economy-metrics.json +61 -0
  112. package/src/config/evaluator-budgets.json +4 -4
  113. package/src/config/gate-violation-baselines.json +3 -3
  114. package/src/config/hook-token-budget.json +91 -0
  115. package/src/config/recycle-threshold-budget.json +12 -0
  116. package/src/config/rule-enforcement-baseline.json +86 -0
  117. package/src/scripts/_cli/cmd_conformance.ts +31 -44
  118. package/src/scripts/_cli/cmd_doctor.ts +65 -48
  119. package/src/scripts/_cli/cmd_session_recycle.ts +226 -0
  120. package/src/scripts/_dispatch.bash +23 -0
  121. package/src/scripts/_lib/agent_settings.ts +58 -0
  122. package/src/scripts/_lib/auto_dispatch.corpus.test.ts +1 -1
  123. package/src/scripts/_lib/auto_dispatch.ts +23 -18
  124. package/src/scripts/_lib/capsule_trigger.ts +124 -0
  125. package/src/scripts/_lib/host_capability.ts +63 -6
  126. package/src/scripts/_lib/judgment_ladder.ts +634 -0
  127. package/src/scripts/_lib/orchestration_gate.ts +8 -0
  128. package/src/scripts/_lib/orchestration_record.ts +78 -10
  129. package/src/scripts/_lib/orchestration_savings.ts +1 -1
  130. package/src/scripts/_lib/recycle_envelope_paths.ts +35 -0
  131. package/src/scripts/_lib/self_repair.ts +354 -13
  132. package/src/scripts/_lib/self_repair_store.ts +28 -0
  133. package/src/scripts/_lib/session_eol.ts +230 -0
  134. package/src/scripts/_lib/session_role.ts +42 -0
  135. package/src/scripts/_lib/subagent_capsule.ts +341 -0
  136. package/src/scripts/_lib/subagent_response.ts +94 -0
  137. package/src/scripts/_lib/subagent_spawn.ts +13 -0
  138. package/src/scripts/_lib/subagent_steering.ts +9 -4
  139. package/src/scripts/_lib/tier_budget_routing.ts +6 -1
  140. package/src/scripts/_lib/worker_budget.ts +37 -2
  141. package/src/scripts/ai_council/clients.ts +126 -55
  142. package/src/scripts/ai_council/config.ts +94 -6
  143. package/src/scripts/ai_council/handoff.ts +113 -0
  144. package/src/scripts/ai_council/modes.ts +19 -4
  145. package/src/scripts/ai_council/orchestrator.ts +105 -0
  146. package/src/scripts/ai_council/quorum.ts +84 -0
  147. package/src/scripts/ai_council/session.ts +44 -0
  148. package/src/scripts/ai_council/transport_resolver.ts +127 -1
  149. package/src/scripts/ai_team/availability.ts +110 -0
  150. package/src/scripts/ai_team/config.ts +34 -14
  151. package/src/scripts/ai_team/team_dispatch.ts +71 -29
  152. package/src/scripts/ask_transport.ts +221 -0
  153. package/src/scripts/bench_critic_protocol.ts +396 -0
  154. package/src/scripts/bench_hook_injection.ts +234 -0
  155. package/src/scripts/check_adr_frontmatter.ts +84 -40
  156. package/src/scripts/check_branch_freshness.ts +1 -0
  157. package/src/scripts/check_corpus_staleness.ts +18 -4
  158. package/src/scripts/check_detector_corpus.ts +219 -0
  159. package/src/scripts/check_gitignore_freshness.ts +42 -8
  160. package/src/scripts/check_hook_bundle_freshness.ts +24 -1
  161. package/src/scripts/check_kernel_prefix_stability.ts +1 -0
  162. package/src/scripts/check_standing_rule_delivery.ts +73 -32
  163. package/src/scripts/check_static_layer_stability.ts +154 -0
  164. package/src/scripts/check_suppression_hygiene.ts +48 -0
  165. package/src/scripts/condense.ts +162 -2
  166. package/src/scripts/council_cli.ts +401 -25
  167. package/src/scripts/dispatch_economy_report.ts +448 -0
  168. package/src/scripts/dispatch_r2_reviewer.ts +15 -2
  169. package/src/scripts/explain_run.ts +206 -4
  170. package/src/scripts/forensics_report.ts +333 -0
  171. package/src/scripts/generate_settings_reference.ts +1 -0
  172. package/src/scripts/handoff_context_hook.ts +112 -4
  173. package/src/scripts/hook_manifest.yaml +117 -10
  174. package/src/scripts/hooks/concern_registry.ts +8 -0
  175. package/src/scripts/hooks/delegation_nudge_hook.ts +106 -35
  176. package/src/scripts/hooks/dispatch_hook.ts +39 -2
  177. package/src/scripts/hooks/edit_shape_hook.ts +303 -0
  178. package/src/scripts/hooks/orchestration_record_hook.ts +19 -1
  179. package/src/scripts/hooks/reread_guard_hook.ts +314 -0
  180. package/src/scripts/hooks/rtk_wrap_hook.ts +133 -14
  181. package/src/scripts/hooks/session_eol_hook.ts +268 -0
  182. package/src/scripts/hooks/turn_end_gate_hook.ts +507 -0
  183. package/src/scripts/install-hooks.sh +1 -1
  184. package/src/scripts/language_mirror_hook.ts +89 -0
  185. package/src/scripts/lint_decision_impact.ts +14 -1
  186. package/src/scripts/lint_discovery_vocabulary.ts +2 -0
  187. package/src/scripts/lint_hook_manifest.ts +82 -0
  188. package/src/scripts/lint_never_silent.ts +276 -0
  189. package/src/scripts/lint_no_activation_gates.ts +271 -0
  190. package/src/scripts/lint_readme_serial_comma.ts +1 -0
  191. package/src/scripts/lint_rule_enforcement_declaration.ts +347 -0
  192. package/src/scripts/measure_turn_end_gate.ts +194 -0
  193. package/src/scripts/orchestration_record.ts +12 -1
  194. package/src/scripts/rebuild_hook_bundle.ts +178 -0
  195. package/src/scripts/release.ts +74 -2
  196. package/src/scripts/report_conformance_funnel.ts +284 -0
  197. package/src/scripts/report_imperative_density.ts +1 -0
  198. package/src/scripts/routing_doctor.ts +118 -36
  199. package/src/scripts/score_skill_selection.ts +19 -5
  200. package/src/scripts/self_repair_cli.ts +337 -59
  201. package/src/scripts/session_eol_report.ts +261 -0
  202. package/src/scripts/team_events_spike.ts +271 -0
  203. package/src/scripts/team_review_gate_hook.ts +31 -9
  204. package/src/server/schemas/settings.ts +24 -17
  205. package/src/shared/settingsCarveOut.ts +0 -10
  206. package/src/shared/settingsClasses.ts +11 -9
  207. package/src/templates/compact-instructions.md +40 -0
  208. package/dist/ui/assets/index-DmR0mbk4.js +0 -26
  209. package/dist/ui/assets/index-DmR0mbk4.js.map +0 -1
@@ -10,7 +10,9 @@
10
10
  * (b) router-pointers — dist/router.json ids + routes_to resolve on disk
11
11
  * (c) hook-dispatcher — dispatcher answers synthetic session_start/stop
12
12
  * (d) lean-projection — lean_projection.mode matches projected artifacts
13
- * (e) host-manifest — subagents.host_capabilities parses strictly
13
+ * (e) host-manifest — a leftover subagents.host_capabilities override
14
+ * is deprecated + ignored (always-on orchestration
15
+ * resolves capability from a probe/registry only)
14
16
  *
15
17
  * All checks are deterministic — no LLM, no network. Exit contract:
16
18
  * 0 = every check ok/skipped (warns allowed) and doctor --ci green
@@ -39,6 +41,7 @@ import { readRecentEntries } from '../../install/txlog.js';
39
41
  import { detectToolPresence } from '../../install/detect.js';
40
42
  import { resolvePackageRoot } from '../_lib/package_root.js';
41
43
  import { routeTargetPathsPosix } from '../router_target_paths.mjs';
44
+ import { buildFunnel, render as renderFunnel } from '../report_conformance_funnel.js';
42
45
  import {
43
46
  _classify,
44
47
  _collect_manifest_entries,
@@ -421,14 +424,6 @@ export function _check_lean_projection(
421
424
  // Check (e) — host-capability manifest parses strictly + matches detection.
422
425
  // ---------------------------------------------------------------------------
423
426
 
424
- const HOST_MANIFEST_KEYS = new Set([
425
- 'schema_version',
426
- 'subagent_spawn',
427
- 'parallel_spawn',
428
- 'status_polling',
429
- 'separate_quota_pool',
430
- ]);
431
-
432
427
  export function _check_host_manifest(projectRoot: string): Dict {
433
428
  const detected = Object.entries(detectToolPresence(projectRoot))
434
429
  .filter(([, v]) => v === true)
@@ -441,7 +436,7 @@ export function _check_host_manifest(projectRoot: string): Dict {
441
436
  return {
442
437
  id: 'host-manifest',
443
438
  status: 'ok',
444
- message: `no .agent-settings.yml — safe-default manifest applies (${detectedNote})`,
439
+ message: `no .agent-settings.yml — host capability is always probe/registry-resolved (${detectedNote})`,
445
440
  remedy: '',
446
441
  };
447
442
  }
@@ -462,44 +457,22 @@ export function _check_host_manifest(projectRoot: string): Dict {
462
457
  return {
463
458
  id: 'host-manifest',
464
459
  status: 'ok',
465
- message: `no host_capabilities override — safe-default manifest applies (${detectedNote})`,
460
+ message: `no host_capabilities override — host capability is always probe/registry-resolved (${detectedNote})`,
466
461
  remedy: '',
467
462
  };
468
463
  }
469
- if (typeof manifest !== 'object' || Array.isArray(manifest)) {
470
- return {
471
- id: 'host-manifest',
472
- status: 'fail',
473
- message: 'subagents.host_capabilities is not a mapping',
474
- remedy: 'use the four boolean fields from the host-capability manifest contract',
475
- };
476
- }
477
- const problems: string[] = [];
478
- for (const [key, value] of Object.entries(manifest as Dict)) {
479
- if (!HOST_MANIFEST_KEYS.has(key)) {
480
- problems.push(`unknown key '${key}'`);
481
- continue;
482
- }
483
- if (key === 'schema_version') {
484
- if (value !== 1) problems.push(`schema_version must be 1 (got ${JSON.stringify(value)})`);
485
- continue;
486
- }
487
- if (typeof value !== 'boolean') {
488
- problems.push(`'${key}' must be boolean (got ${JSON.stringify(value)})`);
489
- }
490
- }
491
- if (problems.length > 0) {
492
- return {
493
- id: 'host-manifest',
494
- status: 'fail',
495
- message: `host_capabilities malformed: ${problems.slice(0, 4).join('; ')}`,
496
- remedy: 'only schema_version:1 + four boolean capability fields are valid',
497
- };
498
- }
464
+ // Always-on orchestration (road-to-always-on-orchestration Phase 1)
465
+ // deleted `subagents.host_capabilities` as a live override — capability
466
+ // now resolves ONLY from the host probe/registry. A leftover key is
467
+ // therefore inert: its shape no longer matters, so this no longer fails
468
+ // on an unknown key or a non-boolean value — there is nothing left for a
469
+ // malformed override to break.
499
470
  return {
500
471
  id: 'host-manifest',
501
472
  status: 'ok',
502
- message: `host_capabilities override parses strictly (${detectedNote})`,
473
+ message:
474
+ `subagents.host_capabilities is deprecated and ignored — host capability is ` +
475
+ `always probe/registry-resolved (${detectedNote})`,
503
476
  remedy: '',
504
477
  };
505
478
  }
@@ -560,16 +533,17 @@ export function appendConformanceReport(
560
533
 
561
534
  const USAGE =
562
535
  'usage: agent-config conformance [-h] [--project PROJECT] [--json]\n' +
563
- ' [--skip-dispatcher]\n';
536
+ ' [--skip-dispatcher] [--funnel]\n';
564
537
 
565
538
  interface Options {
566
539
  project: string | null;
567
540
  json: boolean;
568
541
  skip_dispatcher: boolean;
542
+ funnel: boolean;
569
543
  }
570
544
 
571
545
  function _parse(argv: string[]): Options {
572
- const opts: Options = { project: null, json: false, skip_dispatcher: false };
546
+ const opts: Options = { project: null, json: false, skip_dispatcher: false, funnel: false };
573
547
  let i = 0;
574
548
  while (i < argv.length) {
575
549
  const a = argv[i] as string;
@@ -579,6 +553,8 @@ function _parse(argv: string[]): Options {
579
553
  }
580
554
  if (a === '--json') {
581
555
  opts.json = true;
556
+ } else if (a === '--funnel') {
557
+ opts.funnel = true;
582
558
  } else if (a === '--skip-dispatcher') {
583
559
  opts.skip_dispatcher = true;
584
560
  } else if (a === '--project' || a.startsWith('--project=')) {
@@ -606,6 +582,17 @@ function _parse(argv: string[]): Options {
606
582
  function main(argv: string[] | null = null): number {
607
583
  const opts = _parse(argv !== null ? Array.from(argv) : process.argv.slice(2));
608
584
 
585
+ // `--funnel` — the delivery → activation → compliance report join
586
+ // (road-to-feedback-9-29 Phase 4.2). A REPORT, not a gate: it hangs off
587
+ // this verb so no new top-level verb enters the dispatcher registry, it
588
+ // skips the doctor/conformance legs entirely, and it always exits 0. It
589
+ // must never be wired into CI without a measured false-positive rate
590
+ // first — see the header of `report_conformance_funnel.ts`.
591
+ if (opts.funnel) {
592
+ print(renderFunnel(buildFunnel()));
593
+ return 0;
594
+ }
595
+
609
596
  let project_root: string;
610
597
  try {
611
598
  [project_root] = _resolve_project_root(opts.project);
@@ -1050,7 +1050,7 @@ function _check_lockfile_freshness(manifest: Dict): Dict {
1050
1050
  }
1051
1051
 
1052
1052
  /** `shutil.which(name)` — first PATH hit (with PATHEXT on win32). */
1053
- function shutilWhich(name: string): string | null {
1053
+ export function shutilWhich(name: string): string | null {
1054
1054
  if (path.dirname(name) !== '.' && (name.includes('/') || name.includes('\\'))) {
1055
1055
  // Has a path component: check directly.
1056
1056
  return isExecutableFile(name) ? name : null;
@@ -2065,6 +2065,31 @@ function osErrorStr(exc: unknown): string {
2065
2065
  const _CLI_PROVIDER_META: Readonly<Record<string, readonly [string, boolean]>> =
2066
2066
  PROVIDER_CLI_META;
2067
2067
 
2068
+ /**
2069
+ * m5 fix (independent-review finding) — `MemberConfig.mode` is the RAW
2070
+ * per-member override only (`config.ts::_build_member` never writes the
2071
+ * `defaults.mode`-resolved value back onto it); a member that never sets
2072
+ * `mode:` locally has `member.mode === null` regardless of what the
2073
+ * council's global default is. `defaults.mode` shipped `'auto'` as its own
2074
+ * default (road-to-always-on-orchestration Phase 3.1), so the common,
2075
+ * unconfigured case for every member is `null` here — and `auto` may
2076
+ * legitimately resolve to the `cli` rung, exactly the case
2077
+ * `config.ts::_build_member`'s own binary-override validation already
2078
+ * accounts for ("`auto` may resolve to the cli rung, so a binary override
2079
+ * is legitimate there too"). A check gated on the literal `mode === 'cli'`
2080
+ * misses every `auto`/unset member, honouring neither its binary override
2081
+ * nor its quota — silently, for the majority default shape.
2082
+ */
2083
+ function _effectiveMemberMode(member: ai_council_config.MemberConfig, cfg: ai_council_config.CouncilConfig): string {
2084
+ return member.mode ?? cfg.defaults.mode;
2085
+ }
2086
+
2087
+ /** True when `member` might run over CLI transport — `cli` pinned, or `auto` (which may resolve to it). */
2088
+ function _mayRunOverCli(member: ai_council_config.MemberConfig, cfg: ai_council_config.CouncilConfig): boolean {
2089
+ const mode = _effectiveMemberMode(member, cfg);
2090
+ return mode === 'cli' || mode === 'auto';
2091
+ }
2092
+
2068
2093
  function _check_council_cli(project_root: string): Dict {
2069
2094
  // Python wraps the council-module import in a try/except ImportError so a
2070
2095
  // broken council install degrades to a `warn` instead of crashing doctor.
@@ -2097,7 +2122,7 @@ function _check_council_cli(project_root: string): Dict {
2097
2122
  }
2098
2123
  const cli_members: Array<[string, ai_council_config.MemberConfig]> = [];
2099
2124
  for (const [name, m] of cfg.members.entries()) {
2100
- if (m.enabled && m.mode === 'cli' && name in _CLI_PROVIDER_META) {
2125
+ if (m.enabled && _mayRunOverCli(m, cfg) && name in _CLI_PROVIDER_META) {
2101
2126
  cli_members.push([name, m]);
2102
2127
  }
2103
2128
  }
@@ -2216,11 +2241,12 @@ function _codex_home(): string {
2216
2241
 
2217
2242
  /**
2218
2243
  * Codex binary name for the team check — REUSES the council probe's binary
2219
- * discovery: when a council config exists and declares an enabled cli-mode
2220
- * `openai` member with a `binary` override, honour it; else the provider
2221
- * default from `_CLI_PROVIDER_META` (`codex`). Never throws — an unreadable
2222
- * or invalid council config falls back to the default binary (the council-cli
2223
- * check owns reporting that problem).
2244
+ * discovery: when a council config exists and declares an enabled `openai`
2245
+ * member whose effective mode is `cli` (pinned) OR `auto` (may resolve to
2246
+ * `cli` — see `_mayRunOverCli`) with a `binary` override, honour it; else
2247
+ * the provider default from `_CLI_PROVIDER_META` (`codex`). Never throws —
2248
+ * an unreadable or invalid council config falls back to the default binary
2249
+ * (the council-cli check owns reporting that problem).
2224
2250
  */
2225
2251
  function _team_codex_binary_name(project_root: string): string {
2226
2252
  const default_bin = (_CLI_PROVIDER_META['openai'] as [string, boolean])[0];
@@ -2236,21 +2262,12 @@ function _team_codex_binary_name(project_root: string): string {
2236
2262
  return default_bin;
2237
2263
  }
2238
2264
  const member = cfg.members.get('openai');
2239
- if (member && member.enabled && member.mode === 'cli' && member.binary) {
2265
+ if (member && member.enabled && _mayRunOverCli(member, cfg) && member.binary) {
2240
2266
  return member.binary;
2241
2267
  }
2242
2268
  return default_bin;
2243
2269
  }
2244
2270
 
2245
- /** Settings-flag coercion shared with the tier-usage check (bool or string). */
2246
- function _settings_flag(val: unknown): boolean {
2247
- if (typeof val === 'boolean') return val;
2248
- if (typeof val === 'string') {
2249
- return ['true', 'yes', 'on', '1'].includes(val.trim().toLowerCase());
2250
- }
2251
- return false;
2252
- }
2253
-
2254
2271
  /**
2255
2272
  * Decode a JWT payload's `exp` claim (epoch seconds) — base64 decode only,
2256
2273
  * NO signature verification, no network. Non-JWT / undecodable → null.
@@ -2364,9 +2381,16 @@ function _read_ai_team_block(project_root: string): Dict {
2364
2381
  * loop bound (`max_consecutive_blocks`, Phase 4 — unbuilt) is absent
2365
2382
  * → WARN.
2366
2383
  *
2367
- * Absent feature ≠ broken feature: with `ai_team` absent or disabled the
2368
- * check reports ok ("team mode not configured (default-off)"); WARN fires
2369
- * only on failing sub-signals or inconsistent half-configured states.
2384
+ * Availability, not a setting (road-to-always-on-orchestration Phase 1,
2385
+ * Step 1.3): `ai_team.enabled` was DELETED — `/team`'s on/off state is the
2386
+ * codex binary + auth facts (a) computes below, mirroring
2387
+ * `checkCodexAvailability()` (`src/scripts/ai_team/availability.ts`).
2388
+ * Absent feature ≠ broken feature: with BOTH the binary and auth absent the
2389
+ * check reports ok ("team unavailable (default) — codex CLI not
2390
+ * installed") — a normal starting state, not a misconfiguration; WARN
2391
+ * fires only when something was set up PARTWAY (binary without auth, a
2392
+ * managed Review-Gate with an invalid bound, …) or a real sub-signal
2393
+ * fails.
2370
2394
  */
2371
2395
  // ---------------------------------------------------------------------------
2372
2396
  // detection check (road-to-zero-ceremony-detection Phases 3 + 4)
@@ -2526,36 +2550,11 @@ function _check_detection(project_root: string): Dict {
2526
2550
 
2527
2551
  function _check_team(project_root: string): Dict {
2528
2552
  const ai_team = _read_ai_team_block(project_root);
2529
- const enabled = _settings_flag(ai_team['enabled']);
2530
2553
  const gateRaw = ai_team['review_gate'];
2531
2554
  const gate =
2532
2555
  typeof gateRaw === 'object' && gateRaw !== null && !Array.isArray(gateRaw)
2533
2556
  ? (gateRaw as Dict)
2534
2557
  : {};
2535
- const gate_managed = _settings_flag(gate['managed']);
2536
-
2537
- if (!enabled) {
2538
- if (gate_managed) {
2539
- return {
2540
- id: 'team',
2541
- status: 'warn',
2542
- message:
2543
- 'half-configured: ai_team.review_gate.managed is on but ' +
2544
- 'ai_team.enabled is false — the gate never runs',
2545
- remedy:
2546
- 'set `ai_team.enabled: true` in .agent-settings.yml, or ' +
2547
- 'remove `ai_team.review_gate.managed`',
2548
- };
2549
- }
2550
- return {
2551
- id: 'team',
2552
- status: 'ok',
2553
- message: 'team mode not configured (default-off)',
2554
- remedy:
2555
- 'opt in via `ai_team.enabled: true` in .agent-settings.yml, ' +
2556
- 'then re-run `agent-config doctor --check team`',
2557
- };
2558
- }
2559
2558
 
2560
2559
  const remedies: string[] = [];
2561
2560
 
@@ -2563,7 +2562,8 @@ function _check_team(project_root: string): Dict {
2563
2562
  const binary_name = _team_codex_binary_name(project_root);
2564
2563
  const binary_resolved = shutilWhich(binary_name);
2565
2564
  const binary_glyph = binary_resolved !== null ? '✅' : '❌';
2566
- if (binary_resolved === null) {
2565
+ const binary_missing = binary_resolved === null;
2566
+ if (binary_missing) {
2567
2567
  remedies.push('install the codex CLI: `npm install -g @openai/codex`');
2568
2568
  }
2569
2569
 
@@ -2613,7 +2613,8 @@ function _check_team(project_root: string): Dict {
2613
2613
  // (c) Review-Gate governance (Phase 4) — logic lives in
2614
2614
  // src/scripts/ai_team/review_gate.ts (upstream gate probe + WARN
2615
2615
  // states, incl. plugin-gate-on-while-unmanaged with the quoted
2616
- // upstream cost warning).
2616
+ // upstream cost warning). Independent of /team's own availability —
2617
+ // `managed` governs the codex PLUGIN's own Stop-hook loop.
2617
2618
  const gate_signal = review_gate_doctor_signal(project_root, gate);
2618
2619
  const gate_str = gate_signal.gate_str;
2619
2620
  remedies.push(...gate_signal.remedies);
@@ -2621,6 +2622,21 @@ function _check_team(project_root: string): Dict {
2621
2622
  const detail =
2622
2623
  `codex binary ${binary_glyph} (${binary_name}) · ` +
2623
2624
  `${auth_str} · ${plugin_str} · ${gate_str}`;
2625
+
2626
+ if (binary_missing && !authed) {
2627
+ // Neither the binary nor auth is present — /team simply is not set
2628
+ // up on this machine yet. CLI-first doctrine (road-to-always-on-
2629
+ // orchestration Phase 1, Step 1.3): this is a normal starting
2630
+ // state, not a misconfiguration — still surface the full detail
2631
+ // (e.g. a `review_gate.managed` left on) so nothing is hidden.
2632
+ return {
2633
+ id: 'team',
2634
+ status: 'ok',
2635
+ message: `team unavailable (default) — codex CLI not installed · ${detail}`,
2636
+ remedy: remedies.join('; '),
2637
+ };
2638
+ }
2639
+
2624
2640
  if (remedies.length > 0) {
2625
2641
  return {
2626
2642
  id: 'team',
@@ -2632,7 +2648,7 @@ function _check_team(project_root: string): Dict {
2632
2648
  return {
2633
2649
  id: 'team',
2634
2650
  status: 'ok',
2635
- message: `team mode enabled · ${detail}`,
2651
+ message: `team available · ${detail}`,
2636
2652
  remedy: '',
2637
2653
  };
2638
2654
  }
@@ -3556,6 +3572,7 @@ export {
3556
3572
  _foreign_records,
3557
3573
  _check_scope,
3558
3574
  _check_manifest_integrity,
3575
+ _team_codex_binary_name,
3559
3576
  _check_lockfile_freshness,
3560
3577
  _check_global_binary,
3561
3578
  _check_claude_plugin,
@@ -0,0 +1,226 @@
1
+ /**
2
+ * `agent-config session:recycle` — write the main-session recycle envelope
3
+ * (road-to-token-economy-recycling Phase 2.2).
4
+ *
5
+ * The producer half of the deliberate session recycle: the model composes
6
+ * the envelope content it already knows (state, never a transcript
7
+ * summary), this command VALIDATES it against the main_session CHECKPOINT
8
+ * variant (`_lib/subagent_capsule.validateRecycleEnvelope`) and writes it
9
+ * atomically to `agents/runtime/state/recycle-envelope.json`, then prints
10
+ * the exact resume instruction. Deterministic — no model step in the write
11
+ * path; the only values this command fills are provenance it can resolve
12
+ * itself (`written_at` = now, `workspace` = project root,
13
+ * `capsule_version`/`variant` = the constants).
14
+ *
15
+ * Hooks cannot inject `/clear` (host limitation, roadmap Context) — the
16
+ * clear is the USER's action; the successor session's `handoff_context_hook`
17
+ * consumes the envelope at session_start (moved, not copied).
18
+ *
19
+ * Usage:
20
+ * agent-config session:recycle --file <envelope.json> # read from file
21
+ * agent-config session:recycle < envelope.json # read from stdin
22
+ * agent-config session:recycle --template # print a skeleton
23
+ *
24
+ * Exit codes: 0 written (or template printed) · 1 invalid / refused · 2 usage.
25
+ */
26
+
27
+ import * as fs from 'node:fs';
28
+ import * as path from 'node:path';
29
+ import process from 'node:process';
30
+ import { fileURLToPath, pathToFileURL } from 'node:url';
31
+
32
+ import { resolve_project_root } from '../_lib/agent_settings.js';
33
+ import {
34
+ RECYCLE_ENVELOPE_MAX_BYTES,
35
+ RECYCLE_ENVELOPE_REL,
36
+ } from '../_lib/recycle_envelope_paths.js';
37
+ import {
38
+ CAPSULE_SCHEMA_VERSION,
39
+ validateRecycleEnvelope,
40
+ } from '../_lib/subagent_capsule.js';
41
+ import { atomic_write_json } from '../hooks/state_io.js';
42
+
43
+ export interface RecycleResult {
44
+ code: 0 | 1 | 2;
45
+ out: string[];
46
+ err: string[];
47
+ }
48
+
49
+ /** Skeleton the model fills — every list ships empty, nothing is invented. */
50
+ export function templateEnvelope(): Record<string, unknown> {
51
+ return {
52
+ capsule_version: CAPSULE_SCHEMA_VERSION,
53
+ variant: 'main_session',
54
+ summary: '<one- or two-sentence outcome so far>',
55
+ task: '<the active task, one line>',
56
+ acceptance_criteria: ['<what done means, one line each>'],
57
+ remaining: ['<open work, one line each>'],
58
+ not_carried_forward: ['<what the successor must re-derive from source>'],
59
+ decisions: ['<decision — one-line rationale>'],
60
+ constraints: ['<binding constraint>'],
61
+ open_worker_envelopes: [],
62
+ artifact_paths: ['<path to a deliverable / note / evidence file>'],
63
+ assumptions: [],
64
+ };
65
+ }
66
+
67
+ interface ParsedArgv {
68
+ ok: boolean;
69
+ message?: string;
70
+ file?: string;
71
+ template?: boolean;
72
+ }
73
+
74
+ export function parseArgv(argv: readonly string[]): ParsedArgv {
75
+ const parsed: ParsedArgv = { ok: true };
76
+ for (let i = 0; i < argv.length; i += 1) {
77
+ const a = argv[i] as string;
78
+ if (a === '--template') {
79
+ parsed.template = true;
80
+ } else if (a === '--file') {
81
+ const value = argv[i + 1];
82
+ if (!value) return { ok: false, message: '--file requires a path' };
83
+ parsed.file = value;
84
+ i += 1;
85
+ } else if (a === '-h' || a === '--help') {
86
+ return { ok: false, message: 'usage' };
87
+ } else {
88
+ return { ok: false, message: `unknown argument: ${a}` };
89
+ }
90
+ }
91
+ return parsed;
92
+ }
93
+
94
+ /**
95
+ * Validate + write. `input` is the raw JSON text the model composed;
96
+ * provenance fields this command can resolve itself are filled when absent,
97
+ * then the STRICT validator decides.
98
+ */
99
+ export function runSessionRecycle(
100
+ input: string,
101
+ opts: { cwd: string; now?: Date },
102
+ ): RecycleResult {
103
+ const out: string[] = [];
104
+ const err: string[] = [];
105
+ const [projectRoot] = resolve_project_root(null, { cwd: opts.cwd });
106
+
107
+ let parsed: unknown;
108
+ try {
109
+ parsed = JSON.parse(input);
110
+ } catch (exc) {
111
+ return { code: 1, out, err: [`envelope is not valid JSON: ${String(exc)}`] };
112
+ }
113
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
114
+ return { code: 1, out, err: ['envelope must be a JSON object'] };
115
+ }
116
+ const envelope = parsed as Record<string, unknown>;
117
+
118
+ // Deterministic provenance — filled only when the composer left them out.
119
+ if (envelope['capsule_version'] === undefined) envelope['capsule_version'] = CAPSULE_SCHEMA_VERSION;
120
+ if (envelope['variant'] === undefined) envelope['variant'] = 'main_session';
121
+ if (envelope['written_at'] === undefined) {
122
+ envelope['written_at'] = (opts.now ?? new Date()).toISOString();
123
+ }
124
+ if (envelope['workspace'] === undefined) envelope['workspace'] = projectRoot;
125
+
126
+ const violations = validateRecycleEnvelope(envelope);
127
+ if (violations.length > 0) {
128
+ return {
129
+ code: 1,
130
+ out,
131
+ err: ['recycle envelope refused — schema violations:', ...violations.map((v) => ` - ${v}`)],
132
+ };
133
+ }
134
+
135
+ const serialized = JSON.stringify(envelope, null, 2);
136
+ const bytes = Buffer.byteLength(serialized, 'utf-8');
137
+ if (bytes > RECYCLE_ENVELOPE_MAX_BYTES) {
138
+ return {
139
+ code: 1,
140
+ out,
141
+ err: [
142
+ `recycle envelope refused — ${bytes} bytes > ${RECYCLE_ENVELOPE_MAX_BYTES} byte cap.`,
143
+ 'An envelope is selection and pointers, not a dump: move detail into artifact',
144
+ 'files and reference them via artifact_paths.',
145
+ ],
146
+ };
147
+ }
148
+
149
+ const target = path.join(projectRoot, RECYCLE_ENVELOPE_REL);
150
+ try {
151
+ atomic_write_json(target, envelope);
152
+ } catch (exc) {
153
+ return { code: 1, out, err: [`could not write ${target}: ${String(exc)}`] };
154
+ }
155
+
156
+ out.push(`recycle envelope written — ${RECYCLE_ENVELOPE_REL} (${bytes} bytes)`);
157
+ out.push('');
158
+ out.push('Resume instruction:');
159
+ out.push(' 1. End this session now: run /clear (or start a fresh session in this workspace).');
160
+ out.push(' 2. The successor session receives the envelope automatically at session_start');
161
+ out.push(' (injected once as DATA, then consumed — moved, not copied).');
162
+ out.push(' 3. The successor re-derives everything on the not_carried_forward list from');
163
+ out.push(' source before trusting it.');
164
+ return { code: 0, out, err };
165
+ }
166
+
167
+ export function main(argv: string[] = process.argv.slice(2)): number {
168
+ const parsed = parseArgv(argv);
169
+ if (!parsed.ok) {
170
+ const usage = [
171
+ 'usage: agent-config session:recycle [--file <envelope.json>] [--template]',
172
+ ' --file <path> read the envelope JSON from a file (default: stdin)',
173
+ ' --template print a skeleton envelope and exit',
174
+ ].join('\n');
175
+ if (parsed.message === 'usage') {
176
+ process.stdout.write(`${usage}\n`);
177
+ return 0;
178
+ }
179
+ process.stderr.write(`${parsed.message}\n${usage}\n`);
180
+ return 2;
181
+ }
182
+
183
+ if (parsed.template) {
184
+ process.stdout.write(`${JSON.stringify(templateEnvelope(), null, 2)}\n`);
185
+ return 0;
186
+ }
187
+
188
+ let input: string;
189
+ try {
190
+ if (parsed.file) {
191
+ input = fs.readFileSync(parsed.file, 'utf-8');
192
+ } else if (process.stdin.isTTY) {
193
+ process.stderr.write('no envelope on stdin and no --file given (see --help)\n');
194
+ return 2;
195
+ } else {
196
+ input = fs.readFileSync(0, 'utf-8');
197
+ }
198
+ } catch (exc) {
199
+ process.stderr.write(`could not read envelope input: ${String(exc)}\n`);
200
+ return 2;
201
+ }
202
+
203
+ const result = runSessionRecycle(input, { cwd: process.cwd() });
204
+ for (const line of result.out) process.stdout.write(`${line}\n`);
205
+ for (const line of result.err) process.stderr.write(`${line}\n`);
206
+ return result.code;
207
+ }
208
+
209
+ // Bundle-safety: never auto-run when inlined into an esbuild bundle.
210
+ declare const __AGENT_CONFIG_BUNDLE__: boolean | undefined;
211
+ function _isCliEntry(): boolean {
212
+ if (typeof __AGENT_CONFIG_BUNDLE__ !== 'undefined' && __AGENT_CONFIG_BUNDLE__) return false;
213
+ if (process.argv[1] === undefined) return false;
214
+ if (import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) return true;
215
+ try {
216
+ return (
217
+ fs.realpathSync(fileURLToPath(import.meta.url)) === fs.realpathSync(path.resolve(process.argv[1]))
218
+ );
219
+ } catch {
220
+ return false;
221
+ }
222
+ }
223
+
224
+ if (_isCliEntry()) {
225
+ process.exit(main());
226
+ }
@@ -197,10 +197,17 @@ Tier 2 — maintenance / internal (hooks, MCP, memory, telemetry):
197
197
  session register). Flags: --json
198
198
  sessions:claim Claim a roadmap for this session so other sessions skip
199
199
  it; --release clears the claim
200
+ session:recycle Validate + write the main-session recycle envelope
201
+ (deliberate recycle instead of auto-compact). Flags:
202
+ --file <json> | --template; default reads stdin
200
203
  roadmap:progress Regenerate agents/roadmaps-progress.md from open roadmaps
201
204
  roadmap:progress-check Fail if agents/roadmaps-progress.md is stale (for CI)
202
205
  roadmap:archive Archive completed roadmaps (branch-touched by default;
203
206
  --all for every complete one; --dry-run to preview)
207
+ gates Open decisions that need you, rendered as actions —
208
+ roadmap blockers filtered by owner, most-unblocking
209
+ first. Flags: --all (include maintainer/external),
210
+ --json
204
211
  capabilities:index Regenerate CAPABILITIES.yaml — the package coverage index
205
212
  (capability area → coverage → backing skills/commands → gaps).
206
213
  Pass --check to fail if stale (for CI). Reads src/ (package repo).
@@ -614,6 +621,14 @@ cmd_sessions_claim() {
614
621
  exec_ts "$PACKAGE_ROOT/src/scripts/sessions_cli.ts" claim "$@"
615
622
  }
616
623
 
624
+ # Main-session recycle envelope producer (road-to-token-economy-recycling
625
+ # Phase 2.2). PACKAGE_ROOT: imports src/scripts/_lib/ (capsule schema) and
626
+ # src/scripts/hooks/state_io.ts, which are never projected into
627
+ # dist/agent-src/scripts/.
628
+ cmd_session_recycle() {
629
+ exec_ts "$PACKAGE_ROOT/src/scripts/_cli/cmd_session_recycle.ts" "$@"
630
+ }
631
+
617
632
  # Capability probes (road-to-capability-answerability). All three resolve from
618
633
  # PACKAGE_ROOT rather than the consumer projection: each imports package-internal
619
634
  # libraries under src/scripts/_lib/ or src/shared/, which are never projected into
@@ -654,6 +669,12 @@ cmd_roadmap_archive() {
654
669
  exec_ts "$script" "$@"
655
670
  }
656
671
 
672
+ cmd_gates() {
673
+ local script
674
+ script="$(resolve_script "dist/agent-src/scripts/roadmap_gates.ts" ".augment/scripts/roadmap_gates.ts")"
675
+ exec_ts "$script" "$@"
676
+ }
677
+
657
678
  cmd_capabilities_index() {
658
679
  local script
659
680
  script="$(resolve_script "src/scripts/generate_capabilities_index.ts")"
@@ -1320,6 +1341,7 @@ main() {
1320
1341
  conformance:behavior) cmd_conformance_behavior "$@" ;;
1321
1342
  sessions:list) cmd_sessions_list "$@" ;;
1322
1343
  sessions:claim) cmd_sessions_claim "$@" ;;
1344
+ session:recycle) cmd_session_recycle "$@" ;;
1323
1345
  packs:active) cmd_packs_active "$@" ;;
1324
1346
  settings:get) cmd_settings_get "$@" ;;
1325
1347
  mcp:available) cmd_mcp_available "$@" ;;
@@ -1327,6 +1349,7 @@ main() {
1327
1349
  roadmap:progress) cmd_roadmap_progress "$@" ;;
1328
1350
  roadmap:progress-check) cmd_roadmap_progress_check "$@" ;;
1329
1351
  roadmap:archive) cmd_roadmap_archive "$@" ;;
1352
+ gates) cmd_gates "$@" ;;
1330
1353
  capabilities:index) cmd_capabilities_index "$@" ;;
1331
1354
  hooks:install) cmd_hooks_install "$@" ;;
1332
1355
  keys:install-anthropic) cmd_keys_install_anthropic "$@" ;;