create-agent-rig 0.3.2 → 0.5.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 (109) hide show
  1. package/CHANGELOG.md +294 -10
  2. package/README.md +84 -13
  3. package/package.json +2 -1
  4. package/packages/cli/dist/commands/create.js +41 -8
  5. package/packages/cli/dist/commands/init.js +120 -34
  6. package/packages/cli/dist/commands/upgrade.js +382 -0
  7. package/packages/cli/dist/index.js +132 -21
  8. package/packages/cli/dist/lib/copy-tree.js +44 -7
  9. package/packages/cli/dist/lib/history.js +49 -0
  10. package/packages/cli/dist/lib/init-settings.js +12 -0
  11. package/packages/cli/dist/lib/install-set.js +44 -0
  12. package/packages/cli/dist/lib/manifest.js +111 -0
  13. package/packages/cli/dist/lib/prompts.js +20 -0
  14. package/packages/cli/dist/lib/safe-path.js +71 -0
  15. package/packages/cli/dist/lib/substitute.js +32 -0
  16. package/packages/cli/dist/lib/version.js +15 -0
  17. package/templates/agent-os/init/AGENTS.md +191 -0
  18. package/templates/agent-os/init/CLAUDE.md +61 -9
  19. package/templates/agent-os/stack/aws-cdk/.agents/skills/post-deploy-verify/SKILL.md +98 -0
  20. package/templates/agent-os/stack/aws-cdk/.agents/skills/ro-debug/SKILL.md +117 -0
  21. package/templates/agent-os/stack/aws-cdk/.claude/agents/cdk-diff-reviewer.md +34 -3
  22. package/templates/agent-os/stack/aws-cdk/.claude/rules/aws-cdk.md +1 -1
  23. package/templates/agent-os/stack/aws-cdk/.claude/skills/post-deploy-verify/SKILL.md +34 -0
  24. package/templates/agent-os/stack/aws-cdk/.codex/agents/cdk-diff-reviewer.toml +4 -0
  25. package/templates/agent-os/universal/.agents/skills/check-premises/SKILL.md +233 -0
  26. package/templates/agent-os/universal/.agents/skills/loop/SKILL.md +676 -0
  27. package/templates/agent-os/universal/.agents/skills/new-invariant/SKILL.md +102 -0
  28. package/templates/agent-os/universal/.agents/skills/new-invariant/guard-invariant.example.mjs +78 -0
  29. package/templates/agent-os/universal/.agents/skills/new-invariant/guard-invariant.example.test.mjs +89 -0
  30. package/templates/agent-os/universal/.agents/skills/pr-ship/SKILL.md +338 -0
  31. package/templates/agent-os/universal/.agents/skills/worktree-task/SKILL.md +73 -0
  32. package/templates/agent-os/universal/.claude/agents/code-reviewer.md +33 -1
  33. package/templates/agent-os/universal/.claude/agents/prose-reviewer.md +64 -1
  34. package/templates/agent-os/universal/.claude/agents/security-scanner.md +33 -0
  35. package/templates/agent-os/universal/.claude/hooks/gate-stop-dod.mjs +274 -24
  36. package/templates/agent-os/universal/.claude/hooks/guard-bash.mjs +43 -5
  37. package/templates/agent-os/universal/.claude/hooks/guard-core-purity.mjs +25 -11
  38. package/templates/agent-os/universal/.claude/hooks/guard-secret-file.mjs +180 -0
  39. package/templates/agent-os/universal/.claude/hooks/guard-web-boundary.mjs +32 -13
  40. package/templates/agent-os/universal/.claude/hooks/inject-rules.mjs +175 -7
  41. package/templates/agent-os/universal/.claude/hooks/lib/edit-input.mjs +480 -0
  42. package/templates/agent-os/universal/.claude/rules/autonomy.md +61 -1
  43. package/templates/agent-os/universal/.claude/rules/invariants.md +71 -16
  44. package/templates/agent-os/universal/.claude/rules/workflow.md +55 -5
  45. package/templates/agent-os/universal/.claude/scripts/decision-router.mjs +1242 -0
  46. package/templates/agent-os/universal/.claude/scripts/detect-missed-gate.mjs +65 -2
  47. package/templates/agent-os/universal/.claude/scripts/git-env.mjs +49 -0
  48. package/templates/agent-os/universal/.claude/scripts/lib/secrets.mjs +490 -0
  49. package/templates/agent-os/universal/.claude/scripts/lib/verdict.mjs +433 -0
  50. package/templates/agent-os/universal/.claude/scripts/preflight.mjs +6 -16
  51. package/templates/agent-os/universal/.claude/scripts/queue/checkout.mjs +89 -0
  52. package/templates/agent-os/universal/.claude/scripts/queue/core.mjs +334 -23
  53. package/templates/agent-os/universal/.claude/scripts/queue/gate-rounds.mjs +160 -0
  54. package/templates/agent-os/universal/.claude/scripts/queue/github-issues.mjs +7 -2
  55. package/templates/agent-os/universal/.claude/scripts/queue/index.mjs +413 -8
  56. package/templates/agent-os/universal/.claude/scripts/queue/jira.mjs +75 -13
  57. package/templates/agent-os/universal/.claude/scripts/queue/plan-md.mjs +222 -21
  58. package/templates/agent-os/universal/.claude/scripts/queue/state.mjs +197 -0
  59. package/templates/agent-os/universal/.claude/scripts/run-journal.mjs +435 -0
  60. package/templates/agent-os/universal/.claude/scripts/run-state.mjs +441 -0
  61. package/templates/agent-os/universal/.claude/scripts/verdict.mjs +101 -0
  62. package/templates/agent-os/universal/.claude/settings.json +7 -2
  63. package/templates/agent-os/universal/.claude/skills/check-premises/SKILL.md +115 -7
  64. package/templates/agent-os/universal/.claude/skills/loop/SKILL.md +395 -33
  65. package/templates/agent-os/universal/.claude/skills/pr-ship/SKILL.md +300 -25
  66. package/templates/agent-os/universal/.codex/agents/code-reviewer.toml +4 -0
  67. package/templates/agent-os/universal/.codex/agents/prose-reviewer.toml +4 -0
  68. package/templates/agent-os/universal/.codex/agents/security-scanner.toml +4 -0
  69. package/templates/agent-os/universal/.codex/agents/test-writer.toml +4 -0
  70. package/templates/agent-os/universal/.codex/hooks.json +65 -0
  71. package/templates/agent-os/universal/AGENTS.md +164 -0
  72. package/templates/agent-os/universal/CLAUDE.md +47 -14
  73. package/templates/agent-os/universal/PLAN.md +7 -29
  74. package/templates/agent-os/universal/docs/decisions/closing-a-task.md +98 -0
  75. package/templates/agent-os/universal/docs/decisions/codex-adapter.md +108 -0
  76. package/templates/agent-os/universal/docs/decisions/fail-open-guards.md +43 -0
  77. package/templates/agent-os/universal/docs/decisions/review-lanes.md +72 -0
  78. package/templates/agent-os/universal/docs/decisions/run-directory.md +44 -0
  79. package/templates/agent-os/universal/docs/decisions/spacing-rations-mechanisms.md +125 -0
  80. package/templates/agent-os/universal/docs/decisions/stop-conditions-in-a-file.md +46 -0
  81. package/templates/agent-os/universal/docs/decisions/two-empty-endings.md +62 -0
  82. package/templates/agent-os/universal/journal/README.md +101 -0
  83. package/templates/agent-os/universal/layers.json +36 -2
  84. package/templates/hash-history.json +264 -0
  85. package/templates/skeleton/aws-serverless/.github/workflows/deploy.yml +34 -1
  86. package/templates/skeleton/aws-serverless/README.md +91 -9
  87. package/templates/skeleton/aws-serverless/apps/web/src/lib/api.ts +9 -2
  88. package/templates/skeleton/aws-serverless/gitignore +37 -0
  89. package/templates/skeleton/aws-serverless/infra/bin/app.ts +73 -13
  90. package/templates/skeleton/aws-serverless/infra/lib/app-stack.ts +136 -4
  91. package/templates/skeleton/aws-serverless/infra/lib/web-stack.ts +14 -1
  92. package/templates/skeleton/aws-serverless/infra/test/allowed-origins.test.ts +301 -0
  93. package/templates/skeleton/aws-serverless/infra/test/app-composition.test.ts +137 -0
  94. package/templates/skeleton/aws-serverless/infra/test/app-stack.test.ts +36 -20
  95. package/templates/skeleton/aws-serverless/infra/test/web-stack.test.ts +15 -12
  96. package/templates/skeleton/aws-serverless/services/api/src/handlers/create-note.ts +33 -6
  97. package/templates/skeleton/aws-serverless/services/api/src/handlers/list-notes.ts +18 -5
  98. package/templates/skeleton/aws-serverless/services/api/src/usecases/create-note.ts +11 -0
  99. package/templates/skeleton/aws-serverless/services/api/test/create-note.handler.test.ts +120 -1
  100. package/templates/skeleton/aws-serverless/services/api/test/list-notes.test.ts +72 -1
  101. package/templates/skeleton/node-service/README.md +11 -1
  102. package/templates/skeleton/node-service/gitignore +34 -0
  103. package/templates/skeleton/node-service/packages/db/src/note-store.ts +47 -10
  104. package/templates/skeleton/node-service/packages/db/test/note-store.test.ts +20 -0
  105. package/templates/skeleton/node-service/services/api/src/main.ts +2 -9
  106. package/templates/skeleton/node-service/services/api/src/server.ts +93 -10
  107. package/templates/skeleton/node-service/services/api/src/static-dir.ts +20 -0
  108. package/templates/skeleton/node-service/services/api/test/server.test.ts +98 -13
  109. package/templates/skeleton/node-service/services/api/test/static-dir.test.ts +28 -0
@@ -0,0 +1,233 @@
1
+ ---
2
+ name: check-premises
3
+ description: Check claims about the code before building on them, or before shipping them. Use after taking a queue item and before the failing test — whenever the item asserts something exists, is missing, is broken, or works a particular way. Use again before the gate, on the run's own prose, where a behaviour claim nothing backs is UNMEASURED.
4
+ context: fork
5
+ allowed-tools: Read, Grep, Glob, Bash
6
+ argument-hint: <the queue item's text, or the diff and prose to check>
7
+ ---
8
+
9
+ A queue item is a **claim about the code**, written by someone who was not
10
+ reading the code at the time. "The retry path swallows the error", "there is no
11
+ validation on that field", "the worker never gets the second message" — each of
12
+ those is a premise, and the work that follows is only worth doing if it is true.
13
+
14
+ This skill checks the premises. It writes nothing, and it has **two entry points**.
15
+
16
+ | entry point | the claims are | the code is | verdicts |
17
+ | --- | --- | --- | --- |
18
+ | after selection, **before the Red step** | the queue item's, about code it did not read | the repository | `PREMISES HOLD` / `PREMISE FALSE` / `UNVERIFIABLE` |
19
+ | after the work, **before the gate** | your own, in the rulebook prose the diff touches — and in the PR description if one exists yet | your diff | `PREMISES HOLD` / `UNVERIFIABLE` / `UNMEASURED` |
20
+
21
+ 🔴 **Why the second one exists.** A claim you wrote about a mechanism you did not run
22
+ is cheap to write and expensive to find: `prose-reviewer` reaches it only after loading
23
+ the whole diff, and the fix is an edit to one sentence. Same machinery, same question — *is this claim true?* — pointed
24
+ at the text the run wrote instead of the text it was handed.
25
+
26
+ The rest of this skill is written for the first entry point. The second one runs the
27
+ same four steps with the diff as the code, and §4 carries what is different.
28
+
29
+ **What "rulebook prose" means here is not a new list** — it is the set
30
+ `.claude/rules/workflow.md` already uses for the `prose-reviewer` trigger: a rule
31
+ file, a skill, an agent spec, a decision record, `CLAUDE.md`, the README. Where a
32
+ rulebook file exists twice (a template source and a generated copy), check the
33
+ **source**; the copy is composed from it. A comment in a test or a hook is in scope
34
+ too when it asserts behaviour — the file it lives in does not change what a claim is.
35
+
36
+ 🔴 **`PREMISE FALSE` belongs to the first entry point only.** At the second one the
37
+ claims are your own and the remedy is an edit, so a false one is not an escalation:
38
+ it is `UNMEASURED`'s neighbour — delete or correct the sentence and carry on. Reading
39
+ it as the escalation `loop` §6 defines would send a finished branch back to the queue
40
+ over one sentence.
41
+
42
+ ## Why it sits here and not in review
43
+
44
+ A false premise is not caught later. Review reads the diff against the item, and
45
+ both are wrong in the same direction: the item said the validation was missing,
46
+ the diff adds validation, the reviewer sees a diff that does what the item asked.
47
+ Nobody re-reads the file that had the validation all along. The cost lands as a
48
+ duplicate implementation, a "fix" for a bug that was somewhere else entirely, or
49
+ a refactor of a path that no caller reaches — all of it green, reviewed, merged.
50
+
51
+ The check is cheap because it is narrow, and the next section is that narrowness.
52
+
53
+ ## 1. Write out the claims — as claims
54
+
55
+ List what the item asserts about the code as it exists **now**. Two to five
56
+ lines. Keep them in the item's own terms; do not repair them while transcribing
57
+ — a claim you have already improved is one you will not test.
58
+
59
+ Separate the claims from the request. "Add a `GET /notes/:id` route" asserts
60
+ nothing; "the route handler bypasses the usecase layer" does.
61
+
62
+ An item that asserts nothing is done here: verdict `PREMISES HOLD`, one line
63
+ saying there were none. That is a common and perfectly good outcome.
64
+
65
+ ## 2. Mark the load-bearing ones
66
+
67
+ 🔴 **A claim is load-bearing when its falsity changes what gets built.** Only
68
+ those get verified. **This is not an audit** of the item, the file, or the
69
+ codebase — the moment it becomes one, it stops being cheap, gets skipped under
70
+ time pressure, and the whole step is lost.
71
+
72
+ | Load-bearing | Not |
73
+ | --- | --- |
74
+ | "there is no X" — if X exists, the task is already done | a stale line number in the item's description |
75
+ | "X is called from Y" — if it is not, the fix goes in the wrong place | a misspelled symbol you can resolve at a glance |
76
+ | "X handles the empty case by Z" — the fix is designed against Z | a claim about a file this task will not touch |
77
+ | "nothing enforces X" — the whole task is the enforcement | a claim the task's own failing test would immediately expose |
78
+
79
+ That last row is the one worth internalising: a premise the Red step would
80
+ falsify in the next five minutes does not need checking here. This step exists
81
+ for the premises a passing test **would not** catch — the ones about code the
82
+ task never touches.
83
+
84
+ ## 3. Verify each, against the code, with a citation
85
+
86
+ Read the code. Not the tests, not the docs, not another queue item — those are
87
+ claims too. Each verified premise gets a `file:line` citation; a premise you
88
+ believe but cannot cite is not verified, it is remembered.
89
+
90
+ At the **second** entry point this inverts for one case: a test is exactly what backs
91
+ a behaviour claim, so reading it is the point. The rule above is about not letting a
92
+ test's *name* stand in for what the code does; §4 says which artifacts count.
93
+
94
+ ## 4. The verdict
95
+
96
+ | Verdict | When | What happens next |
97
+ | --- | --- | --- |
98
+ | `PREMISES HOLD` | every load-bearing claim checked out, or there were none | proceed to the Red step |
99
+ | `PREMISE FALSE` | a load-bearing claim is contradicted by the code | **stop and report** |
100
+ | `UNVERIFIABLE` | a load-bearing claim could not be decided from the code | report it as unverifiable, name what would decide it, and proceed only under a **labelled assumption** |
101
+ | `UNMEASURED` | **second entry point only:** a sentence you wrote asserts behaviour, and nothing you can point at backs it | **delete the sentence, or turn it into a pointer to the test that proves it** — before the gate |
102
+
103
+ 🔴 **The edit belongs to the calling session, not to this skill.** It reports; the
104
+ caller performs the exit before the gate. (The rule is the one at the top of this
105
+ file — it writes nothing — not a property of its tool grant.)
106
+
107
+ 🔴 **`UNMEASURED` has exactly two exits, and "reword it" is not one of them.** A
108
+ behaviour claim is either backed or it is not; softening the wording keeps an
109
+ unbacked claim in a document agents follow literally. So either the sentence goes,
110
+ or it becomes `see guard-invariant.example.test.mjs › "blocks the violation, and the
111
+ reason names what to do instead"` — the test's whole name, in a file this project
112
+ carries, so one grep lands on it. `invariants.md` ("State the limits") states the norm this verdict
113
+ enforces.
114
+
115
+ **Two questions, and they have different answers — conflating them is how an unbacked
116
+ sentence survives this check.**
117
+
118
+ *Is the claim founded?* A test you can name, a command whose output is in front of
119
+ you, or a citation to code that does the thing. What does not count: the queue item
120
+ said so (the item is a claim too — that is what the first entry point is for), it was
121
+ true of the previous design, or it is obviously right.
122
+
123
+ *May it stay in the file as written?* Only the two forms `invariants.md` requires —
124
+ **generated** from what it describes, or a **pointer** to the test. A command's output
125
+ is not one of them: you saw it, the reader cannot, so a sentence resting on it is still
126
+ `UNMEASURED` however sure you are. Point at the test that runs that command, or say
127
+ something the reader can check.
128
+
129
+ ⚠ **A measurement of this project's own history fits none of the three**, and that is
130
+ a real gap rather than an oversight: the run that produced it is not in the repository,
131
+ and a journal entry does not travel with a rulebook that ships. So a figure about past
132
+ runs belongs in the journal and **not** in a file other projects receive — where it
133
+ would arrive with no backing at all.
134
+
135
+ A sentence is qualitative when it names **no quantity a reader could check** — not a
136
+ count, not a share, not a duration. "This has happened here before" qualifies; "this
137
+ happened twice last month" does not, and moves to the journal.
138
+
139
+ That is not a third exit from `UNMEASURED`. The two exits apply to **the sentence in
140
+ front of you**: it goes, or it becomes a pointer. Writing a different sentence — one
141
+ that claims no measurement, and so needs none — is the first exit followed by an
142
+ unrelated edit, not a softened version of the same claim. `invariants.md` has a
143
+ worked instance: "Both have happened here, in the same file, within one review
144
+ cycle." No figure, no measurement claimed, and it ships.
145
+
146
+ 🔴 **On `PREMISE FALSE` the answer is stop and report — never quietly work around
147
+ the false premise by building something adjacent that seems useful.** Write what
148
+ the item claimed, what the code actually says with its citation, and what the
149
+ task might become instead. Then let a human re-aim it. The item is wrong, and an
150
+ agent that silently repairs a wrong item produces work nobody asked for, in a
151
+ branch named after a task that does not exist.
152
+
153
+ `UNVERIFIABLE` is not a soft pass. A probe that could not run tells you nothing —
154
+ so the assumption travels in the open, in the item and in the PR description,
155
+ where the next reader can see which part of the work rests on it.
156
+
157
+ ### The verdict block
158
+
159
+ Report in prose for the caller, then end with **exactly one** fenced `json` block
160
+ of this shape, and nothing after it. The word is spaced in prose and one token
161
+ inside the block; both forms are the contract.
162
+
163
+ ```json
164
+ {
165
+ "gate": "check-premises",
166
+ "verdict": "PREMISE_FALSE",
167
+ "blockers": [
168
+ {
169
+ "file": "packages/core/src/note.ts",
170
+ "line": 17,
171
+ "rule": "the item claims the schema does not reject an empty title",
172
+ "note": "it does, here — the reported bug is a caller that skips the validator"
173
+ }
174
+ ],
175
+ "advisories": [],
176
+ "evidence": ["read the validator and both call sites"]
177
+ }
178
+ ```
179
+
180
+ - `verdict` is `PREMISES_HOLD`, `PREMISE_FALSE`, `UNVERIFIABLE` or `UNMEASURED`
181
+ — this skill returns no other word, and none of the reviewers' words.
182
+ - One blocker per premise that did not hold, per claim that could not be decided,
183
+ or per unbacked sentence — `rule` is the claim itself, `note` is what the code
184
+ actually says, and `file`/`line` is the citation §3 requires.
185
+ - `PREMISES_HOLD` carries an empty `blockers` list; the other three name at
186
+ least one. A stop verdict without one is not an answer the caller can act on,
187
+ and the caller is what checks: the `loop` skill runs
188
+ `node .claude/scripts/verdict.mjs check <report> check-premises` on what you
189
+ return. Nothing in this skill runs it — this skill writes nothing at all.
190
+
191
+ ## Examples — the three shapes this actually catches
192
+
193
+ **The thing already exists.** Item: "the payload schema does not reject an empty
194
+ title". The schema does reject it, three lines into the validator; the reported
195
+ bug came from a caller that never invoked the validator. Building "the missing
196
+ check" would have added a second, divergent rule and left the real defect —
197
+ the caller — in place. Verdict `PREMISE FALSE`; the task becomes a caller fix.
198
+
199
+ **The thing is somewhere else.** Item: "the worker retries forever because the
200
+ retry budget is not applied". The budget is applied, and correctly; the message
201
+ returns to the queue from a path above it that never consumed the budget at all.
202
+ The fix designed against the item would have been written in a file that was not
203
+ the problem. Verdict `PREMISE FALSE`.
204
+
205
+ **Nothing enforces it — except something does.** Item: "nothing stops a handler
206
+ importing the storage layer directly". A hook does exactly that, and has since
207
+ before the item was filed. Two hours of building a second enforcement mechanism,
208
+ which would then have disagreed with the first. Verdict `PREMISE FALSE`.
209
+
210
+ Note what all three have in common: the resulting work would have been correct,
211
+ tested, reviewable, and useless. That is the failure mode this catches, and it
212
+ is invisible to every gate downstream.
213
+
214
+ ## Limits — stated, because a check trusted past its reach is worse than none
215
+
216
+ - **It reads the code, so it only catches what the code can contradict.** A claim
217
+ about runtime behaviour ("this times out in production"), about intent, or
218
+ about a system this repository does not contain is `UNVERIFIABLE` here, not
219
+ false — say so rather than guessing.
220
+ - **Each entry point is one pass, at its own end of the task.** A premise that goes
221
+ false *between* them — a merge lands, a dependency moves — is a staleness stop rule
222
+ (`.claude/rules/autonomy.md`), not this skill. Neither pass watches the other's
223
+ claims.
224
+ - **It has no opinion on whether the task is worth doing.** True premises and a
225
+ pointless task is a perfectly consistent state, and it belongs to whoever fills
226
+ the queue.
227
+ - 🔴 **Nothing makes this run, and the verdict is a self-report.** No hook fires
228
+ when a task starts building on an unchecked claim, and no artifact outlives the
229
+ step — so a run that skipped it and a run that passed it look identical
230
+ afterwards. That is the honest description of every rule of this shape here
231
+ (the `loop` skill says the same about its own no-hand-feeding rule), and it is
232
+ why the citation matters: a `file:line` in the report is the one part of this a
233
+ later reader can re-check.