@azure-id/orc 1.9.2 → 2.1.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 (228) hide show
  1. package/CHANGELOG.md +722 -0
  2. package/README-id.md +56 -42
  3. package/README.md +58 -41
  4. package/bin/build-agents.js +125 -29
  5. package/bin/clear-logs.js +620 -0
  6. package/bin/cli.js +1873 -180
  7. package/bin/fix.js +459 -0
  8. package/bin/gotcha-import.js +1081 -0
  9. package/bin/gotcha.js +1566 -0
  10. package/bin/graph-query.js +1 -1
  11. package/bin/graph.js +717 -717
  12. package/bin/habit.js +1538 -0
  13. package/bin/mockrun-catalog.js +284 -276
  14. package/bin/onboarding-content.js +2 -1
  15. package/bin/pricing.json +28 -21
  16. package/bin/run-undo.js +398 -0
  17. package/bin/trace-write.js +869 -0
  18. package/bin/verify-contracts.js +627 -100
  19. package/bin/verify-package.js +68 -10
  20. package/bin/webui/api.js +151 -6
  21. package/bin/webui/app.html +239 -232
  22. package/bin/webui/css/00-tokens.css +110 -92
  23. package/bin/webui/css/04-motion.css +87 -0
  24. package/bin/webui/css/06-responsive.css +203 -178
  25. package/bin/webui/css/panels/behaviour.css +205 -0
  26. package/bin/webui/css/panels/hookui.css +79 -0
  27. package/bin/webui/fixtures/behaviour.js +562 -0
  28. package/bin/webui/fixtures/extra.js +9 -9
  29. package/bin/webui/fixtures/flow.js +81 -81
  30. package/bin/webui/fixtures/hookui.js +506 -431
  31. package/bin/webui/fixtures/index.js +66 -3
  32. package/bin/webui/fixtures/knowledge.js +9 -3
  33. package/bin/webui/fixtures/maintenance.js +123 -42
  34. package/bin/webui/fixtures/rules.js +1007 -1002
  35. package/bin/webui/fixtures/settings.js +6 -7
  36. package/bin/webui/fixtures/stats.js +25 -6
  37. package/bin/webui/fixtures/wait.js +98 -97
  38. package/bin/webui/i18n/en/behaviour.json +156 -0
  39. package/bin/webui/i18n/en/hookui.json +290 -194
  40. package/bin/webui/i18n/en/maintenance.json +71 -52
  41. package/bin/webui/i18n/en/nav.json +25 -24
  42. package/bin/webui/i18n/en/settings.json +60 -60
  43. package/bin/webui/i18n/en/tour.json +37 -35
  44. package/bin/webui/i18n/id/behaviour.json +156 -0
  45. package/bin/webui/i18n/id/hookui.json +290 -194
  46. package/bin/webui/i18n/id/maintenance.json +71 -52
  47. package/bin/webui/i18n/id/nav.json +25 -24
  48. package/bin/webui/i18n/id/settings.json +60 -60
  49. package/bin/webui/i18n/id/tour.json +37 -35
  50. package/bin/webui/js/01-i18n.js +155 -154
  51. package/bin/webui/js/05-banners.js +181 -172
  52. package/bin/webui/js/06-edit.js +193 -183
  53. package/bin/webui/js/90-tour.js +498 -494
  54. package/bin/webui/js/91-shortcuts.js +126 -126
  55. package/bin/webui/js/99-boot.js +121 -118
  56. package/bin/webui/js/panels/behaviour.js +1087 -0
  57. package/bin/webui/js/panels/hookui.js +2196 -1691
  58. package/bin/webui/js/panels/maintenance.js +336 -235
  59. package/bin/webui/js/panels/settings.js +726 -719
  60. package/mock-run/INDEX.md +110 -107
  61. package/mock-run/extra-slots.md +1 -1
  62. package/mock-run/gotcha-import.md +118 -0
  63. package/mock-run/habits.md +129 -0
  64. package/mock-run/orc-aftermath.md +392 -392
  65. package/mock-run/orc-budget.md +29 -33
  66. package/mock-run/orc-cli.md +200 -200
  67. package/mock-run/orc-explain.md +86 -86
  68. package/mock-run/orc-extra.md +389 -392
  69. package/mock-run/orc-fix.md +87 -0
  70. package/mock-run/orc-pattern.md +112 -112
  71. package/mock-run/orc-quick.md +6 -1
  72. package/mock-run/orc.md +157 -157
  73. package/package.json +1 -1
  74. package/templates/agents/MODEL-MAPPING.md +37 -34
  75. package/templates/agents/orc-advisor-opus-5-xhigh.md +1 -7
  76. package/templates/agents/orc-analyze-mini-opus-5-med.md +1 -6
  77. package/templates/agents/orc-analyze-mini-sonnet-5-high.md +2 -5
  78. package/templates/agents/{orc-claude-writer-opus-4-8-high.md → orc-claude-writer-opus-5-low.md} +48 -53
  79. package/templates/agents/orc-context-combiner-opus-5-high.md +1 -11
  80. package/templates/agents/orc-executor-haiku-4-5.md +14 -6
  81. package/templates/agents/orc-executor-opus-4-7-high.md +14 -6
  82. package/templates/agents/orc-executor-opus-4-7-med.md +14 -6
  83. package/templates/agents/orc-executor-opus-4-8-high.md +14 -6
  84. package/templates/agents/orc-executor-opus-5-high.md +14 -6
  85. package/templates/agents/orc-executor-opus-5-low.md +14 -6
  86. package/templates/agents/orc-executor-opus-5-med.md +14 -6
  87. package/templates/agents/orc-executor-sonnet-4-6-high.md +14 -6
  88. package/templates/agents/orc-executor-sonnet-4-6-med.md +14 -6
  89. package/templates/agents/orc-executor-sonnet-5-high.md +15 -7
  90. package/templates/agents/orc-executor-sonnet-5-low.md +155 -0
  91. package/templates/agents/orc-executor-sonnet-5-med.md +155 -0
  92. package/templates/agents/orc-graph-noter-sonnet-4-6-med.md +1 -10
  93. package/templates/agents/orc-judge-opus-5-xhigh.md +5 -9
  94. package/templates/agents/orc-learn-writer-opus-5-low.md +1 -7
  95. package/templates/agents/orc-pattern-codifier-opus-5-med.md +1 -8
  96. package/templates/agents/orc-pattern-codifier-sonnet-5-high.md +58 -63
  97. package/templates/agents/orc-planner-mini-opus-5-med.md +1 -4
  98. package/templates/agents/orc-planner-mini-sonnet-5-high.md +2 -3
  99. package/templates/agents/orc-planner-opus-5-med.md +1 -4
  100. package/templates/agents/orc-recon-opus-5-low.md +1 -8
  101. package/templates/agents/orc-recon-sonnet-4-6-med.md +1 -8
  102. package/templates/agents/orc-retro-opus-5-med.md +6 -8
  103. package/templates/agents/orc-retro-sonnet-5-high.md +7 -8
  104. package/templates/agents/orc-reviewer-opus-5-low.md +96 -0
  105. package/templates/agents/orc-scout-opus-5-low.md +1 -6
  106. package/templates/agents/orc-scout-sonnet-4-6-high.md +35 -39
  107. package/templates/agents/orc-system-analyst-opus-5-high.md +1 -6
  108. package/templates/agents/orc-test-author-opus-5-med.md +4 -5
  109. package/templates/agents/orc-trace-writer-haiku-4-5.md +3 -7
  110. package/templates/agents/orc-verifier-opus-5-med.md +16 -8
  111. package/templates/agents/{orc-wiki-scanner-opus-4-8-high.md → orc-wiki-scanner-opus-5-low.md} +74 -79
  112. package/templates/agents/orc-wiki-scanner-sonnet-5-high.md +97 -106
  113. package/templates/commands/orc-analyze.md +13 -21
  114. package/templates/commands/orc-fast.md +10 -15
  115. package/templates/commands/orc-fix.md +18 -0
  116. package/templates/commands/orc-poly.md +12 -21
  117. package/templates/commands/orc-pr-driver.md +11 -30
  118. package/templates/commands/orc-pr-setup.md +10 -31
  119. package/templates/commands/orc-route.md +11 -41
  120. package/templates/commands/orc-test.md +5 -60
  121. package/templates/commands/orc-wiki.md +64 -64
  122. package/templates/hooks/README.md +109 -7
  123. package/templates/hooks/orc-session-hook.js +339 -0
  124. package/templates/hooks/orc-statusline-render.js +317 -23
  125. package/templates/hooks/orc-statusline.js +165 -50
  126. package/templates/hooks/orc-subagent-line.js +23 -5
  127. package/templates/hooks/orc-weather-fetch.js +123 -0
  128. package/templates/skills/_shared/README.md +9 -0
  129. package/templates/skills/_shared/code-graph.md +47 -55
  130. package/templates/skills/_shared/config-precedence.md +3 -1
  131. package/templates/skills/_shared/extra-dispatch.md +78 -93
  132. package/templates/skills/_shared/gotchas.md +248 -177
  133. package/templates/skills/_shared/habits.md +101 -0
  134. package/templates/skills/_shared/lane-contract.md +84 -0
  135. package/templates/skills/_shared/opus5-only.md +14 -14
  136. package/templates/skills/_shared/phases/README.md +142 -83
  137. package/templates/skills/_shared/phases/analyst-gates.md +10 -21
  138. package/templates/skills/_shared/phases/execution.md +8 -14
  139. package/templates/skills/_shared/phases/house-rules.md +27 -32
  140. package/templates/skills/_shared/phases/intake.md +127 -133
  141. package/templates/skills/_shared/phases/mock-example.md +46 -56
  142. package/templates/skills/_shared/phases/plan-handoff.md +91 -97
  143. package/templates/skills/_shared/phases/planning.md +7 -17
  144. package/templates/skills/_shared/phases/preflight.md +19 -42
  145. package/templates/skills/_shared/phases/review.md +24 -28
  146. package/templates/skills/_shared/phases/rules.md +18 -42
  147. package/templates/skills/_shared/phases/scoring.md +55 -65
  148. package/templates/skills/_shared/phases/security-checklist.md +46 -50
  149. package/templates/skills/_shared/phases/security.md +45 -55
  150. package/templates/skills/_shared/phases/ship.md +6 -15
  151. package/templates/skills/_shared/phases/stop-resume.md +2 -5
  152. package/templates/skills/_shared/phases/summary.md +73 -48
  153. package/templates/skills/_shared/phases/testgen.md +41 -51
  154. package/templates/skills/_shared/phases/trace-verbs.md +447 -0
  155. package/templates/skills/_shared/phases/trace.md +66 -297
  156. package/templates/skills/_shared/phases/verify.md +62 -70
  157. package/templates/skills/_shared/phases/wave-grouping.md +128 -133
  158. package/templates/skills/_shared/phases/wiki-consult.md +10 -6
  159. package/templates/skills/_shared/read-ladder.md +2 -55
  160. package/templates/skills/_shared/return-validation.md +17 -70
  161. package/templates/skills/_shared/review-slice.md +106 -0
  162. package/templates/skills/_shared/smoke-gate.md +46 -28
  163. package/templates/skills/_shared/wait.md +1 -0
  164. package/templates/skills/context-combiner/SKILL.md +15 -44
  165. package/templates/skills/orc/README.md +2 -2
  166. package/templates/skills/orc/SKILL.md +35 -63
  167. package/templates/skills/orc/config.md +25 -27
  168. package/templates/skills/orc/examples/full-run-mock.md +2 -1
  169. package/templates/skills/orc/references/effort-and-mode.md +17 -17
  170. package/templates/skills/orc/references/pattern-gate.md +89 -89
  171. package/templates/skills/orc/references/phases/intake.md +41 -47
  172. package/templates/skills/orc/references/phases/integration.md +13 -19
  173. package/templates/skills/orc/references/preflight-report.md +11 -12
  174. package/templates/skills/orc/references/ultra-mode.md +9 -7
  175. package/templates/skills/orc/schemas/checkpoint.md +122 -122
  176. package/templates/skills/orc/subskills/orc-execution/SKILL.md +27 -73
  177. package/templates/skills/orc/subskills/orc-execution/core.md +12 -99
  178. package/templates/skills/orc/subskills/orc-execution/subagent.md +14 -13
  179. package/templates/skills/orc/subskills/orc-review-verify/SKILL.md +12 -53
  180. package/templates/skills/orc/subskills/orc-review-verify/core.md +52 -135
  181. package/templates/skills/orc/subskills/orc-review-verify/subagent.md +7 -7
  182. package/templates/skills/orc/subskills/orc-testgen/SKILL.md +11 -22
  183. package/templates/skills/orc/subskills/orc-testgen/core.md +20 -59
  184. package/templates/skills/orc/subskills/orc-testgen/subagent.md +7 -7
  185. package/templates/skills/orc-advisor/SKILL.md +56 -60
  186. package/templates/skills/orc-analyze/SKILL.md +33 -67
  187. package/templates/skills/orc-analyze/schemas/report-audit.md +2 -1
  188. package/templates/skills/orc-analyze/schemas/report-prose.md +2 -1
  189. package/templates/skills/orc-analyze-mini/SKILL.md +35 -70
  190. package/templates/skills/orc-claude/SKILL.md +14 -14
  191. package/templates/skills/orc-claude/examples/claude-run-mock.md +65 -65
  192. package/templates/skills/orc-diy/README.md +31 -0
  193. package/templates/skills/orc-diy/SKILL.md +27 -78
  194. package/templates/skills/orc-diy/references/blocks/pattern.md +18 -18
  195. package/templates/skills/orc-fast/SKILL.md +49 -75
  196. package/templates/skills/orc-fix/SKILL.md +110 -0
  197. package/templates/skills/orc-judge/SKILL.md +77 -82
  198. package/templates/skills/orc-mini/SKILL.md +64 -112
  199. package/templates/skills/orc-mini/examples/mini-run-mock.md +4 -2
  200. package/templates/skills/orc-pattern/SKILL.md +27 -48
  201. package/templates/skills/orc-poly/SKILL.md +32 -61
  202. package/templates/skills/orc-pr-driver/SKILL.md +25 -51
  203. package/templates/skills/orc-pr-driver/references/green-gate.md +113 -105
  204. package/templates/skills/orc-pr-setup/SKILL.md +20 -45
  205. package/templates/skills/orc-quick/README.md +44 -3
  206. package/templates/skills/orc-quick/SKILL.md +77 -108
  207. package/templates/skills/orc-quick/references/dispatch-gate.md +18 -6
  208. package/templates/skills/orc-quick/references/gh-mode.md +50 -1
  209. package/templates/skills/orc-quick/references/look.md +3 -1
  210. package/templates/skills/orc-retro/SKILL.md +20 -19
  211. package/templates/skills/orc-retro/examples/retro-mock.md +17 -17
  212. package/templates/skills/orc-route/SKILL.md +25 -45
  213. package/templates/skills/orc-test/SKILL.md +16 -37
  214. package/templates/skills/orc-verify/SKILL.md +14 -32
  215. package/templates/skills/orc-wait/SKILL.md +156 -163
  216. package/templates/skills/orc-wiki/README.md +325 -325
  217. package/templates/skills/orc-wiki/SKILL.md +195 -195
  218. package/templates/skills/orc-wiki/examples/wiki-run-mock.md +37 -37
  219. package/templates/skills/orc-wiki/references/extra.md +2 -2
  220. package/templates/skills/orc-wiki/references/partial-refresh.md +276 -271
  221. package/templates/skills/orc-wiki/references/phases/phase-0.md +2 -7
  222. package/templates/skills/orc-wiki/references/phases/phase-1.md +1 -6
  223. package/templates/skills/orc-wiki/references/phases/phase-2.md +4 -9
  224. package/templates/skills/orc-wiki/references/phases/phase-3.md +1 -6
  225. package/templates/skills/orc-wiki/references/phases/phase-3c.md +4 -8
  226. package/templates/agents/orc-claude-writer-opus-5-med.md +0 -55
  227. package/templates/agents/orc-reviewer-opus-5-med.md +0 -60
  228. package/templates/agents/orc-wiki-scanner-opus-5-med.md +0 -81
@@ -25,11 +25,12 @@ const { wiki, wikiDocs, wikiShow, wikiCoverage, wikiCoverageFull, wikiUnregister
25
25
  const { runs, runDetail, runDetailClosed, aftermath } = require("./runs.js");
26
26
  const { stats, budgetForecast, budgetRates } = require("./stats.js");
27
27
  const { pact } = require("./pact.js");
28
+ const B = require("./behaviour.js");
28
29
  const { boundary } = require("./boundary.js");
29
30
  const { usage, waitLanes, waitStatus } = require("./wait.js");
30
31
  const hookui = require("./hookui.js");
31
32
  const { handoff } = require("./handoff.js");
32
- const { exportState, mocks } = require("./maintenance.js");
33
+ const { exportState, mocks, clearLogsSummary, clearLogsPreview, clearLogsPreviewEmpty } = require("./maintenance.js");
33
34
  const { chGoals, chDims, challengeRoles, challengeCouncil, challengeCycles, challengeList, challengeShow, challengeDiff, challengeDiffMissing, challengeLint } = require("./challenge.js");
34
35
  const { docList, docParts, docStatuses, docMapSections, docMap, docLint, docPlan, docShow, docSection, docShipped, docShippedDrifted, docNext, docAudit, docJournalRich, docJournalEmpty, docContext, docRules, docRulesFrozen, docForecast, docCost } = require("./docs.js");
35
36
  const { laneList, lanePhases, laneCalls } = require("./lanes.js");
@@ -279,7 +280,7 @@ module.exports.get = function get(route, q) {
279
280
  case "/api/budget/rates":
280
281
  return budgetRates;
281
282
  case "/api/budget/actual":
282
- return { ok: true, run: "store-credit", lane: "orc", trace: "run-orc-store-credit-100826-093012.txt", rows: [{ band: "[40,55)", dispatches: 3, forecast_weighted: 96000, actual_weighted: 138000, diff_pct: 44, tokens: { input: 9000, cache_write: 61000, cache_read: 121000, output: 11000 } }, { band: "[70,80)", dispatches: 1, forecast_weighted: 121000, actual_weighted: 304000, diff_pct: 151, tokens: { input: 12000, cache_write: 98000, cache_read: 240000, output: 24000 } }], actual: { tokens: { input: 21000, cache_write: 159000, cache_read: 361000, output: 35000 }, raw: 576000, weighted: 251100, usd: 7.02 }, cache_read_share: 0.71, unattributed: { blocks: 12, tokens: { input: 900, cache_write: 12000, cache_read: 24000, output: 1100 } }, joined: 17, dispatches: 19 };
283
+ return { ok: true, run: "store-credit", lane: "orc", trace: "run-orc-store-credit-100826-093012.txt", rows: [{ band: "[31,41)", dispatches: 3, forecast_weighted: 96000, actual_weighted: 138000, diff_pct: 44, tokens: { input: 9000, cache_write: 61000, cache_read: 121000, output: 11000 } }, { band: "[41,90)", dispatches: 1, forecast_weighted: 121000, actual_weighted: 304000, diff_pct: 151, tokens: { input: 12000, cache_write: 98000, cache_read: 240000, output: 24000 } }], actual: { tokens: { input: 21000, cache_write: 159000, cache_read: 361000, output: 35000 }, raw: 576000, weighted: 251100, usd: 7.02 }, cache_read_share: 0.71, unattributed: { blocks: 12, tokens: { input: 900, cache_write: 12000, cache_read: 24000, output: 1100 } }, joined: 17, dispatches: 19 };
283
284
  case "/api/aftermath":
284
285
  return aftermath;
285
286
  case "/api/export":
@@ -339,6 +340,30 @@ module.exports.get = function get(route, q) {
339
340
  return gotchaPrunePreview;
340
341
  case "/api/stats":
341
342
  return stats;
343
+ // v2.0.0 W7 — the Behaviour panel. The `habits` mode is the one fixture
344
+ // with STATE: the learning switch posts `/api/config/set` (below), and
345
+ // the next read answers in that mode, so off · observe · propose are all
346
+ // reachable from the panel itself. The 30d window is the EMPTY answer
347
+ // (no ASK lines yet, and below the review floor) — a window with nothing
348
+ // in it is exactly where those two states happen on a real machine.
349
+ case "/api/habits":
350
+ if (HABITS_MODE.value === "off") return B.habitsOff;
351
+ if (q && q.window === "30d") return B.habitsEmpty;
352
+ return HABITS_MODE.value === "observe" ? B.habitsObserve : B.habitsPropose;
353
+ case "/api/habits/log":
354
+ return HABITS_MODE.value === "off" ? B.habitLogEmpty : B.habitLog;
355
+ case "/api/habits/states":
356
+ return B.habitStates;
357
+ case "/api/habits/points":
358
+ return B.habitPoints;
359
+ // A path under a scope some gotcha holds answers the card; anything else is
360
+ // the zero-match ANSWER, which is the CLI's exit 1 and "no card".
361
+ case "/api/gotcha/card":
362
+ return /src\/routes\/|tests\/|client\/src\/i18n\//.test(String((q && q.files) || "")) ? B.gotchaCard : B.gotchaCardNone;
363
+ case "/api/gotcha/quality":
364
+ return q && q.window === "30d" ? B.gotchaQualityLow : B.gotchaQuality;
365
+ case "/api/gotcha/candidates":
366
+ return B.gotchaCandidates;
342
367
  case "/api/diy":
343
368
  return diy;
344
369
  case "/api/crosslink":
@@ -439,10 +464,37 @@ module.exports.get = function get(route, q) {
439
464
  { id: "prune", label: "Update AND delete ORC-named orphans from a pre-manifest install", command: "orc update --prune", network: false, names_files: true },
440
465
  { id: "fix", label: "Apply every fix orc doctor found (= update + prune + settings re-merge)", command: "orc doctor --fix", network: false, names_files: false },
441
466
  { id: "upgrade", label: "Fetch the LATEST package from the network, then apply it", command: "orc upgrade", network: true, names_files: false },
467
+ { id: "export", label: "Recompile AGENTS.md from the wiki, patterns, PACT.md and boundary cards", command: "orc export", network: false, names_files: false },
468
+ {
469
+ id: "clear-logs",
470
+ label: "Delete finished traces and run folders older than log_retention_days (never user data, never a waiting run)",
471
+ command: "orc clear logs --apply",
472
+ network: false,
473
+ names_files: true,
474
+ danger: true,
475
+ restarts_ui: false,
476
+ status: clearLogsSummary,
477
+ },
442
478
  { id: "update-global", label: "Re-copy this package's payload over the GLOBAL install in ~/.claude", command: "orc update --global", network: false, names_files: false, advanced: true },
443
479
  ],
444
480
  };
445
481
  case "/api/maintenance/preview":
482
+ if (q.action === "clear-logs")
483
+ return {
484
+ action: q.action,
485
+ label: "Preview (fixtures)",
486
+ command: "orc clear logs --apply",
487
+ network: false,
488
+ names_files: true,
489
+ advanced: false,
490
+ danger: true,
491
+ restarts_ui: false,
492
+ preview_command: "orc clear logs",
493
+ // ORC_UI_FIXTURE_CLEAR=empty shows the "nothing is old enough" state.
494
+ preview: process.env.ORC_UI_FIXTURE_CLEAR === "empty" ? clearLogsPreviewEmpty : clearLogsPreview,
495
+ waiting_runs: runs.runs.filter((r) => r.status === "waiting").map((r) => r.slug),
496
+ dirty_tree: false,
497
+ };
446
498
  return {
447
499
  action: q.action,
448
500
  label: "Preview (fixtures)",
@@ -456,7 +508,9 @@ module.exports.get = function get(route, q) {
456
508
  ? "upgrade"
457
509
  : q.action === "update-global"
458
510
  ? "update --global"
459
- : "update"),
511
+ : q.action === "export"
512
+ ? "export"
513
+ : "update"),
460
514
  network: q.action === "upgrade",
461
515
  names_files: q.action === "prune",
462
516
  advanced: q.action === "update-global",
@@ -549,7 +603,16 @@ module.exports.get = function get(route, q) {
549
603
  // outcome is a file on disk, not a state.
550
604
  const TEST_ENV = { "api-users": [1, testEnvUnhealthy], "orders-api": [1, testEnvAbsent], "staging-checkout": [2, testEnvRemote] };
551
605
 
606
+ // The one piece of fixture STATE: which `habits` mode the Behaviour panel sees.
607
+ // Only the `habits` key is canned — every other config write still answers
608
+ // "nothing ran", because its outcome is a file on disk, not a state.
609
+ const HABITS_MODE = { value: "propose" };
610
+
552
611
  module.exports.post = function post(route, body) {
612
+ if (route === "/api/config/set" && body && body.key === "habits" && ["off", "observe", "propose"].includes(String(body.value))) {
613
+ HABITS_MODE.value = String(body.value);
614
+ return { exit_code: 0, data: { ok: true, key: "habits", value: HABITS_MODE.value } };
615
+ }
553
616
  // `add` answers OK so the CONNECT FLOW can be walked end to end in fixture
554
617
  // mode — the add is only the step before the test, and the test's outcome is
555
618
  // the state worth designing. Every other write still answers "nothing ran".
@@ -12,6 +12,7 @@
12
12
  fixture is worse than no fixture. */
13
13
 
14
14
  const { PROJECT } = require("./shell.js");
15
+ const { gotchaExtraEntries, gotchaPanel } = require("./behaviour.js");
15
16
 
16
17
  const wiki = {
17
18
  state: "registered",
@@ -190,8 +191,8 @@ const wikiPlan = {
190
191
  { id: "orientation", cost: "free", cmd: "/orc-wiki refresh wiki/orc-orientation.md", what: "regenerate the derived orientation doc (read first by every consumer)" },
191
192
  ],
192
193
  rows: [
193
- { doc: "wiki/orc-feature-refunds.md", state: "STRUCTURAL", delta: 0, delta_files: [], gone: ["api/refunds/window.ts"], used: 17, used_of: 20, last_used: "2026-08-10", tier: "deep", agent: "orc-wiki-scanner-opus-4-8-high", tier_rule: "structural", tier_why: "STRUCTURAL — a covered file is gone; a targeted refresh cannot re-anchor blind", new_surface: false, estimate: { p50: { input: 8000, cache_write: 40000, cache_read: 69000, output: 21000 }, p90: { input: 11000, cache_write: 58000, cache_read: 99000, output: 30000 }, samples: 7 }, usd: 0.42, retire_hint: false },
194
- { doc: "wiki/orc-feature-payments.md", state: "TOUCHED", delta: 6, delta_files: ["src/payments/ledger.ts", "src/payments/idempotency.ts"], gone: [], used: 14, used_of: 20, last_used: "2026-08-09", tier: "deep", agent: "orc-wiki-scanner-opus-4-8-high", tier_rule: "wide-delta", tier_why: "covered files touched >= wiki_tier_deep_files", new_surface: false, estimate: { p50: { input: 7000, cache_write: 36000, cache_read: 62000, output: 19000 }, p90: { input: 10000, cache_write: 51000, cache_read: 88000, output: 27000 }, samples: 7 }, usd: 0.38, retire_hint: false },
194
+ { doc: "wiki/orc-feature-refunds.md", state: "STRUCTURAL", delta: 0, delta_files: [], gone: ["api/refunds/window.ts"], used: 17, used_of: 20, last_used: "2026-08-10", tier: "deep", agent: "orc-wiki-scanner-opus-5-low", tier_rule: "structural", tier_why: "STRUCTURAL — a covered file is gone; a targeted refresh cannot re-anchor blind", new_surface: false, estimate: { p50: { input: 8000, cache_write: 40000, cache_read: 69000, output: 21000 }, p90: { input: 11000, cache_write: 58000, cache_read: 99000, output: 30000 }, samples: 7 }, usd: 0.42, retire_hint: false },
195
+ { doc: "wiki/orc-feature-payments.md", state: "TOUCHED", delta: 6, delta_files: ["src/payments/ledger.ts", "src/payments/idempotency.ts"], gone: [], used: 14, used_of: 20, last_used: "2026-08-09", tier: "deep", agent: "orc-wiki-scanner-opus-5-low", tier_rule: "wide-delta", tier_why: "covered files touched >= wiki_tier_deep_files", new_surface: false, estimate: { p50: { input: 7000, cache_write: 36000, cache_read: 62000, output: 19000 }, p90: { input: 10000, cache_write: 51000, cache_read: 88000, output: 27000 }, samples: 7 }, usd: 0.38, retire_hint: false },
195
196
  { doc: "wiki/orc-reference-config.md", state: "TOUCHED", delta: 1, delta_files: ["src/config/index.ts"], gone: [], used: 2, used_of: 20, last_used: "2026-07-25", tier: "light", agent: "orc-wiki-scanner-sonnet-5-high", tier_rule: "small-delta", tier_why: "small delta, no new surface", new_surface: false, estimate: { p50: { input: 3000, cache_write: 11000, cache_read: 17000, output: 4000 }, p90: { input: 4000, cache_write: 16000, cache_read: 25000, output: 6000 }, samples: 4 }, usd: 0.06, retire_hint: false },
196
197
  // The zero-use retire candidate. It KEEPS ITS SLOT and renders muted with a
197
198
  // hint — filtering it out would make "unused" and "does not exist" identical.
@@ -251,7 +252,7 @@ const patterns = {
251
252
 
252
253
  const gotchas = {
253
254
  file: PROJECT + "/.claude/orc/gotchas.md",
254
- count: 3,
255
+ count: 11,
255
256
  // v0.49.1: the cap is what makes the count mean anything, and only `prune`
256
257
  // used to print it — so "11 of 40" was not renderable from this payload.
257
258
  gotchas_max: 40,
@@ -262,7 +263,12 @@ const gotchas = {
262
263
  { id: "G-001", area: "express", kind: "repair", hits: 7, last_seen: "05-08-2026", trigger: "Jest suite hangs unless the server handle is closed in afterAll", fields: { trigger: "Jest suite hangs unless the server handle is closed in afterAll", symptom: "`npm test` never exits; CI times out at 10 minutes", fix: "close the http server in afterAll and await it", why: "supertest keeps the listener open, and Jest waits for the handle", first_seen: "14-05-2026", hits: "7", last_seen: "05-08-2026" } },
263
264
  { id: "G-002", area: "react", kind: "review", hits: 2, last_seen: "22-07-2026", trigger: "Date pickers must use the tz-aware helper, never new Date(string)", fields: { trigger: "Date pickers must use the tz-aware helper, never new Date(string)", symptom: "bookings land one day early for users west of UTC", fix: "use parseInZone from src/time/zone.ts", why: "new Date(string) parses as UTC and then renders local", first_seen: "02-06-2026", hits: "2", last_seen: "22-07-2026" } },
264
265
  { id: "G-003", area: "build", kind: "verify", hits: 0, last_seen: "14-06-2026", trigger: "`npm run build` needs NODE_OPTIONS=--max-old-space-size=4096 on CI", fields: { trigger: "`npm run build` needs NODE_OPTIONS=--max-old-space-size=4096 on CI", symptom: "the CI build is OOM-killed with no error line", fix: "set NODE_OPTIONS in the workflow, not in package.json", why: "the runner has less memory than a dev laptop", first_seen: "14-06-2026", hits: "0", last_seen: "14-06-2026" } },
266
+ // v2.0.0 W7 — eight more, so every source and status the Behaviour
267
+ // panel's Gotchas tab draws is designable. They live in behaviour.js.
268
+ ...gotchaExtraEntries,
265
269
  ],
270
+ // v2.0.0 W7 — the panel view `orc gotcha list --json` carries.
271
+ panel: gotchaPanel,
266
272
  };
267
273
 
268
274
  // STALE, so the Flow panel's gated state is designable.
@@ -1,42 +1,123 @@
1
- "use strict";
2
- /* fixtures/maintenance.js — canned data for `orc ui --fixtures`.
3
- The export state and the mocked-example listing.
4
-
5
- THE RULE FOR EVERY FILE IN HERE: carry ONE OF EVERY STATE, including the
6
- ugly ones. You cannot DESIGN a STALE chip on a fresh wiki, and a state
7
- with no fixture is a state nobody has ever looked at. A per-state count
8
- test asserts this, so a new state cannot ship without one.
9
-
10
- Shapes MUST match what `bin/cli.js --json` really emits — a drifted
11
- fixture is worse than no fixture. */
12
-
13
- const { PROJECT } = require("./shell.js");
14
-
15
- const exportState = {
16
- ok: false,
17
- out: PROJECT + "/AGENTS.md",
18
- exists: true,
19
- source_commit: "c273793aa1b4",
20
- sources: 17,
21
- drifted: ["PACT.md", "wiki/orc-feature-payments.md", ".claude/orc/patterns/ts-pattern.md"],
22
- removed: [],
23
- stale: true,
24
- };
25
-
26
- /* ============================================================ v0.47.0 ====== */
27
- /* /orc-challenge. ONE OF EVERY STATE, including the ugly ones — you cannot
28
- design a TAMPERED chip on a healthy cycle, a MISSING-REVISION candidate list
29
- on a cycle whose revision is right where it should be, or a `NOT-CHECKED`
30
- dimension chip on a cycle that has a template. test/webui.test.js asserts one
31
- fixture per state, so a new state cannot ship without one. */
32
-
33
- const mocks = {
34
- root: PROJECT + "/mock-examples",
35
- total: 2,
36
- mocks: [
37
- { slug: "merchant-notifications", dir: PROJECT + "/mock-examples/merchant-notifications", mtime_ms: Date.now() - 40 * 60 * 1000, has_readme: true },
38
- { slug: "invoice-pdf-export", dir: PROJECT + "/mock-examples/invoice-pdf-export", mtime_ms: Date.now() - 5 * 24 * 60 * 60 * 1000, has_readme: false },
39
- ],
40
- };
41
-
42
- module.exports = { exportState, mocks };
1
+ "use strict";
2
+ /* fixtures/maintenance.js — canned data for `orc ui --fixtures`.
3
+ The export state and the mocked-example listing.
4
+
5
+ THE RULE FOR EVERY FILE IN HERE: carry ONE OF EVERY STATE, including the
6
+ ugly ones. You cannot DESIGN a STALE chip on a fresh wiki, and a state
7
+ with no fixture is a state nobody has ever looked at. A per-state count
8
+ test asserts this, so a new state cannot ship without one.
9
+
10
+ Shapes MUST match what `bin/cli.js --json` really emits — a drifted
11
+ fixture is worse than no fixture. */
12
+
13
+ const { PROJECT } = require("./shell.js");
14
+
15
+ const exportState = {
16
+ ok: false,
17
+ out: PROJECT + "/AGENTS.md",
18
+ exists: true,
19
+ source_commit: "c273793aa1b4",
20
+ sources: 17,
21
+ drifted: ["PACT.md", "wiki/orc-feature-payments.md", ".claude/orc/patterns/ts-pattern.md"],
22
+ removed: [],
23
+ stale: true,
24
+ };
25
+
26
+ /* ============================================================ v0.47.0 ====== */
27
+ /* /orc-challenge. ONE OF EVERY STATE, including the ugly ones — you cannot
28
+ design a TAMPERED chip on a healthy cycle, a MISSING-REVISION candidate list
29
+ on a cycle whose revision is right where it should be, or a `NOT-CHECKED`
30
+ dimension chip on a cycle that has a template. test/webui.test.js asserts one
31
+ fixture per state, so a new state cannot ship without one. */
32
+
33
+ const mocks = {
34
+ root: PROJECT + "/mock-examples",
35
+ total: 2,
36
+ mocks: [
37
+ { slug: "merchant-notifications", dir: PROJECT + "/mock-examples/merchant-notifications", mtime_ms: Date.now() - 40 * 60 * 1000, has_readme: true },
38
+ { slug: "invoice-pdf-export", dir: PROJECT + "/mock-examples/invoice-pdf-export", mtime_ms: Date.now() - 5 * 24 * 60 * 60 * 1000, has_readme: false },
39
+ ],
40
+ };
41
+
42
+ /* ============================================================ v2.1.0 W7 ==== */
43
+ /* `orc clear logs`. The summary is `--summary --json` (no scan); the preview
44
+ is the print mode's `--json`. ONE OF EVERY STATE the renderer draws: a trace
45
+ set, a leftover, a closed run with its git ref, a done run whose ref is
46
+ already gone, every keep reason, the moved cutoff, and the old default
47
+ folder. `ORC_UI_FIXTURE_CLEAR=empty` gives the nothing-to-delete preview. */
48
+
49
+ const clearLogsSummary = {
50
+ ok: true,
51
+ older_than_days: 30,
52
+ auto: "on",
53
+ last_sweep: { date: "2026-10-02", at: Date.now() - 3 * 60 * 60 * 1000, files: 41, bytes: 309112, older_than_days: 60 },
54
+ last_apply: null,
55
+ pruned_runs: 17,
56
+ rollup: ".claude/orc/logs-rollup.json",
57
+ };
58
+
59
+ const L = ".claude/orc/traces/";
60
+ const R = ".claude/orc/run/";
61
+ const clearLogsPreview = {
62
+ ok: true,
63
+ applied: false,
64
+ older_than_days: 30,
65
+ effective_days: 60,
66
+ cutoff: "2026-08-03",
67
+ cutoff_moved: { from: 30, to: 60, reason: "aftermath_window_days" },
68
+ log_dir: ".claude/orc/traces",
69
+ run_dir: ".claude/orc/run",
70
+ delete: [
71
+ {
72
+ path: L + "run-mini-order-store-extract-150626-192929.txt",
73
+ kind: "trace",
74
+ last_activity: "2026-06-15T20:04:11",
75
+ dated_by: "line stamp",
76
+ bytes: 9214,
77
+ files: [L + "run-mini-order-store-extract-150626-192929.txt", L + "run-mini-order-store-extract-150626-192929.txt.jsonl", L + "run-mini-order-store-extract-150626-192929.txt.pending.json"],
78
+ },
79
+ { path: L + "run-300626-005724.txt.superseded", kind: "leftover", last_activity: "2026-06-30T00:57:24", dated_by: "name stamp", bytes: 5830, files: [L + "run-300626-005724.txt.superseded"] },
80
+ {
81
+ path: R + "orders-cancel-endpoint/",
82
+ kind: "run",
83
+ status: "closed",
84
+ ref: "refs/orc/runs/orders-cancel-endpoint/pre",
85
+ last_activity: "2026-07-02T11:40:00",
86
+ dated_by: "mtime",
87
+ bytes: 22410,
88
+ files: [R + "orders-cancel-endpoint/RESUME.closed.md", R + "orders-cancel-endpoint/closed.json", R + "orders-cancel-endpoint/checkpoint.json", R + "orders-cancel-endpoint/snapshot.json"],
89
+ },
90
+ { path: R + "health-endpoint/", kind: "run", status: "done", ref: null, last_activity: "2026-06-20T09:12:45", dated_by: "mtime", bytes: 4096, files: [R + "health-endpoint/checkpoint.json"] },
91
+ ],
92
+ keep: [
93
+ { path: L + ".current", reason: "the active-run pointer — never touched" },
94
+ { path: L + "run-orc-orders-users-get-by-id-auth-011026-091500.txt", reason: "the active run — `.current` names it" },
95
+ { path: L + "run-quick-version-route-020926-101500.txt", reason: "holds habit answers (younger than 180 days)" },
96
+ { path: L + "run-fast-health-endpoint-210926-143000.txt", reason: "younger than 60 days (last activity 2026-09-21T14:41:09)" },
97
+ { path: L + "run-verify-cancel-endpoint-tree-021026-071000.txt", reason: "changed less than 6 hours ago — a run may still write to it" },
98
+ { path: L + "retro/", reason: "retro/ holds /orc-retro reports (deliverables) — never touched" },
99
+ { path: L + "habits-state.json", reason: "user data — never deleted" },
100
+ { path: R + "add-version-route/", reason: "a waiting run (RESUME.md, no RESUME.closed.md) — never touched" },
101
+ { path: R + "orders-search-endpoint/", reason: "a wait is armed (wait.json) — never touched" },
102
+ ],
103
+ totals: { units: 4, files: 9, bytes: 41550 },
104
+ default_dir: { path: ".claude/orc/logs", files: 132, bytes: 784384, included: false },
105
+ notes: [
106
+ "The cutoff moved from 30 to 60 days: aftermath_window_days is 60, and /orc-aftermath grades that window.",
107
+ "The old default folder .claude/orc/logs still holds 132 file(s) (766.0 KB). No reader sees it. Add --include-default-dir to clear it with the same rules.",
108
+ ],
109
+ };
110
+
111
+ const clearLogsPreviewEmpty = Object.assign({}, clearLogsPreview, {
112
+ older_than_days: 90,
113
+ effective_days: 90,
114
+ cutoff: "2026-07-04",
115
+ cutoff_moved: null,
116
+ delete: [],
117
+ keep: clearLogsPreview.keep.slice(0, 4),
118
+ totals: { units: 0, files: 0, bytes: 0 },
119
+ default_dir: null,
120
+ notes: [],
121
+ });
122
+
123
+ module.exports = { exportState, mocks, clearLogsSummary, clearLogsPreview, clearLogsPreviewEmpty };