@techgoblin/gobstack 0.6.0-alpha.4 → 0.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +249 -116
  3. package/VERSION +1 -1
  4. package/bans/README.md +5 -5
  5. package/bans/grep-ban.sh +1 -1
  6. package/bin/goblin-bans +103 -27
  7. package/bin/goblin-init +345 -259
  8. package/bin/goblin-install +269 -213
  9. package/bin/goblin-lib.sh +63 -66
  10. package/bin/goblin-map +130 -579
  11. package/bin/goblin-mcp.js +9 -14
  12. package/bin/goblin-verify +249 -993
  13. package/bin/goblin.js +4 -9
  14. package/docs/GUIDE.md +724 -179
  15. package/docs/LIMITS.md +273 -301
  16. package/docs/RECORD-NOTES.md +1 -2
  17. package/manifest/bans.tsv +9 -9
  18. package/manifest/categories.tsv +18 -0
  19. package/manifest/enforcement.tsv +11 -67
  20. package/manifest/glossary.tsv +6 -12
  21. package/manifest/library.tsv +33 -0
  22. package/package.json +1 -4
  23. package/skills/goblin-bootstrap/SKILL.md +20 -32
  24. package/skills/goblin-feature-map/SKILL.md +1 -1
  25. package/skills/goblin-verify-author/SKILL.md +2 -2
  26. package/skills/practice/SKILL.md +4 -4
  27. package/templates/AGENTS.md.tmpl +6 -6
  28. package/templates/HANDOFF.md.tmpl +1 -1
  29. package/templates/SPEC.md.tmpl +2 -2
  30. package/templates/agents-block.tmpl +1 -10
  31. package/adapters/_template/adapter.tsv +0 -16
  32. package/adapters/_template/detect.sh +0 -10
  33. package/adapters/_template/emit.sh +0 -5
  34. package/adapters/_template/verify.sh +0 -4
  35. package/adapters/claude/adapter.tsv +0 -8
  36. package/adapters/claude/detect.sh +0 -8
  37. package/adapters/claude/verify.sh +0 -47
  38. package/adapters/codex/adapter.tsv +0 -12
  39. package/adapters/codex/detect.sh +0 -9
  40. package/adapters/codex/verify.sh +0 -45
  41. package/adapters/copilot/adapter.tsv +0 -10
  42. package/adapters/copilot/detect.sh +0 -8
  43. package/adapters/copilot/verify.sh +0 -45
  44. package/adapters/cursor/adapter.tsv +0 -11
  45. package/adapters/cursor/detect.sh +0 -10
  46. package/adapters/cursor/verify.sh +0 -45
  47. package/adapters/gemini/adapter.tsv +0 -15
  48. package/adapters/gemini/detect.sh +0 -11
  49. package/adapters/gemini/verify.sh +0 -49
  50. package/adapters/hermes/adapter.tsv +0 -9
  51. package/adapters/hermes/detect.sh +0 -8
  52. package/adapters/hermes/verify.sh +0 -27
  53. package/adapters/opencode/adapter.tsv +0 -14
  54. package/adapters/opencode/detect.sh +0 -9
  55. package/adapters/opencode/verify.sh +0 -45
  56. package/automations/README.md +0 -53
  57. package/automations/bugreporter-intake.sh +0 -145
  58. package/automations/drift-audit.sh +0 -139
  59. package/automations/report.schema.tsv +0 -10
  60. package/bin/goblin +0 -144
  61. package/bin/goblin-audit +0 -143
  62. package/bin/goblin-doctor +0 -233
  63. package/bin/goblin-emit +0 -495
  64. package/bin/goblin-extras +0 -365
  65. package/bin/goblin-model +0 -105
  66. package/bin/goblin-upgrade +0 -580
  67. package/docs/ADOPTION.md +0 -173
  68. package/docs/CI.md +0 -190
  69. package/docs/CONTRACTS.md +0 -218
  70. package/docs/DESIGN.md +0 -92
  71. package/docs/ENFORCEMENT.md +0 -228
  72. package/docs/FLOWS.md +0 -164
  73. package/docs/GLOSSARY.md +0 -40
  74. package/docs/GUARDRAILS.md +0 -126
  75. package/docs/INTEGRATION.md +0 -92
  76. package/docs/LOOP.md +0 -165
  77. package/docs/RE-PLAYBOOK.md +0 -183
  78. package/docs/RISKS.md +0 -70
  79. package/docs/ROLES.md +0 -105
  80. package/extras-catalogue/catalogue.tsv +0 -42
  81. package/extras-catalogue/payload/README.md +0 -14
  82. package/extras-catalogue/payload/taste-skill/taste/REFERENCE.md +0 -3
  83. package/extras-catalogue/payload/taste-skill/taste/SKILL.md +0 -9
  84. package/manifest/classes.tsv +0 -51
  85. package/manifest/playbooks.tsv +0 -16
  86. package/presets/electron-overlay.yaml +0 -38
  87. package/presets/fleet.yaml +0 -43
  88. package/presets/game.yaml +0 -38
  89. package/presets/research.yaml +0 -41
  90. package/presets/service.yaml +0 -40
  91. package/presets/software.yaml +0 -48
  92. package/roles.yaml +0 -54
  93. package/skills/goblin-bugfix/SKILL.md +0 -26
  94. package/skills/goblin-bugreporter/SKILL.md +0 -52
  95. package/skills/goblin-drift-audit/SKILL.md +0 -43
  96. package/skills/goblin-eval/SKILL.md +0 -68
  97. package/skills/goblin-feature/SKILL.md +0 -26
  98. package/skills/goblin-investigation/SKILL.md +0 -26
  99. package/skills/goblin-judge/SKILL.md +0 -74
  100. package/skills/goblin-loop/SKILL.md +0 -88
  101. package/skills/goblin-mode/SKILL.md +0 -70
  102. package/skills/goblin-overnight/SKILL.md +0 -42
  103. package/skills/goblin-pr-gate/SKILL.md +0 -42
  104. package/skills/goblin-re-mobile/SKILL.md +0 -51
  105. package/skills/goblin-refactor/SKILL.md +0 -23
  106. package/skills/goblin-sweep/SKILL.md +0 -23
  107. package/skills/goblin-tdd-repro/SKILL.md +0 -27
  108. package/templates/audit-waiver.tsv.tmpl +0 -10
  109. package/templates/install-hooks.allowlist.tmpl +0 -9
  110. package/templates/report.yaml.tmpl +0 -16
package/bin/goblin-init CHANGED
@@ -5,27 +5,35 @@
5
5
  # gob init --heuristic append the heuristic detection (fallback)
6
6
  # gob init --write <proposal> [--yes] validate the proposal and install it
7
7
  # gob init --target <dir> aim at a directory that is not $PWD
8
- # gob init --with-mcp-config write .mcp.json (repo-distributed MCP
9
- # registration; ask-once, never overwrites)
10
- # gob init --dry-run --write without writing anything
8
+ # gob init --skills <spec> which skills to vendor into .gob/skills/:
9
+ # no|yes = the 5 core skills (default), all =
10
+ # every skill, or a comma-separated name list
11
+ # gob init --write ... --with-mcp-config also write the repo-root .mcp.json (OPT-IN
12
+ # since the v3 enhance layer: the named
13
+ # removal that pays for hooks emission)
14
+ # gob init --list-skills print the skill library and exit
15
+ # gob init --dry-run --write without writing anything (and without
16
+ # running the declared gate)
11
17
  #
12
18
  # The CLI calls NO AI API. A bare `gob init` prints:
13
19
  # 1. the AGENT BRIEF — a structured prompt telling whichever agent is already running
14
- # in this repo (the coding agent the developer already uses) exactly what to scan
15
- # (package.json, routes, tests, CI configs) and what to decide (class, branch,
16
- # owner email, the first gate command);
17
- # 2. the SCHEMA of the proposal file the agent must write — AGENTS.md frontmatter
18
- # pre-filled + a `## gob init summary` section.
20
+ # in this repo exactly what to scan (package.json, routes, tests, CI configs) and
21
+ # what to decide (the first gate command, the feature map, the source root);
22
+ # 2. the SCHEMA of the proposal file the agent must write — the gob block + a
23
+ # `## gob init summary` section + a `## feature-map` section embedding the files.
19
24
  # The agent fulfils the brief with its own tools, writes the proposal, and the human (or
20
25
  # the agent's own next step) runs `gob init --write <proposal>` to validate and install:
21
26
  # - the frontmatter keys are validated against the engine's key set (unknown key,
22
- # bad class, non-boolean archive -> exit 2, nothing written);
23
- # - AGENTS.md (body + gob block) and .gob/engine (the vendored verifier + manifest)
24
- # are written; HANDOFF.md is written once; the sync-translator step runs to emit
25
- # platform files for the proposal's `sync:` line. CI is never part of any output.
27
+ # an unknown key, non-boolean archive -> exit 2, nothing written);
28
+ # - the declared gate is RUN in the working tree (a non-zero exit is a day-one red, a
29
+ # command that cannot be run is refused);
30
+ # - the embedded feature map is validated by bin/goblin-map (FM-01 shape + FM-02
31
+ # resolvability) in the SAME pass, before anything is written;
32
+ # - AGENTS.md (body + gob block), .gob/engine (the vendored verifier + manifest) and
33
+ # features/ are written; HANDOFF.md is written once. CI is never part of any output.
26
34
  #
27
- # The heuristic detector (package.json scripts + route tokens, from bin/goblin-map) is
28
- # the --heuristic FALLBACK: appended to the brief as pre-scanned hints, never the answer.
35
+ # The heuristic detector (package.json scripts + route tokens) is the --heuristic FALLBACK:
36
+ # appended to the brief as pre-scanned hints, never the answer.
29
37
  #
30
38
  # Exit codes: 0 printed or installed | 1 a refusal (named path + fix) | 2 bad input.
31
39
  # No npm, no jq, no yq, no network, no AI API. bash/awk/sed/grep only.
@@ -37,23 +45,22 @@ SRC=$(cd "$SELF_DIR/.." && pwd)
37
45
  # shellcheck source=goblin-lib.sh
38
46
  . "$SELF_DIR/goblin-lib.sh"
39
47
  VERSION=$(cat "$SRC/VERSION" 2>/dev/null || printf 'unknown')
40
- # The extras catalogue (overridable for tests, the same env var goblin-extras reads).
41
- CATALOGUE_TSV="${GOB_EXTRAS_CATALOGUE:-$SRC/extras-catalogue/catalogue.tsv}"
42
48
 
43
49
  g_info() { printf '%s\n' "$*"; }
44
50
 
45
51
  usage() { sed -n '2,/^$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
46
52
 
47
53
  # ------------------------------------------------------------------ flags -----
48
- TARGET="" WRITE="" HEURISTIC=0 DRYRUN=0 RESYNC=0 WITH_MCP=0
54
+ TARGET="" WRITE="" HEURISTIC=0 DRYRUN=0 SKILLS_OPT="no" WITH_MCP=0
49
55
  while [ $# -gt 0 ]; do
50
56
  case "$1" in
51
57
  --target) TARGET="${2:-}"; shift 2 ;;
52
58
  --write) WRITE="${2:-}"; shift 2 ;;
59
+ --skills) SKILLS_OPT="${2:-}"; shift 2 ;;
60
+ --list-skills) exec bash "$SRC/bin/goblin-install" --list-skills ;;
53
61
  --heuristic) HEURISTIC=1; shift ;;
54
- --resync) RESYNC=1; shift ;; # init-internal: re-run the sync step (hidden)
55
- --with-mcp-config) WITH_MCP=1; shift ;;
56
62
  --dry-run) DRYRUN=1; shift ;;
63
+ --with-mcp-config) WITH_MCP=1; shift ;;
57
64
  --yes) shift ;; # accepted for pipe parity; --write is already explicit
58
65
  -h|--help) usage; exit 0 ;;
59
66
  *) g_err "unknown option: $1"; usage >&2; exit 2 ;;
@@ -63,7 +70,6 @@ done
63
70
  for dep in git awk sed grep; do
64
71
  command -v "$dep" >/dev/null 2>&1 || { g_err "missing dependency: $dep"; exit 2; }
65
72
  done
66
- command -v python3 >/dev/null 2>&1 || { g_err "missing dependency: python3 (the extras .mcp.json merge needs it)"; exit 2; }
67
73
  [ -f "$SRC/VERSION" ] || { g_err "no VERSION at $SRC — is this a gobstack checkout?"; exit 2; }
68
74
  TARGET="${TARGET:-$PWD}"
69
75
  TARGET=$(g_expand_tilde "$TARGET")
@@ -71,31 +77,89 @@ TARGET=$(g_expand_tilde "$TARGET")
71
77
  TARGET=$(cd "$TARGET" && pwd)
72
78
  TODAY=$(date +%F)
73
79
 
74
- # The repo-distributed MCP registration (.mcp.json), written by --with-mcp-config in
75
- # BOTH modes (bare and --write). Ask-once semantics: an existing file is never
76
- # overwritten — the generated bytes again are a named no-op, anything else is a
77
- # refusal with exit 1 (the installer's preimage shape). The major coding agents
78
- # auto-detect a repo-root .mcp.json.
79
- # MD-01: the agent CLI's family name is ASSEMBLED at run time — a literal agent-family
80
- # name in bin/ source is the exact string MD-01 exists to catch (the run-tests MD_SLUG
81
- # precedent). The printed line still reads the way the docs quote it.
80
+ # The repo-distributed MCP registration (.mcp.json): OPT-IN since the v3 enhance layer
81
+ # (--with-mcp-config) — the named removal that pays for hooks emission. A registration a
82
+ # repo never asked for was the default; hooks are what init --write writes by default now.
83
+ # Ask-once semantics either way: an existing file is never overwritten — the generated
84
+ # bytes again are a named no-op, anything else is KEPT (a registration you customized is
85
+ # the project's). The major coding agents auto-detect a repo-root .mcp.json.
86
+ # The agent CLI's family name is ASSEMBLED at run time, so no rule here spells the
87
+ # tool's own name literally. The printed line still reads the way the docs quote it.
82
88
  AGENT_CLI="cl"; AGENT_CLI="${AGENT_CLI}aude"
89
+ MCP_BYTES='{"mcpServers":{"gob":{"command":"npx","args":["-y","@techgoblin/gobstack","mcp"]}}}'
83
90
  do_mcp_config() {
84
91
  local f="$TARGET/.mcp.json"
85
- local bytes='{"mcpServers":{"gob":{"command":"npx","args":["-y","@techgoblin/gobstack","mcp"]}}}'
86
92
  if [ -f "$f" ]; then
87
- if [ "$(cat "$f")" = "$bytes" ]; then
93
+ if [ "$(cat "$f")" = "$MCP_BYTES" ]; then
88
94
  g_info "gob init: $TARGET/.mcp.json already carries the generated registration (left as is)"
89
95
  return 0
90
96
  fi
91
- g_err "refusing to write $TARGET/.mcp.json: the file exists and is not the generated registration — edit it by hand or remove it first"
92
- return 1
97
+ g_info "kept $TARGET/.mcp.json (not the generated registration: a registration you customized stays)"
98
+ return 0
93
99
  fi
94
- printf '%s\n' "$bytes" > "$f" || { g_err "could not write $f"; return 1; }
100
+ printf '%s\n' "$MCP_BYTES" > "$f" || { g_err "could not write $f"; return 1; }
95
101
  g_info "wrote $TARGET/.mcp.json (the gob MCP server is repo-distributed; ${AGENT_CLI} Code and Cursor auto-detect it)"
96
102
  return 0
97
103
  }
98
104
 
105
+ # The agent hooks payload (v3 enhance layer): the verify/init surface lands in a vendor
106
+ # hooks file the agent ALREADY reads — written into an EXISTING .claude/ or .cursor/
107
+ # directory only (DETECTION, never creation: creating the vendor dir is how an installer
108
+ # becomes malware-shaped; a repo with neither dir simply gets no hooks, named out loud).
109
+ # The snippet's sha256 is recorded next to .mcp.json's own preimage clause, in
110
+ # .gob/manifest/hooks.tsv; --uninstall removes a hook ONLY when the file on disk still
111
+ # hashes to the recorded value — a snippet the project edited is the project's.
112
+ HOOKS_TSV=".gob/manifest/hooks.tsv"
113
+ hook_entry() { # hook_entry <vendor> <relfile> <bytes> -> vendor<TAB>rel<TAB>sha256
114
+ # The hash is of the FILE AS WRITTEN (printf '%s\n' appends a newline), so the recorded
115
+ # value is the one g_sha256_file computes at uninstall time — never hash one form and
116
+ # check the other.
117
+ local tmp; tmp=$(mktemp) && printf '%s\n' "$3" > "$tmp" && \
118
+ printf '%s\t%s\t%s\n' "$1" "$2" "$(g_sha256_file "$tmp")" && rm -f "$tmp"
119
+ }
120
+ write_hook_file() { # write_hook_file <relpath> <bytes> — ask-once, like .mcp.json
121
+ local f="$TARGET/$1"
122
+ if [ -f "$f" ]; then
123
+ if [ "$(cat "$f")" = "$2" ]; then
124
+ g_info "gob init: $1 already carries the generated hooks (left as is)"
125
+ return 0
126
+ fi
127
+ g_info "kept $1 (not the generated hooks: a hook file you customized stays)"
128
+ return 0
129
+ fi
130
+ printf '%s\n' "$2" > "$f" || { g_err "could not write $f"; return 1; }
131
+ g_info "wrote $1 (gobstack hooks: the verify surface reachable inside the agent session)"
132
+ return 0
133
+ }
134
+ do_hooks() {
135
+ local claude="$TARGET/.claude" cursor="$TARGET/.cursor" wrote=0 entries="" rc=0
136
+ # Claude Code: the vendor's documented hooks file (hooks/SessionStart, command type).
137
+ if [ -d "$claude" ]; then
138
+ local bytes='{"hooks":{"SessionStart":[{"hooks":[{"type":"command","command":"bash .gob/bin/goblin-verify --brief || true"}]}]}}'
139
+ write_hook_file ".claude/hooks.json" "$bytes" || rc=1
140
+ entries+="$(hook_entry claude .claude/hooks.json "$bytes")"$'\n'
141
+ wrote=1
142
+ fi
143
+ # Cursor: the same snippet in the shape its hooks reader documents (sessionStart).
144
+ if [ -d "$cursor" ]; then
145
+ local bytes='{"hooks":{"sessionStart":[{"command":"bash .gob/bin/goblin-verify --brief || true"}]}}'
146
+ write_hook_file ".cursor/hooks.json" "$bytes" || rc=1
147
+ entries+="$(hook_entry cursor .cursor/hooks.json "$bytes")"$'\n'
148
+ wrote=1
149
+ fi
150
+ [ "$wrote" -eq 1 ] || { g_info "no .claude/ or .cursor/ directory at $TARGET — no hooks written (gobstack creates no vendor directory; the MCP registration is the --with-mcp-config opt-in)"; return 0; }
151
+ # The hash record: one row per hook file covered, written ask-once like the files.
152
+ local rec="$TARGET/$HOOKS_TSV"
153
+ if [ -f "$rec" ]; then
154
+ g_info "kept $HOOKS_TSV (a hook record already exists)"
155
+ else
156
+ mkdir -p "$TARGET/.gob/manifest"
157
+ { printf 'vendor\tfile\tsha256\n'; printf '%s' "$entries"; } > "$rec" || { g_err "could not write $HOOKS_TSV"; return 1; }
158
+ g_info "recorded $HOOKS_TSV (the hash --uninstall checks before removing a hook)"
159
+ fi
160
+ return $rc
161
+ }
162
+
99
163
  # ------------------------------------------------------------------ the brief --
100
164
  # `gob init` with no --write: print the prompt + schema. This IS the product: the agent
101
165
  # in the repo reads this output and does the work with its own tools.
@@ -114,95 +178,148 @@ back one proposal file. Do this now:
114
178
  - the test layout (tests/, *.test.*, run-tests.sh or equivalent gate scripts)
115
179
  - CI configs (.github/workflows, .gitlab-ci.yml) — to READ what the project already
116
180
  gates on. gobstack installs no CI.
117
- - the git identity this repo commits with (git config user.email)
118
181
 
119
182
  2. DECIDE, and be ready to justify each line:
120
- - class: software | service | game | research | fleet
121
- - branch: the default branch (main/master/…)
122
- - owner_email: the commit identity this repo expects
123
- - gate_commit_cmd: ONE command that proves the repo is healthy and must stay green
124
- (a real test/lint command from package.json — never a placeholder)
125
-
126
- 3. THE CATALOGUE — `catalogue_suggestions` (init SUGGESTS, it never installs):
127
-
128
- Read the bundled catalogue (`gob extras list` shows it; the file is
129
- `extras-catalogue/catalogue.tsv` in the package). From it, build the
130
- `catalogue_suggestions:` list for this repo:
131
-
132
- - rows whose `matches:` column names this repo's detected stack (the words you
133
- found in step 1 — react, vue, playwright, godot, unity, node, postgres, …);
134
- - RECOMMEND rows are pre-ticked (write `- id` with `[x]`); MAYBE rows are
135
- listed but NOT pre-ticked (`[ ]`) — they are visible choices, never defaults;
136
- - a row with NO vendored payload (no `extras-catalogue/payload/<id>/` directory)
137
- must NOT be pre-ticked even when RECOMMEND — print it as `[ ]` instead;
138
- `--write` installs through `gob extras install`, which refuses a
139
- payload-missing id and fails the whole --write;
140
- - a row whose `conflicts:` names an id you also picked: pick at most one of them;
141
- - SKIP rows are never suggested and refuse install; leave them out entirely.
142
-
143
- Record the picks in the proposal's summary section under `catalogue_suggestions:`
144
- (one `- [x] <id> # <why>` line each). NOTHING installs at init: installing is a
145
- separate, explicit step the human runs —
146
-
147
- npx @techgoblin/gobstack extras install <id...>
148
-
149
- 4. DISCOVER — `discover_extras` (proposals only, nothing auto-installs):
150
-
151
- ALSO search the web with your own tools for agent skills / MCP servers / workflows
152
- that match this repo's stack and are NOT in the bundled catalogue. For each
153
- discovery, propose one entry in the summary under `discover_extras:` with exactly
154
- these keys:
155
-
156
- discover_extras:
157
- - id: <short-kebab-id>
158
- source_url: <the repo or docs URL you actually fetched>
159
- license: <spdx or "unknown — verify">
160
- rationale: <one line — what it adds to THIS repo>
161
- suggested_kind: <skill|mcp|workflow>
162
-
163
- Rules: verify the URL is live before proposing it; state the license you found;
164
- never propose anything you did not actually read. Proposals are INERT — nothing
165
- auto-installs from discovery, and no discovery reaches this repo from the CLI.
166
- A human reviews the proposals, then the curator promotes accepted discoveries
167
- into catalogue.tsv by PR or direct edit. Until a row exists in the
168
- catalogue, `gob extras install` refuses it — the catalogue is the allowlist.
169
-
170
- 5. WRITE the proposal file exactly in the SCHEMA below, at a path you choose (for
183
+ - gate_commit_cmd: ONE command that proves the repo is healthy and must stay green.
184
+ RUN it yourself first: a command that does not exist is not a gate (--write refuses
185
+ an exit-127 command); a command that runs and exits non-zero is a legitimate day-one
186
+ red (--write accepts it and the harness reports it as one).
187
+ - feature_map: the map's README path (the convention is features/README.md). REQUIRED —
188
+ there is no "no map declared" state.
189
+
190
+ 3. WRITE the proposal file exactly in the SCHEMA below, at a path you choose (for
171
191
  example .gob-init-proposal.md), then run:
172
192
 
173
193
  npx @techgoblin/gobstack init --write <proposal-path>
174
194
 
175
195
  Notes:
176
- - Class letters A-E and the names app/agent/desktop are accepted aliases
177
- (app->software, agent->fleet, desktop->software+electron).
178
196
  - A second gate is optional: gate_<name>_cmd, e.g. gate_todo_cmd.
179
- - Keys you do not set are filled from the class default by --write.
197
+ - Keys you do not set are filled from the installer's default block by --write.
198
+ - --write validates BOTH halves in one pass: the config block AND the embedded feature
199
+ map (FM-01 shape + FM-02 resolvability: every entry path exists AND is committed).
200
+ A repo with no committed file to map REFUSES — commit at least one file, then run again.
201
+ - The repo-root .mcp.json registration is OPT-IN: add --with-mcp-config to the
202
+ --write line. Without it the install writes no registration; it DOES write the
203
+ agent hooks (.claude/hooks.json / .cursor/hooks.json) into existing vendor dirs.
204
+
205
+ == EXTERNAL CATEGORIES (adjudication — do this before writing the proposal) =====
206
+
207
+ The install vendored (or, at brief time, ships at manifest/categories.tsv) an inventory of
208
+ external composition categories at .gob/engine/categories.tsv (source: manifest/categories.tsv
209
+ in the gobstack repo of origin). It is DATA — gobstack's code never reads it; you are the
210
+ reader and the adjudicator, because you can see this repo and its code cannot.
211
+
212
+ For EACH row in that file, in order:
213
+
214
+ 1. EVALUATE the row's fits_when predicate against THIS repository (its actual work, its
215
+ actual shape — not what a repo like it might want). A row you cannot evaluate, say so
216
+ in the decision record with that reason.
217
+ 2. PROPOSE every row that FITS to the user before installing anything: name, source URL,
218
+ license, and what it would concretely add here. A fit is a proposal, never an install.
219
+ 3. INSTALL only on the user's explicit approval, through the SK-checked lane: fetch the
220
+ pack, drop it in .gob/skills/<name>/ (SK-01/02/04 hash and police it like any shipped
221
+ skill), and record the row in .gob/manifest/compose-decisions.tsv with added_by = the
222
+ source URL and why = the license + the fit reason. Nothing lands without a license line.
223
+ 4. RECORD EVERY evaluated row — installed or declined — in .gob/manifest/compose-decisions.tsv
224
+ (create it if absent; header: date<TAB>category<TAB>decision<TAB>reason; one row per
225
+ category, tab-separated):
226
+ - installed rows: decision=installed, reason names the license and the concrete fit;
227
+ - declined rows: decision=declined, reason names the CONCRETE property of this repo that
228
+ fails the predicate ("no user-facing feature surface", "single-session CLI", ...) —
229
+ "not applicable" is not a reason;
230
+ - a row left unrecorded is a VIOLATION of this brief: an adjudication that left no
231
+ trace is indistinguishable from an adjudication that never happened.
232
+
233
+ The gate only ever runs the repo's own checks; an external pack may AUTHOR rows (LX-*),
234
+ and then the check is the repo's, proof and all.
180
235
 
181
236
  == PROPOSAL SCHEMA =============================================================
182
237
 
183
238
  <!-- gob:begin (gobstack config — edit in place; the parser reads only this block) -->
184
- class: <software|service|game|research|fleet>
185
- branch: <default branch>
186
- owner_email: <commit identity>
187
239
  gate_<name>_cmd: <one shell command that must stay green>
188
- sync_platforms: <optional array — the agent platform ids the sync reads>
240
+ feature_map: features/README.md
241
+ source_root: .
189
242
  <!-- gob:end -->
190
243
 
191
244
  ## gob init summary
192
245
 
193
246
  - <one bullet per decision: what you scanned, what you chose, why>
194
247
  - <framework / package manager / test command found>
195
- - catalogue_suggestions:
196
- - [x] <catalogue id> # <one line why — RECOMMEND rows pre-ticked>
197
- - [ ] <catalogue id> # <a MAYBE row: visible, never pre-ticked>
198
- - discover_extras:
199
- - id: <kebab-id>
200
- source_url: <live URL>
201
- license: <spdx or "unknown — verify">
202
- rationale: <one line>
203
- suggested_kind: <skill|mcp|workflow>
248
+
249
+ ## feature-map
250
+
251
+ ### features/README.md
252
+
253
+ ```md
254
+ # Features
255
+
256
+ - [<slug>](./<slug>.md) — <one line>
257
+ ```
258
+
259
+ ### features/<slug>.md
260
+
261
+ ```md
262
+ ---
263
+ feature: <slug — lowercase [a-z0-9-], equals the filename stem>
264
+ entry_paths:
265
+ - <repo-relative path that exists AND is committed (git ls-files)>
266
+ verified: never-driven (<today>)
267
+ ---
268
+ # <slug>
269
+
270
+ <one user-visible paragraph, no implementation detail>
271
+
272
+ ## Sub-features
273
+
274
+ - <the sub-behaviours, one per line>
275
+
276
+ ## How to get to it (user POV)
277
+
278
+ - <how a user reaches this feature, and what they should see>
279
+
280
+ ## Driving it with <harness>
281
+
282
+ Preconditions: <what must be true first>.
283
+ **<action>.** Run `<exact command>`. <the observable result.>
284
+
285
+ ## Gotchas
286
+
287
+ - <what commonly breaks, or what the entry-path token does and does not prove>
288
+ ```
289
+
290
+ (embed one `### <dir>/<slug>.md` block per feature; every feature must be linked from the
291
+ README index in the `(./<slug>.md)` form. `feature:` must equal the filename stem, and the
292
+ four H2s above are required, in order.)
204
293
  ============================================================================== ==
205
294
  BRIEF
295
+ print_skill_library
296
+ }
297
+
298
+ # print_skill_library — the discovery surface for the skill LIBRARY (the repo's skills/
299
+ # directory), appended to the brief. The 5 CORE skills are vendored into .gob/skills/ by
300
+ # default; the rest are selectable through --skills, exactly as the rule LIBRARY holds rows
301
+ # that are off by default. Prints name, tier and the one-line purpose (the frontmatter
302
+ # `description:`), so a reader knows what exists without opening the repo.
303
+ # The core set is read from the installer (goblin-install's CORE_SKILLS) rather than
304
+ # restated here — one source of truth, so a tier change cannot fork the two surfaces.
305
+ print_skill_library() {
306
+ local d name desc tier core_list
307
+ core_list=$(bash "$SRC/bin/goblin-install" --print-core-skills 2>/dev/null)
308
+ [ -n "$core_list" ] || core_list="goblin-handoff goblin-verify-author goblin-feature-map practice goblin-bootstrap"
309
+ printf '\n== SKILL LIBRARY =============================================================\n\n'
310
+ printf 'A default install writes the 5 CORE skills into .gob/skills/. Every other skill is\n'
311
+ printf 'available on request. Choose the set with --skills:\n\n'
312
+ printf ' --skills all every skill in the repo\n'
313
+ printf ' --skills goblin-handoff,goblin-bootstrap exactly those (comma-separated)\n\n'
314
+ printf 'Available skills:\n'
315
+ for d in "$SRC"/skills/*/; do
316
+ [ -f "$d/SKILL.md" ] || continue
317
+ name=$(basename "$d")
318
+ desc=$(awk 'NR==1{f=1;next} /^---/{f=0} f&&/^description:/{sub(/^description:[[:space:]]*/,"");print;exit}' "$d/SKILL.md")
319
+ case " $core_list " in
320
+ *" $name "*) tier=core ;; *) tier=optional ;; esac
321
+ printf ' %-22s %-9s %s\n' "$name" "$tier" "$desc"
322
+ done | sort
206
323
  }
207
324
 
208
325
  # The heuristic fallback: pre-scanned hints appended to the brief (--heuristic).
@@ -225,67 +342,54 @@ print_heuristic() {
225
342
  for d in app pages routes src; do
226
343
  [ -d "$TARGET/$d" ] && printf 'route/entry root candidate: %s/\n' "$d"
227
344
  done
228
- # The catalogue_suggestions fallback: rows whose `matches:` cell names a token the
229
- # heuristic scan actually saw in this repo (package.json deps + lockfile + config
230
- # files). The SAME matches column the agent brief reads — the fallback suggests from
231
- # the catalogue, never from its own private list. Verdicts are respected: only
232
- # RECOMMEND rows pre-tick; MAYBE rows print unticked; SKIP rows never appear.
233
- # QA fix (v2-qa): a row pre-ticks ONLY when its vendored payload exists —
234
- # extras-catalogue/payload/<id>/ — because --write installs through
235
- # `gob extras install`, which refuses a payload-missing row and fails the whole
236
- # --write after everything else was already written. A RECOMMEND row with no
237
- # payload prints as a visible, unticked `[ ]` choice instead. (41 researched rows,
238
- # 1 vendored payload: the old pre-tick turned a day-one init into a guaranteed
239
- # exit 2 halfway through writing.)
240
- if [ -f "$CATALOGUE_TSV" ]; then
241
- local scan
242
- scan=$(cat "$TARGET/package.json" "$TARGET"/*.lock "$TARGET"/pnpm-lock.yaml \
243
- "$TARGET"/vue.config.* "$TARGET"/nuxt.config.* "$TARGET"/godot/project.godot \
244
- "$TARGET"/unity/ProjectSettings/ProjectVersion.txt 2>/dev/null | tr 'A-Z' 'a-z')
245
- if [ -n "$scan" ]; then
246
- local ticked="" maybe="" payload_root
247
- payload_root="${GOB_EXTRAS_PAYLOAD:-$SRC/extras-catalogue/payload}"
248
- while IFS=$'\t' read -r cid ccat ckind cname crepo cpath chmd clic cstars cpush \
249
- cmatches cconf creq chint cverdict cby cdate; do
250
- [ -n "$cid" ] || continue
251
- case "$cverdict" in RECOMMEND|MAYBE) ;; *) continue ;; esac
252
- local hit=0 tok
253
- for tok in $cmatches; do
254
- case "$scan" in *"$tok"*) hit=1; break ;; esac
255
- done
256
- [ "$hit" -eq 1 ] || continue
257
- if [ ! -d "$payload_root/$cid" ]; then
258
- # no vendored payload: the row stays visible but never pre-ticks —
259
- # a tick --write cannot honour is a refusal waiting to happen
260
- maybe="$maybe - [ ] $cid # matches this repo, NO VENDORED PAYLOAD yet (gob extras install would refuse — vendor it under extras-catalogue/payload/$cid/ first)"$'\n'
261
- continue
262
- fi
263
- case "$cverdict" in
264
- RECOMMEND) ticked="$ticked - [x] $cid # matches this repo ($cmatches)"$'\n' ;;
265
- MAYBE) maybe="$maybe - [ ] $cid # matches, verdict MAYBE (not pre-ticked)"$'\n' ;;
266
- esac
267
- done < "$CATALOGUE_TSV"
268
- if [ -n "$ticked$maybe" ]; then
269
- printf 'catalogue_suggestions (heuristic — verify the matches before trusting):\n'
270
- printf '%s' "$ticked"
271
- printf '%s' "$maybe"
272
- printf 'install later with: gob extras install <id...> (init itself installs nothing)\n'
273
- fi
274
- fi
275
- fi
276
345
  if [ "$got" -eq 0 ] && [ ! -d "$TARGET/src" ]; then
277
346
  printf 'no package.json, no src/ — the scan above is empty; say so in the summary\n'
278
347
  fi
279
348
  printf '\n'
280
349
  }
281
350
 
351
+ # ------------------------------------------------------------------ the map -----
352
+ # Extract the proposal's `## feature-map` section. Each `### <path>` heading is followed
353
+ # by a fenced code block whose body is the file at <path> (repo-relative). Writes into
354
+ # <stage-dir>/<path> and prints the number of `### ` blocks found. This is the ONLY reader
355
+ # of the map half of the proposal; the SHAPE is then validated by bin/goblin-map (the same
356
+ # code path `gob map --write` used), never re-implemented here.
357
+ extract_feature_map() { # <proposal> <stage-dir> -> block count on stdout
358
+ local prop="$1" stage="$2" p
359
+ # awk cannot mkdir: create every declared path's parent directory first.
360
+ while IFS= read -r p; do
361
+ [ -n "$p" ] || continue
362
+ mkdir -p "$stage/$(dirname "$p")" || return 1
363
+ done < <(awk '
364
+ /^```/ { fence = !fence; next }
365
+ !inmap { if (!fence && $0 ~ /^##[[:space:]]+[Ff]eature-map[[:space:]]*$/) inmap=1; next }
366
+ !fence {
367
+ if ($0 ~ /^##[[:space:]]/) { inmap=0; next }
368
+ if ($0 ~ /^###[[:space:]]+/) { p=$0; sub(/^###[[:space:]]+/,"",p); sub(/[[:space:]]+$/,"",p); print p }
369
+ }
370
+ ' "$prop")
371
+ # then write the fenced-block bodies. Fence-aware: a feature file's own `## ` H2s and any
372
+ # `### ` inside its fenced body are CONTENT, never the section's structure.
373
+ awk -v stage="$stage" '
374
+ function flush() { if (out != "") { close(out); out="" } }
375
+ /^```/ { fence = !fence; next }
376
+ !inmap { if (!fence && $0 ~ /^##[[:space:]]+[Ff]eature-map[[:space:]]*$/) inmap=1; next }
377
+ !fence {
378
+ if ($0 ~ /^##[[:space:]]/) { inmap=0; flush(); next }
379
+ if ($0 ~ /^###[[:space:]]+/) {
380
+ flush(); p=$0; sub(/^###[[:space:]]+/,"",p); sub(/[[:space:]]+$/,"",p)
381
+ out = stage "/" p; n++; next
382
+ }
383
+ next
384
+ }
385
+ { if (out != "") print >> out }
386
+ END { print n+0 }
387
+ ' "$prop"
388
+ }
389
+
282
390
  if [ -z "$WRITE" ]; then
283
- if [ "$WITH_MCP" -eq 1 ]; then
284
- do_mcp_config || exit 1
285
- fi
286
391
  print_brief
287
392
  [ "$HEURISTIC" -eq 1 ] && print_heuristic
288
- printf 'register the verify tool for your agent: %s mcp add gob -- npx -y @techgoblin/gobstack mcp (or run gob init --with-mcp-config)\n' "$AGENT_CLI"
289
393
  g_info "== end of brief — the agent writes the proposal; gob init --write installs it =="
290
394
  exit 0
291
395
  fi
@@ -298,17 +402,16 @@ BLOCK_KEYS=$(g_agents_keys "$PROP")
298
402
 
299
403
  # Unknown keys are refused: the proposal is machine-read, and a typo'd key would
300
404
  # otherwise be silently ignored forever (fail closed, like --only does).
301
- KNOWN_KEYS="class electron branch models_file practice practice_sha256 owner_email archive
405
+ KNOWN_KEYS="practice practice_sha256 archive
302
406
  max_dirty advisory_ceiling security.gitignore_family security.build_output
303
- security.audit_cmd security.audit_max_age_days security.waiver_max_age_days
304
407
  security.write_routes perf.metric perf.cmd perf.baseline_commit perf.baseline_value
305
408
  perf.measured perf.host_gate harness_dir scaffold_checks feature_map source_root
306
- verify_doctor reference_manifest quarantine_root loop_max_turns_ceiling sync_platforms
307
- ratchet.name ratchet.cmd ratchet.ceiling runtime_data bans bans_exempt layers
409
+ verify_doctor reference_manifest quarantine_root
410
+ ratchet.name ratchet.cmd ratchet.ceiling runtime_data bans_disabled bans_exempt layers
308
411
  replay.env replay.cmd replay.commit disabled engine_dir"
309
412
  BAD_KEYS=""
310
413
  # Token-by-token, not a whole-string case: KNOWN_KEYS is a multi-line word list and a
311
- # `case` pattern cannot span the newlines (measured: sync_platforms read as unknown).
414
+ # `case` pattern cannot span the newlines.
312
415
  while IFS= read -r k; do
313
416
  [ -n "$k" ] || continue
314
417
  case "$k" in gate_*_cmd) continue ;; esac
@@ -320,98 +423,95 @@ while IFS= read -r k; do
320
423
  done <<< "$BLOCK_KEYS"
321
424
  [ -z "$BAD_KEYS" ] || { g_err "$PROP names unknown key(s):$BAD_KEYS — fix or drop them"; exit 2; }
322
425
 
323
- CLASS_RAW=$(g_agents_read "$PROP" class)
324
- CLASS=$(g_class_canon "$CLASS_RAW") \
325
- || { g_err "unknown class '$CLASS_RAW' in $PROP (expected software|service|game|research|fleet, or A-E / app / agent / desktop)"; exit 2; }
326
- ELECTRON=0
327
- g_class_is_electron_alias "$CLASS_RAW" && ELECTRON=1
328
- [ "$(g_agents_read "$PROP" electron)" = "true" ] && ELECTRON=1
329
-
330
426
  GATE_NAME=$(g_agents_gates "$PROP" | head -n 1 | awk -F'\t' '{print $1}')
331
427
  GATE_CMD=$(g_agents_gates "$PROP" | head -n 1 | awk -F'\t' '{print $2}')
332
428
  [ -n "$GATE_CMD" ] || { g_err "$PROP declares no gate — the brief requires at least one gate_<name>_cmd"; exit 2; }
333
- BRANCH=$(g_agents_read "$PROP" branch)
334
- [ -n "$BRANCH" ] || BRANCH=$( cd "$TARGET" && git rev-parse --abbrev-ref HEAD 2>/dev/null )
335
- [ -n "$BRANCH" ] || BRANCH=main
336
- EMAIL=$(g_agents_read "$PROP" owner_email)
337
- [ -n "$EMAIL" ] || EMAIL=$( cd "$TARGET" && git config user.email 2>/dev/null )
338
- [ -n "$EMAIL" ] || EMAIL="you@example.com"
339
- SYNC_SEL=$(g_agents_list "$PROP" sync_platforms | tr '\n' ' ')
340
- # The extras the proposal's human approved (catalogue_suggestions tick lines in the
341
- # summary). Only TICKED ids count — an unticked MAYBE line is a visible choice the
342
- # human did not make. Every id is re-resolved through the catalogue's own allowlist
343
- # gate in goblin-extras (unknown id -> refusal; SKIP verdict -> refusal): a proposal
344
- # cannot install anything the catalogue does not carry.
345
- EXTRAS_SEL=$(sed -n '/catalogue_suggestions:/,/^[^ -]/{s/^[[:space:]]*-[[:space:]]*\[x\][[:space:]]*\([A-Za-z0-9_-]*\).*/\1/p;}' "$PROP" | sort -u | tr '\n' ' ')
346
-
347
- # ---------------------------------------------------------------- pre-flight ---
348
- # QA fix (v2-qa issue 1b): the TICKED extras are validated BEFORE anything is written.
349
- # The old order installed the harness first and ran `gob extras install` last, so a
350
- # missing vendored payload refused AFTER 23 files were already in the tree (the day-one
351
- # exit 2 with the repo half-initialized). Here every ticked id is resolved through the
352
- # same allowlist path goblin-extras uses (row exists, verdict installable, license gate,
353
- # vendored payload present) while the target is still untouched; a refusal names the id
354
- # and the fix and exits before the first write.
355
- if [ -n "$EXTRAS_SEL" ] && [ "$DRYRUN" -eq 0 ]; then
356
- PAYLOAD_ROOT="${GOB_EXTRAS_PAYLOAD:-$SRC/extras-catalogue/payload}"
357
- for xid in $EXTRAS_SEL; do
358
- row=$(awk -F'\t' -v id="$xid" 'NR>1 && $1==id { print; exit }' "$CATALOGUE_TSV" 2>/dev/null)
359
- [ -n "$row" ] || { g_err "pre-flight: catalogue has no row '$xid' — fix the proposal's catalogue_suggestions (gob extras list names the allowlist)"; exit 2; }
360
- verdict=$(printf '%s' "$row" | awk -F'\t' '{print $15}')
361
- lic=$(printf '%s' "$row" | awk -F'\t' '{print $18}')
362
- case "$verdict" in
363
- RECOMMEND|MAYBE) ;;
364
- *) g_err "pre-flight: '$xid' carries verdict '$verdict' — untick it in the proposal's catalogue_suggestions"; exit 2 ;;
365
- esac
366
- # the same license gate goblin-extras enforces, read before any write
367
- case "$lic" in
368
- verified) ;;
369
- *) g_err "pre-flight: '$xid' refuses install: license pending verification — untick it in the proposal's catalogue_suggestions"; exit 2 ;;
370
- esac
371
- [ -d "$PAYLOAD_ROOT/$xid" ] || {
372
- g_err "pre-flight: no vendored payload for '$xid' at $PAYLOAD_ROOT/$xid — untick it in the proposal's catalogue_suggestions, or vendor the payload there first";
373
- exit 2;
374
- }
375
- done
429
+
430
+ # feature_map is REQUIRED (DECISION, 2026-10-09): the map is mandatory, so there is no
431
+ # "no map declared" state. A proposal without it, or with it empty, refuses here.
432
+ FEATURE_MAP=$(g_agents_read "$PROP" feature_map)
433
+ [ -n "$FEATURE_MAP" ] || { g_err "$PROP declares no feature_map — add 'feature_map: features/README.md' to the gob block and a '## feature-map' section (the brief's SCHEMA); the map is mandatory"; exit 2; }
434
+
435
+ # The map's directory, relative to the repo root. feature_map names the README (the value
436
+ # verify reads); the map lives in a directory of its own, never the repo root.
437
+ MAPDIR_REL=$(dirname "$FEATURE_MAP")
438
+ [ "$MAPDIR_REL" != "." ] || { g_err "feature_map must name a directory of its own (e.g. features/README.md), not the repo root"; exit 2; }
439
+
440
+ # Empty repo: no committed file to map. The map's entry paths are committed files, so a repo
441
+ # with nothing committed cannot carry a resolvable map. Refuse with the named remedy — no
442
+ # bootstrap feature is invented (a feature with no resolvable entry path is an assertion,
443
+ # not a count).
444
+ if [ -z "$( cd "$TARGET" && git ls-files 2>/dev/null | head -n 1 )" ]; then
445
+ g_err "the target has no committed file to map — commit at least one file, then run again"; exit 2
446
+ fi
447
+
448
+ # Validate BOTH halves in ONE pass, before anything is written. The map the proposal embeds
449
+ # is extracted to a staging dir and handed to bin/goblin-map (the SAME validator `gob map
450
+ # --write` used): the FM-01 shape plus FM-02 resolvability (exists AND tracked) against the
451
+ # target. Nothing is written unless it validates.
452
+ STAGE=$(mktemp -d "${TMPDIR:-/tmp}/goblin-init.map.XXXXXX") || { g_err "mktemp failed"; exit 2; }
453
+ trap 'rm -rf "$STAGE"' EXIT
454
+ BLOCKS=$(extract_feature_map "$PROP" "$STAGE") || { g_err "could not read the proposal's feature-map section"; exit 2; }
455
+ [ "${BLOCKS:-0}" -ge 1 ] || { g_err "$PROP carries no feature-map blocks — the SCHEMA needs a '### $MAPDIR_REL/README.md' block and one '### $MAPDIR_REL/<slug>.md' per feature"; exit 2; }
456
+ [ -d "$STAGE/$MAPDIR_REL" ] || { g_err "the proposal's feature-map blocks are not under '$MAPDIR_REL' (the directory of the declared feature_map: $FEATURE_MAP)"; exit 2; }
457
+ if ! MAP_OUT=$(bash "$SRC/bin/goblin-map" --validate "$STAGE/$MAPDIR_REL" --root "$TARGET" 2>&1); then
458
+ printf '%s\n' "$MAP_OUT" >&2
459
+ g_err "the proposal's feature map failed validation (FM-01/FM-02) — fix the file(s) named above; nothing was written"
460
+ exit 2
376
461
  fi
377
462
 
378
463
  if [ "$DRYRUN" -eq 1 ]; then
379
- g_info "gob init --write --dry-run: validated OK (class $CLASS, branch $BRANCH, owner $EMAIL, 1+ gate)"
380
- g_info " sync: ${SYNC_SEL:-none}"
381
- g_info " extras: ${EXTRAS_SEL:-none}"
382
- g_info " would write: AGENTS.md (body + gob block), .gob/engine/, HANDOFF.md"
464
+ g_info "gob init --write --dry-run: validated OK (1+ gate, feature map '$FEATURE_MAP')"
465
+ g_info " would write: AGENTS.md (body + gob block), .gob/engine/, HANDOFF.md, $MAPDIR_REL/"
466
+ g_info " the declared gate was NOT run (--dry-run)"
383
467
  exit 0
384
468
  fi
385
469
 
470
+ # ------------------------------------------------------------------- the gate ---
471
+ # The gate is RUN, not guessed (DECISION, 2026-10-09). Execute the declared first gate in the
472
+ # working tree before installing, and report the measured exit code and the command's first
473
+ # output line. A non-zero exit is ACCEPTED — a legitimate day-one red that GT-02 re-runs from
474
+ # the installed config. A command that CANNOT be run at all (exit 127) is not a gate: refuse.
475
+ GATE_RAW=$( cd "$TARGET" && bash -c "$GATE_CMD" 2>&1 ); GATE_RC=$?
476
+ if [ "$GATE_RC" -eq 127 ]; then
477
+ g_err "gate_${GATE_NAME}_cmd is not a runnable command (exit 127): $GATE_CMD — name a command that exists, or author one at checks/gate.sh"
478
+ exit 2
479
+ fi
480
+ GATE_LINE=$(printf '%s\n' "$GATE_RAW" | sed '/^[[:space:]]*$/d' | head -n 1)
481
+ g_info "gob init [gate] $GATE_CMD"
482
+ g_info " measured exit code: $GATE_RC"
483
+ if [ -n "$GATE_LINE" ]; then g_info " first output line: $GATE_LINE"; fi
484
+
386
485
  # ------------------------------------------------------------------- install ---
387
486
  # One engine call writes the vendored payload (.gob/), AGENTS.md body + gob block and
388
487
  # HANDOFF.md. Its refusal contract applies verbatim: an existing HANDOFF.md is never
389
488
  # overwritten; an edited AGENTS.md body is kept (put_once) and only the block is rewritten.
390
- INSTALL_ARGS=(--target "$TARGET" --class "$CLASS" --skills no --yes)
489
+ INSTALL_ARGS=(--target "$TARGET" --skills "$SKILLS_OPT" --yes)
391
490
  # The first gate is the proposal's own: its name AND command. The name rides along so the
392
491
  # HANDOFF template renders the declared name — HP-03 anchors on declared gate names, and a
393
492
  # HANDOFF that names a gate the config does not declare is the day-one red (GT-04/HP-03
394
493
  # anchoring). GATE_NAME comes from the same key the reader parses (gate_<name>_cmd).
395
494
  GATE_NAME=$(g_agents_gates "$PROP" | head -n 1 | awk -F'\t' '{print $1}')
396
495
  INSTALL_ARGS+=(--gate "$GATE_CMD" "$GATE_NAME")
397
- [ "$ELECTRON" -eq 1 ] && INSTALL_ARGS+=(--electron)
398
- printf 'gob init [run] goblin-install --target %s --class %s\n' "$TARGET" "$CLASS"
399
- bash "$SRC/bin/goblin-install" "${INSTALL_ARGS[@]}"
496
+ printf 'gob init [run] goblin-install --target %s\n' "$TARGET"
497
+ # The engine is told to DEFER the next-steps block: this front-door command prints the ONE list
498
+ # itself, at the very end (g_next_block). Without this the user saw two `next:` lists.
499
+ GOB_NEXT_DEFER=1 bash "$SRC/bin/goblin-install" "${INSTALL_ARGS[@]}"
400
500
  RC=$?
401
501
  [ "$RC" -eq 0 ] || { g_err "install failed (exit $RC) — the refusals above name the path and the fix"; exit "$RC"; }
402
502
 
403
503
  CONFIG="$TARGET/AGENTS.md"
404
504
  [ -f "$CONFIG" ] || { g_err "install wrote no AGENTS.md at $TARGET"; exit 1; }
405
505
 
406
- # The proposal MERGES over the class defaults the installer rendered: the proposal's keys
506
+ # The proposal MERGES over the defaults the installer rendered: the proposal's keys
407
507
  # win, every default key the proposal did not set stays (a proposal carrying only the
408
508
  # brief's required keys must not blank archive/ratchet/replay — the schema is a minimum,
409
509
  # not the whole block). Proposal keys the config did not have are appended.
410
- # EXCEPT the gate keys: the proposal's first gate REPLACES the class default gate_<name>_cmd
411
- # (the default names a class-taxonomy gate the project never declared), and every OTHER
510
+ # EXCEPT the gate keys: the proposal's first gate REPLACES the installer's default gate_<name>_cmd
511
+ # (the default names a taxonomy gate the project never declared), and every OTHER
412
512
  # default gate_* key is dropped — a gate the config declares must be one the proposal chose,
413
- # never a leftover default naming a gate the HANDOFF does not render. The second class gate
414
- # (e.g. the software class's todo_ceiling) is opt-IN: the proposal may declare it itself.
513
+ # never a leftover default naming a gate the HANDOFF does not render. The second default gate
514
+ # (the todo_ceiling) is opt-IN: the proposal may declare it itself.
415
515
  {
416
516
  first_gate=1
417
517
  while IFS= read -r k; do
@@ -425,8 +525,8 @@ CONFIG="$TARGET/AGENTS.md"
425
525
  esac
426
526
  # An ABSENT key prints "key<TAB><TAB>", which renders as "key:: key:" - a key that
427
527
  # reads back as its own name twice and fails IN-02/PF-01/FM-01 on a fresh install.
428
- # A proposal line with an empty value carries no merge information (the class
429
- # default the installer rendered already covers it): drop it here.
528
+ # A proposal line with an empty value carries no merge information (the installer
529
+ # default already covers it): drop it here.
430
530
  k_val=$(g_agents_read "$PROP" "$k")
431
531
  [ -n "$k_val" ] && printf '%s\t%s\n' "$k" "$k_val"
432
532
  done <<< "$BLOCK_KEYS"
@@ -441,47 +541,33 @@ CONFIG="$TARGET/AGENTS.md"
441
541
  # Fail closed: the declared gate must read back through the engine's own reader.
442
542
  GOT_GATE=$(g_agents_gates "$CONFIG" | head -n 1 | awk -F'\t' '{print $2}')
443
543
  [ "$GOT_GATE" = "$GATE_CMD" ] || { g_err "the first gate did not land in $CONFIG (reader sees '$GOT_GATE', wanted '$GATE_CMD')"; exit 1; }
444
- [ "$(g_agents_read "$CONFIG" owner_email)" = "$EMAIL" ] || { g_err "owner_email did not land in $CONFIG"; exit 1; }
445
-
446
- # ------------------------------------------------------------- sync (hidden) ---
447
- # The sync-translator step (existing emit engine) runs for the platforms the proposal
448
- # named. A proposal that names none emits nothing — the neutral-first contract.
449
- for p in $SYNC_SEL; do
450
- printf 'gob init [run] sync --platform %s --scope project\n' "$p"
451
- bash "$SRC/bin/goblin-emit" --platform "$p" --scope project --target "$TARGET" || {
452
- RC=$?; g_err "sync $p failed (exit $RC)"; exit "$RC"; }
453
- done
454
-
455
- # ------------------------------------------------------------- extras ----------
456
- # The proposal's TICKED catalogue_suggestions install through the goblin-extras
457
- # allowlist itself — one code path, one set of refusals (unknown id, SKIP verdict,
458
- # missing payload). init --write never copies an extra by its own hand: the catalogue
459
- # is the allowlist, and the CLI is the only installer. A refusal fails the whole
460
- # --write (the human re-ticks).
461
- #
462
- # ORDER MATTERS: --with-mcp-config writes the gob registration FIRST, then the mcp-kind
463
- # extras merge INTO it — the other order would leave .mcp.json carrying only the extra
464
- # and do_mcp_config would refuse it (the generated-bytes ask-once check). Extras mcp
465
- # merges are themselves ask-once: an entry you customized is never overwritten.
544
+ [ "$(g_agents_read "$CONFIG" feature_map)" = "$FEATURE_MAP" ] || { g_err "feature_map did not land in $CONFIG (reader sees '$(g_agents_read "$CONFIG" feature_map)', wanted '$FEATURE_MAP')"; exit 1; }
545
+
546
+ # --------------------------------------------------------------- feature map ----
547
+ # Materialise the map the proposal embedded (validated above, before anything was written).
548
+ mkdir -p "$TARGET/$MAPDIR_REL" || { g_err "could not create $TARGET/$MAPDIR_REL"; exit 1; }
549
+ cp -R "$STAGE/$MAPDIR_REL/." "$TARGET/$MAPDIR_REL/" 2>/dev/null \
550
+ || { g_err "could not write the feature map into $TARGET/$MAPDIR_REL"; exit 1; }
551
+ [ -f "$TARGET/$FEATURE_MAP" ] || { g_err "the feature map did not land at $TARGET/$FEATURE_MAP"; exit 1; }
552
+
553
+ # ------------------------------------------------------- mcp config + hooks ----
554
+ # The user runs NO gob command after install. The MCP registration is now OPT-IN
555
+ # (--with-mcp-config): the named removal that pays for hooks emission (proposal §3).
556
+ # The hooks payload runs by default, into existing vendor directories only.
466
557
  if [ "$WITH_MCP" -eq 1 ]; then
467
558
  do_mcp_config || exit 1
468
559
  fi
469
- if [ -n "$EXTRAS_SEL" ]; then
470
- for xid in $EXTRAS_SEL; do
471
- printf 'gob init [run] extras install %s\n' "$xid"
472
- bash "$SRC/bin/goblin-extras" install "$xid" --target "$TARGET" || {
473
- RC=$?; g_err "extras install $xid failed (exit $RC) — fix the proposal's catalogue_suggestions and re-run"; exit "$RC"; }
474
- done
475
- fi
560
+ do_hooks || exit 1
476
561
 
477
562
  # --------------------------------------------------------------------- done ----
478
563
  printf '\n'
479
- printf 'gob init: installed — class %s, branch %s, owner %s\n' "$CLASS" "$BRANCH" "$EMAIL"
564
+ printf 'gob init: installed — feature map %s\n' "$FEATURE_MAP"
480
565
  printf ' harness: %s/.gob/bin/goblin-verify\n' "$TARGET"
481
- printf 'next:\n'
482
- printf ' 1. git add -A && git commit # the install is uncommitted by design\n'
483
- printf ' 2. run .gob/bin/goblin-verify — the skipped rows are the day-one checklist\n'
484
- printf ' 3. features/: gob map (agent brief) then gob map --write features/\n'
485
- printf ' 4. register the verify tool for your agent: %s mcp add gob -- npx -y @techgoblin/gobstack mcp (or run gob init --with-mcp-config)\n' "$AGENT_CLI"
486
- [ -n "$SYNC_SEL" ] || printf ' 5. agent skills are opt-in per platform\n'
566
+ if [ "$WITH_MCP" -eq 0 ]; then
567
+ printf ' no .mcp.json written — the MCP registration is opt-in: re-run with --with-mcp-config\n'
568
+ fi
569
+ printf '\n'
570
+ # The ONE ordered next-steps list (the engine deferred its own copy). The gate is the one this
571
+ # command declared and MEASURED above, so the list does not tell the user to replace it.
572
+ g_next_block "$TARGET" "$SKILLS_OPT" "$GATE_NAME: $GATE_CMD"
487
573
  exit 0