@bluenyang/reins 0.3.4 → 0.4.0-rc.2

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 (66) hide show
  1. package/README.md +164 -39
  2. package/cli/dist/commands/config-gates.js +64 -6
  3. package/cli/dist/commands/config-models.js +19 -0
  4. package/cli/dist/commands/config.js +40 -16
  5. package/cli/dist/commands/configure.js +207 -47
  6. package/cli/dist/commands/install.js +91 -31
  7. package/cli/dist/commands/migrate.js +17 -20
  8. package/cli/dist/commands/update.js +164 -12
  9. package/cli/dist/lib/agents-md.js +55 -13
  10. package/cli/dist/lib/bindings.js +7 -10
  11. package/cli/dist/lib/blocks.js +82 -18
  12. package/cli/dist/lib/detect.js +88 -3
  13. package/cli/dist/lib/gate-refresh.js +35 -5
  14. package/cli/dist/lib/gate-script.js +303 -25
  15. package/cli/dist/lib/generate.js +48 -6
  16. package/cli/dist/lib/git.js +33 -0
  17. package/cli/dist/lib/migrate-plan.js +1 -1
  18. package/cli/dist/lib/profile.js +101 -0
  19. package/cli/dist/lib/prompter.js +2 -1
  20. package/cli/dist/lib/release.js +1 -1
  21. package/cli/dist/lib/schema.js +6 -3
  22. package/cli/dist/lib/upstream.js +1 -1
  23. package/cli/dist/reins.js +40 -14
  24. package/docs/README.ko.md +113 -23
  25. package/harness/CHANGELOG.md +12 -0
  26. package/harness/VERSION +1 -1
  27. package/harness/policy/common-red-lines.yaml +7 -5
  28. package/harness/roles/advisor.md +1 -1
  29. package/harness/roles/auditor.md +12 -11
  30. package/harness/roles/executor.md +4 -3
  31. package/harness/roles/implementer.md +5 -5
  32. package/harness/roles/pl.md +4 -4
  33. package/harness/roles/planner.md +7 -8
  34. package/harness/roles/pm.md +7 -8
  35. package/harness/schemas/bindings.schema.json +2 -0
  36. package/harness/schemas/install.schema.json +1 -0
  37. package/harness/schemas/intent.schema.json +9 -1
  38. package/harness/schemas/plan.schema.json +18 -0
  39. package/harness/schemas/spec.schema.json +9 -6
  40. package/harness/templates/agents-md-blocks.md +19 -54
  41. package/harness/templates/agents-md-guide.md +11 -10
  42. package/harness/templates/audit.md +14 -41
  43. package/harness/templates/history.md +1 -5
  44. package/harness/templates/intent.md +8 -19
  45. package/harness/templates/plan.md +23 -0
  46. package/harness/templates/spec.md +21 -16
  47. package/package.json +1 -1
  48. package/skills/audit/SKILL.md +27 -33
  49. package/skills/gates/SKILL.md +41 -0
  50. package/skills/implement/SKILL.md +33 -22
  51. package/skills/implement/references/procedure.md +51 -0
  52. package/skills/intent/SKILL.md +29 -20
  53. package/skills/intent/references/procedure.md +60 -0
  54. package/skills/onboard/SKILL.md +39 -28
  55. package/skills/plan/SKILL.md +35 -0
  56. package/skills/plan/references/procedure.md +52 -0
  57. package/skills/reins-setup/SKILL.md +4 -4
  58. package/skills/release/SKILL.md +18 -20
  59. package/skills/retro/SKILL.md +21 -26
  60. package/skills/review/SKILL.md +33 -17
  61. package/skills/review/references/procedure.md +50 -0
  62. package/skills/spec/SKILL.md +25 -19
  63. package/skills/spec/references/procedure.md +67 -0
  64. package/skills/merge/SKILL.md +0 -32
  65. package/skills/roadmap/SKILL.md +0 -29
  66. package/skills/test/SKILL.md +0 -26
package/README.md CHANGED
@@ -1,44 +1,145 @@
1
1
  # reins
2
2
 
3
- [한국어](docs/README.ko.md)
3
+ [![한국어](https://img.shields.io/badge/%ED%95%9C%EA%B5%AD%EC%96%B4-README-blue)](docs/README.ko.md)
4
+ [![npm](https://img.shields.io/npm/v/@bluenyang/reins?label=npm)](https://www.npmjs.com/package/@bluenyang/reins)
5
+ [![license](https://img.shields.io/npm/l/@bluenyang/reins)](LICENSE)
6
+ <br>
7
+ [![Node](https://img.shields.io/badge/Node-%E2%89%A522-339933?logo=nodedotjs&logoColor=white)](package.json)
8
+ [![TypeScript](https://img.shields.io/badge/TypeScript-ESM-3178C6?logo=typescript&logoColor=white)](cli/tsconfig.json)
9
+ [![pnpm](https://img.shields.io/badge/pnpm-workspace-F69220?logo=pnpm&logoColor=white)](package.json)
10
+ <br>
11
+ [![AGENTS.md](https://img.shields.io/badge/AGENTS.md-supported-555)](https://agents.md)
12
+ [![Agent Skills](https://img.shields.io/badge/Agent%20Skills-SKILL.md-555)](https://agentskills.io)
13
+ [![Claude Code](https://img.shields.io/badge/Claude%20Code-supported-D97757?logo=claude&logoColor=white)](https://code.claude.com)
14
+ [![Codex](https://img.shields.io/badge/Codex-supported-412991?logo=openai&logoColor=white)](https://developers.openai.com/codex)
15
+ [![Antigravity](https://img.shields.io/badge/Antigravity%20(agy)-supported-4285F4?logo=google&logoColor=white)](https://antigravity.google)
16
+ [![Cursor](https://img.shields.io/badge/Cursor%20Agent-supported-000000?logo=cursor&logoColor=white)](https://cursor.com)
17
+
18
+ **Keep the setup of AI-assisted projects consistent: agents do the repeating, people make the final
19
+ decisions.**
4
20
 
5
21
  reins manages an agent harness for a repository: it installs, migrates, updates and configures the
6
- files that tell coding agents how to work there — `AGENTS.md`, roles, stage skills and the model
22
+ files that tell coding agents how to work there — `AGENTS.md`, skills, roles and the model
7
23
  assignment. That is all it does. Nothing reins installs runs reins while the project works: the
8
- project's own hook tool runs the project's own checks, and an audit at the end of every version
9
- judges whether the flow was followed.
24
+ project's own hook tool runs the project's own checks, and a person confirms the plan, merges and
25
+ releases.
10
26
 
11
- It exists because twelve repositories of BlueNyang and Team Croffle share one harness lineage and
12
- its problems: agents stepping outside the request, one session that implements and also judges,
13
- knowledge lost in gitignored space, copies that drift apart. The full list is in
14
- [docs/proposal.md](docs/proposal.md).
27
+ ## Why
28
+
29
+ reins started from loop engineering: every stage had a command, and a person watched the loop and called
30
+ the next step. The same harness was copied by hand from project to project until the copies drifted apart,
31
+ and setting it up for a new project meant writing the same long prompt again. reins turns that into a tool
32
+ that installs, migrates and updates the harness.
33
+
34
+ Up to 0.3, reins tried to control and restrain the agents at every step, first with a verifier and then
35
+ with mandatory audits. In one project that ended in a review loop of more than six hours, and the
36
+ unnecessary reviews and audits held the models back: they asked for permission at every step even when
37
+ allowed to go on, and rewrote finished work to satisfy an audit. 0.4 goes the other way. A capable model
38
+ gets context rather than constraints, a person keeps the decisions that matter, and a small open model can
39
+ still choose the full harness.
40
+
41
+ How each of these decisions was reached is in [docs/conversation/](docs/conversation/README.md) (Korean).
15
42
 
16
43
  ## Status
17
44
 
18
- **0.3.4-rc.2 is the release candidate** (intent 024): `npx @bluenyang/reins@0.3.4-rc.2`. **0.3.3 is the latest release** (intents 019–023): `npx @bluenyang/reins install`. Up to 0.2.0, skills and hooks called `npx @bluenyang/reins` during work; 0.3 removes that, and `reins update` moves a 0.1.x or 0.2.0 install over. What changed in each version is in [CHANGELOG.md](CHANGELOG.md); what comes next is in the [roadmap](docs/ROADMAP.md).
45
+ **0.3.4 is the latest release.** 0.4 is on `master` and not released yet; this page describes 0.4. What
46
+ changed in each version is in [CHANGELOG.md](CHANGELOG.md), and what comes next in the
47
+ [roadmap](docs/ROADMAP.md).
48
+
49
+ ```sh
50
+ npx @bluenyang/reins install
51
+ ```
19
52
 
20
53
  ## How it works
21
54
 
22
- - **Single agent by default.** One agent, the PM, carries out every stage. It may use subagents of its own
23
- model for read-heavy work (research, review, audit) and urgent parallel work. Multi-agent work is switched
24
- on by assigning models to role groups — PM, PL, Planner, Implementer, Executor, Advisor, Auditor; a group
25
- without a model is done by the PM. The basis is Anthropic's
55
+ - **Single agent by default.** One agent, the PM, does the work. It may use subagents of its own model for
56
+ read-heavy work (research, review, audit) and for building independent features in parallel. Multi-agent
57
+ work is switched on by assigning models to role groups — PM, PL, Planner, Implementer, Executor, Advisor,
58
+ Auditor; a group without a model is done by the PM. The basis is Anthropic's
26
59
  [Building agents: When to fold subagents into your main agent loop](https://claude.com/resources/articles/building-agents-when-to-fold-subagents-into-your-main-agent-loop) (2026-10-22).
27
- - **A flow written down, not enforced at run time.** `docs/ROADMAP.md` → intent → spec → implement →
28
- review → test → PR and CI → first audit → merge → release → second audit → retro. Each stage is a skill in `.agents/skills/`; `AGENTS.md`
29
- holds the order and the rules for stopping and asking.
30
- - **The user approves.** The intent and every spec summary wait for the user; the PM records approvals by
31
- quoting the user. A step the user tells the agent to skip is recorded once.
32
- - **Two audits for every version.** After CI and before the merge, a first audit reads the records (intent,
33
- spec, git history, logs) and looks for risk; after the release a second audit looks at procedure only and
34
- hands its result to the retro. They are mandatory unless the user switches them off, and their record is
35
- committed to `.agents/audit/`.
36
- - **Onboarding.** After installation, the first conversation reads the project, asks the user, and writes the
37
- project sections of `AGENTS.md`.
38
- - **Every file has a lifetime.** Working files are summarised and deleted after the retro.
60
+ - **Skills, not a flow.** The model picks a skill in `.agents/skills/` by its description. No order is
61
+ enforced, and a small fix takes the fast lane (no spec or plan, the first review only). `AGENTS.md` holds
62
+ only what the code cannot tell: the delegation table, what people do, the layout and the project's own
63
+ sections.
64
+ - **A person at five points.** A person states the requirement, confirms the plan, checks the completion
65
+ report, merges and releases (rc included). In between the agent goes on without asking. In Claude Code, merging,
66
+ publishing, releasing and pushing to the default branch or a tag are denied in `.claude/settings.json` (a
67
+ guard against mistakes, not an enforcement), so an agent goes as far as pushing its work branch and opening
68
+ the pull request.
69
+ - **One review that knows when to stop.** The first review is always done and looks at correctness only.
70
+ Only an Important finding blocks the merge, and a fix that can be proven (a passing test, the error gone)
71
+ is not reviewed again.
72
+ - **Gates by area.** `gates.yaml` maps areas to paths, and a hook runs only the gates of the areas a change
73
+ touches; a gate without areas always runs, and so does every gate when `gates.yaml` itself changes. The
74
+ full check is CI's.
75
+ - **The audit is optional.** A person starts it, and it looks at risk only: secrets, red lines, irreversible
76
+ changes, checks without evidence.
77
+ - **Two profiles.** `light` (the default) keeps the skill bodies; `full` adds step-by-step references, the
78
+ role files and the `rs-*` agents, for smaller models.
79
+ - **Every file has a lifetime.** Each file has an owner and a point where it is deleted.
39
80
 
40
81
  The design is in [docs/design.md](docs/design.md).
41
82
 
83
+ ## A piece of work, start to end
84
+
85
+ 1. **Idea.** You say what you want. The agent (skill `intent`) looks it up, asks why, what and how, says so
86
+ when it sees a better way, and keeps the note in `.loctx/intent/`. Settled items go to `docs/ROADMAP.md`.
87
+ 2. **Spec.** When you want something built, `spec` bundles the intents into requirements and a basic
88
+ design in `.agents/spec/<NNN>_<slug>/spec.md`, and asks you about the direction of the design.
89
+ 3. **Plan — you confirm.** `plan` writes one or more plans: the files, the order, the risks and threats, how
90
+ it will be verified and what you should watch. Nothing is built until you confirm.
91
+ 4. **Build.** `implement` follows the plan in the way you asked (itself, subagents, another vendor's model,
92
+ in parallel). Where the plan turns out wrong, it changes course and tells you.
93
+ 5. **Pull request and the first review.** The agent pushes the work branch, opens the pull request with a
94
+ completion report (what changed, the structure, what differs from the plan, the verification with log
95
+ paths) and has it reviewed once.
96
+ 6. **You merge and release.** The merge and every release, rc included, are yours.
97
+
98
+ A defect fix or a small change inside one area skips 2 and 3: the agent fixes it, gets the first review and
99
+ says "fast lane" in the report.
100
+
101
+ ## Using the skills
102
+
103
+ After installation, talk to the agent as usual; it picks a skill when your words match its description.
104
+ You can also name one, for example `/intent` in Claude Code.
105
+
106
+ Codex, Antigravity (`agy`) and Cursor Agent list the skills in `.agents/skills/` as their own, as Claude
107
+ Code does (checked with each on 2026-11-30), and each can be given a role through its command line in the
108
+ delegation table. What reins writes for Claude Code alone are the deny rules in `.claude/settings.json` and,
109
+ in the full profile, the `rs-*` subagents; with the others, merging and releasing are held back only by
110
+ the text of `AGENTS.md` and the skills.
111
+
112
+ | You say, for example | Skill | You get |
113
+ |---|---|---|
114
+ | "I want X, because …", "what if we …" | `intent` | questions, research, a note in `.loctx/intent/` |
115
+ | "let's build X" | `spec` | `spec.md` with requirements and a basic design, and questions |
116
+ | "ready to start", "plan it" | `plan` | `plan.md` for you to confirm |
117
+ | "go", "implement it" | `implement` | commits, a pull request, a completion report |
118
+ | "review this" (also after every push) | `review` | one review; a re-review only when a fix cannot be proven |
119
+ | "the checks are slow", "add a check" | `gates` | proposals for `gates.yaml` — removals first |
120
+ | "write the release notes", `/release` in Claude Code (likewise `audit`, `retro`) | `release`, `audit`, `retro` | release notes, a risk audit, a retrospective — they run only when you name them |
121
+
122
+ The first conversation after `install` or `update` starts with `onboard`, which reads the project, asks you,
123
+ and writes or tidies the project sections of `AGENTS.md`.
124
+
125
+ ## What install adds to a project
126
+
127
+ ```
128
+ <project>/
129
+ ├── AGENTS.md delegation table, what people do, layout (reins) + your project sections
130
+ ├── CLAUDE.md @AGENTS.md
131
+ ├── .agents/ committed
132
+ │ ├── skills/ the skills (+ references/ in full)
133
+ │ ├── spec/ specs and plans, one folder per piece of work
134
+ │ ├── knowledge/ decisions worth keeping
135
+ │ └── harness/ bindings.yaml (models, mode, profile), gates.yaml, run-gates.sh, templates
136
+ ├── .claude/ committed: skills/, settings.json (deny rules), agents/rs-*.md (full)
137
+ └── .loctx/ gitignored: intent/, ROADMAP.local.md, history/, reports/, your personal settings
138
+ ```
139
+
140
+ Your hook tool (husky, lefthook, pre-commit) gets one line per stage, `sh .agents/harness/run-gates.sh
141
+ pre-commit` (and `pre-push`); `install` proposes it and adds it to husky with `--hooks`.
142
+
42
143
  ## Quick start
43
144
 
44
145
  Run it from the root of the repository you want to set up (Node 22 or later):
@@ -46,7 +147,7 @@ Run it from the root of the repository you want to set up (Node 22 or later):
46
147
  ```sh
47
148
  npx @bluenyang/reins install --dry-run # show what would be written
48
149
  npx @bluenyang/reins install # ask, then place the harness
49
- npx @bluenyang/reins config # models and roles, agent tools, mode, audit
150
+ npx @bluenyang/reins config # models and roles, agent tools, mode, profile, gates
50
151
  ```
51
152
 
52
153
  Then open your agent in the repository: the onboarding note in `AGENTS.md` starts the first conversation.
@@ -58,31 +159,55 @@ In Claude Code the plugin shows the same commands:
58
159
  /reins:reins-setup
59
160
  ```
60
161
 
61
- To work on reins itself: `git clone https://github.com/bluenyang/reins.git`, then `pnpm install`,
62
- `pnpm build`, and run `node cli/dist/reins.js <command>` (see [CONTRIBUTING.md](CONTRIBUTING.md)).
63
-
64
162
  ## Commands
65
163
 
66
164
  | Command | Does |
67
165
  |---|---|
68
- | `install` | places the harness, detects agent tools, confirms gates, writes the gate script `.agents/harness/run-gates.sh` (it runs the project's gate commands and keeps their output for the audit) and proposes the one hook line that calls it (`--hooks` adds it to husky), adds the onboarding note; `--mode manual\|auto`, `--dry-run`, `--json` |
69
- | `migrate` | moves an older harness or an `.ai/` workspace onto this layout and keeps the previous `AGENTS.md` aside for the PM to reconcile; `--legacy local\|committed`, `--dry-run` |
70
- | `update` | re-applies the packaged harness; asks before overwriting a generated file edited by hand (`--force`); moves a 0.1.x or 0.2.0 install to 0.3 and lists its old working files (`--yes` deletes them) |
71
- | `config` | a screen on a terminal: models and roles, agent tools, mode (single or multi), audit; `config bindings` and `config gates` take flags (`configure` is an alias). `config gates --refresh` finds the project's checks again (scripts by name and body, workspaces, CI), shows every gate and candidate with its state and reasons — applied, not applied, already run by another — leaves the same list in `.loctx/gates-refresh.md`, and changes `gates.yaml` only as you pick (`--apply <name…|all|remove:name>` without a terminal); it never calls a gate gone; the screen has a `gates` item for the same. A group or a role may name a fallback model (`config bindings --fallback <group>[.<role>]=<model>`): its call line goes into the delegation table, for when the first model cannot be called |
166
+ | `install` | places the harness, asks the profile, finds the gates and proposes their areas, proposes the hook line, adds the onboarding note (`--mode`, `--profile`, `--hooks`, `--dry-run`, `--json`) |
167
+ | `migrate` | moves an older harness or an `.ai/` workspace onto this layout (`--legacy`, `--dry-run`) |
168
+ | `update` | re-applies the packaged harness, asks before overwriting a hand-edited file (`--force`), and moves older installs forward (`--yes`, `--dry-run`) |
169
+ | `config` | a screen on a terminal for models and roles, agent tools, mode, profile, the audit model and gates; `config bindings` and `config gates` take flags without one |
170
+
171
+ **`update` from 0.3.** It removes the `roadmap`, `test` and `merge` skills (a hand-edited one is kept and
172
+ listed), writes the new `AGENTS.md` blocks, sets the profile from the installed agents (`full` when `rs-*`
173
+ agents exist, else `light`), moves `gates.yaml` to version 2 without areas (the checks behave as before) and
174
+ leaves a reset note for `onboard`. From 0.1.x or 0.2.0 it first moves to 0.3 and lists the old working files
175
+ (`--yes` deletes them).
176
+
177
+ **`config gates`.** `--refresh` finds the project's checks again (scripts by name and body, workspaces, CI)
178
+ and lists every gate and candidate with its state and reasons, removal candidates first; the same list goes
179
+ to `.loctx/gates-refresh.md`, and `gates.yaml` changes only as you pick (`--apply <name…|all|remove:name>`).
180
+ `--define-area <name>=<glob,…>`, `--area <gate>=<area,…>` and `--on <gate>=<stage,…>` set areas and stages.
72
181
 
73
- ## Skills
182
+ **Fallback models.** A group or a role may name one (`config bindings --fallback <group>[.<role>]=<model>`);
183
+ its call line goes into the delegation table, for when the first model cannot be called.
184
+
185
+ ## This repository
186
+
187
+ ```
188
+ reins/
189
+ ├── cli/src/
190
+ │ ├── reins.ts the CLI entry
191
+ │ ├── commands/ install, migrate, update, config (and its screens)
192
+ │ └── lib/ AGENTS.md blocks, bindings, gate discovery and the gate script, generation, update steps
193
+ ├── harness/ what is installed into .agents/harness/: roles, templates, schemas, red lines, models
194
+ ├── skills/ what is installed into .agents/skills/ (reins-setup is the plugin's)
195
+ ├── cli/test/, test/e2e/ vitest unit and end-to-end tests
196
+ ├── docs/ design, proposal, roadmap, design conversations, Korean editions
197
+ └── .agents/, .claude/ this repository's own harness — reins is its first user
198
+ ```
74
199
 
75
- `onboard`, `roadmap`, `intent`, `spec`, `implement`, `review`, `test`, `merge`, `audit`, `release`, `retro` —
76
- one per stage, plain text, the same in single and multi mode. Each names the files it creates and when they
77
- are deleted, and the next skill.
200
+ To work on reins: `git clone https://github.com/bluenyang/reins.git`, then `pnpm install`, `pnpm build`, and
201
+ run `node cli/dist/reins.js <command>`; `pnpm check` runs lint, format, typecheck and tests (see
202
+ [CONTRIBUTING.md](CONTRIBUTING.md)).
78
203
 
79
204
  ## Documents
80
205
 
81
206
  - [docs/proposal.md](docs/proposal.md): problems, goal, requirements
82
- - [docs/design.md](docs/design.md): layout, roles, flow, audit, file formats, CLI
207
+ - [docs/design.md](docs/design.md): layout, roles, skills and human checkpoints, file formats, CLI
83
208
  - [docs/ROADMAP.md](docs/ROADMAP.md): versions
84
209
  - [docs/conversation/](docs/conversation/README.md): the maintainer's design conversations, period by period — what was weighed and why, not rules (in Korean only)
85
- - Korean editions: [proposal.ko.md](docs/proposal.ko.md), [design.ko.md](docs/design.ko.md), [ROADMAP.ko.md](docs/ROADMAP.ko.md). Where an English and a Korean edition disagree, the Korean file wins.
210
+ - Korean editions: [README.ko.md](docs/README.ko.md), [proposal.ko.md](docs/proposal.ko.md), [design.ko.md](docs/design.ko.md), [ROADMAP.ko.md](docs/ROADMAP.ko.md). Where an English and a Korean edition disagree, the Korean file wins.
86
211
 
87
212
  ## License
88
213
 
@@ -1,20 +1,25 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { actionsOf, formatGateRow } from '../lib/gate-refresh.js';
3
+ import { actionsOf, reportLines } from '../lib/gate-refresh.js';
4
4
  import { GATE_SCRIPT } from '../lib/gate-script.js';
5
5
  import { BACK, EXIT } from '../lib/prompter.js';
6
- import { configureGates, fileGates, gateRows, REFRESH_LIST, writeRefreshList, } from './configure.js';
6
+ import { configureGates, fileAreas, fileGates, gateRows, REFRESH_LIST, writeRefreshList, } from './configure.js';
7
7
  import { hookTool } from './install.js';
8
8
  const GATES = '.agents/harness/gates.yaml';
9
- /** The gates as the project has them now: name, command, source, in order; and what runs them. */
9
+ /** The gates as the project has them now: name, command, source, areas and stages, in order; the areas; what runs them. */
10
10
  export function formatGates(root) {
11
11
  const path = join(root, GATES);
12
12
  if (!existsSync(path))
13
13
  return ' no gates.yaml — run `reins install`';
14
- const gates = fileGates(readFileSync(path, 'utf8'));
14
+ const text = readFileSync(path, 'utf8');
15
+ const gates = fileGates(text);
15
16
  const lines = gates.length
16
- ? gates.map((g, i) => ` ${String(i + 1).padStart(2)}. ${g.name.padEnd(18)} ${g.cmd} (${g.from ?? 'written by hand'})${g.optional ? ' optional — not in the hooks' : ''}`)
17
+ ? gates.map((g, i) => ` ${String(i + 1).padStart(2)}. ${g.name.padEnd(18)} ${g.cmd} (${g.from ?? 'written by hand'})${g.optional ? ' optional — not in the hooks' : ''} [${g.areas?.length ? `areas: ${g.areas.join(', ')}` : 'always'}${g.on?.length ? `; on: ${g.on.join(', ')}` : ''}]`)
17
18
  : [' no gates'];
19
+ const areas = Object.entries(fileAreas(text));
20
+ lines.push(areas.length
21
+ ? ` areas: ${areas.map(([n, globs]) => `${n} (${globs.join(', ')})`).join('; ')}`
22
+ : ' areas: none — every gate always runs');
18
23
  const tool = hookTool(root);
19
24
  lines.push(` hook tool: ${tool ?? 'none found'}`, ` gate script: ${existsSync(join(root, GATE_SCRIPT)) ? GATE_SCRIPT : 'none (no required gate)'}`);
20
25
  return lines.join('\n');
@@ -31,7 +36,7 @@ export async function refreshGates(root, prompter) {
31
36
  return 'done';
32
37
  }
33
38
  writeRefreshList(root, rows);
34
- prompter.note([...rows.map(formatGateRow), `(the same list: ${REFRESH_LIST})`].join('\n'));
39
+ prompter.note([...reportLines(rows), `(the same list: ${REFRESH_LIST})`].join('\n'));
35
40
  const options = rows.flatMap((r) => actionsOf(r).map((a) => ({
36
41
  value: `${a}:${r.name}`,
37
42
  label: `${a} ${r.name}`,
@@ -75,6 +80,7 @@ export async function gatesScreen(root, prompter) {
75
80
  hint: 'find the gates again, see each state, pick what to apply',
76
81
  },
77
82
  { value: 'add', label: 'add subdirectory proposals' },
83
+ { value: 'areas', label: 'areas', hint: 'pick the areas a gate runs for (none: always)' },
78
84
  ],
79
85
  });
80
86
  if (v === EXIT)
@@ -86,6 +92,11 @@ export async function gatesScreen(root, prompter) {
86
92
  return 'exit';
87
93
  continue;
88
94
  }
95
+ if (v === 'areas') {
96
+ if ((await areasScreen(root, prompter)) === 'exit')
97
+ return 'exit';
98
+ continue;
99
+ }
89
100
  const { available } = configureGates({ cwd: root });
90
101
  if (available.length === 0) {
91
102
  prompter.note('no subdirectory proposals left');
@@ -104,3 +115,50 @@ export async function gatesScreen(root, prompter) {
104
115
  prompter.note(r.refused ? `not changed: ${r.refused}` : `gates: added ${r.added.join(', ')}`);
105
116
  }
106
117
  }
118
+ /** Pick a gate, then the areas it runs for (spec 025 R-5); nothing picked: it always runs. */
119
+ async function areasScreen(root, prompter) {
120
+ const path = join(root, GATES);
121
+ if (!existsSync(path)) {
122
+ prompter.note('no gates.yaml — run `reins install`');
123
+ return 'done';
124
+ }
125
+ const text = readFileSync(path, 'utf8');
126
+ const gates = fileGates(text);
127
+ const areas = fileAreas(text);
128
+ if (!gates.length || !Object.keys(areas).length) {
129
+ prompter.note(gates.length
130
+ ? 'no areas in gates.yaml — define one with `reins config gates --define-area <name>=<glob,…>`'
131
+ : 'no gates');
132
+ return 'done';
133
+ }
134
+ const gate = await prompter.select({
135
+ message: 'Which gate',
136
+ options: gates.map((g) => ({
137
+ value: g.name,
138
+ label: g.name,
139
+ hint: g.areas?.length ? `areas: ${g.areas.join(', ')}` : 'always',
140
+ })),
141
+ });
142
+ if (gate === EXIT)
143
+ return 'exit';
144
+ if (gate === BACK)
145
+ return 'done';
146
+ const picked = await prompter.multiselect({
147
+ message: `Areas ${gate} runs for (none: always)`,
148
+ options: Object.entries(areas).map(([n, globs]) => ({
149
+ value: n,
150
+ label: n,
151
+ hint: globs.join(', '),
152
+ })),
153
+ initial: gates.find((g) => g.name === gate)?.areas ?? [],
154
+ });
155
+ if (picked === EXIT)
156
+ return 'exit';
157
+ if (picked === BACK)
158
+ return 'done';
159
+ const r = configureGates({ cwd: root, area: [`${gate}=${picked.join(',')}`] });
160
+ prompter.note(r.refused
161
+ ? `not changed: ${r.refused}`
162
+ : `gates: ${r.set?.join('; ')} — gates.yaml written; commit it on its own`);
163
+ return 'done';
164
+ }
@@ -214,6 +214,25 @@ async function groupScreen(o, group, spec, write, mode) {
214
214
  await write({ set: [`${group}.${role}=${b.vendor}:${b.model}`] }, `${group}.${role} → ${show(b)}`);
215
215
  return 'back';
216
216
  }
217
+ /**
218
+ * The `audit` item of `reins config` (design §9): the recommended model for an audit a person asks for —
219
+ * the auditor group of the team file. Nothing makes the audit run; the delegation table names the model.
220
+ */
221
+ export async function auditScreen(o) {
222
+ const spec = readTeam(o.root).doc?.groups?.auditor;
223
+ const write = async (opts, label) => {
224
+ const r = await configureBindings({ cwd: o.root, ...opts });
225
+ if (r.refused)
226
+ o.prompter.note(`not changed: ${r.refused}`);
227
+ else if (r.changed.length === 0)
228
+ o.prompter.note(`${label}: already so — nothing changed`);
229
+ else
230
+ o.prompter.note(`${label}: written to .agents/harness/bindings.yaml and the delegation table — commit them`);
231
+ if (r.localDelegation)
232
+ o.prompter.note(LOCAL_DELEGATION_NOTE(r.localDelegation));
233
+ };
234
+ return groupScreen(o, 'auditor', spec, write);
235
+ }
217
236
  /**
218
237
  * The fallback of a group's model or of a role's own model (design §5): pick a model, or clear it. Only a
219
238
  * place that has a model in the file being written can take one; `configureBindings` says so otherwise.
@@ -1,18 +1,25 @@
1
1
  import { applyLocalForcePush, FORCE_WITH_LEASE_QUESTION, recordedForceWithLease, } from '../lib/local-settings.js';
2
2
  import { gatesScreen } from './config-gates.js';
3
- import { effectiveBindings, resolveRoles } from '../lib/bindings.js';
3
+ import { auditBinding, effectiveBindings, readTeam, resolveRoles, } from '../lib/bindings.js';
4
+ import { profileOf } from '../lib/profile.js';
4
5
  import { newModelCache, vendors } from '../lib/detect.js';
5
6
  import { repoRoot } from '../lib/git.js';
6
- import { groupLine, modelsScreen } from './config-models.js';
7
+ import { auditScreen, groupLine, modelsScreen } from './config-models.js';
7
8
  import { configureBindings } from './configure.js';
8
9
  import { LOCAL_DELEGATION_NOTE } from '../lib/local-delegation.js';
9
10
  import { BACK, clackPrompter, EXIT, isInteractive } from '../lib/prompter.js';
10
11
  export const CONFIG_HINT = 'change with: reins config bindings --set <group|group.role>=<model> [--fallback <group|group.role>=<model|none>] [--local] (see: reins config bindings --help)';
11
- /** The effective settings as text: mode, audit, each role that is on. */
12
+ /** The recommended audit model as a label: the auditor's, else a fresh run of the PM's model. */
13
+ const auditLabel = (doc) => {
14
+ const a = doc ? auditBinding(doc) : undefined;
15
+ return a ? `${a.vendor} ${a.model}` : "the PM's model (a fresh run)";
16
+ };
17
+ /** The effective settings as text: mode, profile, the recommended audit model, each role that is on. */
12
18
  export function formatBindings(doc) {
13
19
  const lines = [
14
20
  ` mode: ${doc.mode ?? 'single'}`,
15
- ` audit: ${doc.audit?.required === false ? 'off (switched off by the user)' : 'required every version'}`,
21
+ ` profile: ${profileOf(doc)}`,
22
+ ` audit (when a person asks): ${auditLabel(doc)}`,
16
23
  ' PM: the model in the conversation',
17
24
  ];
18
25
  const on = resolveRoles(doc).filter((r) => r.on);
@@ -63,9 +70,11 @@ export async function runConfig(o = {}) {
63
70
  { value: 'models', label: 'models and roles configuration' },
64
71
  { value: 'tools', label: 'agent tools', hint: 'detect again, use or not' },
65
72
  { value: 'mode', label: `mode: ${doc?.mode ?? 'single'}` },
73
+ { value: 'profile', label: `profile: ${profileOf(readTeam(root).doc)}` },
66
74
  {
67
75
  value: 'audit',
68
- label: `audit: ${doc?.audit?.required === false ? 'off' : 'required'}`,
76
+ label: `audit: ${auditLabel(doc)}`,
77
+ hint: 'the recommended model for an audit a person asks for',
69
78
  },
70
79
  { value: 'gates', label: 'gates', hint: 'the project checks: see them, find them again' },
71
80
  {
@@ -147,18 +156,33 @@ export async function runConfig(o = {}) {
147
156
  prompter.note(LOCAL_DELEGATION_NOTE(r.localDelegation));
148
157
  continue;
149
158
  }
150
- const off = doc?.audit?.required !== false;
151
- if (off) {
152
- const sure = await prompter.confirm({
153
- message: 'Switch the per-version audit off? Nothing will check that the flow was followed.',
154
- initial: false,
159
+ if (v === 'profile') {
160
+ const current = profileOf(readTeam(root).doc);
161
+ const p = await prompter.select({
162
+ message: 'Profile (the team’s: bindings.yaml)',
163
+ initial: current,
164
+ options: [
165
+ { value: 'light', label: 'light', hint: 'skill bodies only (default)' },
166
+ {
167
+ value: 'full',
168
+ label: 'full',
169
+ hint: 'adds step-by-step references, role files and rs-* agents — for smaller models',
170
+ },
171
+ ],
155
172
  });
156
- if (sure !== true)
157
- continue;
173
+ if (typeof p === 'symbol')
174
+ return 0;
175
+ const r = await configureBindings({ cwd: root, profile: p });
176
+ prompter.note(r.refused
177
+ ? `not changed: ${r.refused}`
178
+ : r.changed.includes('profile')
179
+ ? `profile ${p}: the skills, role files and generated files follow — commit them`
180
+ : `profile ${p}: already so`);
181
+ continue;
158
182
  }
159
- const r = await configureBindings({ cwd: root, audit: off ? 'off' : 'on' });
160
- prompter.note(r.refused ? `not changed: ${r.refused}` : `audit ${off ? 'off' : 'required'}`);
161
- if (r.localDelegation)
162
- prompter.note(LOCAL_DELEGATION_NOTE(r.localDelegation));
183
+ // the recommended audit model: the auditor group of the team file (design §9)
184
+ const r = await auditScreen({ root, prompter, detectVendors: detect, modelCache });
185
+ if (r === 'exit')
186
+ return 0;
163
187
  }
164
188
  }