farna-bootstrapper 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,73 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0.0, a minor
7
7
  release may contain a breaking change; every change of that kind is listed under **Changed**.
8
8
 
9
+ ## [0.1.3] - 2026-11-24
10
+
11
+ ### Added
12
+
13
+ - **Self-dogfood.** This repository now generates its own configuration from `.farna/`:
14
+ `.claude/agents/maintainer.md` and `.farna/lock.json` are generated and committed, and CI runs
15
+ `check`, so a source change that was not regenerated, or a generated file edited by hand, fails
16
+ the build. The dogfood covers the `claudecode` target in agent mode only.
17
+ - **A macOS CI job.** CI runs a second job on macOS with every step identical to the Linux job, so
18
+ the same install, build, test, audit and `check` steps are proven on both platforms.
19
+ - **Weekly renderer-pin tracking.** `.github/workflows/renderer-pin.yml` compares the pinned
20
+ renderer with the published npm version once a week, opens one tracking issue when the pin is
21
+ behind, comments on that issue weekly while it stays behind, and closes it when the pin catches
22
+ up. It never bumps anything. A new `## Absorbing a renderer upgrade` runbook in
23
+ [CONTRIBUTING.md](CONTRIBUTING.md#absorbing-a-renderer-upgrade) documents the manual absorb
24
+ procedure.
25
+ - **A roadmap.** [ROADMAP.md](ROADMAP.md) records what is shipped, what is next and what is
26
+ deliberately out of scope, and the README status section links to it.
27
+
28
+ ### Changed
29
+
30
+ - **Renderer pin moved to `rulesync` 43.13.0** (from `43.11.0`), absorbed in two explained steps.
31
+ An OpenCode agent file whose description contains a comma now writes it as a plain YAML scalar
32
+ instead of a single-quoted one: the renderer replaced its frontmatter serialiser (`gray-matter`'s
33
+ YAML 1.1 writer) with YAML 1.2, where a comma is plain-safe. The pin also carried the 43.12.0
34
+ change: a `session-start` hook runs with `context: true`, so its stdout is captured as session
35
+ context while its stderr streams to the host, and the plugin's run helper returns its result on
36
+ success. The `claudecode` golden is byte-identical. Because the agent files and the plugin are
37
+ managed output, `check` reports drift on an existing project until the next `generate`.
38
+
39
+ ### Fixed
40
+
41
+ - **An emitted OpenCode hook matcher now fires.** The generated hooks plugin writes the tool ids the
42
+ harness reports, lowercased and anchored, instead of the canonical names: `Edit|Write` is written
43
+ as `^(?:edit|write)$`, and `Bash` as `^(?:bash)$` on V1 and `^(?:shell)$` on V2. OpenCode reports
44
+ those lowercase ids, so a declared matcher matches a tool call instead of silently never
45
+ matching. The containment gate applies the same translation before comparing.
46
+
47
+ ## [0.1.2] - 2026-11-23
48
+
49
+ ### Added
50
+
51
+ - **`doctor`.** Validates a `.farna` source without rendering or writing: the config schema, persona
52
+ and resource references, `extends` cycles, the model map, target support, permission categories
53
+ and patterns, secret references, path and symlink safety, and the profile-mode invariants. It
54
+ reuses the same config loader, source loader and resolver as `generate` and `check`, so it cannot
55
+ accept a source they refuse. A failure carries the same typed code and exit status; `--json`
56
+ emits one object, and the human report lists every check that ran, every resolved persona and
57
+ resource with its source path, and every warning.
58
+ - **`report`.** Prints the measured capability matrix for all three supported targets, with two
59
+ emissions per capability (per persona and workspace level) and a per-key permission table. The
60
+ vocabulary is `native`, `emulated`, `dropped` and `unknown`; `unknown` renders as `[?] not
61
+ measured` and is never a tick. `--json` emits the same claim as data. The command reads no source
62
+ tree and writes nothing.
63
+ - **A structural matrix guard.** `verifySnapshot` refuses (F010) a snapshot measured against a
64
+ different renderer, a missing supported-target row, or an `unknown` cell on a promised target.
65
+
66
+ ### Changed
67
+
68
+ - The README, `CONTRIBUTING.md` and `--help` describe the five-command surface and the capability
69
+ report.
70
+
71
+ ### Fixed
72
+
73
+ - The `CONTRIBUTING.md` release example used `v0.1.0` as its tag; it now uses the current release
74
+ version.
75
+
9
76
  ## [0.1.1] - 2026-11-22
10
77
 
11
78
  ### Added
@@ -103,5 +170,7 @@ output still matches the source.
103
170
  runner does not grant), the POSIX mode assertions, the FIFO cases and the install-layout suite are
104
171
  skipped on Windows; CI runs them on Linux.
105
172
 
173
+ [0.1.3]: https://github.com/farnalabs/farna-bootstrapper/compare/v0.1.2...v0.1.3
174
+ [0.1.2]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.2
106
175
  [0.1.1]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.1
107
176
  [0.1.0]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.0
package/README.md CHANGED
@@ -16,6 +16,12 @@ and their resources once, under `.farna/`, and it renders the files a harness re
16
16
  - **`check`** renders the same source into a temporary directory and compares it with the
17
17
  repository. Exit `0` when identical, `1` when anything drifted. It never writes.
18
18
  - **`init`** creates the source root and the ignore/attribute lines generated output needs.
19
+ - **`doctor`** validates the source without rendering or writing: schema, references, `extends`
20
+ cycles, the model map, target support, permissions, secret references, paths and profile-mode
21
+ invariants. It exits `0` when the source is valid; when it is not, it reports the loader's own
22
+ typed code and exits non-zero.
23
+ - **`report`** prints the measured capability matrix for every supported target, in a human table
24
+ or as one JSON object. It reads no source and writes nothing.
19
25
 
20
26
  It is a compiler in the useful sense, not a loader:
21
27
 
@@ -44,14 +50,15 @@ It is a compiler in the useful sense, not a loader:
44
50
 
45
51
  ## Status
46
52
 
47
- This is the first public release. It implements three commands (`init`, `generate` and
48
- `check`), three targets (`claudecode`, `opencode` for OpenCode 2.x and `opencodev1` for OpenCode
49
- 1.x), agent mode plus OpenCode profile mode, six resource kinds (`rule`, `permission`, `mcp`,
50
- `skill`, `command` and `hook`) with a model class, and composition with one base persona per
53
+ This is the first public release. It implements five commands (`init`, `doctor`, `report`,
54
+ `generate` and `check`), three targets (`claudecode`, `opencode` for OpenCode 2.x and `opencodev1`
55
+ for OpenCode 1.x), agent mode plus OpenCode profile mode, six resource kinds (`rule`, `permission`,
56
+ `mcp`, `skill`, `command` and `hook`) with a model class, and composition with one base persona per
51
57
  composed persona. Exactly one configured target is rendered per run. Everything else is
52
58
  deliberately deferred; see
53
59
  [What this slice does not do](#what-this-slice-does-not-do) and
54
60
  [Residual risks and known gaps](#residual-risks-and-known-gaps).
61
+ See [ROADMAP.md](ROADMAP.md) for what is shipped, what is next and what is deliberately out of scope.
55
62
 
56
63
  ## Quickstart
57
64
 
@@ -68,8 +75,10 @@ npx farna-bootstrapper init
68
75
  one file per resource; [Use](#use) has a complete pair. Then:
69
76
 
70
77
  ```sh
78
+ npx farna-bootstrapper doctor # validate the source; write nothing
71
79
  npx farna-bootstrapper generate # render the target and write .farna/lock.json
72
80
  npx farna-bootstrapper check # exit 0 when the tree matches a fresh render
81
+ npx farna-bootstrapper report # print the measured capability matrix
73
82
  ```
74
83
 
75
84
  Commit `.farna/` and the generated files. Running `check` in CI is the drift gate: a hand edit, a
@@ -78,6 +87,7 @@ stale render, or a source change that was never regenerated exits `1` and names
78
87
  ## The loop
79
88
 
80
89
  1. You declare personas and their resources under `.farna/`, and select one target in the config.
90
+ `farna-bootstrapper doctor` validates that declaration without rendering it.
81
91
  2. `farna-bootstrapper generate` renders that target's artefacts and records what it wrote in
82
92
  `.farna/lock.json`. Claude Code gets one whole file per persona under `.claude/agents/`; OpenCode
83
93
  in agent mode gets one whole file per persona under `.opencode/agents/` and no workspace file;
@@ -301,6 +311,8 @@ Write the smallest change that satisfies the ticket.
301
311
  Then run:
302
312
 
303
313
  ```sh
314
+ farna-bootstrapper doctor # validate the source; render and write nothing
315
+ farna-bootstrapper report # print the measured capability matrix
304
316
  farna-bootstrapper generate # write the agent files and the lockfile
305
317
  farna-bootstrapper generate --dry-run # print the plan, write nothing
306
318
  farna-bootstrapper generate --adopt # take ownership of existing outputs (see below)
@@ -316,6 +328,8 @@ The complete flag surface:
316
328
  | all | `--json` | emit one JSON object on stdout and suppress the human report; a typed failure also writes its one human line to stderr |
317
329
  | all | `-v, --version`, `-h, --help` | print the compiled-in version or usage; neither needs the renderer |
318
330
  | `init` | `--json` | the created/updated paths and the next step |
331
+ | `doctor` | `--json` | every validation that ran, every resolved persona and resource, and the warnings |
332
+ | `report` | `--json` | the measured capability matrix for every supported target |
319
333
  | `generate` | `--dry-run` | print the plan and write nothing; `would-write` and `unchanged` are counted separately |
320
334
  | `generate` | `--adopt` | take ownership of every existing planned managed output; required when the lockfile is missing |
321
335
  | `generate` | `--persona <id>` | run profile mode as that persona; wins over `targets.<target>.active` and is not written back |
@@ -336,6 +350,13 @@ working tree, so `unchanged` and
336
350
  counts the `would-write` files, not the size of the plan: a tree that already matches reports
337
351
  `would write 0 file(s), N unchanged`.
338
352
 
353
+ `doctor` adds `target`, `mode`, `activePersona`, `notLive`, `configPath`, `counts`, `checks`,
354
+ `personas` and `warnings`; each persona carries its `chain`, `mode`, `model` and every resolved
355
+ resource with its `path`, `fromPersona` and `rank`. `report` adds `renderer` and `targets[]`, where
356
+ each target carries `id`, `status`, `agentReach`, `capabilities` (the seven cells, each with
357
+ `agent`, `workspace`, `basis`, `testId` and `consequence`) and `permissionKeys` (each with
358
+ `emission`, `code` and `consequence`).
359
+
339
360
  A persona's rule text is joined into the body of its subagent, in canonical rule-id order, under a
340
361
  `## displayName` heading. The rule body itself is never re-wrapped or re-indented. There is no
341
362
  shared root rules file: the per-agent body is the only rule surface, so one persona's rules never
@@ -377,26 +398,51 @@ writing any of them.
377
398
 
378
399
  ### Capability matrix
379
400
 
380
- What this release actually carries. A cell is either **native** (written into the emitted
381
- artefact), **profile only** (written at the workspace level, so it requires profile mode and exactly
382
- one live persona), **not carried** (refused with `F001`, naming the reference; nothing is written),
383
- or **unknown** (the harness behaviour is not verified by this release, so it is never claimed as a
384
- tick).
401
+ What this release actually carries, as measured by the tests that pin the emitted bytes and the
402
+ refusals. A cell has one of four values, and each has exactly one rendering in the `report` command:
403
+
404
+ | Value | Meaning | Glyph | Never |
405
+ |---|---|---|---|
406
+ | **native** | written into the emitted artefact | `[x]` | a claim that the harness obeys it at runtime |
407
+ | **emulated** | carried under a different category whose effect differs | `[~]` | counted as carried for a boundary capability |
408
+ | **dropped** | the target receives nothing; a declared reference is refused (`F001`) or reported (`W101`) | `[ ]` | silent |
409
+ | **unknown** | not measured in this release | `[?] not measured` | rendered as a tick |
385
410
 
386
- | Capability | Claude Code, per agent | Claude Code, workspace | OpenCode 2.x, per agent | OpenCode 2.x, workspace | OpenCode 1.x, per agent | OpenCode 1.x, workspace |
411
+ `farna-bootstrapper report` prints this matrix for all three supported targets, as a human table or
412
+ as one JSON object with `--json`. It reads no source and writes nothing; the same data is what this
413
+ section documents.
414
+
415
+ | Capability | claudecode, agent | claudecode, workspace | opencode, agent | opencode, workspace | opencodev1, agent | opencodev1, workspace |
387
416
  |---|---|---|---|---|---|---|
388
- | `rule` | native | — | native | — | native | — |
389
- | `model` | native | — | native | — | native | — |
390
- | `mode` (`primary`/`subagent`/`all`) | not carried (`W117`) | — | native | — | native | — |
391
- | `permission` | native (allow-list via opt-in) | — | native (deny-list; `write` folds into `edit`, W112) | — | native (per-tool map; `write` folds into `edit`, W112) | — |
392
- | `mcp` | not carried | — | not carried in agent mode | profile only (`mcp.servers`) | not carried in agent mode | profile only (flat `mcp.<name>`) |
393
- | `skill` | not carried | — | not carried in agent mode | profile only | not carried in agent mode | profile only |
394
- | `command` | not carried | — | not carried in agent mode | profile only | not carried in agent mode | profile only |
395
- | `hook` | not carried | — | not carried in agent mode | profile only; `{ id, setup }` plugin, representable events only (W101) | not carried in agent mode | profile only; `RulesyncHooksPlugin`, representable events only (W101) |
396
- | `temperature` | not carried (not authored) | — | not carried (not authored) | — | not carried (not authored) | — |
397
- | `tools` (per-agent) | native (allow-list via opt-in) | — | not carried (an OpenCode allow-list cannot be expressed) | — | not carried (an OpenCode allow-list cannot be expressed) | — |
398
-
399
- The OpenCode V1 columns record these differences from V2, each verified against rulesync 43.11.0
417
+ | `rule` | native | dropped [^claude-workspace] | native | native | native | native |
418
+ | `model` | native | dropped [^claude-workspace] | native | native | native | native |
419
+ | `permission` | native | dropped [^claude-workspace] | native | native | native | native |
420
+ | `skill` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
421
+ | `command` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
422
+ | `mcp` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
423
+ | `hook` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
424
+
425
+ [^claude-workspace]: Profile mode is not supported on `claudecode` in this release, so no
426
+ workspace-level output is written for any capability.
427
+
428
+ The `permission` capability is one cell but a per-key measurement. `report` prints the key table
429
+ too, because the cell alone would hide where a key widens or refuses:
430
+
431
+ | Permission key | claudecode | opencode | opencodev1 |
432
+ |---|---|---|---|
433
+ | `read`, `edit`, `shell`, `task` | native | native | native |
434
+ | `write` | native | emulated (`W112`) | emulated (`W112`) |
435
+ | `network` | dropped (`F011`) | dropped (`F011`) | dropped (`F011`) |
436
+ | `mcp` (bare category) | dropped (`F011`) | not measured, refused (`F011`) | not measured, refused (`F011`) |
437
+
438
+ `write` on OpenCode is emulated, not native: OpenCode has no write category, so the rule lands as
439
+ `edit`, and an `allow` then also permits modifying existing files. `W112_PERMISSION_LOSSY` at high
440
+ severity names the widening, and a declaration is never silently weakened. A bare `network` or
441
+ `mcp` category has no mapping on any target, so it is refused (`F011`) rather than written as an
442
+ inert rule; the bare `mcp` category on OpenCode is recorded as **not measured** and is never claimed
443
+ as carried.
444
+
445
+ The OpenCode V1 columns record these differences from V2, each verified against rulesync 43.13.0
400
446
  output in this repository's golden tests:
401
447
 
402
448
  - **Agent frontmatter** — V1 keeps `name` and writes the per-tool `permission` map; V2 drops `name`
@@ -411,23 +457,24 @@ output in this repository's golden tests:
411
457
  - **Hooks plugin** — V1 writes the `RulesyncHooksPlugin` module, which OpenCode 2.x does not run;
412
458
  V2 writes the `{ id, setup }` plugin, which OpenCode 1.x does not run.
413
459
 
414
- Cells that are not verified by a test in this release are **unknown**, never a tick. In particular,
415
- this release verifies the emitted bytes and their containment; it does not verify that a particular
416
- OpenCode build honours `temperature` or per-agent `tools`, and it does not author either field, so
417
- they are not claimed.
418
-
419
460
  Two details matter more than the table:
420
461
 
421
462
  - **OpenCode's workspace kinds are not an agent-mode loss warning.** A workspace emission would give
422
463
  every persona the declaring persona's MCP server, skill, command or hook, with no per-recipient
423
464
  record and no opt-out. That is not a capability the author declared for those personas, so agent
424
- mode refuses the reference and points at profile mode instead of emitting it.
465
+ mode refuses the reference and points at profile mode instead of emitting it. Profile mode carries
466
+ the live persona's kinds; a hook OpenCode cannot represent (`session-end`, or a matcher on a
467
+ non-tool event) is reported as `W101_CAPABILITY_DROPPED` at high severity and is not emitted.
425
468
  - **Claude Code's workspace kinds are absent from this release.** `claudecode` does not carry
426
- `mcp`, `skill`, `command` or `hook` at all yet; a reference is refused rather than silently
469
+ `mcp`, `skill`, `command` or `hook` at any level yet; a reference is refused rather than silently
427
470
  losing it. Profile mode on `claudecode` is later work.
428
471
 
429
- A full 71-target capability matrix, the `agent with loss` and `refuse` plan outcomes, and a
430
- generated capability report page are not in this release. See
472
+ A persona `mode` is documented separately from these seven capabilities: it is native on both
473
+ OpenCode targets and has no Claude Code field (`W117_PERSONA_MODE_IGNORED`). The opt-in Claude Code
474
+ `tools` allow-list has no OpenCode equivalent and is refused there; see [Permissions](#permissions).
475
+
476
+ The full 71-target matrix and the generated `docs/capability-matrix.md` page are not in this
477
+ release. `report` prints the measured matrix for the three supported targets today. See
431
478
  [What this slice does not do](#what-this-slice-does-not-do).
432
479
 
433
480
  ### Output layout
@@ -589,7 +636,7 @@ that *looks like a credential* (`sk-`, `ghp_`, `glpat-`, `npm_`, `AKIA`, a JWT,
589
636
  string with letters and digits) is reported as `W116_SECRET_IN_ARGS` at high severity, naming the
590
637
  argument's position and never echoing the value: it would otherwise be written verbatim into
591
638
  `opencode.jsonc`. A `{ "fromEnv": "NAME" }` reference inside `args` cannot be expressed — rulesync
592
- 43.11.0 accepts only string arguments and copies them into the emitted command verbatim, so the
639
+ 43.13.0 accepts only string arguments and copies them into the emitted command verbatim, so the
593
640
  reference would reach the server as the unexpanded text `${NAME}` — and is refused (F001) with the
594
641
  supported alternative: put the credential in `env` or `headers`.
595
642
 
@@ -740,12 +787,13 @@ on stdout and its single human line on stderr.
740
787
 
741
788
  ```text
742
789
  src/
743
- cli/ Commander wiring, the three commands, and the error boundary
790
+ cli/ Commander wiring, the five commands, and the error boundary
744
791
  config/ strict JSONC config schema and loader
745
792
  source/ YAML personas; markdown rules, skills and commands; JSONC permissions,
746
793
  MCP servers and hooks; strict frontmatter and reference-only secrets
747
794
  compose/ mode resolution, extends resolution, resource union, deny-wins merge, digests
748
795
  permissions/ the canonical vocabulary and the Claude Code and OpenCode mappings
796
+ matrix/ the measured capability snapshot and its F010 integrity guard
749
797
  materialise/ persona and workspace resources -> rulesync source tree
750
798
  render/ port.ts (the seam), upstream.ts (the only rulesync import),
751
799
  identity.ts (installed vs pinned renderer), prepare.ts (the pipeline),
@@ -756,7 +804,7 @@ src/
756
804
  verify/ containment and cross-persona isolation gates
757
805
  lock/ lockfile construction and validated reading
758
806
  core/ constants, typed errors, paths, strict UTF-8 reads, canonical JSON
759
- report/ text and JSON output, warning records
807
+ report/ text and JSON output, warning records, the capability report
760
808
  tests/
761
809
  fixtures/demo/ the demo fixture: two personas, two rules, no permissions
762
810
  fixtures/composed/ builder, builder-python (extends builder) and reviewer, with permissions
@@ -803,7 +851,7 @@ The generated bytes are the product, so they must not depend on where or when th
803
851
  - **Ordering is canonical.** Personas and resources are sorted by kind and codepoint id before
804
852
  hashing or writing. Permission records are the one deliberate exception: they keep source order
805
853
  because OpenCode is last-match-wins, so the digest is order-sensitive there too.
806
- - **The renderer is pinned.** `rulesync` is pinned to exactly `43.11.0` with a tarball integrity (see
854
+ - **The renderer is pinned.** `rulesync` is pinned to exactly `43.13.0` with a tarball integrity (see
807
855
  [The renderer boundary](#the-renderer-boundary)). The lockfile records the pin, not the integrity
808
856
  the local package manager happened to write, so two machines that both verified their install -
809
857
  and one that could not verify its own - produce the same lockfile bytes for the same source.
@@ -817,7 +865,7 @@ The generated bytes are the product, so they must not depend on where or when th
817
865
 
818
866
  The repository's own suites include golden byte comparisons and a two-root determinism test. Two
819
867
  clean runs of the same source on one machine produce identical bytes and an identical lockfile;
820
- cross-machine determinism follows from the same rules, and CI runs on Linux.
868
+ cross-machine determinism follows from the same rules, and CI runs on Linux and macOS.
821
869
 
822
870
  ## The renderer boundary
823
871
 
@@ -826,7 +874,7 @@ imports `rulesync`, and `src/cli/main.ts` is the only place that binds the real
826
874
  Unit tests use an independent fake renderer, so the failure modes the port exists to catch can be
827
875
  exercised without the network or the real renderer.
828
876
 
829
- `rulesync` is pinned to exactly `43.11.0` with a tarball integrity. The lockfile records that pin,
877
+ `rulesync` is pinned to exactly `43.13.0` with a tarball integrity. The lockfile records that pin,
830
878
  and `check` compares it with the installed package before any byte comparison. The renderer
831
879
  identity policy has three parts:
832
880
 
@@ -923,9 +971,10 @@ where a change belongs and which gates it must pass.
923
971
 
924
972
  Deliberately out of scope:
925
973
 
926
- - `doctor`; `agent with loss` and `refuse` as plan outcomes; profile mode on `claudecode`;
927
- rendering more than one configured target per run; every target other than `claudecode`,
928
- `opencode` and `opencodev1`; the full 71-target capability matrix and the capability report page
974
+ - `agent with loss` and `refuse` as plan outcomes; profile mode on `claudecode`; rendering more
975
+ than one configured target per run; every target other than `claudecode`, `opencode` and
976
+ `opencodev1`; the full 71-target capability matrix and the generated `docs/capability-matrix.md`
977
+ page (the `report` command prints the measured matrix for the three supported targets today)
929
978
  - model resources (a model is the persona's `model` class in this slice)
930
979
  - carrying `mcp`, `skill`, `command` or `hook` on any target in **agent** mode; profile mode is
931
980
  where those workspace capabilities belong, and agent mode still refuses them
@@ -1003,8 +1052,8 @@ These are deliberate limits of the current controls, stated rather than implied
1003
1052
  regression suites (creating a symbolic link needs a privilege the runner does not grant), the
1004
1053
  POSIX file- and directory-mode assertions (mode bits are not meaningful on NTFS), the FIFO cases
1005
1054
  (Windows has no `mkfifo`-equivalent endpoint to create one), and the install-layout suite (its
1006
- fixtures model a hoisted or nested install with symlinks). CI runs all of them on Linux; the
1007
- guard code itself is platform-independent.
1055
+ fixtures model a hoisted or nested install with symlinks). CI runs all of them on Linux and
1056
+ macOS; the guard code itself is platform-independent.
1008
1057
  - **Unrecorded files are not drift.** With a lockfile present, `check` compares the paths in the
1009
1058
  fresh plan (missing or changed) and the paths the committed lockfile records (an output the source
1010
1059
  no longer produces). A file the user keeps in a managed directory is not this tool's output, so it
@@ -1018,12 +1067,14 @@ These are deliberate limits of the current controls, stated rather than implied
1018
1067
  escaping in the inverse order before comparing, because it is the renderer's representation of the
1019
1068
  same command. Each command's matcher is read from the slice between the previous command and this
1020
1069
  one, so a matcher-less hook cannot inherit a neighbour's guard and a dropped matcher cannot be
1021
- replaced by an earlier identical one. The parser matches rulesync 43.11.0's two registration shapes
1022
- and cannot recognise a registration emitted as a template literal under a future renderer, so a
1023
- plugin that keeps the same commands but changes its registration shape is caught only by `check`
1024
- against a fresh render of the pinned renderer. A change to rulesync's generated helper code that
1025
- keeps the same registrations is likewise caught only by `check`, not by a committed plugin
1026
- golden.
1070
+ replaced by an earlier identical one. rulesync translates a canonical tool name in a matcher to the
1071
+ target's lowercase id and anchors a pure name list (`Edit|Write` becomes `^(?:edit|write)$`), so the
1072
+ gate applies the same translation before comparing. The parser matches rulesync 43.13.0's two
1073
+ registration shapes and cannot recognise a registration emitted as a template literal under a
1074
+ future renderer, so a plugin that keeps the same commands but changes its registration shape is
1075
+ caught only by `check` against a fresh render of the pinned renderer. A change to rulesync's
1076
+ generated helper code that keeps the same registrations is likewise caught only by `check`, not by
1077
+ a committed plugin golden.
1027
1078
  - **Skill extra files must be UTF-8.** The managed-output pipeline compares and writes text, so a
1028
1079
  binary asset inside a skill directory is refused (F001) rather than carried; decoding and
1029
1080
  re-encoding a valid UTF-8 file is byte-identical.
@@ -1068,6 +1119,7 @@ npm run lint
1068
1119
  npm run typecheck
1069
1120
  npm test
1070
1121
  npm run build
1122
+ node dist/cli/main.js check # the committed agent config matches .farna/
1071
1123
  npm audit --audit-level=moderate
1072
1124
  node scripts/assert-pack.mjs # the tarball is dist/ plus the legal files, with no source map
1073
1125
  npm pack --dry-run # the exact package npm would publish
@@ -1095,6 +1147,25 @@ tag is on `main`, runs the gates, publishes the packed tarball to npm with prove
1095
1147
  the GitHub Release. The publish job waits for approval on the `release` environment, whose
1096
1148
  `NPM_TOKEN` secret carries the npm token. See [Releasing](CONTRIBUTING.md#releasing).
1097
1149
 
1150
+ ## This repository dogfoods itself
1151
+
1152
+ The source of this repository's own agent configuration is `.farna/`: one persona, `maintainer`,
1153
+ built from a rule distilled from [CONTRIBUTING.md](CONTRIBUTING.md) and a permission resource.
1154
+ `generate` renders it to a committed `.claude/agents/maintainer.md` and records the manifest in
1155
+ `.farna/lock.json`.
1156
+
1157
+ ```sh
1158
+ node dist/cli/main.js generate # after any change under .farna/
1159
+ node dist/cli/main.js check # re-render and compare; drift exits 1
1160
+ ```
1161
+
1162
+ `check` runs in CI, so a change to `.farna/` that was not regenerated, or a hand-edited generated
1163
+ file, fails the build rather than merging quietly.
1164
+
1165
+ This is the `claudecode` target in agent mode, and nothing else. This release renders exactly one
1166
+ configured target per run and Claude Code has no profile mode, so the OpenCode half of the dogfood
1167
+ waits on multi-target rendering; it is not represented here today.
1168
+
1098
1169
  ## Licence
1099
1170
 
1100
1171
  MIT, Copyright (c) 2026 Farnalabs Ltd. See `LICENSE` and `NOTICE`. Security reports are handled
@@ -0,0 +1,64 @@
1
+ import { type Capability, type PersonaMode, type RenderMode, type SupportedTarget } from '../../core/constants.js';
2
+ import type { Warning } from '../../report/warnings.js';
3
+ /** One resolved resource with the attribution `doctor` prints. */
4
+ export type DoctorResource = {
5
+ kind: Capability;
6
+ id: string;
7
+ path: string;
8
+ fromPersona: string;
9
+ /** 0 for the persona itself, 1 for its immediate base, and so on. */
10
+ rank: number;
11
+ };
12
+ export type DoctorPersona = {
13
+ id: string;
14
+ displayName: string;
15
+ purpose: string;
16
+ /** The composition chain, base first. */
17
+ chain: string[];
18
+ mode: PersonaMode | null;
19
+ model: string | null;
20
+ resources: DoctorResource[];
21
+ };
22
+ /**
23
+ * One validation this run performed. `doctor` fails at the first error, so a
24
+ * check appears here only when it ran and did not fail; a report never claims
25
+ * a check it did not reach.
26
+ */
27
+ export type DoctorCheck = {
28
+ name: string;
29
+ detail: string;
30
+ };
31
+ export type DoctorResult = {
32
+ ok: true;
33
+ target: SupportedTarget;
34
+ mode: RenderMode;
35
+ activePersona: string | null;
36
+ notLive: string[];
37
+ configPath: string;
38
+ counts: {
39
+ /** Personas declared in the source, live or not. */
40
+ personas: number;
41
+ /** Personas this target emits in the selected mode. */
42
+ live: number;
43
+ resourceReferences: number;
44
+ modelClasses: number;
45
+ warnings: number;
46
+ };
47
+ checks: DoctorCheck[];
48
+ personas: DoctorPersona[];
49
+ warnings: Warning[];
50
+ };
51
+ /**
52
+ * Validate a `.farna` source without rendering or writing.
53
+ *
54
+ * The read → resolve half of `prepareRender` is reused wholesale: the config
55
+ * loader, the source loader and the resolver are the same ones `generate` and
56
+ * `check` run, so `doctor` cannot accept a source they refuse. Only the
57
+ * materialise → render → verify half is skipped, because a report that renders
58
+ * bytes would need the renderer and could mask a source error behind a render
59
+ * error.
60
+ *
61
+ * A failure throws the loader's or resolver's own `FarnaError`, so the exit
62
+ * code and the code are the ones `generate` would produce for the same source.
63
+ */
64
+ export declare function runDoctor(repoRoot: string): Promise<DoctorResult>;
@@ -0,0 +1,101 @@
1
+ import { resolveSource } from '../../compose/resolve.js';
2
+ import { loadConfig } from '../../config/load.js';
3
+ import { CONFIG_PATH, ROOT_DIR, } from '../../core/constants.js';
4
+ import { loadSource } from '../../source/load.js';
5
+ function doctorPersona(persona) {
6
+ return {
7
+ id: persona.id,
8
+ displayName: persona.displayName,
9
+ purpose: persona.purpose,
10
+ chain: persona.chain,
11
+ mode: persona.mode ?? null,
12
+ model: persona.model ?? null,
13
+ resources: persona.resources.map((resource) => ({
14
+ kind: resource.kind,
15
+ id: resource.id,
16
+ path: resource.path,
17
+ fromPersona: resource.fromPersona,
18
+ // Depth from the reported persona: its own resources are rank 0, an
19
+ // immediate base's are rank 1, and so on.
20
+ rank: persona.chain.length - 1 - persona.chain.indexOf(resource.fromPersona),
21
+ })),
22
+ };
23
+ }
24
+ /**
25
+ * Validate a `.farna` source without rendering or writing.
26
+ *
27
+ * The read → resolve half of `prepareRender` is reused wholesale: the config
28
+ * loader, the source loader and the resolver are the same ones `generate` and
29
+ * `check` run, so `doctor` cannot accept a source they refuse. Only the
30
+ * materialise → render → verify half is skipped, because a report that renders
31
+ * bytes would need the renderer and could mask a source error behind a render
32
+ * error.
33
+ *
34
+ * A failure throws the loader's or resolver's own `FarnaError`, so the exit
35
+ * code and the code are the ones `generate` would produce for the same source.
36
+ */
37
+ export async function runDoctor(repoRoot) {
38
+ const config = await loadConfig(repoRoot);
39
+ const tree = await loadSource(repoRoot);
40
+ const source = resolveSource(tree, config);
41
+ const modelClasses = Object.keys(config.models ?? {}).length;
42
+ const personas = source.personas.map(doctorPersona);
43
+ const resourceReferences = personas.reduce((total, persona) => total + persona.resources.length, 0);
44
+ const categories = new Set();
45
+ let patterns = 0;
46
+ for (const persona of source.personas) {
47
+ for (const key of Object.keys(persona.permissions.values)) {
48
+ categories.add(key);
49
+ }
50
+ for (const bucket of Object.values(persona.permissions.patterns)) {
51
+ patterns += Object.keys(bucket).length;
52
+ }
53
+ }
54
+ const modeDetail = source.mode === 'profile'
55
+ ? `${source.target}, profile mode, active ${source.active ?? '<none>'}`
56
+ : `${source.target}, agent mode, every persona live`;
57
+ return {
58
+ ok: true,
59
+ target: source.target,
60
+ mode: source.mode,
61
+ activePersona: source.active,
62
+ notLive: source.notLive,
63
+ configPath: CONFIG_PATH,
64
+ counts: {
65
+ personas: tree.personas.length,
66
+ live: source.personas.length,
67
+ resourceReferences,
68
+ modelClasses,
69
+ warnings: source.warnings.length,
70
+ },
71
+ checks: [
72
+ { name: 'config schema', detail: CONFIG_PATH },
73
+ { name: 'source tree and paths', detail: ROOT_DIR },
74
+ {
75
+ name: 'personas and extends chains',
76
+ detail: `${tree.personas.length} persona(s) resolved, no cycle`,
77
+ },
78
+ {
79
+ name: 'resource references',
80
+ detail: `${resourceReferences} reference(s) across ${source.personas.length} live persona(s)`,
81
+ },
82
+ {
83
+ name: 'model map',
84
+ detail: modelClasses === 0
85
+ ? 'no model class declared'
86
+ : `${modelClasses} model class(es) resolve for ${source.target}`,
87
+ },
88
+ { name: 'target and profile mode', detail: modeDetail },
89
+ {
90
+ name: 'permission categories and patterns',
91
+ detail: `${categories.size} categor(ies), ${patterns} pattern(s)`,
92
+ },
93
+ {
94
+ name: 'secret references',
95
+ detail: 'MCP credential fields are fromEnv or header references only',
96
+ },
97
+ ],
98
+ personas,
99
+ warnings: source.warnings,
100
+ };
101
+ }
@@ -0,0 +1,11 @@
1
+ import { type CapabilityReport } from '../../report/capability.js';
2
+ /**
3
+ * Print the measured capability matrix. This command reads no source tree and
4
+ * writes nothing: the matrix is a property of this build and its pinned
5
+ * renderer, so it is useful in an empty directory and in CI.
6
+ *
7
+ * The snapshot is verified against the pinned renderer before it is printed.
8
+ * A promised target with an unmeasured cell fails with F010 rather than
9
+ * rendering an `unknown` as a tick.
10
+ */
11
+ export declare function runReport(): CapabilityReport;
@@ -0,0 +1,16 @@
1
+ import { SNAPSHOT, verifySnapshot } from '../../matrix/snapshot.js';
2
+ import { RENDERER_PIN } from '../../render/upstream.js';
3
+ import { buildCapabilityReport } from '../../report/capability.js';
4
+ /**
5
+ * Print the measured capability matrix. This command reads no source tree and
6
+ * writes nothing: the matrix is a property of this build and its pinned
7
+ * renderer, so it is useful in an empty directory and in CI.
8
+ *
9
+ * The snapshot is verified against the pinned renderer before it is printed.
10
+ * A promised target with an unmeasured cell fails with F010 rather than
11
+ * rendering an `unknown` as a tick.
12
+ */
13
+ export function runReport() {
14
+ verifySnapshot(SNAPSHOT, RENDERER_PIN.version);
15
+ return buildCapabilityReport(SNAPSHOT);
16
+ }
@@ -19,5 +19,5 @@ export declare function unexpectedFailureObject(command: string | null, message:
19
19
  * the message may come from a platform library or from a tool.
20
20
  */
21
21
  export declare function redactRoot(message: string, root: string): string;
22
- /** Commander wiring for the three commands this slice implements. */
22
+ /** Commander wiring for the five commands this slice implements. */
23
23
  export declare function buildProgram(context: CliContext): Command;