jig-plan 2.1.0 → 2.4.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +81 -14
- package/agents/jig-reviewer.md +88 -13
- package/cli/jig.mjs +34 -3
- package/cli/lib/checks.mjs +1 -1
- package/cli/lib/doctor.mjs +23 -0
- package/cli/lib/hooks.mjs +228 -19
- package/cli/lib/lint.mjs +2 -1
- package/cli/lib/review.mjs +403 -0
- package/cli/lib/verify.mjs +15 -6
- package/package.json +1 -1
- package/references/fundamentals.md +10 -0
- package/references/mechanisms.md +1 -0
- package/references/plan-format.md +1 -1
- package/skills/build/SKILL.md +3 -2
- package/skills/guard/SKILL.md +22 -0
- package/skills/plan/SKILL.md +2 -0
- package/skills/review/SKILL.md +108 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
// jig review: the brief a reviewer starts from. Deterministic, and it runs
|
|
2
|
+
// only git (hardened, through git.mjs) and, for --pr, gh. It never runs a
|
|
3
|
+
// repo's own commands: the gate is the review skill's job.
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { readFileSync, lstatSync, appendFileSync } from 'node:fs';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { join, relative } from 'node:path';
|
|
8
|
+
import { git, isCommit, stateDir } from './git.mjs';
|
|
9
|
+
import { activePlans, doingSlice, plansDir } from './status.mjs';
|
|
10
|
+
import { lastEvidence, workTree, readJsonl } from './verify.mjs';
|
|
11
|
+
import { loadChecks } from './checks.mjs';
|
|
12
|
+
import { section } from './plan.mjs';
|
|
13
|
+
import { diagnose } from './doctor.mjs';
|
|
14
|
+
import { pathMatches } from './hooks.mjs';
|
|
15
|
+
|
|
16
|
+
const lines = (s) => (s ?? '').split('\n').filter(Boolean);
|
|
17
|
+
const full = (root, ref) => git(root, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`])?.trim() || null;
|
|
18
|
+
|
|
19
|
+
// ---------- base ----------
|
|
20
|
+
|
|
21
|
+
function defaultBranch(root) {
|
|
22
|
+
const remote = git(root, ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD'])?.trim();
|
|
23
|
+
if (remote) return remote;
|
|
24
|
+
// A CI checkout has neither origin/HEAD nor a local main.
|
|
25
|
+
for (const b of ['refs/heads/main', 'refs/heads/master', 'refs/remotes/origin/main', 'refs/remotes/origin/master']) if (full(root, b)) return b.replace(/^refs\/(heads|remotes)\//, '');
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The newest commit since Baseline whose Verified: trailer names another
|
|
30
|
+
// slice; else Baseline. Build step 5 writes that trailer on every slice commit.
|
|
31
|
+
export function sliceStart(root, baseline, sliceId) {
|
|
32
|
+
const start = full(root, baseline);
|
|
33
|
+
if (!start) return null;
|
|
34
|
+
const log = git(root, ['log', '--format=%H%x00%B%x1e', `${start}..HEAD`]) ?? '';
|
|
35
|
+
for (const rec of log.split('\x1e')) {
|
|
36
|
+
const [sha, body = ''] = rec.trim().split('\0');
|
|
37
|
+
if (!sha) continue;
|
|
38
|
+
const named = [...body.matchAll(/^Verified:\s+(S\d+)\b/gm)].map((m) => m[1]);
|
|
39
|
+
if (named.some((s) => s !== sliceId)) return sha;
|
|
40
|
+
}
|
|
41
|
+
return start;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function fromPr(root, pr) {
|
|
45
|
+
if (!/^\d+$/.test(String(pr))) return { error: `--pr needs a PR number, got "${pr}"` };
|
|
46
|
+
let j;
|
|
47
|
+
try {
|
|
48
|
+
j = JSON.parse(execFileSync('gh', ['pr', 'view', String(pr), '--json', 'baseRefOid,baseRefName,headRefOid,author,number'], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 20000 }));
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return { error: `gh pr view ${pr} failed (${e.code === 'ENOENT' ? 'gh is not installed' : String(e.stderr || e.message).trim().split('\n')[0]})` };
|
|
51
|
+
}
|
|
52
|
+
if (typeof j?.headRefOid !== 'string' || typeof j?.baseRefOid !== 'string') return { error: `gh pr view ${pr} gave no base or head commit` };
|
|
53
|
+
if (!isCommit(root, j.headRefOid)) return { error: `PR ${pr}'s head ${j.headRefOid.slice(0, 7)} isn't in this clone; run \`gh pr checkout ${pr}\` first` };
|
|
54
|
+
if (!isCommit(root, j.baseRefOid)) return { error: `PR ${pr}'s base ${j.baseRefOid.slice(0, 7)} isn't in this clone; run \`git fetch origin ${j.baseRefName ?? '<base branch>'}\` first` };
|
|
55
|
+
const base = git(root, ['merge-base', j.baseRefOid, j.headRefOid])?.trim();
|
|
56
|
+
if (!base) return { error: `no merge-base between PR ${pr}'s base and head (a shallow clone? run \`git fetch --unshallow\`)` };
|
|
57
|
+
return { base, head: j.headRefOid, how: 'pr', pr: { number: j.number, author: j.author?.login ?? null } };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function resolveBase(root, { base = null, pr = null } = {}) {
|
|
61
|
+
if (pr) return fromPr(root, pr);
|
|
62
|
+
if (base) {
|
|
63
|
+
const b = full(root, base);
|
|
64
|
+
return b ? { base: b, how: 'flag' } : { error: `--base ${base} is not a commit here` };
|
|
65
|
+
}
|
|
66
|
+
// Each step that was tried and skipped is named, so a brief that ends at
|
|
67
|
+
// HEAD says why rather than quietly showing a small diff.
|
|
68
|
+
const fallback = [];
|
|
69
|
+
for (const { path, plan } of activePlans(root)) {
|
|
70
|
+
const slice = doingSlice(plan);
|
|
71
|
+
const baseline = plan.header?.baseline;
|
|
72
|
+
if (!slice || !baseline) continue;
|
|
73
|
+
const b = sliceStart(root, baseline, slice.id);
|
|
74
|
+
if (b) return { base: b, how: 'slice', plan: relative(root, path), slice: slice.id };
|
|
75
|
+
fallback.push(`${relative(root, path)} Baseline ${baseline} is not a commit here`);
|
|
76
|
+
}
|
|
77
|
+
const head = full(root, 'HEAD');
|
|
78
|
+
if (!head) return { error: 'no commits yet' };
|
|
79
|
+
const def = defaultBranch(root);
|
|
80
|
+
if (!def) fallback.push('no default branch (origin/HEAD, main or master)');
|
|
81
|
+
const mb = def ? git(root, ['merge-base', 'HEAD', def])?.trim() : null;
|
|
82
|
+
if (def && !mb) fallback.push(`no merge-base with ${def}`);
|
|
83
|
+
if (mb && mb !== head) return { base: mb, how: 'merge-base', branch: def, fallback };
|
|
84
|
+
if (git(root, ['rev-parse', '--is-shallow-repository'])?.trim() === 'true') fallback.push('shallow clone');
|
|
85
|
+
return { base: head, how: 'head', fallback };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ---------- diff ----------
|
|
89
|
+
|
|
90
|
+
// Files changed from base to head (a commit), or to the working tree when
|
|
91
|
+
// head is null, with added and removed lines. Untracked files count as added.
|
|
92
|
+
// Throws when git fails, so a bad range is never an empty diff.
|
|
93
|
+
// Not for hooks: a working-tree diff runs any clean filter .git/config
|
|
94
|
+
// defines (as a plain `git diff` would), and hooks run outside the sandbox.
|
|
95
|
+
// textconv and external diff drivers are off.
|
|
96
|
+
const MAX_UNTRACKED = 2 * 1024 * 1024;
|
|
97
|
+
export function diffFiles(root, base, head = null) {
|
|
98
|
+
const range = head ? [base, head] : [base];
|
|
99
|
+
const q = ['-c', 'core.quotePath=false'];
|
|
100
|
+
const stat = git(root, [...q, 'diff', '--no-renames', '--no-textconv', '--no-ext-diff', '--numstat', '-z', ...range, '--']);
|
|
101
|
+
// Prefixes pinned: the user's diff.noprefix or diff.mnemonicPrefix would
|
|
102
|
+
// otherwise change the header paths this parser reads.
|
|
103
|
+
const patch = git(root, [...q, 'diff', '--no-renames', '--no-textconv', '--no-ext-diff', '--src-prefix=a/', '--dst-prefix=b/', '-U0', '--no-color', ...range, '--']);
|
|
104
|
+
if (stat === null || patch === null) throw new Error(`git diff ${range.join(' ')} failed`);
|
|
105
|
+
const files = new Map();
|
|
106
|
+
for (const rec of stat.split('\0').filter(Boolean)) {
|
|
107
|
+
const [a, d, ...p] = rec.split('\t');
|
|
108
|
+
files.set(p.join('\t'), { path: p.join('\t'), adds: a === '-' ? 0 : Number(a), dels: d === '-' ? 0 : Number(d), binary: a === '-', added: [], removed: [] });
|
|
109
|
+
}
|
|
110
|
+
// Headers name the file on each side; /dev/null on one side is an add or a
|
|
111
|
+
// delete. Content lines are read only inside hunks.
|
|
112
|
+
let cur = null; let from = null; let inHunk = false;
|
|
113
|
+
for (const l of patch.split('\n')) {
|
|
114
|
+
if (l.startsWith('diff --git ')) { cur = null; from = null; inHunk = false; continue; }
|
|
115
|
+
// git ends a header with a tab when the path has a space.
|
|
116
|
+
if (!inHunk && l.startsWith('--- ')) { from = l === '--- /dev/null' ? null : l.replace(/^--- a\//, '').replace(/\t$/, ''); continue; }
|
|
117
|
+
if (!inHunk && l.startsWith('+++ ')) { cur = files.get(l === '+++ /dev/null' ? from : l.replace(/^\+\+\+ b\//, '').replace(/\t$/, '')) ?? null; continue; }
|
|
118
|
+
if (l.startsWith('@@')) { inHunk = true; continue; }
|
|
119
|
+
if (!inHunk || !cur) continue;
|
|
120
|
+
if (l.startsWith('+')) cur.added.push(l.slice(1));
|
|
121
|
+
else if (l.startsWith('-')) cur.removed.push(l.slice(1));
|
|
122
|
+
}
|
|
123
|
+
if (!head) {
|
|
124
|
+
for (const p of lines(git(root, [...q, 'ls-files', '--others', '--exclude-standard']))) {
|
|
125
|
+
// Regular files only, and not huge ones: a symlink, FIFO or device is
|
|
126
|
+
// never opened, the same rule treeId follows.
|
|
127
|
+
let text = '';
|
|
128
|
+
try {
|
|
129
|
+
const st = lstatSync(join(root, p));
|
|
130
|
+
if (st.isFile() && st.size <= MAX_UNTRACKED) text = readFileSync(join(root, p), 'utf8');
|
|
131
|
+
} catch { /* unreadable: list it with no lines */ }
|
|
132
|
+
const added = text.split('\n'); if (added[added.length - 1] === '') added.pop();
|
|
133
|
+
files.set(p, { path: p, adds: added.length, dels: 0, binary: false, added, removed: [], untracked: true });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return [...files.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ---------- triggers ----------
|
|
140
|
+
|
|
141
|
+
const ext = (p) => (p.match(/\.([^./]+)$/)?.[1] ?? '').toLowerCase();
|
|
142
|
+
// No .txt: requirements.txt and CMakeLists.txt are code, not prose.
|
|
143
|
+
const DOC_EXT = new Set(['md', 'mdx', 'rst', 'adoc']);
|
|
144
|
+
const isDoc = (p) => DOC_EXT.has(ext(p));
|
|
145
|
+
// Images, fonts and other media: their names say nothing about what code does.
|
|
146
|
+
const MEDIA = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg', 'ico', 'avif', 'bmp', 'mp4', 'webm', 'mov', 'mp3', 'wav', 'woff', 'woff2', 'ttf', 'otf', 'pdf']);
|
|
147
|
+
const isMedia = (f) => f.binary || MEDIA.has(ext(f.path));
|
|
148
|
+
const isTest = (p) => /(^|\/)(test|tests|__tests__|spec|e2e)\//i.test(p) || /\.(test|spec)\.[cm]?[jt]sx?$/i.test(p) || /_test\.(go|py|rb)$/.test(p) || /(^|\/)test_[^/]*\.py$/.test(p);
|
|
149
|
+
// Line-content rules read source code only: a test's fixture strings would
|
|
150
|
+
// trigger them for every test that mentions what it tests.
|
|
151
|
+
const code = (f) => !isDoc(f.path) && !f.binary && !isTest(f.path);
|
|
152
|
+
const PEOPLE = /^(readme|changelog|contributing|security|code_of_conduct)(\.[a-z]+)?$/i;
|
|
153
|
+
|
|
154
|
+
// One table: id, the partner skill that reviews those files (or null), and
|
|
155
|
+
// the rule. Rules read paths, plus added or removed lines of code files.
|
|
156
|
+
export const TRIGGERS = [
|
|
157
|
+
{ id: 'ui', partner: 'loupe', match: (f) => !isTest(f.path) && (['tsx', 'jsx', 'vue', 'svelte', 'astro', 'css', 'scss', 'sass', 'less', 'html'].includes(ext(f.path)) || /\.swift$/.test(f.path) && /(view|screen)/i.test(f.path)) },
|
|
158
|
+
{ id: 'prose', partner: 'humanizing-writing', match: (f, o) => isDoc(f.path) && !isTest(f.path) && !f.path.startsWith(`${o.plansDir}/`) && !f.path.startsWith('docs/plans/') },
|
|
159
|
+
{
|
|
160
|
+
id: 'security', partner: 'owasp-security',
|
|
161
|
+
// `token` under a lexer or parser is a lexical token, not a credential.
|
|
162
|
+
match: (f) => !isDoc(f.path) && !isMedia(f) && (
|
|
163
|
+
!(/(^|\/)(lexer|lexers|parser|parsers|tokeniz\w*)\//i.test(f.path) && /(^|\/)tokens?\.\w+$/i.test(f.path)) && /(^|[/_.-])(auth|authn|authz|authenticat\w*|authoriz\w*|login|logout|session|sessions|token|tokens|oauth|jwt|password|passwd|secret|secrets|crypto|permission|permissions|acl|rbac|admin|payment|payments|billing|invoice|invoices|money|wallet|checkout)([/_.-]|$)/i.test(f.path)
|
|
164
|
+
|| code(f) && (f.added.some((l) => SECURITY_LINE.test(l)) || f.removed.some((l) => AUTH_CHECK.test(l)))),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: 'invariants', partner: null,
|
|
168
|
+
match: (f) => code(f) && (/(^|\/)(parser|parsers|parse|serializ\w*|codec|reducer|reducers|state-machine|fsm|queue|queues|cache|caches|lock|locks|scheduler)([/._-]|$)/i.test(f.path)
|
|
169
|
+
|| f.added.some((l) => /\b(transaction|mutex|semaphore|atomic|compareAndSwap|Promise\.all|Promise\.race|idempoten\w*|invalidate|BEGIN TRANSACTION|SELECT .* FOR UPDATE|setInterval)\b|\bnew Worker\(/i.test(l))),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: 'tests-or-checks', partner: null,
|
|
173
|
+
match: (f, o) => isTest(f.path) || /^\.github\/workflows\//.test(f.path) || /(^|\/)(\.gitlab-ci\.yml|\.circleci\/|Jenkinsfile|azure-pipelines\.yml)/.test(f.path)
|
|
174
|
+
|| (f.path.startsWith(`${o.plansDir}/`) || f.path.startsWith('docs/plans/')) && f.path.endsWith('/checks.json')
|
|
175
|
+
|| /(^|\/)(jest|vitest|playwright|cypress|karma|mocha|ava|tap)\.config\.[cm]?[jt]s$|(^|\/)(\.mocharc[^/]*|pytest\.ini|tox\.ini|conftest\.py|\.nycrc[^/]*|codecov\.yml)$/.test(f.path)
|
|
176
|
+
|| /(^|\/)package\.json$/.test(f.path) && [...f.added, ...f.removed].some((l) => /^\s*"(test|tests|lint|typecheck|verify|check|e2e|ci)(:[\w:-]+)?"\s*:/.test(l)),
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: 'migration', partner: null,
|
|
180
|
+
match: (f) => !isDoc(f.path) && (/(^|\/)(migrations?|migrate|alembic|flyway|liquibase)\//i.test(f.path) || /(^|\/)db\/migrate\//.test(f.path) || /\.prisma$/.test(f.path) || /\.sql$/.test(f.path) && /(schema|migrat|V\d+__)/i.test(f.path)
|
|
181
|
+
|| code(f) && f.added.some((l) => /\b(ALTER TABLE|DROP TABLE|CREATE TABLE|DROP COLUMN|ADD COLUMN|RENAME COLUMN|addColumn|dropColumn|renameColumn|createTable|dropTable)\b/i.test(l))),
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
// Shell, query building, deserialisation, user-controlled paths, weak crypto.
|
|
186
|
+
const SECURITY_LINE = new RegExp([
|
|
187
|
+
// Not after a dot: RegExp.prototype.exec and obj.system( are everywhere.
|
|
188
|
+
String.raw`(?<![.\w])(exec|execSync|execFile|execFileSync|spawn|spawnSync|popen|system)\s*\(|\b(cp|child_process|os|subprocess)\.(exec|execSync|spawn|spawnSync|system|popen|run|call|check_output)\w*\s*\(`,
|
|
189
|
+
String.raw`child_process|subprocess\.|os\.system|shell\s*=\s*True`,
|
|
190
|
+
String.raw`\b(eval|new Function)\s*\(`,
|
|
191
|
+
String.raw`\b(SELECT|INSERT INTO|UPDATE|DELETE FROM)\b.*(\$\{|\{\w+\}|["'\x60]\s*\+|%s|\.format\()`,
|
|
192
|
+
String.raw`pickle\.loads?|yaml\.load\(|unserialize\(|Marshal\.load|ObjectInputStream|deserializ`,
|
|
193
|
+
String.raw`\b(path\.(join|resolve)|os\.path\.join|open)\(.*\b(req|request|params|query|body|input|argv|args)\b`,
|
|
194
|
+
String.raw`createHash\(\s*['"](md5|sha1)['"]|createCipher\(|Math\.random\(\).*\b(token|secret|id|nonce|salt)\b|crypto\.subtle|jwt\.(sign|verify|decode)`,
|
|
195
|
+
String.raw`dangerouslySetInnerHTML|innerHTML\s*=`,
|
|
196
|
+
].join('|'), 'i');
|
|
197
|
+
|
|
198
|
+
// A removed line that checked who may do something: deleting an auth check
|
|
199
|
+
// is a security change even when nothing security-shaped is added.
|
|
200
|
+
const AUTH_CHECK = /\b(isAdmin|isOwner|isAuthenticated|requireAuth\w*|authoriz\w*|authenticat\w*|checkPermission\w*|hasPermission\w*|hasRole|can\(|forbidden|unauthori[sz]ed|csrf|verifyToken|jwt\.verify)/i;
|
|
201
|
+
|
|
202
|
+
// Small, docs-only, and nothing else matched.
|
|
203
|
+
const TRIVIAL_LINES = 20;
|
|
204
|
+
const TRIVIAL_FILES = 3;
|
|
205
|
+
|
|
206
|
+
export function triggersFor(files, { plansDir: pd = 'docs/plans' } = {}) {
|
|
207
|
+
const o = { plansDir: pd };
|
|
208
|
+
const out = [];
|
|
209
|
+
for (const t of TRIGGERS) {
|
|
210
|
+
const hit = files.filter((f) => t.match(f, o)).map((f) => f.path);
|
|
211
|
+
if (!hit.length) continue;
|
|
212
|
+
const row = { id: t.id, partner: t.partner, files: hit };
|
|
213
|
+
// People-facing docs get the owner's voice; skills, agents and references don't.
|
|
214
|
+
if (t.id === 'prose') row.voice = hit.filter((p) => PEOPLE.test(p.split('/').pop()) || /^docs\//.test(p));
|
|
215
|
+
out.push(row);
|
|
216
|
+
}
|
|
217
|
+
const lines = files.reduce((n, f) => n + f.adds + f.dels, 0);
|
|
218
|
+
const docsOnly = files.length && files.every((f) => isDoc(f.path));
|
|
219
|
+
if (docsOnly && lines <= TRIVIAL_LINES && files.length <= TRIVIAL_FILES && out.every((t) => t.id === 'prose')) out.push({ id: 'trivial', partner: null, files: files.map((f) => f.path) });
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ---------- REVIEW.md from the base ----------
|
|
224
|
+
|
|
225
|
+
// Entries look like "- When: <trigger> · Check: <what> · Source: <where>".
|
|
226
|
+
// An entry matches when a path or code token in its When (backticks, or a
|
|
227
|
+
// word with a slash or a dot) appears in a changed path or an added line.
|
|
228
|
+
// Entries with no such token go to `judge`: the reviewer decides them.
|
|
229
|
+
export function reviewMdEntries(text, files) {
|
|
230
|
+
const matched = []; const judge = [];
|
|
231
|
+
for (const l of (text ?? '').split('\n')) {
|
|
232
|
+
const m = l.match(/^\s*-\s*When:\s*(.+?)\s*·\s*Check:\s*(.+?)\s*·\s*Source:\s*(.+?)\s*$/);
|
|
233
|
+
if (!m) continue;
|
|
234
|
+
const e = { when: m[1], check: m[2], source: m[3] };
|
|
235
|
+
const toks = [...m[1].matchAll(/`([^`]+)`/g)].map((x) => x[1]);
|
|
236
|
+
if (!toks.length) toks.push(...(m[1].match(/[\w.-]*\/[\w./*-]*|\b[\w-]+\.[a-z]{1,5}\b/g) ?? []));
|
|
237
|
+
if (!toks.length) { judge.push(e); continue; }
|
|
238
|
+
const hit = files.filter((f) => toks.some((t) => (/[*?]/.test(t) ? pathMatches(f.path, t) : f.path.includes(t) || f.added.some((a) => a.includes(t)))));
|
|
239
|
+
if (hit.length) matched.push({ ...e, files: hit.map((f) => f.path) });
|
|
240
|
+
}
|
|
241
|
+
return { matched, judge };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ---------- records ----------
|
|
245
|
+
|
|
246
|
+
export const reviews = (root) => readJsonl(root, 'reviews.jsonl');
|
|
247
|
+
|
|
248
|
+
// A review the skill hands over as JSON. Validated before anything is
|
|
249
|
+
// written; the record is tied to the working tree it reviewed, like evidence.
|
|
250
|
+
export const VERDICTS = ['ready', 'fix first', 'rethink'];
|
|
251
|
+
export const SEVERITIES = ['Important', 'Nit', 'Pre-existing'];
|
|
252
|
+
export const CONFIDENCES = ['Confirmed', 'Likely', 'Needs verification'];
|
|
253
|
+
export const OUTCOMES = ['fixed', 'wrong', 'intentional', 'didnt-matter'];
|
|
254
|
+
const hash8 = (s) => createHash('sha256').update(s).digest('hex').slice(0, 8);
|
|
255
|
+
|
|
256
|
+
// Stable across reviews: class, file and title (lower case, spaces collapsed),
|
|
257
|
+
// never the line, which moves as the file changes.
|
|
258
|
+
export function findingId(f) {
|
|
259
|
+
return hash8([f.class, f.file, String(f.title ?? '').toLowerCase().replace(/\s+/g, ' ').trim()].join('\0'));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function invalid(input) {
|
|
263
|
+
if (!input || typeof input !== 'object') return 'input is not a JSON object';
|
|
264
|
+
if (!VERDICTS.includes(input.verdict)) return `verdict must be one of ${VERDICTS.join(', ')}`;
|
|
265
|
+
if (!Array.isArray(input.findings)) return 'findings must be a list (empty for "Findings: none")';
|
|
266
|
+
for (const [i, f] of input.findings.entries()) {
|
|
267
|
+
const at = `findings[${i}]`;
|
|
268
|
+
if (!SEVERITIES.includes(f.severity)) return `${at}: severity must be one of ${SEVERITIES.join(', ')}`;
|
|
269
|
+
if (f.confidence !== undefined && !CONFIDENCES.includes(f.confidence)) return `${at}: confidence must be one of ${CONFIDENCES.join(', ')}`;
|
|
270
|
+
if (f.severity === 'Important' && f.confidence === undefined) return `${at}: an Important finding needs a confidence`;
|
|
271
|
+
if (typeof f.file !== 'string' || !f.file) return `${at}: file is required`;
|
|
272
|
+
if (f.line !== undefined && f.line !== null && !Number.isInteger(f.line)) return `${at}: line must be an integer`;
|
|
273
|
+
if (typeof f.class !== 'string' || !f.class) return `${at}: class is required (e.g. swallowed-error)`;
|
|
274
|
+
if (typeof f.title !== 'string' || !f.title) return `${at}: title is required`;
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// The input names the base, head and tree from the brief the review started
|
|
280
|
+
// from, so a record can't certify a tree nobody reviewed: if the working
|
|
281
|
+
// tree moved since the brief, the record is refused. A null tree is a PR
|
|
282
|
+
// head that wasn't checked out.
|
|
283
|
+
export function recordReview(root, input) {
|
|
284
|
+
const why = invalid(input);
|
|
285
|
+
if (why) return { error: why };
|
|
286
|
+
for (const k of ['base', 'head', 'tree']) if (!(k in input)) return { error: `${k} is required: copy base, head and tree from \`jig review --json\`` };
|
|
287
|
+
const base = full(root, input.base);
|
|
288
|
+
const head = full(root, input.head);
|
|
289
|
+
if (!base) return { error: `base ${input.base} is not a commit here` };
|
|
290
|
+
if (!head) return { error: `head ${input.head} is not a commit here` };
|
|
291
|
+
let tree = null;
|
|
292
|
+
if (input.tree !== null) {
|
|
293
|
+
tree = workTree(root);
|
|
294
|
+
if (tree !== input.tree || head !== full(root, 'HEAD')) return { error: `the tree reviewed (${String(input.tree).slice(0, 7)}) changed since the brief (now ${String(tree).slice(0, 7)}${head !== full(root, 'HEAD') ? ', and HEAD moved' : ''}); review the new tree` };
|
|
295
|
+
}
|
|
296
|
+
const t = Date.now();
|
|
297
|
+
const findings = input.findings.map((f) => ({ id: findingId(f), severity: f.severity, ...(f.confidence ? { confidence: f.confidence } : {}), file: f.file, line: f.line ?? null, class: f.class, title: f.title }));
|
|
298
|
+
const dup = findings.find((f, i) => findings.findIndex((g) => g.id === f.id) !== i);
|
|
299
|
+
if (dup) return { error: `two findings have the same id ${dup.id} (${dup.class} in ${dup.file}): give them titles that say how they differ, or report them as one finding with both lines` };
|
|
300
|
+
const rec = { v: 1, t, id: hash8(`${t}\0${tree}\0${head}`), head, base, tree, verdict: input.verdict, findings, ...(Number.isInteger(input.dropped) ? { dropped: input.dropped } : {}) };
|
|
301
|
+
appendFileSync(join(stateDir(root), 'reviews.jsonl'), JSON.stringify(rec) + '\n');
|
|
302
|
+
return { record: rec, trailer: `Reviewed: ${rec.verdict}, ${findings.length} findings (tree ${tree ? tree.slice(0, 7) : 'none'})` };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export function recordOutcome(root, id, outcome) {
|
|
306
|
+
if (!OUTCOMES.includes(outcome)) return { error: `outcome must be one of ${OUTCOMES.join(', ')}` };
|
|
307
|
+
if (!reviews(root).some((r) => (r.findings ?? []).some((f) => f.id === id))) return { error: `no finding ${id} in reviews.jsonl` };
|
|
308
|
+
const rec = { v: 1, t: Date.now(), kind: 'outcome', finding: id, outcome };
|
|
309
|
+
appendFileSync(join(stateDir(root), 'reviews.jsonl'), JSON.stringify(rec) + '\n');
|
|
310
|
+
return { record: rec };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// The owner-approved intent for a blind first pass: Outcome (with Done
|
|
314
|
+
// when), Decisions the owner decided, Out of scope, and the slice's Goal,
|
|
315
|
+
// Touch and Checks. Never the Log or the Now line, which are the builder's
|
|
316
|
+
// account of the work.
|
|
317
|
+
export function planIntent(plan, sliceId) {
|
|
318
|
+
const body = (name) => (section(plan, name)?.body ?? []).map((l) => l.trimEnd()).filter((l) => l.trim());
|
|
319
|
+
const s = plan.slices.find((x) => x.id === sliceId) ?? null;
|
|
320
|
+
return {
|
|
321
|
+
outcome: body('Outcome'),
|
|
322
|
+
decisions: body('Decisions').filter((l) => /Decided:\s*owner\b/i.test(l)),
|
|
323
|
+
outOfScope: body('Out of scope'),
|
|
324
|
+
slice: s ? { id: s.id, title: s.title, goal: s.fields.goal?.value ?? null, touch: s.fields.touch?.value ?? null, checks: s.fields.checks?.value ?? null } : null,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// ---------- the brief ----------
|
|
329
|
+
|
|
330
|
+
export function reviewBrief(root, opts = {}) {
|
|
331
|
+
const b = resolveBase(root, opts);
|
|
332
|
+
if (b.error) return b;
|
|
333
|
+
const head = b.head ?? full(root, 'HEAD');
|
|
334
|
+
let files;
|
|
335
|
+
try { files = diffFiles(root, b.base, b.head ?? null); } catch (e) { return { error: e.message }; }
|
|
336
|
+
if (!files.length && b.how === 'head') return { error: `nothing to review: no changes against HEAD${b.fallback.length ? ` (${b.fallback.join('; ')})` : ''}. Pass --base <ref>.` };
|
|
337
|
+
const pd = plansDir(root);
|
|
338
|
+
// The fingerprint is of the working tree, so it is the PR's only when the
|
|
339
|
+
// PR head is what's checked out.
|
|
340
|
+
const tree = b.head && b.head !== full(root, 'HEAD') ? null : workTree(root);
|
|
341
|
+
const ev = lastEvidence(root);
|
|
342
|
+
const all = reviews(root).filter((r) => !r.kind && r.findings);
|
|
343
|
+
const rv = all[all.length - 1] ?? null;
|
|
344
|
+
// Rounds of review on this base: a later round reviews only the diff since
|
|
345
|
+
// the last reviewed head, with the earlier findings.
|
|
346
|
+
const round = all.filter((r) => r.base === b.base).length + 1;
|
|
347
|
+
const active = activePlans(root);
|
|
348
|
+
// The plan whose intent the blind pass reads: the one the base came from,
|
|
349
|
+
// or with --base or --pr, the single plan with a doing slice.
|
|
350
|
+
const doingPlans = active.filter(({ plan }) => doingSlice(plan));
|
|
351
|
+
const mine = b.plan ? active.find(({ path }) => relative(root, path) === b.plan) : doingPlans.length === 1 ? doingPlans[0] : null;
|
|
352
|
+
const checks = active.some(({ path }) => loadChecks(path).exists);
|
|
353
|
+
const reviewText = git(root, ['show', `${b.base}:REVIEW.md`]);
|
|
354
|
+
// What the review skill's gate runs when there is no checks.json (doctor D1, D7).
|
|
355
|
+
const diag = diagnose(root);
|
|
356
|
+
const pick = (d) => (d ? { level: d.level, msg: d.msg, ...(d.id === 'D1' && d.level === 'ok' ? { commands: d.msg.replace(/^verify command found:\s*/, '').split(', ') } : {}) } : null);
|
|
357
|
+
const gate = { D1: pick(diag.find((d) => d.id === 'D1' && d.level !== 'info')), D7: pick(diag.find((d) => d.id === 'D7')) };
|
|
358
|
+
const brief = {
|
|
359
|
+
v: 1,
|
|
360
|
+
base: b.base, head, how: b.how,
|
|
361
|
+
...(b.plan ? { plan: b.plan, slice: b.slice } : {}),
|
|
362
|
+
intent: mine ? planIntent(mine.plan, b.slice ?? doingSlice(mine.plan)?.id) : null,
|
|
363
|
+
...(b.branch ? { branch: b.branch } : {}),
|
|
364
|
+
...(b.pr ? { pr: b.pr } : {}),
|
|
365
|
+
...(b.fallback?.length ? { fallback: b.fallback } : {}),
|
|
366
|
+
uncommitted: !b.head && Boolean(git(root, ['status', '--porcelain'])?.trim()),
|
|
367
|
+
tree,
|
|
368
|
+
stats: { files: files.length, adds: files.reduce((n, f) => n + f.adds, 0), dels: files.reduce((n, f) => n + f.dels, 0) },
|
|
369
|
+
files: files.map(({ path, adds, dels, binary, untracked }) => ({ path, adds, dels, ...(binary ? { binary } : {}), ...(untracked ? { untracked } : {}) })),
|
|
370
|
+
triggers: triggersFor(files, { plansDir: pd }),
|
|
371
|
+
reviewMd: reviewText === null ? null : reviewMdEntries(reviewText, files),
|
|
372
|
+
checks,
|
|
373
|
+
gate,
|
|
374
|
+
round,
|
|
375
|
+
evidence: ev ? { t: ev.t, plan: ev.plan, slice: ev.slice, tree: ev.tree, pass: (ev.results ?? []).length > 0 && ev.results.every((r) => r.pass), current: Boolean(tree && ev.tree === tree) } : null,
|
|
376
|
+
review: rv ? { t: rv.t, id: rv.id, verdict: rv.verdict, base: rv.base, head: rv.head, tree: rv.tree, current: Boolean(tree && rv.tree === tree), findings: rv.findings } : null,
|
|
377
|
+
};
|
|
378
|
+
// --blind: what a first, blind pass may see. The earlier verdict and the
|
|
379
|
+
// evidence record are opinions and claims, so they wait for Phase 2.
|
|
380
|
+
if (opts.blind) { delete brief.review; delete brief.evidence; }
|
|
381
|
+
return brief;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const short = (s) => (s ? s.slice(0, 7) : '-');
|
|
385
|
+
|
|
386
|
+
// The text brief: base and tree first, then what to look at.
|
|
387
|
+
export function formatBrief(b) {
|
|
388
|
+
const out = [];
|
|
389
|
+
out.push(`Base ${short(b.base)} (${b.how}${b.plan ? `: ${b.plan} ${b.slice}` : ''}${b.branch ? `: ${b.branch}` : ''}${b.pr ? `: PR #${b.pr.number} by ${b.pr.author}` : ''}) · head ${short(b.head)}${b.uncommitted ? ' + uncommitted' : ''} · tree ${short(b.tree)}`);
|
|
390
|
+
if (b.fallback?.length) out.push(`Fell back: ${b.fallback.join('; ')}`);
|
|
391
|
+
if (b.tree === null) out.push('Tree: none (the PR head is not checked out, so evidence and review records cannot match it)');
|
|
392
|
+
out.push(`Diff: ${b.stats.files} files, +${b.stats.adds} -${b.stats.dels}`);
|
|
393
|
+
if (b.triggers.length) for (const t of b.triggers) out.push(`Trigger ${t.id}${t.partner ? ` (${t.partner})` : ''}: ${t.files.slice(0, 5).join(', ')}${t.files.length > 5 ? ` and ${t.files.length - 5} more` : ''}`);
|
|
394
|
+
else out.push('Triggers: none');
|
|
395
|
+
if (b.reviewMd) {
|
|
396
|
+
for (const e of b.reviewMd.matched) out.push(`REVIEW.md: ${e.check} (Source: ${e.source}) on ${e.files.join(', ')}`);
|
|
397
|
+
if (b.reviewMd.judge.length) out.push(`REVIEW.md: ${b.reviewMd.judge.length} entr${b.reviewMd.judge.length === 1 ? 'y' : 'ies'} with no path trigger, for the reviewer to judge`);
|
|
398
|
+
}
|
|
399
|
+
out.push(`Gate: ${b.checks ? 'jig verify (checks.json)' : b.gate.D1?.level === 'ok' ? b.gate.D1.msg : 'no checks.json and no one-command verify'}${b.gate.D7?.level === 'ok' ? `; ${b.gate.D7.msg}` : ''}`);
|
|
400
|
+
out.push(`Evidence: ${b.evidence ? `${b.evidence.pass ? 'pass' : 'FAIL'} at tree ${short(b.evidence.tree)} (${b.evidence.current ? 'current' : 'stale'})` : 'none'}`);
|
|
401
|
+
out.push(`Review: ${b.review ? `${b.review.verdict} at tree ${short(b.review.tree)} (${b.review.current ? 'current' : 'stale'})` : 'none'}`);
|
|
402
|
+
return out.join('\n');
|
|
403
|
+
}
|
package/cli/lib/verify.mjs
CHANGED
|
@@ -7,9 +7,15 @@ import { stateDir, showHead, treeId, headSha } from './git.mjs';
|
|
|
7
7
|
import { plansDir } from './status.mjs';
|
|
8
8
|
import { today } from './scaffold.mjs';
|
|
9
9
|
|
|
10
|
+
// The last line that says something. Skips what an error object or stack
|
|
11
|
+
// trace ends with (node --test ends on `}`): brace-only lines, `at ...`
|
|
12
|
+
// frames, indented `key: value,` properties and node's closing `Node.js vNN`
|
|
13
|
+
// line. Falls back to the last line.
|
|
14
|
+
const NOISE = /^\s*[{}[\](),]*\s*$|^\s+at\s|^\s+[\w$]+: .*,?$|^Node\.js v\d/;
|
|
10
15
|
function lastLine(s) {
|
|
11
|
-
const lines = (s ?? '').split('\n').
|
|
12
|
-
|
|
16
|
+
const lines = (s ?? '').split('\n').filter((l) => l.trim());
|
|
17
|
+
const pick = lines.findLast((l) => !NOISE.test(l)) ?? lines[lines.length - 1] ?? '';
|
|
18
|
+
return pick.trim().slice(0, 200);
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export function runCheck(root, c) {
|
|
@@ -43,7 +49,7 @@ export function verifyPlan(root, planPath, opts = {}) {
|
|
|
43
49
|
const logged = Boolean(opts.record && results.length);
|
|
44
50
|
// After the checks: output they write must not make this record stale.
|
|
45
51
|
const tree = workTree(root);
|
|
46
|
-
const record = { t: Date.now(), plan, slice: opts.slice ?? null, fast: Boolean(opts.fast), logged, head: headSha(root, { short: false }), tree, checks, results: results.map(({ id, pass, exit, ms, why }) => ({ id, pass, exit, ms, ...(pass ? {} : { why: why.slice(0, 200) }) })) };
|
|
52
|
+
const record = { v: 1, t: Date.now(), plan, slice: opts.slice ?? null, fast: Boolean(opts.fast), logged, head: headSha(root, { short: false }), tree, checks, results: results.map(({ id, pass, exit, ms, why }) => ({ id, pass, exit, ms, ...(pass ? {} : { why: why.slice(0, 200) }) })) };
|
|
47
53
|
appendFileSync(join(stateDir(root), 'evidence.jsonl'), JSON.stringify(record) + '\n');
|
|
48
54
|
if (logged) appendLog(planPath, logLine(results, opts.slice, changes));
|
|
49
55
|
return { results, ...changes, tree };
|
|
@@ -104,13 +110,16 @@ export function appendLog(planPath, line) {
|
|
|
104
110
|
writeFileSync(planPath, lines.join('\n').replace(/\n*$/, '\n'));
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
// Every readable
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
// Every readable record in a .git/jig/*.jsonl file, oldest first. A corrupt
|
|
114
|
+
// line is skipped.
|
|
115
|
+
export function readJsonl(root, name) {
|
|
116
|
+
const p = join(stateDir(root), name);
|
|
110
117
|
if (!existsSync(p)) return [];
|
|
111
118
|
return readFileSync(p, 'utf8').split('\n').filter(Boolean).flatMap((l) => { try { return [JSON.parse(l)]; } catch { return []; } });
|
|
112
119
|
}
|
|
113
120
|
|
|
121
|
+
export const evidence = (root) => readJsonl(root, 'evidence.jsonl');
|
|
122
|
+
|
|
114
123
|
// The last readable record, parsed from the end: the Stop hook calls this on
|
|
115
124
|
// every turn, and records grow with the number of checks.
|
|
116
125
|
export function lastEvidence(root) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jig-plan",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Plan, verify and guard work done by coding agents: short reviewable plans, executable acceptance checks, and hooks that stop false completion claims.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,6 +34,16 @@ Read only the sections for areas the slice touches. Each question either has an
|
|
|
34
34
|
- Can a retry storm happen: clients retrying in lockstep, or retries multiplying through layers?
|
|
35
35
|
- Is ordering assumed anywhere it isn't guaranteed?
|
|
36
36
|
|
|
37
|
+
## Testing and verification
|
|
38
|
+
- Does a check run the change for real? When a slice changes what a user sees, one `e2e` check starts the app, CLI or service and drives the changed flow. Running the change catches what tests of its parts miss.
|
|
39
|
+
- Does a rule have a property, not only examples? The four shapes that cover most rules:
|
|
40
|
+
- **round-trip:** `decode(encode(x)) == x` (serializers, parsers, migrations up then down)
|
|
41
|
+
- **invariant:** something that holds after every operation (a balance never negative, a list stays sorted, counts add up)
|
|
42
|
+
- **idempotency:** doing it twice equals doing it once (retries, webhooks, `PUT`, migrations)
|
|
43
|
+
- **equivalence:** the new code gives the same result as a simpler or older one (an optimisation, a rewrite)
|
|
44
|
+
- Is this a rewrite or a migration that must keep behaviour? Use a `differential` check: run old and new on the same inputs and compare. Normalise the noise first (timestamps, ids, ordering, whitespace), and keep a checked-in list of approved differences, so a new difference fails and an approved one doesn't.
|
|
45
|
+
- Is a test flaky? Find the cause (shared state, time, ordering, a race). Don't retry, sleep or skip it. If you can't find the cause, delete the test and log why.
|
|
46
|
+
|
|
37
47
|
## Software design
|
|
38
48
|
- Does the change deepen an existing module or add a shallow one: a wrapper that passes calls through, or an interface with one implementation?
|
|
39
49
|
- Agents optimize locally. Does the change respect the boundaries and invariants the repo already has? Look for ADRs and module owners.
|
package/references/mechanisms.md
CHANGED
|
@@ -7,6 +7,7 @@ Prose instructions are advisory, and models follow them less as they pile up (IF
|
|
|
7
7
|
| A rule that must always hold ("never edit migrations", "no prod credentials") | Permission deny rule, or a PreToolUse hook | Deterministic: it runs whether or not the model remembers it |
|
|
8
8
|
| A behaviour that must be true of the code | A test, type or lint rule, run in CI | Fails the build instead of relying on review |
|
|
9
9
|
| A convention or non-obvious fact (build command, a trap in this repo) | One line in CLAUDE.md or AGENTS.md | Advisory and cheap. Only write what isn't already in the repo; generated context files raised cost 20–23% with no significant gain (Gloaguen et al., arXiv 2602.11988) |
|
|
10
|
+
| A review rule that only shows in a diff (no test can decide it) | A `When: · Check: · Source:` entry in REVIEW.md, applied by the diff reviewer from the base commit | Read only when the trigger matches, and a slice can't edit the copy that judges it |
|
|
10
11
|
| A procedure used now and then | A skill | Loaded only when needed, so it costs nothing the rest of the time |
|
|
11
12
|
| Investigation, or parallel work | A subagent, or one agent per git worktree split along module boundaries | Keeps searches and logs out of the main context and avoids merge conflicts |
|
|
12
13
|
| Access to an outside system | An MCP server, pinned, with a read-only token where possible | Each server widens what an injected instruction can reach |
|
|
@@ -135,7 +135,7 @@ The Log is append-only and dated: `- 2026-11-25: ...` or `- 2026-11-25 14:02: ..
|
|
|
135
135
|
|---|---|
|
|
136
136
|
| `id` | Letters, digits, `.`, `-` or `_`, starting with a letter. Unique |
|
|
137
137
|
| `slice` | A slice ID from the plan |
|
|
138
|
-
| `kind` | `acceptance`, `regression`, `property`, `mutation`, `perf` or `
|
|
138
|
+
| `kind` | `acceptance`, `regression`, `property`, `mutation`, `perf`, `security`, `e2e` (starts the real app, CLI or service and drives the changed flow) or `differential` (compares old and new output on the same inputs) |
|
|
139
139
|
| `cmd` | Shell command, run from the repo root |
|
|
140
140
|
| `expect.exit` | Expected exit code (default 0) |
|
|
141
141
|
| `expect.stdout` | Optional JavaScript regex the output must match |
|
package/skills/build/SKILL.md
CHANGED
|
@@ -43,8 +43,9 @@ Run `jig verify --record` for the slice. It runs the slice's checks, prints one
|
|
|
43
43
|
- **A check fails:** fix the code, not the check, and verify again. You get three rounds on the same check. If it still fails on the third `jig verify`, stop: don't try a fourth fix. Report to the owner what you changed in each round and the current error, and let them decide. The Stop hook counts the rounds from `evidence.jsonl` and says when you've reached three.
|
|
44
44
|
- **A check is flaky** (passes and fails on the same code): don't add retries, sleeps or a skip, and don't rerun it until it passes. Find the cause. If you can't, delete the test, log why, and tell the owner (deleting a protected test asks first). `jig lint` warns on a check command that retries or sleeps [J22], and rejects one that can't fail, such as `|| true` [J23].
|
|
45
45
|
- **A check can't run here** (missing service, credentials, hardware): say so in the Log and to the owner. Don't count it as passing.
|
|
46
|
+
- **The slice can't be done as specified** (the spec and a test conflict, a check can't pass in this environment, a service is missing): append a `Blocked: <reason>` line to the Log, for example `- 2026-11-26: Blocked: C3 needs a Postgres this sandbox doesn't have`, tell the owner, and stop. That's an accepted end state: the Stop hook, the rounds count and the commit gate let it through. Use it instead of a fourth fix or a weakened check. A model given an explicit way out cheats on impossible tasks far less, and more retries make it cheat more.
|
|
46
47
|
|
|
47
|
-
At the full tier,
|
|
48
|
+
At the full tier, run the `jig:review` skill on the slice. It runs the gate, the reviewer in two phases and the validator, and records a review tied to this tree. Fix the Important findings, or log why one doesn't apply. Nits are your call, and Pre-existing findings go to the owner rather than into this slice. Answer a finding only with evidence (a run, or a file:line). If you think one is wrong and can't show it, tell the owner rather than arguing with the reviewer. After fixing, run `jig:review` again with the earlier findings, so it reviews only the new diff. If it returns `rethink` (it does so in round 3 when Important findings are still open), stop and take the approach to the owner.
|
|
48
49
|
|
|
49
50
|
When the slice changes UI and the loupe skill is available, run it on the affected screens if the slice's done-when calls for it.
|
|
50
51
|
|
|
@@ -53,7 +54,7 @@ When the slice changes UI and the loupe skill is available, run it on the affect
|
|
|
53
54
|
1. Mark the slice `[done]` and update `Now:` to the next slice.
|
|
54
55
|
2. Append a Log line saying, in two or three sentences, what changed and why. This is for whoever reads the code next, including the owner checking they still understand their system.
|
|
55
56
|
3. Run `jig lint` on the plan.
|
|
56
|
-
4. Commit the slice with a message that says what it does. End the message with the `Verified:` line that `jig verify --record` printed, for example `Verified: S2 C1 pass, C2 pass (tree 3f2a91c)`. If nothing was verified, write `Verified: none (<reason>)` instead, so the commit can be found later.
|
|
57
|
+
4. Commit the slice with a message that says what it does. End the message with the `Verified:` line that `jig verify --record` printed, for example `Verified: S2 C1 pass, C2 pass (tree 3f2a91c)`. If nothing was verified, write `Verified: none (<reason>)` instead, so the commit can be found later. When the slice was reviewed, add the `Reviewed:` line that `jig review --record` printed on the next line.
|
|
57
58
|
|
|
58
59
|
Then stop and report to the owner:
|
|
59
60
|
- the slice
|
package/skills/guard/SKILL.md
CHANGED
|
@@ -37,6 +37,27 @@ Show the owner the mechanism, the exact change, and how you tested that it catch
|
|
|
37
37
|
|
|
38
38
|
Add a Log line to the active plan naming the failure and the guard.
|
|
39
39
|
|
|
40
|
+
## Review checklist entries
|
|
41
|
+
|
|
42
|
+
Some failures can't be caught by a test or lint rule, but a reviewer reading the diff would spot them. Those can become an entry in the repo's REVIEW.md, which the jig-reviewer applies in diff mode:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
- When: <a trigger readable from a diff, e.g. "a new route under src/api/"> · Check: <what to verify> · Source: <incident, PR or plan Log line>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Propose an entry only when all three hold:
|
|
49
|
+
- it has happened twice (find both occurrences)
|
|
50
|
+
- its trigger can be seen in a diff, without running anything
|
|
51
|
+
- it survived one attempt to disprove it: look for a past diff where the trigger matched and the problem wasn't there, and narrow the trigger if you find one
|
|
52
|
+
|
|
53
|
+
Show the owner the exact entry and let them commit REVIEW.md. Rule files are the owner's, and the reviewer reads REVIEW.md from the plan's Baseline commit, so an agent editing it mid-slice changes nothing anyway.
|
|
54
|
+
|
|
55
|
+
Prune the list when you add to it: drop entries whose Source no longer applies (the code is gone, or a test now catches it) and merge entries with the same trigger. A long checklist gets skimmed.
|
|
56
|
+
|
|
57
|
+
## Start a new gate in observe mode
|
|
58
|
+
|
|
59
|
+
A new hook or gate can misfire, and a gate that asks too often gets switched off. Ship it observing first. jig's own gates support `JIG_GATES=observe` (or `JIG_GATES=observe:<gate>,...`), which logs each decision to `.git/jig/observe.jsonl` instead of asking. For a hook you write, log what it would have blocked in the same way. After a few sessions, read the log with the owner, count the false positives, and only then let it enforce.
|
|
60
|
+
|
|
40
61
|
## Doctor
|
|
41
62
|
|
|
42
63
|
`jig doctor` reports gaps in a repo's harness and changes nothing. It checks:
|
|
@@ -46,6 +67,7 @@ Add a Log line to the active plan naming the failure and the guard.
|
|
|
46
67
|
- whether `.claude/settings.json` and `.mcp.json` need reading before you trust the repo
|
|
47
68
|
- for a secret scanner in CI
|
|
48
69
|
- for lockfile drift
|
|
70
|
+
- for a way to run the change end to end: a `.claude/skills/verify*/SKILL.md`, an e2e runner or an e2e script (D7; a gap for apps, a note for a CLI or library)
|
|
49
71
|
|
|
50
72
|
Run it, then turn each gap the owner cares about into a slice or a guard. Treat a repo you didn't write as untrusted: read its `.claude/` and `.mcp.json` before running an agent in it.
|
|
51
73
|
|
package/skills/plan/SKILL.md
CHANGED
|
@@ -66,6 +66,8 @@ What matters most, and why:
|
|
|
66
66
|
- `mutation` on core logic at the full tier
|
|
67
67
|
- `perf` with a threshold on hot paths
|
|
68
68
|
- `security` on auth and input
|
|
69
|
+
- `e2e` when the slice changes behaviour a user sees: one check that starts the real app, CLI or service and drives the changed flow, because tests alone miss what running it shows
|
|
70
|
+
- `differential` when a rewrite must keep behaviour: old and new on the same inputs (see `references/fundamentals.md`)
|
|
69
71
|
- **Risks** say how you'd notice each one and what you'd do instead. Don't score them.
|
|
70
72
|
- **No time estimates.** They are unreliable, and they turn into deadlines. Scope (slices, files, checks) is the measure.
|
|
71
73
|
|