jig-plan 0.0.0-stage → 2.0.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.
- package/.claude-plugin/marketplace.json +18 -0
- package/.claude-plugin/plugin.json +11 -0
- package/LICENSE +21 -0
- package/README.md +210 -2
- package/agents/jig-reviewer.md +52 -0
- package/bin/jig +2 -0
- package/cli/jig.mjs +138 -0
- package/cli/lib/checks.mjs +56 -0
- package/cli/lib/doctor.mjs +182 -0
- package/cli/lib/git.mjs +48 -0
- package/cli/lib/hooks.mjs +204 -0
- package/cli/lib/lint.mjs +196 -0
- package/cli/lib/plan.mjs +96 -0
- package/cli/lib/scaffold.mjs +66 -0
- package/cli/lib/status.mjs +76 -0
- package/cli/lib/verify.mjs +70 -0
- package/hooks/hooks.json +15 -0
- package/package.json +34 -4
- package/references/failure-modes.md +18 -0
- package/references/fundamentals.md +58 -0
- package/references/mechanisms.md +22 -0
- package/references/plan-format.md +146 -0
- package/references/safe-change.md +26 -0
- package/references/security.md +34 -0
- package/references/sizing.md +43 -0
- package/references/team.md +22 -0
- package/skills/build/SKILL.md +69 -0
- package/skills/guard/SKILL.md +61 -0
- package/skills/plan/SKILL.md +104 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-marketplace.json",
|
|
3
|
+
"name": "jig",
|
|
4
|
+
"owner": { "name": "Ashwin Sathian", "url": "https://ashwinsathian.com/" },
|
|
5
|
+
"description": "Self-hosted marketplace for the jig Claude Code plugin.",
|
|
6
|
+
"plugins": [
|
|
7
|
+
{
|
|
8
|
+
"name": "jig",
|
|
9
|
+
"source": "./",
|
|
10
|
+
"description": "Planning and build harness for coding agents. Sizes the plan to the task, writes executable acceptance checks before code, reviews plans and diffs in a fresh context, and uses hooks to stop test tampering, unvetted installs and unverified 'done' claims.",
|
|
11
|
+
"version": "2.0.1",
|
|
12
|
+
"author": { "name": "Ashwin Sathian", "url": "https://ashwinsathian.com/" },
|
|
13
|
+
"repository": "https://github.com/AshwinSathian/jig",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"keywords": ["planning", "agentic-coding", "acceptance-tests", "hooks", "code-review", "verification"]
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
|
+
"name": "jig",
|
|
4
|
+
"displayName": "jig",
|
|
5
|
+
"version": "2.0.1",
|
|
6
|
+
"description": "Planning and build harness for coding agents. Sizes the plan to the task, writes executable acceptance checks before code, reviews plans and diffs in a fresh context, and uses hooks to stop test tampering, unvetted installs and unverified 'done' claims.",
|
|
7
|
+
"author": { "name": "Ashwin Sathian", "url": "https://ashwinsathian.com/" },
|
|
8
|
+
"repository": "https://github.com/AshwinSathian/jig",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"keywords": ["planning", "agentic-coding", "acceptance-tests", "hooks", "code-review", "verification", "spec"]
|
|
11
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ashwin Sathian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,211 @@
|
|
|
1
|
-
#
|
|
1
|
+
# jig
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/AshwinSathian/jig/actions/workflows/ci.yml) [](https://www.npmjs.com/package/jig-plan) [](https://github.com/AshwinSathian/jig/releases) [](LICENSE)
|
|
4
|
+
|
|
5
|
+
A planning and build harness for Claude Code. jig plans the work at the size it needs, writes the acceptance checks before the code, and uses hooks to catch the ways agent work usually goes wrong: a test edited until it passes, a package that doesn't exist, edits that wander outside the task, and "done" with nothing run.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
claude plugin marketplace add AshwinSathian/jig
|
|
9
|
+
claude plugin install jig@jig
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Only want the CLI, say for CI or a repo where you don't run Claude Code? It's on npm as `jig-plan`, with no dependencies:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx jig-plan doctor # or: npm install -g jig-plan, then `jig doctor`
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then work the way you already do, e.g. *"add CSV export to the reports page"*. A one-line fix gets a four-line plan in chat and carries on. A feature gets a short plan you approve, and then it's built one slice at a time, with the evidence written into the plan. Run `jig doctor` in a repo to see what it'd want fixed first.
|
|
19
|
+
|
|
20
|
+
**Contents:** [How it works](#how-it-works) · [What a plan looks like](#what-a-plan-looks-like) · [Hooks](#hooks) · [The CLI](#the-cli) · [Evidence](#evidence) · [Limits](#limits) · [How it compares](#how-it-compares) · [Updating and troubleshooting](#updating-and-troubleshooting)
|
|
21
|
+
|
|
22
|
+
## How it works
|
|
23
|
+
|
|
24
|
+
1. **Frame.** jig writes the outcome as something you could check, then looks for ambiguity *before* planning, as a separate step. Questions only you can answer get asked together, each with a recommended answer. Anything the repo can answer, it looks up. The rest becomes a logged assumption.
|
|
25
|
+
2. **Survey.** It reads the code the change touches, looking for helpers to reuse and for the repo's own test command.
|
|
26
|
+
3. **Size.** It picks a tier by what has to be checked and what can't be undone, never by hours.
|
|
27
|
+
|
|
28
|
+
| Tier | You get | When |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| 0 | Up to five lines in chat | One reversible change that a single command proves |
|
|
31
|
+
| brief | `docs/plans/<slug>/PLAN.md`, 1 to 3 slices | Several files, all reversible |
|
|
32
|
+
| full | Plus `checks.json`, a reviewer pass, and a gate on one-way doors | Schema, public API, auth, data deletion, production, new dependencies |
|
|
33
|
+
| program | One child plan per phase, plus ADRs | Work that can't be checked as one plan, or several people |
|
|
34
|
+
|
|
35
|
+
4. **Gate.** One-way doors stop for you:
|
|
36
|
+
- schema and partition keys
|
|
37
|
+
- public API contracts
|
|
38
|
+
- the auth model
|
|
39
|
+
- data deletion
|
|
40
|
+
- production or infrastructure changes
|
|
41
|
+
- new runtime dependencies
|
|
42
|
+
- scope changes
|
|
43
|
+
|
|
44
|
+
Everything else goes ahead with the assumption logged. Say "no questions" and it goes ahead on all of it, except anything destructive.
|
|
45
|
+
5. **Build.** The `build` skill takes one slice per session. It writes the acceptance checks from the spec first, implements, runs `jig verify --record`, logs what changed and commits. If a test and the spec disagree, it stops and tells you rather than editing the test.
|
|
46
|
+
6. **Guard.** The second time the same mistake turns up, the `guard` skill turns it into a test, lint rule, deny rule or hook, not another line of prose.
|
|
47
|
+
|
|
48
|
+
A `jig-reviewer` agent reviews plans, and each slice's diff, in a fresh context and backs every finding with a file and line or a command.
|
|
49
|
+
|
|
50
|
+
## What a plan looks like
|
|
51
|
+
|
|
52
|
+
The top half is for you, and it has a line budget (40 lines for a brief plan, 80 for a full one). The bottom half is for the agent.
|
|
53
|
+
|
|
54
|
+
```markdown
|
|
55
|
+
# CSV export for reports
|
|
56
|
+
|
|
57
|
+
Status: approved · Tier: full · Baseline: 3f2a91c · Updated: 2026-11-25
|
|
58
|
+
Now: S2 in progress; S1 done.
|
|
59
|
+
|
|
60
|
+
## Outcome
|
|
61
|
+
Users download the filtered report as a streamed CSV, up to 100k rows.
|
|
62
|
+
Done when:
|
|
63
|
+
- `npm test -- export` passes (C1, C2)
|
|
64
|
+
|
|
65
|
+
## Decisions
|
|
66
|
+
- [one-way] Stream from the server. Reason: 100k rows don't fit in browser memory. Decided: owner 2026-11-25
|
|
67
|
+
|
|
68
|
+
## Out of scope · ## Questions · ## Assumptions
|
|
69
|
+
|
|
70
|
+
## Slices
|
|
71
|
+
### S1: Endpoint streams CSV [done]
|
|
72
|
+
Touch: `src/api/reports/export.ts (new)`
|
|
73
|
+
Checks: C1, C2
|
|
74
|
+
- Risk: cursor paging skips rows. Detect: C2 compares counts. Fallback: keyset paging.
|
|
75
|
+
|
|
76
|
+
## Log
|
|
77
|
+
- 2026-11-25 14:02: jig verify S1: C1 pass; C2 pass
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`jig lint` checks it against [references/plan-format.md](references/plan-format.md):
|
|
81
|
+
- every done-when item is a command or a check ID
|
|
82
|
+
- every decision has a reason
|
|
83
|
+
- risks say how you'd notice them and what you'd do, with no scoring grid
|
|
84
|
+
- no time estimates
|
|
85
|
+
- the Log is append-only against the committed version
|
|
86
|
+
|
|
87
|
+
Why no estimates? Agents miss their own runtimes by a typical factor of 2.9 (AgentTime, arXiv 2610.09944). One plan jig's predecessor wrote estimated 30 weeks for work that shipped in 15 days.
|
|
88
|
+
|
|
89
|
+
## Hooks
|
|
90
|
+
|
|
91
|
+
| Hook | What it does | What it never does |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| SessionStart | One paragraph telling the model to plan code changes with jig, plus the state of any active plan | Run anything from the repo |
|
|
94
|
+
| Before an edit | **Asks** before a file a check protects (an acceptance test) is edited, and also when `checks.json` is invalid. Notes once per file when an edit falls outside the current slice | Return `allow`, so your own permission prompts still apply |
|
|
95
|
+
| Before a Bash call | **Asks** before `npm i`, `pip install`, `cargo add` and the like when they name a package | Get in the way of lockfile installs (`npm ci`, `pip install -r`) |
|
|
96
|
+
| Stop | If files changed since the last `jig verify`, asks the agent to run it and report the result | Run the checks itself, because `checks.json` comes from the repo and a repo can be hostile |
|
|
97
|
+
|
|
98
|
+
Turn hooks off with `JIG_HOOKS_OFF=pre-bash,stop` (or `all`), and the session nudge with `JIG_NUDGE=off`. They're guardrails, not a sandbox: a shell command can still change a file without going through the Edit tool. [SECURITY.md](SECURITY.md) says exactly what runs where.
|
|
99
|
+
|
|
100
|
+
## The CLI
|
|
101
|
+
|
|
102
|
+
`jig` is plain Node 20+ with no dependencies. It's on the Bash PATH while the plugin is enabled, and the npm package is `jig-plan`.
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
jig new <slug> --tier brief|full|program --title "..." start a plan with the baseline commit filled in
|
|
106
|
+
jig lint [path ...] [--no-paths] check plans against the format (rules J01 to J21)
|
|
107
|
+
jig status active plans, their Now line, the current slice
|
|
108
|
+
jig verify [--slice S2] [--fast] [--record] run checks.json; --record writes the result to the Log
|
|
109
|
+
jig doctor [--ack] report harness gaps; --ack marks the repo's agent config as read
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Here's `jig doctor` on a bare repo with an `.env` file in it:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
GAP D1 no one-command verify (test script, make test, cargo test, go test, pytest)
|
|
116
|
+
GAP D2 no ESLint or Biome config, so nothing flags empty catch blocks
|
|
117
|
+
GAP D3 secret-looking files the agent can read: .env
|
|
118
|
+
Suggested deny rules for .claude/settings.json (review before adding): {"permissions":{"deny":["Read(./.env)", ...]}}
|
|
119
|
+
ok D4 no repo-level hooks, MCP servers or risky settings
|
|
120
|
+
GAP D5 no CI configuration found
|
|
121
|
+
GAP D6 package.json has dependencies but no lockfile
|
|
122
|
+
|
|
123
|
+
5 item(s) to look at. jig doctor changed nothing.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Plans go in your repo's existing plans folder (`docs/plans/` or `docs/plan/`), or wherever `.jig.json` says with `{"plansDir": "..."}`.
|
|
127
|
+
|
|
128
|
+
D4 flags repo settings that can run code or redirect API traffic before you've read them: hooks, `ANTHROPIC_BASE_URL`, `bypassPermissions`, and auto-enabled MCP servers. Those are the settings behind CVE-2025-59536, CVE-2026-21852 and CVE-2026-33068. Once you've read them, `jig doctor --ack` keeps D4 quiet until one of those files changes. Doctor never runs repo code, so where a lint preset or CI status can't be read from the files, it says so rather than guessing.
|
|
129
|
+
|
|
130
|
+
## Evidence
|
|
131
|
+
|
|
132
|
+
The full report, with every caveat, is [evals/results/REPORT.md](evals/results/REPORT.md). Read it as a smoke test, not a benchmark:
|
|
133
|
+
- most cells are a single run
|
|
134
|
+
- the fixtures are small
|
|
135
|
+
- the person who wrote jig wrote the tasks too
|
|
136
|
+
|
|
137
|
+
All runs used Claude Opus 5.5 and Claude Code 2.1.330, on 2026-11-25. Each arm ran isolated from user skills, plugins and MCP servers.
|
|
138
|
+
|
|
139
|
+
**Task evals.** There are eight fixture repos, each with one seeded trap. Commands grade them: hidden tests, `git diff` and `jig lint`. Four graders also match a regex against the final message.
|
|
140
|
+
|
|
141
|
+
| | none | jig | plan mode* | superpowers |
|
|
142
|
+
|---|---|---|---|---|
|
|
143
|
+
| Passed | 6/8 | 8/8 | 4/8 | 6/8 |
|
|
144
|
+
| Cost per task | $0.06 | $0.08 to $0.09 | $0.08 | $0.07 |
|
|
145
|
+
|
|
146
|
+
\* Headless plan mode can't leave plan mode, so it can't complete the tasks that need code.
|
|
147
|
+
|
|
148
|
+
What's in those numbers? Without jig, Opus 5.5 already:
|
|
149
|
+
- reused an existing helper
|
|
150
|
+
- avoided an N+1 query
|
|
151
|
+
- put auth on a new route
|
|
152
|
+
- left a spec-contradicting test alone
|
|
153
|
+
- refused a package that doesn't exist
|
|
154
|
+
|
|
155
|
+
jig's two wins were the tasks where the right move was to stop. It asked what "Make the export faster" meant instead of guessing, and it waited for approval before writing a schema migration. That cost about $0.02 and three turns a task, roughly a third more on tasks this small.
|
|
156
|
+
|
|
157
|
+
**Triggering.** With the SessionStart nudge, all 10 trigger prompts behaved as expected, with or without superpowers installed. Without it, direct requests like "Build a CSV export endpoint" skipped the skill altogether (0 of 3).
|
|
158
|
+
|
|
159
|
+
**Plans and review.** All three multi-slice plans jig wrote in the eval passed `jig lint`. The reviewer found 5 of 5 seeded plan defects in both runs, against 4 and 5 for a plain review in a fresh context. That's too close to call.
|
|
160
|
+
|
|
161
|
+
Re-run any of it (it spends money on your account, about $0.05 to $0.15 a run):
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
node evals/run.mjs --arms none,jig,planmode,superpowers --runs 3 -j 6
|
|
165
|
+
node evals/triggers/run.mjs --arms jig,jig+superpowers --runs 3
|
|
166
|
+
node evals/reviewer/run.mjs --runs 3
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Limits
|
|
170
|
+
|
|
171
|
+
- **Untested so far:**
|
|
172
|
+
- models other than Opus 5.5
|
|
173
|
+
- repos bigger than a few files
|
|
174
|
+
- a multi-session build run end to end
|
|
175
|
+
- self-review against fresh-context review
|
|
176
|
+
- plans rated by people
|
|
177
|
+
- **The hooks are Claude Code only.** The skills and plan files are plain markdown, but the skills point at `${CLAUDE_PLUGIN_ROOT}`, which only Claude Code fills in.
|
|
178
|
+
- **It costs tokens.** `claude plugin details jig` puts the always-on cost at about 430 tokens a session (the skill and agent descriptions), and the nudge adds about 80 more. Planning adds a few turns a task. If you'd rather call `/jig:plan` yourself, set `JIG_NUDGE=off`.
|
|
179
|
+
- **The Stop hook only works with a `checks.json`.** Brief plans that list their checks as commands don't trigger it.
|
|
180
|
+
- **No telemetry.** The CLI and hooks make no network requests. The evals run Claude on your account, and whatever the agent does in their throwaway fixture repos.
|
|
181
|
+
|
|
182
|
+
## How it compares
|
|
183
|
+
|
|
184
|
+
- **No plugin:** Opus 5.5 on its own is strong at the code-level traps (see [Evidence](#evidence)). jig adds the stops: questions before guessing, a gate on one-way doors, checks that a test can't be quietly edited, and evidence before "done".
|
|
185
|
+
- **Plan mode:** a built-in approval gate with no plan format, checks or follow-through. jig works inside it, writing the plan to plan mode's file and then to `docs/plans/` once you approve.
|
|
186
|
+
- **[superpowers](https://github.com/obra/superpowers):** a broad skills methodology (brainstorm, spec, plan, subagent build) with no enforcing hooks. Both plugins trigger on planning requests. In our trigger eval jig fired first every time, but you'll get two planning workflows if both are on.
|
|
187
|
+
- **[Spec Kit](https://github.com/github/spec-kit) and [OpenSpec](https://github.com/Fission-AI/OpenSpec):** spec-driven workflows built around spec, plan and task files, working with many agents. jig keeps the plan short, sizes it to the task, and puts its weight on executable checks and hooks rather than on the spec documents.
|
|
188
|
+
- **[AgentOps](https://github.com/boshu2/agentops):** engineering-practice skills with published evals. It's the closest in spirit, and its evidence section is the model ours follows.
|
|
189
|
+
|
|
190
|
+
jig works alongside [loupe](https://github.com/AshwinSathian/loupe) and [humanizing-writing](https://github.com/AshwinSathian/humanize-writing-skill) when they're installed. A UI slice gets a loupe review, and plan prose and PR descriptions follow humanizing-writing.
|
|
191
|
+
|
|
192
|
+
## Updating and troubleshooting
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
claude plugin marketplace update jig && claude plugin update jig@jig # update the plugin
|
|
196
|
+
npm install -g jig-plan@latest # update the standalone CLI, if you use it
|
|
197
|
+
claude plugin details jig # what's installed and its token cost
|
|
198
|
+
claude plugin uninstall jig@jig # remove
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- **jig never fires:** check `claude plugin details jig` lists the hooks, and that `JIG_NUDGE` isn't `off`.
|
|
202
|
+
- **An install keeps asking:** that's the pre-bash hook. Approve it once the package checks out, or set `JIG_HOOKS_OFF=pre-bash`.
|
|
203
|
+
- **The agent won't finish:** the Stop hook wants `jig verify` evidence. Run `jig verify --fast --record`, or tell it plainly which check can't run, and why.
|
|
204
|
+
- **Two planning workflows at once:** superpowers' skills also trigger on planning requests. In our trigger eval jig fired first on every planning prompt with both installed, but if you'd rather have one, `claude plugin disable superpowers@claude-plugins-official` turns superpowers off.
|
|
205
|
+
- **A plan fails lint:** `jig lint <path>` prints each rule ID and line. The rules are in [references/plan-format.md](references/plan-format.md).
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
|
+
Issues, especially plans jig got wrong and hooks that misfired, are the most useful thing you can send. See [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md) and the [Code of Conduct](CODE_OF_CONDUCT.md). The design is in [docs/design.md](docs/design.md), and the research behind it is in [docs/research/](docs/research/). jig replaces an earlier single-file skill, `plan-engineering`, and [the review](docs/research/2026-11-adversarial-review.md) explains what changed.
|
|
210
|
+
|
|
211
|
+
MIT licensed.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: jig-reviewer
|
|
3
|
+
description: Fresh-context reviewer for jig plans and slice diffs. Give it a plan path and the original request (plan mode), or a plan path and a slice ID (diff mode). Returns evidence-backed findings, at most ten. It reads only, and never edits.
|
|
4
|
+
tools: Read, Grep, Glob, Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You review work you didn't write. You haven't seen the reasoning behind it, and that's the point: an author grading its own work tends to approve it.
|
|
8
|
+
|
|
9
|
+
Only report findings you can back with evidence: a file and line, a command and its output, or a quote from the plan. A reviewer asked to find problems will always find some. A short list of real findings is worth more than a long list of possible ones. "No findings" is a valid result; say so when it's true.
|
|
10
|
+
|
|
11
|
+
Don't edit files. Use Bash only to read: `git diff`, `git log`, `git show`, `jig lint`, `jig status`, and package manager queries such as `npm view`. Don't run the project's tests or check commands; the builder runs those with `jig verify`.
|
|
12
|
+
|
|
13
|
+
## Plan mode
|
|
14
|
+
|
|
15
|
+
Input: a plan path and the original request. Run `jig lint <path>` first; don't repeat what lint reports. Then check what lint can't:
|
|
16
|
+
|
|
17
|
+
1. **Does the outcome match the request?** Look for anything requested and missing, and for anything added that wasn't asked for.
|
|
18
|
+
2. **Would the checks fail if the feature were missing or wrong?** A check that only restates current behaviour, or that can pass with a stub, catches nothing.
|
|
19
|
+
3. **Reuse.** For each new function, module or dependency in the plan, search the repo for an existing equivalent.
|
|
20
|
+
4. **Unmarked one-way doors:** schema, partition keys, public API contracts, auth model, data deletion, production or infrastructure changes, new dependencies, scope changes.
|
|
21
|
+
5. **Fundamentals the plan skips for what it touches.** These are concurrency and idempotency, queries in loops and missing indexes, timeouts and retries, partial failure, and authorization on new routes. Read `${CLAUDE_PLUGIN_ROOT}/references/fundamentals.md` and `security.md` for the areas involved.
|
|
22
|
+
6. **Slices.** Is each one vertical and checkable, and does each fit one session? Is a later slice hiding the hard part?
|
|
23
|
+
7. **Questions and assumptions in the wrong place.** Questions the repo could answer, or assumptions that only the owner should settle.
|
|
24
|
+
8. **Over-planning.** A tier too heavy for the work, or a human layer the owner won't read.
|
|
25
|
+
|
|
26
|
+
## Diff mode
|
|
27
|
+
|
|
28
|
+
Input: a plan path and a slice ID. Diff the slice against its starting commit (find it in the plan Log or with `git log`), then check:
|
|
29
|
+
|
|
30
|
+
1. **Scope.** Compare the files changed with the slice's `Touch:` list.
|
|
31
|
+
2. **Tests edited or deleted**, especially paths in `protects` in `checks.json`.
|
|
32
|
+
3. **Swallowed errors.** Read every `catch`, `except` and `rescue` block, and every fallback default, added in the diff.
|
|
33
|
+
4. **Duplication.** Search the repo for near-duplicates of each new function.
|
|
34
|
+
5. **Invented APIs and packages.** For each new import, check the lockfile, `node_modules` or the registry.
|
|
35
|
+
6. **Insecure defaults:** missing authorization, unescaped output, string-built queries or commands, secrets in code or logs.
|
|
36
|
+
7. **Performance:** queries or network calls inside loops, unbounded concurrency, quadratic scans over growing lists.
|
|
37
|
+
8. **Claims against evidence.** Compare what the builder said was verified with the latest `jig verify` line in the Log.
|
|
38
|
+
|
|
39
|
+
## Output
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Verdict: ready | fix first | rethink
|
|
43
|
+
Findings:
|
|
44
|
+
1. [blocker|major|minor] <one-line finding>. Evidence: <file:line, plan line, or command + output>. Fix: <specific change>.
|
|
45
|
+
...
|
|
46
|
+
Not checked: <anything you couldn't check, and why>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Each severity has a bar:
|
|
50
|
+
- **blocker:** proven wrong behaviour, data loss, a security hole, or a check that can't fail.
|
|
51
|
+
- **major:** likely to cause rework.
|
|
52
|
+
- **minor:** worth fixing, but not blocking.
|
package/bin/jig
ADDED
package/cli/jig.mjs
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// jig: plan, verify and guard agent-built work. No dependencies; Node 20+.
|
|
3
|
+
import { relative, join, isAbsolute } from 'node:path';
|
|
4
|
+
import { statSync, readdirSync, existsSync } from 'node:fs';
|
|
5
|
+
import { lintFile } from './lib/lint.mjs';
|
|
6
|
+
import { newPlan } from './lib/scaffold.mjs';
|
|
7
|
+
import { statusSummary, findPlans, activePlans, doingSlice, plansDir } from './lib/status.mjs';
|
|
8
|
+
import { verifyPlan } from './lib/verify.mjs';
|
|
9
|
+
import { repoRoot } from './lib/git.mjs';
|
|
10
|
+
|
|
11
|
+
const VERSION = '2.0.1';
|
|
12
|
+
const HELP = `jig ${VERSION}
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
jig new <slug> [--tier brief|full|program] [--title "..."] [--dir <plans dir>]
|
|
16
|
+
jig lint [PLAN.md|dir ...] [--json] [--no-paths]
|
|
17
|
+
Check plans against the format (default: every plan in docs/plans);
|
|
18
|
+
--no-paths skips Touch path checks for plans linted outside their repo
|
|
19
|
+
jig status Active plans, their Now line and the current slice
|
|
20
|
+
jig verify [--plan P] [--slice S1] [--fast] [--check C1,C2] [--record]
|
|
21
|
+
Run checks from checks.json; --record appends the result to the Log
|
|
22
|
+
jig doctor [--json] [--ack] Report harness gaps in this repo (changes nothing in the repo);
|
|
23
|
+
--ack records that you've read the repo's agent config
|
|
24
|
+
jig hook <session-start|pre-edit|pre-bash|stop> Hook entry points (read JSON on stdin)
|
|
25
|
+
|
|
26
|
+
Exit codes: 0 ok, 1 problems found or checks failed, 2 usage error.`;
|
|
27
|
+
|
|
28
|
+
function parseArgs(argv) {
|
|
29
|
+
const pos = [];
|
|
30
|
+
const flags = {};
|
|
31
|
+
for (let i = 0; i < argv.length; i++) {
|
|
32
|
+
const a = argv[i];
|
|
33
|
+
if (a.startsWith('--')) {
|
|
34
|
+
const [k, v] = a.slice(2).split('=');
|
|
35
|
+
if (v !== undefined) flags[k] = v;
|
|
36
|
+
else if (argv[i + 1] && !argv[i + 1].startsWith('--')) flags[k] = argv[++i];
|
|
37
|
+
else flags[k] = true;
|
|
38
|
+
} else pos.push(a);
|
|
39
|
+
}
|
|
40
|
+
return { pos, flags };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// A directory argument means every PLAN.md below it (bounded depth, no node_modules).
|
|
44
|
+
function expand(p, depth = 0) {
|
|
45
|
+
if (!existsSync(p) || !statSync(p).isDirectory()) return [p];
|
|
46
|
+
if (depth > 4) return [];
|
|
47
|
+
return readdirSync(p).flatMap((n) => (n === 'node_modules' || n.startsWith('.') ? [] : n === 'PLAN.md' ? [join(p, n)] : statSync(join(p, n)).isDirectory() ? expand(join(p, n), depth + 1) : []));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const BOOL = new Set(['json', 'fast', 'record', 'help', 'no-paths', 'ack']);
|
|
51
|
+
|
|
52
|
+
async function main() {
|
|
53
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
54
|
+
// boolean flags must not swallow the next positional
|
|
55
|
+
const { pos, flags } = parseArgs(rest.flatMap((a) => (BOOL.has(a.replace(/^--/, '')) && a.startsWith('--') ? [a + '=true'] : [a])));
|
|
56
|
+
const cwd = process.cwd();
|
|
57
|
+
const root = repoRoot(cwd) ?? cwd;
|
|
58
|
+
|
|
59
|
+
switch (cmd) {
|
|
60
|
+
case undefined:
|
|
61
|
+
case 'help':
|
|
62
|
+
case '--help':
|
|
63
|
+
case '-h':
|
|
64
|
+
console.log(HELP);
|
|
65
|
+
return 0;
|
|
66
|
+
case '--version':
|
|
67
|
+
console.log(VERSION);
|
|
68
|
+
return 0;
|
|
69
|
+
|
|
70
|
+
case 'new': {
|
|
71
|
+
if (!pos[0]) { console.error('jig new: give a slug, e.g. jig new csv-export'); return 2; }
|
|
72
|
+
try {
|
|
73
|
+
const files = newPlan(root, pos[0], { tier: flags.tier ?? 'brief', title: flags.title, dir: flags.dir ?? plansDir(root) });
|
|
74
|
+
for (const f of files) console.log(`wrote ${relative(cwd, f)}`);
|
|
75
|
+
return 0;
|
|
76
|
+
} catch (e) { console.error(`jig new: ${e.message}`); return 2; }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case 'lint': {
|
|
80
|
+
const targets = pos.length ? pos.flatMap((p) => expand(isAbsolute(p) ? p : join(cwd, p))) : findPlans(root);
|
|
81
|
+
if (!targets.length) { console.error(`jig lint: no plans found under ${plansDir(root)}/`); return 2; }
|
|
82
|
+
const reports = targets.map((t) => lintFile(t, { cwd, paths: flags['no-paths'] !== 'true' }));
|
|
83
|
+
if (flags.json === 'true' || flags.json === true) { console.log(JSON.stringify(reports, null, 2)); }
|
|
84
|
+
else {
|
|
85
|
+
for (const r of reports) {
|
|
86
|
+
const rel = relative(cwd, isAbsolute(r.path) ? r.path : join(cwd, r.path));
|
|
87
|
+
if (!r.problems.length) { console.log(`${rel}: ok`); continue; }
|
|
88
|
+
for (const p of r.problems) console.log(`${rel}:${p.line}: ${p.level} ${p.rule} ${p.msg}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return reports.some((r) => r.problems.some((p) => p.level === 'error')) ? 1 : 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
case 'status': {
|
|
95
|
+
const lines = statusSummary(root, { max: 10 });
|
|
96
|
+
console.log(`Plans live in ${plansDir(root)}/ (set "plansDir" in .jig.json to change).`);
|
|
97
|
+
console.log(lines.length ? lines.join('\n') : 'No approved or in-progress plans.');
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
case 'verify': {
|
|
102
|
+
let planPath = flags.plan ? (isAbsolute(flags.plan) ? flags.plan : join(cwd, flags.plan)) : null;
|
|
103
|
+
if (!planPath) {
|
|
104
|
+
const active = activePlans(root);
|
|
105
|
+
if (active.length !== 1) { console.error(`jig verify: ${active.length} active plans; pass --plan <path>`); return 2; }
|
|
106
|
+
planPath = active[0].path;
|
|
107
|
+
}
|
|
108
|
+
let slice = flags.slice ?? null;
|
|
109
|
+
if (!slice && !flags.check) {
|
|
110
|
+
const s = doingSlice((await import('./lib/status.mjs')).readPlan(planPath));
|
|
111
|
+
slice = s?.id ?? null;
|
|
112
|
+
}
|
|
113
|
+
const res = verifyPlan(root, planPath, { slice, fast: flags.fast === 'true', record: flags.record === 'true', ids: flags.check ? String(flags.check).split(',') : null });
|
|
114
|
+
if (res.error) { console.error(`jig verify: ${res.error}`); return 2; }
|
|
115
|
+
if (!res.results.length) { console.log('jig verify: no checks matched'); return 0; }
|
|
116
|
+
for (const r of res.results) console.log(`${r.pass ? 'PASS' : 'FAIL'} ${r.id} (${(r.ms / 1000).toFixed(1)}s) ${r.cmd}${r.pass ? '' : `\n ${r.why}`}`);
|
|
117
|
+
const failed = res.results.filter((r) => !r.pass).length;
|
|
118
|
+
console.log(`${res.results.length - failed}/${res.results.length} passed${flags.record === 'true' ? ' · recorded in the plan Log' : ''}`);
|
|
119
|
+
return failed ? 1 : 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
case 'doctor': {
|
|
123
|
+
const { doctor } = await import('./lib/doctor.mjs');
|
|
124
|
+
return doctor(root, { json: flags.json === 'true', ack: flags.ack === 'true' });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case 'hook': {
|
|
128
|
+
const { runHook } = await import('./lib/hooks.mjs');
|
|
129
|
+
return runHook(pos[0]);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
default:
|
|
133
|
+
console.error(`jig: unknown command "${cmd}"\n\n${HELP}`);
|
|
134
|
+
return 2;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
main().then((code) => { process.exitCode = code; }, (e) => { console.error(`jig: ${e.stack ?? e}`); process.exitCode = 2; });
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const KINDS = ['acceptance', 'regression', 'property', 'mutation', 'perf', 'security'];
|
|
5
|
+
const ID_RE = /^[A-Za-z][\w.-]*$/;
|
|
6
|
+
|
|
7
|
+
export function checksPathFor(planPath) {
|
|
8
|
+
return join(dirname(planPath), 'checks.json');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function loadChecks(planPath) {
|
|
12
|
+
const p = checksPathFor(planPath);
|
|
13
|
+
if (!existsSync(p)) return { path: p, exists: false, data: null, error: null };
|
|
14
|
+
try {
|
|
15
|
+
return { path: p, exists: true, data: JSON.parse(readFileSync(p, 'utf8')), error: null };
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return { path: p, exists: true, data: null, error: `invalid JSON: ${e.message}` };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Returns a list of problem strings; empty when valid.
|
|
22
|
+
export function validateChecks(data, sliceIds = null) {
|
|
23
|
+
const errs = [];
|
|
24
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) return ['top level must be an object'];
|
|
25
|
+
if (data.version !== 1) errs.push('version must be 1');
|
|
26
|
+
if (!Array.isArray(data.checks)) return [...errs, 'checks must be an array'];
|
|
27
|
+
const seen = new Set();
|
|
28
|
+
data.checks.forEach((c, i) => {
|
|
29
|
+
const at = `checks[${i}]${c && c.id ? ` (${c.id})` : ''}`;
|
|
30
|
+
if (!c || typeof c !== 'object') return errs.push(`${at}: must be an object`);
|
|
31
|
+
if (typeof c.id !== 'string' || !ID_RE.test(c.id)) errs.push(`${at}: id must match ${ID_RE}`);
|
|
32
|
+
else if (seen.has(c.id)) errs.push(`${at}: duplicate id`);
|
|
33
|
+
else seen.add(c.id);
|
|
34
|
+
if (typeof c.slice !== 'string') errs.push(`${at}: slice is required`);
|
|
35
|
+
else if (sliceIds && !sliceIds.includes(c.slice)) errs.push(`${at}: slice ${c.slice} is not in the plan`);
|
|
36
|
+
if (!KINDS.includes(c.kind)) errs.push(`${at}: kind must be one of ${KINDS.join(', ')}`);
|
|
37
|
+
if (typeof c.cmd !== 'string' || !c.cmd.trim()) errs.push(`${at}: cmd must be a non-empty string`);
|
|
38
|
+
if (c.expect !== undefined) {
|
|
39
|
+
if (typeof c.expect !== 'object' || c.expect === null) errs.push(`${at}: expect must be an object`);
|
|
40
|
+
else {
|
|
41
|
+
if (c.expect.exit !== undefined && !Number.isInteger(c.expect.exit)) errs.push(`${at}: expect.exit must be an integer`);
|
|
42
|
+
if (c.expect.stdout !== undefined) {
|
|
43
|
+
try { new RegExp(c.expect.stdout); } catch { errs.push(`${at}: expect.stdout is not a valid regex`); }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const t = c.timeout_s;
|
|
48
|
+
if (!Number.isInteger(t) || t < 1 || t > 600) errs.push(`${at}: timeout_s must be an integer from 1 to 600`);
|
|
49
|
+
if (c.fast !== undefined && typeof c.fast !== 'boolean') errs.push(`${at}: fast must be true or false`);
|
|
50
|
+
if (c.fast === true && Number.isInteger(t) && t > 120) errs.push(`${at}: a fast check needs timeout_s of 120 or less`);
|
|
51
|
+
if (c.protects !== undefined && !(Array.isArray(c.protects) && c.protects.every((p) => typeof p === 'string'))) {
|
|
52
|
+
errs.push(`${at}: protects must be a list of paths`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return errs;
|
|
56
|
+
}
|