farna-bootstrapper 0.1.1 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,35 @@ 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.2] - 2026-11-23
10
+
11
+ ### Added
12
+
13
+ - **`doctor`.** Validates a `.farna` source without rendering or writing: the config schema, persona
14
+ and resource references, `extends` cycles, the model map, target support, permission categories
15
+ and patterns, secret references, path and symlink safety, and the profile-mode invariants. It
16
+ reuses the same config loader, source loader and resolver as `generate` and `check`, so it cannot
17
+ accept a source they refuse. A failure carries the same typed code and exit status; `--json`
18
+ emits one object, and the human report lists every check that ran, every resolved persona and
19
+ resource with its source path, and every warning.
20
+ - **`report`.** Prints the measured capability matrix for all three supported targets, with two
21
+ emissions per capability (per persona and workspace level) and a per-key permission table. The
22
+ vocabulary is `native`, `emulated`, `dropped` and `unknown`; `unknown` renders as `[?] not
23
+ measured` and is never a tick. `--json` emits the same claim as data. The command reads no source
24
+ tree and writes nothing.
25
+ - **A structural matrix guard.** `verifySnapshot` refuses (F010) a snapshot measured against a
26
+ different renderer, a missing supported-target row, or an `unknown` cell on a promised target.
27
+
28
+ ### Changed
29
+
30
+ - The README, `CONTRIBUTING.md` and `--help` describe the five-command surface and the capability
31
+ report.
32
+
33
+ ### Fixed
34
+
35
+ - The `CONTRIBUTING.md` release example used `v0.1.0` as its tag; it now uses the current release
36
+ version.
37
+
9
38
  ## [0.1.1] - 2026-11-22
10
39
 
11
40
  ### Added
@@ -103,5 +132,6 @@ output still matches the source.
103
132
  runner does not grant), the POSIX mode assertions, the FIFO cases and the install-layout suite are
104
133
  skipped on Windows; CI runs them on Linux.
105
134
 
135
+ [0.1.2]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.2
106
136
  [0.1.1]: https://github.com/farnalabs/farna-bootstrapper/releases/tag/v0.1.1
107
137
  [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,10 +50,10 @@ 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
@@ -68,8 +74,10 @@ npx farna-bootstrapper init
68
74
  one file per resource; [Use](#use) has a complete pair. Then:
69
75
 
70
76
  ```sh
77
+ npx farna-bootstrapper doctor # validate the source; write nothing
71
78
  npx farna-bootstrapper generate # render the target and write .farna/lock.json
72
79
  npx farna-bootstrapper check # exit 0 when the tree matches a fresh render
80
+ npx farna-bootstrapper report # print the measured capability matrix
73
81
  ```
74
82
 
75
83
  Commit `.farna/` and the generated files. Running `check` in CI is the drift gate: a hand edit, a
@@ -78,6 +86,7 @@ stale render, or a source change that was never regenerated exits `1` and names
78
86
  ## The loop
79
87
 
80
88
  1. You declare personas and their resources under `.farna/`, and select one target in the config.
89
+ `farna-bootstrapper doctor` validates that declaration without rendering it.
81
90
  2. `farna-bootstrapper generate` renders that target's artefacts and records what it wrote in
82
91
  `.farna/lock.json`. Claude Code gets one whole file per persona under `.claude/agents/`; OpenCode
83
92
  in agent mode gets one whole file per persona under `.opencode/agents/` and no workspace file;
@@ -301,6 +310,8 @@ Write the smallest change that satisfies the ticket.
301
310
  Then run:
302
311
 
303
312
  ```sh
313
+ farna-bootstrapper doctor # validate the source; render and write nothing
314
+ farna-bootstrapper report # print the measured capability matrix
304
315
  farna-bootstrapper generate # write the agent files and the lockfile
305
316
  farna-bootstrapper generate --dry-run # print the plan, write nothing
306
317
  farna-bootstrapper generate --adopt # take ownership of existing outputs (see below)
@@ -316,6 +327,8 @@ The complete flag surface:
316
327
  | 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
328
  | all | `-v, --version`, `-h, --help` | print the compiled-in version or usage; neither needs the renderer |
318
329
  | `init` | `--json` | the created/updated paths and the next step |
330
+ | `doctor` | `--json` | every validation that ran, every resolved persona and resource, and the warnings |
331
+ | `report` | `--json` | the measured capability matrix for every supported target |
319
332
  | `generate` | `--dry-run` | print the plan and write nothing; `would-write` and `unchanged` are counted separately |
320
333
  | `generate` | `--adopt` | take ownership of every existing planned managed output; required when the lockfile is missing |
321
334
  | `generate` | `--persona <id>` | run profile mode as that persona; wins over `targets.<target>.active` and is not written back |
@@ -336,6 +349,13 @@ working tree, so `unchanged` and
336
349
  counts the `would-write` files, not the size of the plan: a tree that already matches reports
337
350
  `would write 0 file(s), N unchanged`.
338
351
 
352
+ `doctor` adds `target`, `mode`, `activePersona`, `notLive`, `configPath`, `counts`, `checks`,
353
+ `personas` and `warnings`; each persona carries its `chain`, `mode`, `model` and every resolved
354
+ resource with its `path`, `fromPersona` and `rank`. `report` adds `renderer` and `targets[]`, where
355
+ each target carries `id`, `status`, `agentReach`, `capabilities` (the seven cells, each with
356
+ `agent`, `workspace`, `basis`, `testId` and `consequence`) and `permissionKeys` (each with
357
+ `emission`, `code` and `consequence`).
358
+
339
359
  A persona's rule text is joined into the body of its subagent, in canonical rule-id order, under a
340
360
  `## displayName` heading. The rule body itself is never re-wrapped or re-indented. There is no
341
361
  shared root rules file: the per-agent body is the only rule surface, so one persona's rules never
@@ -377,24 +397,49 @@ writing any of them.
377
397
 
378
398
  ### Capability matrix
379
399
 
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).
400
+ What this release actually carries, as measured by the tests that pin the emitted bytes and the
401
+ refusals. A cell has one of four values, and each has exactly one rendering in the `report` command:
402
+
403
+ | Value | Meaning | Glyph | Never |
404
+ |---|---|---|---|
405
+ | **native** | written into the emitted artefact | `[x]` | a claim that the harness obeys it at runtime |
406
+ | **emulated** | carried under a different category whose effect differs | `[~]` | counted as carried for a boundary capability |
407
+ | **dropped** | the target receives nothing; a declared reference is refused (`F001`) or reported (`W101`) | `[ ]` | silent |
408
+ | **unknown** | not measured in this release | `[?] not measured` | rendered as a tick |
385
409
 
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 |
410
+ `farna-bootstrapper report` prints this matrix for all three supported targets, as a human table or
411
+ as one JSON object with `--json`. It reads no source and writes nothing; the same data is what this
412
+ section documents.
413
+
414
+ | Capability | claudecode, agent | claudecode, workspace | opencode, agent | opencode, workspace | opencodev1, agent | opencodev1, workspace |
387
415
  |---|---|---|---|---|---|---|
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) | — |
416
+ | `rule` | native | dropped [^claude-workspace] | native | native | native | native |
417
+ | `model` | native | dropped [^claude-workspace] | native | native | native | native |
418
+ | `permission` | native | dropped [^claude-workspace] | native | native | native | native |
419
+ | `skill` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
420
+ | `command` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
421
+ | `mcp` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
422
+ | `hook` | dropped | dropped [^claude-workspace] | dropped | native | dropped | native |
423
+
424
+ [^claude-workspace]: Profile mode is not supported on `claudecode` in this release, so no
425
+ workspace-level output is written for any capability.
426
+
427
+ The `permission` capability is one cell but a per-key measurement. `report` prints the key table
428
+ too, because the cell alone would hide where a key widens or refuses:
429
+
430
+ | Permission key | claudecode | opencode | opencodev1 |
431
+ |---|---|---|---|
432
+ | `read`, `edit`, `shell`, `task` | native | native | native |
433
+ | `write` | native | emulated (`W112`) | emulated (`W112`) |
434
+ | `network` | dropped (`F011`) | dropped (`F011`) | dropped (`F011`) |
435
+ | `mcp` (bare category) | dropped (`F011`) | not measured, refused (`F011`) | not measured, refused (`F011`) |
436
+
437
+ `write` on OpenCode is emulated, not native: OpenCode has no write category, so the rule lands as
438
+ `edit`, and an `allow` then also permits modifying existing files. `W112_PERMISSION_LOSSY` at high
439
+ severity names the widening, and a declaration is never silently weakened. A bare `network` or
440
+ `mcp` category has no mapping on any target, so it is refused (`F011`) rather than written as an
441
+ inert rule; the bare `mcp` category on OpenCode is recorded as **not measured** and is never claimed
442
+ as carried.
398
443
 
399
444
  The OpenCode V1 columns record these differences from V2, each verified against rulesync 43.11.0
400
445
  output in this repository's golden tests:
@@ -411,23 +456,24 @@ output in this repository's golden tests:
411
456
  - **Hooks plugin** — V1 writes the `RulesyncHooksPlugin` module, which OpenCode 2.x does not run;
412
457
  V2 writes the `{ id, setup }` plugin, which OpenCode 1.x does not run.
413
458
 
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
459
  Two details matter more than the table:
420
460
 
421
461
  - **OpenCode's workspace kinds are not an agent-mode loss warning.** A workspace emission would give
422
462
  every persona the declaring persona's MCP server, skill, command or hook, with no per-recipient
423
463
  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.
464
+ mode refuses the reference and points at profile mode instead of emitting it. Profile mode carries
465
+ the live persona's kinds; a hook OpenCode cannot represent (`session-end`, or a matcher on a
466
+ non-tool event) is reported as `W101_CAPABILITY_DROPPED` at high severity and is not emitted.
425
467
  - **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
468
+ `mcp`, `skill`, `command` or `hook` at any level yet; a reference is refused rather than silently
427
469
  losing it. Profile mode on `claudecode` is later work.
428
470
 
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
471
+ A persona `mode` is documented separately from these seven capabilities: it is native on both
472
+ OpenCode targets and has no Claude Code field (`W117_PERSONA_MODE_IGNORED`). The opt-in Claude Code
473
+ `tools` allow-list has no OpenCode equivalent and is refused there; see [Permissions](#permissions).
474
+
475
+ The full 71-target matrix and the generated `docs/capability-matrix.md` page are not in this
476
+ release. `report` prints the measured matrix for the three supported targets today. See
431
477
  [What this slice does not do](#what-this-slice-does-not-do).
432
478
 
433
479
  ### Output layout
@@ -740,12 +786,13 @@ on stdout and its single human line on stderr.
740
786
 
741
787
  ```text
742
788
  src/
743
- cli/ Commander wiring, the three commands, and the error boundary
789
+ cli/ Commander wiring, the five commands, and the error boundary
744
790
  config/ strict JSONC config schema and loader
745
791
  source/ YAML personas; markdown rules, skills and commands; JSONC permissions,
746
792
  MCP servers and hooks; strict frontmatter and reference-only secrets
747
793
  compose/ mode resolution, extends resolution, resource union, deny-wins merge, digests
748
794
  permissions/ the canonical vocabulary and the Claude Code and OpenCode mappings
795
+ matrix/ the measured capability snapshot and its F010 integrity guard
749
796
  materialise/ persona and workspace resources -> rulesync source tree
750
797
  render/ port.ts (the seam), upstream.ts (the only rulesync import),
751
798
  identity.ts (installed vs pinned renderer), prepare.ts (the pipeline),
@@ -756,7 +803,7 @@ src/
756
803
  verify/ containment and cross-persona isolation gates
757
804
  lock/ lockfile construction and validated reading
758
805
  core/ constants, typed errors, paths, strict UTF-8 reads, canonical JSON
759
- report/ text and JSON output, warning records
806
+ report/ text and JSON output, warning records, the capability report
760
807
  tests/
761
808
  fixtures/demo/ the demo fixture: two personas, two rules, no permissions
762
809
  fixtures/composed/ builder, builder-python (extends builder) and reviewer, with permissions
@@ -923,9 +970,10 @@ where a change belongs and which gates it must pass.
923
970
 
924
971
  Deliberately out of scope:
925
972
 
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
973
+ - `agent with loss` and `refuse` as plan outcomes; profile mode on `claudecode`; rendering more
974
+ than one configured target per run; every target other than `claudecode`, `opencode` and
975
+ `opencodev1`; the full 71-target capability matrix and the generated `docs/capability-matrix.md`
976
+ page (the `report` command prints the measured matrix for the three supported targets today)
929
977
  - model resources (a model is the persona's `model` class in this slice)
930
978
  - carrying `mcp`, `skill`, `command` or `hook` on any target in **agent** mode; profile mode is
931
979
  where those workspace capabilities belong, and agent mode still refuses them
@@ -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;
@@ -2,10 +2,13 @@ import { Command } from 'commander';
2
2
  import { CONFIG_PATH, DRIFT_CODE, EXIT, OPENCODE_SUPPORTED_MAJOR, OPENCODE_V1_SUPPORTED_MAJOR, PRODUCT_NAME, PRODUCT_VERSION, SCHEMA_VERSION, } from '../core/constants.js';
3
3
  import { FarnaError } from '../core/errors.js';
4
4
  import { RENDERER_PIN } from '../render/upstream.js';
5
- import { formatCheck, formatGenerate, formatInit, formatJson } from '../report/format.js';
5
+ import { formatCapabilityReport } from '../report/capability.js';
6
+ import { formatCheck, formatDoctor, formatGenerate, formatInit, formatJson, } from '../report/format.js';
6
7
  import { runCheck } from './commands/check.js';
8
+ import { runDoctor } from './commands/doctor.js';
7
9
  import { runGenerate } from './commands/generate.js';
8
10
  import { runInit } from './commands/init.js';
11
+ import { runReport } from './commands/report.js';
9
12
  /** The one machine-readable failure object: the same keys for every command. */
10
13
  export function failureObject(command, error) {
11
14
  return {
@@ -67,13 +70,16 @@ async function emit(command, json, context, run) {
67
70
  process.exitCode = error.exitCode;
68
71
  }
69
72
  }
70
- /** Commander wiring for the three commands this slice implements. */
73
+ /** Commander wiring for the five commands this slice implements. */
71
74
  export function buildProgram(context) {
72
75
  const program = new Command();
73
76
  program
74
77
  .name(PRODUCT_NAME)
75
- .description('Compile named agent personas and resources into harness configuration, and prove the output still matches the source.')
76
- .addHelpText('after', `\nTwo OpenCode targets are supported, one per run: "opencode" for OpenCode ${OPENCODE_SUPPORTED_MAJOR}.x
78
+ .description('Compile named agent personas and resources into harness configuration, prove the output still matches the source, and report what each target carries.')
79
+ .addHelpText('after', `\nFive commands: init, doctor, report, generate and check. doctor validates a source without
80
+ rendering or writing; report prints the measured capability matrix for every supported target.
81
+
82
+ Two OpenCode targets are supported, one per run: "opencode" for OpenCode ${OPENCODE_SUPPORTED_MAJOR}.x
77
83
  (@opencode/cli) and "opencodev1" for OpenCode ${OPENCODE_V1_SUPPORTED_MAJOR}.x (opencode-ai). They write the same
78
84
  paths in each major's own shapes; configuring both at once is refused.
79
85
  \nProfile mode: pass --persona <id> to generate or check, or set "active" under a target
@@ -110,6 +116,41 @@ remains the default.`)
110
116
  };
111
117
  });
112
118
  });
119
+ program
120
+ .command('doctor')
121
+ .exitOverride()
122
+ .description('validate the source without rendering or writing anything')
123
+ .option('--json', 'print one JSON object')
124
+ .action(async (options) => {
125
+ await emit('doctor', options.json === true, context, async () => {
126
+ const result = await runDoctor(context.cwd);
127
+ return {
128
+ payload: {
129
+ schemaVersion: SCHEMA_VERSION,
130
+ command: 'doctor',
131
+ ...result,
132
+ exitCode: EXIT.ok,
133
+ },
134
+ text: formatDoctor(result),
135
+ exitCode: EXIT.ok,
136
+ };
137
+ });
138
+ });
139
+ program
140
+ .command('report')
141
+ .exitOverride()
142
+ .description('print the measured capability matrix for every supported target')
143
+ .option('--json', 'print one JSON object')
144
+ .action(async (options) => {
145
+ await emit('report', options.json === true, context, async () => {
146
+ const result = runReport();
147
+ return {
148
+ payload: result,
149
+ text: formatCapabilityReport(result),
150
+ exitCode: EXIT.ok,
151
+ };
152
+ });
153
+ });
113
154
  program
114
155
  .command('generate')
115
156
  .exitOverride()
@@ -5,7 +5,7 @@
5
5
  * spelling of each name.
6
6
  */
7
7
  export declare const PRODUCT_NAME = "farna-bootstrapper";
8
- export declare const PRODUCT_VERSION = "0.1.1";
8
+ export declare const PRODUCT_VERSION = "0.1.2";
9
9
  /** The one source/schema version this build understands. */
10
10
  export declare const SCHEMA_VERSION: 1;
11
11
  /**
@@ -5,7 +5,7 @@
5
5
  * spelling of each name.
6
6
  */
7
7
  export const PRODUCT_NAME = 'farna-bootstrapper';
8
- export const PRODUCT_VERSION = '0.1.1';
8
+ export const PRODUCT_VERSION = '0.1.2';
9
9
  /** The one source/schema version this build understands. */
10
10
  export const SCHEMA_VERSION = 1;
11
11
  /**
@@ -0,0 +1,87 @@
1
+ import { type Capability, type SupportedTarget } from '../core/constants.js';
2
+ import { type PermissionCategory } from '../permissions/permissions.js';
3
+ /**
4
+ * The measured capability matrix.
5
+ *
6
+ * A cell answers two questions with one value, so it carries two emissions:
7
+ *
8
+ * - `agent`: can the capability land in the artefact for one persona, visible
9
+ * only to that persona?
10
+ * - `workspace`: can it land at the workspace level, visible to every persona?
11
+ *
12
+ * The value vocabulary is closed. `unknown` is not a soft `native`: it means
13
+ * the behaviour was never measured, so it is never presented as a tick.
14
+ *
15
+ * The data here is the committed measured record for this release. It is not
16
+ * generated by a probe in this slice, so every measured cell is backed by a
17
+ * golden test that pins the emitted bytes; `basis` says which kind of evidence
18
+ * it is. A cell is edited only in the same change that moves the test observing
19
+ * it.
20
+ */
21
+ export type Emission = 'native' | 'emulated' | 'dropped' | 'unknown';
22
+ export type TargetStatus = 'promised' | 'unverified';
23
+ export type CellBasis = 'probe' | 'emitted' | 'upstream-doc' | 'none';
24
+ export type CapabilityCell = {
25
+ agent: Emission;
26
+ workspace: Emission;
27
+ basis: CellBasis;
28
+ /**
29
+ * The test that observes the cell's claim, repository-relative: the golden
30
+ * test that pins the emitted bytes, or the planner test that proves a
31
+ * refusal. `null` when no single test observes the claim.
32
+ */
33
+ testId: string | null;
34
+ /** What the emission means for the author; required for a non-native value. */
35
+ consequence: string | null;
36
+ };
37
+ /** One product permission key as the target carries it, per persona. */
38
+ export type PermissionKeyCell = {
39
+ emission: Emission;
40
+ /** The diagnostic a declaration raises, or `null` when it is carried plainly. */
41
+ code: string | null;
42
+ consequence: string | null;
43
+ };
44
+ export type TargetMatrix = {
45
+ id: SupportedTarget;
46
+ status: TargetStatus;
47
+ /** Whether a persona is the primary session or a callable subagent. */
48
+ agentReach: 'primary' | 'subagent';
49
+ cells: Record<Capability, CapabilityCell>;
50
+ permissionKeys: Record<PermissionCategory, PermissionKeyCell>;
51
+ };
52
+ export type CapabilitySnapshot = {
53
+ schemaVersion: 1;
54
+ renderer: {
55
+ name: string;
56
+ version: string;
57
+ };
58
+ targets: TargetMatrix[];
59
+ };
60
+ /**
61
+ * The reported order. It follows the source model: what a persona reads
62
+ * (rule), what it runs as (model), what it may do (permission), then the
63
+ * workspace-level kinds that are carried only by profile mode.
64
+ */
65
+ export declare const MATRIX_CAPABILITIES: readonly Capability[];
66
+ /**
67
+ * The measured record. `renderer.version` must equal the pinned renderer; a
68
+ * test asserts it, so a renderer bump cannot leave a stale matrix silently
69
+ * published.
70
+ */
71
+ export declare const SNAPSHOT: CapabilitySnapshot;
72
+ /**
73
+ * Refuse a snapshot that cannot be published. This is the structural guard
74
+ * behind "an unknown cell is never a tick": a promised target must have a
75
+ * measured emission on both axes for every capability. `unknown` remains valid
76
+ * on an unverified target, where the whole row is labelled unverified.
77
+ *
78
+ * F010 is the design's code for a matrix that does not match the build: it
79
+ * fails the report rather than rendering a claim nobody measured.
80
+ */
81
+ export declare function verifySnapshot(snapshot: CapabilitySnapshot, rendererVersion?: string): void;
82
+ /** The one glyph each emission renders as. No value renders blank. */
83
+ export declare function emissionGlyph(emission: Emission): string;
84
+ /** The word each emission renders as. `unknown` is always "not measured". */
85
+ export declare function emissionWord(emission: Emission): string;
86
+ /** Every permission category, in the product's declared order. */
87
+ export declare function permissionCategories(): readonly PermissionCategory[];
@@ -0,0 +1,232 @@
1
+ import { DEFAULT_TARGET, OPENCODE_TARGET, OPENCODE_V1_TARGET, SUPPORTED_TARGETS, } from '../core/constants.js';
2
+ import { FarnaError } from '../core/errors.js';
3
+ import { PERMISSION_CATEGORIES } from '../permissions/permissions.js';
4
+ /**
5
+ * The reported order. It follows the source model: what a persona reads
6
+ * (rule), what it runs as (model), what it may do (permission), then the
7
+ * workspace-level kinds that are carried only by profile mode.
8
+ */
9
+ export const MATRIX_CAPABILITIES = [
10
+ 'rule',
11
+ 'model',
12
+ 'permission',
13
+ 'skill',
14
+ 'command',
15
+ 'mcp',
16
+ 'hook',
17
+ ];
18
+ const CLAUDE_TEST = 'tests/golden/builder-python.test.ts';
19
+ const OPENCODE_TEST = 'tests/golden/opencode.test.ts';
20
+ const OPENCODE_V1_TEST = 'tests/golden/opencode-v1.test.ts';
21
+ function cell(agent, workspace, options = {}) {
22
+ return {
23
+ agent,
24
+ workspace,
25
+ basis: options.basis ?? 'emitted',
26
+ testId: options.testId ?? null,
27
+ consequence: options.consequence ?? null,
28
+ };
29
+ }
30
+ /** A cell that is refused in every mode: the evidence is a planner test. */
31
+ function refused(consequence, testId) {
32
+ return cell('dropped', 'dropped', { basis: 'probe', testId, consequence });
33
+ }
34
+ function claudeWorkspaceDropped(capability) {
35
+ return `profile mode is not supported on claudecode in this release, so no workspace-level ${capability} is written`;
36
+ }
37
+ function claudeNotCarried(kind) {
38
+ return `claudecode does not carry ${kind} in this release; a persona that references one is refused with F001`;
39
+ }
40
+ function opencodeWorkspaceOnly(kind, target) {
41
+ switch (kind) {
42
+ case 'skill':
43
+ return `skills are workspace level only on ${target}, so an agent mode persona loses this skill; profile mode carries it`;
44
+ case 'command':
45
+ return `commands are workspace level only on ${target}, so an agent mode persona loses its command set; profile mode carries it`;
46
+ case 'mcp':
47
+ return `${target} configures MCP servers at the workspace level, not per agent, so an agent mode persona loses its server; profile mode carries it`;
48
+ default:
49
+ return `${target} carries hooks at the workspace level only, as a generated plugin, so an agent mode persona loses its hook (W101, high); profile mode carries representable events only`;
50
+ }
51
+ }
52
+ const CLAUDE_PERMISSION_KEYS = {
53
+ read: { emission: 'native', code: null, consequence: null },
54
+ write: { emission: 'native', code: null, consequence: null },
55
+ edit: { emission: 'native', code: null, consequence: null },
56
+ shell: { emission: 'native', code: null, consequence: null },
57
+ task: { emission: 'native', code: null, consequence: null },
58
+ network: {
59
+ emission: 'dropped',
60
+ code: 'F011_PERMISSION_UNMAPPED',
61
+ consequence: 'Claude Code has no tool for a bare network category; a declaration is refused with F011',
62
+ },
63
+ mcp: {
64
+ emission: 'dropped',
65
+ code: 'F011_PERMISSION_UNMAPPED',
66
+ consequence: 'a bare mcp category names no tool; a declaration is refused with F011',
67
+ },
68
+ };
69
+ function opencodePermissionKeys(target) {
70
+ return {
71
+ read: { emission: 'native', code: null, consequence: null },
72
+ write: {
73
+ emission: 'emulated',
74
+ code: 'W112_PERMISSION_LOSSY',
75
+ consequence: `${target} has no write category, so write is emitted as edit; an allow also permits modifying existing files`,
76
+ },
77
+ edit: { emission: 'native', code: null, consequence: null },
78
+ shell: { emission: 'native', code: null, consequence: null },
79
+ task: { emission: 'native', code: null, consequence: null },
80
+ network: {
81
+ emission: 'dropped',
82
+ code: 'F011_PERMISSION_UNMAPPED',
83
+ consequence: `${target} has no mapping for a bare network category; a declaration is refused with F011`,
84
+ },
85
+ mcp: {
86
+ emission: 'unknown',
87
+ code: 'F011_PERMISSION_UNMAPPED',
88
+ consequence: `${target}'s bare mcp permission category is not measured in this release; a declaration is refused with F011`,
89
+ },
90
+ };
91
+ }
92
+ function claudeCells() {
93
+ return {
94
+ rule: cell('native', 'dropped', {
95
+ testId: CLAUDE_TEST,
96
+ consequence: claudeWorkspaceDropped('rule'),
97
+ }),
98
+ model: cell('native', 'dropped', {
99
+ testId: CLAUDE_TEST,
100
+ consequence: claudeWorkspaceDropped('model'),
101
+ }),
102
+ permission: cell('native', 'dropped', {
103
+ testId: CLAUDE_TEST,
104
+ consequence: claudeWorkspaceDropped('permission'),
105
+ }),
106
+ skill: refused(claudeNotCarried('skills'), 'tests/unit/loader.test.ts'),
107
+ command: refused(claudeNotCarried('commands'), 'tests/unit/loader.test.ts'),
108
+ mcp: refused(claudeNotCarried('MCP servers'), 'tests/unit/loader.test.ts'),
109
+ hook: refused(claudeNotCarried('hooks'), 'tests/unit/loader.test.ts'),
110
+ };
111
+ }
112
+ function opencodeCells(target, testId, workspaceTestId) {
113
+ return {
114
+ rule: cell('native', 'native', { testId }),
115
+ model: cell('native', 'native', { testId }),
116
+ permission: cell('native', 'native', { testId }),
117
+ skill: cell('dropped', 'native', {
118
+ testId: workspaceTestId,
119
+ consequence: opencodeWorkspaceOnly('skill', target),
120
+ }),
121
+ command: cell('dropped', 'native', {
122
+ testId: workspaceTestId,
123
+ consequence: opencodeWorkspaceOnly('command', target),
124
+ }),
125
+ mcp: cell('dropped', 'native', {
126
+ testId: workspaceTestId,
127
+ consequence: opencodeWorkspaceOnly('mcp', target),
128
+ }),
129
+ hook: cell('dropped', 'native', {
130
+ testId: workspaceTestId,
131
+ consequence: opencodeWorkspaceOnly('hook', target),
132
+ }),
133
+ };
134
+ }
135
+ /**
136
+ * The measured record. `renderer.version` must equal the pinned renderer; a
137
+ * test asserts it, so a renderer bump cannot leave a stale matrix silently
138
+ * published.
139
+ */
140
+ export const SNAPSHOT = {
141
+ schemaVersion: 1,
142
+ renderer: { name: 'rulesync', version: '43.11.0' },
143
+ targets: [
144
+ {
145
+ id: DEFAULT_TARGET,
146
+ status: 'promised',
147
+ agentReach: 'subagent',
148
+ cells: claudeCells(),
149
+ permissionKeys: CLAUDE_PERMISSION_KEYS,
150
+ },
151
+ {
152
+ id: OPENCODE_TARGET,
153
+ status: 'promised',
154
+ agentReach: 'primary',
155
+ cells: opencodeCells(OPENCODE_TARGET, OPENCODE_TEST, 'tests/unit/profile-mode.test.ts'),
156
+ permissionKeys: opencodePermissionKeys(OPENCODE_TARGET),
157
+ },
158
+ {
159
+ id: OPENCODE_V1_TARGET,
160
+ status: 'promised',
161
+ agentReach: 'primary',
162
+ cells: opencodeCells(OPENCODE_V1_TARGET, OPENCODE_V1_TEST, 'tests/unit/opencode-v1-target.test.ts'),
163
+ permissionKeys: opencodePermissionKeys(OPENCODE_V1_TARGET),
164
+ },
165
+ ],
166
+ };
167
+ /**
168
+ * Refuse a snapshot that cannot be published. This is the structural guard
169
+ * behind "an unknown cell is never a tick": a promised target must have a
170
+ * measured emission on both axes for every capability. `unknown` remains valid
171
+ * on an unverified target, where the whole row is labelled unverified.
172
+ *
173
+ * F010 is the design's code for a matrix that does not match the build: it
174
+ * fails the report rather than rendering a claim nobody measured.
175
+ */
176
+ export function verifySnapshot(snapshot, rendererVersion) {
177
+ if (rendererVersion !== undefined && snapshot.renderer.version !== rendererVersion) {
178
+ throw new FarnaError('F010_RENDERER_MISMATCH', `the capability snapshot records ${snapshot.renderer.name} ${snapshot.renderer.version} but this build pins ${rendererVersion}`, {
179
+ subject: snapshot.renderer.name,
180
+ action: 'measure the matrix against the pinned renderer and update the snapshot in the same change',
181
+ });
182
+ }
183
+ const ids = snapshot.targets.map((target) => target.id);
184
+ for (const supported of SUPPORTED_TARGETS) {
185
+ const matches = ids.filter((id) => id === supported).length;
186
+ if (matches !== 1) {
187
+ throw new FarnaError('F010_RENDERER_MISMATCH', `the capability snapshot has ${matches} row(s) for the supported target "${supported}"`, {
188
+ subject: supported,
189
+ action: 'give every supported target exactly one measured row',
190
+ });
191
+ }
192
+ }
193
+ for (const target of snapshot.targets) {
194
+ if (target.status !== 'promised') {
195
+ continue;
196
+ }
197
+ for (const capability of MATRIX_CAPABILITIES) {
198
+ const measured = target.cells[capability];
199
+ if (measured.agent === 'unknown' || measured.workspace === 'unknown') {
200
+ throw new FarnaError('F010_RENDERER_MISMATCH', `the promised target "${target.id}" has an unmeasured "${capability}" cell`, {
201
+ subject: `${target.id}/${capability}`,
202
+ action: 'measure the cell, or mark the target unverified',
203
+ });
204
+ }
205
+ }
206
+ }
207
+ }
208
+ /** The one glyph each emission renders as. No value renders blank. */
209
+ export function emissionGlyph(emission) {
210
+ switch (emission) {
211
+ case 'native':
212
+ return '[x]';
213
+ case 'emulated':
214
+ return '[~]';
215
+ case 'dropped':
216
+ return '[ ]';
217
+ case 'unknown':
218
+ return '[?]';
219
+ default: {
220
+ const exhaustive = emission;
221
+ return exhaustive;
222
+ }
223
+ }
224
+ }
225
+ /** The word each emission renders as. `unknown` is always "not measured". */
226
+ export function emissionWord(emission) {
227
+ return emission === 'unknown' ? 'not measured' : emission;
228
+ }
229
+ /** Every permission category, in the product's declared order. */
230
+ export function permissionCategories() {
231
+ return PERMISSION_CATEGORIES;
232
+ }
@@ -0,0 +1,32 @@
1
+ import { type Capability } from '../core/constants.js';
2
+ import { type CapabilityCell, type CapabilitySnapshot, type PermissionKeyCell, type TargetStatus } from '../matrix/snapshot.js';
3
+ import type { PermissionCategory } from '../permissions/permissions.js';
4
+ /**
5
+ * The machine-readable capability report. It is built from the committed
6
+ * snapshot and carries every value the human table prints, so `--json` is the
7
+ * same claim in a shape a pipeline can consume.
8
+ */
9
+ export type CapabilityReport = {
10
+ schemaVersion: 1;
11
+ command: 'report';
12
+ ok: true;
13
+ exitCode: 0;
14
+ renderer: {
15
+ name: string;
16
+ version: string;
17
+ };
18
+ targets: Array<{
19
+ id: string;
20
+ status: TargetStatus;
21
+ agentReach: 'primary' | 'subagent';
22
+ capabilities: Record<Capability, CapabilityCell>;
23
+ permissionKeys: Record<PermissionCategory, PermissionKeyCell>;
24
+ }>;
25
+ };
26
+ export declare function buildCapabilityReport(snapshot?: CapabilitySnapshot): CapabilityReport;
27
+ /**
28
+ * The human table. `unknown` renders as `[?] not measured` and is never
29
+ * printed as `[x]`; every dropped, emulated and unknown cell prints its
30
+ * consequence, so the table never becomes a bare tick a reader can misread.
31
+ */
32
+ export declare function formatCapabilityReport(report: CapabilityReport): string;
@@ -0,0 +1,136 @@
1
+ import { PRODUCT_VERSION } from '../core/constants.js';
2
+ import { escapeControlCharacters } from '../core/text.js';
3
+ import { emissionGlyph, emissionWord, MATRIX_CAPABILITIES, permissionCategories, SNAPSHOT, } from '../matrix/snapshot.js';
4
+ export function buildCapabilityReport(snapshot = SNAPSHOT) {
5
+ return {
6
+ schemaVersion: 1,
7
+ command: 'report',
8
+ ok: true,
9
+ exitCode: 0,
10
+ renderer: { ...snapshot.renderer },
11
+ targets: snapshot.targets.map((target) => ({
12
+ id: target.id,
13
+ status: target.status,
14
+ agentReach: target.agentReach,
15
+ // A copy, never the snapshot object: a caller must not be able to mutate
16
+ // the measured record through a report it was handed.
17
+ capabilities: Object.fromEntries(MATRIX_CAPABILITIES.map((capability) => [capability, { ...target.cells[capability] }])),
18
+ permissionKeys: Object.fromEntries(permissionCategories().map((key) => [key, { ...target.permissionKeys[key] }])),
19
+ })),
20
+ };
21
+ }
22
+ function pad(value, width) {
23
+ return value.length >= width ? `${value} ` : value.padEnd(width);
24
+ }
25
+ const CAPABILITY_WIDTH = 14;
26
+ const TARGET_WIDTH = 17;
27
+ const AXIS_AGENT_WIDTH = 6;
28
+ const AXIS_WORKSPACE_WIDTH = 11;
29
+ /** The non-native axes of a cell, each with its glyph and word. */
30
+ function nonNativeAxes(cell) {
31
+ const axes = [];
32
+ if (cell.agent !== 'native') {
33
+ axes.push(`agent ${emissionGlyph(cell.agent)} ${emissionWord(cell.agent)}`);
34
+ }
35
+ if (cell.workspace !== 'native') {
36
+ axes.push(`workspace ${emissionGlyph(cell.workspace)} ${emissionWord(cell.workspace)}`);
37
+ }
38
+ return axes.join(', ');
39
+ }
40
+ function capabilityTable(report) {
41
+ const lines = ['capability matrix'];
42
+ const header = report.targets.map((target) => pad(target.id, TARGET_WIDTH)).join('');
43
+ lines.push(` ${pad('capability', CAPABILITY_WIDTH)}${header}`.trimEnd());
44
+ const axisHeader = report.targets
45
+ .map(() => `${pad('agent', AXIS_AGENT_WIDTH)}${pad('workspace', AXIS_WORKSPACE_WIDTH)}`)
46
+ .join('');
47
+ lines.push(` ${pad('', CAPABILITY_WIDTH)}${axisHeader}`.trimEnd());
48
+ for (const capability of MATRIX_CAPABILITIES) {
49
+ const cells = report.targets
50
+ .map((target) => {
51
+ const cell = target.capabilities[capability];
52
+ return `${pad(emissionGlyph(cell.agent), AXIS_AGENT_WIDTH)}${pad(emissionGlyph(cell.workspace), AXIS_WORKSPACE_WIDTH)}`;
53
+ })
54
+ .join('');
55
+ lines.push(` ${pad(capability, CAPABILITY_WIDTH)}${cells}`.trimEnd());
56
+ }
57
+ lines.push('', 'consequences');
58
+ let anyConsequence = false;
59
+ for (const target of report.targets) {
60
+ lines.push(` ${escapeControlCharacters(target.id)}`);
61
+ for (const capability of MATRIX_CAPABILITIES) {
62
+ const cell = target.capabilities[capability];
63
+ const axes = nonNativeAxes(cell);
64
+ if (axes === '') {
65
+ continue;
66
+ }
67
+ anyConsequence = true;
68
+ lines.push(` ${pad(capability, 12)}${axes}`);
69
+ if (cell.consequence !== null) {
70
+ lines.push(` ${escapeControlCharacters(cell.consequence)}`);
71
+ }
72
+ }
73
+ }
74
+ if (!anyConsequence) {
75
+ lines.push(' none: every cell is native');
76
+ }
77
+ return lines;
78
+ }
79
+ function permissionTable(report) {
80
+ const keys = permissionCategories();
81
+ const lines = ['', 'permission keys (per persona, agent mode)'];
82
+ const header = report.targets.map((target) => pad(target.id, 13)).join('');
83
+ lines.push(` ${pad('key', 12)}${header}`.trimEnd());
84
+ for (const key of keys) {
85
+ const cells = report.targets
86
+ .map((target) => pad(emissionGlyph(target.permissionKeys[key].emission), 13))
87
+ .join('');
88
+ lines.push(` ${pad(key, 12)}${cells}`.trimEnd());
89
+ }
90
+ lines.push('', 'permission consequences');
91
+ let anyConsequence = false;
92
+ for (const target of report.targets) {
93
+ const entries = [];
94
+ for (const key of keys) {
95
+ const cell = target.permissionKeys[key];
96
+ if (cell.emission === 'native') {
97
+ continue;
98
+ }
99
+ anyConsequence = true;
100
+ const code = cell.code === null ? '' : ` (${cell.code})`;
101
+ entries.push(` ${pad(key, 10)}${emissionGlyph(cell.emission)} ${emissionWord(cell.emission)}${code}`);
102
+ if (cell.consequence !== null) {
103
+ entries.push(` ${escapeControlCharacters(cell.consequence)}`);
104
+ }
105
+ }
106
+ if (entries.length > 0) {
107
+ lines.push(` ${escapeControlCharacters(target.id)}`, ...entries);
108
+ }
109
+ }
110
+ if (!anyConsequence) {
111
+ lines.push(' none: every permission key is native');
112
+ }
113
+ return lines;
114
+ }
115
+ /**
116
+ * The human table. `unknown` renders as `[?] not measured` and is never
117
+ * printed as `[x]`; every dropped, emulated and unknown cell prints its
118
+ * consequence, so the table never becomes a bare tick a reader can misread.
119
+ */
120
+ export function formatCapabilityReport(report) {
121
+ const lines = [
122
+ `farna-bootstrapper report ${PRODUCT_VERSION}`,
123
+ ` renderer ${report.renderer.name} ${report.renderer.version}`,
124
+ ' cells native [x] emulated [~] dropped [ ] not measured [?]',
125
+ ' note the committed measured matrix; the harness remains the authority on runtime behaviour',
126
+ '',
127
+ ...capabilityTable(report),
128
+ ...permissionTable(report),
129
+ '',
130
+ 'labels',
131
+ ...report.targets.map((target) => ` ${pad(target.id, 12)}${pad(escapeControlCharacters(target.status), 12)}reach ${target.agentReach}`),
132
+ '',
133
+ 'report: ok',
134
+ ];
135
+ return `${lines.join('\n')}\n`;
136
+ }
@@ -1,7 +1,14 @@
1
1
  import type { CheckResult } from '../cli/commands/check.js';
2
+ import type { DoctorResult } from '../cli/commands/doctor.js';
2
3
  import type { GenerateResult } from '../cli/commands/generate.js';
3
4
  import type { InitResult } from '../cli/commands/init.js';
4
5
  export declare function formatInit(result: InitResult): string;
5
6
  export declare function formatGenerate(result: GenerateResult): string;
6
7
  export declare function formatCheck(result: CheckResult): string;
8
+ /**
9
+ * The validation report. Every check listed here ran to completion: `doctor`
10
+ * fails at the first error and never prints a partial success, so a check name
11
+ * in this section is evidence the check did not fail.
12
+ */
13
+ export declare function formatDoctor(result: DoctorResult): string;
7
14
  export declare function formatJson(value: unknown): string;
@@ -92,6 +92,48 @@ export function formatCheck(result) {
92
92
  lines.push('', 'check: drift');
93
93
  return `${lines.join('\n')}\n`;
94
94
  }
95
+ /**
96
+ * The validation report. Every check listed here ran to completion: `doctor`
97
+ * fails at the first error and never prints a partial success, so a check name
98
+ * in this section is evidence the check did not fail.
99
+ */
100
+ export function formatDoctor(result) {
101
+ const lines = ['farna-bootstrapper doctor'];
102
+ lines.push(` source ${escapeControlCharacters(result.configPath)}`);
103
+ lines.push(` target ${escapeControlCharacters(result.target)} (${modeLabel(result.mode, result.activePersona)})`);
104
+ lines.push(` personas ${result.counts.personas} in source, ${result.counts.live} live`);
105
+ const notLive = notLiveLine(result.mode, result.notLive);
106
+ if (notLive !== undefined) {
107
+ lines.push(notLive);
108
+ }
109
+ lines.push(` checks ${result.checks.length} ok`);
110
+ lines.push(` warnings ${result.warnings.length}`);
111
+ lines.push('', 'checks');
112
+ for (const check of result.checks) {
113
+ lines.push(` ok ${check.name.padEnd(36)}${escapeControlCharacters(check.detail)}`);
114
+ }
115
+ lines.push('', 'personas');
116
+ for (const persona of result.personas) {
117
+ lines.push(` ${escapeControlCharacters(persona.id)}`);
118
+ lines.push(` chain ${persona.chain.map(escapeControlCharacters).join(' -> ')}`);
119
+ lines.push(` mode ${persona.mode ?? 'subagent (default)'}`);
120
+ lines.push(` model ${persona.model === null ? '<none>' : escapeControlCharacters(persona.model)}`);
121
+ for (const resource of persona.resources) {
122
+ const from = resource.fromPersona === persona.id
123
+ ? ''
124
+ : ` (from ${escapeControlCharacters(resource.fromPersona)}, rank ${resource.rank})`;
125
+ lines.push(` resource ${`${resource.kind}/${resource.id}`.padEnd(28)}${escapeControlCharacters(resource.path)}${from}`);
126
+ }
127
+ }
128
+ if (result.warnings.length > 0) {
129
+ lines.push('', 'warnings');
130
+ for (const entry of result.warnings) {
131
+ lines.push(` ${entry.code} ${entry.severity.padEnd(6)} ${escapeControlCharacters(entry.persona)}: ${escapeControlCharacters(entry.message)}`);
132
+ }
133
+ }
134
+ lines.push('', 'doctor: ok');
135
+ return `${lines.join('\n')}\n`;
136
+ }
95
137
  export function formatJson(value) {
96
138
  return `${JSON.stringify(value, null, 2)}\n`;
97
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "farna-bootstrapper",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Compile named agent personas and resources into the configuration each coding harness reads, and prove that the output still matches the source.",
5
5
  "license": "MIT",
6
6
  "author": "Farnalabs Ltd",