@haposoft/cafekit 0.16.7 → 0.18.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 (193) hide show
  1. package/README.md +14 -22
  2. package/bin/__tests__/codex-hooks-ownership.test.js +2 -2
  3. package/bin/__tests__/codex-hooks.test.js +0 -36
  4. package/bin/__tests__/codex-native.test.js +46 -88
  5. package/bin/__tests__/develop-contract.test.js +26 -57
  6. package/bin/__tests__/docs-sync-on-demand.test.js +93 -0
  7. package/bin/__tests__/grok-envelope.test.js +0 -56
  8. package/bin/__tests__/hook-payload.test.js +4 -6
  9. package/bin/__tests__/legacy-authority-decoupled.test.js +159 -0
  10. package/bin/__tests__/legacy-hooks-retired.test.js +221 -0
  11. package/bin/__tests__/omp-bridge.test.js +20 -17
  12. package/bin/__tests__/omp-hooks.test.js +0 -19
  13. package/bin/__tests__/optional-skill-inventory.test.js +112 -4
  14. package/bin/__tests__/orca-session.test.js +0 -2
  15. package/bin/__tests__/package-inventory.test.js +100 -541
  16. package/bin/__tests__/runtime-dir.test.js +0 -3
  17. package/bin/__tests__/runtime-schema.test.js +3 -2
  18. package/bin/__tests__/skill-routing-source.test.js +27 -15
  19. package/bin/__tests__/spec-narrowing.test.js +0 -27
  20. package/bin/__tests__/specs-v2-execution-closeout.test.js +4 -69
  21. package/bin/__tests__/ui-ux-skill.test.js +101 -0
  22. package/bin/__tests__/usage-hook-retired.test.js +114 -0
  23. package/bin/__tests__/validator-grounding.test.js +9 -28
  24. package/bin/phases/codex-runtime.js +24 -0
  25. package/bin/phases/omp-runtime.js +22 -0
  26. package/package.json +1 -1
  27. package/src/claude/CLAUDE.md +3 -10
  28. package/src/claude/agents/brainstormer.md +7 -3
  29. package/src/claude/agents/code-auditor.md +35 -50
  30. package/src/claude/agents/debugger.md +5 -79
  31. package/src/claude/agents/deployer.md +3 -5
  32. package/src/claude/agents/docs-keeper.md +2 -7
  33. package/src/claude/agents/implementer.md +6 -9
  34. package/src/claude/agents/inspector.md +2 -3
  35. package/src/claude/agents/project-manager.md +7 -15
  36. package/src/claude/agents/researcher.md +9 -3
  37. package/src/claude/agents/spec-maker.md +11 -11
  38. package/src/claude/hooks/__tests__/fixtures/statusline-default.golden +1 -1
  39. package/src/claude/hooks/__tests__/spec-gate.test.js +74 -3
  40. package/src/claude/hooks/__tests__/spec-state-touched.test.js +134 -0
  41. package/src/claude/hooks/__tests__/state.test.js +68 -0
  42. package/src/claude/hooks/__tests__/statusline.test.js +140 -11
  43. package/src/claude/hooks/agent.cjs +2 -1
  44. package/src/claude/hooks/lib/context.cjs +0 -89
  45. package/src/claude/hooks/lib/hook-payload.cjs +2 -2
  46. package/src/claude/hooks/rules.cjs +2 -1
  47. package/src/claude/hooks/session.cjs +0 -1
  48. package/src/claude/hooks/spec-gate.cjs +17 -28
  49. package/src/claude/hooks/spec-state.cjs +95 -1
  50. package/src/claude/hooks/state.cjs +21 -2
  51. package/src/claude/migration-manifest.json +30 -15
  52. package/src/claude/rules/ai-dev-rules.md +1 -1
  53. package/src/claude/rules/hook-protocols.md +8 -15
  54. package/src/claude/rules/manage-docs.md +9 -23
  55. package/src/claude/rules/orchestrator.md +3 -4
  56. package/src/claude/rules/review-audit-self-decision.md +3 -3
  57. package/src/claude/rules/skill-domain-routing.md +1 -3
  58. package/src/claude/rules/skill-workflow-routing.md +4 -5
  59. package/src/claude/rules/state-sync.md +3 -12
  60. package/src/claude/rules/workflow.md +10 -18
  61. package/src/claude/runtime.schema.json +5 -3
  62. package/src/claude/scripts/generate-skill-catalog.cjs +7 -6
  63. package/src/claude/scripts/provenance.cjs +23 -5
  64. package/src/claude/scripts/spec-receipt.cjs +24 -7
  65. package/src/claude/scripts/spec-resolver.cjs +1 -2
  66. package/src/claude/scripts/validate-spec-output.cjs +5 -32
  67. package/src/claude/settings/settings.json +1 -32
  68. package/src/claude/skills/{question → ask}/SKILL.md +9 -75
  69. package/src/claude/skills/brainstorm/SKILL.md +43 -131
  70. package/src/claude/skills/code-review/SKILL.md +48 -17
  71. package/src/claude/skills/code-review/references/spec-compliance-review.md +2 -3
  72. package/src/claude/skills/code-review/references/verification-gate.md +22 -27
  73. package/src/claude/skills/debug/SKILL.md +29 -149
  74. package/src/claude/skills/develop/SKILL.md +27 -36
  75. package/src/claude/skills/develop/references/parallel-waves.md +0 -8
  76. package/src/claude/skills/develop/references/quality-gate.md +15 -13
  77. package/src/claude/skills/docs/SKILL.md +2 -2
  78. package/src/claude/skills/docs/references/update-workflow.md +1 -1
  79. package/src/claude/skills/fix/SKILL.md +153 -0
  80. package/src/claude/skills/{hotfix → fix}/references/diagnosis-protocol.md +2 -2
  81. package/src/claude/skills/{hotfix → fix}/references/parallel-patterns.md +2 -2
  82. package/src/claude/skills/{hotfix → fix}/references/prevention-gate.md +3 -3
  83. package/src/claude/skills/{hotfix → fix}/references/review-cycle.md +1 -1
  84. package/src/claude/skills/git/SKILL.md +48 -9
  85. package/src/claude/skills/git/references/commit-protocols.md +35 -16
  86. package/src/claude/skills/git/references/worktree-blueprint.md +42 -6
  87. package/src/claude/skills/orca/SKILL.md +9 -8
  88. package/src/claude/skills/research/SKILL.md +2 -0
  89. package/src/claude/skills/scout/SKILL.md +61 -0
  90. package/src/claude/skills/{inspect → scout}/references/internal-inspection.md +26 -10
  91. package/src/claude/skills/specs/SKILL.md +22 -29
  92. package/src/claude/skills/specs/references/review.md +8 -6
  93. package/src/claude/skills/specs/references/templates.md +34 -41
  94. package/src/claude/skills/sync/SKILL.md +8 -15
  95. package/src/claude/skills/sync/references/rebind-and-audit.md +59 -0
  96. package/src/claude/skills/sync/references/sync-protocols.md +4 -13
  97. package/src/claude/skills/test/SKILL.md +22 -3
  98. package/src/claude/skills/test/references/execution-strategy.md +83 -0
  99. package/src/claude/skills/test/references/failure-triage.md +1 -1
  100. package/src/claude/skills/ui-ux/LICENSE +21 -0
  101. package/src/claude/skills/ui-ux/SKILL.md +497 -0
  102. package/src/claude/skills/ui-ux/references/brand-tokens.md +90 -0
  103. package/src/claude/skills/ui-ux/references/budgets.md +113 -0
  104. package/src/claude/skills/ui-ux/references/checklist.md +271 -0
  105. package/src/claude/skills/ui-ux/references/components/accordion.md +246 -0
  106. package/src/claude/skills/ui-ux/references/components/avatar.md +153 -0
  107. package/src/claude/skills/ui-ux/references/components/banner.md +43 -0
  108. package/src/claude/skills/ui-ux/references/components/breadcrumb.md +201 -0
  109. package/src/claude/skills/ui-ux/references/components/button.md +142 -0
  110. package/src/claude/skills/ui-ux/references/components/card.md +113 -0
  111. package/src/claude/skills/ui-ux/references/components/charts.md +376 -0
  112. package/src/claude/skills/ui-ux/references/components/chat.md +132 -0
  113. package/src/claude/skills/ui-ux/references/components/choice-controls.md +369 -0
  114. package/src/claude/skills/ui-ux/references/components/comment-thread.md +17 -0
  115. package/src/claude/skills/ui-ux/references/components/description-list.md +116 -0
  116. package/src/claude/skills/ui-ux/references/components/empty-state.md +98 -0
  117. package/src/claude/skills/ui-ux/references/components/file-upload.md +107 -0
  118. package/src/claude/skills/ui-ux/references/components/inline-edit.md +128 -0
  119. package/src/claude/skills/ui-ux/references/components/input.md +161 -0
  120. package/src/claude/skills/ui-ux/references/components/list-row.md +56 -0
  121. package/src/claude/skills/ui-ux/references/components/loading.md +198 -0
  122. package/src/claude/skills/ui-ux/references/components/logo.md +147 -0
  123. package/src/claude/skills/ui-ux/references/components/otp-input.md +43 -0
  124. package/src/claude/skills/ui-ux/references/components/quantity-input.md +100 -0
  125. package/src/claude/skills/ui-ux/references/components/range-slider.md +16 -0
  126. package/src/claude/skills/ui-ux/references/components/small-controls.md +340 -0
  127. package/src/claude/skills/ui-ux/references/components/sortable-header.md +86 -0
  128. package/src/claude/skills/ui-ux/references/components/tag-input.md +14 -0
  129. package/src/claude/skills/ui-ux/references/components/timeline.md +38 -0
  130. package/src/claude/skills/ui-ux/references/components/tree.md +30 -0
  131. package/src/claude/skills/ui-ux/references/design-process.md +650 -0
  132. package/src/claude/skills/ui-ux/references/layouts/app-kanban.html +303 -0
  133. package/src/claude/skills/ui-ux/references/layouts/app.md +1369 -0
  134. package/src/claude/skills/ui-ux/references/layouts/form.md +430 -0
  135. package/src/claude/skills/ui-ux/references/layouts/overlay.md +552 -0
  136. package/src/claude/skills/ui-ux/references/layouts/pricing.md +204 -0
  137. package/src/claude/skills/ui-ux/references/locked-rules.md +35 -0
  138. package/src/claude/skills/ui-ux/references/principles.md +408 -0
  139. package/src/claude/skills/ui-ux/references/refactor.md +245 -0
  140. package/src/claude/skills/ui-ux/references/responsive.md +195 -0
  141. package/src/claude/skills/ui-ux/references/review.md +528 -0
  142. package/src/claude/skills/ui-ux/references/rules-color.md +623 -0
  143. package/src/claude/skills/ui-ux/references/rules-form.md +235 -0
  144. package/src/claude/skills/ui-ux/references/rules-state.md +680 -0
  145. package/src/claude/skills/ui-ux/references/rules-type.md +369 -0
  146. package/src/claude/skills/ui-ux/references/styles.md +311 -0
  147. package/src/claude/skills/ui-ux/references/system.md +219 -0
  148. package/src/claude/skills/ui-ux/references/tailwind-v4-traps.md +237 -0
  149. package/src/claude/skills/ui-ux/references/tokens.css +362 -0
  150. package/src/claude/skills/ui-ux/scripts/lint-skill.mjs +216 -0
  151. package/src/claude/skills/ui-ux/scripts/package.json +9 -0
  152. package/src/claude/skills/ui-ux/scripts/probe.mjs +4447 -0
  153. package/src/claude/skills/ui-ux-pro-max/SKILL.md +1 -1
  154. package/src/claude/status.cjs +149 -144
  155. package/src/codex/AGENTS.md +8 -13
  156. package/src/codex/hooks/agent.cjs +2 -1
  157. package/src/codex/hooks/lib/spec-receipt.cjs +2 -2
  158. package/src/codex/hooks/lib/spec-utils.cjs +0 -7
  159. package/src/codex/hooks/rules.cjs +2 -1
  160. package/src/codex/hooks/session.cjs +0 -2
  161. package/src/codex/hooks/spec-gate.cjs +7 -18
  162. package/src/codex/hooks.json +0 -20
  163. package/src/codex/rules/state-sync.md +3 -12
  164. package/src/common/AGENTS.md +2 -2
  165. package/src/omp/extensions/cafekit-bridge.mjs +6 -6
  166. package/src/claude/hooks/__tests__/completion-authority.test.js +0 -990
  167. package/src/claude/hooks/__tests__/semantic-review-authority.test.js +0 -259
  168. package/src/claude/hooks/completion-authority-check.cjs +0 -56
  169. package/src/claude/hooks/completion-authority-state.cjs +0 -527
  170. package/src/claude/hooks/completion-authority.cjs +0 -163
  171. package/src/claude/hooks/semantic-review-authority.cjs +0 -154
  172. package/src/claude/hooks/task-scaffold-guard.cjs +0 -114
  173. package/src/claude/hooks/usage.cjs +0 -197
  174. package/src/claude/skills/delegate/SKILL.md +0 -124
  175. package/src/claude/skills/delegate/references/codex-delegation.md +0 -71
  176. package/src/claude/skills/delegate/references/grok-delegation.md +0 -84
  177. package/src/claude/skills/hotfix/SKILL.md +0 -289
  178. package/src/claude/skills/inspect/SKILL.md +0 -142
  179. package/src/claude/skills/loop/SKILL.md +0 -114
  180. package/src/claude/skills/loop/references/bounded-loop-protocol.md +0 -104
  181. package/src/claude/skills/loop/references/metric-and-guard-contract.md +0 -76
  182. package/src/claude/skills/route/SKILL.md +0 -94
  183. package/src/claude/skills/route/references/agent-timing.md +0 -46
  184. package/src/claude/skills/route/references/chaining-patterns.md +0 -53
  185. package/src/claude/skills/route/references/task-taxonomy.md +0 -48
  186. package/src/codex/hooks/completion-authority-check.cjs +0 -67
  187. package/src/codex/hooks/completion-authority-state.cjs +0 -527
  188. package/src/codex/hooks/completion-authority.cjs +0 -109
  189. package/src/codex/hooks/semantic-review-authority.cjs +0 -130
  190. package/src/codex/hooks/task-scaffold-guard.cjs +0 -63
  191. /package/src/claude/skills/{question → ask}/templates/question.md +0 -0
  192. /package/src/claude/skills/{hotfix → fix}/references/escalation-tactics.md +0 -0
  193. /package/src/claude/skills/{hotfix → fix}/references/workflow-specialized.md +0 -0
@@ -1,104 +0,0 @@
1
- # Bounded Loop protocol
2
-
3
- This is a cooperative instruction contract, not a sandbox or a production
4
- runtime. Live-agent adherence remains `[UNPROVEN]` until separately observed.
5
-
6
- ## Run identity and filesystem boundary
7
-
8
- 1. Resolve the repository root and pinned base OID without changing checkout.
9
- 2. Capture primary tracked and untracked status. Reject any dirty path that is
10
- inside Scope; never import, stash, clean, or overwrite primary dirt.
11
- 3. Create a unique temp directory using the platform's secure temp API. Resolve
12
- its lexical and canonical path, require it outside the repository, and refuse
13
- a symlink, pre-existing reused run path, broad root, or ownership ambiguity.
14
- 4. Write an ownership marker containing a random run ID, base OID, canonical
15
- root, and creation time. Acquire one exclusive run lock; contention blocks.
16
- 5. With upfront consent for this exact path, use `git worktree add --detach`
17
- against the pinned OID. Do not use `-b`, create refs, or commit.
18
-
19
- Every later path must be a lexical and canonical descendant of the owned root.
20
- Reject `..`, symlink traversal, mount redirection, absolute external targets,
21
- submodules, and paths that changed identity after validation.
22
-
23
- ## Command trust and screening
24
-
25
- Commands are supplied or already owned by the trusted repository/user. Record
26
- the separately trusted/allowlisted executable realpath (which may be outside the
27
- worktree), argv, fixed cwd, timeout, output limit, and allowlisted
28
- environment before execution. Do not pass secrets; redact credentials, tokens,
29
- cookies, authorization headers, PII, and secret-looking patch lines from reports.
30
-
31
- Refuse general shell evaluation, inline code flags, Git external targeting
32
- (`-C`, `--git-dir`, `--work-tree`), destructive Git (`reset --hard`, `clean`,
33
- branch/ref deletion), recursive deletion, privilege escalation, deploy/publish,
34
- and any path-valued target argument that resolves outside the detached root,
35
- including response/config/output targets. Do not apply the target-path rule to
36
- the separately approved executable itself. A trusted script file may run through
37
- its declared interpreter, but inline `-c`, `-e`, `--eval`, and equivalent dynamic
38
- code are forbidden.
39
-
40
- This screening reduces mistakes; it cannot contain arbitrary side effects from
41
- a malicious or compromised executable. If that threat is material, return
42
- `BLOCKED` and require an OS sandbox outside this skill's scope.
43
-
44
- ## Iteration lifecycle
45
-
46
- - Revalidate base OID, primary status, contract digests, lock, ownership marker,
47
- and canonical roots before every iteration.
48
- - Build a new never-reused detached worktree from pinned base plus the current
49
- accepted-best tracked-text patch. Do not repair a rejected candidate in place.
50
- - Capture a complete Scope manifest of path, type, mode, size, and SHA-256 before
51
- mutation; lstat paths and reject symlink/type/identity changes.
52
- - Permit one hypothesis patch. Its post-change manifest must be contained in
53
- Scope and attributable to that hypothesis.
54
- - Capture the complete detached-worktree tracked/untracked fingerprint around
55
- every Metric and Guard command. Subtract only exact immutable cache paths
56
- frozen at preflight; every other oracle-created file or byte/mode/type/path
57
- change, inside or outside Scope, rejects the candidate as drift.
58
- - Record command exit/signal/timeout, bounded redacted output, raw finite samples,
59
- median/noise, Guard verdict, patch digest, and keep/discard reason.
60
-
61
- Parallel iterations are forbidden: one run, one lock, one candidate at a time.
62
- An external source/base/contract change stops the run; it never triggers an
63
- automatic rebase, new baseline, threshold change, or wider Scope.
64
-
65
- ## Process-tree timeout and cancellation
66
-
67
- Spawn a new process group on POSIX or Job Object on Windows. On timeout or user
68
- cancellation, stop scheduling, terminate the whole tree, wait the frozen grace
69
- period, escalate to kill, reap, and verify no owned descendant remains. The run
70
- path is permanently retired after timeout.
71
-
72
- If the platform cannot own/observe descendants, termination fails, a process
73
- survives, or quiescence cannot be proven, do not clean. Preserve the exact path,
74
- PID/process evidence, and ownership marker; return `BLOCKED` for operator action.
75
-
76
- ## Cleanup and recovery
77
-
78
- Clean only a canonical path whose run ID, lock, marker, base OID, and inode/path
79
- identity still match the run and whose process tree is quiescent. Release the
80
- detached worktree through Git, then remove only that exact temp root using the
81
- pre-approved cleanup action. Never broaden a glob or follow a symlink.
82
-
83
- No `git reset --hard`, `git clean`, force checkout, stash, branch deletion,
84
- primary-index edit, or unrelated recovery is permitted. Cleanup uncertainty is
85
- a retained residue plus `BLOCKED`, not a reason to become more destructive.
86
-
87
- ## Patch handoff
88
-
89
- Default handoff supports tracked regular UTF-8 text files only. Generate a
90
- reviewable unified patch against the pinned base, then bind:
91
-
92
- - `base_oid`;
93
- - sorted complete Scope manifest before/after with file SHA-256;
94
- - patch byte length and lowercase SHA-256;
95
- - Metric/Guard contract digests and evidence;
96
- - accepted/rejected iteration ledger and stop reason;
97
- - secret/redaction scan result;
98
- - mode: inline ephemeral, or exact approved external path;
99
- - creation time, retention/expiry, cleanup owner, and application authority.
100
-
101
- Reject missing/untracked/binary/symlink/submodule/secret-bearing/incomplete or
102
- stale patch bytes. Never store the artifact in the primary worktree implicitly.
103
- Never apply or commit it. A later authorized workflow revalidates base, patch,
104
- tests, review, and current repository state before application.
@@ -1,76 +0,0 @@
1
- # Metric and Guard contract
2
-
3
- Freeze this contract before mutation. If any field changes, stop for drift; do
4
- not silently recompute the baseline under new rules.
5
-
6
- ## Required Metric fields
7
-
8
- - `argv`: nonempty trusted argv vector; no shell string.
9
- - `cwd`: canonical detached worktree root, fixed by Loop.
10
- - `unit`: one nonempty unit label.
11
- - `direction`: exactly `higher` or `lower`.
12
- - `sample_count`: integer at least 3, identical for baseline and candidates.
13
- - `timeout_ms`: positive integer per sample.
14
- - `minimum_delta`: finite nonnegative number in the declared unit.
15
- - `numeric_format`: exactly IEEE-754 binary64, roundTiesToEven after every
16
- operation, with negative zero normalized to positive zero.
17
- - `environment`: fixed allowlisted names and redacted non-secret values; no
18
- inherited credential or mutable random/time seed unless explicitly frozen.
19
-
20
- Each successful sample must emit exactly one trimmed UTF-8 line matching
21
- `^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$`. Reject empty,
22
- multi-line, multi-value, `NaN`, `Infinity`, unit-suffixed, nonzero exit, signaled,
23
- or timed-out output. Parse to a finite number without locale-dependent separators.
24
- Reject a decimal with a nonzero significand when binary64 parsing underflows it
25
- to zero.
26
-
27
- ## Fixed calculation
28
-
29
- For each sample set:
30
-
31
- 1. Sort binary64 values and calculate the median. For an even count with central
32
- values `lower <= upper`, use `lower + (upper - lower) / 2` when both have the
33
- same sign (zero may join either sign); otherwise use
34
- `lower / 2 + upper / 2`. Apply binary64 roundTiesToEven after every operation
35
- and normalize negative zero to positive zero.
36
- 2. Calculate noise as the maximum absolute distance from that median.
37
- 3. For `higher`, improvement is `candidate_median - best_median`; for `lower`,
38
- improvement is `best_median - candidate_median`.
39
- 4. Calculate `required_delta = max(minimum_delta, best_noise + candidate_noise)`.
40
- 5. Accept only when `improvement > required_delta` and Guard passes on the exact
41
- candidate bytes. Equality is not an improvement.
42
-
43
- After every operation, require median, noise, improvement, and required delta to
44
- remain finite. A parsed nonzero value that became zero, an overflow, or a
45
- non-finite derived value blocks the baseline or rejects the candidate; never
46
- store it as current best. A rounded zero produced by subtraction is handled
47
- conservatively as no improvement, never as a win.
48
-
49
- The initial current best is the pinned baseline. Keep the accepted candidate's
50
- median and noise as the next current best. Never compare a candidate against an
51
- older, more favorable baseline or select one sample from a noisy set.
52
-
53
- ## Guard independence
54
-
55
- For code mutation, Guard is mandatory, fixed before baseline, and distinct from
56
- Metric. It must validate correctness beyond the optimized outcome—for example a
57
- relevant real test command, typecheck, or invariant checker. A second invocation
58
- of Metric, a threshold over the same output, or an oracle the loop may edit is
59
- not an independent Guard.
60
-
61
- Run Guard after Metric on the identical candidate fingerprint. Guard passes only
62
- with its predeclared literal exit/oracle and zero required skips; `NO_TESTS`,
63
- warning-only, partial, flaky-history waiver, or changed Guard bytes do not pass.
64
- Metric and Guard may create disposable caches only at exact predeclared paths.
65
- Snapshot the complete detached-worktree tracked/untracked state around each
66
- oracle, subtract only that fixed cache allowlist, and treat every other byte,
67
- mode, type, or path mutation—including outside Scope—as drift.
68
-
69
- ## Reproducibility and drift
70
-
71
- Record tool versions, immutable Metric/Guard/test/benchmark/dataset digests,
72
- fixed inputs/data digest, relevant configuration digest,
73
- base OID, scoped byte manifest digest, and environment fingerprint. Stop when any
74
- of them changes. Report variance and raw sample values; do not hide outliers or
75
- retry only bad samples. A failed sample rejects the candidate rather than being
76
- dropped from aggregation.
@@ -1,94 +0,0 @@
1
- ---
2
- name: cf:route
3
- description: "Route ambiguous, multi-step, multi-domain, or risk-elevated work through the shortest valid chain of installed CafeKit skills and agents."
4
- user-invocable: true
5
- when_to_use: "Use when no single obvious installed skill covers the request; skip for an explicitly named skill, one clear low-risk intent, or a direct factual answer."
6
- category: utilities
7
- keywords: [routing, workflow, orchestration, delegation, risk]
8
- argument-hint: "<task>"
9
- metadata:
10
- author: haposoft
11
- version: "1.0.0"
12
- ---
13
- # Route — proportional native routing
14
-
15
- Choose the shortest valid path through capabilities that are installed now.
16
- Route is a decision layer: it classifies, composes, and hands off; each selected
17
- skill or agent still owns its domain contract and evidence.
18
-
19
- ## 1. Proportional gate
20
-
21
- Apply these exits before discovery, classification, or delegation:
22
-
23
- 1. **Explicit installed skill:** when the user names a valid installed skill,
24
- invoke that skill directly. Do not reclassify it or add routing ceremony.
25
- 2. **One obvious intent:** when exactly one installed skill clearly covers a
26
- low-risk request, use it directly without constructing a chain.
27
- 3. **Direct factual conversation:** answer a factual question directly, or use
28
- the installed evidence-answering skill when repository or current evidence is
29
- needed. Do not create a route chain or spawn agents merely to answer it.
30
- 4. Continue in Route only for ambiguity, multiple dependent steps, multiple
31
- domains, elevated/high risk, or no obvious installed capability.
32
-
33
- An explicitly named capability that is absent, invalid, duplicate, ambiguous,
34
- or retired is not an installed route. Name the gap; do not invent a substitute
35
- with broader authority.
36
-
37
- ## 2. Classify material work
38
-
39
- Load `references/task-taxonomy.md`. Record exactly one class based on the final
40
- deliverable, then record size (`trivial | standard | epic`), the highest-link
41
- risk (`low | elevated | high`), and the number of material domains. Never
42
- average risk down across links.
43
-
44
- Use the runtime's live installed skill and agent catalogs. Never synthesize a
45
- skill, agent, command, or optional bundle from examples in these instructions.
46
- If inventory is unavailable, use only capabilities the runtime visibly exposes;
47
- otherwise name the capability gap and keep the path inline where safe.
48
-
49
- ## 3. Compose the shortest valid chain
50
-
51
- Load `references/chaining-patterns.md` only when two or more links are required.
52
- Start from `understand -> decide -> execute -> verify -> deliver`, remove every
53
- link whose output is already evidenced, and add a link only when a modifier
54
- requires it. Every retained link has an entry condition, an observable exit
55
- artifact, and exactly one owner.
56
-
57
- Prefer the user-named skill, then the narrowest domain skill, then a generic
58
- workflow skill. One intent has one primary skill. Supporting skills may produce
59
- inputs for it but may not compete for ownership.
60
-
61
- ## 4. Agents and risk gates
62
-
63
- Load `references/agent-timing.md` only when delegation may materially improve
64
- fresh context, specialization, tool isolation, or safe parallel work. Discover
65
- agents from the current runtime; if the preferred agent is missing, continue
66
- inline when safe or return the named gap. Never synthesize an unavailable agent.
67
-
68
- - `low`: the owning link's normal proof is sufficient.
69
- - `elevated`: add explicit verification appropriate to the changed surface.
70
- - `high`: require independent review and user confirmation before advancing
71
- past the high-risk gate. When an irreversible or external action is present,
72
- obtain that confirmation immediately before the action.
73
-
74
- ## 5. Authority is monotonic
75
-
76
- The route may narrow user authority but never expand it. Read-only stays
77
- read-only; diagnosis does not authorize repair; implementation does not
78
- authorize commit, push, deploy, publish, or release; local work does not
79
- authorize an external action. Stop before any mutation or delivery link that
80
- the user did not already authorize and state what authority is missing.
81
-
82
- ## 6. Return and handoff
83
-
84
- Return a compact route record before the first material handoff:
85
-
86
- ```text
87
- Route: <class> | size=<trivial|standard|epic> | risk=<low|elevated|high> | domains=<n>
88
- Chain: <owner: entry -> exit> [-> ...]
89
- Gates: <authority, verification, confirmation, or named gap>
90
- ```
91
-
92
- Do not claim that source text or installed projection proves live-model
93
- adherence. That behavior remains `[UNPROVEN]` until a separate host run observes
94
- it.
@@ -1,46 +0,0 @@
1
- # Agent timing
2
-
3
- Delegation is optional acceleration, not a mandatory stage. Keep work inline
4
- when it is small, tightly coupled, dependent on shared evolving context, or no
5
- installed specialist offers a material advantage.
6
-
7
- Delegate only when at least one trigger is evidenced:
8
-
9
- - a specialist needs fresh isolated context;
10
- - a distinct tool or runtime boundary must be owned separately;
11
- - two or more scopes are genuinely independent and can run in parallel;
12
- - an independent reviewer or tester is required by risk.
13
-
14
- Discover the current runtime's installed agent catalog before delegation. Use
15
- Claude-native agent types in Claude Code and Codex-native agents/subagents in
16
- Codex. If the preferred agent is absent, do the work inline when safe or name
17
- the gap and stop; never synthesize a role or pretend delegation occurred.
18
-
19
- ## Delegation brief
20
-
21
- Every delegated link receives exactly these seven fields:
22
-
23
- 1. **Outcome** — observable result.
24
- 2. **Scope** — owned files, systems, or questions.
25
- 3. **Inputs** — current evidence and prerequisite artifacts.
26
- 4. **Constraints** — safety, compatibility, authority, and non-goals.
27
- 5. **Acceptance** — proof required for completion.
28
- 6. **Handoff** — expected returned artifact and destination.
29
- 7. **Status vocabulary** — `DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT`.
30
-
31
- Parallel delegates require disjoint write ownership and no hidden dependency.
32
- The controller reconciles their outputs and remains responsible for route state;
33
- an agent never gains commit, push, deploy, publish, release, or other mutation
34
- authority from delegation alone.
35
-
36
- ## Status handling
37
-
38
- - `DONE`: validate the exit artifact, then advance.
39
- - `DONE_WITH_CONCERNS`: resolve correctness or scope concerns before advancing;
40
- record observational concerns without inventing failure.
41
- - `BLOCKED`: change evidence, owner, scope, or dependency before retrying.
42
- - `NEEDS_CONTEXT`: supply the missing bounded context before retrying.
43
-
44
- Never blindly retry `BLOCKED` or `NEEDS_CONTEXT`. A retry without a material
45
- change preserves the same normalized cause and therefore the same route failure
46
- key.
@@ -1,53 +0,0 @@
1
- # Chaining patterns
2
-
3
- Use a chain only when one link's output is required by another. The default
4
- skeleton is:
5
-
6
- ```text
7
- understand -> decide -> execute -> verify -> deliver
8
- ```
9
-
10
- ## Link contract
11
-
12
- Every retained link must state:
13
-
14
- - **Entry:** the evidence or artifact required to start.
15
- - **Exit:** one observable artifact or decision passed forward.
16
- - **Owner:** exactly one installed skill, installed agent, or the controller.
17
-
18
- Pass only the exit artifact plus the target, constraints, authority, acceptance,
19
- and unresolved gaps needed by the next owner. For one or two short links, chat
20
- context is enough. For longer or interruption-prone work, use an already
21
- authorized repository artifact; routing never grants permission to create one.
22
-
23
- ## Collapse and insertion
24
-
25
- Remove a link when its exit is already current and evidenced. An explicit valid
26
- skill or one obvious low-risk intent normally collapses to one link. Do not keep
27
- Scout, Brainstorm, Research, Specs, Test, Review, Git, or delivery merely for
28
- ceremony.
29
-
30
- Insert a link only for a real modifier:
31
-
32
- - unresolved repository shape -> discovery;
33
- - unresolved material choice -> decision;
34
- - implementation or repair -> execution;
35
- - elevated risk or changed behavior -> verification;
36
- - high risk -> independent review and confirmation;
37
- - commit, push, deploy, publish, or release -> delivery, only with matching
38
- user authority.
39
-
40
- ## Failure detours and stop
41
-
42
- On a failed link, preserve its valid exit evidence, normalize the root cause,
43
- and choose one bounded detour that can change that cause. Track the failure key
44
- as `(link, owner, normalized cause)` within the current chain.
45
-
46
- Two failures with the same failure key stop the chain and return `BLOCKED` with
47
- the evidence and missing decision or capability. Different normalized causes do
48
- not share a key and must not stop early merely because the link name matches.
49
- This route-level stop does not replace a separate orchestrator's authoritative
50
- task-retry budget.
51
-
52
- No detour may add authority. In particular, review cannot imply push,
53
- diagnosis cannot imply repair, and build cannot imply deploy.
@@ -1,48 +0,0 @@
1
- # Task taxonomy
2
-
3
- Classify by the final deliverable the user expects, not by the first verb, file
4
- type, or tool mentioned. Choose exactly one class; use domains as modifiers.
5
-
6
- | Class | Final deliverable |
7
- |---|---|
8
- | `answer` | Evidence-backed explanation or factual response |
9
- | `discover` | Located files, call path, inventory, or blast-radius map |
10
- | `decide` | Chosen product, architecture, or technical direction |
11
- | `specify` | Approved bounded plan and executable task packet |
12
- | `change` | Working implementation or content change |
13
- | `diagnose` | Root cause and verification-ready repair plan |
14
- | `repair` | Cause-aligned fix plus regression proof |
15
- | `verify` | Test or review verdict with owned evidence |
16
- | `deliver` | Authorized commit, push, deploy, publish, or release result |
17
-
18
- When a request contains several verbs, classify by its terminal observable
19
- result. For example, “research options and implement the winner” is `change`,
20
- while research is a decision link. “Inspect this failure and tell me why” is
21
- `diagnose`, not `repair`.
22
-
23
- ## Size
24
-
25
- - `trivial`: one clear reversible outcome, normally one owner and one link.
26
- - `standard`: multiple dependent links or a bounded cross-file/domain change.
27
- - `epic`: three or more independently deliverable subsystems; split them into
28
- bounded routes instead of creating one oversized chain.
29
-
30
- ## Risk
31
-
32
- Risk is the maximum risk of any retained link, never an average:
33
-
34
- - `low`: local, reversible, no material compatibility or data boundary.
35
- - `elevated`: shared contract, integration, migration, sensitive data, or a
36
- meaningful regression surface.
37
- - `high`: security boundary, irreversible data/action, production delivery,
38
- public compatibility, or large blast radius.
39
-
40
- ## Domains and ambiguity
41
-
42
- Count only material domains that need distinct evidence or ownership. A file
43
- extension alone is not a domain. Ambiguity adds an understand or decide link
44
- only when unresolved information can change the final deliverable, authority,
45
- or verification; otherwise choose the shortest valid direct path.
46
-
47
- Modifiers constrain a route. They never grant mutation, external-action,
48
- commit, push, deploy, publish, or release authority.
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const STATE = require('./completion-authority-state.cjs');
6
- const { checkFeatureReceipt, checkReceiptDetails } = require('./lib/spec-receipt.cjs');
7
- const RESOLVER = require('./lib/spec-utils.cjs');
8
-
9
- const installedScripts = path.join(__dirname, '..', 'scripts');
10
- const scripts = fs.existsSync(path.join(installedScripts, 'spec-final-state.cjs'))
11
- ? installedScripts
12
- : path.resolve(__dirname, '..', '..', 'claude', 'scripts');
13
-
14
- function runtimeModule(root, name) {
15
- const target = path.join(root, name);
16
- const stat = fs.lstatSync(target);
17
- if (stat.isSymbolicLink() || !stat.isFile()) throw new Error(`runtime dependency must be a regular non-symlink file: ${name}`);
18
- const canonicalRoot = fs.realpathSync(root);
19
- const canonical = fs.realpathSync(target);
20
- const relative = path.relative(canonicalRoot, canonical);
21
- if (relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) throw new Error(`runtime dependency escaped scripts root: ${name}`);
22
- return require(canonical);
23
- }
24
-
25
- const FINAL_STATE = runtimeModule(scripts, 'spec-final-state.cjs');
26
-
27
- function explicitTarget(payload) {
28
- for (const key of ['featureName', 'feature', 'explicitFeature']) {
29
- if (Object.prototype.hasOwnProperty.call(payload, key)) return { explicitFeature: payload[key] };
30
- }
31
- for (const key of ['specPath', 'spec_path', 'featurePath']) {
32
- if (Object.prototype.hasOwnProperty.call(payload, key)) return { explicitPath: payload[key] };
33
- }
34
- return null;
35
- }
36
-
37
- function resolveCandidate({ projectRoot, runtime, payload }) {
38
- const target = explicitTarget(payload);
39
- if (target) return RESOLVER.resolveActiveSpec({ projectRoot, runtime, ...target });
40
- // Delegate so both runtimes answer the same question; the count below stays only as a
41
- // fallback for an installed resolver older than this wrapper.
42
- const shared = RESOLVER.resolvePersistedSpec({ projectRoot, runtime });
43
- if (shared !== null) return shared;
44
- const candidates = RESOLVER.findAllSpecCandidates(projectRoot, runtime);
45
- if (candidates.length > 1) return { error: 'multiple_persisted', candidates: candidates.map((candidate) => candidate.featureName) };
46
- return candidates[0] || null;
47
- }
48
-
49
- function dependencies(overrides = {}) {
50
- if (!overrides.grounder) runtimeModule(scripts, 'spec-semantic-model.cjs');
51
- const grounder = overrides.grounder || runtimeModule(scripts, 'spec-ground.cjs');
52
- return {
53
- validator: overrides.validator || runtimeModule(scripts, 'validate-spec-output.cjs'),
54
- grounder,
55
- semanticAuthority: overrides.semanticAuthority || require('./semantic-review-authority.cjs'),
56
- };
57
- }
58
-
59
- module.exports = FINAL_STATE.createAuthority({
60
- state: STATE,
61
- resolveCandidate,
62
- dependencies,
63
- receipts: {
64
- task: (featureDir, taskPath, task, context) => checkReceiptDetails(featureDir, taskPath, task, context),
65
- feature: (featureDir, context) => checkFeatureReceipt(featureDir, context),
66
- },
67
- });