@haposoft/cafekit 0.16.7 → 0.18.1

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 (231) 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 +169 -272
  4. package/bin/__tests__/codex-native.test.js +100 -202
  5. package/bin/__tests__/develop-contract.test.js +122 -1413
  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 +154 -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 +90 -925
  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 +30 -161
  20. package/bin/__tests__/specs-v2-execution-closeout.test.js +0 -437
  21. package/bin/__tests__/test-runtime-dependency-closure.cjs +1 -2
  22. package/bin/__tests__/ui-ux-skill.test.js +101 -0
  23. package/bin/__tests__/usage-hook-retired.test.js +114 -0
  24. package/bin/__tests__/validator-grounding.test.js +18 -2949
  25. package/bin/lib/managed-writer.js +2 -3
  26. package/bin/phases/codex-runtime.js +27 -0
  27. package/bin/phases/copy-payload.js +13 -28
  28. package/bin/phases/omp-runtime.js +25 -0
  29. package/package.json +2 -3
  30. package/src/claude/CLAUDE.md +3 -10
  31. package/src/claude/agents/brainstormer.md +7 -3
  32. package/src/claude/agents/code-auditor.md +44 -56
  33. package/src/claude/agents/debugger.md +8 -88
  34. package/src/claude/agents/deployer.md +3 -5
  35. package/src/claude/agents/docs-keeper.md +6 -14
  36. package/src/claude/agents/git-ops.md +2 -4
  37. package/src/claude/agents/implementer.md +12 -16
  38. package/src/claude/agents/inspector.md +4 -3
  39. package/src/claude/agents/project-manager.md +9 -17
  40. package/src/claude/agents/researcher.md +9 -3
  41. package/src/claude/agents/spec-maker.md +15 -15
  42. package/src/claude/agents/test-runner.md +8 -11
  43. package/src/claude/agents/ui-ux-designer.md +0 -1
  44. package/src/claude/hooks/__tests__/fixtures/statusline-default.golden +1 -1
  45. package/src/claude/hooks/__tests__/spec-gate.test.js +244 -333
  46. package/src/claude/hooks/__tests__/spec-state-touched.test.js +160 -0
  47. package/src/claude/hooks/__tests__/state.test.js +68 -0
  48. package/src/claude/hooks/__tests__/statusline.test.js +140 -11
  49. package/src/claude/hooks/agent.cjs +2 -1
  50. package/src/claude/hooks/lib/hook-payload.cjs +2 -2
  51. package/src/claude/hooks/rules.cjs +2 -1
  52. package/src/claude/hooks/session.cjs +0 -1
  53. package/src/claude/hooks/spec-gate.cjs +17 -83
  54. package/src/claude/hooks/spec-state.cjs +142 -39
  55. package/src/claude/hooks/state.cjs +21 -2
  56. package/src/claude/migration-manifest.json +42 -22
  57. package/src/claude/output-styles/coding-level-0-eli5.md +9 -9
  58. package/src/claude/output-styles/coding-level-1-junior.md +3 -3
  59. package/src/claude/output-styles/coding-level-2-mid.md +3 -3
  60. package/src/claude/output-styles/coding-level-3-senior.md +2 -2
  61. package/src/claude/output-styles/coding-level-4-lead.md +5 -5
  62. package/src/claude/output-styles/coding-level-5-god.md +6 -6
  63. package/src/claude/rules/ai-dev-rules.md +2 -3
  64. package/src/claude/rules/hook-protocols.md +8 -15
  65. package/src/claude/rules/manage-docs.md +9 -23
  66. package/src/claude/rules/orchestrator.md +3 -4
  67. package/src/claude/rules/review-audit-self-decision.md +3 -3
  68. package/src/claude/rules/skill-domain-routing.md +1 -3
  69. package/src/claude/rules/skill-workflow-routing.md +4 -5
  70. package/src/claude/rules/state-sync.md +3 -12
  71. package/src/claude/rules/workflow.md +11 -19
  72. package/src/claude/runtime.schema.json +5 -3
  73. package/src/claude/scripts/generate-skill-catalog.cjs +7 -6
  74. package/src/claude/scripts/provenance.cjs +23 -5
  75. package/src/claude/scripts/spec-receipt.cjs +24 -121
  76. package/src/claude/scripts/spec-resolver.cjs +41 -458
  77. package/src/claude/scripts/workflow-policy.cjs +3 -1801
  78. package/src/claude/settings/settings.json +1 -32
  79. package/src/claude/skills/agent-browser/SKILL.md +1 -1
  80. package/src/claude/skills/{question → ask}/SKILL.md +9 -75
  81. package/src/claude/skills/brainstorm/SKILL.md +43 -131
  82. package/src/claude/skills/chrome-devtools/SKILL.md +14 -31
  83. package/src/claude/skills/code-review/SKILL.md +29 -81
  84. package/src/claude/skills/code-review/references/spec-compliance-review.md +4 -8
  85. package/src/claude/skills/debug/SKILL.md +29 -149
  86. package/src/claude/skills/develop/SKILL.md +26 -83
  87. package/src/claude/skills/develop/references/parallel-waves.md +0 -8
  88. package/src/claude/skills/develop/references/quality-gate.md +15 -13
  89. package/src/claude/skills/develop/references/subagent-patterns.md +0 -6
  90. package/src/claude/skills/docs/SKILL.md +2 -2
  91. package/src/claude/skills/docs/references/update-workflow.md +1 -1
  92. package/src/claude/skills/fix/SKILL.md +153 -0
  93. package/src/claude/skills/{hotfix → fix}/references/diagnosis-protocol.md +2 -2
  94. package/src/claude/skills/{hotfix → fix}/references/parallel-patterns.md +2 -2
  95. package/src/claude/skills/{hotfix → fix}/references/prevention-gate.md +3 -3
  96. package/src/claude/skills/{hotfix → fix}/references/review-cycle.md +1 -1
  97. package/src/claude/skills/git/SKILL.md +48 -9
  98. package/src/claude/skills/git/references/commit-protocols.md +35 -16
  99. package/src/claude/skills/git/references/worktree-blueprint.md +42 -6
  100. package/src/claude/skills/orca/SKILL.md +9 -8
  101. package/src/claude/skills/research/SKILL.md +17 -46
  102. package/src/claude/skills/scout/SKILL.md +61 -0
  103. package/src/claude/skills/{inspect → scout}/references/internal-inspection.md +26 -10
  104. package/src/claude/skills/specs/SKILL.md +22 -29
  105. package/src/claude/skills/specs/references/review.md +8 -6
  106. package/src/claude/skills/specs/references/templates.md +34 -41
  107. package/src/claude/skills/sync/SKILL.md +16 -45
  108. package/src/claude/skills/sync/references/rebind-and-audit.md +59 -0
  109. package/src/claude/skills/sync/references/sync-protocols.md +4 -13
  110. package/src/claude/skills/test/SKILL.md +39 -104
  111. package/src/claude/skills/test/references/execution-strategy.md +93 -21
  112. package/src/claude/skills/test/references/failure-triage.md +1 -1
  113. package/src/claude/skills/ui-ux/LICENSE +21 -0
  114. package/src/claude/skills/ui-ux/SKILL.md +497 -0
  115. package/src/claude/skills/ui-ux/references/brand-tokens.md +90 -0
  116. package/src/claude/skills/ui-ux/references/budgets.md +113 -0
  117. package/src/claude/skills/ui-ux/references/checklist.md +271 -0
  118. package/src/claude/skills/ui-ux/references/components/accordion.md +246 -0
  119. package/src/claude/skills/ui-ux/references/components/avatar.md +153 -0
  120. package/src/claude/skills/ui-ux/references/components/banner.md +43 -0
  121. package/src/claude/skills/ui-ux/references/components/breadcrumb.md +201 -0
  122. package/src/claude/skills/ui-ux/references/components/button.md +142 -0
  123. package/src/claude/skills/ui-ux/references/components/card.md +113 -0
  124. package/src/claude/skills/ui-ux/references/components/charts.md +376 -0
  125. package/src/claude/skills/ui-ux/references/components/chat.md +132 -0
  126. package/src/claude/skills/ui-ux/references/components/choice-controls.md +369 -0
  127. package/src/claude/skills/ui-ux/references/components/comment-thread.md +17 -0
  128. package/src/claude/skills/ui-ux/references/components/description-list.md +116 -0
  129. package/src/claude/skills/ui-ux/references/components/empty-state.md +98 -0
  130. package/src/claude/skills/ui-ux/references/components/file-upload.md +107 -0
  131. package/src/claude/skills/ui-ux/references/components/inline-edit.md +128 -0
  132. package/src/claude/skills/ui-ux/references/components/input.md +161 -0
  133. package/src/claude/skills/ui-ux/references/components/list-row.md +56 -0
  134. package/src/claude/skills/ui-ux/references/components/loading.md +198 -0
  135. package/src/claude/skills/ui-ux/references/components/logo.md +147 -0
  136. package/src/claude/skills/ui-ux/references/components/otp-input.md +43 -0
  137. package/src/claude/skills/ui-ux/references/components/quantity-input.md +100 -0
  138. package/src/claude/skills/ui-ux/references/components/range-slider.md +16 -0
  139. package/src/claude/skills/ui-ux/references/components/small-controls.md +340 -0
  140. package/src/claude/skills/ui-ux/references/components/sortable-header.md +86 -0
  141. package/src/claude/skills/ui-ux/references/components/tag-input.md +14 -0
  142. package/src/claude/skills/ui-ux/references/components/timeline.md +38 -0
  143. package/src/claude/skills/ui-ux/references/components/tree.md +30 -0
  144. package/src/claude/skills/ui-ux/references/design-process.md +650 -0
  145. package/src/claude/skills/ui-ux/references/layouts/app-kanban.html +303 -0
  146. package/src/claude/skills/ui-ux/references/layouts/app.md +1369 -0
  147. package/src/claude/skills/ui-ux/references/layouts/form.md +430 -0
  148. package/src/claude/skills/ui-ux/references/layouts/overlay.md +552 -0
  149. package/src/claude/skills/ui-ux/references/layouts/pricing.md +204 -0
  150. package/src/claude/skills/ui-ux/references/locked-rules.md +35 -0
  151. package/src/claude/skills/ui-ux/references/principles.md +408 -0
  152. package/src/claude/skills/ui-ux/references/refactor.md +245 -0
  153. package/src/claude/skills/ui-ux/references/responsive.md +195 -0
  154. package/src/claude/skills/ui-ux/references/review.md +528 -0
  155. package/src/claude/skills/ui-ux/references/rules-color.md +623 -0
  156. package/src/claude/skills/ui-ux/references/rules-form.md +235 -0
  157. package/src/claude/skills/ui-ux/references/rules-state.md +680 -0
  158. package/src/claude/skills/ui-ux/references/rules-type.md +369 -0
  159. package/src/claude/skills/ui-ux/references/styles.md +311 -0
  160. package/src/claude/skills/ui-ux/references/system.md +219 -0
  161. package/src/claude/skills/ui-ux/references/tailwind-v4-traps.md +237 -0
  162. package/src/claude/skills/ui-ux/references/tokens.css +362 -0
  163. package/src/claude/skills/ui-ux/scripts/lint-skill.mjs +216 -0
  164. package/src/claude/skills/ui-ux/scripts/package.json +9 -0
  165. package/src/claude/skills/ui-ux/scripts/probe.mjs +4447 -0
  166. package/src/claude/skills/ui-ux-pro-max/SKILL.md +25 -80
  167. package/src/claude/skills/web-testing/SKILL.md +2 -20
  168. package/src/claude/status.cjs +149 -144
  169. package/src/codex/AGENTS.md +8 -13
  170. package/src/codex/hooks/agent.cjs +2 -1
  171. package/src/codex/hooks/lib/spec-receipt.cjs +4 -32
  172. package/src/codex/hooks/lib/spec-utils.cjs +6 -52
  173. package/src/codex/hooks/rules.cjs +2 -1
  174. package/src/codex/hooks/session.cjs +0 -2
  175. package/src/codex/hooks/spec-gate.cjs +13 -81
  176. package/src/codex/hooks/spec-state.cjs +37 -41
  177. package/src/codex/hooks.json +0 -20
  178. package/src/codex/rules/state-sync.md +3 -12
  179. package/src/common/AGENTS.md +6 -12
  180. package/src/omp/extensions/cafekit-bridge.mjs +6 -6
  181. package/bin/__tests__/change-firewall.semantic-firewall.test.js +0 -2133
  182. package/bin/__tests__/finalizer-pass-gate.semantic-firewall.test.js +0 -342
  183. package/bin/__tests__/release-preflight.semantic-firewall.test.js +0 -586
  184. package/bin/__tests__/review-receipt-c2.semantic-firewall.test.js +0 -378
  185. package/bin/__tests__/specs-v2-policy-and-scaffold.test.js +0 -665
  186. package/bin/__tests__/specs-v2-validator-grounder-contract.test.js +0 -1132
  187. package/src/claude/hooks/__tests__/completion-authority.test.js +0 -990
  188. package/src/claude/hooks/__tests__/semantic-review-authority.test.js +0 -259
  189. package/src/claude/hooks/completion-authority-check.cjs +0 -56
  190. package/src/claude/hooks/completion-authority-state.cjs +0 -527
  191. package/src/claude/hooks/completion-authority.cjs +0 -163
  192. package/src/claude/hooks/lib/context.cjs +0 -616
  193. package/src/claude/hooks/lib/detect.cjs +0 -474
  194. package/src/claude/hooks/semantic-review-authority.cjs +0 -154
  195. package/src/claude/hooks/task-scaffold-guard.cjs +0 -114
  196. package/src/claude/hooks/usage.cjs +0 -197
  197. package/src/claude/scripts/change-firewall.cjs +0 -1748
  198. package/src/claude/scripts/spec-authoring-digest.cjs +0 -151
  199. package/src/claude/scripts/spec-authoring-validation.cjs +0 -126
  200. package/src/claude/scripts/spec-final-state.cjs +0 -290
  201. package/src/claude/scripts/spec-ground.cjs +0 -650
  202. package/src/claude/scripts/spec-readiness.cjs +0 -425
  203. package/src/claude/scripts/spec-scaffold.cjs +0 -2317
  204. package/src/claude/scripts/spec-semantic-model.cjs +0 -396
  205. package/src/claude/scripts/validate-spec-output.cjs +0 -3941
  206. package/src/claude/skills/code-review/references/verification-gate.md +0 -46
  207. package/src/claude/skills/delegate/SKILL.md +0 -124
  208. package/src/claude/skills/delegate/references/codex-delegation.md +0 -71
  209. package/src/claude/skills/delegate/references/grok-delegation.md +0 -84
  210. package/src/claude/skills/hotfix/SKILL.md +0 -289
  211. package/src/claude/skills/inspect/SKILL.md +0 -142
  212. package/src/claude/skills/loop/SKILL.md +0 -114
  213. package/src/claude/skills/loop/references/bounded-loop-protocol.md +0 -104
  214. package/src/claude/skills/loop/references/metric-and-guard-contract.md +0 -76
  215. package/src/claude/skills/route/SKILL.md +0 -94
  216. package/src/claude/skills/route/references/agent-timing.md +0 -46
  217. package/src/claude/skills/route/references/chaining-patterns.md +0 -53
  218. package/src/claude/skills/route/references/task-taxonomy.md +0 -48
  219. package/src/claude/skills/specs/templates/design.md +0 -82
  220. package/src/claude/skills/specs/templates/requirements-init.md +0 -8
  221. package/src/claude/skills/specs/templates/requirements.md +0 -42
  222. package/src/claude/skills/specs/templates/spec-state.json +0 -56
  223. package/src/claude/skills/specs/templates/task.md +0 -47
  224. package/src/codex/hooks/completion-authority-check.cjs +0 -67
  225. package/src/codex/hooks/completion-authority-state.cjs +0 -527
  226. package/src/codex/hooks/completion-authority.cjs +0 -109
  227. package/src/codex/hooks/semantic-review-authority.cjs +0 -130
  228. package/src/codex/hooks/task-scaffold-guard.cjs +0 -63
  229. /package/src/claude/skills/{question → ask}/templates/question.md +0 -0
  230. /package/src/claude/skills/{hotfix → fix}/references/escalation-tactics.md +0 -0
  231. /package/src/claude/skills/{hotfix → fix}/references/workflow-specialized.md +0 -0
@@ -1,142 +0,0 @@
1
- ---
2
- name: cf:scout
3
- description: "Fast scoped codebase discovery using local search first and user-permitted Explore delegation only for broad independent scopes. Use for file discovery, task context, entrypoints, call paths, and blast radius."
4
- user-invocable: true
5
- when_to_use: "Invoke for fast scoped codebase discovery and file location."
6
- category: discovery
7
- keywords: [scout, inspect, discovery, search, context]
8
- argument-hint: "[search-target]"
9
- metadata:
10
- author: haposoft
11
- version: "2.1.0"
12
- ---
13
- # Scout
14
-
15
- Fast, token-efficient codebase discovery that uses focused local search by default
16
- and delegates only when parallel scouting has a concrete benefit.
17
-
18
- ## Arguments
19
- - Default: Scout the named target with local `rg` and targeted reads. For a
20
- genuinely broad scope, use the conditional delegation route in
21
- `./references/internal-inspection.md`.
22
-
23
- ## When to Use
24
-
25
- - Feature spanning multiple directories; user wants to find/locate/search files
26
- - Debugging that needs file relationships; project structure questions
27
- - Before multi-area changes, review, debug, or impact analysis
28
-
29
- ## Preflight Scope Gate (MANDATORY)
30
-
31
- Before scanning:
32
- 1. Detect repo-root or root-wide scans such as `.`, `/`, `./`, `**/*`, `**/*.ts`, or similar broad patterns without a scoped directory.
33
- 2. Apply the built-in no-scan lists below.
34
- 3. Prefer file-type or glob hints whenever possible.
35
-
36
- **When scope is too broad:** use a **2-phase approach** — lightweight structure
37
- mapping first, then parallel agents only when the Delegation Gate is open.
38
-
39
- ### Phase 1 — Structure Map
40
-
41
- Map the top-level layout in the main agent. A single Explore agent may do this
42
- only when the Delegation Gate below is already open:
43
- 1. List immediate children of the scope root (dirs + key config; monorepo markers)
44
- 2. Rough file count per discovered directory
45
- 3. Return a division plan of 1–10 logical sub-scopes (path/glob, est. files, focus)
46
-
47
- Complete the structure map before Phase 2.
48
-
49
- ### Phase 2 — Conditional Parallel Explore
50
-
51
- 1. Follow the structure map; merge scopes < 10 files; split scopes > 100 files
52
- 2. If the Delegation Gate is open, spawn Explore agents on distinct sub-scopes;
53
- otherwise scout the sub-scopes sequentially in the main agent
54
- 3. Aggregate into the Scout Report; offer deeper follow-up on specific areas
55
-
56
- **Fallback to AskUserQuestion:** if the structure map still leaves multiple
57
- plausible targets and the choice would materially change the scan, offer 2–4
58
- concrete scopes from findings, then continue with the selected scope.
59
-
60
- ## Built-in No-Scan Guidance
61
-
62
- ### `NO_SCAN_PATHS`
63
- - `.git/`, `node_modules/`, `dist/`, `build/`, `.next/`, `coverage/`
64
- - `tmp/`, `temp/`, `vendor/`, `artifacts/`, `secrets/`, `private/`
65
-
66
- ### `NO_SCAN_CONTENT_HINTS`
67
- - private keys, token dumps, credential exports, `.env` secrets
68
- - generated bundles, binary blobs
69
-
70
- ## Workflow
71
-
72
- ### 1. Analyze Task
73
- - Parse search targets; identify directories, patterns, file types
74
- - Estimate scan size and whether the work divides into independent scopes
75
-
76
- ### 2. Choose The Smallest Route
77
-
78
- | Condition | Route |
79
- |---|---|
80
- | Named files/directories or focused scope (about 50 files or fewer) | Main-agent `rg` plus targeted reads; do not delegate |
81
- | Medium scope that still fits one coherent search | Main-agent scouting; narrow before considering delegation |
82
- | Broad scope with two or more independent areas | Structure map, then evaluate the Delegation Gate |
83
-
84
- Do not use the file estimate alone to justify agents. A focused 100-file search
85
- may still be cheaper locally; a smaller cross-system search may justify two
86
- independent scopes.
87
-
88
- ### 3. Delegation Gate
89
-
90
- Delegate only when all are true:
91
-
92
- - The user explicitly requested or permitted subagents, delegation, or parallel work.
93
- - The active runtime exposes an Explore/delegation capability.
94
- - At least two non-overlapping scopes have useful independent work.
95
-
96
- If any condition is false, continue in the main agent with scoped `rg`, file
97
- listing, and targeted reads. Do not ask for delegation merely to complete an
98
- ordinary focused scout.
99
-
100
- ### 4. Divide And Scout
101
-
102
- For local scouting, search the shortlisted scopes sequentially and stop when the
103
- question is answered. For delegated scouting, load
104
- `./references/internal-inspection.md`, split by logical boundaries, and ensure
105
- no overlap.
106
-
107
- - Skip task registration for two or fewer agents.
108
- - For three or more agents, use the live task/plan surface when available.
109
- - Prompt each agent with exact directories/files and a read-only boundary.
110
-
111
- ### 5. Collect Results
112
- - Timeout: 3 minutes per agent (skip non-responders; log in report)
113
- - Update live task/plan state when one was used; aggregate; list unresolved questions at end
114
-
115
- ## Report Format
116
-
117
- ```markdown
118
- # Scout Report
119
-
120
- ## Relevant Files
121
- - `path/to/file.ts` - Brief description
122
- - ...
123
-
124
- ## Patterns
125
- - Key patterns observed
126
-
127
- ## Unresolved Questions
128
- - Any gaps in findings
129
- ```
130
-
131
- ## Rules
132
-
133
- - Keep scope narrow. Do not use `cf:scout` as a runtime policy engine.
134
- - Prefer listing files first, then reading only the shortlisted files.
135
- - Never encourage scanning ignored/generated/sensitive areas from the no-scan list.
136
- - Keep reports concise and actionable.
137
- - Ensure no overlap between agent scopes.
138
- - Skip non-responding agents, do not retry.
139
-
140
- ## References
141
-
142
- - `./references/internal-inspection.md` - Conditional Explore delegation
@@ -1,114 +0,0 @@
1
- ---
2
- name: cf:loop
3
- description: "Run an explicit, bounded optimization loop against a numeric metric while a separate correctness guard protects the result."
4
- user-invocable: true
5
- when_to_use: "Use only when the user explicitly requests measurable iterative optimization and supplies a safe Metric and Guard contract."
6
- category: utilities
7
- keywords: [loop, optimization, benchmark, metric, experiment]
8
- argument-hint: "<goal>"
9
- metadata:
10
- author: haposoft
11
- version: "1.0.0"
12
- ---
13
- # Loop — bounded metric optimization
14
-
15
- Loop is explicit-only. Never auto-route ordinary implementation, debugging, or
16
- research into Loop. It optimizes one numeric outcome under a separate correctness
17
- Guard; it does not guarantee improvement or replace Test/Review.
18
-
19
- Live-agent adherence to this written contract is `[UNPROVEN]` without a host run.
20
- The safety boundary is cooperative: commands must already be trusted by the user
21
- or repository. No instruction-only workflow can contain a malicious executable
22
- without an OS sandbox.
23
-
24
- ## 1. Preflight before mutation
25
-
26
- Load `references/metric-and-guard-contract.md` and freeze every field before any
27
- worktree, process, patch, or file mutation:
28
-
29
- - Goal and canonical repository root.
30
- - Scope: contained regular tracked text paths; symlink, untracked, binary, and
31
- submodule policy. Default is reject each unsupported kind.
32
- - Pinned base OID plus primary tracked/untracked status. Reject dirty in-scope
33
- state; record but never import or clean out-of-scope dirt.
34
- - Metric argv, unit, `higher|lower`, sample count, IEEE-754 binary64 numeric and
35
- rounding policy, fixed aggregation/noise rule, minimum delta, timeout, and
36
- reproducible baseline environment.
37
- - Distinct immutable Guard argv and timeout for code mutation. Metric and Guard
38
- may not be the same command or validate the same sole outcome.
39
- - Frozen positive iteration and wall-clock budgets; explicit success,
40
- no-improvement, drift, failure, timeout, and cancellation stops.
41
- - Unique run identity, exact disposable root, ownership marker, upfront cleanup
42
- consent, handoff mode/destination, retention, and cleanup owner.
43
-
44
- Missing, ambiguous, unsafe, or non-reproducible input returns `BLOCKED` without
45
- mutation. A subjective score, a metric that can be edited by the loop, or code
46
- mutation without a distinct Guard is ineligible.
47
-
48
- ## 2. Establish isolation and baseline
49
-
50
- Load `references/bounded-loop-protocol.md`. Create a never-reused canonical temp
51
- root and ownership marker, then add a detached Git worktree at the pinned OID.
52
- Do not create a branch or commit. Necessary common-Git-dir worktree metadata is
53
- the only allowed primary-repository metadata effect; primary worktree bytes,
54
- index, branch, and refs remain untouched.
55
-
56
- Screen each trusted command as an argv vector and run it with `cwd` fixed to the
57
- canonical detached root. The executable is a separately approved external
58
- realpath; only path-valued target arguments must resolve inside the detached
59
- root. Never use `eval`, `sh -c`, `bash -c`, `zsh -c`,
60
- `cmd /c`, PowerShell `-Command`, inline interpreter code, Git `-C`, `--git-dir`,
61
- `--work-tree`, destructive Git operations, path traversal, or an absolute target
62
- outside the detached root. Use a minimal fixed environment and redact secrets.
63
-
64
- Capture the complete detached-worktree tracked/untracked manifest before and
65
- after every Metric and Guard run, subtracting only an exact immutable cache
66
- allowlist frozen at preflight. Any other oracle mutation is drift. Establish
67
- baseline samples on pinned bytes before allowing a candidate.
68
-
69
- ## 3. Iterate one attributable change
70
-
71
- For every iteration:
72
-
73
- 1. Create a fresh unique detached worktree from pinned base and apply only the
74
- accepted-best patch, if one exists. Never restore in place.
75
- 2. Make exactly one bounded hypothesis change inside Scope. Multiple unrelated
76
- changes are forbidden. Reject unexpected,
77
- untracked, binary, symlink, submodule, or out-of-scope bytes.
78
- 3. Fingerprint candidate bytes, run Metric samples, fingerprint again, then run
79
- Guard on those identical bytes and fingerprint once more.
80
- 4. Reject on nonzero exit, timeout, malformed/non-finite/multi-value output,
81
- oracle mutation, Guard failure, or any source/environment/contract drift.
82
- 5. Accept only when Guard passes and improvement over current best is strictly
83
- greater than both the frozen minimum delta and calculated noise threshold.
84
- Record the candidate as a base-bound accepted-best patch; otherwise discard
85
- only that iteration's owned disposable environment.
86
-
87
- Do not edit Metric, Guard, tests, benchmarks, datasets, budgets, or thresholds
88
- to win; their frozen digests are revalidated before every candidate.
89
- Stop at the first budget, cancellation, drift, ownership, cleanup, or repeated
90
- no-improvement condition named in preflight.
91
-
92
- ## 4. Failure and process ownership
93
-
94
- Launch every command in an isolated process group on POSIX or Job Object on
95
- Windows. If the runtime cannot terminate the whole process tree, refuse to run.
96
- On timeout/cancel, terminate, escalate to kill, reap, and verify quiescence before
97
- cleanup. Never reuse a timed-out path. If descendants, path ownership, or cleanup
98
- is uncertain, retain exact residue and return `BLOCKED`; never use
99
- `git reset --hard`, `git clean`, broad deletion, or unrelated recovery.
100
-
101
- ## 5. Handoff
102
-
103
- Return baseline, best value/noise, the exact keep formula, accepted/rejected
104
- iteration ledger, Guard evidence, stop reason, remaining limits, and live-proof
105
- status. A successful handoff is a redacted tracked-text patch bound to base OID,
106
- complete scoped file manifest, and lowercase SHA-256. Reject secret-bearing,
107
- untracked, binary, incomplete, or stale output unless a separately approved
108
- bundle contract exists.
109
-
110
- Use only the preflight-selected handoff mode: inline ephemeral patch, or an exact
111
- user-approved path outside the primary worktree with retention and cleanup owner.
112
- Never apply, commit, push, merge, cherry-pick, deploy, publish, or write an
113
- artifact into the primary worktree implicitly. The user reviews and explicitly
114
- authorizes any later application through the normal Develop/Test/Review flow.
@@ -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.