farna-bootstrapper 0.1.0 → 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.
@@ -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
  }
@@ -7,6 +7,11 @@ export declare const personaSchema: z.ZodObject<{
7
7
  purpose: z.ZodString;
8
8
  resources: z.ZodArray<z.ZodString>;
9
9
  model: z.ZodOptional<z.ZodString>;
10
+ mode: z.ZodOptional<z.ZodEnum<{
11
+ primary: "primary";
12
+ subagent: "subagent";
13
+ all: "all";
14
+ }>>;
10
15
  extends: z.ZodOptional<z.ZodString>;
11
16
  }, z.core.$strict>;
12
17
  /**
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { ID_MAX_LENGTH, ID_RE } from '../core/constants.js';
2
+ import { ID_MAX_LENGTH, ID_RE, PERSONA_MODES } from '../core/constants.js';
3
3
  import { PERMISSION_CATEGORIES, PERMISSION_KEYS } from '../permissions/permissions.js';
4
4
  export const idSchema = z.string().regex(ID_RE, 'must be lower-case kebab-case').max(ID_MAX_LENGTH);
5
5
  export const personaSchema = z
@@ -10,6 +10,15 @@ export const personaSchema = z
10
10
  purpose: z.string().min(1).max(120),
11
11
  resources: z.array(z.string().min(1)).max(200),
12
12
  model: idSchema.optional(),
13
+ /**
14
+ * The OpenCode agent mode this persona is emitted with. It is
15
+ * OpenCode-facing: `primary` is selectable as the main agent, `subagent`
16
+ * is callable by another agent, and `all` is both. Absent means the
17
+ * emitted default, `subagent`. A composed persona inherits the base's mode
18
+ * and may override it, so a chain declares at most one effective value.
19
+ * Claude Code has no such concept and reports W117 instead of carrying it.
20
+ */
21
+ mode: z.enum(PERSONA_MODES).optional(),
13
22
  extends: idSchema.optional(),
14
23
  })
15
24
  .superRefine((persona, ctx) => {
@@ -1,7 +1,7 @@
1
1
  import { join } from 'node:path';
2
2
  import { isDeepStrictEqual } from 'node:util';
3
3
  import { parseDocument } from 'yaml';
4
- import { AGENT_FILE_EXT, CLAUDE_AGENTS_DIR, isOpencodeTarget, OPENCODE_AGENTS_DIR, OPENCODE_COMMANDS_DIR, OPENCODE_CONFIG_FILE, OPENCODE_HOOKS_PLUGIN, OPENCODE_SKILLS_DIR, SKILL_FILE_NAME, } from '../core/constants.js';
4
+ import { AGENT_FILE_EXT, CLAUDE_AGENTS_DIR, DEFAULT_PERSONA_MODE, isOpencodeTarget, OPENCODE_AGENTS_DIR, OPENCODE_COMMANDS_DIR, OPENCODE_CONFIG_FILE, OPENCODE_HOOKS_PLUGIN, OPENCODE_SKILLS_DIR, SKILL_FILE_NAME, } from '../core/constants.js';
5
5
  import { declaredNotEmitted } from '../core/errors.js';
6
6
  import { readUtf8File } from '../core/fs.js';
7
7
  import { compareCodepoints } from '../core/json.js';
@@ -222,7 +222,7 @@ function verifyOpencodeV2Agent(persona, source, parsed, managedPath) {
222
222
  }
223
223
  assertKeySet(keys, parsed.frontmatter, persona, managedPath);
224
224
  assertField(parsed.frontmatter, 'description', persona.purpose, managedPath, persona);
225
- assertField(parsed.frontmatter, 'mode', 'subagent', managedPath, persona);
225
+ assertField(parsed.frontmatter, 'mode', persona.mode ?? DEFAULT_PERSONA_MODE, managedPath, persona);
226
226
  assertField(parsed.frontmatter, 'model', persona.model, managedPath, persona);
227
227
  const expectedPermissions = persona.opencode.records;
228
228
  if (expectedPermissions.length === 0) {
@@ -260,7 +260,7 @@ function verifyOpencodeV1Agent(persona, source, parsed, managedPath) {
260
260
  assertKeySet(keys, parsed.frontmatter, persona, managedPath);
261
261
  assertField(parsed.frontmatter, 'name', persona.id, managedPath, persona);
262
262
  assertField(parsed.frontmatter, 'description', persona.purpose, managedPath, persona);
263
- assertField(parsed.frontmatter, 'mode', 'subagent', managedPath, persona);
263
+ assertField(parsed.frontmatter, 'mode', persona.mode ?? DEFAULT_PERSONA_MODE, managedPath, persona);
264
264
  assertField(parsed.frontmatter, 'model', persona.model, managedPath, persona);
265
265
  const expected = {};
266
266
  for (const category of persona.opencode.permission) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "farna-bootstrapper",
3
- "version": "0.1.0",
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",