@guilhermednobre/agent-kit 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/CHANGELOG.md +49 -0
- package/README.md +102 -76
- package/bin/cli.js +78 -39
- package/package.json +11 -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 +17 -6
- package/templates/CLAUDE.md +184 -159
- 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 +9 -0
- package/templates/claude/commands/configurar-worker.md +93 -62
- package/templates/claude/commands/criar-prd.md +15 -0
- package/templates/claude/commands/criar-tasks.md +31 -0
- package/templates/claude/commands/criar-techspec.md +11 -0
- package/templates/claude/commands/executar-bugfix.md +8 -8
- package/templates/claude/commands/executar-qa.md +11 -13
- package/templates/claude/commands/executar-release.md +20 -0
- package/templates/claude/commands/executar-review.md +37 -31
- package/templates/claude/commands/executar-task.md +13 -22
- package/templates/claude/commands/executar-workflow.md +101 -0
- package/templates/claude/commands/fechar-ciclo.md +9 -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/settings.json +25 -0
- package/templates/claude/templates/plan-template.json +33 -0
- package/templates/claude/templates/task-template.md +5 -5
- package/templates/claude/templates/worker-brief-template.md +8 -6
- package/templates/docs/agents/worker.md +64 -45
package/templates/CLAUDE.md
CHANGED
|
@@ -1,184 +1,209 @@
|
|
|
1
1
|
@AGENTS.md
|
|
2
|
+
@.agent-kit/runtime/{{RUNTIME}}.md
|
|
2
3
|
|
|
3
4
|
# CLAUDE.md
|
|
4
5
|
|
|
5
|
-
Claude's role in this repository: the **
|
|
6
|
-
|
|
7
|
-
|
|
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.
|
|
8
11
|
|
|
9
12
|
<!--WORKER-SETUP-->
|
|
10
|
-
> **First session: the
|
|
11
|
-
> `/configurar-worker`. It
|
|
12
|
-
>
|
|
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.
|
|
13
17
|
<!--/WORKER-SETUP-->
|
|
14
18
|
|
|
15
|
-
## 1. Roles
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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"`).
|
|
48
|
+
|
|
49
|
+
### Commands
|
|
50
|
+
|
|
51
|
+
| Command | When |
|
|
52
|
+
|---|---|
|
|
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 |
|
|
48
63
|
|
|
49
64
|
---
|
|
50
65
|
|
|
51
|
-
## 2.
|
|
52
|
-
|
|
53
|
-
<!--WORKER-RECIPE-->
|
|
54
|
-
**Not configured.** Run `/configurar-worker`.
|
|
55
|
-
<!--/WORKER-RECIPE-->
|
|
66
|
+
## 2. Autonomy
|
|
56
67
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# 0. Once per session - create the Run
|
|
62
|
-
orca orchestration run-create --objective "<objective>" --json
|
|
68
|
+
Policy lives in `.agent-kit/autonomy.json`; `agent-kit validate` checks it. With `level:
|
|
69
|
+
"autonomous"` (default) **do not ask the user** to:
|
|
63
70
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
67
77
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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:
|
|
71
82
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# 4. Task + dispatch - never pass --inject
|
|
76
|
-
orca orchestration task-create --spec "$(cat <brief-file>)" --json
|
|
77
|
-
orca orchestration dispatch --task <task_id> --to <handle> --return-preamble --json
|
|
78
|
-
# write result.preamble to a file; it carries the real dispatch id
|
|
79
|
-
|
|
80
|
-
# 5. Deliver by file reference, not by pasting a long brief into the TUI
|
|
81
|
-
orca terminal send --terminal <handle> \
|
|
82
|
-
--text "Read the file <abs-path-to-preamble> in full, then follow it exactly." --enter --json
|
|
83
|
+
```bash
|
|
84
|
+
agent-kit policy check -- <command> # exit 0 allowed, exit 3 needs approval
|
|
85
|
+
agent-kit policy check --path <file>
|
|
83
86
|
```
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
### Supervising
|
|
89
|
-
|
|
90
|
-
The Orca notification ("You have 1 orchestration message") reaches the user, not Claude. Do not
|
|
91
|
-
rely on it, and do not leave a worker running unwatched:
|
|
92
|
-
|
|
93
|
-
- After every dispatch, arm a background **Monitor** that polls
|
|
94
|
-
`orca orchestration check --run <run> --json` every 30 s. It acknowledges batches that hold only
|
|
95
|
-
heartbeats (`check --run <run> --ack <delivery_id>`) and exits **without** acknowledging when a
|
|
96
|
-
`worker_done`, `question` or `escalation` arrives, so Claude reads it next. Re-arm it on timeout.
|
|
97
|
-
- Prefer it over a long `check --wait`: an unacknowledged message is replayed, and a background
|
|
98
|
-
`--wait` can be killed under memory pressure.
|
|
99
|
-
- If the Orca runtime drops, the `worker_done` may be lost. Detect the end from the worker's own
|
|
100
|
-
report (the worker block in `bugs.md`, the files on disk), review, and close the task with
|
|
101
|
-
`orca orchestration task-update`.
|
|
102
|
-
- After a reboot, Orca may restore old worker terminals: close them before relaunching.
|
|
103
|
-
|
|
104
|
-
### Worktrees
|
|
105
|
-
|
|
106
|
-
- A new Orca worktree branches from `origin/main`: **push** what the worker needs before
|
|
107
|
-
dispatching, or it will not be there.
|
|
108
|
-
- `orca worktree rm` deletes the local branch. Note its SHA, and commit reviewed work first.
|
|
109
|
-
- From Git Bash, prefix `MSYS_NO_PATHCONV=1` when sending slash-prefixed text or POSIX paths, or
|
|
110
|
-
they get rewritten into `C:/Program Files/Git/...`.
|
|
111
|
-
|
|
112
|
-
### Worker brief
|
|
113
|
-
|
|
114
|
-
Every brief uses `.claude/templates/worker-brief-template.md` and states objective, context,
|
|
115
|
-
constraints, files involved, acceptance criteria, and the exact validation to run. When two workers
|
|
116
|
-
run in parallel and one consumes what the other produces, the brief **fixes the contract in
|
|
117
|
-
writing**: route, method, status code and response body field by field. When tests share a
|
|
118
|
-
database, Redis index or fixed port, the brief names the directory lock that serializes them.
|
|
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.
|
|
119
90
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
## 3. Parallel work
|
|
123
|
-
|
|
124
|
-
Open a separate worktree and worker per task **only** when tasks are genuinely independent: no
|
|
125
|
-
dependency between them and no overlapping files.
|
|
91
|
+
### When to ask the user
|
|
126
92
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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.
|
|
131
98
|
|
|
132
99
|
---
|
|
133
100
|
|
|
134
|
-
##
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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.
|
|
150
129
|
|
|
151
130
|
---
|
|
152
131
|
|
|
153
|
-
##
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Runtime: Orca (legacy)
|
|
2
|
+
|
|
3
|
+
How the coordinator runs workers on **Orca**. Imported by `CLAUDE.md`. The workflow rules come from
|
|
4
|
+
`agent-kit wf`; this file only maps each step onto Orca commands. T3 Code is the recommended
|
|
5
|
+
runtime; Orca stays supported for existing setups.
|
|
6
|
+
|
|
7
|
+
## Worker recipe
|
|
8
|
+
|
|
9
|
+
<!--WORKER-RECIPE-->
|
|
10
|
+
**Not configured.** Run `/configurar-worker`.
|
|
11
|
+
<!--/WORKER-RECIPE-->
|
|
12
|
+
|
|
13
|
+
`/configurar-worker` also writes `runtimes.orca.launchCommand` (with an optional `{model}`
|
|
14
|
+
placeholder) and `runtimes.orca.readiness` into `.agent-kit/config.json`.
|
|
15
|
+
|
|
16
|
+
## Dispatch
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
agent-kit wf next <run>
|
|
20
|
+
agent-kit wf dispatch <run> <task> # prints { call: { kind: "shell", commands: [...] } }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Run the printed commands in order (run-create once per run; a worktree only when parallelizing),
|
|
24
|
+
then record the terminal handle and Orca task id:
|
|
25
|
+
`agent-kit wf started <run> <task> --ref "<handle>|<task_id>"`.
|
|
26
|
+
|
|
27
|
+
- Never pass `--inject`. Deliver the preamble by file reference, not by pasting a long brief.
|
|
28
|
+
- Do not use `orca orchestration worker-start`: a failed start marks the task `failed` and forces a
|
|
29
|
+
new task row.
|
|
30
|
+
- When the task has a Linear issue (tracker `linear`), the worktree command carries
|
|
31
|
+
`--linear-issue`, so Orca shows the same issue the tracker updates.
|
|
32
|
+
|
|
33
|
+
## Supervising
|
|
34
|
+
|
|
35
|
+
The Orca notification reaches the user, not Claude. After every dispatch, arm a background
|
|
36
|
+
**Monitor** that polls `orca orchestration check --run <run> --json` every 30 s. It acknowledges
|
|
37
|
+
batches that hold only heartbeats (`check --run <run> --ack <delivery_id>`) and exits **without**
|
|
38
|
+
acknowledging when a `worker_done`, `question` or `escalation` arrives. Re-arm it on timeout.
|
|
39
|
+
|
|
40
|
+
On `worker_done`: save its body (it carries the `agent-kit-report` block) to
|
|
41
|
+
`.agent-kit/runs/<run>/inbox/<task>.md` and run
|
|
42
|
+
`agent-kit wf report <run> <task> --file .agent-kit/runs/<run>/inbox/<task>.md`.
|
|
43
|
+
|
|
44
|
+
On `question`: answer it if the answer is inferable and reversible; otherwise follow the
|
|
45
|
+
escalation rules in `CLAUDE.md`. On `escalation`: record it as a blocked report.
|
|
46
|
+
|
|
47
|
+
If the Orca runtime drops, the `worker_done` may be lost. Detect the end from the files on disk and
|
|
48
|
+
the worker's terminal (`orca terminal read`), then record the report or `wf lost`.
|
|
49
|
+
|
|
50
|
+
## Closing workers
|
|
51
|
+
|
|
52
|
+
Close a worker only after its review is recorded: `orca terminal close --terminal <handle> --tab --json`
|
|
53
|
+
(`agent-kit wf cancel` prints this for cancelled tasks). Never close one on a timeout, a heartbeat or
|
|
54
|
+
an unreviewed `worker_done`. After a reboot, Orca may restore old worker terminals: close them
|
|
55
|
+
before relaunching.
|
|
56
|
+
|
|
57
|
+
## Worktrees
|
|
58
|
+
|
|
59
|
+
- A new Orca worktree branches from `origin/main`: what the worker needs must be pushed first —
|
|
60
|
+
which is a protected action unless `autonomy.permissions.push` is true. Prefer the current
|
|
61
|
+
worktree when pushing is not allowed.
|
|
62
|
+
- `orca worktree rm` deletes the local branch. Note its SHA, and commit reviewed work first.
|
|
63
|
+
- From Git Bash, prefix `MSYS_NO_PATHCONV=1` when sending slash-prefixed text or POSIX paths.
|
|
64
|
+
|
|
65
|
+
## Progress visibility
|
|
66
|
+
|
|
67
|
+
Update the worktree comment at checkpoints:
|
|
68
|
+
`orca worktree set --worktree <selector> --comment "<short current state>" --json`.
|