@guilhermednobre/agent-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/bin/cli.js +195 -0
- package/package.json +35 -0
- package/src/detect.js +94 -0
- package/src/install.js +67 -0
- package/src/render.js +27 -0
- package/templates/AGENTS.md +159 -0
- package/templates/CLAUDE.md +330 -0
- package/templates/claude/commands/criar-prd.md +93 -0
- package/templates/claude/commands/criar-tasks.md +98 -0
- package/templates/claude/commands/criar-techspec.md +118 -0
- package/templates/claude/commands/executar-bugfix.md +173 -0
- package/templates/claude/commands/executar-qa.md +179 -0
- package/templates/claude/commands/executar-review.md +241 -0
- package/templates/claude/commands/executar-task.md +121 -0
- package/templates/claude/rules/README.md +64 -0
- package/templates/claude/rules/code-standards.md +307 -0
- package/templates/claude/rules/http.md +375 -0
- package/templates/claude/rules/logging.md +196 -0
- package/templates/claude/rules/node.md +339 -0
- package/templates/claude/rules/react.md +350 -0
- package/templates/claude/rules/tests.md +225 -0
- package/templates/claude/templates/bugs-template.md +80 -0
- package/templates/claude/templates/prd-template.md +61 -0
- package/templates/claude/templates/task-template.md +54 -0
- package/templates/claude/templates/tasks-template.md +27 -0
- package/templates/claude/templates/techspec-template.md +129 -0
- package/templates/claude/templates/worker-brief-template.md +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Guilherme Damasceno
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @guilhermednobre/agent-kit
|
|
2
|
+
|
|
3
|
+
Scaffolds a multi-agent development workflow into any repository: **Claude orchestrates,
|
|
4
|
+
Antigravity (`agy`) workers implement**, supervised through Orca orchestration.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npx @guilhermednobre/agent-kit init
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Installed globally, the command is just `agent-kit`.
|
|
11
|
+
|
|
12
|
+
## What it writes
|
|
13
|
+
|
|
14
|
+
| Path | Purpose |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `CLAUDE.md` | Orchestrator contract — roles, worker launch recipe, parallel worktrees, review and shutdown, bugfix loop, engineering rules |
|
|
17
|
+
| `AGENTS.md` | Worker contract — what the worker owns, the `worker_done` protocol, stack constraints, definition of done |
|
|
18
|
+
| `.claude/commands/` | Seven pipeline commands: `criar-prd`, `criar-techspec`, `criar-tasks`, `executar-task`, `executar-bugfix`, `executar-qa`, `executar-review` |
|
|
19
|
+
| `.claude/rules/` | Engineering rules split into always-applicable principles and technology-conditional ones |
|
|
20
|
+
| `.claude/templates/` | Document templates for PRD, TechSpec, tasks, bugs and worker briefs |
|
|
21
|
+
|
|
22
|
+
Existing files are never overwritten without `--force` or an explicit confirmation.
|
|
23
|
+
|
|
24
|
+
## Two modes
|
|
25
|
+
|
|
26
|
+
`init` inspects the target directory and picks a mode. Override it with `--mode`.
|
|
27
|
+
|
|
28
|
+
- **greenfield** — no dependency manifest found. The generated contracts state that the stack is
|
|
29
|
+
an open user decision, and forbid Claude and workers from choosing one unilaterally.
|
|
30
|
+
- **existing** — a manifest was found (`package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`,
|
|
31
|
+
`pom.xml`, `Gemfile`, `composer.json`, `mix.exs`, and others). The contracts instead point at a
|
|
32
|
+
commands table. For Node projects the table is prefilled from the actual `scripts` and lockfile;
|
|
33
|
+
anything unknown is written as `TBD` rather than guessed.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx @guilhermednobre/agent-kit init [directory]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| Option | Effect |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `--name <name>` | Project name written into the contracts |
|
|
44
|
+
| `--description <text>` | One-line project description |
|
|
45
|
+
| `--mode <mode>` | `greenfield` or `existing`, overriding detection |
|
|
46
|
+
| `--force` | Overwrite existing files without asking |
|
|
47
|
+
| `-y, --yes` | Non-interactive; skip files that already exist |
|
|
48
|
+
| `--dry-run` | Print the plan, write nothing |
|
|
49
|
+
| `-h, --help` | Show help |
|
|
50
|
+
| `-v, --version` | Show version |
|
|
51
|
+
|
|
52
|
+
Run without flags in a terminal and it prompts for name and description, and asks what to do about
|
|
53
|
+
each file that already exists (skip, overwrite, or write a `.new` sibling).
|
|
54
|
+
|
|
55
|
+
## Language
|
|
56
|
+
|
|
57
|
+
The contracts (`CLAUDE.md`, `AGENTS.md`) are in English. The commands, rules and document
|
|
58
|
+
templates are in Portuguese, matching the workflow they came from. Change either after generating —
|
|
59
|
+
nothing in the kit depends on the wording.
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
Node 20+ to run the generator. The workflow it scaffolds assumes Claude Code, and the worker half
|
|
64
|
+
assumes the Antigravity CLI (`agy`) plus Orca; the documents are still readable and useful without
|
|
65
|
+
them, but the launch recipe in `CLAUDE.md` section 2 is specific to that setup.
|
|
66
|
+
|
|
67
|
+
## After generating
|
|
68
|
+
|
|
69
|
+
1. Read `CLAUDE.md` and fill in anything marked `TBD`.
|
|
70
|
+
2. In `existing` mode, verify the commands table actually runs.
|
|
71
|
+
3. Delete the rule files under `.claude/rules/` that do not match your project, and update
|
|
72
|
+
`.claude/rules/README.md`.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm test
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Zero runtime dependencies. Tests use the built-in `node:test` runner.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
import { detectProject } from "../src/detect.js";
|
|
8
|
+
import { planFiles, installFiles } from "../src/install.js";
|
|
9
|
+
|
|
10
|
+
const TEMPLATES_DIR = fileURLToPath(new URL("../templates/", import.meta.url));
|
|
11
|
+
const PACKAGE_JSON = fileURLToPath(new URL("../package.json", import.meta.url));
|
|
12
|
+
|
|
13
|
+
const OPTIONS = {
|
|
14
|
+
name: { type: "string" },
|
|
15
|
+
description: { type: "string" },
|
|
16
|
+
mode: { type: "string" },
|
|
17
|
+
force: { type: "boolean", default: false },
|
|
18
|
+
yes: { type: "boolean", short: "y", default: false },
|
|
19
|
+
"dry-run": { type: "boolean", default: false },
|
|
20
|
+
help: { type: "boolean", short: "h", default: false },
|
|
21
|
+
version: { type: "boolean", short: "v", default: false },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const HELP = `
|
|
25
|
+
agent-kit — scaffolds a Claude-as-orchestrator / agy-worker agent workflow.
|
|
26
|
+
|
|
27
|
+
Usage:
|
|
28
|
+
npx @guilhermednobre/agent-kit init [directory]
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--name <name> Project name written into CLAUDE.md and AGENTS.md
|
|
32
|
+
--description <text> One-line project description
|
|
33
|
+
--mode <mode> greenfield | existing (default: auto-detected)
|
|
34
|
+
--force Overwrite existing files without asking
|
|
35
|
+
-y, --yes Non-interactive; skip files that already exist
|
|
36
|
+
--dry-run Show what would be written, write nothing
|
|
37
|
+
-h, --help Show this help
|
|
38
|
+
-v, --version Show version
|
|
39
|
+
|
|
40
|
+
Writes CLAUDE.md, AGENTS.md and .claude/{commands,rules,templates} into the
|
|
41
|
+
target directory. Existing files are never overwritten without --force or a
|
|
42
|
+
confirmation.
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
async function main() {
|
|
46
|
+
const { values, positionals } = parseArgs({
|
|
47
|
+
options: OPTIONS,
|
|
48
|
+
allowPositionals: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (values.help) return console.log(HELP.trim());
|
|
52
|
+
if (values.version) return console.log(await readVersion());
|
|
53
|
+
|
|
54
|
+
const command = positionals[0];
|
|
55
|
+
if (command && command !== "init") {
|
|
56
|
+
console.error(`Unknown command: ${command}\n${HELP.trim()}`);
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const targetDir = resolve(positionals[1] || process.cwd());
|
|
62
|
+
await runInit(targetDir, values);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function readVersion() {
|
|
66
|
+
const pkg = JSON.parse(await readFile(PACKAGE_JSON, "utf8"));
|
|
67
|
+
return pkg.version;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function runInit(targetDir, flags) {
|
|
71
|
+
const detected = await detectProject(targetDir);
|
|
72
|
+
const mode = resolveMode(flags.mode, detected.mode);
|
|
73
|
+
const interactive = !flags.yes && process.stdin.isTTY;
|
|
74
|
+
|
|
75
|
+
console.log(`Target: ${targetDir}`);
|
|
76
|
+
console.log(`Mode: ${mode}${flags.mode ? " (forced)" : " (detected)"}`);
|
|
77
|
+
if (detected.manifest) console.log(`Stack: ${detected.stack} (${detected.manifest})`);
|
|
78
|
+
console.log("");
|
|
79
|
+
|
|
80
|
+
const answers = await collectAnswers({ detected, flags, interactive });
|
|
81
|
+
const vars = buildVars(detected, answers);
|
|
82
|
+
const files = await planFiles(TEMPLATES_DIR);
|
|
83
|
+
const resolveConflict = makeConflictResolver(flags, interactive);
|
|
84
|
+
const results = await installFiles({
|
|
85
|
+
files,
|
|
86
|
+
targetDir,
|
|
87
|
+
mode,
|
|
88
|
+
vars,
|
|
89
|
+
resolveConflict,
|
|
90
|
+
dryRun: flags["dry-run"],
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
report(results, flags["dry-run"], mode);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function resolveMode(requested, detected) {
|
|
97
|
+
if (!requested) return detected;
|
|
98
|
+
if (requested === "greenfield" || requested === "existing") return requested;
|
|
99
|
+
throw new Error(`Invalid --mode: ${requested}. Use "greenfield" or "existing".`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function collectAnswers({ detected, flags, interactive }) {
|
|
103
|
+
const fallbackName = flags.name || detected.name;
|
|
104
|
+
const fallbackDescription = flags.description || detected.description;
|
|
105
|
+
if (!interactive || (flags.name && flags.description)) {
|
|
106
|
+
return { name: fallbackName, description: fallbackDescription };
|
|
107
|
+
}
|
|
108
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
109
|
+
try {
|
|
110
|
+
const name = flags.name || (await ask(rl, "Project name", fallbackName));
|
|
111
|
+
const description =
|
|
112
|
+
flags.description ||
|
|
113
|
+
(await ask(rl, "One-line description", fallbackDescription || "TBD"));
|
|
114
|
+
console.log("");
|
|
115
|
+
return { name, description };
|
|
116
|
+
} finally {
|
|
117
|
+
rl.close();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function ask(rl, label, fallback) {
|
|
122
|
+
const answer = await rl.question(`${label} [${fallback}]: `);
|
|
123
|
+
return answer.trim() || fallback;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function buildVars(detected, answers) {
|
|
127
|
+
const commands = detected.commands;
|
|
128
|
+
return {
|
|
129
|
+
PROJECT_NAME: answers.name,
|
|
130
|
+
PROJECT_DESCRIPTION: answers.description || "TBD",
|
|
131
|
+
STACK_MANIFEST: detected.manifest || "none",
|
|
132
|
+
CMD_INSTALL: commands.install,
|
|
133
|
+
CMD_BUILD: commands.build,
|
|
134
|
+
CMD_TEST: commands.test,
|
|
135
|
+
CMD_LINT: commands.lint,
|
|
136
|
+
CMD_TEST_ONE: commands.testOne,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function makeConflictResolver(flags, interactive) {
|
|
141
|
+
if (flags.force) return async () => "overwrite";
|
|
142
|
+
if (!interactive) return async () => "skip";
|
|
143
|
+
return async (target) => {
|
|
144
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
145
|
+
try {
|
|
146
|
+
const answer = await rl.question(
|
|
147
|
+
`${target} already exists. [s]kip, [o]verwrite, [b]oth? [s]: `
|
|
148
|
+
);
|
|
149
|
+
return decodeChoice(answer.trim().toLowerCase());
|
|
150
|
+
} finally {
|
|
151
|
+
rl.close();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function decodeChoice(answer) {
|
|
157
|
+
if (answer === "o") return "overwrite";
|
|
158
|
+
if (answer === "b") return "keep-both";
|
|
159
|
+
return "skip";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function report(results, dryRun, mode) {
|
|
163
|
+
const counts = results.reduce((acc, result) => {
|
|
164
|
+
acc[result.action] = (acc[result.action] || 0) + 1;
|
|
165
|
+
return acc;
|
|
166
|
+
}, {});
|
|
167
|
+
for (const result of results) {
|
|
168
|
+
console.log(` ${result.action.padEnd(18)} ${result.target}`);
|
|
169
|
+
}
|
|
170
|
+
console.log("");
|
|
171
|
+
console.log(dryRun ? "Dry run — nothing was written." : summarize(counts));
|
|
172
|
+
if (!dryRun) printNextSteps(mode);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function summarize(counts) {
|
|
176
|
+
const parts = Object.entries(counts).map(([action, count]) => `${count} ${action}`);
|
|
177
|
+
return parts.join(", ");
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function printNextSteps(mode) {
|
|
181
|
+
console.log("");
|
|
182
|
+
console.log("Next steps:");
|
|
183
|
+
console.log(" 1. Read CLAUDE.md and fill in anything marked TBD.");
|
|
184
|
+
if (mode === "existing") {
|
|
185
|
+
console.log(" 2. Verify the commands table in CLAUDE.md actually runs.");
|
|
186
|
+
} else {
|
|
187
|
+
console.log(" 2. Decide the stack with your team, then update CLAUDE.md and rules/README.md.");
|
|
188
|
+
}
|
|
189
|
+
console.log(" 3. Drop the rule files under .claude/rules that do not match your project.");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
main().catch((error) => {
|
|
193
|
+
console.error(error.message);
|
|
194
|
+
process.exitCode = 1;
|
|
195
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guilhermednobre/agent-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffolds a Claude-as-orchestrator / Antigravity-worker agent workflow into any repository",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agent-kit": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"templates",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "node --test",
|
|
23
|
+
"prepublishOnly": "npm test"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"claude",
|
|
27
|
+
"claude-code",
|
|
28
|
+
"agents",
|
|
29
|
+
"orchestration",
|
|
30
|
+
"scaffold",
|
|
31
|
+
"antigravity"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"author": "Guilherme Damasceno"
|
|
35
|
+
}
|
package/src/detect.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { basename, join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const UNKNOWN = "TBD";
|
|
6
|
+
|
|
7
|
+
const MANIFESTS = [
|
|
8
|
+
{ file: "package.json", stack: "Node.js" },
|
|
9
|
+
{ file: "deno.json", stack: "Deno" },
|
|
10
|
+
{ file: "pyproject.toml", stack: "Python" },
|
|
11
|
+
{ file: "requirements.txt", stack: "Python" },
|
|
12
|
+
{ file: "go.mod", stack: "Go" },
|
|
13
|
+
{ file: "Cargo.toml", stack: "Rust" },
|
|
14
|
+
{ file: "pom.xml", stack: "Java (Maven)" },
|
|
15
|
+
{ file: "build.gradle", stack: "Java (Gradle)" },
|
|
16
|
+
{ file: "build.gradle.kts", stack: "Kotlin (Gradle)" },
|
|
17
|
+
{ file: "Gemfile", stack: "Ruby" },
|
|
18
|
+
{ file: "composer.json", stack: "PHP" },
|
|
19
|
+
{ file: "mix.exs", stack: "Elixir" },
|
|
20
|
+
{ file: "pubspec.yaml", stack: "Dart / Flutter" },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const PACKAGE_MANAGERS = [
|
|
24
|
+
{ lockfile: "pnpm-lock.yaml", name: "pnpm", install: "pnpm install" },
|
|
25
|
+
{ lockfile: "yarn.lock", name: "yarn", install: "yarn install" },
|
|
26
|
+
{ lockfile: "bun.lockb", name: "bun", install: "bun install" },
|
|
27
|
+
{ lockfile: "package-lock.json", name: "npm", install: "npm ci" },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export async function detectProject(dir) {
|
|
31
|
+
const manifest = MANIFESTS.find((entry) => existsSync(join(dir, entry.file)));
|
|
32
|
+
if (!manifest) {
|
|
33
|
+
return { mode: "greenfield", ...emptyProfile(dir) };
|
|
34
|
+
}
|
|
35
|
+
const profile = await readProfile(dir, manifest);
|
|
36
|
+
return { mode: "existing", manifest: manifest.file, stack: manifest.stack, ...profile };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function emptyProfile(dir) {
|
|
40
|
+
return {
|
|
41
|
+
manifest: null,
|
|
42
|
+
stack: null,
|
|
43
|
+
name: basename(dir),
|
|
44
|
+
description: "",
|
|
45
|
+
commands: blankCommands(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function blankCommands() {
|
|
50
|
+
return {
|
|
51
|
+
install: UNKNOWN,
|
|
52
|
+
build: UNKNOWN,
|
|
53
|
+
test: UNKNOWN,
|
|
54
|
+
lint: UNKNOWN,
|
|
55
|
+
testOne: UNKNOWN,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function readProfile(dir, manifest) {
|
|
60
|
+
if (manifest.file !== "package.json") {
|
|
61
|
+
return { name: basename(dir), description: "", commands: blankCommands() };
|
|
62
|
+
}
|
|
63
|
+
const pkg = await readJson(join(dir, "package.json"));
|
|
64
|
+
return {
|
|
65
|
+
name: pkg.name || basename(dir),
|
|
66
|
+
description: pkg.description || "",
|
|
67
|
+
commands: nodeCommands(dir, pkg.scripts || {}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function readJson(path) {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
74
|
+
} catch {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function nodeCommands(dir, scripts) {
|
|
80
|
+
const manager = detectPackageManager(dir);
|
|
81
|
+
const runner = manager.name === "npm" ? "npm run" : `${manager.name} run`;
|
|
82
|
+
return {
|
|
83
|
+
install: manager.install,
|
|
84
|
+
build: scripts.build ? `${runner} build` : UNKNOWN,
|
|
85
|
+
test: scripts.test ? `${manager.name} test` : UNKNOWN,
|
|
86
|
+
lint: scripts.lint ? `${runner} lint` : UNKNOWN,
|
|
87
|
+
testOne: UNKNOWN,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function detectPackageManager(dir) {
|
|
92
|
+
const found = PACKAGE_MANAGERS.find((entry) => existsSync(join(dir, entry.lockfile)));
|
|
93
|
+
return found || { name: "npm", install: "npm install" };
|
|
94
|
+
}
|
package/src/install.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { readdir, readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
4
|
+
import { render } from "./render.js";
|
|
5
|
+
|
|
6
|
+
export async function planFiles(templatesDir) {
|
|
7
|
+
const sources = await listFiles(templatesDir);
|
|
8
|
+
return sources.map((source) => ({
|
|
9
|
+
source,
|
|
10
|
+
target: toTargetPath(relative(templatesDir, source)),
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function listFiles(dir) {
|
|
15
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
16
|
+
const nested = await Promise.all(
|
|
17
|
+
entries.map((entry) => {
|
|
18
|
+
const full = join(dir, entry.name);
|
|
19
|
+
return entry.isDirectory() ? listFiles(full) : Promise.resolve([full]);
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
return nested.flat();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function toTargetPath(relativePath) {
|
|
26
|
+
const segments = relativePath.split(sep);
|
|
27
|
+
if (segments[0] === "claude") {
|
|
28
|
+
return [".claude", ...segments.slice(1)].join(sep);
|
|
29
|
+
}
|
|
30
|
+
return relativePath;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function installFiles(options) {
|
|
34
|
+
const { files, targetDir, mode, vars, resolveConflict, dryRun } = options;
|
|
35
|
+
const results = [];
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
results.push(await installOne(file, { targetDir, mode, vars, resolveConflict, dryRun }));
|
|
38
|
+
}
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function installOne(file, { targetDir, mode, vars, resolveConflict, dryRun }) {
|
|
43
|
+
const absoluteTarget = join(targetDir, file.target);
|
|
44
|
+
const template = await readFile(file.source, "utf8");
|
|
45
|
+
const content = render(template, mode, vars);
|
|
46
|
+
if (!existsSync(absoluteTarget)) {
|
|
47
|
+
await writeIfWanted(absoluteTarget, content, dryRun);
|
|
48
|
+
return { target: file.target, action: "created" };
|
|
49
|
+
}
|
|
50
|
+
const decision = await resolveConflict(file.target);
|
|
51
|
+
if (decision === "skip") {
|
|
52
|
+
return { target: file.target, action: "skipped" };
|
|
53
|
+
}
|
|
54
|
+
if (decision === "keep-both") {
|
|
55
|
+
const alternate = `${absoluteTarget}.new`;
|
|
56
|
+
await writeIfWanted(alternate, content, dryRun);
|
|
57
|
+
return { target: `${file.target}.new`, action: "written-alongside" };
|
|
58
|
+
}
|
|
59
|
+
await writeIfWanted(absoluteTarget, content, dryRun);
|
|
60
|
+
return { target: file.target, action: "overwritten" };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function writeIfWanted(path, content, dryRun) {
|
|
64
|
+
if (dryRun) return;
|
|
65
|
+
await mkdir(dirname(path), { recursive: true });
|
|
66
|
+
await writeFile(path, content, "utf8");
|
|
67
|
+
}
|
package/src/render.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const CONDITIONAL_BLOCK = /<!--IF:([a-z-]+)-->\r?\n?([\s\S]*?)<!--END-->\r?\n?/g;
|
|
2
|
+
const PLACEHOLDER = /\{\{([A-Z_]+)\}\}/g;
|
|
3
|
+
|
|
4
|
+
export function render(text, mode, vars) {
|
|
5
|
+
const selected = selectBlocks(text, mode);
|
|
6
|
+
return fillPlaceholders(selected, vars);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function selectBlocks(text, mode) {
|
|
10
|
+
return text.replace(CONDITIONAL_BLOCK, (_, blockMode, body) =>
|
|
11
|
+
blockMode === mode ? body : ""
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function fillPlaceholders(text, vars) {
|
|
16
|
+
return text.replace(PLACEHOLDER, (whole, key) =>
|
|
17
|
+
Object.hasOwn(vars, key) ? vars[key] : whole
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function findUnresolved(text) {
|
|
22
|
+
return [...new Set(Array.from(text.matchAll(PLACEHOLDER), (m) => m[1]))];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function findModes(text) {
|
|
26
|
+
return [...new Set(Array.from(text.matchAll(CONDITIONAL_BLOCK), (m) => m[1]))];
|
|
27
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Operating contract for the **Antigravity implementation worker** (CLI `agy`) in this repository.
|
|
4
|
+
|
|
5
|
+
You run inside an Orca-managed worktree, launched as `agy --model gemini-3.8-flash-high
|
|
6
|
+
--dangerously-skip-permissions`, and you are supervised by a Claude orchestrator. `CLAUDE.md`
|
|
7
|
+
governs the orchestrator; this file governs you. On any conflict, `CLAUDE.md` wins.
|
|
8
|
+
|
|
9
|
+
Read `CLAUDE.md` and the applicable files in `.claude/rules/` before you start working.
|
|
10
|
+
|
|
11
|
+
## Project
|
|
12
|
+
|
|
13
|
+
**{{PROJECT_NAME}}** — {{PROJECT_DESCRIPTION}}
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. What you own
|
|
18
|
+
|
|
19
|
+
- Feature implementation
|
|
20
|
+
- Routine refactoring
|
|
21
|
+
- Tests
|
|
22
|
+
- Documentation
|
|
23
|
+
- Boilerplate
|
|
24
|
+
- Straightforward debugging
|
|
25
|
+
- Repetitive code changes
|
|
26
|
+
- Applying fixes already diagnosed in `tasks/prd-<feature>/bugs.md`
|
|
27
|
+
|
|
28
|
+
## 2. What you do not own
|
|
29
|
+
|
|
30
|
+
- Architecture and technical decisions
|
|
31
|
+
- Stack selection (see section 4)
|
|
32
|
+
- Security-sensitive decisions
|
|
33
|
+
- Difficult debugging and root-cause analysis
|
|
34
|
+
- Planning and task decomposition
|
|
35
|
+
- Final review
|
|
36
|
+
- Commits, pushes, branch operations, and merges
|
|
37
|
+
|
|
38
|
+
If a task pushes you into any of these, stop and escalate. Do not decide it yourself.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 3. Orca orchestration protocol
|
|
43
|
+
|
|
44
|
+
You receive work as a dispatched task carrying an injected `task_id` and `dispatch_id`. Never
|
|
45
|
+
invent, guess, or reuse stale IDs. You are a worker: you do not dispatch sub-workers.
|
|
46
|
+
|
|
47
|
+
Report completion **exactly once**:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
orca orchestration send --type worker_done \
|
|
51
|
+
--subject "<short status>" \
|
|
52
|
+
--body "<what you did, what you found, what remains>" \
|
|
53
|
+
--task-id <task_id> --dispatch-id <dispatch_id> \
|
|
54
|
+
--outcome succeeded --files-modified "path/a,path/b" --json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- Encode failure with `--outcome failed`. Never signal failure in prose alone, and never exit
|
|
58
|
+
silently.
|
|
59
|
+
- Blocking question to the coordinator:
|
|
60
|
+
`orca orchestration ask --question "<q>" --options "<a,b>" --timeout-ms 600000`.
|
|
61
|
+
Never use an interactive local prompt — the coordinator cannot see or answer it.
|
|
62
|
+
- Blocked before completion: `--type escalation`.
|
|
63
|
+
- Long runs: `--type heartbeat` every 5 minutes, or `--type status` for progress.
|
|
64
|
+
- Read coordinator messages with `orca orchestration check --terminal <your handle>`.
|
|
65
|
+
|
|
66
|
+
After `worker_done`, your turn is over. Stop, return to an idle prompt, and start nothing new.
|
|
67
|
+
Do not exit the shell — the coordinator reviews your work and then closes this terminal itself.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 4. Stack constraints
|
|
72
|
+
|
|
73
|
+
<!--IF:greenfield-->
|
|
74
|
+
The stack is **not chosen**. This repository has no source code, no package manager, no dependency
|
|
75
|
+
manifest, no build system, no test suite, and no CI.
|
|
76
|
+
|
|
77
|
+
Hard rules:
|
|
78
|
+
|
|
79
|
+
- Do not pick the language, framework, package manager, directory layout, or test tooling.
|
|
80
|
+
- Do not scaffold a project structure on your own initiative.
|
|
81
|
+
- Do not run or claim to have run a command that does not exist yet.
|
|
82
|
+
|
|
83
|
+
If a task cannot proceed without one of those decisions, send an `ask` or an `escalation`. Never
|
|
84
|
+
assume a default.
|
|
85
|
+
<!--END-->
|
|
86
|
+
<!--IF:existing-->
|
|
87
|
+
This project already has a stack. The commands table in `CLAUDE.md` is the single source of truth
|
|
88
|
+
for how to build, test and lint it.
|
|
89
|
+
|
|
90
|
+
Hard rules:
|
|
91
|
+
|
|
92
|
+
- Use only the commands listed in `CLAUDE.md`. If the one you need is missing there, ask — do not
|
|
93
|
+
guess an invocation.
|
|
94
|
+
- Do not add, replace or upgrade a language, framework, package manager or test tool. That is a
|
|
95
|
+
user decision, even when it looks like the obvious fix.
|
|
96
|
+
- Do not introduce a new dependency unless the brief names it.
|
|
97
|
+
- Do not run or claim to have run a command that does not exist or that you did not execute.
|
|
98
|
+
|
|
99
|
+
If a task cannot proceed without one of those decisions, send an `ask` or an `escalation`. Never
|
|
100
|
+
assume a default.
|
|
101
|
+
<!--END-->
|
|
102
|
+
|
|
103
|
+
`.claude/rules/README.md` says which rule files always apply and which only apply when the matching
|
|
104
|
+
technology is part of the project. The code examples in the rules are illustrative, not a stack
|
|
105
|
+
mandate.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 5. Development workflow
|
|
110
|
+
|
|
111
|
+
1. Read `CLAUDE.md`, this file, and the applicable `.claude/rules/` files.
|
|
112
|
+
2. Read the brief in full: objective, context, constraints, files involved, acceptance criteria,
|
|
113
|
+
validation.
|
|
114
|
+
3. Work **only** inside the files the brief names. Touch nothing else.
|
|
115
|
+
4. Prefer small, reviewable diffs. Match the existing style.
|
|
116
|
+
5. Run the validation the brief specifies and observe the real output.
|
|
117
|
+
6. Report honestly — including what you did not do and why.
|
|
118
|
+
|
|
119
|
+
Never commit, push, stage, or switch branches. The coordinator reviews the working tree as-is.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 6. Engineering rules
|
|
124
|
+
|
|
125
|
+
The full set is in `CLAUDE.md` section 6 and `.claude/rules/`. The ones that most often go wrong:
|
|
126
|
+
|
|
127
|
+
- **Simplicity first** — minimum code that solves the problem. No speculative features,
|
|
128
|
+
abstractions for single-use code, or unrequested configurability. Simplicity governs *how* you
|
|
129
|
+
implement each item, never *whether* you implement it.
|
|
130
|
+
- **Surgical changes** — do not improve adjacent code, comments, or formatting. Do not refactor
|
|
131
|
+
what is not broken. Remove only the symbols your own change orphaned; mention other dead code
|
|
132
|
+
instead of deleting it.
|
|
133
|
+
- **The spec is the request** — implement every item in the brief. Never silently drop, defer, or
|
|
134
|
+
merge items. Ambiguity is a question, not a licence to omit.
|
|
135
|
+
- **Language** — code, identifiers, and comments in English; process documents
|
|
136
|
+
(`prd.md`, `techspec.md`, `tasks.md`, `bugs.md`) in Portuguese.
|
|
137
|
+
- **Comments** — prefer self-explanatory code. Comment only when the *why* is non-obvious.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 7. Definition of done
|
|
142
|
+
|
|
143
|
+
A task is done only when all of the following hold:
|
|
144
|
+
|
|
145
|
+
- Every acceptance criterion in the brief is met.
|
|
146
|
+
- Every item in the brief is implemented, or explicitly reported as partial or skipped with a
|
|
147
|
+
reason.
|
|
148
|
+
- The specified validation was actually executed and its output observed.
|
|
149
|
+
- No unrequested scope was added and no unrelated file was touched.
|
|
150
|
+
- Nothing is fabricated: no invented command output, test result, file path, or dependency.
|
|
151
|
+
|
|
152
|
+
Then, and only then, send `worker_done`.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 8. Maintenance
|
|
157
|
+
|
|
158
|
+
Update this file whenever the stack lands or the worker protocol changes, in the same pass as
|
|
159
|
+
`CLAUDE.md` and `.claude/rules/README.md`.
|