@bluenyang/reins 0.3.4-rc.1 → 0.3.4

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/README.md CHANGED
@@ -15,7 +15,7 @@ knowledge lost in gitignored space, copies that drift apart. The full list is in
15
15
 
16
16
  ## Status
17
17
 
18
- **0.3.4-rc.1 is the release candidate** (intent 024): `npx @bluenyang/reins@0.3.4-rc.1`. **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).
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).
19
19
 
20
20
  ## How it works
21
21
 
@@ -92,6 +92,73 @@ export function runsGateScript(text, stage) {
92
92
  .map((l) => l.trim().replace(/\s+/g, ' '))
93
93
  .some((l) => !l.startsWith('#') && paths.some((p) => l === `sh ${p} ${stage}`));
94
94
  }
95
+ /** The parsed lefthook or pre-commit configuration files of the root; unreadable ones are left out. */
96
+ function hookConfigs(root, tool) {
97
+ const files = tool === 'lefthook'
98
+ ? ['lefthook.yml', 'lefthook.yaml', '.lefthook.yml', '.lefthook.yaml', 'lefthook-local.yml']
99
+ : ['.pre-commit-config.yaml'];
100
+ const out = [];
101
+ for (const f of files.filter((x) => existsSync(join(root, x))))
102
+ try {
103
+ out.push(parse(readFileSync(join(root, f), 'utf8')));
104
+ }
105
+ catch {
106
+ // unreadable: nothing in it counts, so the line is proposed
107
+ }
108
+ return out;
109
+ }
110
+ const obj = (v) => v && typeof v === 'object' && !Array.isArray(v) ? v : null;
111
+ /** Whether a command value is the gate script for `stage`: `sh <path> <stage>`, the path quoted or with `./`. */
112
+ export function isGateCommand(cmd, stage) {
113
+ if (typeof cmd !== 'string')
114
+ return false;
115
+ // only horizontal space is evened out: a newline is a command boundary for the shell (review 10)
116
+ const c = cmd.trim().replace(/[ \t]+/g, ' ');
117
+ return new RegExp(`^sh (['"]?)(\\./)?\\.agents/harness/run-gates\\.sh\\1 ${stage}$`).test(c);
118
+ }
119
+ /** The `run:` values lefthook runs at `stage`: its `commands`, `jobs` (and job `group`s) and `scripts`' runners. */
120
+ function lefthookRuns(doc, stage) {
121
+ const hook = obj(obj(doc)?.[stage]);
122
+ if (!hook)
123
+ return [];
124
+ const runs = [];
125
+ for (const c of Object.values(obj(hook['commands']) ?? {}))
126
+ runs.push(obj(c)?.['run']);
127
+ const jobs = (list) => {
128
+ if (!Array.isArray(list))
129
+ return;
130
+ for (const j of list) {
131
+ runs.push(obj(j)?.['run']);
132
+ jobs(obj(obj(j)?.['group'])?.['jobs']);
133
+ }
134
+ };
135
+ jobs(hook['jobs']);
136
+ return runs;
137
+ }
138
+ const PRE_COMMIT_STAGE = { commit: 'pre-commit', push: 'pre-push' };
139
+ /** The `entry` values pre-commit runs at `stage`: each hook's `stages`, else `default_stages`, else every stage. */
140
+ function preCommitEntries(doc, stage) {
141
+ const d = obj(doc);
142
+ const defaults = Array.isArray(d?.['default_stages']) ? d['default_stages'] : null;
143
+ const out = [];
144
+ for (const repo of Array.isArray(d?.['repos']) ? d['repos'] : [])
145
+ for (const h of Array.isArray(obj(repo)?.['hooks']) ? obj(repo)['hooks'] : []) {
146
+ const hook = obj(h);
147
+ const stages = Array.isArray(hook?.['stages']) ? hook['stages'] : defaults;
148
+ const runs = stages === null || stages.some((x) => (PRE_COMMIT_STAGE[String(x)] ?? String(x)) === stage);
149
+ if (runs)
150
+ out.push(hook?.['entry']);
151
+ }
152
+ return out;
153
+ }
154
+ /**
155
+ * Whether the lefthook or pre-commit configuration already runs the gate script for `stage` (A-20): a
156
+ * parsed `run:` (lefthook, under that hook) or `entry:` (pre-commit, for a hook that runs at that stage)
157
+ * whose value is the gate command. Comments, names and other fields never count.
158
+ */
159
+ export function configRunsGateScript(docs, tool, stage) {
160
+ return docs.some((d) => (tool === 'lefthook' ? lefthookRuns(d, stage) : preCommitEntries(d, stage)).some((c) => isGateCommand(c, stage)));
161
+ }
95
162
  /** A command that runs reins: what 0.x put into hooks and settings. */
96
163
  export const RUNS_REINS = /@bluenyang\/reins|reins\.js\b|(^|[\s;&|])reins\s+(check|hook|gate|status)\b/;
97
164
  /** `reins install` (design §9): place the harness, ask, propose hooks, mark onboarding. Never writes history. */
@@ -333,10 +400,15 @@ export async function runInstall(o) {
333
400
  if (missing.length && !addHooks)
334
401
  notes.push(`hook proposal (husky): add \`${hookLine('pre-commit')}\` to .husky/pre-commit and \`${hookLine('pre-push')}\` to .husky/pre-push; re-run with --hooks to add them`);
335
402
  }
336
- else if (gated && tool === 'lefthook')
337
- notes.push(`hook proposal (lefthook): under \`pre-commit: commands:\` add \`gates: { run: ${hookLine('pre-commit')} }\`, and the same under \`pre-push:\` with \`${hookLine('pre-push')}\` (reins proposes lefthook lines only; add them to its config yourself)`);
338
- else if (gated && tool === 'pre-commit')
339
- notes.push(`hook proposal (pre-commit): under \`repos:\` add \`- repo: local\` with a hook \`{ id: gates, name: project gates, entry: ${hookLine('pre-commit')}, language: system, pass_filenames: false }\`, and one with \`stages: [pre-push]\` and \`${hookLine('pre-push')}\` (reins proposes pre-commit lines only; add them to its config yourself)`);
403
+ else if (gated && (tool === 'lefthook' || tool === 'pre-commit')) {
404
+ // a config that already runs the gate script for a stage is not proposed it again (0.3.4-rc.2, A-20)
405
+ const docs = hookConfigs(root, tool);
406
+ const missing = HOOK_STAGES.filter((s) => !configRunsGateScript(docs, tool, s));
407
+ if (missing.length && tool === 'lefthook')
408
+ notes.push(`hook proposal (lefthook): ${missing.map((s) => `under \`${s}: commands:\` add \`gates: { run: ${hookLine(s)} }\``).join(', and ')} (reins proposes lefthook lines only; add them to its config yourself)`);
409
+ else if (missing.length)
410
+ notes.push(`hook proposal (pre-commit): under \`repos:\` add \`- repo: local\` with ${missing.map((s) => `a hook \`{ id: gates${s === 'pre-push' ? '-push' : ''}, name: project gates, entry: ${hookLine(s)}, language: system, pass_filenames: false, stages: [${s}] }\``).join(' and ')} (reins proposes pre-commit lines only; add them to its config yourself)`);
411
+ }
340
412
  else if (gated)
341
413
  notes.push(`no hook tool found — the PM asks which one to use during onboarding; whichever it is runs \`${hookLine('pre-commit')}\` and \`${hookLine('pre-push')}\``);
342
414
  // 6. AGENTS.md: managed blocks, the onboarding note; CLAUDE.md pointer
package/docs/README.ko.md CHANGED
@@ -8,7 +8,7 @@ BlueNyang과 Team Croffle의 저장소 열두 곳이 같은 하네스 계통을
8
8
 
9
9
  ## 상태
10
10
 
11
- **0.3.4-rc.1이 릴리스 후보입니다**(intent 024): `npx @bluenyang/reins@0.3.4-rc.1`. **0.3.3이 최신 릴리스입니다**(intent 019~023): `npx @bluenyang/reins install`. 0.2.0까지는 스킬과 훅이 작업 중에 `npx @bluenyang/reins`를 불렀습니다. 0.3은 그것을 없애고, `reins update`가 0.1.x·0.2.0 설치를 옮깁니다. 버전마다 바뀐 것은 [CHANGELOG.md](../CHANGELOG.md)에, 앞으로의 계획은 [로드맵](ROADMAP.ko.md)에 있습니다.
11
+ **0.3.4-rc.2가 릴리스 후보입니다**(intent 024): `npx @bluenyang/reins@0.3.4-rc.2`. **0.3.3이 최신 릴리스입니다**(intent 019~023): `npx @bluenyang/reins install`. 0.2.0까지는 스킬과 훅이 작업 중에 `npx @bluenyang/reins`를 불렀습니다. 0.3은 그것을 없애고, `reins update`가 0.1.x·0.2.0 설치를 옮깁니다. 버전마다 바뀐 것은 [CHANGELOG.md](../CHANGELOG.md)에, 앞으로의 계획은 [로드맵](ROADMAP.ko.md)에 있습니다.
12
12
 
13
13
  ## 동작 방식
14
14
 
@@ -7,7 +7,7 @@ Read by `reins update`: it lists the entries newer than a project's pinned versi
7
7
  - `reins config gates --refresh` no longer reports new, changed or gone. It shows every gate and candidate with its state — applied, applied (written by hand / source not found / another command), not applied, not applied (already runs) — and leaves the same list in `.loctx/gates-refresh.md`, so the user picks and an agent edits `gates.yaml` in a commit of its own. reins never calls a gate gone and never removes one by itself; `--apply all` only adds, removing and replacing take a name.
8
8
  - `.agents/harness/run-gates.sh` reads `gates.yaml` when it runs (POSIX `awk`, the shape reins writes) instead of holding the commands, so editing `gates.yaml` is enough. Another shape, or a missing `gates.yaml`, stops the run with exit 2 before anything runs. The script is written even without a required gate; `config gates` no longer rewrites it. `gates.yaml` is the project's file, not a generated one.
9
9
  - Already installed repositories: run `reins config gates --refresh` once after `reins update` to see the candidates the new discovery finds; `update` does not change `gates.yaml`.
10
- - husky: a hook file that already runs the gate script outside a reins block is neither proposed nor given a block again.
10
+ - husky: a hook file that already runs the gate script outside a reins block is neither proposed nor given a block again. lefthook and pre-commit (rc.2): a stage whose configuration already runs the gate script is not proposed again.
11
11
  - Force push (revision 1): the team `.claude/settings.json` no longer denies `--force-with-lease` (a team deny cannot be lifted for one person, and a glob cannot tell a work branch from the default branch). `install` and `update` ask on a terminal whether to deny it to the agents on this machine; the answer is kept in `.loctx/bindings.local.yaml` and written to the personal `.claude/settings.local.json` (`Bash(git push --force-with-lease)`, `Bash(git push --force-with-lease *)`); `reins config` changes it. Without a terminal it is denied and the next terminal run asks. `--force`, `-f`, a `+` refspec and hook bypass, each also after other arguments, stay denied for everyone. The `merge` skill says to push a work branch naming it, never the default branch or a tag; the stop block names force push to the default branch or a tag.
12
12
  - Skills (0.3.3 retro): open `.loctx/delegation.local.md` before anything else when work starts (`intent`, `implement`, the delegation block); `git diff --stat` at the head of a review request, checked against the diff received (`review`); keep the request to another model and its final answer in `.loctx/reports/<version>/` as they came (every skill that calls one); compare the two language editions again after the last change (`review`, `test`); read both roadmaps and the review records when revising a spec (`spec`); rate each violation's severity and put independent opinions beside a high one's remedy (`audit`).
13
13
  - `update` lists these entries under a heading per version.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluenyang/reins",
3
- "version": "0.3.4-rc.1",
3
+ "version": "0.3.4",
4
4
  "description": "Installs, migrates and updates an agent harness (harness → loop → graph) that keeps coding agents inside their permitted roles.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,10 +15,10 @@ If either still starts with `${` (unsubstituted — this copy lives in a project
15
15
  1. **Look.** Is there an `.agents/harness/` (reins installed), an `.ai/` workspace, or an older harness
16
16
  (`.claude/commands/`, many skills)? Say which.
17
17
  2. **Show the user the command** for their terminal, with the version pinned to this skill's release:
18
- - nothing installed: `npx @bluenyang/reins@0.3.4-rc.1 install --mode <mode>`
19
- - an older harness or `.ai/`: `npx @bluenyang/reins@0.3.4-rc.1 migrate --dry-run`, then without `--dry-run`
20
- - reins already installed: `npx @bluenyang/reins@0.3.4-rc.1 update`
21
- - to change models, the mode or the audit later: `npx @bluenyang/reins@0.3.4-rc.1 config` (the user can run `reins config`)
18
+ - nothing installed: `npx @bluenyang/reins@0.3.4 install --mode <mode>`
19
+ - an older harness or `.ai/`: `npx @bluenyang/reins@0.3.4 migrate --dry-run`, then without `--dry-run`
20
+ - reins already installed: `npx @bluenyang/reins@0.3.4 update`
21
+ - to change models, the mode or the audit later: `npx @bluenyang/reins@0.3.4 config` (the user can run `reins config`)
22
22
  Run it yourself only when the user asks you to, and only that command.
23
23
  3. **Explain what follows.** reins writes AGENTS.md blocks with an onboarding note; the next conversation starts
24
24
  with the `onboard` skill, which reads the project, asks the user, and writes AGENTS.md's project sections.