arey-pi 0.4.0 → 0.6.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 +29 -14
- package/docs/adoption.md +6 -6
- package/docs/commands.md +37 -194
- package/docs/templates.md +1 -1
- package/docs/workflows.md +13 -14
- package/extensions/arey-pi/bootstrap.ts +198 -0
- package/extensions/arey-pi/core.ts +33 -19
- package/extensions/arey-pi/index.ts +5 -270
- package/extensions/arey-pi/paths.ts +28 -0
- package/extensions/arey-pi/workflow-runtime.ts +112 -0
- package/package.json +1 -1
- package/prompts/adr-review.md +33 -0
- package/prompts/engineering-review.md +37 -0
- package/prompts/feature-spec.md +35 -0
- package/prompts/red-green-refactor.md +34 -0
- package/prompts/sync-drift.md +44 -0
- package/skills/engineering-review/SKILL.md +65 -0
- package/skills/spec-sync/SKILL.md +69 -0
- package/skills/tdd-red-green-refactor/SKILL.md +69 -0
package/README.md
CHANGED
|
@@ -50,6 +50,12 @@ The rules are the policy layer.
|
|
|
50
50
|
The skills and prompts make those policies usable inside Pi.
|
|
51
51
|
The agents define the intended specialist roles for subagent-backed delivery.
|
|
52
52
|
|
|
53
|
+
Arey Pi includes focused prompt templates and skills for feature specs,
|
|
54
|
+
strict Red-Green-Refactor,
|
|
55
|
+
spec drift repair,
|
|
56
|
+
ADR assessment,
|
|
57
|
+
and adversarial engineering review.
|
|
58
|
+
|
|
53
59
|
## Current subagent architecture
|
|
54
60
|
|
|
55
61
|
Arey Pi is designed to work with `pi-subagents`.
|
|
@@ -113,7 +119,7 @@ Or load the readiness skill directly:
|
|
|
113
119
|
/skill:project-readiness
|
|
114
120
|
```
|
|
115
121
|
|
|
116
|
-
Arey Pi also ships an extension with native
|
|
122
|
+
Arey Pi also ships an extension with native setup commands and automatic natural-language harness activation.
|
|
117
123
|
|
|
118
124
|
When the Arey Pi agents are available to `pi-subagents`, the project evaluator runtime name is:
|
|
119
125
|
|
|
@@ -123,7 +129,7 @@ arey-pi.project-evaluator
|
|
|
123
129
|
|
|
124
130
|
## Extension-backed workflow
|
|
125
131
|
|
|
126
|
-
Arey Pi includes a polished extension-backed workflow:
|
|
132
|
+
Arey Pi includes a polished extension-backed setup and natural-language workflow harness:
|
|
127
133
|
|
|
128
134
|
```txt
|
|
129
135
|
/arey-doctor # check package, subagent, prompt, skill, and project readiness setup
|
|
@@ -133,19 +139,23 @@ Arey Pi includes a polished extension-backed workflow:
|
|
|
133
139
|
/arey-bootstrap --docs # scaffold starter docs directory
|
|
134
140
|
/arey-bootstrap --full # explicit alias for the default full bootstrap
|
|
135
141
|
/arey-bootstrap --force # full bootstrap and overwrite selected project-local files
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
/arey-assess # assess project readiness against Arey Pi rules
|
|
142
|
+
# Development workflows are natural-language first:
|
|
143
|
+
# "Implementa password reset siguiendo Arey Pi"
|
|
144
|
+
# "Corrige este bug con Arey Pi"
|
|
145
|
+
# "Revisa el current diff contra Arey Pi"
|
|
141
146
|
```
|
|
142
147
|
|
|
143
|
-
The goal is that users
|
|
144
|
-
|
|
148
|
+
The goal is that users work naturally without development commands.
|
|
149
|
+
Requests such as `Implementa password reset siguiendo Arey Pi` automatically activate quiet harness context behind the scenes.
|
|
150
|
+
Arey Pi lets the parent agent infer the work mode,
|
|
151
|
+
act as orchestrator,
|
|
152
|
+
use specialist subagents when available,
|
|
153
|
+
inject the relevant delivery guidance,
|
|
154
|
+
and apply simple event-based guardrails for protected paths.
|
|
145
155
|
|
|
146
156
|
See:
|
|
147
157
|
|
|
148
|
-
- `docs/commands.md` for
|
|
158
|
+
- `docs/commands.md` for setup commands and natural-language workflow behaviour;
|
|
149
159
|
- `docs/adoption.md` for adopting Arey Pi in an existing repository;
|
|
150
160
|
- `docs/workflows.md` for workflow expectations;
|
|
151
161
|
- `docs/workflow-diagram.md` for the visual framework workflow;
|
|
@@ -189,8 +199,13 @@ The policy layer,
|
|
|
189
199
|
readiness workflow,
|
|
190
200
|
documentation sync rule,
|
|
191
201
|
core subagent role definitions,
|
|
192
|
-
and professional extension commands exist.
|
|
202
|
+
and professional setup extension commands exist.
|
|
203
|
+
|
|
204
|
+
Arey Pi now includes natural-language harness activation,
|
|
205
|
+
focused prompts,
|
|
206
|
+
TDD/spec-sync/review skills,
|
|
207
|
+
and extension-core tests.
|
|
193
208
|
|
|
194
|
-
Next
|
|
195
|
-
|
|
196
|
-
and deeper
|
|
209
|
+
Next improvements include stronger bootstrap scaffolding,
|
|
210
|
+
custom Arey Pi tools,
|
|
211
|
+
and deeper enforcement through Pi extension events.
|
package/docs/adoption.md
CHANGED
|
@@ -85,13 +85,13 @@ agents should be able to discover:
|
|
|
85
85
|
|
|
86
86
|
### 5. Assess readiness
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
Ask naturally:
|
|
89
89
|
|
|
90
90
|
```txt
|
|
91
|
-
|
|
91
|
+
Evalúa este repo contra Arey Pi
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
You can also use the focused prompt template if desired:
|
|
95
95
|
|
|
96
96
|
```txt
|
|
97
97
|
/assess-project
|
|
@@ -155,7 +155,7 @@ Use this for active product repositories.
|
|
|
155
155
|
- Add Gherkin specs for core behaviours.
|
|
156
156
|
- Add DBML if persistence exists.
|
|
157
157
|
- Add ADRs for significant decisions.
|
|
158
|
-
- Require
|
|
158
|
+
- Require natural Arey Pi sync review before completing non-trivial work.
|
|
159
159
|
|
|
160
160
|
### Strict adoption
|
|
161
161
|
|
|
@@ -202,11 +202,11 @@ Do not:
|
|
|
202
202
|
## Completion Standard
|
|
203
203
|
|
|
204
204
|
After adoption work,
|
|
205
|
-
run:
|
|
205
|
+
run setup diagnostics and ask for a natural readiness assessment:
|
|
206
206
|
|
|
207
207
|
```txt
|
|
208
208
|
/arey-doctor
|
|
209
|
-
|
|
209
|
+
Evalúa este repo contra Arey Pi
|
|
210
210
|
```
|
|
211
211
|
|
|
212
212
|
A good first adoption result is not perfection.
|
package/docs/commands.md
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
# Arey Pi Commands
|
|
2
2
|
|
|
3
|
-
Arey Pi ships a Pi extension that registers native slash commands.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
The commands are designed for two modes of use:
|
|
7
|
-
|
|
8
|
-
- quick explicit workflows such as `/arey-feature` or `/arey-sync`;
|
|
9
|
-
- natural-language work where the parent agent acts as the Arey Pi tech lead and uses the same workflow expectations.
|
|
3
|
+
Arey Pi ships a Pi extension that registers native setup slash commands.
|
|
4
|
+
Development workflows are intentionally natural-language first:
|
|
5
|
+
the extension recognises explicit Arey Pi opt-in and injects quiet harness guidance automatically.
|
|
10
6
|
|
|
11
7
|
## Command overview
|
|
12
8
|
|
|
13
9
|
```txt
|
|
14
10
|
/arey-doctor
|
|
15
11
|
/arey-bootstrap [--agentsmd] [--specs] [--docs] [--full] [--force]
|
|
16
|
-
/arey-feature <feature request>
|
|
17
|
-
/arey-bugfix <bug description>
|
|
18
|
-
/arey-sync [scope]
|
|
19
|
-
/arey-review [scope]
|
|
20
|
-
/arey-assess [scope]
|
|
21
12
|
```
|
|
22
13
|
|
|
23
14
|
## `/arey-doctor`
|
|
@@ -158,197 +149,49 @@ Examples:
|
|
|
158
149
|
|
|
159
150
|
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`.
|
|
160
151
|
|
|
161
|
-
##
|
|
162
|
-
|
|
163
|
-
Starts the Arey Pi feature delivery workflow.
|
|
164
|
-
|
|
165
|
-
Usage:
|
|
166
|
-
|
|
167
|
-
```txt
|
|
168
|
-
/arey-feature <feature request>
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Example:
|
|
172
|
-
|
|
173
|
-
```txt
|
|
174
|
-
/arey-feature Add password reset with expiring email links
|
|
175
|
-
```
|
|
152
|
+
## Natural-language development workflows
|
|
176
153
|
|
|
177
|
-
|
|
178
|
-
|
|
154
|
+
Arey Pi is designed to work without development slash commands.
|
|
155
|
+
When the user explicitly opts into Arey Pi in normal language,
|
|
156
|
+
for example:
|
|
179
157
|
|
|
180
158
|
```txt
|
|
181
|
-
|
|
159
|
+
Implementa password reset siguiendo Arey Pi
|
|
160
|
+
Corrige este bug con Arey Pi
|
|
161
|
+
Revisa el current diff contra Arey Pi
|
|
162
|
+
Evalúa este repo contra Arey Pi
|
|
182
163
|
```
|
|
183
164
|
|
|
184
|
-
The
|
|
165
|
+
The extension injects quiet harness context automatically before the agent turn.
|
|
166
|
+
The harness is not meant to add ceremony for the user.
|
|
167
|
+
It asks the agent to infer whether the request is a feature,
|
|
168
|
+
bugfix,
|
|
169
|
+
sync,
|
|
170
|
+
review,
|
|
171
|
+
assessment,
|
|
172
|
+
or mixed task,
|
|
173
|
+
then apply the corresponding Arey Pi posture.
|
|
174
|
+
The parent agent should act as orchestrator,
|
|
175
|
+
use specialist Arey Pi subagents when available,
|
|
176
|
+
and continue conversationally while reporting evidence naturally.
|
|
185
177
|
|
|
186
|
-
|
|
187
|
-
- preserve TDD through Red → Green → Refactor;
|
|
188
|
-
- synchronise specs, docs, tests, code, DBML, ADRs, glossary, and architecture docs;
|
|
189
|
-
- run engineering review when risk warrants it;
|
|
190
|
-
- report validation evidence and residual risks.
|
|
191
|
-
|
|
192
|
-
## `/arey-bugfix`
|
|
193
|
-
|
|
194
|
-
Starts the Arey Pi regression-test-first bugfix workflow.
|
|
195
|
-
|
|
196
|
-
Usage:
|
|
197
|
-
|
|
198
|
-
```txt
|
|
199
|
-
/arey-bugfix <bug description>
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
Example:
|
|
203
|
-
|
|
204
|
-
```txt
|
|
205
|
-
/arey-bugfix Users can bypass email verification by refreshing the session
|
|
206
|
-
```
|
|
178
|
+
The injected harness guidance emphasises:
|
|
207
179
|
|
|
208
|
-
|
|
180
|
+
- `arey-pi.spec-author` for canonical specs;
|
|
181
|
+
- `arey-pi.tdd-implementer` for Red → Green → Refactor;
|
|
182
|
+
- `arey-pi.spec-syncer` for alignment;
|
|
183
|
+
- `arey-pi.engineering-reviewer` for fresh review;
|
|
184
|
+
- `arey-pi.project-evaluator` for readiness assessment;
|
|
185
|
+
- builtin scout/planner/reviewer/oracle-style agents for discovery, planning, and second opinions.
|
|
209
186
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
- keep TDD evidence visible;
|
|
213
|
-
- update Gherkin, docs, DBML, ADRs, glossary, or architecture docs when affected;
|
|
214
|
-
- run validation and report residual risks.
|
|
187
|
+
While Arey Pi is active,
|
|
188
|
+
Arey Pi applies simple tool-call guardrails:
|
|
215
189
|
|
|
216
|
-
|
|
190
|
+
- writes or edits to protected paths such as `.env`, `.git/`, and `node_modules/` are blocked.
|
|
217
191
|
|
|
218
|
-
Runs Arey Pi sync review for the current repository or a specific scope.
|
|
219
192
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
```txt
|
|
223
|
-
/arey-sync
|
|
224
|
-
/arey-sync <scope>
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Examples:
|
|
228
|
-
|
|
229
|
-
```txt
|
|
230
|
-
/arey-sync
|
|
231
|
-
/arey-sync authentication flow
|
|
232
|
-
/arey-sync current diff
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
The command asks the parent agent to verify alignment across:
|
|
236
|
-
|
|
237
|
-
- Gherkin specs;
|
|
238
|
-
- tests;
|
|
239
|
-
- code;
|
|
240
|
-
- DBML;
|
|
241
|
-
- ADRs;
|
|
242
|
-
- glossary;
|
|
243
|
-
- architecture docs;
|
|
244
|
-
- README files;
|
|
245
|
-
- `docs/`;
|
|
246
|
-
- `AGENTS.md`;
|
|
247
|
-
- skills, prompts, rules, agents, examples, templates;
|
|
248
|
-
- command and tooling instructions.
|
|
249
|
-
|
|
250
|
-
The final report should include both:
|
|
251
|
-
|
|
252
|
-
```txt
|
|
253
|
-
Specs updated
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
or:
|
|
257
|
-
|
|
258
|
-
```txt
|
|
259
|
-
Specs unaffected: <reason>
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
and:
|
|
263
|
-
|
|
264
|
-
```txt
|
|
265
|
-
Docs updated
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
or:
|
|
269
|
-
|
|
270
|
-
```txt
|
|
271
|
-
Docs unaffected: <reason>
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
## `/arey-review`
|
|
275
|
-
|
|
276
|
-
Runs an adversarial Arey Pi engineering review.
|
|
277
|
-
|
|
278
|
-
Usage:
|
|
279
|
-
|
|
280
|
-
```txt
|
|
281
|
-
/arey-review
|
|
282
|
-
/arey-review <scope>
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
Examples:
|
|
286
|
-
|
|
287
|
-
```txt
|
|
288
|
-
/arey-review
|
|
289
|
-
/arey-review current diff
|
|
290
|
-
/arey-review persistence layer
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
The review should examine:
|
|
294
|
-
|
|
295
|
-
- architecture and code quality;
|
|
296
|
-
- test quality;
|
|
297
|
-
- quality tooling and validation evidence;
|
|
298
|
-
- security and privacy;
|
|
299
|
-
- reliability and operability;
|
|
300
|
-
- maintainability;
|
|
301
|
-
- spec, ADR, DBML, glossary, and documentation sync concerns;
|
|
302
|
-
- generated-code or agent-authored-code slop.
|
|
303
|
-
|
|
304
|
-
Findings should be classified by severity.
|
|
305
|
-
|
|
306
|
-
## `/arey-assess`
|
|
307
|
-
|
|
308
|
-
Runs Arey Pi project readiness assessment.
|
|
309
|
-
|
|
310
|
-
Usage:
|
|
311
|
-
|
|
312
|
-
```txt
|
|
313
|
-
/arey-assess
|
|
314
|
-
/arey-assess <scope>
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Examples:
|
|
318
|
-
|
|
319
|
-
```txt
|
|
320
|
-
/arey-assess
|
|
321
|
-
/arey-assess backend package only
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
The assessment is read-only by default.
|
|
325
|
-
It should score the repository against Arey Pi rules,
|
|
326
|
-
provide evidence with file paths,
|
|
327
|
-
identify blockers and quick wins,
|
|
328
|
-
and propose a prioritised improvement plan.
|
|
329
|
-
|
|
330
|
-
Use this when adopting Arey Pi in an existing repository or checking whether a project remains aligned.
|
|
331
|
-
|
|
332
|
-
## Busy agent behaviour
|
|
333
|
-
|
|
334
|
-
Workflow commands send a user message to the current Pi session.
|
|
335
|
-
|
|
336
|
-
If the agent is idle,
|
|
337
|
-
the workflow starts immediately.
|
|
338
|
-
|
|
339
|
-
If the agent is already working,
|
|
340
|
-
the workflow is queued as a follow-up message.
|
|
341
|
-
|
|
342
|
-
## Relationship to natural language
|
|
343
|
-
|
|
344
|
-
Commands are optional.
|
|
345
|
-
|
|
346
|
-
Users can also work naturally:
|
|
347
|
-
|
|
348
|
-
```txt
|
|
349
|
-
Implement magic links following Arey Pi.
|
|
350
|
-
```
|
|
193
|
+
## Prompt templates and skills
|
|
351
194
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
195
|
+
Arey Pi still ships focused prompt templates and skills for targeted use,
|
|
196
|
+
but they are optional.
|
|
197
|
+
The intended default is natural language plus automatic harness injection.
|
package/docs/templates.md
CHANGED
|
@@ -133,7 +133,7 @@ The readiness report template captures Arey Pi assessment output.
|
|
|
133
133
|
|
|
134
134
|
Use it when you want a persistent audit snapshot under `docs/`.
|
|
135
135
|
For routine checks,
|
|
136
|
-
|
|
136
|
+
ask naturally: `Evalúa este repo contra Arey Pi`.
|
|
137
137
|
|
|
138
138
|
## Template Maintenance
|
|
139
139
|
|
package/docs/workflows.md
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
See `docs/workflow-diagram.md` for a visual overview of the framework workflow.
|
|
4
4
|
|
|
5
|
-
Arey Pi workflows
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Natural language should still follow the same rules when the user asks to work following Arey Pi.
|
|
5
|
+
Arey Pi development workflows are natural-language first.
|
|
6
|
+
When the user asks to work following Arey Pi,
|
|
7
|
+
the extension injects quiet harness guidance automatically before the agent turn.
|
|
9
8
|
|
|
10
9
|
## Feature Workflow
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
Example request:
|
|
13
12
|
|
|
14
13
|
```txt
|
|
15
|
-
|
|
14
|
+
Implementa password reset siguiendo Arey Pi
|
|
16
15
|
```
|
|
17
16
|
|
|
18
17
|
Expected flow:
|
|
@@ -41,10 +40,10 @@ The workflow should:
|
|
|
41
40
|
|
|
42
41
|
## Bugfix Workflow
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
Example request:
|
|
45
44
|
|
|
46
45
|
```txt
|
|
47
|
-
|
|
46
|
+
Corrige el bug de verificación de email con Arey Pi
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
Use this when behaviour is wrong.
|
|
@@ -61,10 +60,10 @@ and it should live outside production source directories by default.
|
|
|
61
60
|
|
|
62
61
|
## Sync Workflow
|
|
63
62
|
|
|
64
|
-
|
|
63
|
+
Example request:
|
|
65
64
|
|
|
66
65
|
```txt
|
|
67
|
-
|
|
66
|
+
Sincroniza specs y docs con Arey Pi para el current diff
|
|
68
67
|
```
|
|
69
68
|
|
|
70
69
|
Use this before completing non-trivial work or when drift is suspected.
|
|
@@ -101,10 +100,10 @@ or justified unaffected statuses.
|
|
|
101
100
|
|
|
102
101
|
## Review Workflow
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
Example request:
|
|
105
104
|
|
|
106
105
|
```txt
|
|
107
|
-
|
|
106
|
+
Revisa el current diff contra Arey Pi
|
|
108
107
|
```
|
|
109
108
|
|
|
110
109
|
Use this for adversarial engineering review.
|
|
@@ -128,10 +127,10 @@ Findings should be classified by severity.
|
|
|
128
127
|
|
|
129
128
|
## Assessment Workflow
|
|
130
129
|
|
|
131
|
-
|
|
130
|
+
Example request:
|
|
132
131
|
|
|
133
132
|
```txt
|
|
134
|
-
|
|
133
|
+
Evalúa este repo contra Arey Pi
|
|
135
134
|
```
|
|
136
135
|
|
|
137
136
|
Use this to assess project readiness.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative } from "node:path";
|
|
3
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import {
|
|
5
|
+
buildDoctorReport,
|
|
6
|
+
docsScaffoldFiles,
|
|
7
|
+
parseBootstrapFlags,
|
|
8
|
+
requiredAgents,
|
|
9
|
+
specScaffoldFiles,
|
|
10
|
+
type ScaffoldFile,
|
|
11
|
+
} from "./core.ts";
|
|
12
|
+
import { agentSourceDir, cwdFrom, dirExists, fileExists, packageRoot, rulesDir, templatesDir } from "./paths.ts";
|
|
13
|
+
|
|
14
|
+
type AgentCopyResult = { copied: string[]; skipped: string[]; missing: string[] };
|
|
15
|
+
type ScaffoldResult = { created: string[]; skipped: string[] };
|
|
16
|
+
|
|
17
|
+
function copyAgents(targetDir: string, force: boolean): AgentCopyResult {
|
|
18
|
+
mkdirSync(targetDir, { recursive: true });
|
|
19
|
+
|
|
20
|
+
const copied: string[] = [];
|
|
21
|
+
const skipped: string[] = [];
|
|
22
|
+
const missing: string[] = [];
|
|
23
|
+
|
|
24
|
+
for (const agent of requiredAgents) {
|
|
25
|
+
const source = join(agentSourceDir, agent);
|
|
26
|
+
const target = join(targetDir, agent);
|
|
27
|
+
|
|
28
|
+
if (!fileExists(source)) {
|
|
29
|
+
missing.push(agent);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (fileExists(target) && !force) {
|
|
34
|
+
skipped.push(agent);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
copyFileSync(source, target);
|
|
39
|
+
copied.push(agent);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { copied, skipped, missing };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function templateContent(name: string): string {
|
|
46
|
+
return readFileSync(join(templatesDir, name), "utf8");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function writeTemplateIfMissing(file: ScaffoldFile, force: boolean, cwd: string, result: ScaffoldResult): void {
|
|
50
|
+
const target = join(cwd, file.target);
|
|
51
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
52
|
+
|
|
53
|
+
if (fileExists(target) && !force) {
|
|
54
|
+
result.skipped.push(file.target);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
writeFileSync(target, templateContent(file.template));
|
|
59
|
+
result.created.push(file.target);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function scaffoldFiles(cwd: string, force: boolean, files: ScaffoldFile[]): ScaffoldResult {
|
|
63
|
+
const result: ScaffoldResult = { created: [], skipped: [] };
|
|
64
|
+
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
writeTemplateIfMissing(file, force, cwd, result);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function packageVersion(): string {
|
|
73
|
+
try {
|
|
74
|
+
const pkg = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")) as { version?: string };
|
|
75
|
+
return pkg.version ?? "unknown";
|
|
76
|
+
} catch {
|
|
77
|
+
return "unknown";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function buildBootstrapReport(input: {
|
|
82
|
+
cwd: string;
|
|
83
|
+
targetDir: string;
|
|
84
|
+
agents: AgentCopyResult;
|
|
85
|
+
specs: ScaffoldResult;
|
|
86
|
+
docs: ScaffoldResult;
|
|
87
|
+
agentsMd: string;
|
|
88
|
+
}): string {
|
|
89
|
+
const createdScaffold = [...input.specs.created, ...input.docs.created];
|
|
90
|
+
const skippedScaffold = [...input.specs.skipped, ...input.docs.skipped];
|
|
91
|
+
|
|
92
|
+
return [
|
|
93
|
+
"# Arey Pi Bootstrap",
|
|
94
|
+
"",
|
|
95
|
+
`- Target: ${relative(input.cwd, input.targetDir)}`,
|
|
96
|
+
`- Copied agents: ${input.agents.copied.length}`,
|
|
97
|
+
`- Skipped existing agents: ${input.agents.skipped.length}`,
|
|
98
|
+
`- Missing package agents: ${input.agents.missing.length}`,
|
|
99
|
+
`- AGENTS.md: ${input.agentsMd}`,
|
|
100
|
+
`- Spec scaffold created: ${input.specs.created.length}`,
|
|
101
|
+
`- Spec scaffold skipped: ${input.specs.skipped.length}`,
|
|
102
|
+
`- Docs scaffold created: ${input.docs.created.length}`,
|
|
103
|
+
`- Docs scaffold skipped: ${input.docs.skipped.length}`,
|
|
104
|
+
"",
|
|
105
|
+
"## Copied agents",
|
|
106
|
+
input.agents.copied.length ? input.agents.copied.map((agent) => `- ${agent}`).join("\n") : "- none",
|
|
107
|
+
"",
|
|
108
|
+
"## Skipped agents",
|
|
109
|
+
input.agents.skipped.length ? input.agents.skipped.map((agent) => `- ${agent}`).join("\n") : "- none",
|
|
110
|
+
"",
|
|
111
|
+
"## Created scaffold files",
|
|
112
|
+
createdScaffold.length ? createdScaffold.map((path) => `- ${path}`).join("\n") : "- none",
|
|
113
|
+
"",
|
|
114
|
+
"## Skipped scaffold files",
|
|
115
|
+
skippedScaffold.length ? skippedScaffold.map((path) => `- ${path}`).join("\n") : "- none",
|
|
116
|
+
"",
|
|
117
|
+
"Run `/arey-doctor` to verify setup.",
|
|
118
|
+
].join("\n");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function handleDoctor(pi: ExtensionAPI, ctx: ExtensionCommandContext): void {
|
|
122
|
+
const cwd = cwdFrom(ctx);
|
|
123
|
+
const projectAgentDir = join(cwd, ".pi", "agents", "arey-pi");
|
|
124
|
+
const commands = pi.getCommands();
|
|
125
|
+
const installedAgents = requiredAgents.filter((agent) => fileExists(join(projectAgentDir, agent)));
|
|
126
|
+
const missingAgents = requiredAgents.filter((agent) => !fileExists(join(projectAgentDir, agent)));
|
|
127
|
+
const packageAgents = requiredAgents.filter((agent) => fileExists(join(agentSourceDir, agent)));
|
|
128
|
+
const prompts = commands.filter(
|
|
129
|
+
(command) => command.source === "prompt" && command.sourceInfo?.source?.includes("arey-pi"),
|
|
130
|
+
);
|
|
131
|
+
const skills = commands.filter(
|
|
132
|
+
(command) => command.source === "skill" && command.sourceInfo?.source?.includes("arey-pi"),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
pi.sendMessage({
|
|
136
|
+
customType: "arey-pi-doctor",
|
|
137
|
+
content: buildDoctorReport({
|
|
138
|
+
packageVersion: packageVersion(),
|
|
139
|
+
cwd,
|
|
140
|
+
packageRulesPresent: dirExists(rulesDir),
|
|
141
|
+
packageTemplatesPresent: dirExists(templatesDir),
|
|
142
|
+
packageAgentsCount: packageAgents.length,
|
|
143
|
+
requiredAgentsCount: requiredAgents.length,
|
|
144
|
+
hasSubagentsCommand: commands.some((command) => command.name.startsWith("subagents-doctor")),
|
|
145
|
+
installedAgentsCount: installedAgents.length,
|
|
146
|
+
hasRootAgentsMd: fileExists(join(cwd, "AGENTS.md")),
|
|
147
|
+
hasPiSettings: fileExists(join(cwd, ".pi", "settings.json")),
|
|
148
|
+
promptsCount: prompts.length,
|
|
149
|
+
skillsCount: skills.length,
|
|
150
|
+
missingAgents,
|
|
151
|
+
}),
|
|
152
|
+
display: true,
|
|
153
|
+
details: {},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function handleBootstrap(pi: ExtensionAPI, args: string, ctx: ExtensionCommandContext): void {
|
|
158
|
+
const cwd = cwdFrom(ctx);
|
|
159
|
+
const { force, createAgentsMd, createSpecs, createDocs } = parseBootstrapFlags(args);
|
|
160
|
+
const targetDir = join(cwd, ".pi", "agents", "arey-pi");
|
|
161
|
+
const agents = copyAgents(targetDir, force);
|
|
162
|
+
const specs = createSpecs ? scaffoldFiles(cwd, force, specScaffoldFiles) : { created: [], skipped: [] };
|
|
163
|
+
const docs = createDocs ? scaffoldFiles(cwd, force, docsScaffoldFiles) : { created: [], skipped: [] };
|
|
164
|
+
const agentsMdPath = join(cwd, "AGENTS.md");
|
|
165
|
+
let agentsMd = "unchanged";
|
|
166
|
+
|
|
167
|
+
if (!fileExists(agentsMdPath) && (createAgentsMd || force)) {
|
|
168
|
+
writeFileSync(agentsMdPath, templateContent("AGENTS.md"));
|
|
169
|
+
agentsMd = "created";
|
|
170
|
+
} else if (fileExists(agentsMdPath) && createAgentsMd && !force) {
|
|
171
|
+
agentsMd = "skipped existing";
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
pi.sendMessage({
|
|
175
|
+
customType: "arey-pi-bootstrap",
|
|
176
|
+
content: buildBootstrapReport({ cwd, targetDir, agents, specs, docs, agentsMd }),
|
|
177
|
+
display: true,
|
|
178
|
+
details: { agents, specs, docs, agentsMd },
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function registerBootstrapCommands(pi: ExtensionAPI): void {
|
|
183
|
+
pi.registerCommand("arey-doctor", {
|
|
184
|
+
description: "Check Arey Pi package, project bootstrap, and subagent readiness",
|
|
185
|
+
handler: (_args, ctx) => {
|
|
186
|
+
handleDoctor(pi, ctx);
|
|
187
|
+
return Promise.resolve();
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
pi.registerCommand("arey-bootstrap", {
|
|
192
|
+
description: "Install Arey Pi subagents and optionally scaffold specs/docs",
|
|
193
|
+
handler: (args, ctx) => {
|
|
194
|
+
handleBootstrap(pi, args, ctx);
|
|
195
|
+
return Promise.resolve();
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
}
|