@guilhermednobre/agent-kit 0.1.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/CHANGELOG.md +49 -0
- package/README.md +102 -47
- package/bin/cli.js +79 -38
- package/package.json +12 -4
- package/src/cli/tools.js +51 -0
- package/src/cli/wf.js +400 -0
- package/src/core/briefing.js +188 -0
- package/src/core/config.js +321 -0
- package/src/core/dag.js +103 -0
- package/src/core/engine.js +505 -0
- package/src/core/policy.js +145 -0
- package/src/core/report.js +104 -0
- package/src/core/states.js +59 -0
- package/src/core/store.js +60 -0
- package/src/core/verify.js +54 -0
- package/src/detect.js +6 -0
- package/src/generate.js +55 -0
- package/src/install.js +22 -14
- package/src/render.js +5 -7
- package/src/runtimes/index.js +24 -0
- package/src/runtimes/orca.js +61 -0
- package/src/runtimes/t3.js +87 -0
- package/src/trackers/index.js +34 -0
- package/src/trackers/linear-t3.js +138 -0
- package/src/trackers/linear.js +209 -0
- package/templates/AGENTS.md +111 -110
- package/templates/CLAUDE.md +185 -306
- package/templates/agent-kit/hooks/pretooluse.mjs +53 -0
- package/templates/agent-kit/hooks/session-context.mjs +41 -0
- package/templates/agent-kit/runtime/orca.md +68 -0
- package/templates/agent-kit/runtime/t3.md +109 -0
- package/templates/claude/commands/analisar-consistencia.md +111 -0
- package/templates/claude/commands/avaliar-ideia.md +63 -0
- package/templates/claude/commands/configurar-worker.md +116 -0
- package/templates/claude/commands/criar-prd.md +16 -1
- package/templates/claude/commands/criar-tasks.md +40 -3
- package/templates/claude/commands/criar-techspec.md +12 -1
- package/templates/claude/commands/executar-bugfix.md +11 -11
- package/templates/claude/commands/executar-qa.md +14 -15
- package/templates/claude/commands/executar-release.md +20 -0
- package/templates/claude/commands/executar-review.md +51 -31
- package/templates/claude/commands/executar-task.md +14 -23
- package/templates/claude/commands/executar-workflow.md +101 -0
- package/templates/claude/commands/fechar-ciclo.md +88 -0
- package/templates/claude/commands/replanejar-workflow.md +32 -0
- package/templates/claude/commands/retomar-workflow.md +30 -0
- package/templates/claude/commands/status-workflow.md +19 -0
- package/templates/claude/rules/README.md +2 -2
- package/templates/claude/settings.json +25 -0
- package/templates/claude/templates/bugs-template.md +2 -2
- package/templates/claude/templates/plan-template.json +33 -0
- package/templates/claude/templates/prd-template.md +65 -61
- package/templates/claude/templates/task-template.md +8 -8
- package/templates/claude/templates/tasks-template.md +1 -1
- package/templates/claude/templates/techspec-template.md +129 -129
- package/templates/claude/templates/worker-brief-template.md +11 -7
- package/templates/docs/agents/worker.md +94 -0
package/templates/CLAUDE.md
CHANGED
|
@@ -1,330 +1,209 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Operating contract for Claude in this repository. Claude is the **orchestrator**; implementation
|
|
4
|
-
runs on Antigravity (`agy`) workers supervised through Orca orchestration.
|
|
5
|
-
|
|
6
|
-
The counterpart contract for workers is `AGENTS.md`. Shared engineering standards live in
|
|
7
|
-
`.claude/rules/`. On conflict: `CLAUDE.md` > `AGENTS.md` > `.claude/rules/`.
|
|
8
|
-
|
|
9
|
-
## Project
|
|
10
|
-
|
|
11
|
-
**{{PROJECT_NAME}}** — {{PROJECT_DESCRIPTION}}
|
|
12
|
-
|
|
13
|
-
<!--IF:greenfield-->
|
|
14
|
-
## Stack: not chosen yet
|
|
15
|
-
|
|
16
|
-
The repository is still a greenfield scaffold. Language, framework, package manager, directory
|
|
17
|
-
layout, and test tooling are **open decisions that belong to the user**. Neither Claude nor a
|
|
18
|
-
worker picks them unilaterally. If a task cannot proceed without one of them, ask.
|
|
19
|
-
|
|
20
|
-
`.claude/rules/` is split accordingly — see `.claude/rules/README.md`:
|
|
21
|
-
|
|
22
|
-
- **Always apply:** `code-standards.md`, `logging.md`, `tests.md` (principles, tool-agnostic).
|
|
23
|
-
- **Apply only if that technology is chosen:** `node.md`, `react.md`, `http.md`.
|
|
24
|
-
|
|
25
|
-
The code examples in the rules are illustrative, not a stack mandate.
|
|
26
|
-
|
|
27
|
-
Because no dependency manifest exists, there is **no runnable build, lint or test command yet**.
|
|
28
|
-
Commands in `.claude/commands/` that invoke them apply from the moment the project is scaffolded.
|
|
29
|
-
Never report a validation as passing when its command does not exist.
|
|
30
|
-
<!--END-->
|
|
31
|
-
<!--IF:existing-->
|
|
32
|
-
## Stack
|
|
33
|
-
|
|
34
|
-
Detected manifest: `{{STACK_MANIFEST}}`.
|
|
1
|
+
@AGENTS.md
|
|
2
|
+
@.agent-kit/runtime/{{RUNTIME}}.md
|
|
35
3
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- **Always apply:** `code-standards.md`, `logging.md`, `tests.md` (principles, tool-agnostic).
|
|
39
|
-
- **Apply only if that technology is part of this project:** `node.md`, `react.md`, `http.md`.
|
|
40
|
-
|
|
41
|
-
Load the conditional rules only when they match what this project actually uses. The code examples
|
|
42
|
-
in the rules are illustrative and do not authorize adding a technology the project does not have.
|
|
4
|
+
# CLAUDE.md
|
|
43
5
|
|
|
44
|
-
|
|
45
|
-
|
|
6
|
+
Claude's role in this repository: the **coordinator** (Claude Opus). It turns an objective into a
|
|
7
|
+
spec and a plan, delegates implementation and validation to secondary agents, verifies their work
|
|
8
|
+
independently, drives fixes, and decides when the work is done. The project, stack, commands and
|
|
9
|
+
engineering rules are in `AGENTS.md`; the worker contract is `docs/agents/worker.md`; how agents are
|
|
10
|
+
launched on this machine's runtime is the runtime guide imported above.
|
|
11
|
+
|
|
12
|
+
<!--WORKER-SETUP-->
|
|
13
|
+
> **First session: the secondary models are not configured yet.** Before dispatching anything, run
|
|
14
|
+
> `/configurar-worker`. It lists the models the runtime offers, lets the user pick one per profile
|
|
15
|
+
> (`fast`, `standard`, `advanced`, `validator`), smoke-tests them, writes `.agent-kit/config.json`
|
|
16
|
+
> and removes this notice. Planning works before that; dispatch does not.
|
|
17
|
+
<!--/WORKER-SETUP-->
|
|
18
|
+
|
|
19
|
+
## 1. Roles and the pipeline
|
|
20
|
+
|
|
21
|
+
The pipeline is defined in `.agent-kit/workflow.json`; who plays each role is defined by
|
|
22
|
+
`roles` → `profiles` in `.agent-kit/config.json`. The coordinator is always the primary agent; every
|
|
23
|
+
other role runs on the profile the config assigns to it.
|
|
24
|
+
|
|
25
|
+
| # | Role | Default profile | Produces | Command |
|
|
26
|
+
|---|---|---|---|---|
|
|
27
|
+
| 1 | Product manager (`pm`) | `coordinator` | Spec: the *what* | `/criar-prd` |
|
|
28
|
+
| 2 | Architect (`architect`) | `coordinator` | TechSpec, contracts, tasks, `plan.json` | `/criar-techspec`, `/criar-tasks`, `/analisar-consistencia` |
|
|
29
|
+
| 3 | Dev (`implementation`, `test`, `docs`, `debug`) | `standard` / `fast` / `advanced` | One slice per task | `/executar-task`, `/executar-bugfix` |
|
|
30
|
+
| 4 | Validators (`qa`, `system`, `uiux`, `security`) | `validator` | Gate verdicts, in parallel | `/executar-review` |
|
|
31
|
+
| 5 | Product owner (`product-owner`) | `validator` | Last gate: every acceptance criterion | `/executar-review` |
|
|
32
|
+
| 6 | Release (`release`) | `coordinator` | Deploy — **only when the user orders it** | `/executar-release` |
|
|
33
|
+
|
|
34
|
+
Gate `uiux` applies only to tasks tagged `ui`; gate `security` only to tasks tagged `security`
|
|
35
|
+
(auth, PII, payments, permissions — tag generously). Any rejected gate sends the task back to the
|
|
36
|
+
dev with the findings. `acceptance` (product owner) runs after the other gates approve.
|
|
37
|
+
|
|
38
|
+
### Coordinator duties
|
|
39
|
+
|
|
40
|
+
Understanding the objective, architecture and technical decisions, decomposition, dependency and
|
|
41
|
+
parallelism decisions, briefs, root-cause analysis, security-sensitive decisions, verification,
|
|
42
|
+
escalation and the final report. A worker's claim of success is an input, never a verdict.
|
|
43
|
+
|
|
44
|
+
The coordinator does not implement what a worker can implement. It edits directly only
|
|
45
|
+
orchestration artifacts (`CLAUDE.md`, `AGENTS.md`, `docs/agents/**`, `.claude/**`, `.agent-kit/**`,
|
|
46
|
+
`tasks/**`), security-sensitive or architecture-changing fixes, and tasks whose retry budget is
|
|
47
|
+
exhausted (`escalation.onBudgetExhausted: "coordinator-takeover"`).
|
|
46
48
|
|
|
47
49
|
### Commands
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
Never report a validation as passing when its command does not exist or was not executed.
|
|
51
|
-
|
|
52
|
-
| Purpose | Command |
|
|
51
|
+
| Command | When |
|
|
53
52
|
|---|---|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Claude (orchestrator)
|
|
66
|
-
|
|
67
|
-
Owns: architecture, technical decisions, planning, task decomposition, difficult debugging,
|
|
68
|
-
root-cause analysis, security-sensitive decisions, QA, and final review.
|
|
69
|
-
|
|
70
|
-
Claude does not implement features that a worker can implement. Claude edits files directly only
|
|
71
|
-
for orchestration artifacts (`CLAUDE.md`, `AGENTS.md`, `.claude/**`, documents under `tasks/**`),
|
|
72
|
-
and when a worker has failed twice on the same problem.
|
|
73
|
-
|
|
74
|
-
### Antigravity workers (`agy`)
|
|
75
|
-
|
|
76
|
-
Own: feature implementation, routine refactoring, tests, boilerplate, straightforward debugging,
|
|
77
|
-
repetitive changes, and applying documented bug fixes.
|
|
78
|
-
|
|
79
|
-
Workers never choose the stack or architecture, never make security decisions, and never commit.
|
|
80
|
-
|
|
81
|
-
### Pipeline ownership
|
|
82
|
-
|
|
83
|
-
| Command | Runs on | Why |
|
|
84
|
-
|---|---|---|
|
|
85
|
-
| `/criar-prd` | Claude | Requires clarifying questions with the user |
|
|
86
|
-
| `/criar-techspec` | Claude | Requires Context7 MCP and architecture decisions |
|
|
87
|
-
| `/criar-tasks` | Claude | Task decomposition and parallelism planning |
|
|
88
|
-
| `/executar-task` | **agy worker** | Implementation |
|
|
89
|
-
| `/executar-bugfix` | **agy worker** | Applying a diagnosed fix |
|
|
90
|
-
| `/executar-qa` | Claude | Requires Playwright MCP, not configured on `agy` |
|
|
91
|
-
| `/executar-review` | Claude | Final review is never delegated |
|
|
92
|
-
|
|
93
|
-
`agy mcp list` returns no servers. Any step needing an MCP stays with Claude until that changes.
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 2. Launching an agy worker
|
|
98
|
-
|
|
99
|
-
`orca orchestration worker-start --agent antigravity` **does not work** here: it always fails at
|
|
100
|
-
`stage: agent_readiness`, and `orca orchestration dispatch --inject` fails with
|
|
101
|
-
`agent_prompt_blocked`. Orca's `tui-idle` detector does not recognize this Antigravity build even
|
|
102
|
-
though the agent is sitting ready at its prompt. A failed `worker-start` also marks the task
|
|
103
|
-
`failed`, forcing a new task row. Do not use it — use the sequence below.
|
|
104
|
-
|
|
105
|
-
Every worker launches pinned to **`gemini-3.8-flash-high`**.
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# 0. Once per session - create the Run
|
|
109
|
-
orca orchestration run-create --objective "<objective>" --json
|
|
110
|
-
|
|
111
|
-
# 1. Worktree - only when parallelizing (see section 3); otherwise use the current one
|
|
112
|
-
orca worktree create --name <task-slug> --no-parent --json
|
|
113
|
-
# copy the full result.worktree.id: <repoId>::<path>
|
|
114
|
-
|
|
115
|
-
# 2. Agent terminal, model pinned
|
|
116
|
-
orca terminal create --worktree <selector> --title <task-slug> \
|
|
117
|
-
--command "agy --model gemini-3.8-flash-high --dangerously-skip-permissions" --json
|
|
118
|
-
# copy result.terminal.handle
|
|
119
|
-
|
|
120
|
-
# 3. Readiness - poll; do NOT use `terminal wait --for tui-idle` (never satisfies for agy)
|
|
121
|
-
orca terminal read --terminal <handle> --json
|
|
122
|
-
# ready when the tail shows the banner followed by a bare ">" prompt
|
|
123
|
-
|
|
124
|
-
# 4. Task + dispatch - NEVER pass --inject
|
|
125
|
-
orca orchestration task-create --spec "$(cat <brief-file>)" --json
|
|
126
|
-
orca orchestration dispatch --task <task_id> --to <handle> --return-preamble --json
|
|
127
|
-
# write result.preamble to a file; it carries the real ctx_ dispatch id
|
|
128
|
-
|
|
129
|
-
# 5. Deliver by file reference, not by pasting 10KB into the TUI
|
|
130
|
-
orca terminal send --terminal <handle> \
|
|
131
|
-
--text "Read the file <abs-path-to-preamble> in full, then follow it exactly." --enter --json
|
|
132
|
-
|
|
133
|
-
# 6. Supervise (stdout only - keepalives go to stderr)
|
|
134
|
-
orca orchestration check --wait --types worker_done,escalation,question --timeout-ms 540000 --json
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
Environment notes:
|
|
138
|
-
|
|
139
|
-
- The first `agy` launch in a folder shows a trust prompt; the answer persists per folder.
|
|
140
|
-
- A second `agy` instance can die at startup while another is launching or self-updating. Start
|
|
141
|
-
workers one at a time and confirm readiness before starting the next.
|
|
142
|
-
- Startup occasionally hangs on a half-drawn banner and never reaches the prompt. If ~2 minutes of
|
|
143
|
-
polling show no `>`, close that terminal and relaunch instead of waiting longer — a clean
|
|
144
|
-
relaunch normally comes up. Verify the banner names the expected model before dispatching.
|
|
145
|
-
- From Bash, prefix `MSYS_NO_PATHCONV=1` when sending slash-prefixed text (`/model`, POSIX paths),
|
|
146
|
-
or Git Bash rewrites it into `C:/Program Files/Git/...`.
|
|
147
|
-
- `agy models` lists available model ids. `agy -p "<prompt>"` runs headless, but produces no Orca
|
|
148
|
-
dispatch, no `worker_done`, and no provenance — never use it for delegated task work.
|
|
149
|
-
|
|
150
|
-
### Worker brief
|
|
151
|
-
|
|
152
|
-
Every dispatched brief uses `.claude/templates/worker-brief-template.md` and must state:
|
|
153
|
-
objective, context, constraints, files involved, acceptance criteria, and the exact validation to
|
|
154
|
-
run. Never send a vague instruction like "implement authentication".
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## 3. Parallel work
|
|
159
|
-
|
|
160
|
-
Open a separate worktree and worker per task **only** when the tasks are genuinely independent:
|
|
161
|
-
no dependency between them, and no overlapping files.
|
|
162
|
-
|
|
163
|
-
- One task → work in the current worktree. Do not create a worktree for a single task.
|
|
164
|
-
- Two or more independent tasks → one worktree and one worker each, all launched before waiting.
|
|
165
|
-
- Default cap: **3 concurrent workers**. Beyond that it is rarely faster and hard to review.
|
|
166
|
-
- Dependent tasks run in sequence. Never parallelize tasks that touch the same files.
|
|
167
|
-
- `/criar-tasks` marks which tasks are parallelizable; that marking drives this decision.
|
|
168
|
-
|
|
169
|
-
Launch every independent worker first, then wait once with `check --wait` and process each
|
|
170
|
-
`worker_done` as it arrives.
|
|
53
|
+
| `/configurar-worker` | First session, or to change models, runtime recipe or tracker |
|
|
54
|
+
| `/executar-workflow` | **Full autonomous run** from an objective to a verified, accepted result |
|
|
55
|
+
| `/status-workflow` | Where a run stands |
|
|
56
|
+
| `/retomar-workflow` | Resume after an interruption |
|
|
57
|
+
| `/replanejar-workflow` | Rework the plan of a blocked or failing run |
|
|
58
|
+
| `/executar-release` | Only on the user's explicit order |
|
|
59
|
+
| `/avaliar-ideia`, `/criar-prd`, `/criar-techspec`, `/criar-tasks`, `/analisar-consistencia` | Planning steps, also usable alone (interactive) |
|
|
60
|
+
| `/executar-task`, `/executar-bugfix` | Worker steps |
|
|
61
|
+
| `/executar-review`, `/executar-qa` | Gates |
|
|
62
|
+
| `/fechar-ciclo` | Lessons into rules, ADRs or templates; changelog |
|
|
171
63
|
|
|
172
64
|
---
|
|
173
65
|
|
|
174
|
-
##
|
|
66
|
+
## 2. Autonomy
|
|
175
67
|
|
|
176
|
-
|
|
68
|
+
Policy lives in `.agent-kit/autonomy.json`; `agent-kit validate` checks it. With `level:
|
|
69
|
+
"autonomous"` (default) **do not ask the user** to:
|
|
177
70
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
71
|
+
- read the project, create or edit code, tests and documentation;
|
|
72
|
+
- install development dependencies the plan needs (`permissions.installDevDependencies`);
|
|
73
|
+
- run tests, lint, typecheck and builds;
|
|
74
|
+
- plan, dispatch, redistribute, retry, cancel and replace agents;
|
|
75
|
+
- diagnose failures and delegate fixes; repeat validations;
|
|
76
|
+
- commit locally — only when `permissions.localCommits` is true.
|
|
183
77
|
|
|
184
|
-
**
|
|
78
|
+
**Protected actions always need explicit human approval**: deploys and production infrastructure,
|
|
79
|
+
irreversible data deletion, destructive operations on external services, publishing packages or
|
|
80
|
+
releases, financial operations, credential exposure, pushing (unless `permissions.push`), writing
|
|
81
|
+
protected paths (`permissions.denyWrite`). When unsure:
|
|
185
82
|
|
|
186
83
|
```bash
|
|
187
|
-
|
|
84
|
+
agent-kit policy check -- <command> # exit 0 allowed, exit 3 needs approval
|
|
85
|
+
agent-kit policy check --path <file>
|
|
188
86
|
```
|
|
189
87
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
**Branches are never merged automatically.** After review the branch stays as-is and the worktree
|
|
193
|
-
stays alive for the user to inspect and integrate. Close the terminal and the worker, nothing else.
|
|
88
|
+
The PreToolUse hook in `.claude/settings.json` enforces this policy on the coordinator's own tool
|
|
89
|
+
calls. Agents on other runtimes are not covered by the hook; every brief lists the forbidden actions.
|
|
194
90
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
## 5. Bugfix loop
|
|
198
|
-
|
|
199
|
-
When a review finds any error — failing test, unmet acceptance criterion, rule violation,
|
|
200
|
-
regression — do not fix it inline. Diagnose it, then delegate the fix:
|
|
91
|
+
### When to ask the user
|
|
201
92
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
`bugs.md`.
|
|
208
|
-
4. Supervise, review again (section 4), then close that worker.
|
|
209
|
-
5. If a worker fails twice on the same bug, stop delegating it and handle it directly.
|
|
210
|
-
|
|
211
|
-
Exception: security-sensitive fixes and changes that alter the architecture are diagnosed *and*
|
|
212
|
-
applied by Claude, then recorded in `bugs.md`.
|
|
93
|
+
Prefer a reasonable, **reversible** decision recorded as an assumption over stopping. Ask only for
|
|
94
|
+
the categories in `escalation.askUserFor` (default: the stack of a greenfield project, an ambiguous
|
|
95
|
+
product scope, conflicting business rules, a protected action, a task that still fails after the
|
|
96
|
+
coordinator took it over). Ask once, with options and your recommendation, and keep working on
|
|
97
|
+
everything that does not depend on the answer.
|
|
213
98
|
|
|
214
99
|
---
|
|
215
100
|
|
|
216
|
-
##
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
Turn every task into a verifiable goal before starting: "add validation" becomes "write tests for
|
|
246
|
-
invalid inputs, then make them pass". State a short plan with a verification step per item. Strong
|
|
247
|
-
success criteria are what let a worker run unsupervised — weak ones ("make it work") guarantee
|
|
248
|
-
rework.
|
|
249
|
-
|
|
250
|
-
### 6.5 The spec is the request
|
|
251
|
-
|
|
252
|
-
A PRD, TechSpec, or task file is a contract, not a suggestion. Every feature, bullet, and numbered
|
|
253
|
-
item gets implemented. Never silently drop, defer, merge, or "phase" items; if one looks
|
|
254
|
-
unnecessary, surface it and ask before skipping. Ambiguity is a question, not a licence to omit.
|
|
255
|
-
|
|
256
|
-
Before declaring a multi-item task done, enumerate every item and its status:
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
- [Item 1] -> done
|
|
260
|
-
- [Item 2] -> partial - what is missing and why
|
|
261
|
-
- [Item 3] -> skipped - reason, surfaced earlier
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
Never claim completion while items are missing.
|
|
265
|
-
|
|
266
|
-
### 6.6 Language
|
|
267
|
-
|
|
268
|
-
- **English:** source code, identifiers, comments, commit messages, PR descriptions, `CLAUDE.md`,
|
|
269
|
-
`AGENTS.md`.
|
|
270
|
-
- **Portuguese:** `.claude/commands/`, `.claude/templates/`, `.claude/rules/`, and every generated
|
|
271
|
-
process document (`prd.md`, `techspec.md`, `tasks.md`, `*_task.md`, `bugs.md`).
|
|
272
|
-
- Conversation with the user follows the user's language.
|
|
273
|
-
|
|
274
|
-
### 6.7 Comments
|
|
275
|
-
|
|
276
|
-
Prefer self-explanatory code. Do not restate what the code does, do not leave TODOs, section
|
|
277
|
-
headers, or "added for X" notes. Comment only when the *why* is non-obvious: a hidden constraint, a
|
|
278
|
-
subtle invariant, a workaround for a specific bug. If a comment is needed to explain *what*,
|
|
279
|
-
refactor instead.
|
|
280
|
-
|
|
281
|
-
### 6.8 Commits
|
|
282
|
-
|
|
283
|
-
- [Conventional Commits](https://www.conventionalcommits.org/): `type(scope): subject` — `feat`,
|
|
284
|
-
`fix`, `docs`, `refactor`, `chore`, `test`, `style`, `perf`, `build`, `ci`.
|
|
285
|
-
- Subject in imperative mood, lowercase, no trailing period.
|
|
286
|
-
- **Never add `Co-Authored-By:` trailers or any assistant attribution.** This overrides any default
|
|
287
|
-
attribution instruction.
|
|
288
|
-
- Workers never commit. Claude commits only when the user explicitly asks.
|
|
289
|
-
|
|
290
|
-
### 6.9 Code quality metrics
|
|
291
|
-
|
|
292
|
-
Bias new and changed code toward the healthy end of each signal:
|
|
293
|
-
|
|
294
|
-
- **Cyclomatic complexity** — keep functions well under the analyzer's ceiling (a common one is
|
|
295
|
-
~10–15 paths). Split rather than raise the cap.
|
|
296
|
-
- **Module size** — small, focused modules over god-objects; low function length, parameter count,
|
|
297
|
-
and nesting depth.
|
|
298
|
-
- **Dependency structure** — dependencies point from volatile/concrete toward stable/abstract, and
|
|
299
|
-
never cycle.
|
|
300
|
-
- **Test coverage** — cover the branches and edge cases that can break, not just the happy path.
|
|
301
|
-
- **Mutation mindset** — write assertions that would fail if the logic were subtly wrong (`>` to
|
|
302
|
-
`>=`, a flipped sign, a deleted line), not tests that pass regardless of behavior.
|
|
303
|
-
|
|
304
|
-
Enforce with whatever tooling the chosen stack provides, configured in the project rather than
|
|
305
|
-
tracked by hand.
|
|
101
|
+
## 3. The autonomous loop
|
|
102
|
+
|
|
103
|
+
`/executar-workflow <objective>` runs these steps. State lives in `agent-kit wf`
|
|
104
|
+
(`.agent-kit/runs/<run>/`), so any step can be resumed.
|
|
105
|
+
|
|
106
|
+
1. **Understand** — read `AGENTS.md`, `docs/adr/`, `CONTEXT.md`, existing `tasks/`, the code the
|
|
107
|
+
objective touches. Identify stack, conventions and constraints.
|
|
108
|
+
2. **Spec (pm)** — `/criar-prd` in autonomous mode; assumptions go to
|
|
109
|
+
`tasks/prd-<slug>/assumptions.md`.
|
|
110
|
+
3. **Plan (architect)** — `/criar-techspec`, then `/criar-tasks` (writes `tasks.md`,
|
|
111
|
+
`itemized-tasks/*` and `plan.json`: owned files, dependencies, tags, acceptance criteria,
|
|
112
|
+
validation commands), then `agent-kit validate --plan tasks/prd-<slug>/plan.json` and
|
|
113
|
+
`/analisar-consistencia`. Fix Blocker/High findings before dispatching.
|
|
114
|
+
4. **Start** — `agent-kit wf new <run> --plan tasks/prd-<slug>/plan.json --objective "<objective>"`.
|
|
115
|
+
5. **Loop** until `agent-kit wf next <run>` has nothing left:
|
|
116
|
+
- `dispatch` → `agent-kit wf dispatch <run> <task>` and run the printed call (runtime guide);
|
|
117
|
+
- a worker finished → `agent-kit wf report` → `agent-kit wf verify <run> <task>`;
|
|
118
|
+
- `awaitingReview[].ready` gates → `agent-kit wf gate <run> <task> <gate>` and run the printed call
|
|
119
|
+
(gates of one task run in parallel; they never edit files) → `agent-kit wf review … --gate <gate>
|
|
120
|
+
--file <answer>`;
|
|
121
|
+
- follow each command's `next`: `redispatch` (fix attempt — the brief carries the findings),
|
|
122
|
+
`gates`, `resolve-blocker`, `coordinator-takeover`, `ask-user`.
|
|
123
|
+
6. **Integrate** — when nothing is running: `agent-kit wf verify <run> --final` and a coordinator
|
|
124
|
+
review of the whole diff.
|
|
125
|
+
7. **Close** — `agent-kit wf complete <run>` (refuses while a criterion is unmet and lists what is
|
|
126
|
+
missing), `/fechar-ciclo`, then the final report (section 9). Release is not part of the loop.
|
|
127
|
+
|
|
128
|
+
Never end a run silently: if you stop, `agent-kit wf status <run>` must explain why.
|
|
306
129
|
|
|
307
130
|
---
|
|
308
131
|
|
|
309
|
-
##
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
##
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
132
|
+
## 4. Delegation
|
|
133
|
+
|
|
134
|
+
- Briefs are generated by `agent-kit wf dispatch` / `wf gate`, never improvised. They inline the task
|
|
135
|
+
document and the plan's `context` files, dependency results, owned and forbidden files,
|
|
136
|
+
acceptance criteria, validation commands, forbidden actions and the report protocol, and are
|
|
137
|
+
stored with their hash under `.agent-kit/runs/<run>/briefs/`.
|
|
138
|
+
- An agent receives **only** its brief. Anything it needs from this conversation must be in the plan
|
|
139
|
+
or in a task document.
|
|
140
|
+
- When parallel tasks meet at an interface, the techspec fixes the contract in writing (route,
|
|
141
|
+
method, status, body field by field; signatures; event names).
|
|
142
|
+
- When tests share a database, port or other singleton, either the task document says how they are
|
|
143
|
+
serialized or the tasks are not parallel.
|
|
144
|
+
|
|
145
|
+
## 5. Parallelism
|
|
146
|
+
|
|
147
|
+
`wf next` only offers a task when its dependencies are completed, a slot is free (`maxWorkers`), and
|
|
148
|
+
none of its files overlap a task that is running, testing or in review. Overlap is computed
|
|
149
|
+
conservatively from the plan's file patterns. Plan small, file-disjoint slices to get parallelism;
|
|
150
|
+
set `maxWorkers: 1` for strictly one slice at a time.
|
|
151
|
+
|
|
152
|
+
## 6. Verification, gates and fixes
|
|
153
|
+
|
|
154
|
+
1. `agent-kit wf verify <run> <task>` runs the task's validation commands in the coordinator's
|
|
155
|
+
process and records real exit codes. A failure becomes a fix attempt automatically.
|
|
156
|
+
2. Gates (`/executar-review`) are recorded per gate. A gate's reviewer must not be the implementer;
|
|
157
|
+
the CLI refuses it. When a gate's profile is `coordinator`, you run the gate yourself.
|
|
158
|
+
3. On a rejection or failed checks, **diagnose the root cause** before the redispatch: write it in
|
|
159
|
+
`tasks/prd-<slug>/bugs.md` (`.claude/templates/bugs-template.md`). The next brief carries the
|
|
160
|
+
findings; gates run again from scratch on the new attempt.
|
|
161
|
+
4. Security-sensitive fixes and architecture changes are diagnosed *and* applied by the coordinator.
|
|
162
|
+
|
|
163
|
+
## 7. Failure handling and recovery
|
|
164
|
+
|
|
165
|
+
Budgets come from `autonomy.json`: `maxAttemptsPerTask`, `maxFixCycles`, `taskTimeoutMinutes`,
|
|
166
|
+
`retry` (`escalate-profile` moves `fast → standard → advanced`). An exhausted budget makes the task
|
|
167
|
+
`failed` and the run `blocked`; then `escalation.onBudgetExhausted` decides:
|
|
168
|
+
`coordinator-takeover` (`agent-kit wf takeover <run> <task>`, implement it yourself from the
|
|
169
|
+
generated brief, then report, verify and pass the gates like any attempt — a takeover that fails
|
|
170
|
+
again goes to the user), `ask-user`, or `fail`.
|
|
171
|
+
|
|
172
|
+
A worker that reports `blocked` lists its blockers: resolve them and
|
|
173
|
+
`agent-kit wf unblock <run> <task> --resolution "<what changed>"`.
|
|
174
|
+
|
|
175
|
+
A timeout is not proof of death: check the runtime first (runtime guide, "Overdue"). After any
|
|
176
|
+
interruption, run `/retomar-workflow`: it reconciles every in-flight attempt and gate with the
|
|
177
|
+
runtime before anything is redispatched.
|
|
178
|
+
|
|
179
|
+
## 8. Tracker
|
|
180
|
+
|
|
181
|
+
`tracker.kind` in `.agent-kit/config.json`:
|
|
182
|
+
|
|
183
|
+
- `local`: state only in `.agent-kit/runs/`.
|
|
184
|
+
- `linear`: the plan is mirrored as a parent issue plus one issue per task; each transition updates
|
|
185
|
+
the issue state and comments the reason. Task state stays owned by `agent-kit wf`, never by a
|
|
186
|
+
runtime, so one backlog serves T3 and Orca sessions alike.
|
|
187
|
+
- `via: "t3"` (default on T3): through T3's issue tools, no API key — the CLI prints the calls and
|
|
188
|
+
you acknowledge them (runtime guide, "Linear through T3").
|
|
189
|
+
- `via: "api"`: through Linear's API with a personal key; real sub-issues and `blocks` relations,
|
|
190
|
+
automatic sync, and runs can start from Linear (`wf new <run> --from-linear <ISSUE-ID>`).
|
|
191
|
+
Tracker failures never stop a run: events stay queued until `agent-kit wf sync <run>` delivers them.
|
|
192
|
+
|
|
193
|
+
## 9. Definition of done and final report
|
|
194
|
+
|
|
195
|
+
`agent-kit wf complete <run>` passes only when the configured criteria hold (all tasks completed or
|
|
196
|
+
cancelled, final checks passed after the last change, every applicable gate approved by someone
|
|
197
|
+
other than the implementer). Then report:
|
|
198
|
+
|
|
199
|
+
1. what was built, per task, with its state and gate verdicts;
|
|
200
|
+
2. checks executed and their real results; checks that could not run and why;
|
|
201
|
+
3. assumptions and autonomous decisions;
|
|
202
|
+
4. what remains, known limitations, and anything that needs a protected action or a credential —
|
|
203
|
+
including the release, which waits for the user's order.
|
|
204
|
+
|
|
205
|
+
## 10. Maintaining this file
|
|
206
|
+
|
|
207
|
+
Role-specific instructions only. Anything every agent needs goes in `AGENTS.md`; the worker
|
|
208
|
+
contract in `docs/agents/worker.md`; runtime mechanics in `.agent-kit/runtime/`; the pipeline in
|
|
209
|
+
`.agent-kit/workflow.json`.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Claude Code PreToolUse hook generated by agent-kit. It asks for (or denies) approval before a
|
|
2
|
+
// protected action, using the policy in .agent-kit/autonomy.json. Everything else passes through.
|
|
3
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
4
|
+
import { join, relative, isAbsolute } from "node:path";
|
|
5
|
+
import { classifyCommand, classifyWrite } from "./policy.mjs";
|
|
6
|
+
|
|
7
|
+
function readStdin() {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(readFileSync(0, "utf8"));
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function loadAutonomy(root) {
|
|
16
|
+
const path = join(root, ".agent-kit", "autonomy.json");
|
|
17
|
+
if (!existsSync(path)) return {};
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
20
|
+
} catch {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function verdictFor(input, autonomy, root) {
|
|
26
|
+
const tool = input.tool_name;
|
|
27
|
+
const args = input.tool_input || {};
|
|
28
|
+
if (tool === "Bash" || tool === "PowerShell") return classifyCommand(args.command, autonomy);
|
|
29
|
+
if (["Write", "Edit", "MultiEdit", "NotebookEdit"].includes(tool)) {
|
|
30
|
+
const target = args.file_path || args.notebook_path;
|
|
31
|
+
if (!target) return { decision: "allow" };
|
|
32
|
+
const path = isAbsolute(target) ? relative(root, target) : target;
|
|
33
|
+
return classifyWrite(path, autonomy);
|
|
34
|
+
}
|
|
35
|
+
return { decision: "allow" };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const input = readStdin();
|
|
39
|
+
if (input) {
|
|
40
|
+
const root = process.env.CLAUDE_PROJECT_DIR || input.cwd || process.cwd();
|
|
41
|
+
const verdict = verdictFor(input, loadAutonomy(root), root);
|
|
42
|
+
if (verdict.decision !== "allow") {
|
|
43
|
+
process.stdout.write(
|
|
44
|
+
JSON.stringify({
|
|
45
|
+
hookSpecificOutput: {
|
|
46
|
+
hookEventName: "PreToolUse",
|
|
47
|
+
permissionDecision: verdict.decision,
|
|
48
|
+
permissionDecisionReason: `agent-kit protected action (${verdict.category}): ${verdict.reason}. Needs explicit human approval.`,
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Claude Code SessionStart hook generated by agent-kit. Prints a short summary of unfinished
|
|
2
|
+
// workflow runs so the coordinator resumes them instead of starting over. Silent when there are none.
|
|
3
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
const root = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
7
|
+
const runsDir = join(root, ".agent-kit", "runs");
|
|
8
|
+
|
|
9
|
+
function activeRuns() {
|
|
10
|
+
if (!existsSync(runsDir)) return [];
|
|
11
|
+
const runs = [];
|
|
12
|
+
for (const entry of readdirSync(runsDir, { withFileTypes: true })) {
|
|
13
|
+
const file = join(runsDir, entry.name, "run.json");
|
|
14
|
+
if (!entry.isDirectory() || !existsSync(file)) continue;
|
|
15
|
+
try {
|
|
16
|
+
const run = JSON.parse(readFileSync(file, "utf8"));
|
|
17
|
+
if (["completed", "cancelled"].includes(run.state)) continue;
|
|
18
|
+
const counts = {};
|
|
19
|
+
for (const task of Object.values(run.tasks || {})) counts[task.state] = (counts[task.state] || 0) + 1;
|
|
20
|
+
runs.push({ id: run.id, state: run.state, objective: run.objective, counts });
|
|
21
|
+
} catch {
|
|
22
|
+
runs.push({ id: entry.name, state: "unreadable", objective: "", counts: {} });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return runs;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const runs = activeRuns();
|
|
29
|
+
if (runs.length) {
|
|
30
|
+
const lines = runs.map((run) => {
|
|
31
|
+
const counts = Object.entries(run.counts).map(([state, count]) => `${count} ${state}`).join(", ");
|
|
32
|
+
return `- ${run.id} (${run.state}): ${run.objective || "no objective"} — ${counts}`;
|
|
33
|
+
});
|
|
34
|
+
process.stdout.write(
|
|
35
|
+
[
|
|
36
|
+
"agent-kit: unfinished workflow runs in this repository:",
|
|
37
|
+
...lines,
|
|
38
|
+
"Resume with /retomar-workflow (it reconciles in-flight workers before redispatching) or check /status-workflow.",
|
|
39
|
+
].join("\n") + "\n"
|
|
40
|
+
);
|
|
41
|
+
}
|