special-agents 0.1.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.
- package/README.md +69 -0
- package/content/agents/builder.yaml +25 -0
- package/content/agents/planner.yaml +13 -0
- package/content/agents/qa.yaml +16 -0
- package/content/agents/ticket-maker.yaml +11 -0
- package/content/defaults.yaml +13 -0
- package/content/docs/README.md +42 -0
- package/content/docs/admins.md +46 -0
- package/content/docs/ai-costs.md +38 -0
- package/content/docs/ai-evals.md +55 -0
- package/content/docs/ai.md +141 -0
- package/content/docs/api.md +51 -0
- package/content/docs/architecture.md +61 -0
- package/content/docs/business.md +49 -0
- package/content/docs/data-governance.md +67 -0
- package/content/docs/decisions/0000-template.md +29 -0
- package/content/docs/decisions/README.md +30 -0
- package/content/docs/docs.index.yaml +25 -0
- package/content/docs/features.md +41 -0
- package/content/docs/local-cloud.md +58 -0
- package/content/docs/operations.md +69 -0
- package/content/docs/release-checklist.md +56 -0
- package/content/docs/scalability.md +81 -0
- package/content/docs/security.md +82 -0
- package/content/docs/tickets.md +45 -0
- package/content/docs/users.md +43 -0
- package/content/preamble.md +13 -0
- package/content/rules/base/code-quality.md +20 -0
- package/content/rules/base/core.md +17 -0
- package/content/rules/base/definition-of-done.md +21 -0
- package/content/rules/base/git-safety.md +16 -0
- package/content/rules/base/response-expectations.md +18 -0
- package/content/rules/domain/accessibility.md +14 -0
- package/content/rules/domain/ai-cost.md +21 -0
- package/content/rules/domain/ai-evals.md +25 -0
- package/content/rules/domain/ai-governance.md +16 -0
- package/content/rules/domain/ai-reproducibility.md +19 -0
- package/content/rules/domain/ai-safety.md +19 -0
- package/content/rules/domain/data-governance.md +17 -0
- package/content/rules/domain/observability.md +18 -0
- package/content/rules/domain/robustness.md +21 -0
- package/content/rules/domain/scalability.md +18 -0
- package/content/rules/domain/security.md +28 -0
- package/content/rules/packs.index.yaml +177 -0
- package/content/rules/process/api-docs.md +16 -0
- package/content/rules/process/architecture.md +14 -0
- package/content/rules/process/business-docs.md +13 -0
- package/content/rules/process/ci.md +18 -0
- package/content/rules/process/dependencies.md +17 -0
- package/content/rules/process/project-docs.md +35 -0
- package/content/rules/process/release.md +16 -0
- package/content/rules/process/tdd.md +16 -0
- package/content/rules/process/testing.md +28 -0
- package/content/rules/process/tickets.md +17 -0
- package/content/rules/templated/database.md +16 -0
- package/content/rules/templated/infra.md +18 -0
- package/content/rules/templated/stack.md +19 -0
- package/content/skills/better-sqlite3-rebuild/SKILL.md +14 -0
- package/content/skills/grill-me/SKILL.md +10 -0
- package/content/skills/improve-codebase-architecture/REFERENCE.md +78 -0
- package/content/skills/improve-codebase-architecture/SKILL.md +76 -0
- package/content/skills/prd-to-issues/SKILL.md +92 -0
- package/content/skills/tdd/SKILL.md +107 -0
- package/content/skills/tdd/deep-modules.md +33 -0
- package/content/skills/tdd/interface-design.md +31 -0
- package/content/skills/tdd/mocking.md +59 -0
- package/content/skills/tdd/refactoring.md +10 -0
- package/content/skills/tdd/tests.md +61 -0
- package/content/skills/write-a-prd/SKILL.md +74 -0
- package/dist/agents.d.ts +11 -0
- package/dist/agents.js +31 -0
- package/dist/compile.d.ts +79 -0
- package/dist/compile.js +113 -0
- package/dist/content.d.ts +49 -0
- package/dist/content.js +73 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/resolve.d.ts +46 -0
- package/dist/resolve.js +54 -0
- package/dist/skills.d.ts +11 -0
- package/dist/skills.js +45 -0
- package/dist/template.d.ts +22 -0
- package/dist/template.js +34 -0
- package/node_modules/rafi-spec/dist/index.d.ts +4 -0
- package/node_modules/rafi-spec/dist/index.js +4 -0
- package/node_modules/rafi-spec/dist/schemas.d.ts +185 -0
- package/node_modules/rafi-spec/dist/schemas.js +95 -0
- package/node_modules/rafi-spec/dist/types.d.ts +111 -0
- package/node_modules/rafi-spec/dist/types.js +6 -0
- package/node_modules/rafi-spec/dist/validate.d.ts +16 -0
- package/node_modules/rafi-spec/dist/validate.js +40 -0
- package/node_modules/rafi-spec/package.json +35 -0
- package/node_modules/rafi-spec/src/index.ts +19 -0
- package/node_modules/rafi-spec/src/schemas.ts +102 -0
- package/node_modules/rafi-spec/src/types.ts +134 -0
- package/node_modules/rafi-spec/src/validate.ts +60 -0
- package/package.json +39 -0
package/dist/template.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Rafi templating engine — deliberately tiny (§3 of PLAN.md).
|
|
3
|
+
*
|
|
4
|
+
* Two directives only:
|
|
5
|
+
* - `{{key}}` → substituted from {@link TemplateContext.vars}
|
|
6
|
+
* - `{{#if flag}}…{{/if}}` → body kept when the flag is true, else the whole
|
|
7
|
+
* block (markers + body) is removed
|
|
8
|
+
*
|
|
9
|
+
* No nesting, no expressions, no helpers. An unknown var or flag is a hard error
|
|
10
|
+
* rather than a silent blank, so a typo can never quietly drop guidance from a
|
|
11
|
+
* composed agent. Conditional blocks are resolved first, so vars that live only
|
|
12
|
+
* inside a dropped block are never required to exist.
|
|
13
|
+
*/
|
|
14
|
+
const IF_BLOCK = /\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g;
|
|
15
|
+
const VAR = /\{\{\s*(\w+)\s*\}\}/g;
|
|
16
|
+
/** Render a template string against the given context. Throws on unknown var/flag. */
|
|
17
|
+
export function render(template, ctx) {
|
|
18
|
+
// 1) Resolve conditional blocks. Body is kept verbatim (and re-scanned for vars
|
|
19
|
+
// in step 2) when the flag is true; the entire block is dropped when false.
|
|
20
|
+
const withConditionals = template.replace(IF_BLOCK, (_match, flag, body) => {
|
|
21
|
+
if (!(flag in ctx.flags)) {
|
|
22
|
+
throw new Error(`unknown flag in {{#if}}: ${flag}`);
|
|
23
|
+
}
|
|
24
|
+
return ctx.flags[flag] ? body : "";
|
|
25
|
+
});
|
|
26
|
+
// 2) Substitute remaining {{var}} occurrences. Anything left now is real text
|
|
27
|
+
// the author expected to fill, so an unknown key is an error.
|
|
28
|
+
return withConditionals.replace(VAR, (_match, key) => {
|
|
29
|
+
if (!(key in ctx.vars)) {
|
|
30
|
+
throw new Error(`unknown placeholder: {{${key}}}`);
|
|
31
|
+
}
|
|
32
|
+
return ctx.vars[key];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
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";
|
|
@@ -0,0 +1,4 @@
|
|
|
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";
|
|
@@ -0,0 +1,185 @@
|
|
|
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"];
|
|
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
|
+
};
|
|
185
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
export const projectConfigSchema = {
|
|
72
|
+
$id: "rafi/projectConfig",
|
|
73
|
+
type: "object",
|
|
74
|
+
additionalProperties: false,
|
|
75
|
+
required: ["appName", "timezone", "stack", "flags", "harness"],
|
|
76
|
+
properties: {
|
|
77
|
+
appName: { type: "string", minLength: 1 },
|
|
78
|
+
timezone: { type: "string", minLength: 1 },
|
|
79
|
+
stack: stringRecord(["frontend", "backend", "database", "cloud", "packageManager"]),
|
|
80
|
+
flags: boolRecord(["hasFrontend", "usesAI", "runsInCloud"]),
|
|
81
|
+
harness: {
|
|
82
|
+
type: "object",
|
|
83
|
+
additionalProperties: false,
|
|
84
|
+
required: ["targets", "qa"],
|
|
85
|
+
properties: {
|
|
86
|
+
targets: {
|
|
87
|
+
type: "array",
|
|
88
|
+
minItems: 1,
|
|
89
|
+
items: { enum: ["claude", "codex"] },
|
|
90
|
+
},
|
|
91
|
+
qa: { type: "boolean" },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
/**
|
|
102
|
+
* The committed `project.yaml` in a target repo. Skipping the walkthrough uses
|
|
103
|
+
* the library defaults, which reproduce today's hardcoded guidance.
|
|
104
|
+
*/
|
|
105
|
+
export interface ProjectConfig {
|
|
106
|
+
appName: string;
|
|
107
|
+
timezone: string;
|
|
108
|
+
stack: ProjectStack;
|
|
109
|
+
flags: ProjectFlags;
|
|
110
|
+
harness: HarnessConfig;
|
|
111
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rafi-spec",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Rafi neutral schema: rule packs, skills, agents, and project config shapes shared by special-agents and ai-foreman.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"test": "tsx --test test/*.test.ts"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"ajv": "^8.20.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.14.0",
|
|
32
|
+
"tsx": "^4.19.0",
|
|
33
|
+
"typescript": "^5.6.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Rafi neutral schema — public surface. */
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export {
|
|
4
|
+
rulePackSchema,
|
|
5
|
+
skillManifestSchema,
|
|
6
|
+
agentManifestSchema,
|
|
7
|
+
projectConfigSchema,
|
|
8
|
+
} from "./schemas.js";
|
|
9
|
+
export {
|
|
10
|
+
type ValidationResult,
|
|
11
|
+
validateRulePack,
|
|
12
|
+
validateSkillManifest,
|
|
13
|
+
validateAgentManifest,
|
|
14
|
+
validateProjectConfig,
|
|
15
|
+
assertRulePack,
|
|
16
|
+
assertSkillManifest,
|
|
17
|
+
assertAgentManifest,
|
|
18
|
+
assertProjectConfig,
|
|
19
|
+
} from "./validate.js";
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
|
|
6
|
+
const KEBAB = "^[a-z0-9]+(?:-[a-z0-9]+)*$";
|
|
7
|
+
|
|
8
|
+
export const rulePackSchema = {
|
|
9
|
+
$id: "rafi/rulePack",
|
|
10
|
+
type: "object",
|
|
11
|
+
additionalProperties: false,
|
|
12
|
+
required: ["name", "category", "description", "condition", "template"],
|
|
13
|
+
properties: {
|
|
14
|
+
name: { type: "string", pattern: KEBAB },
|
|
15
|
+
category: { enum: ["base", "process", "domain", "templated"] },
|
|
16
|
+
description: { type: "string", minLength: 1 },
|
|
17
|
+
condition: { enum: ["always", "frontend", "ai", "cloud", "backend"] },
|
|
18
|
+
template: { type: "boolean" },
|
|
19
|
+
supersededByForeman: { type: "boolean" },
|
|
20
|
+
body: { type: "string" },
|
|
21
|
+
},
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
export const skillManifestSchema = {
|
|
25
|
+
$id: "rafi/skillManifest",
|
|
26
|
+
type: "object",
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
required: ["name", "description"],
|
|
29
|
+
properties: {
|
|
30
|
+
name: { type: "string", pattern: KEBAB },
|
|
31
|
+
description: { type: "string", minLength: 1 },
|
|
32
|
+
pins: { type: "array", items: { type: "string" } },
|
|
33
|
+
codexPriority: { enum: ["inline", "reference"] },
|
|
34
|
+
body: { type: "string" },
|
|
35
|
+
},
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export const agentManifestSchema = {
|
|
39
|
+
$id: "rafi/agentManifest",
|
|
40
|
+
type: "object",
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
required: ["name", "description", "role", "packs", "skills"],
|
|
43
|
+
properties: {
|
|
44
|
+
name: { type: "string", pattern: KEBAB },
|
|
45
|
+
description: { type: "string", minLength: 1 },
|
|
46
|
+
role: { enum: ["builder", "qa", "planner", "ticket-maker"] },
|
|
47
|
+
packs: { type: "array", items: { type: "string" } },
|
|
48
|
+
skills: { type: "array", items: { type: "string" } },
|
|
49
|
+
conditionalPacks: {
|
|
50
|
+
type: "object",
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
properties: {
|
|
53
|
+
ai: { type: "array", items: { type: "string" } },
|
|
54
|
+
frontend: { type: "array", items: { type: "string" } },
|
|
55
|
+
cloud: { type: "array", items: { type: "string" } },
|
|
56
|
+
backend: { type: "array", items: { type: "string" } },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
model: { type: ["string", "null"] },
|
|
60
|
+
effort: { type: ["string", "null"], enum: ["low", "medium", "high", "xhigh", null] },
|
|
61
|
+
},
|
|
62
|
+
} as const;
|
|
63
|
+
|
|
64
|
+
const stringRecord = (keys: string[]) => ({
|
|
65
|
+
type: "object",
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
required: keys,
|
|
68
|
+
properties: Object.fromEntries(keys.map((k) => [k, { type: "string", minLength: 1 }])),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const boolRecord = (keys: string[]) => ({
|
|
72
|
+
type: "object",
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
required: keys,
|
|
75
|
+
properties: Object.fromEntries(keys.map((k) => [k, { type: "boolean" }])),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const projectConfigSchema = {
|
|
79
|
+
$id: "rafi/projectConfig",
|
|
80
|
+
type: "object",
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
required: ["appName", "timezone", "stack", "flags", "harness"],
|
|
83
|
+
properties: {
|
|
84
|
+
appName: { type: "string", minLength: 1 },
|
|
85
|
+
timezone: { type: "string", minLength: 1 },
|
|
86
|
+
stack: stringRecord(["frontend", "backend", "database", "cloud", "packageManager"]),
|
|
87
|
+
flags: boolRecord(["hasFrontend", "usesAI", "runsInCloud"]),
|
|
88
|
+
harness: {
|
|
89
|
+
type: "object",
|
|
90
|
+
additionalProperties: false,
|
|
91
|
+
required: ["targets", "qa"],
|
|
92
|
+
properties: {
|
|
93
|
+
targets: {
|
|
94
|
+
type: "array",
|
|
95
|
+
minItems: 1,
|
|
96
|
+
items: { enum: ["claude", "codex"] },
|
|
97
|
+
},
|
|
98
|
+
qa: { type: "boolean" },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
} as const;
|