@techgoblin/gobstack 0.6.0 → 0.7.3

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 CHANGED
@@ -5,6 +5,18 @@ version recorded in a target's `.goblin/installed.json` and the source `VERSION`
5
5
 
6
6
  ## Unreleased (v3 core: a default row set + a library)
7
7
 
8
+ - **`AG-01`: an instruction file changes only with a recorded approval.** `AGENTS.md` — the file
9
+ the gates are read from, editable by the very worker the gate polices — is now hash-pinned to
10
+ `.gob/agents.approved` (append-only: date · sha256 · approver · one-line reason, latest row
11
+ wins). New command `gob approve-agents "<reason>"` (`--approver` defaults to the repo's git
12
+ `user.name`, then `$USER`), shipped in `.gob/bin/goblin-approve` and routed through the npm
13
+ shim. `goblin-verify --only AG-01` passes when the hash matches, FAILs naming the file, both
14
+ hashes and the fix command when it does not, and SKIPs (exit 3 under `--only AG-01` alone)
15
+ when no record exists — an existing install never turns red by upgrading. `gob init --write`
16
+ writes the first record, so a fresh install is green on day one; a re-run never re-approves.
17
+ Only the hash is coverage: a record row carries no file name, so a reason naming another file
18
+ clears nothing (the control pins it). What the row cannot see — a forged record, an unread
19
+ diff, a record rewritten alongside the file — is docs/LIMITS.md #60.
8
20
  - **The default verifier is the ~19-row core; the rest lives in a library.** `verify` now runs a
9
21
  row set that is right for every repo — `IN-01..04`, `HP-01/02/03/05`, `GT-01/02/03`,
10
22
  `FM-01/02`, `SC-01`, `SK-01..04`, `BN-00`, plus the 8 `applies_when`-gated bans. The other 32
@@ -42,6 +54,131 @@ version recorded in a target's `.goblin/installed.json` and the source `VERSION`
42
54
  promotes them into catalogue.tsv by PR or edit. `--write` honours only the proposal's TICKED
43
55
  rows, through `gob extras install` itself — one allowlist, one code path.
44
56
 
57
+ ## 0.7.3 (categories: the anti-slop filter is inventoried)
58
+
59
+ - **`manifest/categories.tsv` gains a fourth external pack: `anti-slop`.** MIT, v3.2.33,
60
+ `github.com/miqdadbadjuber/anti-slop` — six `SKILL.md` packs (a 40-rule filter in three tiers
61
+ behind a delivery gate, plus ui / copywriting / human / layoutmobile / code-comment) that catch
62
+ the generic-output failure modes mechanical checks do not: fabricated proof, decorative status,
63
+ comments that restate the line, uniform rhythm in copy. Its `fits_when` requires a target that
64
+ ships a web surface or user-facing copy, so a repo with neither records `declined` with a
65
+ reason. Data only — no executable line reads the file; the agent adjudicates the row at init and
66
+ writes `compose-decisions.tsv`. Not vendored: a project installs the upstream skill files itself
67
+ under the SK-01..04 lane every external pack uses, and a skipped pack stays visible as a
68
+ decision rather than quietly missing.
69
+
70
+ ## 0.7.2 (installer: a re-install keeps every line the project declared)
71
+
72
+ The carry in 0.7.1 was a LIST of seven names (`CARRY_KEYS`). Every other key the render drew
73
+ from a hardcoded literal was overwritten with the template default on a plain re-install, and
74
+ every key the render did not emit at all was silently deleted — comment lines included.
75
+ Measured on a fixture (kit 0.7.1, declare, then re-install with no flags): `ratchet.ceiling:
76
+ 1105500` -> `0`; `gate_tsc_build_cmd: npx tsc --noEmit && npx vite build` -> line gone; three
77
+ `#` comment lines -> gone (same fixture against this build: all three kept, second consecutive
78
+ re-install byte-identical). Measured on `~/projects/tech-goblin/lab/diagram-studio`'s restored
79
+ AGENTS.md adopted into a fixture: `ratchet.ceiling: 1105500`, `gate_tsc_build_cmd`,
80
+ `perf.baseline_commit: 0bde816`, `perf.baseline_value: 831522`, `security.build_output:
81
+ dist/assets` and its 301-line ratchet comment block all kept through a re-install (`rc=0`);
82
+ the only change to the block is the three keys this template emits that the old block lacked,
83
+ appended at the end.
84
+
85
+ Two measured fixes round out the same carry: the `--opt-out` re-record stripped no brackets
86
+ (`${cur#[]}` is an empty glob class), so a fresh install with `--opt-out mcp` rendered the
87
+ malformed `disabled: [[mcp],mcp]` on 0.7.1 AND on this build — now the opt-out seeds from the
88
+ previous value with brackets stripped, appends its part once, dedupes and sorts: `[mcp]` stays
89
+ `[mcp]` across re-installs, `--opt-out skills` on top gives `[mcp,skills]`, and an empty set
90
+ renders `disabled: []`.
91
+
92
+ The carry is no longer a list: the previous block is read as LINES and
93
+ every line the new render did not reproduce under the same key is kept — a pair's previous
94
+ value replaces the rendered one, a pair the render does not emit is re-inserted, a comment
95
+ survives verbatim in its old relative position. Two rules sit above the merge: a flag is a
96
+ decision (`--gate`, `--archive`, `--opt-out` keep the rendered value), and a value the project
97
+ deliberately blanked stays blank. The practice pin's own contract is unchanged and sits above
98
+ the merge — an `--upgrade` never re-pins the standard by itself, even when `--practice` names a
99
+ file; `--re-pin` remains the deliberate path. Fresh installs render exactly as before. No row
100
+ changes: 26 enforcement + 32 library stays.
101
+
102
+ ## 0.7.1 (installer: a re-install keeps the block's declared values)
103
+
104
+ Two fixes that landed after 0.7.0 was tagged, both about `goblin-install` erasing a value the
105
+ repo had declared. No row changes: 58 target rows, the same measured baseline.
106
+
107
+ ### Fixed
108
+
109
+ - **A re-install no longer blanks a declared key.** The block is rendered from the template on every
110
+ install and written wholesale, and the render call draws a set of keys from hardcoded literals
111
+ (`feature_map`, `verify_doctor`, `reference_manifest`, `quarantine_root`, `source_root`, `max_dirty`,
112
+ `bans_exempt` — `CARRY_KEYS`, the whole enumeration) — so a plain `goblin-install` (no `--upgrade`)
113
+ erased every declared value and the gate reading it fell back to SKIP: `FM-01`/`FM-02`, `VA-01`,
114
+ `RC-01`, `CM-03` and the `bans_exempt:` route were all rows a re-install could switch off by
115
+ deleting their subject. The installer now carries each previous value forward through the
116
+ round-trip reader (`g_agents_pairs`, so a value containing ": " or a raw tab survives), and the
117
+ carry replaces the rendered line rather than appending a duplicate. A value the project blanked
118
+ stays blank — the carry never resurrects one — and a key whose literal default is real
119
+ (`source_root: .`, `max_dirty: 0`) re-renders that default, exactly as a fresh install does.
120
+ `tests/t-install-feature-map-carry.sh` plants every key, re-installs twice, asserts the block is
121
+ byte-identical, diffs a fresh install against the pre-change renderer, and carries the negative
122
+ control (4 in -> 0 out with the carry switched off; on the previous engine the same plants measure
123
+ 0/6 and 4 in -> 1 out).
124
+
125
+ ## 0.7.0 (curation: framework-agnostic)
126
+
127
+ Rows removed is a breaking change: a repo upgrading from 0.6.x loses six rows (see Removed) and
128
+ four rows stop passing vacuously (see Fixed). Measured default green after this change:
129
+ `19 passed, 0 failed, 0 advisory, 7 skipped` on a fresh install of every shape (Godot, Python,
130
+ docs-only) — was `20 passed, 0 failed, 0 advisory, 11 skipped`.
131
+
132
+ ### Removed
133
+
134
+ - **`BN-06`..`BN-09` (Electron renderer isolation).** The four bans state Electron mechanics
135
+ (`nodeIntegration`, `contextIsolation`+`sandbox`, `webPreferences`, `sendSync`+`@electron/remote`)
136
+ that no repo in the fleet has. They were gated on a `dep:electron` predicate so other shapes
137
+ skipped them, but the statement itself is framework-bound; the rule text moves to the audit doc
138
+ for the project that needs it. Their `bans.tsv` rows went with them (`BN-00` recount: 4 bans).
139
+ - **`HV-02` (browser bounding box guard).** A `getBoundingClientRect` probe run through a Node
140
+ child process — the web-automation surface of one project. On every other shape it graded the
141
+ kit's own `checks/*.mjs` scaffold and passed by measuring nothing.
142
+ - **`SC-09` (auth consistency across sibling routes).** "Sibling routes" is web routing; the row
143
+ was advisory prose with no check at all.
144
+
145
+ ### Fixed
146
+
147
+ - **`SC-03` no longer passes without inspecting.** Zero JS-family source files and no declared
148
+ build output used to print `PASS 0 client-visible secret-shaped name(s); no build output to
149
+ scan for clause 2`; it now SKIPs with that reason. PASS requires at least one examined artifact.
150
+ - **`SC-04` no longer passes without inspecting.** Zero cookie writes examined now SKIPs
151
+ (`no cookie write found in N examined file(s)`) instead of `PASS 0 cookie write(s) checked`;
152
+ a non-JS repo's `set_cookie` is a named skip, not a green.
153
+ - **`SC-05` no longer passes on an undeclared or unmatched route surface.** Undeclared
154
+ `security.write_routes` now SKIPs (`there is no route surface to check`); a declared surface
155
+ matching zero handlers now SKIPs naming the declaration and the 0 matches, instead of
156
+ `PASS 0 write handler(s), 0 waived`.
157
+ - **`HS-02` counts what it actually replayed.** Zero replayed harnesses now SKIPs
158
+ (`no harness in <dir> matched the replay set`) instead of `PASS every harness was RED at <sha>`;
159
+ the PASS names the count, the commit and the extension set, and files outside the replay set
160
+ are listed as `not replayed:` rather than silently ungraded.
161
+ - **`HV-01` no longer false-REDs a non-JS harness file.** A harness directory whose only files are
162
+ not JS-family now SKIPs (`the text probe reads import/require syntax it cannot see in other
163
+ languages`) instead of accusing the file.
164
+ - **Nine rows now name their ecosystem and prove their skip.** `BN-01`/`BN-02`/`BN-03`/`BN-05`,
165
+ `HV-01`, `SC-02`, `SC-06`, `RC-02`, `RC-04` carry an `ecosystem:` token in the artifact cell,
166
+ and a fixture of another shape must get SKIP(3) with a reason — never a PASS graded on nothing
167
+ (controls in tests/t-verify-red.sh).
168
+
169
+ Method, class counts and the empirical baseline: docs/AUDIT-2026-11-25-framework-agnostic.md.
170
+
171
+ ## 0.6.1
172
+
173
+ A crash fix in the front door. `gob init --write` with a flag and no value hung forever, printing nothing: the
174
+ flag loop called `shift 2` when only one argument remained, which fails silently under `set -uo pipefail`, so the
175
+ argument was never consumed and the loop spun. The same shape hit every value flag, not just `--write`.
176
+
177
+ Now a value flag with no value, an unknown option, and a proposal path that does not exist all print one line
178
+ naming the problem and `usage: gob init --write <proposal-path>`, then exit 2 — nothing is installed. The
179
+ documented path is unchanged: `gob init --write <proposal>` still installs (22 files on a bare repo) and the
180
+ verifier then reports green.
181
+
45
182
  ## 0.6.0
46
183
 
47
184
  The first stable release of the v3 core: one `gob` verb set, an enforcement matrix that grows by data rather than by
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
- # gobstack
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/harveynguyen33/goblin-stack/main/assets/brand/lockup.svg#gh-dark-mode-only" alt="gobstack — a goblin who turns rules into gates" width="380">
3
+ <img src="https://raw.githubusercontent.com/harveynguyen33/goblin-stack/main/assets/brand/lockup-light.svg#gh-light-mode-only" alt="gobstack — a goblin who turns rules into gates" width="380">
4
+ </p>
5
+ <p align="center"><sub>a goblin who turns rules into gates — and counts the ones he cannot check.</sub></p>
2
6
 
3
- > **Personal layer note (2026-10-10):** this is Harvey's personal agent-enhancement layer — owner of one, zero users. Install = clone this repo + `gob init`; the npm package is FROZEN at 0.6.0-beta.1 and is not the install path.
7
+ # gobstack
4
8
 
5
- **gobstack** (npm: [`@techgoblin/gobstack`](https://www.npmjs.com/package/@techgoblin/gobstack))
6
- installs an **executable rule manifest**, a **vendored verifier**, and an **AGENTS.md-frontmatter
7
- config** into any project — so that an AI coding session never re-improvises, and a rule that
8
- cannot be checked is counted rather than asserted.
9
+ **An executable rule manifest for AI coding sessions.** gobstack (npm:
10
+ [`@techgoblin/gobstack`](https://www.npmjs.com/package/@techgoblin/gobstack)) installs an
11
+ **executable rule manifest**, a **vendored verifier**, and an **AGENTS.md-frontmatter config** into any
12
+ project — so that an AI coding session never re-improvises, and a rule that cannot be checked is
13
+ counted rather than asserted.
9
14
 
10
15
  Start here — `init` is the first verb, and it needs no global install:
11
16
 
@@ -15,6 +20,29 @@ or install the CLI globally (it is a CLI, not a library):
15
20
 
16
21
  npm install -g @techgoblin/gobstack # gives you the `gob` CLI (`goblin` remains as a legacy alias)
17
22
 
23
+ > **Status:** v0.6.0 — stable, 34 rule rows, 23 tests, published as `latest`. Gobstack is Harvey's
24
+ > personal agent-enhancement layer, built for one owner; the source of truth is this repo, and the
25
+ > npm package tracks it.
26
+
27
+ ## The short version
28
+
29
+ - 🧾 **One install, three artifacts** — an executable rule manifest, the verifier that runs it, and the
30
+ `AGENTS.md` config block that names the gates.
31
+ - 🔍 **A rule nobody can check is counted, not claimed** — every row either has a mechanism or is labelled
32
+ advisory, and the advisory count is printed on every run.
33
+ - 🧪 **The gate lives in the repo** — `bash .gob/bin/goblin-verify` needs `git` and `bash`, not gobstack;
34
+ an initialized repo keeps working on a machine where gobstack was never installed.
35
+ - 🤖 **The agent runs the gate, not you** — the same verifier is served over MCP, so a session checks its
36
+ own work instead of describing it.
37
+ - 📋 **Two contracts are themselves gated** — the HANDOFF (`HP-*`) and the feature map (`FM-*`), so the
38
+ documents cannot quietly drift from the code.
39
+ - 🧩 **Extend by data, not by code** — a library of extra rows is switched on per repo through a versioned
40
+ local override, and a miswritten row is refused rather than silently green.
41
+
42
+ `gob init` refuses a gate command that does not exist (exit 127), refuses a proposal with no feature map,
43
+ and writes only paths it records. What it will not do is listed under [What it is not](#what-it-is-not),
44
+ and what it cannot see is in [docs/LIMITS.md](./docs/LIMITS.md).
45
+
18
46
  ## Install
19
47
 
20
48
  **The v2 flow is `init`-first.** `gob init` prints an AGENT BRIEF — a structured prompt telling
@@ -54,20 +82,20 @@ After installing, in this order:
54
82
  cd <target> && git add -A && git commit # the install is a change like any other
55
83
  .gob/bin/goblin-verify # or gob verify, anywhere in the target
56
84
 
57
- **A default install verifies green — `20 passed, 0 failed, 0 advisory,
58
- 10 skipped`, exit 0 — once `HANDOFF.md` names a commit that exists. Before that edit the
59
- scaffold's `0000000` placeholder is the one expected red.** Ten rows skip: `SK-01`, `SK-02` and
85
+ **A default install verifies green — `19 passed, 0 failed, 0 advisory,
86
+ 7 skipped`, exit 0 — once `HANDOFF.md` names a commit that exists. Before that edit the
87
+ scaffold's `0000000` placeholder is the one expected red.** Seven rows skip: `AG-01` has no
88
+ approval record yet (a plain install writes none; `gob approve-agents "<reason>"` records the
89
+ first, and `gob init --write` writes it for you); `SK-01`, `SK-02` and
60
90
  `SK-04` **run** (the core procedure tier is vendored under `.gob/skills/` on every install);
61
91
  `BN-01`/`BN-02`/`BN-03`/`BN-05` match only `.ts`/`.tsx`/`.js`/`.jsx` and have no such source, so
62
- each reports itself *not applicable*; the four electron bans `BN-06`–`BN-09` are selected by the
63
- `dep:electron` predicate, so with no `package.json` they too report *not applicable* — never
64
- running vacuously off the harness's own `.mjs`/`.json`;
65
- and `FM-01`/`FM-02` have no feature map yet. **Thirty-two further rows are OFF by default** —
92
+ each reports itself *not applicable*;
93
+ and `FM-01`/`FM-02` have no feature map yet. **Thirty-four further rows are OFF by default** —
66
94
  they are not skipped, they are held in the **library** (`gob verify --library`), the discovery
67
95
  surface for the extend mechanism: the spec/round rows (`SP-01`..`SP-03`), the ratchet rows
68
96
  (`GT-04`/`GT-05`), the replay rows (`HS-01`..`HS-03`), commit hygiene (`CM-02`/`CM-03`),
69
97
  the PR-gate rows (`PG-01`..`PG-03`), the runtime-data rows (`DS-01`/`DS-02`), the doc rows
70
- (`DOC-01`/`DOC-02`), the security rows (`SC-02`..`SC-06`, `SC-09`), the perf baseline (`PF-01`),
98
+ (`DOC-01`/`DOC-02`), the security rows (`SC-02`..`SC-06`), the perf baseline (`PF-01`),
71
99
  the reference corpus (`RC-01`..`RC-04`), the archive switch (`CL-02`), the portability row
72
100
  (`PT-01`) and the doctor row (`VA-01`). A default run states the library count in its summary, so
73
101
  a green run is never the whole story. Full inventory: `gob verify --library`. Turn one on by
@@ -88,8 +116,9 @@ and prints the usage.
88
116
  | command | what it does |
89
117
  |---|---|
90
118
  | `gob init` | the first step: print the AGENT BRIEF + proposal schema; `--heuristic` appends scanned hints as a fallback; `--write <proposal> [--yes]` validates the proposal and installs; `--target <dir>` aims elsewhere; `--dry-run` validates without writing |
91
- | `gob verify` | run the rule matrix against the current repo — `PASS`/`FAIL`/`SKIP` per row, exit 0 pass · 1 a check failed · 2 could not run · 3 the manifest is broken |
119
+ | `gob verify` | run the rule matrix against the current repo — `PASS`/`FAIL`/`SKIP` per row, exit 0 pass · 1 a check failed · 2 could not run · 3 the manifest is broken (or `--only AG-01` with no approval record: not policed yet, not red) |
92
120
  | `gob bans` | run the ban list (per-pattern red lines over the source tree) |
121
+ | `gob approve-agents "<reason>"` | record who approved the current `AGENTS.md` (row `AG-01`): appends date · sha256 · approver · reason to `.gob/agents.approved`; the row goes red when the file changes with no approval |
93
122
  | `gob mcp` | serve the harness to your coding agent over MCP stdio — three tools (`gob_verify`, `gob_map_status`, `gob_init_status`), local only, no SDK, no network |
94
123
  | `gob uninstall` | remove everything an install wrote, byte-exactly (the same job as `goblin-install --target <dir> --uninstall` from the checkout/install tree) |
95
124
 
@@ -167,14 +196,15 @@ flows; `manifest/glossary.tsv` for the vocabulary.
167
196
  gob verify [--only <id[,id...]>] [--json] [--list] [--source <path>]
168
197
 
169
198
  Exit codes: `0` pass · `1` a check failed · `2` could not
170
- run · `3` the manifest is broken. Every run prints what it cannot see.
199
+ run · `3` the manifest is broken (`--only AG-01` with no approval record is also 3: not policed
200
+ yet, not red). Every run prints what it cannot see.
171
201
 
172
202
  ## Develop
173
203
 
174
204
  bash tests/run-tests.sh
175
205
 
176
206
  Runs the source-scope rules (PR-01..PR-04) and the test scripts, including `t-verify-red.sh` —
177
- one control per target-scope row (125 over 62 target rows), each required to go RED and then
207
+ one control per target-scope row (149 over 60 target rows), each required to go RED and then
178
208
  restored. **A verifier that only ever prints GREEN is a failure**, so that file is the one that
179
209
  matters most.
180
210
 
@@ -228,6 +258,15 @@ then reports `practice pin ok`. Nothing re-pins automatically, not even a re-ins
228
258
  `bash`, `git`, `awk`, `sed`, `grep`, `python3` (the engine); node ≥ 18 for the npm shim only. No
229
259
  jq, no yq, no network at verify time.
230
260
 
261
+ ## Author
262
+
263
+ [Harvey Nguyen](mailto:harvey.nguyen33@gmail.com) — the same address signs every commit and the LICENSE.
264
+
265
+ ## Support
266
+
267
+ gobstack is free and MIT. If it saves you a review round, the goblin takes coffee:
268
+ [buymeacoffee.com/harveynguyen33](https://buymeacoffee.com/harveynguyen33).
269
+
231
270
  ## License
232
271
 
233
272
  MIT.
@@ -260,7 +299,9 @@ bounded panel, a pinned-SHA verdict. What does not transfer is cut, with the rea
260
299
  #### D1 — the enforcement matrix is an executable artifact, not a document
261
300
 
262
301
  `manifest/enforcement.tsv` has one row per rule. The `check` column holds a real command, the
263
- literal `advisory`, or the marker `goblin-verify --only <ID>` for a check that needs more than
302
+ literal `advisory`, prose that names its reader (the library's `GT-06`/`EX-01` rows end in
303
+ ", read by a human" and the engine advisories them), or the marker `goblin-verify --only <ID>` for
304
+ a check that needs more than
264
305
  one shell line. A self-check row (IN-03) fails the manifest when a row has neither, and SK-03
265
306
  caps the advisory count. **The number of unenforceable rules is itself a gate.**
266
307
 
@@ -356,14 +397,13 @@ state), and CI and `goblin-verify` were free to report different truths about on
356
397
 
357
398
  No row of the shipped matrix is labelled `advisory` — the **six advisory rows moved to the
358
399
  library**, so a default run sits at **0 of 10** on the `SK-03` cap (`gob verify --library` lists
359
- them). Those six carry **no executable check at all**:
400
+ them). Those five carry **no executable check at all**:
360
401
 
361
402
  - **HP-04** — a stale sentence is corrected in place with a dated parenthetical, never deleted.
362
403
  - **HS-03** — source probes read text with comments blanked first.
363
404
  - **CM-02** — the commit message was written to a file, not passed inline.
364
405
  - **DOC-01** — a significant change updates the docs that teach it.
365
406
  - **DOC-02** — system-level changes are recorded wherever the project's standard says they live.
366
- - **SC-09** — auth is applied consistently across sibling routes.
367
407
 
368
408
  `HP-04` and `CM-02` additionally print a heuristic when run with `--only`. A heuristic is not a
369
409
  check: it never fails a run. A counted rule is still not an enforced one, and the cap is a policy,
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.3
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env bash
2
+ # goblin-approve — `gob approve-agents "<reason>"` (AG-01): record an approval of AGENTS.md
3
+ # as it stands right now.
4
+ #
5
+ # The row AG-01 exists because the file that decides what "green" means (AGENTS.md's gates)
6
+ # is editable by the worker the gate polices. This command is the human half of the loop:
7
+ # after a person reads the diff, it appends ONE row to .gob/agents.approved —
8
+ #
9
+ # date <TAB> sha256-of-AGENTS.md <TAB> approver <TAB> one-line reason
10
+ #
11
+ # append-only history, latest row wins. `goblin-verify --only AG-01` recomputes the hash and
12
+ # compares it with the last row: match = PASS (printing date + approver), mismatch = FAIL,
13
+ # no record at all = SKIP (an existing install never turns red by upgrading).
14
+ #
15
+ # gob approve-agents "<reason>" [--approver <name>] [--target <dir>]
16
+ #
17
+ # --approver defaults to the target repo's git user.name, then $USER. The reason is one
18
+ # line: tabs and newlines are flattened to spaces so the row stays 4 tab-separated fields.
19
+ #
20
+ # Exit codes: 0 recorded | 1 refusal (named path + fix) | 2 bad input.
21
+ # No npm, no jq, no network. bash/awk/git only.
22
+ set -uo pipefail
23
+
24
+ SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
25
+ # shellcheck source=goblin-lib.sh
26
+ . "$SELF_DIR/goblin-lib.sh"
27
+
28
+ usage() { sed -n '2,/^$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
29
+
30
+ # need_val <flag> <usage> <value> — refuse exit 2 unless the value is set. The same guard
31
+ # goblin-init learned from INIT-WRITE-HANG: `shift 2` with $#=1 fails silently under
32
+ # `set -uo pipefail`, so a value flag at the end of the line must demand its argument.
33
+ need_val() {
34
+ [ -n "${3:-}" ] && return 0
35
+ g_err "$1: missing value — usage: gob approve-agents $2"
36
+ exit 2
37
+ }
38
+
39
+ REASON="" APPROVER="" TARGET=""
40
+ while [ $# -gt 0 ]; do
41
+ case "$1" in
42
+ --target) need_val --target '[--target <dir>] "<reason>"' "${2:-}"; TARGET=$2; shift 2 ;;
43
+ --approver) need_val --approver '"<reason>" --approver <name>' "${2:-}"; APPROVER=$2; shift 2 ;;
44
+ -h|--help) usage; exit 0 ;;
45
+ -*) g_err "unknown option: $1"; usage >&2; exit 2 ;;
46
+ *) [ -z "$REASON" ] || { g_err "one reason only — usage: gob approve-agents \"<reason>\""; exit 2; }
47
+ REASON=$1; shift ;;
48
+ esac
49
+ done
50
+ [ -n "$REASON" ] || { g_err "no reason given — usage: gob approve-agents \"<one-line reason>\""; usage >&2; exit 2; }
51
+
52
+ command -v git >/dev/null 2>&1 || { g_err "missing dependency: git"; exit 2; }
53
+
54
+ # Root resolution, the verifier's own rule (D20): the installed AGENTS.md is the marker, so
55
+ # a nested target is not verified/approved as the outer repo that encloses it.
56
+ if [ -n "$TARGET" ]; then
57
+ TARGET=$(g_expand_tilde "$TARGET")
58
+ [ -d "$TARGET" ] || { g_err "--target is not a directory: $TARGET"; exit 2; }
59
+ ROOT=$(cd "$TARGET" && pwd)
60
+ else
61
+ ROOT=""
62
+ local_d="$PWD"
63
+ while :; do
64
+ if [ -f "$local_d/AGENTS.md" ] && grep -q "^$GOB_AGENTS_BEGIN" "$local_d/AGENTS.md" 2>/dev/null; then ROOT="$local_d"; break; fi
65
+ [ "$local_d" = "/" ] && break
66
+ local_d=$(dirname "$local_d")
67
+ done
68
+ [ -n "$ROOT" ] || ROOT="$PWD"
69
+ fi
70
+ AGENTS="$ROOT/AGENTS.md"
71
+ [ -f "$AGENTS" ] || { g_err "no AGENTS.md at $ROOT — approve-agents records the file AG-01 polices; run it inside an installed repo"; exit 1; }
72
+
73
+ # The approver: explicit, then the repo's own git identity, then $USER.
74
+ if [ -z "$APPROVER" ]; then
75
+ APPROVER=$(git -C "$ROOT" config user.name 2>/dev/null | head -n 1)
76
+ fi
77
+ [ -n "$APPROVER" ] || APPROVER=${USER:-unknown}
78
+
79
+ # The reason is one line: flatten tabs/newlines so the row stays exactly 4 fields.
80
+ REASON=$(printf '%s' "$REASON" | tr '\t\r\n' ' ' | sed 's/ */ /g; s/^ //; s/ $//')
81
+
82
+ RECORD="$ROOT/.gob/agents.approved"
83
+ SHA=$(g_sha256_file "$AGENTS")
84
+ DATE=$(date +%F)
85
+ mkdir -p "$ROOT/.gob" || { g_err "could not create $ROOT/.gob"; exit 1; }
86
+ printf '%s\t%s\t%s\t%s\n' "$DATE" "$SHA" "$APPROVER" "$REASON" >> "$RECORD" || { g_err "could not append to $RECORD"; exit 1; }
87
+
88
+ N=$(grep -c . "$RECORD" || true)
89
+ printf 'approved %s\n' "AGENTS.md"
90
+ printf ' record %s (row %s, latest wins)\n' "${RECORD#"$ROOT"/}" "$N"
91
+ printf ' sha256 %s\n' "$SHA"
92
+ printf ' date %s by %s — %s\n' "$DATE" "$APPROVER" "$REASON"
93
+ exit 0
package/bin/goblin-bans CHANGED
@@ -41,7 +41,7 @@
41
41
 
42
42
  set -uo pipefail
43
43
 
44
- GOBLIN_BANS_VERSION="0.6.0"
44
+ GOBLIN_BANS_VERSION="0.7.3"
45
45
  SELF_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
46
46
  # shellcheck source=goblin-lib.sh
47
47
  . "$SELF_DIR/goblin-lib.sh"
package/bin/goblin-init CHANGED
@@ -50,13 +50,28 @@ g_info() { printf '%s\n' "$*"; }
50
50
 
51
51
  usage() { sed -n '2,/^$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
52
52
 
53
+ # A value-taking flag at the end of the line once spun the loop below forever:
54
+ # `shift 2` with $#=1 fails silently under `set -uo pipefail` (no -e), $1 is never
55
+ # consumed, and `gob init --write` answered a missing argument by hanging with zero
56
+ # bytes of output (INIT-WRITE-HANG, measured rc 124 on the published 0.6.0). The
57
+ # root cause was that unbounded flag loop, NOT a stdin read: with stdin at /dev/null
58
+ # the process still never exited. Each value flag now demands its argument up front,
59
+ # names the usage shape, and exits 2 before any work is done. The check MUST run in
60
+ # the main shell (an `exit` inside a $( ) substitution would only kill the subshell
61
+ # and the loop would spin on).
62
+ need_val() { # need_val <flag> <usage> <value> — refuse exit 2 unless the value is set
63
+ [ -n "${3:-}" ] && return 0
64
+ g_err "$1: missing value — usage: gob init $1 $2"
65
+ exit 2
66
+ }
67
+
53
68
  # ------------------------------------------------------------------ flags -----
54
69
  TARGET="" WRITE="" HEURISTIC=0 DRYRUN=0 SKILLS_OPT="no" WITH_MCP=0
55
70
  while [ $# -gt 0 ]; do
56
71
  case "$1" in
57
- --target) TARGET="${2:-}"; shift 2 ;;
58
- --write) WRITE="${2:-}"; shift 2 ;;
59
- --skills) SKILLS_OPT="${2:-}"; shift 2 ;;
72
+ --target) need_val --target '<dir>' "${2:-}"; TARGET=$2; shift 2 ;;
73
+ --write) need_val --write '<proposal-path>' "${2:-}"; WRITE=$2; shift 2 ;;
74
+ --skills) need_val --skills '<spec>' "${2:-}"; SKILLS_OPT=$2; shift 2 ;;
60
75
  --list-skills) exec bash "$SRC/bin/goblin-install" --list-skills ;;
61
76
  --heuristic) HEURISTIC=1; shift ;;
62
77
  --dry-run) DRYRUN=1; shift ;;
@@ -395,7 +410,14 @@ if [ -z "$WRITE" ]; then
395
410
  fi
396
411
 
397
412
  # ----------------------------------------------------------------- validate ----
398
- [ -f "$WRITE" ] || { g_err "proposal file not found: $WRITE"; exit 2; }
413
+ if [ ! -e "$WRITE" ]; then
414
+ g_err "proposal file not found: $WRITE — usage: gob init --write <proposal-path>"
415
+ exit 2
416
+ fi
417
+ if [ -d "$WRITE" ]; then
418
+ g_err "proposal path is a directory, not a file: $WRITE — usage: gob init --write <proposal-path>"
419
+ exit 2
420
+ fi
399
421
  PROP=$(cd "$(dirname "$WRITE")" && pwd)/$(basename "$WRITE")
400
422
  BLOCK_KEYS=$(g_agents_keys "$PROP")
401
423
  [ -n "$BLOCK_KEYS" ] || { g_err "$PROP carries no gob block — the agent did not write the schema"; exit 2; }
@@ -559,6 +581,19 @@ if [ "$WITH_MCP" -eq 1 ]; then
559
581
  fi
560
582
  do_hooks || exit 1
561
583
 
584
+ # ------------------------------------------------- AG-01's first record --------
585
+ # A fresh install is green on day one: `gob init --write` records an approval of the
586
+ # AGENTS.md it just wrote. FIRST RECORD ONLY — a re-run over a repo that already has one
587
+ # leaves it alone, so an init block-rewrite over unapproved edits stays AG-01 red with the
588
+ # fix command, rather than this command silently rubber-stamping them.
589
+ if [ ! -f "$TARGET/.gob/agents.approved" ]; then
590
+ bash "$SRC/bin/goblin-approve" --target "$TARGET" "gob init --write day one" >/dev/null 2>&1 \
591
+ || { g_err "could not write the first AG-01 approval record at $TARGET/.gob/agents.approved"; exit 1; }
592
+ g_info "recorded .gob/agents.approved (AG-01: re-approve after you edit AGENTS.md — gob approve-agents \"<reason>\")"
593
+ else
594
+ g_info "kept .gob/agents.approved (an approval record already exists; AG-01 judges AGENTS.md against it)"
595
+ fi
596
+
562
597
  # --------------------------------------------------------------------- done ----
563
598
  printf '\n'
564
599
  printf 'gob init: installed — feature map %s\n' "$FEATURE_MAP"