liteagents 2.22.0 → 2.23.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/CHANGELOG.md +170 -1
- package/README.md +7 -5
- package/package.json +1 -1
- package/packages/ampcode/commands/branch-review.md +180 -14
- package/packages/ampcode/commands/docs-builder/docs-builder.cjs +25 -8
- package/packages/ampcode/commands/refactor.md +71 -3
- package/packages/ampcode/commands/release.md +49 -9
- package/packages/ampcode/commands/remember/AGENT_RULES.md +12 -3
- package/packages/ampcode/commands/remember.md +40 -7
- package/packages/ampcode/commands/ship.md +16 -0
- package/packages/claude/commands/branch-review.md +180 -14
- package/packages/claude/commands/docs-builder/docs-builder.cjs +25 -8
- package/packages/claude/commands/refactor.md +71 -3
- package/packages/claude/commands/release.md +49 -9
- package/packages/claude/commands/remember/AGENT_RULES.md +12 -3
- package/packages/claude/commands/remember.md +40 -7
- package/packages/claude/commands/ship.md +16 -0
- package/packages/droid/commands/branch-review.md +180 -14
- package/packages/droid/commands/docs-builder/docs-builder.cjs +25 -8
- package/packages/droid/commands/refactor.md +71 -3
- package/packages/droid/commands/release.md +49 -9
- package/packages/droid/commands/remember/AGENT_RULES.md +12 -3
- package/packages/droid/commands/remember.md +40 -7
- package/packages/droid/commands/ship.md +16 -0
- package/packages/opencode/command/branch-review.md +180 -14
- package/packages/opencode/command/docs-builder/docs-builder.cjs +25 -8
- package/packages/opencode/command/refactor.md +71 -3
- package/packages/opencode/command/release.md +49 -9
- package/packages/opencode/command/remember/AGENT_RULES.md +12 -3
- package/packages/opencode/command/remember.md +40 -7
- package/packages/opencode/command/ship.md +16 -0
|
@@ -103,6 +103,18 @@ function fenceMask(lines) {
|
|
|
103
103
|
// prose), sentences()'s own regex strip, and checkCitations/checkLinks doing none at all — so
|
|
104
104
|
// a page documenting the citation/link syntax INSIDE a fence got its own example flagged as
|
|
105
105
|
// a real violation. One mechanism: mask with fenceMask(), drop the masked lines.
|
|
106
|
+
// `text.split('\n')` returns a trailing EMPTY element for any file ending in a newline —
|
|
107
|
+
// which is nearly every file — so `lines.length` is real_lines + 1. That phantom line reached
|
|
108
|
+
// the index row's "N lines", the last H2's range (one line past EOF) and scan()'s outline.json.
|
|
109
|
+
// Use this wherever lines are COUNTED or a range is BOUNDED. The raw `.split('\n')` is still
|
|
110
|
+
// correct where the array is mapped and re-joined back into file text (stripFences,
|
|
111
|
+
// replaceOutsideFences): dropping the element there would strip the file's final newline.
|
|
112
|
+
function splitLines(text) {
|
|
113
|
+
const lines = text.split('\n');
|
|
114
|
+
if (lines.length && lines[lines.length - 1] === '') lines.pop();
|
|
115
|
+
return lines;
|
|
116
|
+
}
|
|
117
|
+
|
|
106
118
|
function stripFences(text) {
|
|
107
119
|
const lines = text.split('\n');
|
|
108
120
|
const mask = fenceMask(lines);
|
|
@@ -229,7 +241,7 @@ function scan(files) {
|
|
|
229
241
|
if (!files.length) die('usage: docs-builder.cjs scan <file.md...>');
|
|
230
242
|
const records = [];
|
|
231
243
|
for (const f of files) {
|
|
232
|
-
const lines = read(f)
|
|
244
|
+
const lines = splitLines(read(f));
|
|
233
245
|
const mask = fenceMask(lines);
|
|
234
246
|
const { h1, heads } = headings(lines, mask);
|
|
235
247
|
const h2s = heads.filter(h => h.lvl === 2);
|
|
@@ -522,8 +534,13 @@ const MIN_PAGE_LINES = 10;
|
|
|
522
534
|
function pageStatus(file) {
|
|
523
535
|
if (!fs.existsSync(file)) return 'TODO';
|
|
524
536
|
const txt = fs.readFileSync(file, 'utf8');
|
|
525
|
-
const lines = txt
|
|
526
|
-
|
|
537
|
+
const lines = splitLines(txt);
|
|
538
|
+
// splitLines() returns [] for a 0-byte file — 0 lines is the right COUNT, but it means
|
|
539
|
+
// lines[0] can be undefined, where the old raw split('\n') always yielded ['']. An empty
|
|
540
|
+
// page is reachable (a touched placeholder, or page-writing interrupted before it wrote
|
|
541
|
+
// anything) and must read as PARTIAL, not throw and take `plan` down with it.
|
|
542
|
+
const hasFrontmatter = lines.length > 0 && lines[0].trim() === '---'
|
|
543
|
+
&& lines.slice(1).some(l => l.trim() === '---');
|
|
527
544
|
return hasFrontmatter && lines.length >= MIN_PAGE_LINES ? 'done' : 'PARTIAL';
|
|
528
545
|
}
|
|
529
546
|
|
|
@@ -732,7 +749,7 @@ const ARCHIVE_WARN_ROWS = 100; // stated default, not measured — see docs-buil
|
|
|
732
749
|
// section a reader is being routed into, so its row stays H1 + line count + link only.
|
|
733
750
|
function indexRow(rel, dest, includeH2) {
|
|
734
751
|
const text = read(rel);
|
|
735
|
-
const lines = text
|
|
752
|
+
const lines = splitLines(text);
|
|
736
753
|
// Same headings()+fenceMask() path scan() uses -- no second parser -- so an H2 inside a
|
|
737
754
|
// ``` fence is masked out here exactly as it is there.
|
|
738
755
|
const mask = fenceMask(lines);
|
|
@@ -1398,7 +1415,7 @@ function ledger() {
|
|
|
1398
1415
|
const head = git(['rev-parse', 'HEAD'], 'reading HEAD (is this a git repo?)');
|
|
1399
1416
|
const docs = docFiles().map(f => ({
|
|
1400
1417
|
path: f,
|
|
1401
|
-
lines: read(f)
|
|
1418
|
+
lines: splitLines(read(f)).length,
|
|
1402
1419
|
sha256: sha(path.join(REPO, f)).slice(0, 16)
|
|
1403
1420
|
}));
|
|
1404
1421
|
const out = { sha: head, at: new Date().toISOString(),
|
|
@@ -1492,7 +1509,7 @@ function lint(files) {
|
|
|
1492
1509
|
if (!files.length) die('usage: docs-builder.cjs lint <file.md...>');
|
|
1493
1510
|
const sections = [];
|
|
1494
1511
|
for (const f of files) {
|
|
1495
|
-
const lines = read(f)
|
|
1512
|
+
const lines = splitLines(read(f));
|
|
1496
1513
|
const mask = fenceMask(lines);
|
|
1497
1514
|
let cur = null;
|
|
1498
1515
|
const close = i => { if (cur) { cur.e = i; cur.body = lines.slice(cur.s, i).join('\n'); } };
|
|
@@ -1665,7 +1682,7 @@ function isIncludeStub(lines) {
|
|
|
1665
1682
|
// but its size. Oversized is now orthogonal to sorting: a product doc that's too big is
|
|
1666
1683
|
// still a product doc.
|
|
1667
1684
|
function classifyDoc(rel, text) {
|
|
1668
|
-
const lines = text
|
|
1685
|
+
const lines = splitLines(text);
|
|
1669
1686
|
const mask = fenceMask(lines);
|
|
1670
1687
|
const { h1 } = headings(lines, mask);
|
|
1671
1688
|
const snip = snippet(lines, mask, 0, lines.length, 200);
|
|
@@ -2214,7 +2231,7 @@ function cleanup(files) {
|
|
|
2214
2231
|
+ `would overwrite that split's still-in-flight outline.json/labels.json. Finish it `
|
|
2215
2232
|
+ `first: write its remaining pages, then re-run \`cleanup-apply ${inFlight} ...\` until `
|
|
2216
2233
|
+ `it archives — THEN run \`cleanup ${file}\`.`);
|
|
2217
|
-
const lines = read(file)
|
|
2234
|
+
const lines = splitLines(read(file)).length;
|
|
2218
2235
|
const est = writeCostEstimate(1, lines);
|
|
2219
2236
|
console.log(`${file}: ${lines} lines`);
|
|
2220
2237
|
console.log(`est. write cost: $${est.toFixed(2)} (mid tier, floor assuming 1 page — the `
|
|
@@ -1,12 +1,80 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: refactor
|
|
3
3
|
description: Refactor [code]
|
|
4
|
-
usage: /refactor <code-section>
|
|
5
|
-
argument-hint: [file-or-function]
|
|
6
|
-
allowed-tools: Read, Edit, Grep, Glob, Bash(npm test *), Bash(npx jest *), Bash(npx vitest *), Bash(pnpm test *), Bash(yarn test *), Bash(pytest *), Bash(python *), Bash(go test *), Bash(cargo test *), Bash(make test *), Bash(git diff *)
|
|
4
|
+
usage: /refactor <code-section> | /refactor (no args = fix-ledger mode)
|
|
5
|
+
argument-hint: [file-or-function, or empty for the fix ledger]
|
|
6
|
+
allowed-tools: Read, Edit, Grep, Glob, Bash(npm test *), Bash(npx jest *), Bash(npx vitest *), Bash(pnpm test *), Bash(yarn test *), Bash(pytest *), Bash(python *), Bash(go test *), Bash(cargo test *), Bash(make test *), Bash(git diff *), Bash(git grep *), Bash(git status *), Bash(git rev-parse *), Bash(git switch *)
|
|
7
7
|
---
|
|
8
8
|
Refactor $ARGUMENTS.
|
|
9
9
|
|
|
10
|
+
## Guardrails
|
|
11
|
+
- **Spawn a worker and explicitly select your tool's mid tier.** State the
|
|
12
|
+
tier on the spawn — do not omit it and rely on a default. An omitted tier
|
|
13
|
+
inherits the *parent's* tier, which is not the same thing as the balanced
|
|
14
|
+
one. Pick the judgment-capable tier that is cheaper and faster than your top
|
|
15
|
+
reasoning tier. **Not the cheapest/fastest tier**: on judgment work it
|
|
16
|
+
measurably degrades (misclassification rates several times higher). Choose by
|
|
17
|
+
tier, not by a vendor model name copied from this file — names drift, and
|
|
18
|
+
this command ships to several tools. Fall back to running inline if your tool
|
|
19
|
+
has no subagent mechanism.
|
|
20
|
+
- **Escalate, never assume.** Anything you cannot decide, cannot verify, or
|
|
21
|
+
that this spec does not cover → **stop and report it to the orchestrator**
|
|
22
|
+
(the main session). Never improvise, never widen scope, never fix a side
|
|
23
|
+
issue you noticed along the way.
|
|
24
|
+
- **The worker does the work itself — no delegation.** The fixer must **not**
|
|
25
|
+
spawn subagents of its own. Every edit it reports, and every test run it
|
|
26
|
+
cites, has to be one it made or ran with its own tool calls: a relayed "I
|
|
27
|
+
fixed it and the suite is green" from a sub-worker is hearsay, and this
|
|
28
|
+
command's whole output is the claim that a change landed and the tests still
|
|
29
|
+
pass. A fix that delegates its work is a report about a report.
|
|
30
|
+
- **The HITL gates below belong to the orchestrator, not the worker.** A
|
|
31
|
+
subagent cannot hold a conversation with the user, so it cannot run a gate
|
|
32
|
+
that ends in *stop and ask*. When one trips — a failing test, a crossed
|
|
33
|
+
public API boundary, a change bigger than the bullet asked for — the worker
|
|
34
|
+
**stops there and hands the situation back**, with the options and its
|
|
35
|
+
reasoning but no choice made. The orchestrator asks. A worker that picks
|
|
36
|
+
revert / patch / update-test on the user's behalf has answered a question it
|
|
37
|
+
was never allowed to ask.
|
|
38
|
+
- **Edit only what a surviving bullet names.** Ledger mode's scope is the
|
|
39
|
+
bullets that survive revalidation, one change per bullet — not the
|
|
40
|
+
neighbouring code, not the formatting, not a second finding noticed on the
|
|
41
|
+
way past. Anything else goes back to the orchestrator to become a new
|
|
42
|
+
bullet.
|
|
43
|
+
- **Prove the blast radius with two checks, because neither sees what the
|
|
44
|
+
other does.** `git status --porcelain` at exit must list only files a
|
|
45
|
+
surviving bullet named — that is this command's scope guarantee, and unlike
|
|
46
|
+
`/branch-review` it is not expected to be empty. It cannot police the
|
|
47
|
+
memory directory: `.claude/` is normally gitignored, so porcelain stays
|
|
48
|
+
empty whether you deleted a fixed bullet, wrote nothing, or overwrote
|
|
49
|
+
`MEMORY.md`. So also take `md5sum .claude/remember/*` before you start and
|
|
50
|
+
again before you report, and show the comparison: only `fix-ledger.md` may
|
|
51
|
+
differ. `last-review.md` in particular is `/branch-review`'s to write —
|
|
52
|
+
a fixer that touches it forges the gate that judges its own work.
|
|
53
|
+
|
|
54
|
+
## Ledger mode — `$ARGUMENTS` empty
|
|
55
|
+
Work through `.claude/remember/fix-ledger.md`, the non-blocking findings
|
|
56
|
+
`/branch-review` has accumulated. Everything below (goals, constraints,
|
|
57
|
+
verification, HITL gates) still applies; this section only says what to
|
|
58
|
+
refactor and how to close each item.
|
|
59
|
+
|
|
60
|
+
1. **Tree must be clean and not on `main`.** The orchestrator runs this check
|
|
61
|
+
before spawning the worker, so a dirty tree costs no worker; the worker
|
|
62
|
+
then re-runs it as its own first act. `git status --porcelain` non-empty
|
|
63
|
+
→ stop, say what is uncommitted. On `main` → `git switch -c chore/fix-ledger`.
|
|
64
|
+
2. **Ledger missing or has zero bullets** → say so and stop. Nothing to do.
|
|
65
|
+
3. **Revalidate every bullet first, fix nothing yet.** For each: `git grep -F
|
|
66
|
+
"<snippet>" -- <path>`. **No hit → delete the bullet** and list it as
|
|
67
|
+
"cleaned by other work". Hit → re-read the surrounding code; if the finding
|
|
68
|
+
no longer holds, delete the bullet with a one-line reason. What survives is
|
|
69
|
+
the work list.
|
|
70
|
+
4. **Fix the survivors, one bullet per change**, under the constraints below.
|
|
71
|
+
Delete each bullet as its fix lands. A fix that turns out to need a
|
|
72
|
+
behaviour change is not a refactor — leave the bullet, note it in the report.
|
|
73
|
+
5. Run the tests as described below. Then report: **fixed / dropped / left**
|
|
74
|
+
with the reason per left item, and the remaining bullet count.
|
|
75
|
+
6. Say plainly: **commit, then run `/branch-review`** on this branch — ledger
|
|
76
|
+
mode is a fixer, not a review, and its diff gets the ordinary gate.
|
|
77
|
+
|
|
10
78
|
## Goals
|
|
11
79
|
- Reduce complexity
|
|
12
80
|
- Improve readability
|
|
@@ -56,20 +56,48 @@ separate command that must have run first.
|
|
|
56
56
|
A review must have run on this branch **at the current HEAD SHA**.
|
|
57
57
|
|
|
58
58
|
**Compare the SHAs yourself; do not settle for an answer.** Run `git rev-parse
|
|
59
|
-
HEAD` and compare it against the
|
|
60
|
-
|
|
61
|
-
puts the question to the one party with an
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
HEAD` and compare it against the `sha:` line in
|
|
60
|
+
`.claude/remember/last-review.md`, which `/branch-review` writes. Asking the
|
|
61
|
+
orchestrator "did a review run?" puts the question to the one party with an
|
|
62
|
+
incentive to say yes, so its word is not evidence — and neither is a SHA
|
|
63
|
+
quoted from a chat message, which is the same claim in another costume and is
|
|
64
|
+
gone after a compaction or a handover. Read the file; match the two strings.
|
|
65
|
+
**No such file, or no `sha:` line in it = no review**, never a pass. A review
|
|
66
|
+
that predates this file's introduction has no record, so it does not count.
|
|
64
67
|
|
|
65
68
|
- **No review**, or no recorded SHA obtainable → **stop**: "No review at
|
|
66
69
|
`<sha>`. Run `/branch-review medium` (or `/code-review medium`) first."
|
|
67
70
|
- **Stale** — recorded SHA ≠ `git rev-parse HEAD`, i.e. commits landed after
|
|
68
71
|
the review (including fix commits) → **stop** and ask for a re-review. This
|
|
69
72
|
is what makes "all findings fixed" checkable instead of promised.
|
|
73
|
+
**No exceptions — including the fix ledger.** It is normally gitignored, so
|
|
74
|
+
appending to it moves nothing and this never comes up. A repo that tracks
|
|
75
|
+
`.claude/` instead will see a ledger commit land after the review and make
|
|
76
|
+
it stale. That is the rule working, not a case to carve out: re-review, or
|
|
77
|
+
leave the ledger uncommitted until after the release.
|
|
78
|
+
- **`coverage:` naming any stage `NOT RUN`** → **stop**. A `ready` from a run
|
|
79
|
+
that skipped the security stage is not the same fact as one that did not,
|
|
80
|
+
and this line is the only place the difference is visible to you.
|
|
81
|
+
- **`verdict: blocked` in the record** → **stop**, even when the SHA matches.
|
|
82
|
+
Read that line as mechanically as the `sha:` one. A matching SHA proves a
|
|
83
|
+
review ran here; it says nothing about what the review concluded, and
|
|
84
|
+
leaving the conclusion to the orchestrator's recollection restores exactly
|
|
85
|
+
the unverified claim this file replaced. Only `verdict: ready` with a
|
|
86
|
+
matching SHA is a pass.
|
|
70
87
|
- **Reviewed at this SHA with findings outstanding** → **stop**. Findings are
|
|
71
88
|
resolved before a release is cut.
|
|
72
89
|
|
|
90
|
+
This phase runs **before** `/release` writes anything, so the docs-and-bump
|
|
91
|
+
commit it makes later cannot invalidate the review it just checked. That
|
|
92
|
+
If Phase 2's docs sweep happens to correct a line that a fix-ledger bullet
|
|
93
|
+
also names, that is ordinary sweep work — the doc changed with the feature,
|
|
94
|
+
so it was already yours to update. **Do not delete the bullet.** `/refactor`
|
|
95
|
+
is the only deleter, and its revalidation will drop that bullet on its next
|
|
96
|
+
run when it finds the finding no longer holds. Deleting it here would make
|
|
97
|
+
`/release` a second writer on state that has exactly one owner, and the whole
|
|
98
|
+
value of the ledger's one-append-one-delete split is that it stays readable
|
|
99
|
+
as a log.
|
|
100
|
+
|
|
73
101
|
Report the comparison you actually ran: recorded `<sha>` vs HEAD `<sha>`,
|
|
74
102
|
match yes/no.
|
|
75
103
|
|
|
@@ -141,15 +169,27 @@ orchestrator can run them on the user's named go:
|
|
|
141
169
|
> Ready when you are:
|
|
142
170
|
> 1. `git push -u origin <branch>`
|
|
143
171
|
> 2. `gh pr create` into `main`
|
|
144
|
-
> 3. `gh pr
|
|
172
|
+
> 3. `gh pr checks <pr> --watch` — **merge only on green.** Every gate before
|
|
173
|
+
> this one ran on the same machine; CI is the only differently-configured
|
|
174
|
+
> instrument in the chain, and this is the first time it sees the branch.
|
|
175
|
+
> A test that passes locally because of a path, a fixture, or a tool that
|
|
176
|
+
> exists only on your box fails here and nowhere earlier. Read the exit
|
|
177
|
+
> code off the bare command. Red → stop, fix, re-review, and start again.
|
|
178
|
+
> 4. `gh pr merge --admin --squash --delete-branch` (main is PR-protected;
|
|
145
179
|
> owner-authorized admin merge on a solo repo). **Keep `--squash`** — `gh`
|
|
146
180
|
> requires an explicit merge-method flag (`--squash` / `--merge` /
|
|
147
181
|
> `--rebase`); drop it and the command will not squash-merge.
|
|
148
|
-
>
|
|
149
|
-
>
|
|
182
|
+
> 5. `git tag vX.Y.Z` on `main` and push the tag
|
|
183
|
+
> 6. Publish **if this project has a publish path** (e.g.
|
|
150
184
|
> `gh workflow run publish.yml`) — manual by design
|
|
151
|
-
>
|
|
185
|
+
> 7. Verify it is actually live (`npm view <pkg> version`, and the published
|
|
152
186
|
> tarball's contents), not the working tree
|
|
153
187
|
|
|
188
|
+
**Every exit code in this sequence is read off the bare command, including
|
|
189
|
+
the ones you type yourself.** `/ship`'s rule is not just for the worker: a
|
|
190
|
+
pipeline reports its last element's status, so `gh run watch --exit-status |
|
|
191
|
+
tail -2; echo $?` prints `0` for a failed run. That has already turned a red
|
|
192
|
+
CI into a green reading in a real release.
|
|
193
|
+
|
|
154
194
|
Final line: **Cut ✅ (vX.Y.Z — ready to push)** or **Blocked 🛑** with the
|
|
155
195
|
specific reason.
|
|
@@ -105,11 +105,14 @@ Before adding any external dependency, all of these must be true:
|
|
|
105
105
|
|
|
106
106
|
- **Open-source only.** Always use open-source solutions. No vendor lock-in
|
|
107
107
|
- **Lightweight over complex.** If two solutions solve the same problem, use the one with fewer moving parts, fewer dependencies, and less configuration
|
|
108
|
-
- **Every line
|
|
108
|
+
- **Every line earns its place.** If you can't say what breaks when it's deleted, delete it. No speculative code, no "might need this later", no abstractions for one use case. One function, one concern, one owner — small blocks beat spaghetti
|
|
109
109
|
- **Simple > clever.** Readable code that a junior can follow beats elegant code that requires a PhD to debug
|
|
110
|
+
- **One writer per piece of state.** One function assigns each field; everything else calls it. Grep who writes it before you write it. Ownership says *where*, not *when* — if a write can land from a callback, thread, or lifecycle, the reader must tell stale from fresh
|
|
111
|
+
- **Split the decision from the machinery.** A branch whose outcome matters, tangled with a framework, IO, or UI object, moves into a pure function; the framework class applies the result. Extract to pin a branch, not to raise coverage — a one-line delegation in its own file buys a test that cannot fail
|
|
112
|
+
- **Claims in comments must be checkable.** "The only place that writes X" is a claim — run the grep first, and expect the next reader to re-run it. A name search proves an edge exists, never that one doesn't
|
|
110
113
|
- **Containerize only when necessary.** Start with a virtualenv or bare metal. Docker adds value for deployment parity and isolation — not for running a script
|
|
111
114
|
- **Responsive web UI is mandatory in dev projects.** Any web UI must be usable on mobile by default — fluid layouts, viewport meta tag, breakpoints for narrow screens, no horizontal scroll. Test in DevTools device emulation before declaring a UI task done. POCs are exempt (validate the idea first), but the moment a POC graduates to a real project this becomes a hard requirement
|
|
112
|
-
- **Surgical changes only.** Touch what the task requires; nothing else. Don't "improve" adjacent code, comments, or formatting. Match existing style even if you'd do it differently. Only clean up orphans your own change created — leave
|
|
115
|
+
- **Surgical changes only.** Touch what the task requires; nothing else. Don't "improve" adjacent code, comments, or formatting. Match existing style even if you'd do it differently. Only clean up orphans your own change created. Dead code, nits, bugs you pass on the way: if it's inside or affects the code you're already changing, and the fix changes no behavior, fix it and say so. Otherwise report it — say what it costs to leave it. "It would be nicer" is not a cost. Every changed line traces to the request or to a fix you named
|
|
113
116
|
|
|
114
117
|
### Red Flags — Stop and Flag These
|
|
115
118
|
- Over-engineering simple problems
|
|
@@ -121,6 +124,8 @@ Before adding any external dependency, all of these must be true:
|
|
|
121
124
|
- Authoring a fixture/corpus that *guarantees* the result (a test that can't return the negative), or trusting a degenerate-looking number without auditing the harness for confounds — use real uncrafted data; the test must be able to fail
|
|
122
125
|
- Fitting a POC to pass (narrowed input, moved threshold, shrunk scope) instead of reporting the failure; starting module N+1 while module N is unproven
|
|
123
126
|
|
|
127
|
+
A problem you see and don't fix goes in the report, never in a comment. Comments are where findings go to be forgotten.
|
|
128
|
+
|
|
124
129
|
---
|
|
125
130
|
|
|
126
131
|
## Testing Standards
|
|
@@ -291,7 +296,11 @@ Copy this to any project's AGENTS.md. These are mandatory rules, not suggestions
|
|
|
291
296
|
|
|
292
297
|
**Lightweight over complex.** Fewer moving parts, fewer deps, less config. Express over NestJS, Flask over Django, unless the project genuinely needs the framework. Simple > clever. Readable > elegant.
|
|
293
298
|
|
|
294
|
-
**Open-source only.** No vendor lock-in. Every line of code
|
|
299
|
+
**Open-source only.** No vendor lock-in. Every line of code earns its place — if you can't say what breaks when it's deleted, delete it. No speculative code, no premature abstractions.
|
|
300
|
+
|
|
301
|
+
**One writer per piece of state.** One function assigns each field; everything else calls it. Grep who writes it before you write it — and if a write can land from a callback, thread, or lifecycle, the reader must tell stale from fresh.
|
|
302
|
+
|
|
303
|
+
**Surgical changes only.** Touch what the task requires. Dead code, nits, bugs you pass: if it's inside or affects the code you're already changing and the fix changes no behavior, fix it and say so — otherwise report it and say what it costs to leave it. A problem you don't fix goes in the report, never in a comment.
|
|
295
304
|
|
|
296
305
|
**Responsive web UI is mandatory.** Any web UI must work on mobile by default — fluid layouts, viewport meta, breakpoints, no horizontal scroll. Verify in DevTools device emulation before claiming a UI task is done. POCs exempt; real projects are not.
|
|
297
306
|
|
|
@@ -133,6 +133,14 @@ Reads all raw material (`.factory/stash/*.md` + `.factory/remember/friction/anti
|
|
|
133
133
|
Re-processing a stash whose episode is already filed must not create a near-duplicate
|
|
134
134
|
pair. Every older episode is **folded, then deleted**: its lesson becomes a fact (handed
|
|
135
135
|
to the rewrite above); the narrative is removed. No archive — git has the history.
|
|
136
|
+
**Specify the operation once.** The keep-10 rule is the rule; the set to remove is
|
|
137
|
+
*derived* from it, never supplied alongside it as a second list. Given both, an agent
|
|
138
|
+
applies both and removes their union — observed in the field: a run told to keep 10 and
|
|
139
|
+
handed a 5-entry delete list removed 7, and the 2 extras were never folded, so one
|
|
140
|
+
lesson left memory with nothing carrying it. **No episode is removed whose lesson has
|
|
141
|
+
not been folded into a fact first**, and the two sets must match: state the count
|
|
142
|
+
before, the count after, and name each episode removed. Removed-but-not-folded is a
|
|
143
|
+
defect to report, not a tidy-up.
|
|
136
144
|
- **Antigens section**: only update from friction output (step 4)
|
|
137
145
|
- Write merged result to `.factory/remember/MEMORY.md` in the format under step 5.
|
|
138
146
|
|
|
@@ -276,7 +284,11 @@ Reads all raw material (`.factory/stash/*.md` + `.factory/remember/friction/anti
|
|
|
276
284
|
recurrence; a single occurrence has none to track yet. Friction re-scans every
|
|
277
285
|
session log every run, so a later run matches it back to 2+ sessions and seeds it
|
|
278
286
|
then — this does not change matching against an EXISTING entry, which is recurrence
|
|
279
|
-
regardless of the matching cluster's own session count.
|
|
287
|
+
regardless of the matching cluster's own session count. **A match is not an
|
|
288
|
+
increment.** Whether it counts as a new conversation is decided in 4c by
|
|
289
|
+
`friction.cjs count`, which is a no-op when that session hash is already stored — so
|
|
290
|
+
several matches against one entry routinely produce zero increments, and that is
|
|
291
|
+
correct, not a miscount.
|
|
280
292
|
- For `new:<theme>` groups with no ledger match: distinct conversations = distinct
|
|
281
293
|
cluster indices in the group (within one classify batch, no two cluster indices
|
|
282
294
|
share a session hash). `sessions < 2` → writes nothing. `sessions >= 2` → new entry,
|
|
@@ -346,18 +358,39 @@ Reads all raw material (`.factory/stash/*.md` + `.factory/remember/friction/anti
|
|
|
346
358
|
inline duplication is needed
|
|
347
359
|
- If `.factory/remember/AGENT_RULES.md` exists (bootstrapped in step 1), compose a second,
|
|
348
360
|
independent section between `<!-- AGENT_RULES:START -->` and `<!-- AGENT_RULES:END -->`
|
|
349
|
-
markers. Unlike MEMORY.md above,
|
|
350
|
-
|
|
351
|
-
|
|
361
|
+
markers. Unlike MEMORY.md above, the file itself is **never `@`-referenced** — an
|
|
362
|
+
`@`-reference hot-loads all ~300 lines into every session, and it is a standards guide
|
|
363
|
+
to consult when designing/building something new, not hot context. The section carries
|
|
364
|
+
a path pointer plus exactly two inline rules: the ones that change what you TYPE, which
|
|
365
|
+
you cannot look up because you do not know you need them. Everything else stays behind
|
|
366
|
+
the pointer. Write the section verbatim, rules first:
|
|
352
367
|
```
|
|
353
368
|
<!-- AGENT_RULES:START -->
|
|
369
|
+
**One writer per piece of state.** One function assigns each field; everything else
|
|
370
|
+
calls it. Grep who writes it before you write it — and if a write can land from a
|
|
371
|
+
callback, thread, or lifecycle, the reader must tell stale from fresh.
|
|
372
|
+
|
|
373
|
+
**Surgical changes only.** Touch what the task requires. Dead code, nits, bugs you
|
|
374
|
+
pass: if it's inside or affects the code you're already changing and the fix changes
|
|
375
|
+
no behavior, fix it and say so — otherwise report it and say what it costs to leave
|
|
376
|
+
it. A problem you don't fix goes in the report, never in a comment.
|
|
377
|
+
|
|
354
378
|
Standards guide (read when designing/building something new, not hot context):
|
|
355
379
|
.factory/remember/AGENT_RULES.md
|
|
356
380
|
<!-- AGENT_RULES:END -->
|
|
357
381
|
```
|
|
358
|
-
- Each marker pair is independent: if AGENTS.md
|
|
359
|
-
|
|
360
|
-
containing whichever section(s) apply
|
|
382
|
+
- Each marker pair is independent: if AGENTS.md lacks a given pair, append it at the
|
|
383
|
+
end; if a given pair already exists, replace its content in place; if no AGENTS.md
|
|
384
|
+
exists, create one containing whichever section(s) apply.
|
|
385
|
+
- **An existing AGENT_RULES pair is left alone — bootstrap once, never overwrite.** The
|
|
386
|
+
block above is what to write when creating it, not a template to re-impose every run.
|
|
387
|
+
Users trim this section deliberately (a pointer-only variant is common), and rewriting
|
|
388
|
+
it silently re-adds text they removed, on every single run, forever. Observed in the
|
|
389
|
+
field: a run restored the inline rules into a AGENTS.md whose owner had cut them, and
|
|
390
|
+
the edit had to be reverted by hand. This matches how `AGENT_RULES.md` itself is
|
|
391
|
+
handled — bootstrapped once, never overwritten after.
|
|
392
|
+
- If an existing pair is present but its **path pointer** is missing or wrong, that is
|
|
393
|
+
load-bearing: **report it and stop**, do not silently rewrite the section around it.
|
|
361
394
|
|
|
362
395
|
```markdown
|
|
363
396
|
# Project Memory
|
|
@@ -20,6 +20,22 @@ its exit code**. A check you did not run is a **fail**, never a pass. **N/A
|
|
|
20
20
|
requires a stated reason** ("no build script in `package.json`") — N/A must
|
|
21
21
|
never stand in for "didn't get to it."
|
|
22
22
|
|
|
23
|
+
**Capture the exit code of the command itself, never of a pipeline.** Run the
|
|
24
|
+
bare command, then read `$?` on the next line:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
node "$f" > /tmp/out 2>&1; e=$?
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`$?` after a pipe is the *last element's* status, so the common shape
|
|
31
|
+
`out=$(cmd 2>&1 | tail -1); echo "exit=$?"` reports `tail`'s success — `0` —
|
|
32
|
+
for a suite that exited `2`. Reproduced: a check printing "exit 2:
|
|
33
|
+
prerequisites missing" was recorded as a pass by exactly that loop. Nor does
|
|
34
|
+
`${PIPESTATUS[0]}` rescue it inside a command substitution; it is empty by
|
|
35
|
+
the time you read it. This is the rule the whole gate rests on, and the
|
|
36
|
+
piped form is the natural way to write a multi-suite loop, so it fails
|
|
37
|
+
silently and in the unsafe direction.
|
|
38
|
+
|
|
23
39
|
## Checklist
|
|
24
40
|
- [ ] **Tests pass** — run the project's real test command (`npm test`,
|
|
25
41
|
`pytest`, `go test ./...`, `cargo test`, `make test`).
|