@chankov/agent-skills 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/.claude/commands/{doctor.md → doctor-agent-skills.md} +1 -1
- package/.pi/extensions/agent-skills-update-check/README.md +4 -4
- package/.pi/prompts/{doctor.md → doctor-agent-skills.md} +1 -1
- package/.versions/0.2.0/.claude/commands/{doctor.md → doctor-agent-skills.md} +1 -1
- package/.versions/0.2.0/.pi/extensions/agent-skills-update-check/README.md +4 -4
- package/.versions/0.2.0/.pi/prompts/{doctor.md → doctor-agent-skills.md} +1 -1
- package/.versions/0.2.0/skills/guided-workspace-setup/SKILL.md +40 -2
- package/.versions/0.3.0/.claude/commands/build.md +18 -0
- package/.versions/0.3.0/.claude/commands/code-simplify.md +22 -0
- package/.versions/0.3.0/.claude/commands/design-agent.md +14 -0
- package/.versions/0.3.0/.claude/commands/doctor-agent-skills.md +13 -0
- package/.versions/0.3.0/.claude/commands/plan.md +16 -0
- package/.versions/0.3.0/.claude/commands/prime.md +22 -0
- package/.versions/0.3.0/.claude/commands/review.md +16 -0
- package/.versions/0.3.0/.claude/commands/setup-agent-skills.md +19 -0
- package/.versions/0.3.0/.claude/commands/ship.md +17 -0
- package/.versions/0.3.0/.claude/commands/spec.md +15 -0
- package/.versions/0.3.0/.claude/commands/test.md +19 -0
- package/.versions/0.3.0/.opencode/commands/as-build.md +17 -0
- package/.versions/0.3.0/.opencode/commands/as-code-simplify.md +16 -0
- package/.versions/0.3.0/.opencode/commands/as-design-agent.md +15 -0
- package/.versions/0.3.0/.opencode/commands/as-doctor-agent-skills.md +11 -0
- package/.versions/0.3.0/.opencode/commands/as-plan.md +16 -0
- package/.versions/0.3.0/.opencode/commands/as-prime.md +22 -0
- package/.versions/0.3.0/.opencode/commands/as-review.md +15 -0
- package/.versions/0.3.0/.opencode/commands/as-setup-agent-skills.md +11 -0
- package/.versions/0.3.0/.opencode/commands/as-ship.md +16 -0
- package/.versions/0.3.0/.opencode/commands/as-spec.md +16 -0
- package/.versions/0.3.0/.opencode/commands/as-test.md +21 -0
- package/.versions/0.3.0/.pi/agents/agent-chain.yaml +49 -0
- package/.versions/0.3.0/.pi/agents/bowser.md +19 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/agent-expert.md +98 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/cli-expert.md +41 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/config-expert.md +63 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/ext-expert.md +43 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/keybinding-expert.md +134 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/pi-orchestrator.md +57 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/prompt-expert.md +70 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/skill-expert.md +42 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/theme-expert.md +40 -0
- package/.versions/0.3.0/.pi/agents/pi-pi/tui-expert.md +85 -0
- package/.versions/0.3.0/.pi/agents/teams.yaml +31 -0
- package/.versions/0.3.0/.pi/damage-control-rules.yaml +278 -0
- package/.versions/0.3.0/.pi/extensions/agent-skills-update-check/README.md +58 -0
- package/.versions/0.3.0/.pi/extensions/agent-skills-update-check/index.ts +161 -0
- package/.versions/0.3.0/.pi/extensions/agent-skills-update-check/package.json +6 -0
- package/.versions/0.3.0/.pi/extensions/chrome-devtools-mcp/README.md +39 -0
- package/.versions/0.3.0/.pi/extensions/chrome-devtools-mcp/index.ts +61 -0
- package/.versions/0.3.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/0.3.0/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/0.3.0/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/0.3.0/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/0.3.0/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/0.3.0/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/0.3.0/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/0.3.0/.pi/extensions/package-lock.json +1143 -0
- package/.versions/0.3.0/.pi/extensions/package.json +9 -0
- package/.versions/0.3.0/.pi/harnesses/agent-chain/README.md +37 -0
- package/.versions/0.3.0/.pi/harnesses/agent-chain/index.ts +795 -0
- package/.versions/0.3.0/.pi/harnesses/agent-chain/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/agent-team/README.md +38 -0
- package/.versions/0.3.0/.pi/harnesses/agent-team/index.ts +732 -0
- package/.versions/0.3.0/.pi/harnesses/agent-team/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/coms/README.md +36 -0
- package/.versions/0.3.0/.pi/harnesses/coms/index.ts +1595 -0
- package/.versions/0.3.0/.pi/harnesses/coms/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/coms-net/README.md +46 -0
- package/.versions/0.3.0/.pi/harnesses/coms-net/index.ts +1637 -0
- package/.versions/0.3.0/.pi/harnesses/coms-net/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/damage-control/README.md +38 -0
- package/.versions/0.3.0/.pi/harnesses/damage-control/index.ts +207 -0
- package/.versions/0.3.0/.pi/harnesses/damage-control/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/damage-control-continue/README.md +37 -0
- package/.versions/0.3.0/.pi/harnesses/damage-control-continue/index.ts +234 -0
- package/.versions/0.3.0/.pi/harnesses/damage-control-continue/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/minimal/README.md +27 -0
- package/.versions/0.3.0/.pi/harnesses/minimal/index.ts +32 -0
- package/.versions/0.3.0/.pi/harnesses/minimal/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/package-lock.json +35 -0
- package/.versions/0.3.0/.pi/harnesses/package.json +9 -0
- package/.versions/0.3.0/.pi/harnesses/pi-pi/README.md +39 -0
- package/.versions/0.3.0/.pi/harnesses/pi-pi/index.ts +631 -0
- package/.versions/0.3.0/.pi/harnesses/pi-pi/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/purpose-gate/README.md +27 -0
- package/.versions/0.3.0/.pi/harnesses/purpose-gate/index.ts +82 -0
- package/.versions/0.3.0/.pi/harnesses/purpose-gate/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/session-replay/README.md +28 -0
- package/.versions/0.3.0/.pi/harnesses/session-replay/index.ts +214 -0
- package/.versions/0.3.0/.pi/harnesses/session-replay/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/subagent-widget/README.md +36 -0
- package/.versions/0.3.0/.pi/harnesses/subagent-widget/index.ts +479 -0
- package/.versions/0.3.0/.pi/harnesses/subagent-widget/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/system-select/README.md +39 -0
- package/.versions/0.3.0/.pi/harnesses/system-select/index.ts +165 -0
- package/.versions/0.3.0/.pi/harnesses/system-select/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/tilldone/README.md +35 -0
- package/.versions/0.3.0/.pi/harnesses/tilldone/index.ts +724 -0
- package/.versions/0.3.0/.pi/harnesses/tilldone/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/tool-counter/README.md +31 -0
- package/.versions/0.3.0/.pi/harnesses/tool-counter/index.ts +100 -0
- package/.versions/0.3.0/.pi/harnesses/tool-counter/package.json +6 -0
- package/.versions/0.3.0/.pi/harnesses/tool-counter-widget/README.md +27 -0
- package/.versions/0.3.0/.pi/harnesses/tool-counter-widget/index.ts +66 -0
- package/.versions/0.3.0/.pi/harnesses/tool-counter-widget/package.json +6 -0
- package/.versions/0.3.0/.pi/prompts/build.md +24 -0
- package/.versions/0.3.0/.pi/prompts/code-simplify.md +22 -0
- package/.versions/0.3.0/.pi/prompts/doctor-agent-skills.md +13 -0
- package/.versions/0.3.0/.pi/prompts/plan.md +16 -0
- package/.versions/0.3.0/.pi/prompts/review.md +16 -0
- package/.versions/0.3.0/.pi/prompts/setup-agent-skills.md +19 -0
- package/.versions/0.3.0/.pi/prompts/ship.md +17 -0
- package/.versions/0.3.0/.pi/prompts/spec.md +15 -0
- package/.versions/0.3.0/.pi/prompts/test.md +19 -0
- package/.versions/0.3.0/.pi/skills/bowser/SKILL.md +114 -0
- package/.versions/0.3.0/.version +1 -0
- package/.versions/0.3.0/agents/builder.md +6 -0
- package/.versions/0.3.0/agents/code-reviewer.md +93 -0
- package/.versions/0.3.0/agents/documenter.md +6 -0
- package/.versions/0.3.0/agents/plan-reviewer.md +22 -0
- package/.versions/0.3.0/agents/planner.md +6 -0
- package/.versions/0.3.0/agents/scout.md +6 -0
- package/.versions/0.3.0/agents/security-auditor.md +97 -0
- package/.versions/0.3.0/agents/test-engineer.md +89 -0
- package/.versions/0.3.0/hooks/SIMPLIFY-IGNORE.md +90 -0
- package/.versions/0.3.0/hooks/hooks.json +14 -0
- package/.versions/0.3.0/hooks/session-start.sh +74 -0
- package/.versions/0.3.0/hooks/simplify-ignore-test.sh +247 -0
- package/.versions/0.3.0/hooks/simplify-ignore.sh +302 -0
- package/.versions/0.3.0/references/accessibility-checklist.md +159 -0
- package/.versions/0.3.0/references/performance-checklist.md +121 -0
- package/.versions/0.3.0/references/prompting-patterns.md +380 -0
- package/.versions/0.3.0/references/security-checklist.md +134 -0
- package/.versions/0.3.0/references/testing-patterns.md +236 -0
- package/.versions/0.3.0/skills/api-and-interface-design/SKILL.md +294 -0
- package/.versions/0.3.0/skills/browser-testing-with-devtools/SKILL.md +335 -0
- package/.versions/0.3.0/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/0.3.0/skills/code-review-and-quality/SKILL.md +347 -0
- package/.versions/0.3.0/skills/code-simplification/SKILL.md +331 -0
- package/.versions/0.3.0/skills/context-engineering/SKILL.md +291 -0
- package/.versions/0.3.0/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/0.3.0/skills/deprecation-and-migration/SKILL.md +206 -0
- package/.versions/0.3.0/skills/designing-agents/SKILL.md +394 -0
- package/.versions/0.3.0/skills/designing-agents/pi-harness-authoring.md +213 -0
- package/.versions/0.3.0/skills/documentation-and-adrs/SKILL.md +278 -0
- package/.versions/0.3.0/skills/frontend-ui-engineering/SKILL.md +322 -0
- package/.versions/0.3.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/0.3.0/skills/guided-workspace-setup/SKILL.md +331 -0
- package/.versions/0.3.0/skills/idea-refine/SKILL.md +178 -0
- package/.versions/0.3.0/skills/idea-refine/examples.md +238 -0
- package/.versions/0.3.0/skills/idea-refine/frameworks.md +99 -0
- package/.versions/0.3.0/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/0.3.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/0.3.0/skills/incremental-implementation/SKILL.md +279 -0
- package/.versions/0.3.0/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/0.3.0/skills/planning-and-task-breakdown/SKILL.md +237 -0
- package/.versions/0.3.0/skills/security-and-hardening/SKILL.md +349 -0
- package/.versions/0.3.0/skills/shipping-and-launch/SKILL.md +309 -0
- package/.versions/0.3.0/skills/source-driven-development/SKILL.md +194 -0
- package/.versions/0.3.0/skills/spec-driven-development/SKILL.md +237 -0
- package/.versions/0.3.0/skills/test-driven-development/SKILL.md +379 -0
- package/.versions/0.3.0/skills/using-agent-skills/SKILL.md +176 -0
- package/CHANGELOG.md +72 -0
- package/README.md +5 -5
- package/bin/cli.js +100 -24
- package/bin/lib/bootstrap.js +254 -0
- package/bin/lib/doctor.js +1 -1
- package/docs/getting-started.md +2 -2
- package/docs/npm-install.md +34 -11
- package/package.json +1 -1
- package/skills/guided-workspace-setup/SKILL.md +40 -2
- /package/.claude/commands/{setup.md → setup-agent-skills.md} +0 -0
- /package/.opencode/commands/{as-doctor.md → as-doctor-agent-skills.md} +0 -0
- /package/.opencode/commands/{as-setup.md → as-setup-agent-skills.md} +0 -0
- /package/.pi/prompts/{setup.md → setup-agent-skills.md} +0 -0
- /package/.versions/0.2.0/.claude/commands/{setup.md → setup-agent-skills.md} +0 -0
- /package/.versions/0.2.0/.opencode/commands/{as-doctor.md → as-doctor-agent-skills.md} +0 -0
- /package/.versions/0.2.0/.opencode/commands/{as-setup.md → as-setup-agent-skills.md} +0 -0
- /package/.versions/0.2.0/.pi/prompts/{setup.md → setup-agent-skills.md} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Authoring a pi Harness
|
|
2
|
+
|
|
3
|
+
Reference for the harness branch of the `designing-agents` skill. Read this before writing
|
|
4
|
+
any file under `.pi/harnesses/`. It is the harness equivalent of `docs/skill-anatomy.md`.
|
|
5
|
+
|
|
6
|
+
## What a harness is
|
|
7
|
+
|
|
8
|
+
A pi harness is a TypeScript pi extension that reshapes a whole session. The 15 in
|
|
9
|
+
`.pi/harnesses/` were ported from `disler/pi-vs-claude-code`; `docs/pi-extensions.md` is
|
|
10
|
+
their catalog. A harness can:
|
|
11
|
+
|
|
12
|
+
- replace the footer or status line — `minimal`, `tool-counter`
|
|
13
|
+
- gate every tool call and block or confirm it — `damage-control`, `tilldone`, `purpose-gate`
|
|
14
|
+
- register a new tool or `/command` — `tilldone`, `system-select`, `session-replay`
|
|
15
|
+
- inject text into the system prompt — `purpose-gate`, `system-select`
|
|
16
|
+
- orchestrate sub-agents — `agent-team`, `agent-chain`, `subagent-widget`, `pi-pi`
|
|
17
|
+
- add cross-agent messaging — `coms`, `coms-net`
|
|
18
|
+
|
|
19
|
+
### Harness vs. utility extension — where it lives
|
|
20
|
+
|
|
21
|
+
pi auto-discovers and loads **every** directory under `.pi/extensions/`. The three there
|
|
22
|
+
(`mcp-bridge`, `chrome-devtools-mcp`, `compact-and-continue`) are always-on utilities that
|
|
23
|
+
coexist. Harnesses are different: they are **mutually exclusive** — two that both replace
|
|
24
|
+
the footer fight, two that register the same CLI flag abort startup. So harnesses live in
|
|
25
|
+
`.pi/harnesses/`, which pi does **not** auto-discover, and load one (or two stacked) at a
|
|
26
|
+
time via `pi -e <path>`. Never put a harness under `.pi/extensions/`.
|
|
27
|
+
|
|
28
|
+
## Directory anatomy
|
|
29
|
+
|
|
30
|
+
Every harness is a directory with exactly three files:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
.pi/harnesses/<name>/
|
|
34
|
+
index.ts # the extension
|
|
35
|
+
package.json # four fields, identical shape for every harness
|
|
36
|
+
README.md # the discovery surface
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### package.json
|
|
40
|
+
|
|
41
|
+
Identical shape for every harness — only `name` changes:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"name": "agent-skills-pi-<name>",
|
|
46
|
+
"private": true,
|
|
47
|
+
"type": "module",
|
|
48
|
+
"main": "index.ts"
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Runtime dependencies are **not** declared here. Shared deps (`@sinclair/typebox`, `yaml`)
|
|
53
|
+
live in `.pi/harnesses/package.json` and are installed once by `just install`. The
|
|
54
|
+
`@mariozechner/pi-*` packages are provided by the pi runtime. If a harness needs a new
|
|
55
|
+
dependency, add it to `.pi/harnesses/package.json`, not the per-harness file.
|
|
56
|
+
|
|
57
|
+
## The ExtensionAPI surface
|
|
58
|
+
|
|
59
|
+
`index.ts` exports a default function that receives the `ExtensionAPI`:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
63
|
+
|
|
64
|
+
export default function (pi: ExtensionAPI) {
|
|
65
|
+
// register handlers, tools, and commands here
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Use only events and methods confirmed in an existing harness — a misspelled event name
|
|
70
|
+
fails silently. The list below is what the 15 ported harnesses use.
|
|
71
|
+
|
|
72
|
+
### Events — `pi.on(event, handler)`
|
|
73
|
+
|
|
74
|
+
Handlers are `async (event, ctx) => …`.
|
|
75
|
+
|
|
76
|
+
| Event | Fires when | The handler can |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `session_start` | A session opens | Initialise state; set footer / widget / status; scan files |
|
|
79
|
+
| `session_switch` / `session_fork` / `session_tree` | The user navigates session history | Reconstruct state from `ctx.sessionManager` |
|
|
80
|
+
| `input` | The user submits a prompt | Return `{ action: "continue" }` or `{ action: "handled" }` to swallow it |
|
|
81
|
+
| `before_agent_start` | Just before the model runs | Return `{ systemPrompt }` to replace or extend the system prompt |
|
|
82
|
+
| `tool_call` | The agent calls any tool | Return `{ block: false }`, or `{ block: true, reason }` to gate it |
|
|
83
|
+
| `agent_end` | The agent finishes a turn | Nudge with `pi.sendMessage`; refresh UI |
|
|
84
|
+
|
|
85
|
+
### Registering tools and commands
|
|
86
|
+
|
|
87
|
+
- `pi.registerTool({ name, label, description, parameters, execute, renderCall, renderResult })`
|
|
88
|
+
— `parameters` is a TypeBox schema (`import { Type } from "@sinclair/typebox"`). The
|
|
89
|
+
`description` is read by the model, so write it the way you'd write a skill description.
|
|
90
|
+
`execute` is `async (toolCallId, params, signal, onUpdate, ctx) => { content, details }`.
|
|
91
|
+
- `pi.registerCommand("name", { description, handler })` — adds a `/name` slash command;
|
|
92
|
+
`handler` is `async (args, ctx) => …`.
|
|
93
|
+
|
|
94
|
+
### Other pi methods
|
|
95
|
+
|
|
96
|
+
- `pi.getActiveTools()` / `pi.setActiveTools(names)` — read or restrict the tool set
|
|
97
|
+
- `pi.sendMessage(msg, { triggerTurn })` — inject a message, optionally starting a turn
|
|
98
|
+
- `pi.appendEntry(type, data)` — write a custom entry into the session log
|
|
99
|
+
|
|
100
|
+
### The context object — `ctx`
|
|
101
|
+
|
|
102
|
+
- `ctx.cwd` — project root
|
|
103
|
+
- `ctx.model` — active model (`ctx.model?.id`)
|
|
104
|
+
- `ctx.getContextUsage()` — `{ percent }` context-window usage
|
|
105
|
+
- `ctx.getSystemPrompt()` — the current system prompt
|
|
106
|
+
- `ctx.sessionManager.getBranch()` — session entries, for state reconstruction
|
|
107
|
+
- `ctx.abort()` — abort the current turn
|
|
108
|
+
- `ctx.hasUI` — false in headless runs; guard UI-only commands with it
|
|
109
|
+
- `ctx.ui.setFooter(fn)` / `setWidget(id, fn, opts)` / `setStatus(text, id)` — UI surfaces
|
|
110
|
+
- `ctx.ui.notify(text, level)` — transient message (`info` | `warning` | `error` | `success`)
|
|
111
|
+
- `ctx.ui.confirm(title, body, opts)` — yes/no dialog
|
|
112
|
+
- `ctx.ui.select(title, options)` — pick-one dialog
|
|
113
|
+
- `ctx.ui.input(title, placeholder)` — text-input dialog
|
|
114
|
+
- `ctx.ui.custom(fn)` — full-screen overlay component
|
|
115
|
+
|
|
116
|
+
UI rendering uses `@mariozechner/pi-tui` helpers (`Text`, `Container`, `DynamicBorder`,
|
|
117
|
+
`truncateToWidth`, `visibleWidth`, `matchesKey`). Render against pi's active theme — do
|
|
118
|
+
not ship theme files (the ported harnesses had their theme code stripped).
|
|
119
|
+
|
|
120
|
+
## index.ts skeleton
|
|
121
|
+
|
|
122
|
+
The minimum viable harness — adapt to the chosen surface:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
/**
|
|
126
|
+
* <Name> — <one-line purpose>
|
|
127
|
+
*
|
|
128
|
+
* <2-3 lines on what it does and why.>
|
|
129
|
+
*
|
|
130
|
+
* Usage: pi -e .pi/harnesses/<name>/index.ts
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
134
|
+
|
|
135
|
+
export default function (pi: ExtensionAPI) {
|
|
136
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
137
|
+
// initialise state, set UI surfaces
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// add a tool_call gate / registerTool / registerCommand as the purpose requires
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Copy the closest existing harness
|
|
145
|
+
|
|
146
|
+
Do not write from scratch. Pick the nearest pattern and adapt it:
|
|
147
|
+
|
|
148
|
+
| If the harness… | Study | Approx. lines |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| Replaces the footer with status | `minimal` | 30 |
|
|
151
|
+
| Counts or summarises tool calls | `tool-counter`, `tool-counter-widget` | 70–100 |
|
|
152
|
+
| Gates the session on a precondition | `purpose-gate` | 80 |
|
|
153
|
+
| Blocks tool calls from a rules file | `damage-control` | 200 |
|
|
154
|
+
| Adds a `/command` that picks from files | `system-select` | 165 |
|
|
155
|
+
| Registers a tool + gate + multi-surface UI | `tilldone` | 720 |
|
|
156
|
+
| Orchestrates sub-agents | `agent-team`, `agent-chain`, `subagent-widget` | large |
|
|
157
|
+
|
|
158
|
+
Start from the smallest one that has the surface you need.
|
|
159
|
+
|
|
160
|
+
## README.md template
|
|
161
|
+
|
|
162
|
+
The README is the discovery surface — keep it to these sections, matching the others in
|
|
163
|
+
`.pi/harnesses/`:
|
|
164
|
+
|
|
165
|
+
```markdown
|
|
166
|
+
# <name>
|
|
167
|
+
|
|
168
|
+
<One-line subtitle.>
|
|
169
|
+
|
|
170
|
+
## What it does
|
|
171
|
+
|
|
172
|
+
<1-2 short paragraphs: the session surface it changes and why it is useful.>
|
|
173
|
+
|
|
174
|
+
## Commands & tools
|
|
175
|
+
|
|
176
|
+
<List each `/command` and registered tool — or "None — <surface> only.">
|
|
177
|
+
|
|
178
|
+
## Requires
|
|
179
|
+
|
|
180
|
+
<Files, env vars, or a sibling harness it stacks with. Omit the section if nothing.>
|
|
181
|
+
|
|
182
|
+
## Usage
|
|
183
|
+
|
|
184
|
+
\`\`\`bash
|
|
185
|
+
pi -e .pi/harnesses/<name>/index.ts
|
|
186
|
+
\`\`\`
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
A ported harness also carries an attribution blockquote and an "Upstream changes" section.
|
|
190
|
+
A **new** harness authored in this repo needs neither.
|
|
191
|
+
|
|
192
|
+
## Wiring — three edits beyond the directory
|
|
193
|
+
|
|
194
|
+
1. **`justfile`** — add a recipe under the matching `# -----` category header:
|
|
195
|
+
```
|
|
196
|
+
# <Name>: <short description>
|
|
197
|
+
ext-<name>:
|
|
198
|
+
pi -e .pi/harnesses/<name>/index.ts
|
|
199
|
+
```
|
|
200
|
+
If the harness has no footer of its own, stack `minimal`:
|
|
201
|
+
`pi -e .pi/harnesses/<name>/index.ts -e .pi/harnesses/minimal/index.ts`.
|
|
202
|
+
2. **`docs/pi-extensions.md`** — add one row to the catalog table:
|
|
203
|
+
`| [<name>](../.pi/harnesses/<name>/README.md) | <Category> | <what it does> | `just ext-<name>` |`.
|
|
204
|
+
Categories in use: UI, Focus, Safety, Orchestration, Messaging.
|
|
205
|
+
3. **`.pi/harnesses/package.json`** — add any new runtime dependency (only if one is needed).
|
|
206
|
+
|
|
207
|
+
## Verify the harness runs
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
just install # only if a dependency was added
|
|
211
|
+
pi -e .pi/harnesses/<name>/index.ts # launches without error
|
|
212
|
+
just ext-<name> # the recipe works
|
|
213
|
+
```
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-and-adrs
|
|
3
|
+
description: Records decisions and documentation. Use when making architectural decisions, changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Documentation and ADRs
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Document decisions, not just code. The most valuable documentation captures the *why* — the context, constraints, and trade-offs that led to a decision. Code shows *what* was built; documentation explains *why it was built this way* and *what alternatives were considered*. This context is essential for future humans and agents working in the codebase.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- Making a significant architectural decision
|
|
15
|
+
- Choosing between competing approaches
|
|
16
|
+
- Adding or changing a public API
|
|
17
|
+
- Shipping a feature that changes user-facing behavior
|
|
18
|
+
- Onboarding new team members (or agents) to the project
|
|
19
|
+
- When you find yourself explaining the same thing repeatedly
|
|
20
|
+
|
|
21
|
+
**When NOT to use:** Don't document obvious code. Don't add comments that restate what the code already says. Don't write docs for throwaway prototypes.
|
|
22
|
+
|
|
23
|
+
## Architecture Decision Records (ADRs)
|
|
24
|
+
|
|
25
|
+
ADRs capture the reasoning behind significant technical decisions. They're the highest-value documentation you can write.
|
|
26
|
+
|
|
27
|
+
### When to Write an ADR
|
|
28
|
+
|
|
29
|
+
- Choosing a framework, library, or major dependency
|
|
30
|
+
- Designing a data model or database schema
|
|
31
|
+
- Selecting an authentication strategy
|
|
32
|
+
- Deciding on an API architecture (REST vs. GraphQL vs. tRPC)
|
|
33
|
+
- Choosing between build tools, hosting platforms, or infrastructure
|
|
34
|
+
- Any decision that would be expensive to reverse
|
|
35
|
+
|
|
36
|
+
### ADR Template
|
|
37
|
+
|
|
38
|
+
Store ADRs in `docs/decisions/` with sequential numbering:
|
|
39
|
+
|
|
40
|
+
```markdown
|
|
41
|
+
# ADR-001: Use PostgreSQL for primary database
|
|
42
|
+
|
|
43
|
+
## Status
|
|
44
|
+
Accepted | Superseded by ADR-XXX | Deprecated
|
|
45
|
+
|
|
46
|
+
## Date
|
|
47
|
+
2025-01-15
|
|
48
|
+
|
|
49
|
+
## Context
|
|
50
|
+
We need a primary database for the task management application. Key requirements:
|
|
51
|
+
- Relational data model (users, tasks, teams with relationships)
|
|
52
|
+
- ACID transactions for task state changes
|
|
53
|
+
- Support for full-text search on task content
|
|
54
|
+
- Managed hosting available (for small team, limited ops capacity)
|
|
55
|
+
|
|
56
|
+
## Decision
|
|
57
|
+
Use PostgreSQL with Prisma ORM.
|
|
58
|
+
|
|
59
|
+
## Alternatives Considered
|
|
60
|
+
|
|
61
|
+
### MongoDB
|
|
62
|
+
- Pros: Flexible schema, easy to start with
|
|
63
|
+
- Cons: Our data is inherently relational; would need to manage relationships manually
|
|
64
|
+
- Rejected: Relational data in a document store leads to complex joins or data duplication
|
|
65
|
+
|
|
66
|
+
### SQLite
|
|
67
|
+
- Pros: Zero configuration, embedded, fast for reads
|
|
68
|
+
- Cons: Limited concurrent write support, no managed hosting for production
|
|
69
|
+
- Rejected: Not suitable for multi-user web application in production
|
|
70
|
+
|
|
71
|
+
### MySQL
|
|
72
|
+
- Pros: Mature, widely supported
|
|
73
|
+
- Cons: PostgreSQL has better JSON support, full-text search, and ecosystem tooling
|
|
74
|
+
- Rejected: PostgreSQL is the better fit for our feature requirements
|
|
75
|
+
|
|
76
|
+
## Consequences
|
|
77
|
+
- Prisma provides type-safe database access and migration management
|
|
78
|
+
- We can use PostgreSQL's full-text search instead of adding Elasticsearch
|
|
79
|
+
- Team needs PostgreSQL knowledge (standard skill, low risk)
|
|
80
|
+
- Hosting on managed service (Supabase, Neon, or RDS)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### ADR Lifecycle
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
PROPOSED → ACCEPTED → (SUPERSEDED or DEPRECATED)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- **Don't delete old ADRs.** They capture historical context.
|
|
90
|
+
- When a decision changes, write a new ADR that references and supersedes the old one.
|
|
91
|
+
|
|
92
|
+
## Inline Documentation
|
|
93
|
+
|
|
94
|
+
### When to Comment
|
|
95
|
+
|
|
96
|
+
Comment the *why*, not the *what*:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// BAD: Restates the code
|
|
100
|
+
// Increment counter by 1
|
|
101
|
+
counter += 1;
|
|
102
|
+
|
|
103
|
+
// GOOD: Explains non-obvious intent
|
|
104
|
+
// Rate limit uses a sliding window — reset counter at window boundary,
|
|
105
|
+
// not on a fixed schedule, to prevent burst attacks at window edges
|
|
106
|
+
if (now - windowStart > WINDOW_SIZE_MS) {
|
|
107
|
+
counter = 0;
|
|
108
|
+
windowStart = now;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### When NOT to Comment
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// Don't comment self-explanatory code
|
|
116
|
+
function calculateTotal(items: CartItem[]): number {
|
|
117
|
+
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Don't leave TODO comments for things you should just do now
|
|
121
|
+
// TODO: add error handling ← Just add it
|
|
122
|
+
|
|
123
|
+
// Don't leave commented-out code
|
|
124
|
+
// const oldImplementation = () => { ... } ← Delete it, git has history
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Document Known Gotchas
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
/**
|
|
131
|
+
* IMPORTANT: This function must be called before the first render.
|
|
132
|
+
* If called after hydration, it causes a flash of unstyled content
|
|
133
|
+
* because the theme context isn't available during SSR.
|
|
134
|
+
*
|
|
135
|
+
* See ADR-003 for the full design rationale.
|
|
136
|
+
*/
|
|
137
|
+
export function initializeTheme(theme: Theme): void {
|
|
138
|
+
// ...
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## API Documentation
|
|
143
|
+
|
|
144
|
+
For public APIs (REST, GraphQL, library interfaces):
|
|
145
|
+
|
|
146
|
+
### Inline with Types (Preferred for TypeScript)
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
/**
|
|
150
|
+
* Creates a new task.
|
|
151
|
+
*
|
|
152
|
+
* @param input - Task creation data (title required, description optional)
|
|
153
|
+
* @returns The created task with server-generated ID and timestamps
|
|
154
|
+
* @throws {ValidationError} If title is empty or exceeds 200 characters
|
|
155
|
+
* @throws {AuthenticationError} If the user is not authenticated
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* const task = await createTask({ title: 'Buy groceries' });
|
|
159
|
+
* console.log(task.id); // "task_abc123"
|
|
160
|
+
*/
|
|
161
|
+
export async function createTask(input: CreateTaskInput): Promise<Task> {
|
|
162
|
+
// ...
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### OpenAPI / Swagger for REST APIs
|
|
167
|
+
|
|
168
|
+
```yaml
|
|
169
|
+
paths:
|
|
170
|
+
/api/tasks:
|
|
171
|
+
post:
|
|
172
|
+
summary: Create a task
|
|
173
|
+
requestBody:
|
|
174
|
+
required: true
|
|
175
|
+
content:
|
|
176
|
+
application/json:
|
|
177
|
+
schema:
|
|
178
|
+
$ref: '#/components/schemas/CreateTaskInput'
|
|
179
|
+
responses:
|
|
180
|
+
'201':
|
|
181
|
+
description: Task created
|
|
182
|
+
content:
|
|
183
|
+
application/json:
|
|
184
|
+
schema:
|
|
185
|
+
$ref: '#/components/schemas/Task'
|
|
186
|
+
'422':
|
|
187
|
+
description: Validation error
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## README Structure
|
|
191
|
+
|
|
192
|
+
Every project should have a README that covers:
|
|
193
|
+
|
|
194
|
+
```markdown
|
|
195
|
+
# Project Name
|
|
196
|
+
|
|
197
|
+
One-paragraph description of what this project does.
|
|
198
|
+
|
|
199
|
+
## Quick Start
|
|
200
|
+
1. Clone the repo
|
|
201
|
+
2. Install dependencies: `npm install`
|
|
202
|
+
3. Set up environment: `cp .env.example .env`
|
|
203
|
+
4. Run the dev server: `npm run dev`
|
|
204
|
+
|
|
205
|
+
## Commands
|
|
206
|
+
| Command | Description |
|
|
207
|
+
|---------|-------------|
|
|
208
|
+
| `npm run dev` | Start development server |
|
|
209
|
+
| `npm test` | Run tests |
|
|
210
|
+
| `npm run build` | Production build |
|
|
211
|
+
| `npm run lint` | Run linter |
|
|
212
|
+
|
|
213
|
+
## Architecture
|
|
214
|
+
Brief overview of the project structure and key design decisions.
|
|
215
|
+
Link to ADRs for details.
|
|
216
|
+
|
|
217
|
+
## Contributing
|
|
218
|
+
How to contribute, coding standards, PR process.
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Changelog Maintenance
|
|
222
|
+
|
|
223
|
+
For shipped features:
|
|
224
|
+
|
|
225
|
+
```markdown
|
|
226
|
+
# Changelog
|
|
227
|
+
|
|
228
|
+
## [1.2.0] - 2025-01-20
|
|
229
|
+
### Added
|
|
230
|
+
- Task sharing: users can share tasks with team members (#123)
|
|
231
|
+
- Email notifications for task assignments (#124)
|
|
232
|
+
|
|
233
|
+
### Fixed
|
|
234
|
+
- Duplicate tasks appearing when rapidly clicking create button (#125)
|
|
235
|
+
|
|
236
|
+
### Changed
|
|
237
|
+
- Task list now loads 50 items per page (was 20) for better UX (#126)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Documentation for Agents
|
|
241
|
+
|
|
242
|
+
Special consideration for AI agent context:
|
|
243
|
+
|
|
244
|
+
- **CLAUDE.md / rules files** — Document project conventions so agents follow them
|
|
245
|
+
- **Spec files** — Keep specs updated so agents build the right thing
|
|
246
|
+
- **ADRs** — Help agents understand why past decisions were made (prevents re-deciding)
|
|
247
|
+
- **Inline gotchas** — Prevent agents from falling into known traps
|
|
248
|
+
|
|
249
|
+
## Common Rationalizations
|
|
250
|
+
|
|
251
|
+
| Rationalization | Reality |
|
|
252
|
+
|---|---|
|
|
253
|
+
| "The code is self-documenting" | Code shows what. It doesn't show why, what alternatives were rejected, or what constraints apply. |
|
|
254
|
+
| "We'll write docs when the API stabilizes" | APIs stabilize faster when you document them. The doc is the first test of the design. |
|
|
255
|
+
| "Nobody reads docs" | Agents do. Future engineers do. Your 3-months-later self does. |
|
|
256
|
+
| "ADRs are overhead" | A 10-minute ADR prevents a 2-hour debate about the same decision six months later. |
|
|
257
|
+
| "Comments get outdated" | Comments on *why* are stable. Comments on *what* get outdated — that's why you only write the former. |
|
|
258
|
+
|
|
259
|
+
## Red Flags
|
|
260
|
+
|
|
261
|
+
- Architectural decisions with no written rationale
|
|
262
|
+
- Public APIs with no documentation or types
|
|
263
|
+
- README that doesn't explain how to run the project
|
|
264
|
+
- Commented-out code instead of deletion
|
|
265
|
+
- TODO comments that have been there for weeks
|
|
266
|
+
- No ADRs in a project with significant architectural choices
|
|
267
|
+
- Documentation that restates the code instead of explaining intent
|
|
268
|
+
|
|
269
|
+
## Verification
|
|
270
|
+
|
|
271
|
+
After documenting:
|
|
272
|
+
|
|
273
|
+
- [ ] ADRs exist for all significant architectural decisions
|
|
274
|
+
- [ ] README covers quick start, commands, and architecture overview
|
|
275
|
+
- [ ] API functions have parameter and return type documentation
|
|
276
|
+
- [ ] Known gotchas are documented inline where they matter
|
|
277
|
+
- [ ] No commented-out code remains
|
|
278
|
+
- [ ] Rules files (CLAUDE.md etc.) are current and accurate
|