@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.
Files changed (51) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +102 -76
  3. package/bin/cli.js +78 -39
  4. package/package.json +11 -4
  5. package/src/cli/tools.js +51 -0
  6. package/src/cli/wf.js +400 -0
  7. package/src/core/briefing.js +188 -0
  8. package/src/core/config.js +321 -0
  9. package/src/core/dag.js +103 -0
  10. package/src/core/engine.js +505 -0
  11. package/src/core/policy.js +145 -0
  12. package/src/core/report.js +104 -0
  13. package/src/core/states.js +59 -0
  14. package/src/core/store.js +60 -0
  15. package/src/core/verify.js +54 -0
  16. package/src/detect.js +6 -0
  17. package/src/generate.js +55 -0
  18. package/src/install.js +22 -14
  19. package/src/render.js +5 -7
  20. package/src/runtimes/index.js +24 -0
  21. package/src/runtimes/orca.js +61 -0
  22. package/src/runtimes/t3.js +87 -0
  23. package/src/trackers/index.js +34 -0
  24. package/src/trackers/linear-t3.js +138 -0
  25. package/src/trackers/linear.js +209 -0
  26. package/templates/AGENTS.md +17 -6
  27. package/templates/CLAUDE.md +184 -159
  28. package/templates/agent-kit/hooks/pretooluse.mjs +53 -0
  29. package/templates/agent-kit/hooks/session-context.mjs +41 -0
  30. package/templates/agent-kit/runtime/orca.md +68 -0
  31. package/templates/agent-kit/runtime/t3.md +109 -0
  32. package/templates/claude/commands/analisar-consistencia.md +9 -0
  33. package/templates/claude/commands/configurar-worker.md +93 -62
  34. package/templates/claude/commands/criar-prd.md +15 -0
  35. package/templates/claude/commands/criar-tasks.md +31 -0
  36. package/templates/claude/commands/criar-techspec.md +11 -0
  37. package/templates/claude/commands/executar-bugfix.md +8 -8
  38. package/templates/claude/commands/executar-qa.md +11 -13
  39. package/templates/claude/commands/executar-release.md +20 -0
  40. package/templates/claude/commands/executar-review.md +37 -31
  41. package/templates/claude/commands/executar-task.md +13 -22
  42. package/templates/claude/commands/executar-workflow.md +101 -0
  43. package/templates/claude/commands/fechar-ciclo.md +9 -0
  44. package/templates/claude/commands/replanejar-workflow.md +32 -0
  45. package/templates/claude/commands/retomar-workflow.md +30 -0
  46. package/templates/claude/commands/status-workflow.md +19 -0
  47. package/templates/claude/settings.json +25 -0
  48. package/templates/claude/templates/plan-template.json +33 -0
  49. package/templates/claude/templates/task-template.md +5 -5
  50. package/templates/claude/templates/worker-brief-template.md +8 -6
  51. package/templates/docs/agents/worker.md +64 -45
package/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 — unreleased
4
+
5
+ ### Added
6
+
7
+ - Runtime-independent core (`src/core`): configuration and plan validation, task/workflow state
8
+ machine with history, DAG scheduler (dependencies, waves, `maxWorkers`, file ownership),
9
+ retry/escalation, coordinator takeover, blocked/unblock, replan, resume, completion criteria.
10
+ - `agent-kit wf` — the coordinator's workflow CLI: `new`, `next`, `dispatch`, `started`, `touch`,
11
+ `report`, `verify` (task and `--final`), `gate`, `review`, `lost`, `takeover`, `unblock`,
12
+ `cancel`, `replan`, `status`, `resume`, `complete`, `sync`, `list`.
13
+ - Self-contained, hashed briefs for implementers and validators.
14
+ - Worker and validator report protocols (`agent-kit-report`, `agent-kit-review`).
15
+ - Role pipeline (`.agent-kit/workflow.json`): PM → architect → dev → QA / system / UI/UX / security
16
+ gates → product owner → release on demand. Reviewer independence enforced.
17
+ - Model profiles per role (`fast`, `standard`, `advanced`, `validator`, `coordinator`).
18
+ - Runtime adapters: **T3 Code** (default; `delegate_task` calls with retry keys) and Orca (legacy
19
+ recipe), plus `registerAdapter` for new runtimes.
20
+ - Linear tracker, two ways: **through T3** (`via: "t3"`, default on T3 — no API key; the CLI prints
21
+ `create_issue` / `set_issue_state` / `comment_on_issue` calls, `wf tracker-bind` and
22
+ `wf sync --ack` close the loop; tested live) and **through the API** (`via: "api"` — sub-issues,
23
+ `blocks` relations, automatic sync, import with `wf new --from-linear`). Failures queue instead
24
+ of blocking.
25
+ - Autonomy policy (`.agent-kit/autonomy.json`) with protected-action categories, write protection,
26
+ `agent-kit policy check`, and a Claude Code PreToolUse hook enforcing it; SessionStart hook that
27
+ surfaces unfinished runs.
28
+ - Commands `/executar-workflow`, `/status-workflow`, `/retomar-workflow`, `/replanejar-workflow`,
29
+ `/executar-release`; autonomous mode in the planning commands; `plan.json` output in
30
+ `/criar-tasks`.
31
+ - `init --runtime t3|orca`, `--tracker local|linear`, `--linear-team`; `.agent-kit/` generation with
32
+ checks derived from the detected commands; Node `typecheck` detection.
33
+ - `agent-kit validate`, `agent-kit runtimes`.
34
+ - Docs: audit, architecture, autonomy, T3 runtime (with the real integration run), Linear,
35
+ migration.
36
+
37
+ ### Changed
38
+
39
+ - `CLAUDE.md` is runtime-neutral and imports `.agent-kit/runtime/<runtime>.md`; the Orca recipe
40
+ moved there.
41
+ - `docs/agents/worker.md` covers implementers and validators and the new report protocol.
42
+ - `/executar-review` became the gate command; `/executar-task` and `/executar-bugfix` no longer
43
+ depend on Orca; `/configurar-worker` configures profiles from the runtime's live catalogue.
44
+ - The template guard test now forbids model ids everywhere and tool names outside runtime-specific
45
+ files.
46
+
47
+ ## 0.2.0
48
+
49
+ - First session chooses the worker agent; shared, orchestrator and worker contracts split.
package/README.md CHANGED
@@ -1,104 +1,128 @@
1
1
  # @guilhermednobre/agent-kit
2
2
 
3
- Scaffolds a multi-agent development workflow into any repository: **Claude orchestrates, a worker
4
- agent of your choice implements**, supervised through Orca orchestration.
3
+ An autonomous, multi-agent development workflow for any repository. **Claude Opus coordinates;
4
+ secondary agents (Gemini via Antigravity by default) implement and validate**, on T3 Code or Orca,
5
+ with tasks tracked locally or in Linear.
5
6
 
6
7
  ```bash
7
8
  npx @guilhermednobre/agent-kit init
8
9
  ```
9
10
 
10
- Installed globally, the command is just `agent-kit`.
11
+ Give the coordinator an objective — *"Implement authentication with sign-up, login, password
12
+ recovery, tests and docs"* — and `/executar-workflow` takes it from spec to an accepted,
13
+ independently verified result, asking you only for decisions it cannot safely infer and for
14
+ protected actions (deploys, publishing, pushes, data deletion, credentials).
11
15
 
12
- ## What it writes
16
+ ## The pipeline
13
17
 
14
- | Path | Purpose |
15
- |---|---|
16
- | `AGENTS.md` | Shared contract for every agent and tool: project, stack, commands, engineering rules. Read natively by Claude Code, opencode, Codex and others |
17
- | `CLAUDE.md` | Imports `AGENTS.md` (`@AGENTS.md`) and adds only the orchestrator role: pipeline, worker launch, supervision, review, bugfix loop |
18
- | `docs/agents/worker.md` | The worker role: what it owns, the `worker_done` protocol, definition of done. Every brief points to it |
19
- | `.claude/commands/` | The pipeline commands (below) |
20
- | `.claude/rules/` | Engineering rules split into always-applicable principles and technology-conditional ones |
21
- | `.claude/templates/` | Document templates for PRD, TechSpec, tasks, bugs and worker briefs |
18
+ | # | Role | Runs on (default) | Output |
19
+ |---|---|---|---|
20
+ | 1 | Product manager | Coordinator (Opus) | Spec — *what* |
21
+ | 2 | Architect | Coordinator (Opus) | TechSpec, contracts, tasks, `plan.json` |
22
+ | 3 | Dev | `standard` / `fast` / `advanced` profiles | One slice per task |
23
+ | 4 | QA · System · UI/UX · Security | `validator` profile, in parallel | Gate verdicts; UI/UX only for `ui` tasks, Security only for `security` tasks |
24
+ | 5 | Product owner | `validator` profile | Last gate: every acceptance criterion |
25
+ | 6 | Release | Coordinator | Only when you order it |
22
26
 
23
- Existing files are never overwritten without `--force` or an explicit confirmation.
27
+ Any rejected gate sends the task back to the dev with the findings. Retries escalate the model
28
+ (`fast → standard → advanced`); an exhausted budget hands the task to the coordinator, then to you.
24
29
 
25
- ### Why three files
30
+ ## What makes it autonomous (and not just prompts)
26
31
 
27
- The orchestrator and the worker get opposite orders ("dispatch and review" against "implement and
28
- stop"). In one file, each reads the other's orders. So the shared part lives in `AGENTS.md`, which
29
- every tool reads, and each role adds only its own file. Nothing is written twice.
32
+ The Markdown contracts tell agents *how* to behave. The `agent-kit` CLI is the coordinator's
33
+ deterministic tool for *what* to do next, and it persists everything:
30
34
 
31
- ## The worker is chosen in the first session
35
+ | Concern | Implemented by |
36
+ |---|---|
37
+ | Dependencies, waves, max workers, file ownership | `agent-kit wf next` (DAG scheduler) |
38
+ | Self-contained, reproducible briefs | `agent-kit wf dispatch` / `wf gate` (stored with a hash) |
39
+ | The exact runtime call | Runtime adapters: T3 `delegate_task` args, or the Orca command recipe |
40
+ | Independent verification | `agent-kit wf verify` runs the checks itself and records exit codes |
41
+ | Gates and reviewer independence | `agent-kit wf review --gate …` refuses the implementer as reviewer |
42
+ | Retry, escalation, fix cycles, timeouts | `.agent-kit/autonomy.json` + the workflow engine |
43
+ | Resume after interruption, no duplicate workers | `agent-kit wf resume` + idempotent `clientRequestId` |
44
+ | Definition of done | `agent-kit wf complete` refuses while a criterion is unmet |
45
+ | Protected actions | `.agent-kit/autonomy.json` + a Claude Code PreToolUse hook |
46
+ | Tracker | Local run files, or Linear issues kept in sync |
47
+
48
+ ## What `init` writes
32
49
 
33
- The kit does not hard-code a worker tool or model. The generated `CLAUDE.md` opens with a notice;
34
- in the first Claude Code session, run `/configurar-worker`. It asks which tool (opencode,
35
- Antigravity, Codex CLI, another Claude Code, or none) and which model and effort level, lists the
36
- models the tool offers, smoke-tests the choice, confirms readiness in a real Orca terminal, and
37
- then writes the launch recipe into `CLAUDE.md` section 2 and removes the notice. Run it again to
38
- switch.
50
+ | Path | Purpose |
51
+ |---|---|
52
+ | `AGENTS.md` | Shared contract for every agent: project, stack, commands, engineering rules |
53
+ | `CLAUDE.md` | Coordinator contract; imports `AGENTS.md` and the runtime guide |
54
+ | `docs/agents/worker.md` | Worker contract (implementers and validators) and the report protocol |
55
+ | `.agent-kit/config.json` | Runtime, tracker, checks, model profiles, role → profile map |
56
+ | `.agent-kit/autonomy.json` | Limits, retry/escalation, permissions, protected actions, completion criteria |
57
+ | `.agent-kit/workflow.json` | Role pipeline and validation gates |
58
+ | `.agent-kit/runtime/<runtime>.md` | How each step maps onto T3 Code or Orca |
59
+ | `.agent-kit/hooks/` | Approval hook and session-context hook (no install needed) |
60
+ | `.claude/settings.json` | Wires the hooks into Claude Code |
61
+ | `.claude/commands/` | Pipeline commands (below) |
62
+ | `.claude/rules/`, `.claude/templates/` | Engineering rules; PRD, TechSpec, tasks, plan, bugs, brief templates |
39
63
 
40
- ## The pipeline
64
+ Existing files are never overwritten without `--force` or an explicit confirmation.
65
+
66
+ ## Commands (in Claude Code)
67
+
68
+ | Command | Purpose |
69
+ |---|---|
70
+ | `/configurar-worker` | First session: pick a model per profile from the runtime's real catalogue, smoke-test, save |
71
+ | `/executar-workflow <objective>` | Full autonomous run |
72
+ | `/status-workflow`, `/retomar-workflow`, `/replanejar-workflow` | Inspect, resume, re-plan |
73
+ | `/executar-release` | Deploy — only on your explicit order |
74
+ | `/avaliar-ideia`, `/criar-prd`, `/criar-techspec`, `/criar-tasks`, `/analisar-consistencia` | Planning steps (interactive when used alone) |
75
+ | `/executar-task`, `/executar-bugfix` | Worker steps |
76
+ | `/executar-review`, `/executar-qa` | Gates |
77
+ | `/fechar-ciclo` | Lessons and changelog |
41
78
 
42
- | Command | Runs on | When |
43
- |---|---|---|
44
- | `/configurar-worker` | Claude | First session, or to switch worker tool or model |
45
- | `/avaliar-ideia` | Claude | Optional: go / clarify / kill verdict before writing a PRD |
46
- | `/criar-prd` | Claude | Clarifying questions with the user |
47
- | `/criar-techspec` | Claude | Architecture decisions |
48
- | `/criar-tasks` | Claude | Decomposition into `itemized-tasks/`, parallelism marking |
49
- | `/analisar-consistencia` | Claude | Cross-checks PRD, TechSpec and Tasks; nothing is dispatched while a Blocker or High finding is open |
50
- | `/executar-task` | worker | Implementation |
51
- | `/executar-review` | Claude | After each `worker_done`; findings ranked Blocker / High / Medium / Low |
52
- | `/executar-bugfix` | worker | Applies a fix Claude diagnosed in `bugs.md` |
53
- | `/executar-qa` | Claude | Browser QA with Playwright MCP |
54
- | `/fechar-ciclo` | Claude | After an approved QA: turns the cycle's lessons into rules, ADRs, memory or templates, and writes the changelog |
55
-
56
- ## Two modes
57
-
58
- `init` inspects the target directory and picks a mode. Override it with `--mode`.
59
-
60
- - **greenfield** — no dependency manifest found. `AGENTS.md` states that the stack is an open user
61
- decision, and forbids every agent from choosing one unilaterally.
62
- - **existing** — a manifest was found (`package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`,
63
- `pom.xml`, `Gemfile`, `composer.json`, `mix.exs`, and others). `AGENTS.md` gets a commands table.
64
- For Node projects it is prefilled from the actual `scripts` and lockfile; anything unknown is
65
- written as `TBD` rather than guessed.
66
-
67
- ## Usage
79
+ ## CLI
68
80
 
69
81
  ```bash
70
- npx @guilhermednobre/agent-kit init [directory]
82
+ npx @guilhermednobre/agent-kit init [dir] [--runtime t3|orca] [--tracker local|linear --linear-team KEY]
83
+ [--mode greenfield|existing] [--name] [--description]
84
+ [--force] [-y] [--dry-run]
85
+ agent-kit validate [--plan tasks/prd-x/plan.json]
86
+ agent-kit policy check -- <command> # exit 3 = needs human approval
87
+ agent-kit policy check --path <file>
88
+ agent-kit runtimes
89
+ agent-kit wf help # the workflow commands the coordinator uses
71
90
  ```
72
91
 
73
- | Option | Effect |
74
- |---|---|
75
- | `--name <name>` | Project name written into `AGENTS.md` |
76
- | `--description <text>` | One-line project description |
77
- | `--mode <mode>` | `greenfield` or `existing`, overriding detection |
78
- | `--force` | Overwrite existing files without asking |
79
- | `-y, --yes` | Non-interactive; skip files that already exist |
80
- | `--dry-run` | Print the plan, write nothing |
81
- | `-h, --help` | Show help |
82
- | `-v, --version` | Show version |
92
+ `init` detects the mode: **greenfield** (no manifest: the stack is the user's decision) or
93
+ **existing** (manifest found; for Node, commands and checks come from the real `scripts` and
94
+ lockfile; anything unknown stays `TBD`).
83
95
 
84
- ## Language
96
+ ## Setup
85
97
 
86
- The contracts (`AGENTS.md`, `CLAUDE.md`, `docs/agents/worker.md`) are in English. The commands,
87
- rules and document templates are in Portuguese, matching the workflow they came from.
98
+ 1. **Node 20+**.
99
+ 2. **Claude Code** with Claude Opus as the coordinator model.
100
+ 3. **T3 Code** (recommended runtime) with the providers you want enabled — e.g. **Antigravity** for
101
+ Gemini workers. `/configurar-worker` reads `orchestrator_capabilities`, so only models your
102
+ account really has are offered. Quotas are real: Google AI Pro does not mean unlimited API use;
103
+ tune `maxWorkers` and use the `fast` profile for cheap work.
104
+ 4. Optional **Linear**: `init --tracker linear`. On T3, connect the project to Linear in T3 and that
105
+ is all — the coordinator reaches Linear through T3's issue tools, no API key. On Orca (or to get
106
+ real sub-issues and import), use the API mode: `--linear-team ENG` and a personal key in
107
+ `LINEAR_API_KEY`. See [docs/linear.md](docs/linear.md).
108
+ 5. Run `npx @guilhermednobre/agent-kit init`, open Claude Code, run `/configurar-worker`, then
109
+ `/executar-workflow <objective>`.
88
110
 
89
- ## Requirements
111
+ Orca stays supported: `init --runtime orca` writes the Orca guide and the legacy terminal recipe.
90
112
 
91
- Node 20+ to run the generator. The workflow assumes Claude Code as orchestrator and Orca for
92
- worktrees and orchestration. The worker can be any CLI agent that runs in a terminal and can call
93
- `orca orchestration send`.
113
+ ## Documentation
94
114
 
95
- ## After generating
115
+ - [docs/architecture.md](docs/architecture.md) — layers, state machine, adapters, how to add a runtime
116
+ - [docs/autonomy.md](docs/autonomy.md) — every setting in `autonomy.json`, approvals, escalation
117
+ - [docs/runtime-t3.md](docs/runtime-t3.md) — T3 Code, Antigravity, model selection, the real integration test
118
+ - [docs/linear.md](docs/linear.md) — Linear as the shared task base for T3 and Orca
119
+ - [docs/migration.md](docs/migration.md) — upgrading a project from 0.2 (Orca-only)
120
+ - [docs/audit.md](docs/audit.md) — the audit of 0.2.0 that motivated this design
121
+
122
+ ## Language
96
123
 
97
- 1. Open Claude Code and run `/configurar-worker`.
98
- 2. Read `AGENTS.md` and fill in anything marked `TBD`.
99
- 3. In `existing` mode, verify the commands table actually runs.
100
- 4. Delete the rule files under `.claude/rules/` that do not match your project, and update
101
- `.claude/rules/README.md`.
124
+ Contracts (`AGENTS.md`, `CLAUDE.md`, `docs/agents/`, runtime guides) are in English. Commands, rules,
125
+ templates and briefs are in Portuguese.
102
126
 
103
127
  ## Development
104
128
 
@@ -106,7 +130,9 @@ worktrees and orchestration. The worker can be any CLI agent that runs in a term
106
130
  npm test
107
131
  ```
108
132
 
109
- Zero runtime dependencies. Tests use the built-in `node:test` runner.
133
+ Zero runtime dependencies. Tests use the built-in `node:test` runner; runtimes and Linear are
134
+ exercised through mocks, and [docs/runtime-t3.md](docs/runtime-t3.md) describes the manual
135
+ integration test against a real T3 session.
110
136
 
111
137
  ## License
112
138
 
package/bin/cli.js CHANGED
@@ -6,6 +6,9 @@ import { fileURLToPath } from "node:url";
6
6
  import { resolve } from "node:path";
7
7
  import { detectProject } from "../src/detect.js";
8
8
  import { planFiles, installFiles } from "../src/install.js";
9
+ import { generatedFiles, normalizeInitChoices } from "../src/generate.js";
10
+ import { runWorkflowCommand } from "../src/cli/wf.js";
11
+ import { runValidate, runPolicy, runRuntimes } from "../src/cli/tools.js";
9
12
 
10
13
  const TEMPLATES_DIR = fileURLToPath(new URL("../templates/", import.meta.url));
11
14
  const PACKAGE_JSON = fileURLToPath(new URL("../package.json", import.meta.url));
@@ -14,6 +17,9 @@ const OPTIONS = {
14
17
  name: { type: "string" },
15
18
  description: { type: "string" },
16
19
  mode: { type: "string" },
20
+ runtime: { type: "string" },
21
+ tracker: { type: "string" },
22
+ "linear-team": { type: "string" },
17
23
  force: { type: "boolean", default: false },
18
24
  yes: { type: "boolean", short: "y", default: false },
19
25
  "dry-run": { type: "boolean", default: false },
@@ -22,45 +28,58 @@ const OPTIONS = {
22
28
  };
23
29
 
24
30
  const HELP = `
25
- agent-kit — scaffolds a Claude-as-orchestrator / worker-agent workflow.
31
+ agent-kit — scaffolds and runs an autonomous coordinator / worker workflow.
26
32
 
27
33
  Usage:
28
- npx @guilhermednobre/agent-kit init [directory]
29
-
30
- Options:
34
+ npx @guilhermednobre/agent-kit init [directory] [options]
35
+ agent-kit wf <command> ... workflow state for the coordinator (agent-kit wf help)
36
+ agent-kit validate [--plan <file>] validate .agent-kit configuration (and a plan)
37
+ agent-kit policy check -- <command> is this command allowed autonomously? (exit 3 = needs approval)
38
+ agent-kit policy check --path <p> is writing this path allowed?
39
+ agent-kit runtimes list runtime adapters
40
+
41
+ Init options:
31
42
  --name <name> Project name written into AGENTS.md
32
43
  --description <text> One-line project description
33
44
  --mode <mode> greenfield | existing (default: auto-detected)
45
+ --runtime <runtime> t3 (default, recommended) | orca (legacy)
46
+ --tracker <tracker> local (default) | linear
47
+ --linear-team <KEY> Linear team key (needed only for Linear through the API, e.g. with Orca)
34
48
  --force Overwrite existing files without asking
35
49
  -y, --yes Non-interactive; skip files that already exist
36
50
  --dry-run Show what would be written, write nothing
37
51
  -h, --help Show this help
38
52
  -v, --version Show version
39
53
 
40
- Writes AGENTS.md, CLAUDE.md, docs/agents/worker.md and
41
- .claude/{commands,rules,templates} into the target directory. The worker
42
- tool and model are chosen in the first Claude session (/configurar-worker). Existing files are never overwritten without --force or a
43
- confirmation.
54
+ Writes AGENTS.md, CLAUDE.md, docs/agents/worker.md, .claude/{commands,rules,templates,settings.json}
55
+ and .agent-kit/ (config, autonomy policy, runtime guide, approval hook). Worker models are chosen
56
+ in the first Claude session (/configurar-worker). Existing files are never overwritten without
57
+ --force or a confirmation.
44
58
  `;
45
59
 
60
+ const SUBCOMMANDS = {
61
+ wf: runWorkflowCommand,
62
+ validate: runValidate,
63
+ policy: runPolicy,
64
+ runtimes: runRuntimes,
65
+ };
66
+
46
67
  async function main() {
47
- const { values, positionals } = parseArgs({
48
- options: OPTIONS,
49
- allowPositionals: true,
50
- });
68
+ const argv = process.argv.slice(2);
69
+ const sub = SUBCOMMANDS[argv[0]];
70
+ if (sub) return sub(argv.slice(1));
51
71
 
52
- if (values.help) return console.log(HELP.trim());
53
- if (values.version) return console.log(await readVersion());
72
+ const { values, positionals } = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });
73
+ if (values.help) return void console.log(HELP.trim());
74
+ if (values.version) return void console.log(await readVersion());
54
75
 
55
- const command = positionals[0];
56
- if (command && command !== "init") {
57
- console.error(`Unknown command: ${command}\n${HELP.trim()}`);
58
- process.exitCode = 1;
59
- return;
76
+ if (positionals[0] && positionals[0] !== "init") {
77
+ console.error(`Unknown command: ${positionals[0]}\n${HELP.trim()}`);
78
+ return 1;
60
79
  }
61
-
62
80
  const targetDir = resolve(positionals[1] || process.cwd());
63
81
  await runInit(targetDir, values);
82
+ return 0;
64
83
  }
65
84
 
66
85
  async function readVersion() {
@@ -71,27 +90,34 @@ async function readVersion() {
71
90
  async function runInit(targetDir, flags) {
72
91
  const detected = await detectProject(targetDir);
73
92
  const mode = resolveMode(flags.mode, detected.mode);
93
+ const choices = normalizeInitChoices(flags);
74
94
  const interactive = !flags.yes && process.stdin.isTTY;
75
95
 
76
96
  console.log(`Target: ${targetDir}`);
77
97
  console.log(`Mode: ${mode}${flags.mode ? " (forced)" : " (detected)"}`);
78
98
  if (detected.manifest) console.log(`Stack: ${detected.stack} (${detected.manifest})`);
99
+ console.log(`Runtime: ${choices.runtime}${choices.runtime === "orca" ? " (legacy)" : ""}`);
100
+ console.log(`Tracker: ${choices.tracker}${choices.linearTeam ? ` (team ${choices.linearTeam})` : ""}`);
79
101
  console.log("");
80
102
 
81
103
  const answers = await collectAnswers({ detected, flags, interactive });
82
- const vars = buildVars(detected, answers);
83
- const files = await planFiles(TEMPLATES_DIR);
104
+ const vars = buildVars(detected, answers, choices);
105
+ const files = [
106
+ ...(await planFiles(TEMPLATES_DIR, { runtime: choices.runtime })),
107
+ ...(await generatedFiles({ detected, answers, choices })),
108
+ ];
84
109
  const resolveConflict = makeConflictResolver(flags, interactive);
85
110
  const results = await installFiles({
86
111
  files,
87
112
  targetDir,
88
113
  mode,
89
114
  vars,
115
+ flags: [`runtime-${choices.runtime}`, `tracker-${choices.tracker}`],
90
116
  resolveConflict,
91
117
  dryRun: flags["dry-run"],
92
118
  });
93
119
 
94
- report(results, flags["dry-run"], mode);
120
+ report(results, flags["dry-run"], mode, choices);
95
121
  }
96
122
 
97
123
  function resolveMode(requested, detected) {
@@ -124,7 +150,7 @@ async function ask(rl, label, fallback) {
124
150
  return answer.trim() || fallback;
125
151
  }
126
152
 
127
- function buildVars(detected, answers) {
153
+ function buildVars(detected, answers, choices) {
128
154
  const commands = detected.commands;
129
155
  return {
130
156
  PROJECT_NAME: answers.name,
@@ -134,7 +160,9 @@ function buildVars(detected, answers) {
134
160
  CMD_BUILD: commands.build,
135
161
  CMD_TEST: commands.test,
136
162
  CMD_LINT: commands.lint,
163
+ CMD_TYPECHECK: commands.typecheck,
137
164
  CMD_TEST_ONE: commands.testOne,
165
+ RUNTIME: choices.runtime,
138
166
  };
139
167
  }
140
168
 
@@ -160,7 +188,7 @@ function decodeChoice(answer) {
160
188
  return "skip";
161
189
  }
162
190
 
163
- function report(results, dryRun, mode) {
191
+ function report(results, dryRun, mode, choices) {
164
192
  const counts = results.reduce((acc, result) => {
165
193
  acc[result.action] = (acc[result.action] || 0) + 1;
166
194
  return acc;
@@ -170,7 +198,7 @@ function report(results, dryRun, mode) {
170
198
  }
171
199
  console.log("");
172
200
  console.log(dryRun ? "Dry run — nothing was written." : summarize(counts));
173
- if (!dryRun) printNextSteps(mode);
201
+ if (!dryRun) printNextSteps(mode, choices);
174
202
  }
175
203
 
176
204
  function summarize(counts) {
@@ -178,20 +206,31 @@ function summarize(counts) {
178
206
  return parts.join(", ");
179
207
  }
180
208
 
181
- function printNextSteps(mode) {
209
+ function printNextSteps(mode, choices) {
210
+ const steps = [
211
+ "Open Claude Code here and run /configurar-worker to choose the worker models per profile.",
212
+ "Read AGENTS.md and fill in anything marked TBD.",
213
+ mode === "existing"
214
+ ? "Verify the commands table in AGENTS.md and the checks in .agent-kit/config.json actually run."
215
+ : "Decide the stack, then update AGENTS.md, the checks in .agent-kit/config.json and .claude/rules/README.md.",
216
+ "Review .agent-kit/autonomy.json (limits, permissions, protected actions).",
217
+ ];
218
+ if (choices.tracker === "linear" && choices.runtime === "t3") {
219
+ steps.push("Connect this project to Linear in T3 Code (Linear is reached through T3's issue tools; no API key needed).");
220
+ } else if (choices.tracker === "linear") {
221
+ steps.push("Export LINEAR_API_KEY (a Linear personal API key) before running workflows.");
222
+ }
223
+ steps.push("Start a full run with /executar-workflow <objective>.");
182
224
  console.log("");
183
225
  console.log("Next steps:");
184
- console.log(" 1. Open Claude Code here and run /configurar-worker to choose the worker agent and model.");
185
- console.log(" 2. Read AGENTS.md and fill in anything marked TBD.");
186
- if (mode === "existing") {
187
- console.log(" 3. Verify the commands table in AGENTS.md actually runs.");
188
- } else {
189
- console.log(" 3. Decide the stack, then update AGENTS.md and .claude/rules/README.md.");
190
- }
191
- console.log(" 4. Drop the rule files under .claude/rules that do not match your project.");
226
+ steps.forEach((step, index) => console.log(` ${index + 1}. ${step}`));
192
227
  }
193
228
 
194
- main().catch((error) => {
195
- console.error(error.message);
196
- process.exitCode = 1;
197
- });
229
+ main()
230
+ .then((code) => {
231
+ if (typeof code === "number") process.exitCode = code;
232
+ })
233
+ .catch((error) => {
234
+ console.error(error.message);
235
+ process.exitCode = 1;
236
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@guilhermednobre/agent-kit",
3
- "version": "0.2.0",
4
- "description": "Scaffolds a Claude-as-orchestrator / worker-agent workflow into any repository",
3
+ "version": "0.3.0",
4
+ "description": "Autonomous multi-agent development workflow: Claude coordinates, secondary agents implement and validate, on T3 Code or Orca",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "agent-kit": "bin/cli.js"
@@ -10,7 +10,8 @@
10
10
  "bin",
11
11
  "src",
12
12
  "templates",
13
- "README.md"
13
+ "README.md",
14
+ "CHANGELOG.md"
14
15
  ],
15
16
  "engines": {
16
17
  "node": ">=20"
@@ -29,7 +30,13 @@
29
30
  "orchestration",
30
31
  "scaffold",
31
32
  "agents-md",
32
- "opencode"
33
+ "opencode",
34
+ "t3-code",
35
+ "antigravity",
36
+ "gemini",
37
+ "linear",
38
+ "workflow",
39
+ "autonomous-agents"
33
40
  ],
34
41
  "license": "MIT",
35
42
  "author": "Guilherme Damasceno"
@@ -0,0 +1,51 @@
1
+ import { parseArgs } from "node:util";
2
+ import { readFile } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+ import { loadSettings, validateAutonomy, validateConfig, validateWorkflow } from "../core/config.js";
5
+ import { assertPlan } from "../core/engine.js";
6
+ import { classifyCommand, classifyWrite } from "../core/policy.js";
7
+ import { executionWaves } from "../core/dag.js";
8
+ import { listAdapters } from "../runtimes/index.js";
9
+
10
+ export async function runValidate(argv, { root = process.cwd(), out = console.log } = {}) {
11
+ const { values } = parseArgs({ args: argv, options: { plan: { type: "string" } }, allowPositionals: false });
12
+ const { config, autonomy, workflow, found } = await loadSettings(root);
13
+ const configResult = validateConfig(config);
14
+ const autonomyResult = validateAutonomy(autonomy, config);
15
+ const workflowResult = validateWorkflow(workflow, config);
16
+ const errors = [...configResult.errors, ...autonomyResult.errors, ...workflowResult.errors];
17
+ const warnings = [...configResult.warnings];
18
+ if (!found.workflow) warnings.push(".agent-kit/workflow.json not found; using the default role pipeline");
19
+ if (!found.config) warnings.push(".agent-kit/config.json not found; using defaults");
20
+ if (!found.autonomy) warnings.push(".agent-kit/autonomy.json not found; using defaults");
21
+ let waves;
22
+ if (values.plan) {
23
+ try {
24
+ const plan = JSON.parse(await readFile(resolve(root, values.plan), "utf8"));
25
+ assertPlan(plan);
26
+ waves = executionWaves(plan.tasks);
27
+ } catch (error) {
28
+ errors.push(error.message);
29
+ }
30
+ }
31
+ out(JSON.stringify({ valid: errors.length === 0, errors, warnings, waves }, null, 2));
32
+ return errors.length === 0 ? 0 : 1;
33
+ }
34
+
35
+ export async function runPolicy(argv, { root = process.cwd(), out = console.log } = {}) {
36
+ const { values, positionals } = parseArgs({
37
+ args: argv,
38
+ options: { path: { type: "string" } },
39
+ allowPositionals: true,
40
+ });
41
+ if (positionals[0] !== "check") throw new Error("Usage: agent-kit policy check -- <command> | --path <path>");
42
+ const { autonomy } = await loadSettings(root);
43
+ const verdict = values.path ? classifyWrite(values.path, autonomy) : classifyCommand(positionals.slice(1).join(" "), autonomy);
44
+ out(JSON.stringify(verdict, null, 2));
45
+ return verdict.decision === "allow" ? 0 : 3;
46
+ }
47
+
48
+ export async function runRuntimes(_argv, { out = console.log } = {}) {
49
+ out(JSON.stringify(listAdapters(), null, 2));
50
+ return 0;
51
+ }