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 +69 -0
- package/README.md +119 -48
- package/dist/cli/commands/doctor.d.ts +64 -0
- package/dist/cli/commands/doctor.js +101 -0
- package/dist/cli/commands/report.d.ts +11 -0
- package/dist/cli/commands/report.js +16 -0
- package/dist/cli/program.d.ts +1 -1
- package/dist/cli/program.js +45 -4
- package/dist/compose/resolve.js +1 -1
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.js +2 -2
- package/dist/matrix/snapshot.d.ts +87 -0
- package/dist/matrix/snapshot.js +232 -0
- package/dist/permissions/permissions.d.ts +1 -1
- package/dist/permissions/permissions.js +1 -1
- package/dist/render/upstream.js +2 -2
- package/dist/report/capability.d.ts +32 -0
- package/dist/report/capability.js +136 -0
- package/dist/report/format.d.ts +7 -0
- package/dist/report/format.js +42 -0
- package/dist/source/load.js +1 -1
- package/dist/verify/containment.js +64 -8
- package/package.json +2 -2
package/dist/cli/program.js
CHANGED
|
@@ -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 {
|
|
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
|
|
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,
|
|
76
|
-
.addHelpText('after', `\
|
|
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()
|
package/dist/compose/resolve.js
CHANGED
|
@@ -180,7 +180,7 @@ function sortResources(resources) {
|
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Why OpenCode cannot carry this hook, or `undefined` when it can. Measured at
|
|
183
|
-
* rulesync 43.
|
|
183
|
+
* rulesync 43.13.0: `session-end` has no OpenCode event, and a matcher is
|
|
184
184
|
* honoured only on the tool events (`preToolUse`/`postToolUse`).
|
|
185
185
|
*/
|
|
186
186
|
function hookProblem(hook) {
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -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.
|
|
8
|
+
export declare const PRODUCT_VERSION = "0.1.3";
|
|
9
9
|
/** The one source/schema version this build understands. */
|
|
10
10
|
export declare const SCHEMA_VERSION: 1;
|
|
11
11
|
/**
|
|
@@ -126,7 +126,7 @@ export declare const CLAUDE_AGENTS_DIR = ".claude/agents";
|
|
|
126
126
|
/**
|
|
127
127
|
* The OpenCode paths this slice writes, relative to the repository root.
|
|
128
128
|
* `commands` is plural and the workspace config is `opencode.jsonc`, both
|
|
129
|
-
* measured at rulesync 43.
|
|
129
|
+
* measured at rulesync 43.13.0.
|
|
130
130
|
*/
|
|
131
131
|
export declare const OPENCODE_DIR = ".opencode";
|
|
132
132
|
export declare const OPENCODE_AGENTS_DIR = ".opencode/agents";
|
package/dist/core/constants.js
CHANGED
|
@@ -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.
|
|
8
|
+
export const PRODUCT_VERSION = '0.1.3';
|
|
9
9
|
/** The one source/schema version this build understands. */
|
|
10
10
|
export const SCHEMA_VERSION = 1;
|
|
11
11
|
/**
|
|
@@ -125,7 +125,7 @@ export const CLAUDE_AGENTS_DIR = `${CLAUDE_DIR}/agents`;
|
|
|
125
125
|
/**
|
|
126
126
|
* The OpenCode paths this slice writes, relative to the repository root.
|
|
127
127
|
* `commands` is plural and the workspace config is `opencode.jsonc`, both
|
|
128
|
-
* measured at rulesync 43.
|
|
128
|
+
* measured at rulesync 43.13.0.
|
|
129
129
|
*/
|
|
130
130
|
export const OPENCODE_DIR = '.opencode';
|
|
131
131
|
export const OPENCODE_AGENTS_DIR = `${OPENCODE_DIR}/agents`;
|
|
@@ -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.13.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
|
+
}
|
|
@@ -99,7 +99,7 @@ export type OpencodePermissionMapping = {
|
|
|
99
99
|
};
|
|
100
100
|
/**
|
|
101
101
|
* Map a persona's resolved permission map onto OpenCode's ordered permission
|
|
102
|
-
* records. Measured at rulesync 43.
|
|
102
|
+
* records. Measured at rulesync 43.13.0: `bash` becomes `shell`, `task` becomes
|
|
103
103
|
* `subagent`, and `write` folds into `edit` (there is no write category). The
|
|
104
104
|
* fold is reported as W112 when a write-derived allow is emitted without a
|
|
105
105
|
* matching edit declaration. `ask` becomes deny (W111).
|
|
@@ -277,7 +277,7 @@ function stricterWinner(a, b) {
|
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
279
|
* Map a persona's resolved permission map onto OpenCode's ordered permission
|
|
280
|
-
* records. Measured at rulesync 43.
|
|
280
|
+
* records. Measured at rulesync 43.13.0: `bash` becomes `shell`, `task` becomes
|
|
281
281
|
* `subagent`, and `write` folds into `edit` (there is no write category). The
|
|
282
282
|
* fold is reported as W112 when a write-derived allow is emitted without a
|
|
283
283
|
* matching edit declaration. `ask` becomes deny (W111).
|
package/dist/render/upstream.js
CHANGED
|
@@ -26,8 +26,8 @@ import { installedRendererIdentity, integrityRecordOf } from './identity.js';
|
|
|
26
26
|
*/
|
|
27
27
|
export const RENDERER_PIN = {
|
|
28
28
|
name: 'rulesync',
|
|
29
|
-
version: '43.
|
|
30
|
-
integrity: 'sha512-
|
|
29
|
+
version: '43.13.0',
|
|
30
|
+
integrity: 'sha512-fGOfX/kbs089e2nPDNZtf/nY/eNKIgM8n5Mer6f+A2ZQlxjVTjBHS60O847aCV/kZIwHHUIXASgh6aRv3VlR9w==',
|
|
31
31
|
};
|
|
32
32
|
let loaded;
|
|
33
33
|
async function loadRenderer() {
|
|
@@ -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
|
+
}
|
package/dist/report/format.d.ts
CHANGED
|
@@ -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;
|