pi-aia-asf 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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ - Initial release of the Ai Applied Agentic Software Factory.
13
+ - ASF skill with 8 gated phases: classify, intake, research, specs, adversarial analysis, plan (approval gate), test-first implementation, verification & delivery.
14
+ - Per-phase reference guides (intake question bank, research playbook, adversarial checklist, PLAN.md template, implementation discipline, release workflow).
15
+ - `/asf` commands: new, feature, bugfix, refactor, status, approve, abort.
16
+ - Per-project phase state tracking in `~/.pi/agent/skills/aia-asf/projects/<project>/state.json`.
17
+ - Dependency checks at startup and on `/asf` (pi-vigilant, pi-smart-web-search, pi-smart-fetch, pi-aia-browser).
18
+ - Specs shared with pi-vigilant via `capture_spec` / `get_task_specs` / `update_spec_status`.
19
+ - Strict codebase isolation rule (project never touches other repos unless the user says so).
20
+ - Mandatory pi-aia-browser testing for any web interface.
21
+ - Release workflow: prepare version + CHANGELOG + tag + push; publishing always requires explicit user approval.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bruno Jakic, Ai Applied
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # pi-aia-asf — Ai Applied Agentic Software Factory
2
+
3
+ Codifies the full, disciplined software development flow used on real projects (conversense, betamaxx, mbee.me, pi-vigilant): **classify → intake → research → specs → adversarial analysis → plan with approval gate → test-first implementation → verification & delivery**.
4
+
5
+ It turns "let's build something" into a gated pipeline where nothing is implemented on assumptions, every hard requirement is captured as a verifiable spec, and nothing ships without evidence.
6
+
7
+ ## What it does
8
+
9
+ | Phase | Gate | What happens |
10
+ |---|---|---|
11
+ | 0. Classify | must be ASF work | New project / feature / major bugfix / refactor — or *not* ASF (skill stays quiet) |
12
+ | 1. Intake | user confirms intent | Ask until goal, success criteria, constraints are all clear |
13
+ | 2. Research | approach agreed | SOTA + existing packages via `web_search`/`web_fetch`, cited |
14
+ | 3. Specs | user signs off | Every hard requirement → `capture_spec` (shared with pi-vigilant) |
15
+ | 4. Adversarial | findings confirmed | Edge cases, failure modes, security, maintainability challenged |
16
+ | 5. Plan | **explicit approval** | `PLAN.md` in repo root — no implementation before approval |
17
+ | 6. Implement | tests green | Test-first, strict codebase isolation, browser-tested UIs |
18
+ | 7. Verify & deliver | specs met | Every spec verified with evidence; release offered, never auto-published |
19
+
20
+ ## Activation
21
+
22
+ The skill activates when the user's request is a **new software project, significant feature, major bugfix, or architectural refactor**. It does **not** activate for Q&A, one-liners, casual conversation, or non-software tasks. When in doubt, it asks.
23
+
24
+ You can also force/start a session explicitly:
25
+
26
+ ```
27
+ /asf new — start a new software project
28
+ /asf feature — add a feature
29
+ /asf bugfix — major bugfix
30
+ /asf refactor — architectural refactor
31
+ /asf status — show current phase + state
32
+ /asf approve — mark PLAN.md as approved (Gate 5)
33
+ /asf abort — end the session
34
+ ```
35
+
36
+ ## Dependencies (required)
37
+
38
+ | Package | Provides | Install |
39
+ |---|---|---|
40
+ | **pi-vigilant** | `capture_spec`, `get_task_specs`, `update_spec_status`, final verification | `pi install npm:pi-vigilant` |
41
+ | **pi-smart-web-search** | `web_search` | `pi install npm:pi-smart-web-search` |
42
+ | **pi-smart-fetch** | `web_fetch`, `batch_web_fetch` | `pi install npm:pi-smart-fetch` |
43
+ | **pi-aia-browser** | `browser_init`, `browser_navigate`, … (Playwright + Chromium, auto-installed) | `pi install npm:pi-aia-browser` |
44
+
45
+ The extension warns at startup (and on `/asf` with no args) when any dependency is missing.
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pi install npm:pi-aia-asf
51
+ ```
52
+
53
+ Then `/reload`.
54
+
55
+ ## How it works
56
+
57
+ - **Skill** (`skills/aia-asf/SKILL.md`) — the workflow itself, with per-phase reference guides in `references/`.
58
+ - **Extension** (`index.ts`) — `/asf` commands, per-project phase state (`~/.pi/agent/skills/aia-asf/projects/<project>/state.json`), dependency checks.
59
+ - **Specs shared with pi-vigilant** — ASF drives `capture_spec` during intake; pi-vigilant re-verifies every spec at task end and blocks "done" while MUST specs are open. One spec file, two systems.
60
+
61
+ ## Hygiene rules enforced
62
+
63
+ - Test-first; only green commits
64
+ - **Strict codebase isolation** — the project never touches other repos unless the user explicitly says so
65
+ - **Mandatory browser testing** of any web interface (real user experience, not just curl)
66
+ - Descriptive commits + CHANGELOG entries (no placeholders)
67
+ - **Publishing is always the user's decision** — ASF prepares the release (version + CHANGELOG + tag), optionally offers CI/CD setup, but never auto-publishes
68
+
69
+ ## Development
70
+
71
+ ```bash
72
+ npm run check # typecheck
73
+ npm test # see repo for test suites
74
+ npm run release patch|minor|major # test → version → CHANGELOG → tag → push
75
+ ```
76
+
77
+ ## License
78
+
79
+ MIT © Bruno Jakic, Ai Applied
package/index.ts ADDED
@@ -0,0 +1,232 @@
1
+ /**
2
+ * pi-aia-asf — Ai Applied Agentic Software Factory.
3
+ *
4
+ * Small extension complementing the aia-asf skill:
5
+ * - `/asf` commands (new, feature, bugfix, refactor, status, abort)
6
+ * - per-project phase state (JSON in ~/.pi/agent/skills/aia-asf/projects/<project>/state.json)
7
+ * - startup + first-run dependency check (pi-vigilant, web search/fetch, browser)
8
+ *
9
+ * The actual workflow lives in skills/aia-asf/SKILL.md — this extension only
10
+ * provides state and commands. Safe to load even when dependencies are missing:
11
+ * it warns instead of crashing.
12
+ */
13
+
14
+ import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
15
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
16
+ import { existsSync } from "node:fs";
17
+ import { join } from "node:path";
18
+ import { homedir } from "node:os";
19
+
20
+ // ─── Types ─────────────────────────────────────────────────────────────────
21
+
22
+ type AsfPhase =
23
+ | "none"
24
+ | "classify"
25
+ | "intake"
26
+ | "research"
27
+ | "specs"
28
+ | "adversarial"
29
+ | "plan"
30
+ | "implementation"
31
+ | "verification";
32
+
33
+ interface AsfState {
34
+ workType?: "new-project" | "feature" | "major-bugfix" | "refactor";
35
+ phase: AsfPhase;
36
+ planApproved?: boolean;
37
+ startedAt?: string;
38
+ updatedAt: string;
39
+ }
40
+
41
+ interface ProjectStateFile {
42
+ current: AsfState | null;
43
+ history: Array<{ workType: string; phase: AsfPhase; startedAt: string; endedAt: string }>;
44
+ }
45
+
46
+ // ─── Constants & helpers ───────────────────────────────────────────────────
47
+
48
+ const SKILLS_DIR = join(homedir(), ".pi", "agent", "skills");
49
+ const STATE_DIR = join(SKILLS_DIR, "aia-asf", "projects");
50
+
51
+ function projectName(): string {
52
+ try {
53
+ return process.cwd().split(/[\\/]/).pop() || "default";
54
+ } catch {
55
+ return "default";
56
+ }
57
+ }
58
+
59
+ function stateFileFor(project: string): string {
60
+ return join(STATE_DIR, project, "state.json");
61
+ }
62
+
63
+ async function loadState(project: string): Promise<ProjectStateFile> {
64
+ const file = stateFileFor(project);
65
+ if (!existsSync(file)) {
66
+ return { current: null, history: [] };
67
+ }
68
+ try {
69
+ return JSON.parse(await readFile(file, "utf-8")) as ProjectStateFile;
70
+ } catch {
71
+ return { current: null, history: [] };
72
+ }
73
+ }
74
+
75
+ async function saveState(project: string, data: ProjectStateFile): Promise<void> {
76
+ const file = stateFileFor(project);
77
+ await mkdir(join(STATE_DIR, project), { recursive: true });
78
+ await writeFile(file, JSON.stringify(data, null, 2), "utf-8");
79
+ }
80
+
81
+ // ─── Dependency check ──────────────────────────────────────────────────────
82
+
83
+ interface DependencyCheck {
84
+ name: string;
85
+ package: string;
86
+ present: boolean;
87
+ hint: string;
88
+ }
89
+
90
+ function checkDependencies(): DependencyCheck[] {
91
+ // Detect the tools by looking for the packages that register them.
92
+ // Tools are registered by extensions at runtime, so we check the
93
+ // installed packages in ~/.pi/agent/npm and the extensions dir.
94
+ const npmDir = join(homedir(), ".pi", "agent", "npm", "node_modules");
95
+ const extDir = join(homedir(), ".pi", "agent", "extensions");
96
+ const gitDir = join(homedir(), ".pi", "agent", "git");
97
+
98
+ const checks: DependencyCheck[] = [
99
+ {
100
+ name: "pi-vigilant (spec-memory: capture_spec / get_task_specs / update_spec_status)",
101
+ package: "pi-vigilant",
102
+ present: existsSync(join(npmDir, "pi-vigilant")) || existsSync(join(extDir, "pi-vigilant")) || existsSync(join(gitDir, "github.com", "brunoj", "pi-vigilant")),
103
+ hint: "pi install npm:pi-vigilant",
104
+ },
105
+ {
106
+ name: "pi-smart-web-search (web_search)",
107
+ package: "pi-smart-web-search",
108
+ present: existsSync(join(npmDir, "pi-smart-web-search")),
109
+ hint: "pi install npm:pi-smart-web-search",
110
+ },
111
+ {
112
+ name: "pi-smart-fetch (web_fetch / batch_web_fetch)",
113
+ package: "pi-smart-fetch",
114
+ present: existsSync(join(npmDir, "pi-smart-fetch")),
115
+ hint: "pi install npm:pi-smart-fetch",
116
+ },
117
+ {
118
+ name: "pi-aia-browser (browser_init / browser_navigate / …)",
119
+ package: "pi-aia-browser",
120
+ present:
121
+ existsSync(join(npmDir, "pi-aia-browser")) ||
122
+ existsSync(join(extDir, "pi-aia-browser")) ||
123
+ existsSync(join(extDir, "pi-browser")) ||
124
+ existsSync(join(gitDir, "github.com", "brunoj", "pi-aia-browser")),
125
+ hint: "pi install npm:pi-aia-browser (installs Playwright + Chromium)",
126
+ },
127
+ ];
128
+
129
+ return checks;
130
+ }
131
+
132
+ function dependencySummary(): string {
133
+ const checks = checkDependencies();
134
+ const missing = checks.filter((c) => !c.present);
135
+ if (missing.length === 0) {
136
+ return "All ASF dependencies present: pi-vigilant, pi-smart-web-search, pi-smart-fetch, pi-aia-browser ✓";
137
+ }
138
+ return (
139
+ "⚠️ ASF dependencies missing — install before starting a project:\n" +
140
+ missing.map((m) => ` - ${m.name}\n → ${m.hint}`).join("\n")
141
+ );
142
+ }
143
+
144
+ // ─── Extension registration ────────────────────────────────────────────────
145
+
146
+ export default function register(pi: ExtensionAPI): void {
147
+ // Startup check: warn once per session if deps are missing (unless disabled)
148
+ // The extension loads at startup; log to console so it surfaces in logs.
149
+
150
+ const setPhase = async (ctx: ExtensionCommandContext, phase: AsfPhase, workType?: AsfState["workType"]): Promise<string> => {
151
+ const project = projectName();
152
+ const state = await loadState(project);
153
+ const now = new Date().toISOString();
154
+
155
+ if (state.current && phase === "none") {
156
+ state.history.push({
157
+ workType: state.current.workType || "unknown",
158
+ phase: state.current.phase,
159
+ startedAt: state.current.startedAt || now,
160
+ endedAt: now,
161
+ });
162
+ state.current = null;
163
+ } else {
164
+ if (!state.current) {
165
+ state.current = {
166
+ workType,
167
+ phase: "classify",
168
+ startedAt: now,
169
+ updatedAt: now,
170
+ };
171
+ }
172
+ if (workType) state.current.workType = workType;
173
+ state.current.phase = phase;
174
+ state.current.updatedAt = now;
175
+ }
176
+
177
+ await saveState(project, state);
178
+ return state.current ? `ASF phase → ${phase}${workType ? ` (${workType})` : ""}` : "ASF session ended.";
179
+ };
180
+
181
+ pi.registerCommand("asf", async (args: string[], ctx: ExtensionCommandContext) => {
182
+ const sub = (args[0] || "").toLowerCase();
183
+
184
+ switch (sub) {
185
+ case "new":
186
+ return await setPhase(ctx, "intake", "new-project");
187
+ case "feature":
188
+ return await setPhase(ctx, "intake", "feature");
189
+ case "bugfix":
190
+ return await setPhase(ctx, "intake", "major-bugfix");
191
+ case "refactor":
192
+ return await setPhase(ctx, "intake", "refactor");
193
+ case "status": {
194
+ const project = projectName();
195
+ const state = await loadState(project);
196
+ if (!state.current) return "No active ASF session.";
197
+ return (
198
+ `ASF status (${project}):\n` +
199
+ ` work type: ${state.current.workType || "unset"}\n` +
200
+ ` phase: ${state.current.phase}\n` +
201
+ ` plan approved: ${state.current.planApproved ? "yes" : "no"}\n` +
202
+ ` started: ${state.current.startedAt || "?"}\n` +
203
+ ` history: ${state.history.length} completed session(s)`
204
+ );
205
+ }
206
+ case "abort":
207
+ return await setPhase(ctx, "none");
208
+ default:
209
+ return (
210
+ "ASF commands:\n" +
211
+ " /asf new — start a new software project\n" +
212
+ " /asf feature — add a feature to an existing project\n" +
213
+ " /asf bugfix — major bugfix\n" +
214
+ " /asf refactor — architectural refactor\n" +
215
+ " /asf status — show current phase\n" +
216
+ " /asf abort — end the current session\n\n" +
217
+ dependencySummary()
218
+ );
219
+ }
220
+ });
221
+
222
+ // Plan-approval helper: /asf approve marks the plan as approved (records Gate 5)
223
+ pi.registerCommand("asf-approve", async (_args: string[], ctx: ExtensionCommandContext) => {
224
+ const project = projectName();
225
+ const state = await loadState(project);
226
+ if (!state.current) return "No active ASF session — start one with /asf new|feature|bugfix|refactor.";
227
+ state.current.planApproved = true;
228
+ state.current.updatedAt = new Date().toISOString();
229
+ await saveState(project, state);
230
+ return "Plan approved ✓ — Gate 5 passed, implementation may begin.";
231
+ });
232
+ }
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "pi-aia-asf",
3
+ "version": "0.1.0",
4
+ "description": "Ai Applied Agentic Software Factory — codifies the full software development flow: intake, research, spec capture, adversarial analysis, planning with approval gates, test-first implementation, and release. Requires pi-vigilant, pi-smart-web-search, pi-smart-fetch, and pi-aia-browser.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "software-factory",
8
+ "asf",
9
+ "specs",
10
+ "planning"
11
+ ],
12
+ "type": "module",
13
+ "license": "MIT",
14
+ "author": "Bruno Jakic <bruno@ai-applied.nl>",
15
+ "homepage": "https://github.com/brunoj/pi-aia-asf#readme",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/brunoj/pi-aia-asf.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/brunoj/pi-aia-asf/issues"
22
+ },
23
+ "files": [
24
+ "index.ts",
25
+ "README.md",
26
+ "LICENSE",
27
+ "CHANGELOG.md",
28
+ "skills/"
29
+ ],
30
+ "scripts": {
31
+ "clean": "echo 'nothing to clean'",
32
+ "build": "echo 'nothing to build — pi loads .ts via jiti at runtime'",
33
+ "check": "tsc --noEmit --target ES2022 --module NodeNext --moduleResolution NodeNext --skipLibCheck --allowImportingTsExtensions --noCheck index.ts",
34
+ "test": "echo 'see https://github.com/brunoj/pi-aia-asf for test suites'",
35
+ "release": "./scripts/release.sh"
36
+ },
37
+ "pi": {
38
+ "extensions": [
39
+ "./index.ts"
40
+ ],
41
+ "skills": [
42
+ "./skills/aia-asf"
43
+ ]
44
+ },
45
+ "peerDependencies": {
46
+ "@earendil-works/pi-ai": "*",
47
+ "@earendil-works/pi-agent-core": "*",
48
+ "@earendil-works/pi-coding-agent": "*",
49
+ "typebox": "*"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "@earendil-works/pi-ai": {
53
+ "optional": false
54
+ },
55
+ "@earendil-works/pi-agent-core": {
56
+ "optional": false
57
+ },
58
+ "@earendil-works/pi-coding-agent": {
59
+ "optional": false
60
+ },
61
+ "typebox": {
62
+ "optional": false
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "@earendil-works/pi-agent-core": "0.83.0",
67
+ "@earendil-works/pi-ai": "0.83.0",
68
+ "@earendil-works/pi-coding-agent": "0.83.0",
69
+ "typebox": "1.1.38",
70
+ "typescript": "5.9.3"
71
+ }
72
+ }
@@ -0,0 +1,175 @@
1
+ ---
2
+ name: aia-asf
3
+ description: Agentic Software Factory — run a complete, disciplined software development cycle. Use when the user wants to start a NEW software project, add a SIGNIFICANT FEATURE to an existing project, perform a MAJOR BUGFIX, or do an ARCHITECTURAL REFACTOR. The flow is: classify the work, ask questions until the intent is clear, research SOTA and existing packages, capture hard specifications (via capture_spec, shared with pi-vigilant), run adversarial analysis, produce a PLAN.md and get explicit user approval, then implement test-first with strict codebase isolation and mandatory browser testing of any web interfaces (pi-aia-browser). Do NOT activate for simple Q&A, one-line fixes, casual conversation, content writing, or non-software tasks. When in doubt about whether work qualifies as a project/feature/bugfix/refactor, ask the user.
4
+ ---
5
+
6
+ # AIA Agentic Software Factory (ASF)
7
+
8
+ You are running the **Ai Applied Agentic Software Factory**. This skill codifies the full development flow used for real projects (conversense, betamaxx, mbee.me, pi-vigilant, and others). Follow the phases strictly, in order. Every phase has an explicit gate — never skip a gate.
9
+
10
+ > **Dependencies** (verify at Phase 0, warn if missing, do not proceed without them):
11
+ > - `pi-vigilant` — provides `capture_spec`, `get_task_specs`, `update_spec_status` and final-verification. If the tools are not available, tell the user: `pi install npm:pi-vigilant` and `/reload`.
12
+ > - `pi-smart-web-search` / `pi-smart-fetch` — `web_search`, `web_fetch`, `batch_web_fetch` for research. If missing: `pi install npm:pi-smart-web-search npm:pi-smart-fetch`.
13
+ > - `pi-aia-browser` — browser automation (`browser_init`, `browser_navigate`, …) for testing web interfaces. If missing: `pi install npm:pi-aia-browser` (installs Playwright + Chromium automatically).
14
+
15
+ ---
16
+
17
+ ## Phase 0 — Classify the work (gate)
18
+
19
+ Determine the work type. If it is not ASF work, **do not run the factory** — just help normally.
20
+
21
+ | Work type | ASF? |
22
+ |---|---|
23
+ | New software project | ✅ yes — full flow |
24
+ | Significant feature in an existing project | ✅ yes — full flow (research: medium depth) |
25
+ | Major bugfix (multi-file, behavior change, needs tests) | ✅ yes — lighter flow (research optional) |
26
+ | Architectural refactor | ✅ yes — full flow (research: low depth) |
27
+ | Simple Q&A, one-liner fix, casual talk, docs-only | ❌ no |
28
+ | Non-software tasks (LinkedIn, research-only, writing) | ❌ no |
29
+
30
+ If the user's request is ambiguous, **ask** before starting. State the classification explicitly:
31
+ `ASF: <new-project|feature|major-bugfix|refactor> — starting Phase 1 (intake).`
32
+
33
+ ---
34
+
35
+ ## Phase 1 — Intake: ask until it's clear (gate)
36
+
37
+ The factory **keeps asking until all is clear**. Never start planning or implementation on guesses.
38
+
39
+ Minimum intake checklist (ask anything not yet known, one question at a time or a short batch):
40
+
41
+ - **Goal** — what exactly is being built/changed? (one sentence)
42
+ - **Context** — existing system? which repo? what's there today?
43
+ - **Users / audience** — who uses this, and how?
44
+ - **Success criteria** — how will we know it's done and correct? (be concrete)
45
+ - **Constraints** — musts, must-nots, boundaries, budget, timeline
46
+ - **Preferences** — stack, language, platform, style (only if the user has them)
47
+ - **Definition of done** — tests? deploy? release? docs?
48
+
49
+ For each answer, **capture hard requirements immediately with `capture_spec`** (requirement, area, priority). Specs are the shared contract with pi-vigilant — it will re-verify them at the end.
50
+
51
+ **Gate 1**: You may only leave intake when the user has confirmed the summary of intent (restate it back in 3–5 bullet points and ask "is this correct?").
52
+
53
+ ---
54
+
55
+ ## Phase 2 — Research: SOTA and packages (adaptive depth)
56
+
57
+ | Work type | Research depth |
58
+ |---|---|
59
+ | New project | **Mandatory, full** — SOTA approaches, frameworks, existing packages, reference implementations |
60
+ | Significant feature | **Mandatory, medium** — existing packages/libraries, similar features in the wild |
61
+ | Major bugfix | **Optional** — only if the fix changes scope or needs new tech |
62
+ | Refactor | **Low** — best practices for the target architecture |
63
+
64
+ Research method (use `web_search` + `web_fetch`/`batch_web_fetch`):
65
+ 1. Search for the topic + "best practices" / "comparison" / "2026"
66
+ 2. Search for existing npm/pip packages: `npm search <topic>` or web search
67
+ 3. Fetch the 2–3 most relevant results and extract concrete facts
68
+ 4. **Cite sources** in the research summary — every claim about a package/library gets a URL
69
+ 5. Summarize findings + a **recommendation** (which approach, which packages, with rationale)
70
+
71
+ **Gate 2**: present the research summary + recommendation to the user. Ask: "proceed with this approach, or adjust?" Do not enter planning until the approach is agreed.
72
+
73
+ ---
74
+
75
+ ## Phase 3 — Specifications (gate)
76
+
77
+ Turn the intake answers + research into the authoritative spec set.
78
+
79
+ 1. Run `get_task_specs` to see what's already captured.
80
+ 2. Fill gaps: for every requirement the user stated or approved, ensure a spec exists (`capture_spec`).
81
+ 3. Decompose broad specs with `parentId` (e.g. "must be secure" → auth + encryption sub-specs).
82
+ 4. Default priority is `must`; use `should` only when the user says "nice to have".
83
+ 5. Areas: functionality, ui-ux, performance, security, error-handling, testing, documentation, compatibility, constraints, format, data, deployment, other.
84
+
85
+ **Gate 3**: show the full spec tree (`get_task_specs`) and get user sign-off: "specs correct — proceed to adversarial analysis?"
86
+
87
+ ---
88
+
89
+ ## Phase 4 — Adversarial analysis (gate)
90
+
91
+ Challenge the plan like a hostile reviewer before committing to it. For each spec and the overall design, ask and resolve:
92
+
93
+ - **Edge cases** — empty input, zero users, max load, missing data, concurrency
94
+ - **Failure modes** — what breaks, and how do we detect/recover?
95
+ - **Security** — auth, injection, data exposure, abuse
96
+ - **Maintainability** — will this be understandable in 6 months? who maintains it?
97
+ - **Dependencies** — are they maintained? license? size? alternatives?
98
+ - **Scope** — is anything here actually unnecessary? (cut it)
99
+ - **Feasibility** — is the SOTA research consistent with the specs?
100
+
101
+ For each finding: either capture a new spec, refine an existing one (supersede), or record the decision to accept the risk. **Ask the user about anything that changes scope.**
102
+
103
+ **Gate 4**: summarize adversarial findings + resolutions, get user confirmation.
104
+
105
+ ---
106
+
107
+ ## Phase 5 — Plan + approval gate
108
+
109
+ Write `PLAN.md` in the project root (repo root, or cwd if no repo). Structure:
110
+
111
+ ```markdown
112
+ # <Project> — Plan
113
+
114
+ ## Goal
115
+ ## Context
116
+ ## Approach (from research, cited)
117
+ ## Architecture / Design
118
+ ## Milestones (M1..Mn with exit criteria)
119
+ ## Task list (per milestone, checkboxes)
120
+ ## Dependencies (with licenses)
121
+ ## Risks & mitigations (from adversarial analysis)
122
+ ## Definition of done (tests, deploy, release)
123
+ ```
124
+
125
+ Keep the plan **implementation-ready**: any competent engineer (or agent) can execute the task list without re-deriving decisions.
126
+
127
+ **Gate 5 — MANDATORY user approval**: present the plan and ask explicitly:
128
+ > "Plan ready. Do you approve starting implementation? (yes / changes needed)"
129
+
130
+ **Never start implementing before Gate 5 passes.** If the user says "go" without reading, still show the plan and confirm.
131
+
132
+ ---
133
+
134
+ ## Phase 6 — Implementation (test-first, disciplined)
135
+
136
+ Execute the task list milestone by milestone. Discipline rules:
137
+
138
+ 1. **Test-first**: write/update tests before or with implementation; run them; only commit green.
139
+ 2. **Codebase isolation**: work strictly inside the project's own codebase. Do NOT edit files in other repos, global config, or unrelated directories — **unless the user explicitly instructs otherwise**. If a change would touch another codebase, stop and ask.
140
+ 3. **No scope creep**: if something new is discovered that changes specs, capture it, ask the user, and update the plan before implementing.
141
+ 4. **Descriptive commits**: `git commit -m "type: specific description of what and why"` (e.g. `fix: verify specs before rotation`). No vague messages, no placeholders.
142
+ 5. **Browser testing — MANDATORY for any web interface**: if the deliverable has a UI/website/web app, test it through `pi-aia-browser` (`browser_init`, `browser_navigate`, `browser_click`, `browser_type`, `browser_screenshot`, `browser_dom`, …) to replicate the user's real experience — not just curl/API checks. Verify: loads, key user journeys, responsive behavior, console errors.
143
+ 6. **Let pi-vigilant do its job**: it will auto-continue after premature stops and verify specs at settle. When it asks for `update_spec_status` with evidence, do it.
144
+ 7. **CHANGELOG discipline**: every user-visible change gets a CHANGELOG entry describing exactly what changed (no placeholder text).
145
+
146
+ ---
147
+
148
+ ## Phase 7 — Verification & delivery (gate)
149
+
150
+ 1. Run the full test suite; fix failures; re-run until green.
151
+ 2. Run `get_task_specs` and verify **every spec** with `update_spec_status` + concrete evidence (test output, build result, code inspection). Unverifiable → `partial` + ask the user. Never self-certify.
152
+ 3. If the project is a library/package that the user publishes (npm, GitHub release): **offer** to run the release (see `references/07-release.md`): version bump, CHANGELOG, git tag, push. **Publishing is always the user's decision** — never publish without explicit approval. Optionally offer to set up a CI/CD pipeline for publishing.
153
+ 4. Present a completion summary: what was built, specs met, tests passing, how to use it.
154
+
155
+ ---
156
+
157
+ ## Anti-patterns
158
+
159
+ - ❌ Starting implementation without Gate 5 approval
160
+ - ❌ Planning on assumptions — always ask
161
+ - ❌ Skipping research for new projects
162
+ - ❌ Editing other codebases without explicit permission
163
+ - ❌ Verifying a UI only via API/curl — browser testing is mandatory
164
+ - ❌ Vague commits or CHANGELOG placeholders
165
+ - ❌ Declaring done while specs are still `open`
166
+ - ❌ Publishing anything without the user's explicit go-ahead
167
+
168
+ ## References
169
+
170
+ - `references/01-intake.md` — question bank and probing techniques
171
+ - `references/02-research.md` — research playbook with search templates
172
+ - `references/04-adversarial.md` — adversarial checklist per area
173
+ - `references/05-plan.md` — PLAN.md template with examples
174
+ - `references/06-implementation.md` — coding discipline details
175
+ - `references/07-release.md` — release workflow (versioning, CHANGELOG, tags, npm, CI/CD)
@@ -0,0 +1,34 @@
1
+ # Phase 1 — Intake: Question Bank
2
+
3
+ Keep asking until the user confirms. One question at a time is fine; short batches (3–5) are faster. Do not proceed on guesses.
4
+
5
+ ## Starter questions
6
+
7
+ - "What are we building, in one sentence?"
8
+ - "What problem does it solve, and for whom?"
9
+ - "What exists today?" (blank slate / existing repo / replaces something)
10
+ - "How will we know it's done and correct?" (concrete success criteria)
11
+ - "Any hard constraints?" (stack, platform, budget, timeline, must-nots)
12
+
13
+ ## Probing techniques
14
+
15
+ - **Five whys**: when the goal is vague, keep asking "why" until the real outcome surfaces.
16
+ - **Concretize**: "what does 'fast' mean — under 200ms?" → convert adjectives to numbers → capture as spec.
17
+ - **Boundary questions**: "what happens when there's no input / 10k users / the API is down?"
18
+ - **Scope confirmation**: "is X in scope for this round, or later?" — write the answer down.
19
+
20
+ ## What to capture as specs (during intake)
21
+
22
+ Every concrete requirement the user states → `capture_spec` immediately, before responding further. Examples:
23
+
24
+ | User says | Capture |
25
+ |---|---|
26
+ | "must be in TypeScript" | constraints, must |
27
+ | "handle empty input gracefully" | error-handling, must |
28
+ | "needs to support Firefox and Chrome" | compatibility, must |
29
+ | "should notify admins on failure" | functionality, should (if user says "should") |
30
+ | "output JSON with id and name" | format, must |
31
+
32
+ ## Intake gate
33
+
34
+ Restate intent in 3–5 bullets, then ask: **"Is this correct?"** Only proceed on an explicit yes.
@@ -0,0 +1,44 @@
1
+ # Phase 2 — Research Playbook
2
+
3
+ Goal: decisions based on current facts, with sources. Never plan architecture on memory alone.
4
+
5
+ ## When research is mandatory
6
+
7
+ - New project: full research
8
+ - Significant feature: medium research (packages/libraries, similar implementations)
9
+ - Major bugfix: only if scope/tech changes
10
+ - Refactor: best practices for target architecture
11
+
12
+ ## Search templates (web_search)
13
+
14
+ - `<topic> best practices 2026`
15
+ - `<topic> vs <alternative> comparison`
16
+ - `<topic> npm package` / `npm search <topic>` (via bash)
17
+ - `how to implement <feature> <language>`
18
+ - `<framework> <version> release notes`
19
+ - `reference implementation <topic> open source`
20
+
21
+ ## Extraction (web_fetch / batch_web_fetch)
22
+
23
+ - Fetch the 2–3 most relevant results (batch_web_fetch for parallel).
24
+ - Extract: what it is, version, license, maintenance status, adoption, key trade-offs.
25
+ - For npm packages: check `npm view <pkg>` (version, license, weekly downloads, dependencies) — fast and authoritative.
26
+
27
+ ## Decision criteria for packages
28
+
29
+ 1. License compatible (MIT/Apache preferred)
30
+ 2. Maintained (recent release, active issues)
31
+ 3. Mature enough (v1+ or widely adopted)
32
+ 4. Dependency footprint reasonable
33
+ 5. Fits the project's constraints (browser? node? size?)
34
+
35
+ ## Output
36
+
37
+ Research summary with:
38
+ - **Findings** (each with source URL)
39
+ - **Recommendation** (approach + packages, with rationale)
40
+ - **Alternatives considered** (one line each, why rejected)
41
+
42
+ ## Research gate
43
+
44
+ Present summary + recommendation → ask: "proceed with this approach, or adjust?" → only proceed on agreement.
@@ -0,0 +1,31 @@
1
+ # Phase 4 — Adversarial Analysis Checklist
2
+
3
+ Challenge every spec and design decision like a hostile reviewer. For each item, determine: capture a new spec / supersede an existing one / accept the risk (recorded).
4
+
5
+ ## Per-spec questions
6
+
7
+ - **Edge cases**: empty input, zero data, max load, missing fields, concurrent access, duplicate input, unicode, huge payloads
8
+ - **Failure modes**: what breaks first? Is failure loud or silent? Can we recover automatically?
9
+ - **Security**: authentication, authorization, injection (SQL/XSS), data exposure, secrets, abuse/rate-limiting, supply chain
10
+ - **Maintainability**: will a new engineer understand this in 6 months? Is the design over-engineered or under-documented?
11
+ - **Dependencies**: license, maintenance, size, security history, lockfile hygiene
12
+ - **Scope**: does anything here NOT need to exist? Cut it (record the cut).
13
+ - **Feasibility**: does the research support the spec? Is the plan's chosen stack proven for this use case?
14
+
15
+ ## Architecture questions
16
+
17
+ - **Data flow**: what's the full path of a request/event? Where can it fail?
18
+ - **State**: what state exists, where does it live, what happens on restart?
19
+ - **Scaling**: what happens at 10× the expected load?
20
+ - **Rollback**: if this ships and breaks, how do we revert?
21
+ - **Observability**: logs, metrics, errors — can we see it working in production?
22
+
23
+ ## Resolution rules
24
+
25
+ - Finding → **new spec** (capture_spec) or **spec change** (capture superseding spec; old one becomes obsolete)
26
+ - Accepted risk → write it into the PLAN.md risks section with rationale
27
+ - Scope change → **ask the user before proceeding**
28
+
29
+ ## Adversarial gate
30
+
31
+ Summarize: findings found, specs added/changed, risks accepted → user confirmation.
@@ -0,0 +1,63 @@
1
+ # Phase 5 — PLAN.md Template
2
+
3
+ Write `PLAN.md` in the project root. It must be executable by any competent engineer without re-deriving decisions.
4
+
5
+ ```markdown
6
+ # <Project> — Plan
7
+
8
+ Status: DRAFT / APPROVED
9
+ Date: YYYY-MM-DD
10
+
11
+ ## Goal
12
+ One sentence. What are we building and why?
13
+
14
+ ## Context
15
+ Existing system, repo layout, relevant prior work. Links to research sources.
16
+
17
+ ## Approach
18
+ Decided approach with rationale. Cite the research (package names, URLs).
19
+
20
+ ## Architecture / Design
21
+ - Components and their responsibilities
22
+ - Data model / schema (if any)
23
+ - Key flows (request lifecycle, event flow)
24
+ - Interfaces / contracts between components
25
+
26
+ ## Milestones
27
+ | # | Milestone | Exit criteria |
28
+ |---|-----------|---------------|
29
+ | M1 | Scaffold + CI | Repo builds, tests run |
30
+ | M2 | Core feature | Feature works end-to-end (tests pass) |
31
+ | ... | ... | ... |
32
+
33
+ ## Task list
34
+ - [ ] M1: Initialize package (`npm init`, deps)
35
+ - [ ] M1: Set up test runner
36
+ - [ ] M2: Implement <feature> (tests first)
37
+ - [ ] ...
38
+
39
+ ## Dependencies
40
+ | Package | Version | License | Purpose |
41
+ |---------|---------|---------|---------|
42
+
43
+ ## Risks & mitigations
44
+ From adversarial analysis. Each risk: likelihood, impact, mitigation, owner.
45
+
46
+ ## Definition of done
47
+ - [ ] All MUST specs met (pi-vigilant)
48
+ - [ ] Test suite green
49
+ - [ ] Browser-tested if UI involved
50
+ - [ ] CHANGELOG updated
51
+ - [ ] User approved delivery/release
52
+
53
+ ## Out of scope
54
+ Explicitly cut items (so nobody re-adds them).
55
+ ```
56
+
57
+ ## Approval gate (MANDATORY)
58
+
59
+ Present the plan and ask:
60
+
61
+ > "Plan ready. Do you approve starting implementation? (yes / changes needed)"
62
+
63
+ Do not implement before explicit approval. If the user says "go", record the plan as APPROVED.
@@ -0,0 +1,56 @@
1
+ # Phase 6 — Implementation Discipline
2
+
3
+ ## Test-first
4
+
5
+ 1. Write the failing test for the next behavior
6
+ 2. Implement the minimum to pass
7
+ 3. Run the suite; refactor; re-run
8
+ 4. Only commit green
9
+
10
+ For web interfaces, browser tests via pi-aia-browser are part of the test suite, not an afterthought.
11
+
12
+ ## Codebase isolation (STRICT)
13
+
14
+ - Work **only inside the project's codebase** (the repo the task belongs to).
15
+ - Do NOT modify: other project repos, `~/.pi/agent/`, global config, unrelated directories.
16
+ - If a legitimate need to touch another codebase arises (shared lib, dependency fix): **stop and ask the user**.
17
+ - Exception: the user explicitly instructs otherwise — then note the instruction and proceed.
18
+
19
+ ## Browser testing (MANDATORY for web interfaces)
20
+
21
+ Any deliverable with a UI/web surface must be verified through the browser to replicate the user's real experience:
22
+
23
+ 1. `browser_init` — start the browser
24
+ 2. `browser_navigate` to the app URL (local dev server or deployed)
25
+ 3. Walk the key user journeys: `browser_click`, `browser_type`, `browser_navigate`
26
+ 4. Verify: page loads, journeys work, console has no errors (`browser_js`), screenshots for record (`browser_screenshot`)
27
+ 5. Check responsiveness (desktop + mobile viewport)
28
+ 6. `browser_close` when done
29
+
30
+ API-only verification is NOT sufficient for anything a human would see or click.
31
+
32
+ ## Commit messages
33
+
34
+ `type: specific description of what and why`
35
+
36
+ - `feat:` new capability
37
+ - `fix:` bug fix
38
+ - `refactor:` structural change, no behavior change
39
+ - `docs:` documentation
40
+ - `test:` tests
41
+ - `chore:` tooling, deps, release
42
+
43
+ Examples:
44
+ - ✅ `fix: reset verification cooldown on new user task`
45
+ - ✅ `feat: add rate limiting middleware with 429 responses`
46
+ - ❌ `update stuff`, `fixes`, `wip`
47
+
48
+ ## CHANGELOG
49
+
50
+ Every user-visible change gets an entry under `## [Unreleased]` or the released version, describing exactly what changed and why. No placeholder text.
51
+
52
+ ## Specs during implementation
53
+
54
+ - New hard requirement discovered → `capture_spec` immediately
55
+ - Requirement changed → capture superseding spec (old → obsolete)
56
+ - When pi-vigilant injects its verification checklist → respond with `update_spec_status` + evidence
@@ -0,0 +1,42 @@
1
+ # Phase 7 — Release Workflow
2
+
3
+ Publishing is **always the user's decision**. The factory prepares everything; the user gives the final go.
4
+
5
+ ## When release applies
6
+
7
+ - npm packages (pi extensions, libraries)
8
+ - GitHub releases
9
+ - Deployed applications
10
+ - NOT for internal-only experiments the user keeps local
11
+
12
+ ## Steps
13
+
14
+ 1. **Verify first** (mandatory, before any versioning):
15
+ - typecheck / build passes
16
+ - test suite green
17
+ - all MUST specs `met` in pi-vigilant
18
+ 2. **Version bump** — semantic versioning:
19
+ - `patch` (0.1.0 → 0.1.1): bug fixes
20
+ - `minor` (0.1.0 → 0.2.0): new features, backward compatible
21
+ - `major` (1.0.0): breaking changes
22
+ 3. **CHANGELOG** — move `[Unreleased]` entries into the new version section; describe each change specifically.
23
+ 4. **Tag** — `git tag vX.Y.Z`
24
+ 5. **Push** — `git push --follow-tags`
25
+ 6. **Publish** — only with explicit user approval:
26
+ - npm: `npm publish` (ensure 2FA token, `npm login` state)
27
+ - GitHub release: via web or `gh release create` if installed
28
+
29
+ ## CI/CD offer
30
+
31
+ After a successful release (or for a new project), **offer** to set up a CI/CD pipeline for publishing:
32
+
33
+ - GitHub Actions: test on push → version + publish on tag/release
34
+ - Requires the user's secrets (npm token, etc.) — never invent credentials
35
+ - Keep it minimal: test job + publish job, gated on tags
36
+
37
+ ## Hygiene rules
38
+
39
+ - No auto-publish — always explicit user approval
40
+ - Describe changes specifically in CHANGELOG (no placeholders)
41
+ - The version in package.json, the git tag, and the npm release must match
42
+ - If publishing fails partway, fix forward; never publish a second version with the same number