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.
Files changed (97) hide show
  1. package/README.md +69 -0
  2. package/content/agents/builder.yaml +25 -0
  3. package/content/agents/planner.yaml +13 -0
  4. package/content/agents/qa.yaml +16 -0
  5. package/content/agents/ticket-maker.yaml +11 -0
  6. package/content/defaults.yaml +13 -0
  7. package/content/docs/README.md +42 -0
  8. package/content/docs/admins.md +46 -0
  9. package/content/docs/ai-costs.md +38 -0
  10. package/content/docs/ai-evals.md +55 -0
  11. package/content/docs/ai.md +141 -0
  12. package/content/docs/api.md +51 -0
  13. package/content/docs/architecture.md +61 -0
  14. package/content/docs/business.md +49 -0
  15. package/content/docs/data-governance.md +67 -0
  16. package/content/docs/decisions/0000-template.md +29 -0
  17. package/content/docs/decisions/README.md +30 -0
  18. package/content/docs/docs.index.yaml +25 -0
  19. package/content/docs/features.md +41 -0
  20. package/content/docs/local-cloud.md +58 -0
  21. package/content/docs/operations.md +69 -0
  22. package/content/docs/release-checklist.md +56 -0
  23. package/content/docs/scalability.md +81 -0
  24. package/content/docs/security.md +82 -0
  25. package/content/docs/tickets.md +45 -0
  26. package/content/docs/users.md +43 -0
  27. package/content/preamble.md +13 -0
  28. package/content/rules/base/code-quality.md +20 -0
  29. package/content/rules/base/core.md +17 -0
  30. package/content/rules/base/definition-of-done.md +21 -0
  31. package/content/rules/base/git-safety.md +16 -0
  32. package/content/rules/base/response-expectations.md +18 -0
  33. package/content/rules/domain/accessibility.md +14 -0
  34. package/content/rules/domain/ai-cost.md +21 -0
  35. package/content/rules/domain/ai-evals.md +25 -0
  36. package/content/rules/domain/ai-governance.md +16 -0
  37. package/content/rules/domain/ai-reproducibility.md +19 -0
  38. package/content/rules/domain/ai-safety.md +19 -0
  39. package/content/rules/domain/data-governance.md +17 -0
  40. package/content/rules/domain/observability.md +18 -0
  41. package/content/rules/domain/robustness.md +21 -0
  42. package/content/rules/domain/scalability.md +18 -0
  43. package/content/rules/domain/security.md +28 -0
  44. package/content/rules/packs.index.yaml +177 -0
  45. package/content/rules/process/api-docs.md +16 -0
  46. package/content/rules/process/architecture.md +14 -0
  47. package/content/rules/process/business-docs.md +13 -0
  48. package/content/rules/process/ci.md +18 -0
  49. package/content/rules/process/dependencies.md +17 -0
  50. package/content/rules/process/project-docs.md +35 -0
  51. package/content/rules/process/release.md +16 -0
  52. package/content/rules/process/tdd.md +16 -0
  53. package/content/rules/process/testing.md +28 -0
  54. package/content/rules/process/tickets.md +17 -0
  55. package/content/rules/templated/database.md +16 -0
  56. package/content/rules/templated/infra.md +18 -0
  57. package/content/rules/templated/stack.md +19 -0
  58. package/content/skills/better-sqlite3-rebuild/SKILL.md +14 -0
  59. package/content/skills/grill-me/SKILL.md +10 -0
  60. package/content/skills/improve-codebase-architecture/REFERENCE.md +78 -0
  61. package/content/skills/improve-codebase-architecture/SKILL.md +76 -0
  62. package/content/skills/prd-to-issues/SKILL.md +92 -0
  63. package/content/skills/tdd/SKILL.md +107 -0
  64. package/content/skills/tdd/deep-modules.md +33 -0
  65. package/content/skills/tdd/interface-design.md +31 -0
  66. package/content/skills/tdd/mocking.md +59 -0
  67. package/content/skills/tdd/refactoring.md +10 -0
  68. package/content/skills/tdd/tests.md +61 -0
  69. package/content/skills/write-a-prd/SKILL.md +74 -0
  70. package/dist/agents.d.ts +11 -0
  71. package/dist/agents.js +31 -0
  72. package/dist/compile.d.ts +79 -0
  73. package/dist/compile.js +113 -0
  74. package/dist/content.d.ts +49 -0
  75. package/dist/content.js +73 -0
  76. package/dist/index.d.ts +12 -0
  77. package/dist/index.js +12 -0
  78. package/dist/resolve.d.ts +46 -0
  79. package/dist/resolve.js +54 -0
  80. package/dist/skills.d.ts +11 -0
  81. package/dist/skills.js +45 -0
  82. package/dist/template.d.ts +22 -0
  83. package/dist/template.js +34 -0
  84. package/node_modules/rafi-spec/dist/index.d.ts +4 -0
  85. package/node_modules/rafi-spec/dist/index.js +4 -0
  86. package/node_modules/rafi-spec/dist/schemas.d.ts +185 -0
  87. package/node_modules/rafi-spec/dist/schemas.js +95 -0
  88. package/node_modules/rafi-spec/dist/types.d.ts +111 -0
  89. package/node_modules/rafi-spec/dist/types.js +6 -0
  90. package/node_modules/rafi-spec/dist/validate.d.ts +16 -0
  91. package/node_modules/rafi-spec/dist/validate.js +40 -0
  92. package/node_modules/rafi-spec/package.json +35 -0
  93. package/node_modules/rafi-spec/src/index.ts +19 -0
  94. package/node_modules/rafi-spec/src/schemas.ts +102 -0
  95. package/node_modules/rafi-spec/src/types.ts +134 -0
  96. package/node_modules/rafi-spec/src/validate.ts +60 -0
  97. package/package.json +39 -0
@@ -0,0 +1,134 @@
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
+
7
+ // ───────────────────────────── Rule packs ─────────────────────────────
8
+
9
+ /** Which category a rule pack belongs to (drives default load behavior). */
10
+ export type PackCategory = "base" | "process" | "domain" | "templated";
11
+
12
+ /**
13
+ * When a pack applies. `always` packs load for every project; the others load
14
+ * only when the matching project flag is on (see {@link ProjectFlags}).
15
+ */
16
+ export type PackCondition = "always" | "frontend" | "ai" | "cloud" | "backend";
17
+
18
+ /** The YAML front-matter carried by each rule pack markdown file. */
19
+ export interface RulePackFrontmatter {
20
+ /** Unique, kebab-case identifier (e.g. `security`). */
21
+ name: string;
22
+ category: PackCategory;
23
+ /** One-line summary used in indexes and pack pickers. */
24
+ description: string;
25
+ condition: PackCondition;
26
+ /** True when the body contains `{{placeholders}}` / `{{#if}}` directives. */
27
+ template: boolean;
28
+ /** When true, the pack is omitted while the foreman ticket tracker is active. */
29
+ supersededByForeman?: boolean;
30
+ }
31
+
32
+ /** A fully loaded rule pack: its front-matter plus the markdown body. */
33
+ export interface RulePack extends RulePackFrontmatter {
34
+ /** The rule text (bullets) below the front-matter. */
35
+ body: string;
36
+ }
37
+
38
+ // ───────────────────────────── Skills ─────────────────────────────
39
+
40
+ /** How a skill should be treated when flattening for Codex (which can't lazy-load). */
41
+ export type CodexPriority = "inline" | "reference";
42
+
43
+ /**
44
+ * A skill manifest. Keeps the existing Anthropic `SKILL.md` format and adds two
45
+ * optional composition fields that non-Rafi tools can safely ignore.
46
+ */
47
+ export interface SkillManifest {
48
+ /** Unique, kebab-case identifier matching the skill directory name. */
49
+ name: string;
50
+ /** One-line trigger description (the cheap progressive-disclosure index). */
51
+ description: string;
52
+ /** Rule packs this skill wants loaded alongside it. */
53
+ pins?: string[];
54
+ /** Whether Codex flattening should inline this skill's body or just reference it. */
55
+ codexPriority?: CodexPriority;
56
+ /** The skill body (instructions). Optional in metadata-only contexts. */
57
+ body?: string;
58
+ }
59
+
60
+ // ───────────────────────────── Agents (roles) ─────────────────────────────
61
+
62
+ /** The role an agent fills, mapped to an ai-foreman turn-type or command. */
63
+ export type AgentRole = "builder" | "qa" | "planner" | "ticket-maker";
64
+
65
+ /** Reasoning effort levels accepted by the builders. */
66
+ export type EffortLevel = "low" | "medium" | "high" | "xhigh";
67
+
68
+ /** Packs added to a role only when the matching project flag is on. */
69
+ export interface ConditionalPacks {
70
+ ai?: string[];
71
+ frontend?: string[];
72
+ cloud?: string[];
73
+ backend?: string[];
74
+ }
75
+
76
+ /**
77
+ * A role manifest: a named composition of rule packs + skills that the runtime
78
+ * loads for a given turn-type.
79
+ */
80
+ export interface AgentManifest {
81
+ /** Unique, kebab-case identifier (usually equals {@link role}). */
82
+ name: string;
83
+ description: string;
84
+ role: AgentRole;
85
+ /** Pack references; globs like `base/*` are allowed and expanded at compile time. */
86
+ packs: string[];
87
+ /** Skill names this role preloads. */
88
+ skills: string[];
89
+ /** Extra packs gated on project flags. */
90
+ conditionalPacks?: ConditionalPacks;
91
+ /** Model override; null inherits the runtime's `--model`. */
92
+ model?: string | null;
93
+ /** Effort override; null inherits the runtime's `--effort`. */
94
+ effort?: EffortLevel | null;
95
+ }
96
+
97
+ // ───────────────────────────── Project config ─────────────────────────────
98
+
99
+ /** Which harness targets to emit native config for. */
100
+ export type HarnessTarget = "claude" | "codex";
101
+
102
+ /** The stack choices collected by `rafi create` (free-text strings). */
103
+ export interface ProjectStack {
104
+ frontend: string;
105
+ backend: string;
106
+ database: string;
107
+ cloud: string;
108
+ packageManager: string;
109
+ }
110
+
111
+ /** Boolean flags that gate conditional packs and docs. */
112
+ export interface ProjectFlags {
113
+ hasFrontend: boolean;
114
+ usesAI: boolean;
115
+ runsInCloud: boolean;
116
+ }
117
+
118
+ /** Harness emission + QA preferences. */
119
+ export interface HarnessConfig {
120
+ targets: HarnessTarget[];
121
+ qa: boolean;
122
+ }
123
+
124
+ /**
125
+ * The committed `project.yaml` in a target repo. Skipping the walkthrough uses
126
+ * the library defaults, which reproduce today's hardcoded guidance.
127
+ */
128
+ export interface ProjectConfig {
129
+ appName: string;
130
+ timezone: string;
131
+ stack: ProjectStack;
132
+ flags: ProjectFlags;
133
+ harness: HarnessConfig;
134
+ }
@@ -0,0 +1,60 @@
1
+ /** ajv-backed validation for the neutral schemas. */
2
+ import { Ajv, type ValidateFunction } from "ajv";
3
+ import {
4
+ rulePackSchema,
5
+ skillManifestSchema,
6
+ agentManifestSchema,
7
+ projectConfigSchema,
8
+ } from "./schemas.js";
9
+ import type {
10
+ RulePackFrontmatter,
11
+ SkillManifest,
12
+ AgentManifest,
13
+ ProjectConfig,
14
+ } from "./types.js";
15
+
16
+ const ajv = new Ajv({ allErrors: true, allowUnionTypes: true });
17
+
18
+ /** Outcome of validating a value against one of the neutral schemas. */
19
+ export interface ValidationResult {
20
+ valid: boolean;
21
+ /** Human-readable messages; empty when valid. */
22
+ errors: string[];
23
+ }
24
+
25
+ function run(fn: ValidateFunction, data: unknown): ValidationResult {
26
+ const valid = fn(data) as boolean;
27
+ if (valid) return { valid: true, errors: [] };
28
+ const errors = (fn.errors ?? []).map(
29
+ (e) => `${e.instancePath || "(root)"} ${e.message ?? "is invalid"}`.trim(),
30
+ );
31
+ return { valid: false, errors };
32
+ }
33
+
34
+ const vRulePack = ajv.compile(rulePackSchema);
35
+ const vSkill = ajv.compile(skillManifestSchema);
36
+ const vAgent = ajv.compile(agentManifestSchema);
37
+ const vProject = ajv.compile(projectConfigSchema);
38
+
39
+ export const validateRulePack = (d: unknown): ValidationResult => run(vRulePack, d);
40
+ export const validateSkillManifest = (d: unknown): ValidationResult => run(vSkill, d);
41
+ export const validateAgentManifest = (d: unknown): ValidationResult => run(vAgent, d);
42
+ export const validateProjectConfig = (d: unknown): ValidationResult => run(vProject, d);
43
+
44
+ /** Validate and narrow, throwing on failure. */
45
+ export function assertRulePack(d: unknown): asserts d is RulePackFrontmatter {
46
+ const r = validateRulePack(d);
47
+ if (!r.valid) throw new Error(`Invalid rule pack: ${r.errors.join("; ")}`);
48
+ }
49
+ export function assertSkillManifest(d: unknown): asserts d is SkillManifest {
50
+ const r = validateSkillManifest(d);
51
+ if (!r.valid) throw new Error(`Invalid skill manifest: ${r.errors.join("; ")}`);
52
+ }
53
+ export function assertAgentManifest(d: unknown): asserts d is AgentManifest {
54
+ const r = validateAgentManifest(d);
55
+ if (!r.valid) throw new Error(`Invalid agent manifest: ${r.errors.join("; ")}`);
56
+ }
57
+ export function assertProjectConfig(d: unknown): asserts d is ProjectConfig {
58
+ const r = validateProjectConfig(d);
59
+ if (!r.valid) throw new Error(`Invalid project config: ${r.errors.join("; ")}`);
60
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "special-agents",
3
+ "version": "0.1.0",
4
+ "description": "Rafi library: composable best-practice rules, skills, and agents for Claude Code and Codex.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "content",
17
+ "README.md"
18
+ ],
19
+ "engines": {
20
+ "node": ">=20"
21
+ },
22
+ "bundledDependencies": [
23
+ "rafi-spec"
24
+ ],
25
+ "dependencies": {
26
+ "yaml": "^2.5.1",
27
+ "rafi-spec": "0.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^20.14.0",
31
+ "tsx": "^4.19.0",
32
+ "typescript": "^5.6.0"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.build.json",
36
+ "typecheck": "tsc --noEmit",
37
+ "test": "tsx --test test/*.test.ts"
38
+ }
39
+ }