special-agents 0.3.6 → 0.4.0

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.
Files changed (36) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +2 -2
  3. package/content/docs/features.md +1 -2
  4. package/content/rules/domain/ai-cost.md +3 -3
  5. package/content/rules/domain/ai-evals.md +2 -2
  6. package/content/rules/domain/ai-governance.md +2 -2
  7. package/content/rules/domain/ai-safety.md +2 -2
  8. package/content/rules/domain/data-governance.md +2 -2
  9. package/content/rules/domain/observability.md +2 -2
  10. package/content/rules/domain/scalability.md +2 -2
  11. package/content/rules/packs.index.yaml +12 -12
  12. package/content/rules/process/architecture.md +4 -4
  13. package/content/rules/process/business-docs.md +2 -2
  14. package/content/rules/process/project-docs.md +19 -19
  15. package/content/rules/process/release.md +2 -2
  16. package/content/rules/process/tickets.md +2 -2
  17. package/content/rules/templated/database.md +1 -1
  18. package/content/rules/templated/infra.md +1 -1
  19. package/dist/compile.d.ts +1 -1
  20. package/dist/compile.js +9 -5
  21. package/dist/content.d.ts +1 -0
  22. package/dist/content.js +2 -1
  23. package/package.json +21 -13
  24. package/node_modules/rafi-spec/dist/index.d.ts +0 -4
  25. package/node_modules/rafi-spec/dist/index.js +0 -4
  26. package/node_modules/rafi-spec/dist/schemas.d.ts +0 -245
  27. package/node_modules/rafi-spec/dist/schemas.js +0 -121
  28. package/node_modules/rafi-spec/dist/types.d.ts +0 -129
  29. package/node_modules/rafi-spec/dist/types.js +0 -6
  30. package/node_modules/rafi-spec/dist/validate.d.ts +0 -16
  31. package/node_modules/rafi-spec/dist/validate.js +0 -40
  32. package/node_modules/rafi-spec/package.json +0 -35
  33. package/node_modules/rafi-spec/src/index.ts +0 -19
  34. package/node_modules/rafi-spec/src/schemas.ts +0 -130
  35. package/node_modules/rafi-spec/src/types.ts +0 -156
  36. package/node_modules/rafi-spec/src/validate.ts +0 -60
package/dist/content.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare function parseRulePack(raw: string): RulePack;
7
7
  export interface Defaults {
8
8
  stack: Record<string, string>;
9
9
  flags: Record<string, boolean>;
10
+ docsRoot?: string;
10
11
  }
11
12
  /** Read content/defaults.yaml. */
12
13
  export declare function loadDefaults(): Defaults;
package/dist/content.js CHANGED
@@ -27,7 +27,8 @@ export function parseRulePack(raw) {
27
27
  }
28
28
  /** Read content/defaults.yaml. */
29
29
  export function loadDefaults() {
30
- return parseYaml(readFileSync(join(CONTENT_DIR, "defaults.yaml"), "utf8"));
30
+ const defaults = parseYaml(readFileSync(join(CONTENT_DIR, "defaults.yaml"), "utf8"));
31
+ return { ...defaults, docsRoot: defaults.docsRoot ?? "docs" };
31
32
  }
32
33
  /** The flattened-rules-doc preamble (everything before the first section). */
33
34
  export function loadPreamble() {
package/package.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
2
  "name": "special-agents",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "description": "Rafi library: composable best-practice rules, skills, and agents for Claude Code and Codex.",
5
+ "license": "Apache-2.0",
5
6
  "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ttante/rafi.git",
10
+ "directory": "packages/special-agents"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ttante/rafi/issues"
14
+ },
15
+ "homepage": "https://github.com/ttante/rafi/tree/main/packages/special-agents#readme",
6
16
  "main": "./dist/index.js",
7
17
  "types": "./dist/index.d.ts",
8
18
  "exports": {
@@ -14,27 +24,25 @@
14
24
  "files": [
15
25
  "dist",
16
26
  "content",
17
- "README.md"
27
+ "README.md",
28
+ "LICENSE"
18
29
  ],
30
+ "scripts": {
31
+ "build": "tsc -p tsconfig.build.json",
32
+ "typecheck": "tsc --noEmit",
33
+ "test": "tsx --test test/*.test.ts"
34
+ },
19
35
  "engines": {
20
36
  "node": ">=20"
21
37
  },
22
- "bundledDependencies": [
23
- "rafi-spec"
24
- ],
25
38
  "dependencies": {
39
+ "rafi-spec": "0.4.0",
26
40
  "ajv": "^8.20.0",
27
- "yaml": "^2.5.1",
28
- "rafi-spec": "0.0.0"
41
+ "yaml": "^2.5.1"
29
42
  },
30
43
  "devDependencies": {
31
44
  "@types/node": "^20.14.0",
32
45
  "tsx": "^4.19.0",
33
46
  "typescript": "^5.6.0"
34
- },
35
- "scripts": {
36
- "build": "tsc -p tsconfig.build.json",
37
- "typecheck": "tsc --noEmit",
38
- "test": "tsx --test test/*.test.ts"
39
47
  }
40
- }
48
+ }
@@ -1,4 +0,0 @@
1
- /** Rafi neutral schema — public surface. */
2
- export * from "./types.js";
3
- export { rulePackSchema, skillManifestSchema, agentManifestSchema, projectConfigSchema, } from "./schemas.js";
4
- export { type ValidationResult, validateRulePack, validateSkillManifest, validateAgentManifest, validateProjectConfig, assertRulePack, assertSkillManifest, assertAgentManifest, assertProjectConfig, } from "./validate.js";
@@ -1,4 +0,0 @@
1
- /** Rafi neutral schema — public surface. */
2
- export * from "./types.js";
3
- export { rulePackSchema, skillManifestSchema, agentManifestSchema, projectConfigSchema, } from "./schemas.js";
4
- export { validateRulePack, validateSkillManifest, validateAgentManifest, validateProjectConfig, assertRulePack, assertSkillManifest, assertAgentManifest, assertProjectConfig, } from "./validate.js";
@@ -1,245 +0,0 @@
1
- /**
2
- * JSON Schemas (draft-07) for the neutral types in {@link ./types}. Kept in lockstep
3
- * with those interfaces; validated by {@link ./validate}.
4
- */
5
- export declare const rulePackSchema: {
6
- readonly $id: "rafi/rulePack";
7
- readonly type: "object";
8
- readonly additionalProperties: false;
9
- readonly required: readonly ["name", "category", "description", "condition", "template"];
10
- readonly properties: {
11
- readonly name: {
12
- readonly type: "string";
13
- readonly pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$";
14
- };
15
- readonly category: {
16
- readonly enum: readonly ["base", "process", "domain", "templated"];
17
- };
18
- readonly description: {
19
- readonly type: "string";
20
- readonly minLength: 1;
21
- };
22
- readonly condition: {
23
- readonly enum: readonly ["always", "frontend", "ai", "cloud", "backend"];
24
- };
25
- readonly template: {
26
- readonly type: "boolean";
27
- };
28
- readonly supersededByForeman: {
29
- readonly type: "boolean";
30
- };
31
- readonly body: {
32
- readonly type: "string";
33
- };
34
- };
35
- };
36
- export declare const skillManifestSchema: {
37
- readonly $id: "rafi/skillManifest";
38
- readonly type: "object";
39
- readonly additionalProperties: false;
40
- readonly required: readonly ["name", "description"];
41
- readonly properties: {
42
- readonly name: {
43
- readonly type: "string";
44
- readonly pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$";
45
- };
46
- readonly description: {
47
- readonly type: "string";
48
- readonly minLength: 1;
49
- };
50
- readonly pins: {
51
- readonly type: "array";
52
- readonly items: {
53
- readonly type: "string";
54
- };
55
- };
56
- readonly codexPriority: {
57
- readonly enum: readonly ["inline", "reference"];
58
- };
59
- readonly body: {
60
- readonly type: "string";
61
- };
62
- };
63
- };
64
- export declare const agentManifestSchema: {
65
- readonly $id: "rafi/agentManifest";
66
- readonly type: "object";
67
- readonly additionalProperties: false;
68
- readonly required: readonly ["name", "description", "role", "packs", "skills"];
69
- readonly properties: {
70
- readonly name: {
71
- readonly type: "string";
72
- readonly pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$";
73
- };
74
- readonly description: {
75
- readonly type: "string";
76
- readonly minLength: 1;
77
- };
78
- readonly role: {
79
- readonly enum: readonly ["builder", "qa", "planner", "ticket-maker"];
80
- };
81
- readonly packs: {
82
- readonly type: "array";
83
- readonly items: {
84
- readonly type: "string";
85
- };
86
- };
87
- readonly skills: {
88
- readonly type: "array";
89
- readonly items: {
90
- readonly type: "string";
91
- };
92
- };
93
- readonly conditionalPacks: {
94
- readonly type: "object";
95
- readonly additionalProperties: false;
96
- readonly properties: {
97
- readonly ai: {
98
- readonly type: "array";
99
- readonly items: {
100
- readonly type: "string";
101
- };
102
- };
103
- readonly frontend: {
104
- readonly type: "array";
105
- readonly items: {
106
- readonly type: "string";
107
- };
108
- };
109
- readonly cloud: {
110
- readonly type: "array";
111
- readonly items: {
112
- readonly type: "string";
113
- };
114
- };
115
- readonly backend: {
116
- readonly type: "array";
117
- readonly items: {
118
- readonly type: "string";
119
- };
120
- };
121
- };
122
- };
123
- readonly model: {
124
- readonly type: readonly ["string", "null"];
125
- };
126
- readonly effort: {
127
- readonly type: readonly ["string", "null"];
128
- readonly enum: readonly ["low", "medium", "high", "xhigh", null];
129
- };
130
- };
131
- };
132
- export declare const projectConfigSchema: {
133
- readonly $id: "rafi/projectConfig";
134
- readonly type: "object";
135
- readonly additionalProperties: false;
136
- readonly required: readonly ["appName", "timezone", "stack", "flags", "harness", "agent_files", "agents", "skills"];
137
- readonly properties: {
138
- readonly appName: {
139
- readonly type: "string";
140
- readonly minLength: 1;
141
- };
142
- readonly timezone: {
143
- readonly type: "string";
144
- readonly minLength: 1;
145
- };
146
- readonly stack: {
147
- type: string;
148
- additionalProperties: boolean;
149
- required: string[];
150
- properties: {
151
- [k: string]: {
152
- type: string;
153
- minLength: number;
154
- };
155
- };
156
- };
157
- readonly flags: {
158
- type: string;
159
- additionalProperties: boolean;
160
- required: string[];
161
- properties: {
162
- [k: string]: {
163
- type: string;
164
- };
165
- };
166
- };
167
- readonly harness: {
168
- readonly type: "object";
169
- readonly additionalProperties: false;
170
- readonly required: readonly ["targets", "qa"];
171
- readonly properties: {
172
- readonly targets: {
173
- readonly type: "array";
174
- readonly minItems: 1;
175
- readonly items: {
176
- readonly enum: readonly ["claude", "codex"];
177
- };
178
- };
179
- readonly qa: {
180
- readonly type: "boolean";
181
- };
182
- };
183
- };
184
- readonly agent_files: {
185
- readonly type: "object";
186
- readonly additionalProperties: false;
187
- readonly required: readonly ["mode", "codex", "claude"];
188
- readonly properties: {
189
- readonly mode: {
190
- readonly enum: readonly ["append", "update", "overwrite"];
191
- };
192
- readonly codex: {
193
- readonly type: "string";
194
- readonly minLength: 1;
195
- };
196
- readonly claude: {
197
- readonly type: "string";
198
- readonly minLength: 1;
199
- };
200
- };
201
- };
202
- readonly agents: {
203
- readonly type: "object";
204
- readonly additionalProperties: {
205
- readonly type: "object";
206
- readonly additionalProperties: false;
207
- readonly required: readonly ["artifact_source", "claude", "codex"];
208
- readonly properties: {
209
- readonly artifact_source: {
210
- readonly enum: readonly ["rafi", "existing"];
211
- };
212
- readonly claude: {
213
- readonly type: "string";
214
- readonly minLength: 1;
215
- };
216
- readonly codex: {
217
- readonly type: "string";
218
- readonly minLength: 1;
219
- };
220
- };
221
- };
222
- };
223
- readonly skills: {
224
- readonly type: "object";
225
- readonly additionalProperties: {
226
- readonly type: "object";
227
- readonly additionalProperties: false;
228
- readonly required: readonly ["artifact_source", "claude", "codex"];
229
- readonly properties: {
230
- readonly artifact_source: {
231
- readonly enum: readonly ["rafi", "existing"];
232
- };
233
- readonly claude: {
234
- readonly type: "string";
235
- readonly minLength: 1;
236
- };
237
- readonly codex: {
238
- readonly type: "string";
239
- readonly minLength: 1;
240
- };
241
- };
242
- };
243
- };
244
- };
245
- };
@@ -1,121 +0,0 @@
1
- /**
2
- * JSON Schemas (draft-07) for the neutral types in {@link ./types}. Kept in lockstep
3
- * with those interfaces; validated by {@link ./validate}.
4
- */
5
- const KEBAB = "^[a-z0-9]+(?:-[a-z0-9]+)*$";
6
- export const rulePackSchema = {
7
- $id: "rafi/rulePack",
8
- type: "object",
9
- additionalProperties: false,
10
- required: ["name", "category", "description", "condition", "template"],
11
- properties: {
12
- name: { type: "string", pattern: KEBAB },
13
- category: { enum: ["base", "process", "domain", "templated"] },
14
- description: { type: "string", minLength: 1 },
15
- condition: { enum: ["always", "frontend", "ai", "cloud", "backend"] },
16
- template: { type: "boolean" },
17
- supersededByForeman: { type: "boolean" },
18
- body: { type: "string" },
19
- },
20
- };
21
- export const skillManifestSchema = {
22
- $id: "rafi/skillManifest",
23
- type: "object",
24
- additionalProperties: false,
25
- required: ["name", "description"],
26
- properties: {
27
- name: { type: "string", pattern: KEBAB },
28
- description: { type: "string", minLength: 1 },
29
- pins: { type: "array", items: { type: "string" } },
30
- codexPriority: { enum: ["inline", "reference"] },
31
- body: { type: "string" },
32
- },
33
- };
34
- export const agentManifestSchema = {
35
- $id: "rafi/agentManifest",
36
- type: "object",
37
- additionalProperties: false,
38
- required: ["name", "description", "role", "packs", "skills"],
39
- properties: {
40
- name: { type: "string", pattern: KEBAB },
41
- description: { type: "string", minLength: 1 },
42
- role: { enum: ["builder", "qa", "planner", "ticket-maker"] },
43
- packs: { type: "array", items: { type: "string" } },
44
- skills: { type: "array", items: { type: "string" } },
45
- conditionalPacks: {
46
- type: "object",
47
- additionalProperties: false,
48
- properties: {
49
- ai: { type: "array", items: { type: "string" } },
50
- frontend: { type: "array", items: { type: "string" } },
51
- cloud: { type: "array", items: { type: "string" } },
52
- backend: { type: "array", items: { type: "string" } },
53
- },
54
- },
55
- model: { type: ["string", "null"] },
56
- effort: { type: ["string", "null"], enum: ["low", "medium", "high", "xhigh", null] },
57
- },
58
- };
59
- const stringRecord = (keys) => ({
60
- type: "object",
61
- additionalProperties: false,
62
- required: keys,
63
- properties: Object.fromEntries(keys.map((k) => [k, { type: "string", minLength: 1 }])),
64
- });
65
- const boolRecord = (keys) => ({
66
- type: "object",
67
- additionalProperties: false,
68
- required: keys,
69
- properties: Object.fromEntries(keys.map((k) => [k, { type: "boolean" }])),
70
- });
71
- const runtimeArtifactPaths = {
72
- type: "object",
73
- additionalProperties: false,
74
- required: ["artifact_source", "claude", "codex"],
75
- properties: {
76
- artifact_source: { enum: ["rafi", "existing"] },
77
- claude: { type: "string", minLength: 1 },
78
- codex: { type: "string", minLength: 1 },
79
- },
80
- };
81
- const artifactPathMap = {
82
- type: "object",
83
- additionalProperties: runtimeArtifactPaths,
84
- };
85
- export const projectConfigSchema = {
86
- $id: "rafi/projectConfig",
87
- type: "object",
88
- additionalProperties: false,
89
- required: ["appName", "timezone", "stack", "flags", "harness", "agent_files", "agents", "skills"],
90
- properties: {
91
- appName: { type: "string", minLength: 1 },
92
- timezone: { type: "string", minLength: 1 },
93
- stack: stringRecord(["frontend", "backend", "database", "cloud", "packageManager"]),
94
- flags: boolRecord(["hasFrontend", "usesAI", "runsInCloud"]),
95
- harness: {
96
- type: "object",
97
- additionalProperties: false,
98
- required: ["targets", "qa"],
99
- properties: {
100
- targets: {
101
- type: "array",
102
- minItems: 1,
103
- items: { enum: ["claude", "codex"] },
104
- },
105
- qa: { type: "boolean" },
106
- },
107
- },
108
- agent_files: {
109
- type: "object",
110
- additionalProperties: false,
111
- required: ["mode", "codex", "claude"],
112
- properties: {
113
- mode: { enum: ["append", "update", "overwrite"] },
114
- codex: { type: "string", minLength: 1 },
115
- claude: { type: "string", minLength: 1 },
116
- },
117
- },
118
- agents: artifactPathMap,
119
- skills: artifactPathMap,
120
- },
121
- };
@@ -1,129 +0,0 @@
1
- /**
2
- * Rafi neutral schema — the shapes that the `special-agents` library and the
3
- * `ai-foreman` runtime must agree on. Authoring inputs (rule packs, skills,
4
- * agent manifests) and the per-project configuration that drives composition.
5
- */
6
- /** Which category a rule pack belongs to (drives default load behavior). */
7
- export type PackCategory = "base" | "process" | "domain" | "templated";
8
- /**
9
- * When a pack applies. `always` packs load for every project; the others load
10
- * only when the matching project flag is on (see {@link ProjectFlags}).
11
- */
12
- export type PackCondition = "always" | "frontend" | "ai" | "cloud" | "backend";
13
- /** The YAML front-matter carried by each rule pack markdown file. */
14
- export interface RulePackFrontmatter {
15
- /** Unique, kebab-case identifier (e.g. `security`). */
16
- name: string;
17
- category: PackCategory;
18
- /** One-line summary used in indexes and pack pickers. */
19
- description: string;
20
- condition: PackCondition;
21
- /** True when the body contains `{{placeholders}}` / `{{#if}}` directives. */
22
- template: boolean;
23
- /** When true, the pack is omitted while the foreman ticket tracker is active. */
24
- supersededByForeman?: boolean;
25
- }
26
- /** A fully loaded rule pack: its front-matter plus the markdown body. */
27
- export interface RulePack extends RulePackFrontmatter {
28
- /** The rule text (bullets) below the front-matter. */
29
- body: string;
30
- }
31
- /** How a skill should be treated when flattening for Codex (which can't lazy-load). */
32
- export type CodexPriority = "inline" | "reference";
33
- /**
34
- * A skill manifest. Keeps the existing Anthropic `SKILL.md` format and adds two
35
- * optional composition fields that non-Rafi tools can safely ignore.
36
- */
37
- export interface SkillManifest {
38
- /** Unique, kebab-case identifier matching the skill directory name. */
39
- name: string;
40
- /** One-line trigger description (the cheap progressive-disclosure index). */
41
- description: string;
42
- /** Rule packs this skill wants loaded alongside it. */
43
- pins?: string[];
44
- /** Whether Codex flattening should inline this skill's body or just reference it. */
45
- codexPriority?: CodexPriority;
46
- /** The skill body (instructions). Optional in metadata-only contexts. */
47
- body?: string;
48
- }
49
- /** The role an agent fills, mapped to an ai-foreman turn-type or command. */
50
- export type AgentRole = "builder" | "qa" | "planner" | "ticket-maker";
51
- /** Reasoning effort levels accepted by the builders. */
52
- export type EffortLevel = "low" | "medium" | "high" | "xhigh";
53
- /** Packs added to a role only when the matching project flag is on. */
54
- export interface ConditionalPacks {
55
- ai?: string[];
56
- frontend?: string[];
57
- cloud?: string[];
58
- backend?: string[];
59
- }
60
- /**
61
- * A role manifest: a named composition of rule packs + skills that the runtime
62
- * loads for a given turn-type.
63
- */
64
- export interface AgentManifest {
65
- /** Unique, kebab-case identifier (usually equals {@link role}). */
66
- name: string;
67
- description: string;
68
- role: AgentRole;
69
- /** Pack references; globs like `base/*` are allowed and expanded at compile time. */
70
- packs: string[];
71
- /** Skill names this role preloads. */
72
- skills: string[];
73
- /** Extra packs gated on project flags. */
74
- conditionalPacks?: ConditionalPacks;
75
- /** Model override; null inherits the runtime's `--model`. */
76
- model?: string | null;
77
- /** Effort override; null inherits the runtime's `--effort`. */
78
- effort?: EffortLevel | null;
79
- }
80
- /** Which harness targets to emit native config for. */
81
- export type HarnessTarget = "claude" | "codex";
82
- /** The stack choices collected by `rafi create` (free-text strings). */
83
- export interface ProjectStack {
84
- frontend: string;
85
- backend: string;
86
- database: string;
87
- cloud: string;
88
- packageManager: string;
89
- }
90
- /** Boolean flags that gate conditional packs and docs. */
91
- export interface ProjectFlags {
92
- hasFrontend: boolean;
93
- usesAI: boolean;
94
- runsInCloud: boolean;
95
- }
96
- /** Harness emission + QA preferences. */
97
- export interface HarnessConfig {
98
- targets: HarnessTarget[];
99
- qa: boolean;
100
- }
101
- /** How Rafi should handle existing root instruction files. */
102
- export type AgentFileMode = "append" | "update" | "overwrite";
103
- /** Root instruction files used by Codex and Claude. */
104
- export interface AgentFilesConfig {
105
- mode: AgentFileMode;
106
- codex: string;
107
- claude: string;
108
- }
109
- /** Per-runtime paths for a skill or agent artifact. */
110
- export type ArtifactSource = "rafi" | "existing";
111
- export interface RuntimeArtifactConfig {
112
- artifact_source: ArtifactSource;
113
- claude: string;
114
- codex: string;
115
- }
116
- /**
117
- * The committed `rafi-config.yaml` in a target repo. Skipping the walkthrough uses
118
- * the library defaults, which reproduce today's hardcoded guidance.
119
- */
120
- export interface ProjectConfig {
121
- appName: string;
122
- timezone: string;
123
- stack: ProjectStack;
124
- flags: ProjectFlags;
125
- harness: HarnessConfig;
126
- agent_files: AgentFilesConfig;
127
- agents: Record<string, RuntimeArtifactConfig>;
128
- skills: Record<string, RuntimeArtifactConfig>;
129
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Rafi neutral schema — the shapes that the `special-agents` library and the
3
- * `ai-foreman` runtime must agree on. Authoring inputs (rule packs, skills,
4
- * agent manifests) and the per-project configuration that drives composition.
5
- */
6
- export {};
@@ -1,16 +0,0 @@
1
- import type { RulePackFrontmatter, SkillManifest, AgentManifest, ProjectConfig } from "./types.js";
2
- /** Outcome of validating a value against one of the neutral schemas. */
3
- export interface ValidationResult {
4
- valid: boolean;
5
- /** Human-readable messages; empty when valid. */
6
- errors: string[];
7
- }
8
- export declare const validateRulePack: (d: unknown) => ValidationResult;
9
- export declare const validateSkillManifest: (d: unknown) => ValidationResult;
10
- export declare const validateAgentManifest: (d: unknown) => ValidationResult;
11
- export declare const validateProjectConfig: (d: unknown) => ValidationResult;
12
- /** Validate and narrow, throwing on failure. */
13
- export declare function assertRulePack(d: unknown): asserts d is RulePackFrontmatter;
14
- export declare function assertSkillManifest(d: unknown): asserts d is SkillManifest;
15
- export declare function assertAgentManifest(d: unknown): asserts d is AgentManifest;
16
- export declare function assertProjectConfig(d: unknown): asserts d is ProjectConfig;
@@ -1,40 +0,0 @@
1
- /** ajv-backed validation for the neutral schemas. */
2
- import { Ajv } from "ajv";
3
- import { rulePackSchema, skillManifestSchema, agentManifestSchema, projectConfigSchema, } from "./schemas.js";
4
- const ajv = new Ajv({ allErrors: true, allowUnionTypes: true });
5
- function run(fn, data) {
6
- const valid = fn(data);
7
- if (valid)
8
- return { valid: true, errors: [] };
9
- const errors = (fn.errors ?? []).map((e) => `${e.instancePath || "(root)"} ${e.message ?? "is invalid"}`.trim());
10
- return { valid: false, errors };
11
- }
12
- const vRulePack = ajv.compile(rulePackSchema);
13
- const vSkill = ajv.compile(skillManifestSchema);
14
- const vAgent = ajv.compile(agentManifestSchema);
15
- const vProject = ajv.compile(projectConfigSchema);
16
- export const validateRulePack = (d) => run(vRulePack, d);
17
- export const validateSkillManifest = (d) => run(vSkill, d);
18
- export const validateAgentManifest = (d) => run(vAgent, d);
19
- export const validateProjectConfig = (d) => run(vProject, d);
20
- /** Validate and narrow, throwing on failure. */
21
- export function assertRulePack(d) {
22
- const r = validateRulePack(d);
23
- if (!r.valid)
24
- throw new Error(`Invalid rule pack: ${r.errors.join("; ")}`);
25
- }
26
- export function assertSkillManifest(d) {
27
- const r = validateSkillManifest(d);
28
- if (!r.valid)
29
- throw new Error(`Invalid skill manifest: ${r.errors.join("; ")}`);
30
- }
31
- export function assertAgentManifest(d) {
32
- const r = validateAgentManifest(d);
33
- if (!r.valid)
34
- throw new Error(`Invalid agent manifest: ${r.errors.join("; ")}`);
35
- }
36
- export function assertProjectConfig(d) {
37
- const r = validateProjectConfig(d);
38
- if (!r.valid)
39
- throw new Error(`Invalid project config: ${r.errors.join("; ")}`);
40
- }