arey-pi 0.2.0 → 0.3.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 CHANGED
@@ -25,7 +25,7 @@ Arey Pi is built around these guarantees:
25
25
  - behaviour is captured in canonical Gherkin specs;
26
26
  - database projects keep canonical DBML specs precisely synchronised;
27
27
  - TDD is mandatory for production behaviour changes;
28
- - tests must be meaningful, reviewed, and strengthened with coverage or mutation testing where risk warrants it;
28
+ - tests must be meaningful, reviewed, kept outside production source directories, and strengthened with coverage or mutation testing where risk warrants it;
29
29
  - architecture and code must meet a senior engineering quality bar;
30
30
  - significant technical decisions are captured in high-quality ADRs;
31
31
  - specs, tests, code, DBML, ADRs, glossary, and architecture docs stay synchronised;
@@ -38,10 +38,12 @@ Arey Pi is built around these guarantees:
38
38
 
39
39
  ```txt
40
40
  agents/ # Arey Pi subagent role definitions for pi-subagents
41
- extensions/ # Slash commands for doctor, bootstrap, and workflows
41
+ extensions/ # Directory-style Pi extension for doctor, bootstrap, and workflows
42
+ docs/ # Package documentation
42
43
  skills/ # On-demand Arey Pi workflows and instructions
43
44
  prompts/ # Reusable Pi prompt workflows
44
45
  rules/ # Arey Pi operating rules
46
+ templates/ # Bootstrap templates for AGENTS.md, specs, ADRs, DBML, glossary, and reports
45
47
  ```
46
48
 
47
49
  The rules are the policy layer.
@@ -125,9 +127,12 @@ Arey Pi includes a polished extension-backed workflow:
125
127
 
126
128
  ```txt
127
129
  /arey-doctor # check package, subagent, prompt, skill, and project readiness setup
128
- /arey-bootstrap # install project-local Arey Pi agents
130
+ /arey-bootstrap # full safe bootstrap: agents, AGENTS.md, specs, docs, and templates
129
131
  /arey-bootstrap --agentsmd # also create a starter AGENTS.md if missing
130
- /arey-bootstrap --force # overwrite existing project-local Arey Pi agents
132
+ /arey-bootstrap --specs # scaffold starter specs directories and glossary
133
+ /arey-bootstrap --docs # scaffold starter docs directory
134
+ /arey-bootstrap --full # explicit alias for the default full bootstrap
135
+ /arey-bootstrap --force # full bootstrap and overwrite selected project-local files
131
136
  /arey-feature # run spec → TDD → sync → review for a feature
132
137
  /arey-bugfix # run regression-test-first bug fixing
133
138
  /arey-sync # verify specs, docs, tests, code, DBML, ADRs, and glossary alignment
@@ -147,10 +152,11 @@ Arey Pi uses Bun as its package manager and Biome for extension formatting and l
147
152
  ```bash
148
153
  bun install
149
154
  bun run format
155
+ bun run test
150
156
  bun run check
151
157
  ```
152
158
 
153
- `bun run check` runs Biome linting and TypeScript type checking.
159
+ `bun run check` runs Biome linting, TypeScript type checking, and Bun tests.
154
160
 
155
161
  ## Rule categories
156
162
 
@@ -44,6 +44,7 @@ Check:
44
44
  - whether domain concepts and contracts are explicit;
45
45
  - whether error handling, security, privacy, and edge cases are appropriate;
46
46
  - whether tests assert behaviour and would catch plausible regressions;
47
+ - whether tests are kept in a dedicated test/spec directory rather than colocated with production source files without justification;
47
48
  - whether quality tooling ran and is sufficient for project risk;
48
49
  - whether durable decisions require ADRs;
49
50
  - whether DBML, Gherkin, glossary, architecture docs, README files, docs, AGENTS.md, skills, prompts, rules, agents, commands, or tooling instructions may need sync;
@@ -69,7 +70,7 @@ Return:
69
70
  Engineering review:
70
71
  - Blocking findings:
71
72
  - High/medium/low findings:
72
- - Test quality:
73
+ - Test quality and location:
73
74
  - Tooling/validation:
74
75
  - Architecture/code quality:
75
76
  - Security/privacy/operability:
@@ -22,6 +22,7 @@ Own:
22
22
 
23
23
  - deriving tests from accepted specs, bug reports, or explicit requirements;
24
24
  - writing failing tests before production behaviour;
25
+ - placing tests in a dedicated test/spec directory outside production source trees by default;
25
26
  - implementing the smallest high-quality production change that satisfies the tests;
26
27
  - refactoring after tests pass;
27
28
  - keeping tests meaningful and behaviour-focused;
@@ -56,6 +57,9 @@ If you cannot demonstrate Red-Green-Refactor because of project constraints, sta
56
57
  Tests must constrain behaviour.
57
58
  They should cover important success paths, edge cases, failure paths, permissions, contracts, and regressions where relevant.
58
59
 
60
+ Tests must not be colocated beside production files in `src/` or equivalent source directories unless an existing project convention, framework constraint, or user-approved exception requires it.
61
+ Prefer mirroring production module structure under `tests/`, `test/`, `__tests__/`, or `spec/`.
62
+
59
63
  Weak tests are not acceptable evidence merely because they pass.
60
64
  Use mutation testing, coverage, or explicit test review where appropriate to risk.
61
65
 
@@ -71,7 +75,7 @@ Return:
71
75
  ```txt
72
76
  Implementation handoff:
73
77
  - Changed files:
74
- - Tests added/updated:
78
+ - Tests added/updated and location:
75
79
  - Red-Green-Refactor evidence:
76
80
  - Validation commands:
77
81
  - Spec impact:
package/docs/commands.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Arey Pi Commands
2
2
 
3
3
  Arey Pi ships a Pi extension that registers native slash commands.
4
+ The extension uses Pi's documented directory style at `extensions/arey-pi/index.ts`.
4
5
 
5
6
  The commands are designed for two modes of use:
6
7
 
@@ -11,7 +12,7 @@ The commands are designed for two modes of use:
11
12
 
12
13
  ```txt
13
14
  /arey-doctor
14
- /arey-bootstrap [--agentsmd] [--force]
15
+ /arey-bootstrap [--agentsmd] [--specs] [--docs] [--full] [--force]
15
16
  /arey-feature <feature request>
16
17
  /arey-bugfix <bug description>
17
18
  /arey-sync [scope]
@@ -28,6 +29,7 @@ It reports:
28
29
  - Arey Pi package version;
29
30
  - current project path;
30
31
  - whether packaged rules are present;
32
+ - whether packaged templates are present;
31
33
  - whether packaged agents are present;
32
34
  - whether `pi-subagents` appears to be installed;
33
35
  - whether project-local Arey Pi agents exist in `.pi/agents/arey-pi/`;
@@ -49,15 +51,23 @@ or when subagent workflows are not behaving as expected.
49
51
 
50
52
  ## `/arey-bootstrap`
51
53
 
52
- Installs Arey Pi's packaged subagent definitions into the current project.
54
+ Installs Arey Pi's packaged subagent definitions into the current project and performs a safe starter scaffold.
53
55
 
54
- Default target:
56
+ With no flags, `/arey-bootstrap` runs the full bootstrap path:
57
+
58
+ ```txt
59
+ --agentsmd --specs --docs
60
+ ```
61
+
62
+ Default agent target:
55
63
 
56
64
  ```txt
57
65
  .pi/agents/arey-pi/
58
66
  ```
59
67
 
60
- By default, existing project-local agent files are not overwritten.
68
+ By default, existing project-local agent files and scaffold files are not overwritten.
69
+ Starter scaffold files are copied from the packaged `templates/` directory.
70
+ Selective flags are available when you only want one part of the scaffold.
61
71
 
62
72
  Usage:
63
73
 
@@ -65,6 +75,24 @@ Usage:
65
75
  /arey-bootstrap
66
76
  ```
67
77
 
78
+ This creates or installs, where missing:
79
+
80
+ ```txt
81
+ .pi/agents/arey-pi/
82
+ AGENTS.md
83
+ specs/README.md
84
+ specs/features/README.md
85
+ specs/features/example.feature
86
+ specs/database/README.md
87
+ specs/database/schema.dbml
88
+ specs/architecture/README.md
89
+ specs/decisions/README.md
90
+ specs/decisions/0001-record-architecture-decision.md
91
+ specs/glossary.md
92
+ docs/README.md
93
+ docs/project-readiness-report.md
94
+ ```
95
+
68
96
  Options:
69
97
 
70
98
  ```txt
@@ -73,13 +101,61 @@ Options:
73
101
 
74
102
  Also creates a starter root `AGENTS.md` when one does not already exist.
75
103
 
104
+ ```txt
105
+ /arey-bootstrap --specs
106
+ ```
107
+
108
+ Creates starter Arey Pi spec structure when files do not already exist:
109
+
110
+ ```txt
111
+ specs/README.md
112
+ specs/features/README.md
113
+ specs/features/example.feature
114
+ specs/database/README.md
115
+ specs/database/schema.dbml
116
+ specs/architecture/README.md
117
+ specs/decisions/README.md
118
+ specs/decisions/0001-record-architecture-decision.md
119
+ specs/glossary.md
120
+ ```
121
+
122
+ ```txt
123
+ /arey-bootstrap --docs
124
+ ```
125
+
126
+ Creates starter project documentation structure when files do not already exist:
127
+
128
+ ```txt
129
+ docs/README.md
130
+ docs/project-readiness-report.md
131
+ ```
132
+
133
+ ```txt
134
+ /arey-bootstrap --full
135
+ ```
136
+
137
+ Explicitly runs the same combined bootstrap path as `/arey-bootstrap` with no flags:
138
+
139
+ ```txt
140
+ --agentsmd --specs --docs
141
+ ```
142
+
76
143
  ```txt
77
144
  /arey-bootstrap --force
78
145
  ```
79
146
 
80
- Overwrites existing project-local Arey Pi agent files.
147
+ Overwrites existing project-local Arey Pi agent files and scaffold files selected by the other flags.
148
+ When used alone, it applies to the default full bootstrap path.
81
149
  It also creates a starter `AGENTS.md` when one does not already exist.
82
150
 
151
+ Examples:
152
+
153
+ ```txt
154
+ /arey-bootstrap --specs --docs
155
+ /arey-bootstrap --full
156
+ /arey-bootstrap --full --force
157
+ ```
158
+
83
159
  Use this command after installing Arey Pi and `pi-subagents` in a repository where you want the Arey Pi agents to be discoverable by `pi-subagents`.
84
160
 
85
161
  ## `/arey-feature`
@@ -0,0 +1,121 @@
1
+ export const requiredAgents = [
2
+ "tech-lead.md",
3
+ "spec-author.md",
4
+ "tdd-implementer.md",
5
+ "spec-syncer.md",
6
+ "engineering-reviewer.md",
7
+ "project-evaluator.md",
8
+ ] as const;
9
+
10
+ export type ScaffoldFile = { template: string; target: string };
11
+
12
+ export const specScaffoldFiles: ScaffoldFile[] = [
13
+ { template: "specs-readme.md", target: "specs/README.md" },
14
+ { template: "features-readme.md", target: "specs/features/README.md" },
15
+ { template: "feature.feature", target: "specs/features/example.feature" },
16
+ { template: "database-readme.md", target: "specs/database/README.md" },
17
+ { template: "database.dbml", target: "specs/database/schema.dbml" },
18
+ { template: "architecture-readme.md", target: "specs/architecture/README.md" },
19
+ { template: "decisions-readme.md", target: "specs/decisions/README.md" },
20
+ { template: "adr.md", target: "specs/decisions/0001-record-architecture-decision.md" },
21
+ { template: "glossary.md", target: "specs/glossary.md" },
22
+ ];
23
+
24
+ export const docsScaffoldFiles: ScaffoldFile[] = [
25
+ { template: "docs-readme.md", target: "docs/README.md" },
26
+ { template: "project-readiness-report.md", target: "docs/project-readiness-report.md" },
27
+ ];
28
+
29
+ const selectiveBootstrapFlags = ["--agentsmd", "--specs", "--docs", "--full"];
30
+
31
+ export type BootstrapPlan = {
32
+ flags: string[];
33
+ force: boolean;
34
+ full: boolean;
35
+ defaultFullBootstrap: boolean;
36
+ createAgentsMd: boolean;
37
+ createSpecs: boolean;
38
+ createDocs: boolean;
39
+ };
40
+
41
+ export function parseBootstrapFlags(args: string): BootstrapPlan {
42
+ const flags = args.split(/\s+/).filter(Boolean);
43
+ const force = flags.includes("--force");
44
+ const full = flags.includes("--full");
45
+ const hasSelectiveScaffoldFlag = flags.some((flag) => selectiveBootstrapFlags.includes(flag));
46
+ const defaultFullBootstrap = !hasSelectiveScaffoldFlag;
47
+
48
+ return {
49
+ flags,
50
+ force,
51
+ full,
52
+ defaultFullBootstrap,
53
+ createAgentsMd: defaultFullBootstrap || flags.includes("--agentsmd") || full,
54
+ createSpecs: defaultFullBootstrap || flags.includes("--specs") || full,
55
+ createDocs: defaultFullBootstrap || flags.includes("--docs") || full,
56
+ };
57
+ }
58
+
59
+ export type WorkflowKind = "feature" | "bugfix" | "sync" | "review" | "assess" | string;
60
+
61
+ export function workflowMessage(kind: WorkflowKind, args: string): string {
62
+ const target = args.trim() || "the current repository/task";
63
+ const common = `Act as the Arey Pi tech lead. Use pi-subagents when available and appropriate. Keep orchestration authority in the parent session. Follow Arey Pi rules, preserve TDD, and report evidence clearly.`;
64
+
65
+ switch (kind) {
66
+ case "feature":
67
+ return `${common}\n\nRun the Arey Pi feature workflow for: ${target}\n\nExpected flow: spec-author for canonical specs, tdd-implementer for Red-Green-Refactor, spec-syncer for final alignment, and engineering-reviewer for adversarial quality review when risk warrants it.`;
68
+ case "bugfix":
69
+ return `${common}\n\nRun the Arey Pi bugfix workflow for: ${target}\n\nStart with a regression test that fails for the bug, then implement the minimal high-quality fix, synchronise specs, and review engineering quality.`;
70
+ case "sync":
71
+ return `${common}\n\nRun Arey Pi spec and documentation sync for: ${target}\n\nVerify Gherkin, tests, code, DBML, ADRs, glossary, architecture docs, README files, docs, AGENTS.md, skills, prompts, rules, agents, commands, and tooling instructions. End with both a spec status and a documentation status.`;
72
+ case "review":
73
+ return `${common}\n\nRun an Arey Pi engineering review for: ${target}\n\nReview architecture, code quality, test quality, quality tooling, security, privacy, operability, maintainability, and spec/ADR/DBML concerns. Classify findings by severity.`;
74
+ case "assess":
75
+ return `${common}\n\nAssess this repository against Arey Pi Project Readiness. Audit only by default. Produce scores, evidence, blockers, quick wins, and a prioritised improvement plan.`;
76
+ default:
77
+ return `${common}\n\nWork on: ${target}`;
78
+ }
79
+ }
80
+
81
+ export type DoctorReportInput = {
82
+ packageVersion: string;
83
+ cwd: string;
84
+ packageRulesPresent: boolean;
85
+ packageTemplatesPresent: boolean;
86
+ packageAgentsCount: number;
87
+ requiredAgentsCount: number;
88
+ hasSubagentsCommand: boolean;
89
+ installedAgentsCount: number;
90
+ hasRootAgentsMd: boolean;
91
+ hasPiSettings: boolean;
92
+ promptsCount: number;
93
+ skillsCount: number;
94
+ missingAgents: string[];
95
+ };
96
+
97
+ export function buildDoctorReport(input: DoctorReportInput): string {
98
+ return [
99
+ "# Arey Pi Doctor",
100
+ "",
101
+ `- Package: arey-pi@${input.packageVersion}`,
102
+ `- Project: ${input.cwd}`,
103
+ `- Package rules present: ${input.packageRulesPresent ? "yes" : "no"}`,
104
+ `- Package templates present: ${input.packageTemplatesPresent ? "yes" : "no"}`,
105
+ `- Package agents present: ${input.packageAgentsCount}/${input.requiredAgentsCount}`,
106
+ `- pi-subagents command detected: ${input.hasSubagentsCommand ? "yes" : "no"}`,
107
+ `- Project-local Arey Pi agents: ${input.installedAgentsCount}/${input.requiredAgentsCount}`,
108
+ `- Root AGENTS.md: ${input.hasRootAgentsMd ? "yes" : "no"}`,
109
+ `- .pi/settings.json: ${input.hasPiSettings ? "yes" : "no"}`,
110
+ `- Arey Pi prompts discovered: ${input.promptsCount}`,
111
+ `- Arey Pi skills discovered: ${input.skillsCount}`,
112
+ "",
113
+ "## Missing project agents",
114
+ input.missingAgents.length ? input.missingAgents.map((agent) => `- ${agent}`).join("\n") : "- none",
115
+ "",
116
+ "## Recommended next step",
117
+ input.installedAgentsCount === input.requiredAgentsCount
118
+ ? "- Project-local Arey Pi subagents are installed. Use `/arey-feature`, `/arey-bugfix`, `/arey-sync`, `/arey-review`, or natural language."
119
+ : "- Run `/arey-bootstrap` to install project-local Arey Pi subagents.",
120
+ ].join("\n");
121
+ }
@@ -2,18 +2,20 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileS
2
2
  import { dirname, join, relative } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
5
+ import {
6
+ buildDoctorReport,
7
+ docsScaffoldFiles,
8
+ parseBootstrapFlags,
9
+ requiredAgents,
10
+ specScaffoldFiles,
11
+ workflowMessage,
12
+ type ScaffoldFile,
13
+ } from "./core.ts";
5
14
 
6
15
  const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
7
16
  const agentSourceDir = join(packageRoot, "agents");
8
17
  const rulesDir = join(packageRoot, "rules");
9
- const requiredAgents = [
10
- "tech-lead.md",
11
- "spec-author.md",
12
- "tdd-implementer.md",
13
- "spec-syncer.md",
14
- "engineering-reviewer.md",
15
- "project-evaluator.md",
16
- ];
18
+ const templatesDir = join(packageRoot, "templates");
17
19
 
18
20
  function cwdFrom(ctx: unknown): string {
19
21
  const maybe = ctx as { cwd?: string };
@@ -64,52 +66,45 @@ function copyAgents(targetDir: string, force: boolean): { copied: string[]; skip
64
66
  return { copied, skipped, missing };
65
67
  }
66
68
 
67
- function starterAgentsMd(): string {
68
- return `# Agent Instructions
69
+ type ScaffoldResult = { created: string[]; skipped: string[] };
70
+
71
+ function templateContent(name: string): string {
72
+ return readFileSync(join(templatesDir, name), "utf8");
73
+ }
69
74
 
70
- This project uses Arey Pi.
75
+ function writeTemplateIfMissing(file: ScaffoldFile, force: boolean, cwd: string, result: ScaffoldResult) {
76
+ const target = join(cwd, file.target);
77
+ mkdirSync(dirname(target), { recursive: true });
71
78
 
72
- ## Delivery rules
79
+ if (fileExists(target) && !force) {
80
+ result.skipped.push(file.target);
81
+ return;
82
+ }
73
83
 
74
- - Treat canonical specs as the source of truth.
75
- - Use Gherkin for behaviour specs.
76
- - Use DBML for database specs when the project has persistence.
77
- - Follow TDD for production behaviour changes.
78
- - Keep specs, tests, code, DBML, ADRs, glossary, and architecture docs synchronised.
79
- - Capture significant technical decisions in high-quality ADRs.
80
- - Run formatter, lint/static analysis, typecheck, tests, and relevant dynamic analysis where available.
81
- - Use incremental Conventional Commits for meaningful steps.
84
+ writeFileSync(target, templateContent(file.template));
85
+ result.created.push(file.target);
86
+ }
82
87
 
83
- ## Subagents
88
+ function scaffoldFiles(cwd: string, force: boolean, files: ScaffoldFile[]): ScaffoldResult {
89
+ const result: ScaffoldResult = { created: [], skipped: [] };
84
90
 
85
- Project-local Arey Pi subagents live in:
91
+ for (const file of files) {
92
+ writeTemplateIfMissing(file, force, cwd, result);
93
+ }
86
94
 
87
- \`\`\`txt
88
- .pi/agents/arey-pi/
89
- \`\`\`
95
+ return result;
96
+ }
90
97
 
91
- Use them through pi-subagents when available.
92
- `;
98
+ function scaffoldSpecs(cwd: string, force: boolean): ScaffoldResult {
99
+ return scaffoldFiles(cwd, force, specScaffoldFiles);
93
100
  }
94
101
 
95
- function workflowMessage(kind: string, args: string): string {
96
- const target = args.trim() || "the current repository/task";
97
- const common = `Act as the Arey Pi tech lead. Use pi-subagents when available and appropriate. Keep orchestration authority in the parent session. Follow Arey Pi rules, preserve TDD, and report evidence clearly.`;
98
-
99
- switch (kind) {
100
- case "feature":
101
- return `${common}\n\nRun the Arey Pi feature workflow for: ${target}\n\nExpected flow: spec-author for canonical specs, tdd-implementer for Red-Green-Refactor, spec-syncer for final alignment, and engineering-reviewer for adversarial quality review when risk warrants it.`;
102
- case "bugfix":
103
- return `${common}\n\nRun the Arey Pi bugfix workflow for: ${target}\n\nStart with a regression test that fails for the bug, then implement the minimal high-quality fix, synchronise specs, and review engineering quality.`;
104
- case "sync":
105
- return `${common}\n\nRun Arey Pi spec and documentation sync for: ${target}\n\nVerify Gherkin, tests, code, DBML, ADRs, glossary, architecture docs, README files, docs, AGENTS.md, skills, prompts, rules, agents, commands, and tooling instructions. End with both a spec status and a documentation status.`;
106
- case "review":
107
- return `${common}\n\nRun an Arey Pi engineering review for: ${target}\n\nReview architecture, code quality, test quality, quality tooling, security, privacy, operability, maintainability, and spec/ADR/DBML concerns. Classify findings by severity.`;
108
- case "assess":
109
- return `${common}\n\nAssess this repository against Arey Pi Project Readiness. Audit only by default. Produce scores, evidence, blockers, quick wins, and a prioritised improvement plan.`;
110
- default:
111
- return `${common}\n\nWork on: ${target}`;
112
- }
102
+ function scaffoldDocs(cwd: string, force: boolean): ScaffoldResult {
103
+ return scaffoldFiles(cwd, force, docsScaffoldFiles);
104
+ }
105
+
106
+ function starterAgentsMd(): string {
107
+ return templateContent("AGENTS.md");
113
108
  }
114
109
 
115
110
  function sendWorkflow(
@@ -163,28 +158,21 @@ export default function areyPi(pi: ExtensionAPI) {
163
158
  (command) => command.source === "skill" && command.sourceInfo?.source?.includes("arey-pi"),
164
159
  );
165
160
 
166
- const report = [
167
- "# Arey Pi Doctor",
168
- "",
169
- `- Package: arey-pi@${packageVersion()}`,
170
- `- Project: ${cwd}`,
171
- `- Package rules present: ${dirExists(rulesDir) ? "yes" : "no"}`,
172
- `- Package agents present: ${packageAgents.length}/${requiredAgents.length}`,
173
- `- pi-subagents command detected: ${hasSubagentsCommand ? "yes" : "no"}`,
174
- `- Project-local Arey Pi agents: ${installedAgents.length}/${requiredAgents.length}`,
175
- `- Root AGENTS.md: ${fileExists(join(cwd, "AGENTS.md")) ? "yes" : "no"}`,
176
- `- .pi/settings.json: ${fileExists(join(cwd, ".pi", "settings.json")) ? "yes" : "no"}`,
177
- `- Arey Pi prompts discovered: ${prompts.length}`,
178
- `- Arey Pi skills discovered: ${skills.length}`,
179
- "",
180
- "## Missing project agents",
181
- missingAgents.length ? missingAgents.map((agent) => `- ${agent}`).join("\n") : "- none",
182
- "",
183
- "## Recommended next step",
184
- installedAgents.length === requiredAgents.length
185
- ? "- Project-local Arey Pi subagents are installed. Use `/arey-feature`, `/arey-bugfix`, `/arey-sync`, `/arey-review`, or natural language."
186
- : "- Run `/arey-bootstrap` to install project-local Arey Pi subagents.",
187
- ].join("\n");
161
+ const report = buildDoctorReport({
162
+ packageVersion: packageVersion(),
163
+ cwd,
164
+ packageRulesPresent: dirExists(rulesDir),
165
+ packageTemplatesPresent: dirExists(templatesDir),
166
+ packageAgentsCount: packageAgents.length,
167
+ requiredAgentsCount: requiredAgents.length,
168
+ hasSubagentsCommand,
169
+ installedAgentsCount: installedAgents.length,
170
+ hasRootAgentsMd: fileExists(join(cwd, "AGENTS.md")),
171
+ hasPiSettings: fileExists(join(cwd, ".pi", "settings.json")),
172
+ promptsCount: prompts.length,
173
+ skillsCount: skills.length,
174
+ missingAgents,
175
+ });
188
176
 
189
177
  pi.sendMessage({
190
178
  customType: "arey-pi-doctor",
@@ -196,19 +184,22 @@ export default function areyPi(pi: ExtensionAPI) {
196
184
  });
197
185
 
198
186
  pi.registerCommand("arey-bootstrap", {
199
- description: "Install Arey Pi project-local subagents and optional starter AGENTS.md",
187
+ description: "Install Arey Pi subagents and optionally scaffold specs/docs",
200
188
  handler: async (args, ctx) => {
201
189
  const cwd = cwdFrom(ctx);
202
- const force = args.split(/\s+/).includes("--force");
203
- const createAgentsMd = args.split(/\s+/).includes("--agentsmd");
190
+ const { force, createAgentsMd, createSpecs, createDocs } = parseBootstrapFlags(args);
204
191
  const targetDir = join(cwd, ".pi", "agents", "arey-pi");
205
192
  const result = copyAgents(targetDir, force);
193
+ const specsResult = createSpecs ? scaffoldSpecs(cwd, force) : { created: [], skipped: [] };
194
+ const docsResult = createDocs ? scaffoldDocs(cwd, force) : { created: [], skipped: [] };
206
195
  const agentsMdPath = join(cwd, "AGENTS.md");
207
196
  let agentsMdStatus = "unchanged";
208
197
 
209
198
  if (!fileExists(agentsMdPath) && (createAgentsMd || force)) {
210
199
  writeFileSync(agentsMdPath, starterAgentsMd());
211
200
  agentsMdStatus = "created";
201
+ } else if (fileExists(agentsMdPath) && createAgentsMd && !force) {
202
+ agentsMdStatus = "skipped existing";
212
203
  }
213
204
 
214
205
  const report = [
@@ -219,13 +210,27 @@ export default function areyPi(pi: ExtensionAPI) {
219
210
  `- Skipped existing agents: ${result.skipped.length}`,
220
211
  `- Missing package agents: ${result.missing.length}`,
221
212
  `- AGENTS.md: ${agentsMdStatus}`,
213
+ `- Spec scaffold created: ${specsResult.created.length}`,
214
+ `- Spec scaffold skipped: ${specsResult.skipped.length}`,
215
+ `- Docs scaffold created: ${docsResult.created.length}`,
216
+ `- Docs scaffold skipped: ${docsResult.skipped.length}`,
222
217
  "",
223
- "## Copied",
218
+ "## Copied agents",
224
219
  result.copied.length ? result.copied.map((agent) => `- ${agent}`).join("\n") : "- none",
225
220
  "",
226
- "## Skipped",
221
+ "## Skipped agents",
227
222
  result.skipped.length ? result.skipped.map((agent) => `- ${agent}`).join("\n") : "- none",
228
223
  "",
224
+ "## Created scaffold files",
225
+ [...specsResult.created, ...docsResult.created].length
226
+ ? [...specsResult.created, ...docsResult.created].map((path) => `- ${path}`).join("\n")
227
+ : "- none",
228
+ "",
229
+ "## Skipped scaffold files",
230
+ [...specsResult.skipped, ...docsResult.skipped].length
231
+ ? [...specsResult.skipped, ...docsResult.skipped].map((path) => `- ${path}`).join("\n")
232
+ : "- none",
233
+ "",
229
234
  "Run `/arey-doctor` to verify setup.",
230
235
  ].join("\n");
231
236
 
@@ -233,7 +238,7 @@ export default function areyPi(pi: ExtensionAPI) {
233
238
  customType: "arey-pi-bootstrap",
234
239
  content: report,
235
240
  display: true,
236
- details: result,
241
+ details: { agents: result, specs: specsResult, docs: docsResult, agentsMd: agentsMdStatus },
237
242
  });
238
243
  },
239
244
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arey-pi",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A Pi package for canonical Gherkin specs, non-negotiable TDD, spec synchronisation, AI harness readiness, and senior-quality software delivery.",
5
5
  "license": "MIT",
6
6
  "author": "Alejandro Rey Leyva",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "pi": {
37
37
  "extensions": [
38
- "./extensions/arey-pi.ts"
38
+ "./extensions/arey-pi/index.ts"
39
39
  ],
40
40
  "skills": [
41
41
  "./skills"
@@ -48,7 +48,8 @@
48
48
  "format": "biome format --write .",
49
49
  "lint": "biome lint .",
50
50
  "typecheck": "tsc --noEmit",
51
- "check": "bun run lint && bun run typecheck",
51
+ "test": "bun test",
52
+ "check": "bun run lint && bun run typecheck && bun run test",
52
53
  "prepublishOnly": "bun run check && npm pack --dry-run"
53
54
  },
54
55
  "peerDependencies": {
@@ -65,6 +66,7 @@
65
66
  "devDependencies": {
66
67
  "@biomejs/biome": "^2.4.16",
67
68
  "@earendil-works/pi-coding-agent": "^0.78.1",
69
+ "@types/bun": "^1.3.14",
68
70
  "@types/node": "^25.9.2",
69
71
  "typescript": "^6.0.3"
70
72
  }
@@ -54,6 +54,7 @@ Check whether:
54
54
  - coverage is available or intentionally absent;
55
55
  - mutation testing is configured for critical code or proposed as an improvement;
56
56
  - tests assert behaviour rather than implementation mechanics;
57
+ - tests are organised in a dedicated test/spec directory rather than colocated with production source files without justification;
57
58
  - edge cases and failure paths are covered for important behaviour;
58
59
  - surviving mutants or weak assertions are triaged when evidence exists.
59
60
 
@@ -12,6 +12,7 @@ A change is complete when:
12
12
 
13
13
  - relevant Gherkin specs exist or are explicitly confirmed unaffected;
14
14
  - production behaviour is covered by meaningful tests;
15
+ - tests are placed in a dedicated test/spec directory outside production source trees, unless an explicit project or framework constraint justifies an exception;
15
16
  - test quality has been assessed with mutation testing, coverage, or explicit review appropriate to risk;
16
17
  - TDD was followed for production behaviour;
17
18
  - bug fixes include regression tests;
@@ -37,6 +38,7 @@ A change is not done if:
37
38
 
38
39
  - behaviour changed but Gherkin was not updated or justified unaffected;
39
40
  - tests were skipped silently;
41
+ - new tests are colocated inside production source directories without a documented convention or approved exception;
40
42
  - production code was written without TDD evidence;
41
43
  - failing tests remain unresolved without explicit blocker status;
42
44
  - code contradicts canonical specs;
@@ -57,7 +59,7 @@ Agents should close with:
57
59
  ```txt
58
60
  Done summary:
59
61
  - Behaviour/spec impact:
60
- - Tests/TDD:
62
+ - Tests/TDD, including test location:
61
63
  - Validation:
62
64
  - Quality tooling:
63
65
  - Spec sync:
@@ -16,13 +16,16 @@ Red → Green → Refactor
16
16
 
17
17
  This applies to features, bug fixes, behaviour changes, risky refactors, API/CLI behaviour, validation, permissions, persistence, and error handling.
18
18
 
19
+ Tests must live outside production source directories by default.
20
+ Do not colocate test files beside production files in `src/` or equivalent source trees unless an existing project convention explicitly requires it or the user approves an exception.
21
+
19
22
  ## Red
20
23
 
21
24
  Before implementation, create, update, or identify a test that fails for the intended reason.
22
25
 
23
26
  Valid Red evidence includes:
24
27
 
25
- - a newly added failing test;
28
+ - a newly added failing test in the dedicated test directory;
26
29
  - an updated failing test;
27
30
  - an existing failing test that already captures the intended behaviour;
28
31
  - a documented inability to run the test, including the exact intended command and reason.
@@ -46,6 +49,32 @@ After Green, refactor only while tests remain green.
46
49
 
47
50
  Refactoring should improve clarity, structure, duplication, or maintainability without expanding scope or changing behaviour.
48
51
 
52
+ ## Test Location
53
+
54
+ Use a dedicated test/spec directory for automated tests.
55
+
56
+ Preferred locations include project conventions such as:
57
+
58
+ ```txt
59
+ tests/
60
+ test/
61
+ __tests__/
62
+ spec/
63
+ ```
64
+
65
+ When adding tests for code under `src/`, mirror the production module structure under the chosen test directory instead of creating sibling test files inside `src/`.
66
+
67
+ Example:
68
+
69
+ ```txt
70
+ src/domain/accounts/password-reset.ts
71
+ tests/domain/accounts/password-reset.test.ts
72
+ ```
73
+
74
+ If a repository already has a clear separate test root, follow it.
75
+ If it only has colocated tests, ask before continuing the pattern or migrating it.
76
+ If a framework mandates colocated tests, document the constraint in the final evidence.
77
+
49
78
  ## Bug Fixes
50
79
 
51
80
  Every bug fix requires a regression test.
@@ -82,5 +111,6 @@ Completion must report:
82
111
  - Green evidence;
83
112
  - refactor status;
84
113
  - commands run;
114
+ - test location and any exception to separate test directories;
85
115
  - tests not run and why;
86
116
  - residual risks.
@@ -23,6 +23,36 @@ Agents should assess test quality across these dimensions:
23
23
  5. **Minimal coupling:** the test avoids depending on private implementation details unless intentionally characterizing legacy code before refactor.
24
24
  6. **Maintainability:** the test is readable, focused, deterministic, and not overly broad.
25
25
  7. **Regression value:** for bug fixes, the test would have failed before the fix.
26
+ 8. **Source separation:** tests live in a dedicated test/spec directory rather than being colocated with production files, unless an explicit project or framework constraint justifies an exception.
27
+
28
+ ## Test Organisation
29
+
30
+ Tests should be organised outside production source directories.
31
+
32
+ Prefer a project-level test root such as:
33
+
34
+ ```txt
35
+ tests/
36
+ test/
37
+ __tests__/
38
+ spec/
39
+ ```
40
+
41
+ Mirror production structure inside that test root when useful.
42
+
43
+ Avoid creating files such as:
44
+
45
+ ```txt
46
+ src/foo.test.ts
47
+ src/foo.spec.ts
48
+ src/foo.test.py
49
+ ```
50
+
51
+ unless the repository has an established, user-approved, or framework-mandated colocated test convention.
52
+
53
+ This keeps production source trees clean,
54
+ makes generated tests easier to audit,
55
+ and avoids mixing executable product code with validation artefacts.
26
56
 
27
57
  ## Coverage
28
58
 
@@ -101,7 +131,8 @@ Agents must reject or improve tests that:
101
131
  - over-mock collaborators so the real contract is not exercised;
102
132
  - assert private structure instead of observable behaviour;
103
133
  - pass even if important logic is removed;
104
- - lack a clear connection to a spec, bug, or requirement.
134
+ - lack a clear connection to a spec, bug, or requirement;
135
+ - are colocated with production source files without an explicit project convention or approved exception.
105
136
 
106
137
  ## Negative and Edge Cases
107
138
 
@@ -130,7 +161,7 @@ If the answer is no, the test is probably weak.
130
161
 
131
162
  For non-trivial production changes, agents should report:
132
163
 
133
- - tests added or modified;
164
+ - tests added or modified, including their dedicated test directory location;
134
165
  - related Gherkin scenarios or requirements;
135
166
  - Red evidence;
136
167
  - Green evidence;
@@ -0,0 +1,25 @@
1
+ # Agent Instructions
2
+
3
+ This project uses Arey Pi.
4
+
5
+ ## Delivery rules
6
+
7
+ - Treat canonical specs as the source of truth.
8
+ - Use Gherkin for behaviour specs.
9
+ - Use DBML for database specs when the project has persistence.
10
+ - Follow TDD for production behaviour changes.
11
+ - Put tests in a dedicated test/spec directory outside production source trees unless a documented project or framework convention requires otherwise.
12
+ - Keep specs, tests, code, DBML, ADRs, glossary, architecture docs, README files, docs, AGENTS.md, commands, and tooling instructions synchronised.
13
+ - Capture significant technical decisions in high-quality ADRs.
14
+ - Run formatter, lint/static analysis, typecheck, tests, and relevant dynamic analysis where available.
15
+ - Use incremental Conventional Commits for meaningful steps.
16
+
17
+ ## Subagents
18
+
19
+ Project-local Arey Pi subagents live in:
20
+
21
+ ```txt
22
+ .pi/agents/arey-pi/
23
+ ```
24
+
25
+ Use them through pi-subagents when available.
@@ -0,0 +1,60 @@
1
+ # ADR-NNNN: Decision Title
2
+
3
+ ## Status
4
+
5
+ Proposed
6
+
7
+ ## Context
8
+
9
+ Describe the forces,
10
+ constraints,
11
+ requirements,
12
+ and tradeoffs that make this decision necessary.
13
+
14
+ ## Decision
15
+
16
+ State the decision clearly.
17
+
18
+ ## Options Considered
19
+
20
+ ### Option 1
21
+
22
+ Summary.
23
+
24
+ Pros:
25
+
26
+ - ...
27
+
28
+ Cons:
29
+
30
+ - ...
31
+
32
+ ### Option 2
33
+
34
+ Summary.
35
+
36
+ Pros:
37
+
38
+ - ...
39
+
40
+ Cons:
41
+
42
+ - ...
43
+
44
+ ## Consequences
45
+
46
+ Describe expected consequences,
47
+ including risks,
48
+ costs,
49
+ follow-up work,
50
+ and operational impact.
51
+
52
+ ## Supersession and Relationships
53
+
54
+ Record whether this ADR supersedes,
55
+ is superseded by,
56
+ or overlaps with other ADRs.
57
+
58
+ ## Revisit Conditions
59
+
60
+ List conditions that should trigger review of this decision.
@@ -0,0 +1,9 @@
1
+ # Architecture
2
+
3
+ Use this directory for durable architecture memory.
4
+
5
+ Document boundaries,
6
+ integrations,
7
+ ownership,
8
+ constraints,
9
+ and current system structure that future humans and agents need to preserve.
@@ -0,0 +1,10 @@
1
+ # Database Specs
2
+
3
+ Database projects must keep canonical DBML specs here or document the canonical DBML location.
4
+
5
+ DBML must stay synchronised with migrations,
6
+ ORM models,
7
+ SQL DDL,
8
+ constraints,
9
+ indexes,
10
+ and relationships.
@@ -0,0 +1,14 @@
1
+ // Canonical database specification.
2
+ // Keep this DBML synchronised with migrations, ORM models, SQL DDL, constraints, indexes, and relationships.
3
+
4
+ Project project_name {
5
+ database_type: 'PostgreSQL'
6
+ Note: 'Replace this starter DBML with the canonical project schema.'
7
+ }
8
+
9
+ Table example_entities {
10
+ id uuid [pk, note: 'Primary identifier']
11
+ name varchar [not null]
12
+ created_at timestamptz [not null]
13
+ updated_at timestamptz [not null]
14
+ }
@@ -0,0 +1,11 @@
1
+ # Decisions
2
+
3
+ Use this directory for high-quality ADRs.
4
+
5
+ ADRs should capture meaningful technical decisions,
6
+ context,
7
+ options,
8
+ tradeoffs,
9
+ consequences,
10
+ revisit conditions,
11
+ and supersession relationships.
@@ -0,0 +1,9 @@
1
+ # Documentation
2
+
3
+ Use this directory for project-facing documentation that is not itself a canonical spec.
4
+
5
+ Keep usage,
6
+ setup,
7
+ commands,
8
+ operations,
9
+ and workflow instructions synchronised with the implementation and Arey Pi rules.
@@ -0,0 +1,17 @@
1
+ Feature: Feature name
2
+ As a stakeholder
3
+ I want a capability
4
+ So that an outcome is achieved
5
+
6
+ Background:
7
+ Given relevant starting context
8
+
9
+ Scenario: Observable behaviour
10
+ Given preconditions
11
+ When an action occurs
12
+ Then the expected outcome is observable
13
+
14
+ Scenario: Important edge case
15
+ Given edge-case preconditions
16
+ When an action occurs
17
+ Then the system handles the case explicitly
@@ -0,0 +1,7 @@
1
+ # Behaviour Specs
2
+
3
+ Write behaviour specs in Gherkin.
4
+
5
+ Use semantic line breaks in feature files and accompanying notes.
6
+ Each feature should describe externally observable behaviour,
7
+ not implementation details.
@@ -0,0 +1,19 @@
1
+ # Glossary
2
+
3
+ Use this glossary for durable domain language.
4
+
5
+ ## Terms
6
+
7
+ <!--
8
+ Add terms as they become important.
9
+
10
+ Example:
11
+
12
+ ### Account
13
+
14
+ Definition.
15
+
16
+ Related specs:
17
+
18
+ - specs/features/example.feature
19
+ -->
@@ -0,0 +1,120 @@
1
+ # Arey Pi Project Readiness Report
2
+
3
+ ## Overall
4
+
5
+ - Overall Readiness: N/5
6
+ - Lowest Rule Scores:
7
+ - Highest Rule Scores:
8
+
9
+ ## Executive Summary
10
+
11
+ Summarise the current readiness posture.
12
+
13
+ ## Blockers
14
+
15
+ List issues that prevent reliable Arey Pi delivery.
16
+
17
+ ## Quick Wins
18
+
19
+ List low-effort improvements with high leverage.
20
+
21
+ ## Rule Scores
22
+
23
+ ### Canonical Specs
24
+
25
+ - Score:
26
+ - Evidence:
27
+ - Findings:
28
+ - Recommendations:
29
+
30
+ ### Gherkin Authoring
31
+
32
+ - Score:
33
+ - Evidence:
34
+ - Findings:
35
+ - Recommendations:
36
+
37
+ ### Tests/TDD
38
+
39
+ - Score:
40
+ - Evidence:
41
+ - Findings:
42
+ - Recommendations:
43
+
44
+ ### Test Quality
45
+
46
+ - Score:
47
+ - Evidence:
48
+ - Findings:
49
+ - Recommendations:
50
+
51
+ ### Quality Tooling
52
+
53
+ - Score:
54
+ - Evidence:
55
+ - Findings:
56
+ - Recommendations:
57
+
58
+ ### Engineering Quality
59
+
60
+ - Score:
61
+ - Evidence:
62
+ - Findings:
63
+ - Recommendations:
64
+
65
+ ### Spec Sync
66
+
67
+ - Score:
68
+ - Evidence:
69
+ - Findings:
70
+ - Recommendations:
71
+
72
+ ### Documentation Sync
73
+
74
+ - Score:
75
+ - Evidence:
76
+ - Findings:
77
+ - Recommendations:
78
+
79
+ ### Database Specs
80
+
81
+ - Score:
82
+ - Evidence:
83
+ - Findings:
84
+ - Recommendations:
85
+
86
+ ### Rebuildability
87
+
88
+ - Score:
89
+ - Evidence:
90
+ - Findings:
91
+ - Recommendations:
92
+
93
+ ### Architecture Memory and ADRs
94
+
95
+ - Score:
96
+ - Evidence:
97
+ - Findings:
98
+ - Recommendations:
99
+
100
+ ### Incremental Commits
101
+
102
+ - Score:
103
+ - Evidence:
104
+ - Findings:
105
+ - Recommendations:
106
+
107
+ ### AI Harness
108
+
109
+ - Score:
110
+ - Evidence:
111
+ - Findings:
112
+ - Recommendations:
113
+
114
+ ## Recommended Plan
115
+
116
+ 1. ...
117
+
118
+ ## Residual Risks / Unknowns
119
+
120
+ List what could not be verified.
@@ -0,0 +1,6 @@
1
+ # Specs
2
+
3
+ This directory contains canonical Arey Pi project specifications.
4
+
5
+ Specs are durable project knowledge.
6
+ Keep them synchronised with tests, code, DBML, ADRs, glossary, architecture docs, and project documentation.