levi-gear 0.4.0 → 0.5.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/README.md +24 -34
- package/package.json +3 -3
- package/src/cli.js +3 -3
- package/src/commands/init.js +9 -24
- package/src/commands/list.js +3 -5
- package/src/commands/status.js +1 -1
- package/src/commands/update.js +4 -4
- package/src/lib/agents.js +1 -1
- package/src/lib/desired-state.js +16 -31
- package/src/lib/sync.js +3 -3
- package/src/lib/tools.js +10 -81
- package/src/runtime/quota-check.mjs +21 -142
- package/usecases/_run-rules.md +13 -20
- package/usecases/brainstorming/SKILL.md +0 -4
- package/usecases/code-review/SKILL.md +0 -4
- package/usecases/create-feature/SKILL.md +3 -4
- package/usecases/design/SKILL.md +0 -4
- package/usecases/fix-bug/SKILL.md +3 -4
- package/usecases/generate-test-scenarios/SKILL.md +0 -5
- package/usecases/spec-writing/SKILL.md +0 -4
- package/src/runtime/codex-run-state.mjs +0 -156
- package/usecases/brainstorming/references/codex-runner.md +0 -28
- package/usecases/code-review/references/codex-runner.md +0 -5
- package/usecases/create-feature/references/codex-runner.md +0 -57
- package/usecases/design/references/codex-runner.md +0 -27
- package/usecases/fix-bug/references/codex-runner.md +0 -32
- package/usecases/generate-test-scenarios/references/codex-runner.md +0 -32
- package/usecases/spec-writing/references/codex-runner.md +0 -25
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# levi-gear
|
|
2
2
|
|
|
3
|
-
**Gather a whole software team into your terminal.** levi is an agentic kit that breathes a complete crew into
|
|
3
|
+
**Gather a whole software team into your terminal.** levi is an agentic kit that breathes a complete crew into Claude Code: a product manager, a teamlead, a developer, a designer and a QA engineer, each with a clear craft and a clear territory. Write a workflow once, and it comes alive as native Claude Code skills and subagents.
|
|
4
4
|
|
|
5
5
|
## Why levi
|
|
6
6
|
|
|
7
|
-
- **
|
|
7
|
+
- **Built for Claude Code.** A usecase is written once and installed as native Claude Code skills and subagents.
|
|
8
8
|
- **A team, not a lone assistant.** Five role agents, each owning only its own files, pass work to one another through plain files in a shared work folder, so every hand-off leaves a trail you can read.
|
|
9
9
|
- **Craft from idea to release.** Seven ready usecases carry work from a vague idea to a verified result: brainstorming, spec writing, design, test-first feature building, bug fixing, code review and test scenarios.
|
|
10
10
|
- **Tests that cannot be bent.** In `create-feature` and `fix-bug` the tests come first and are locked, and QA writes its test cases from the spec alone, so the code is fixed until the proof passes.
|
|
11
11
|
- **Ask once, then run alone.** All questions are gathered up front; afterwards the run proceeds without you, picks cheap-to-change options on its own and lays them out in a closing report so you can change any of them.
|
|
12
12
|
- **A run that outlasts the quota.** When the 5-hour usage window runs dry, the run resumes itself once it refills, with its context kept, instead of stopping half-way.
|
|
13
|
-
- **Quiet until called.** levi never acts on its own; a prompt without the levi command is handled by
|
|
13
|
+
- **Quiet until called.** levi never acts on its own; a prompt without the levi command is handled by Claude Code as usual. `/levi <request>` routes a request, in any language, to the best matching usecase.
|
|
14
14
|
- **Your files stay yours.** Everything installed is a plain file in your repository. `levi update` refreshes only what you did not touch and never overwrites your edits.
|
|
15
15
|
- **Featherlight.** No runtime dependencies; Node.js 18 or newer is all it asks for.
|
|
16
16
|
|
|
@@ -19,9 +19,8 @@
|
|
|
19
19
|
## Install into a project
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npx levi-gear@latest init # all usecases
|
|
22
|
+
npx levi-gear@latest init # all usecases
|
|
23
23
|
npx levi-gear@latest init brainstorming # only some usecases
|
|
24
|
-
npx levi-gear@latest init --tools claude,codex # only some tools
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
Installed files are recorded in `.levi.json`. Commit the generated folders and `.levi.json` so teammates get everything by cloning.
|
|
@@ -30,22 +29,18 @@ Installed files are recorded in `.levi.json`. Commit the generated folders and `
|
|
|
30
29
|
|
|
31
30
|
| Command | What it does |
|
|
32
31
|
|---|---|
|
|
33
|
-
| `levi init [usecase...]
|
|
32
|
+
| `levi init [usecase...]` | Install usecases (all by default) |
|
|
34
33
|
| `levi update [--force [path...]]` | Refresh installed files to this package version, keeping files you changed |
|
|
35
34
|
| `levi status` | Show what `update` would do, without changing anything |
|
|
36
35
|
| `levi list` | List usecases in the kit and print how to invoke them |
|
|
37
36
|
|
|
38
37
|
## Using it
|
|
39
38
|
|
|
40
|
-
levi only runs when you ask for it. A prompt that does not start with the levi command is handled by
|
|
39
|
+
levi only runs when you ask for it. A prompt that does not start with the levi command is handled by Claude Code as usual.
|
|
41
40
|
|
|
42
|
-
|
|
|
43
|
-
|
|
44
|
-
|
|
|
45
|
-
| Copilot | `/levi <request>` | `/levi-<usecase> <request>` |
|
|
46
|
-
| Codex | `$levi <request>` | `$levi-<usecase> <request>` |
|
|
47
|
-
|
|
48
|
-
Codex has no user-defined `/` commands in a repo, so it uses `$` instead. `levi init`, `update` and `list` print the right syntax for the tools you installed.
|
|
41
|
+
| Let levi pick the usecase | Call a usecase directly |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `/levi <request>` | `/levi-<usecase> <request>` |
|
|
49
44
|
|
|
50
45
|
`levi <request>` is an entry point generated at install time from the installed usecases. It matches the request (in any language) against each usecase description, runs the best match (naming the runner-up when it was close, so you can call that one directly), and tells you when none fits.
|
|
51
46
|
|
|
@@ -65,7 +60,7 @@ Each agent does only its own role's work and writes only the files it owns; work
|
|
|
65
60
|
|
|
66
61
|
Some usecases are also a role's skill: `spec-writing` for the PM, `design` for the designer, `code-review` for the teamlead and `generate-test-scenarios` for QA. They are installed with every install, and the agent follows that skill's guide whenever it gets that kind of task, from any usecase. A usecase declares this with `skill-for`, `skill-when` and `skill-guide` in its `SKILL.md`.
|
|
67
62
|
|
|
68
|
-
The usecase's skill or workflow runs the team: it calls each member in turn. The PM only decides who owns each task and records it; the workflow follows that. Members hand work to each other through files in a work folder (`docs/levi/<slug>/` by default): `spec.md`, `status.md`, `docs/designs/`, `architecture.md`, `tasks.md`, `review.md`, `test-plan.md`, `test-report.md`.
|
|
63
|
+
The usecase's skill or workflow runs the team: it calls each member in turn. The PM only decides who owns each task and records it; the workflow follows that. Members hand work to each other through files in a work folder (`docs/levi/<slug>/` by default): `spec.md`, `status.md`, `docs/designs/`, `architecture.md`, `tasks.md`, `review.md`, `test-plan.md`, `test-report.md`. The shared rules live in `agents/_team-protocol.md`, which is appended to every team agent. Every usecase also follows the run rules in `usecases/_run-rules.md`, appended to each installed `SKILL.md`: all questions are asked up front, cheap-to-change choices are picked and reported at the end, and a run that hits the 5-hour quota resumes itself with its context kept ([docs/unattended-runs.md](docs/unattended-runs.md)).
|
|
69
64
|
|
|
70
65
|
## Update
|
|
71
66
|
|
|
@@ -89,11 +84,9 @@ levi does not merge: a file you changed is yours from then on and stops receivin
|
|
|
89
84
|
|
|
90
85
|
## Where things go
|
|
91
86
|
|
|
92
|
-
|
|
|
93
|
-
|
|
94
|
-
|
|
|
95
|
-
| Codex | `.agents/skills/levi/`, `.agents/skills/levi-<usecase>/` | `.codex/agents/levi-<usecase>-<role>.toml` |
|
|
96
|
-
| Copilot | reads `.claude/skills` and `.agents/skills` (gets `.agents/skills` itself only if Claude is not selected) | `.github/agents/levi-<usecase>-<role>.agent.md` |
|
|
87
|
+
| Skill | Subagents |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `.claude/skills/levi/`, `.claude/skills/levi-<usecase>/` | `.claude/agents/levi-<usecase>-<role>.md` |
|
|
97
90
|
|
|
98
91
|
## Authoring a usecase
|
|
99
92
|
|
|
@@ -109,19 +102,18 @@ agents/_*.md # partials appended to every team agent
|
|
|
109
102
|
|
|
110
103
|
Agent frontmatter (usecase and team agents alike):
|
|
111
104
|
|
|
112
|
-
| Field | Values | Claude Code |
|
|
113
|
-
|
|
114
|
-
| `name`, `description` | required | as is |
|
|
115
|
-
| `tools` | comma list of `read`, `edit`, `execute`, `web`; omit for the
|
|
116
|
-
| `model` | `strong`, `standard`, `fast`; omit to inherit | `opus` / `sonnet` / `haiku` |
|
|
105
|
+
| Field | Values | Claude Code |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| `name`, `description` | required | as is |
|
|
108
|
+
| `tools` | comma list of `read`, `edit`, `execute`, `web`; omit for the defaults | `Read, Grep, Glob` / `Edit, Write` / `Bash` / `WebFetch, WebSearch` |
|
|
109
|
+
| `model` | `strong`, `standard`, `fast`; omit to inherit | `opus` / `sonnet` / `haiku` |
|
|
117
110
|
|
|
118
|
-
An explicit `tools` list also cuts off MCP tools
|
|
111
|
+
An explicit `tools` list also cuts off MCP tools, so leave it out for agents that need a browser or other MCP servers.
|
|
119
112
|
|
|
120
|
-
- Every usecase is manual-only: the installer sets `disable-model-invocation: true` in the installed `SKILL.md
|
|
113
|
+
- Every usecase is manual-only: the installer sets `disable-model-invocation: true` in the installed `SKILL.md`, so Claude Code never triggers it by itself.
|
|
121
114
|
- The `description` in `SKILL.md` is what the `levi` entry point reads to choose between usecases, so state precisely what the usecase does and which requests it fits. English is fine; requests in other languages are matched by meaning.
|
|
122
115
|
- The entry point reads a chosen usecase's `SKILL.md` directly, because manual-only skills cannot be called through a skill tool. Keep the workflow in that file.
|
|
123
|
-
- The installer appends a note to each subagent description so
|
|
124
|
-
- Subagent files use the same format for every tool; the installer converts them (Codex needs TOML).
|
|
116
|
+
- The installer appends a note to each subagent description so Claude Code delegates to it only through its usecase.
|
|
125
117
|
- Delegate to team agents by name (`levi-pm`, `levi-qa`, ...) from the usecase's `SKILL.md`, and name the work folder they should use. A usecase id must not reuse a team role name.
|
|
126
118
|
- Write everything in the repo in English: usecase files, code, comments and docs. Requests to the entry point can still be in any language.
|
|
127
119
|
- Test in a scratch project with `node /path/to/levi-gear/bin/levi.js init`, then `npm version <patch|minor>` and `npm publish`.
|
|
@@ -136,11 +128,9 @@ Commit messages, branch names and pull requests are written in English, using sh
|
|
|
136
128
|
|
|
137
129
|
## Status
|
|
138
130
|
|
|
139
|
-
Checked in
|
|
131
|
+
Checked in Claude Code 2.1.276:
|
|
140
132
|
|
|
141
133
|
- The installed skills and agents are picked up.
|
|
142
134
|
- A prompt without the levi command does not use levi.
|
|
143
|
-
- `/levi`
|
|
144
|
-
- The team agents run when a usecase delegates to them (
|
|
145
|
-
|
|
146
|
-
Not checked yet: the Copilot extension in VS Code. The Copilot CLI was tested with a non-interactive prompt, so try `/levi` interactively once to see it in the `/` menu.
|
|
135
|
+
- `/levi` routes a request to the matching usecase.
|
|
136
|
+
- The team agents run when a usecase delegates to them (the full `brainstorming` flow runs).
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "levi-gear",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Summon a whole software team (PM, teamlead, developer, designer, QA) into Claude Code
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Summon a whole software team (PM, teamlead, developer, designer, QA) into Claude Code: test-first workflows that run unattended, outlast the quota and never trample your files",
|
|
5
5
|
"bin": {
|
|
6
6
|
"levi": "./bin/levi.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "node --test test/
|
|
9
|
+
"test": "node --test test/quota-check.test.mjs test/legacy-tools-cleanup.test.mjs"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"agents",
|
package/src/cli.js
CHANGED
|
@@ -9,8 +9,8 @@ const HELP = `levi ${kitVersion()}
|
|
|
9
9
|
Usage: levi <command>
|
|
10
10
|
|
|
11
11
|
Commands:
|
|
12
|
-
init [usecase...]
|
|
13
|
-
Install usecases (all by default) for
|
|
12
|
+
init [usecase...]
|
|
13
|
+
Install usecases (all by default) for Claude Code
|
|
14
14
|
update [--force [path...]]
|
|
15
15
|
Refresh installed files to this package version. Files you changed are kept;
|
|
16
16
|
--force overwrites them (all, or only the given paths)
|
|
@@ -30,7 +30,7 @@ function main(argv) {
|
|
|
30
30
|
case 'status':
|
|
31
31
|
return status(projectDir);
|
|
32
32
|
case 'list':
|
|
33
|
-
return list(
|
|
33
|
+
return list();
|
|
34
34
|
case undefined:
|
|
35
35
|
case '-h':
|
|
36
36
|
case '--help':
|
package/src/commands/init.js
CHANGED
|
@@ -2,38 +2,23 @@ const config = require('../lib/config');
|
|
|
2
2
|
const { sync } = require('../lib/sync');
|
|
3
3
|
const { printReport } = require('../lib/report');
|
|
4
4
|
const { listUsecases, kitVersion } = require('../lib/usecases');
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
function parseArgs(argv) {
|
|
8
|
-
const names = [];
|
|
9
|
-
let tools = null;
|
|
10
|
-
for (let i = 0; i < argv.length; i++) {
|
|
11
|
-
const arg = argv[i];
|
|
12
|
-
if (arg === '--tools') tools = argv[++i];
|
|
13
|
-
else if (arg.startsWith('--tools=')) tools = arg.slice('--tools='.length);
|
|
14
|
-
else names.push(arg);
|
|
15
|
-
}
|
|
16
|
-
return { names, tools: tools ? tools.split(',').filter(Boolean) : null };
|
|
17
|
-
}
|
|
5
|
+
const { INVOCATION_HELP } = require('../lib/tools');
|
|
18
6
|
|
|
19
7
|
function init(projectDir, argv) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const tools = requested || existing.tools || TOOLS;
|
|
23
|
-
const unknown = tools.filter((t) => !TOOLS.includes(t));
|
|
24
|
-
if (unknown.length) {
|
|
25
|
-
console.error(`Unknown tool(s): ${unknown.join(', ')}. Choose from: ${TOOLS.join(', ')}`);
|
|
8
|
+
if (argv.some((arg) => arg === '--tools' || arg.startsWith('--tools='))) {
|
|
9
|
+
console.error('levi supports Claude Code only; the --tools option no longer exists.');
|
|
26
10
|
process.exitCode = 1;
|
|
27
11
|
return;
|
|
28
12
|
}
|
|
29
|
-
const
|
|
13
|
+
const existing = config.read(projectDir) || { usecases: {}, router: { files: {} }, team: { files: {} } };
|
|
14
|
+
const wanted = argv.length ? argv : listUsecases().map((u) => u.id);
|
|
30
15
|
const ids = [...new Set([...Object.keys(existing.usecases), ...wanted])];
|
|
31
|
-
const result = sync(projectDir, ids,
|
|
32
|
-
config.write(projectDir, { version: kitVersion(),
|
|
33
|
-
console.log(`Installed ${Object.keys(result.usecases).length} usecase(s) for
|
|
16
|
+
const result = sync(projectDir, ids, existing);
|
|
17
|
+
config.write(projectDir, { version: kitVersion(), usecases: result.usecases, router: result.router, team: result.team });
|
|
18
|
+
console.log(`Installed ${Object.keys(result.usecases).length} usecase(s) for Claude Code`);
|
|
34
19
|
for (const id of Object.keys(result.usecases)) console.log(` - ${id}`);
|
|
35
20
|
printReport(result.actions);
|
|
36
|
-
if (Object.keys(result.usecases).length) console.log(`\nInvoke with:\n${
|
|
21
|
+
if (Object.keys(result.usecases).length) console.log(`\nInvoke with:\n${INVOCATION_HELP}`);
|
|
37
22
|
if (result.missing.length) {
|
|
38
23
|
console.error(`Not found in kit: ${result.missing.join(', ')}`);
|
|
39
24
|
process.exitCode = 1;
|
package/src/commands/list.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const config = require('../lib/config');
|
|
2
1
|
const { listUsecases } = require('../lib/usecases');
|
|
3
|
-
const {
|
|
2
|
+
const { INVOCATION_HELP } = require('../lib/tools');
|
|
4
3
|
|
|
5
|
-
function list(
|
|
4
|
+
function list() {
|
|
6
5
|
const usecases = listUsecases();
|
|
7
6
|
if (!usecases.length) console.log('No usecases in the kit yet.');
|
|
8
7
|
for (const u of usecases) {
|
|
@@ -11,8 +10,7 @@ function list(projectDir) {
|
|
|
11
10
|
console.log(`${u.id}${roles}${requires}\n ${u.description}`);
|
|
12
11
|
}
|
|
13
12
|
if (usecases.length) {
|
|
14
|
-
|
|
15
|
-
console.log(`\nInvoke with:\n${invocationHelp(installed ? installed.tools : TOOLS)}`);
|
|
13
|
+
console.log(`\nInvoke with:\n${INVOCATION_HELP}`);
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
16
|
|
package/src/commands/status.js
CHANGED
|
@@ -10,7 +10,7 @@ function status(projectDir) {
|
|
|
10
10
|
process.exitCode = 1;
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
const { actions } = sync(projectDir, Object.keys(existing.usecases), existing
|
|
13
|
+
const { actions } = sync(projectDir, Object.keys(existing.usecases), existing, { dryRun: true });
|
|
14
14
|
printReport(actions, { dryRun: true });
|
|
15
15
|
}
|
|
16
16
|
|
package/src/commands/update.js
CHANGED
|
@@ -2,7 +2,7 @@ const config = require('../lib/config');
|
|
|
2
2
|
const { sync } = require('../lib/sync');
|
|
3
3
|
const { printReport } = require('../lib/report');
|
|
4
4
|
const { kitVersion } = require('../lib/usecases');
|
|
5
|
-
const {
|
|
5
|
+
const { INVOCATION_HELP } = require('../lib/tools');
|
|
6
6
|
|
|
7
7
|
// `--force` alone overwrites every file the user changed; with paths it only overwrites those.
|
|
8
8
|
function parseForce(argv) {
|
|
@@ -18,12 +18,12 @@ function update(projectDir, argv = []) {
|
|
|
18
18
|
process.exitCode = 1;
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const result = sync(projectDir, Object.keys(existing.usecases), existing
|
|
22
|
-
config.write(projectDir, { version: kitVersion(),
|
|
21
|
+
const result = sync(projectDir, Object.keys(existing.usecases), existing, { force: parseForce(argv) });
|
|
22
|
+
config.write(projectDir, { version: kitVersion(), usecases: result.usecases, router: result.router, team: result.team });
|
|
23
23
|
console.log(`Updated ${existing.version} -> ${kitVersion()} (${Object.keys(result.usecases).length} usecase(s))`);
|
|
24
24
|
printReport(result.actions);
|
|
25
25
|
for (const id of result.missing) console.log(`\n${id} is no longer in the kit; its unchanged files were removed.`);
|
|
26
|
-
if (Object.keys(result.usecases).length) console.log(`\nInvoke with:\n${
|
|
26
|
+
if (Object.keys(result.usecases).length) console.log(`\nInvoke with:\n${INVOCATION_HELP}`);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
module.exports = { update };
|
package/src/lib/agents.js
CHANGED
|
@@ -7,7 +7,7 @@ const TEAM_DIR = path.join(__dirname, '..', '..', 'agents');
|
|
|
7
7
|
// Files in agents/ starting with "_" are not agents: they are appended to every team agent.
|
|
8
8
|
const PARTIAL = '_';
|
|
9
9
|
|
|
10
|
-
// Tool-neutral fields. The installer maps them to
|
|
10
|
+
// Tool-neutral fields. The installer maps them to Claude Code in tools.js.
|
|
11
11
|
const CAPABILITIES = ['read', 'edit', 'execute', 'web'];
|
|
12
12
|
const MODEL_TIERS = ['strong', 'standard', 'fast'];
|
|
13
13
|
|
package/src/lib/desired-state.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { ROUTER_NAME, skillName } = require('./usecases');
|
|
4
|
-
const {
|
|
4
|
+
const { SKILL_DIR, AGENT_DIR, renderAgent } = require('./tools');
|
|
5
5
|
const { joinSections } = require('./agents');
|
|
6
6
|
const { withRoleSkills } = require('./role-skills');
|
|
7
7
|
const { setField } = require('./frontmatter');
|
|
8
8
|
const { renderRouter } = require('./router');
|
|
9
9
|
|
|
10
|
-
const CODEX_RUN_STATE = path.join(__dirname, '..', 'runtime', 'codex-run-state.mjs');
|
|
11
10
|
const QUOTA_CHECK = path.join(__dirname, '..', 'runtime', 'quota-check.mjs');
|
|
12
11
|
|
|
13
12
|
// Group keys say which part of the kit a file belongs to; they decide where its hash is
|
|
@@ -28,41 +27,27 @@ function put(out, rel, content, group) {
|
|
|
28
27
|
out.set(rel, { content: Buffer.from(content), group });
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
// Every levi skill runs only when the user invokes it
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const root = path.posix.join(dir, skillName(usecase.id));
|
|
30
|
+
// Every levi skill runs only when the user invokes it, which the frontmatter flag enforces.
|
|
31
|
+
function addSkill(out, usecase, runRules) {
|
|
32
|
+
const root = path.posix.join(SKILL_DIR, skillName(usecase.id));
|
|
35
33
|
for (const rel of walk(usecase.dir, true)) {
|
|
36
34
|
let content = fs.readFileSync(path.join(usecase.dir, rel));
|
|
37
35
|
if (rel === 'SKILL.md') content = joinSections(setField(content.toString('utf8'), 'disable-model-invocation', 'true'), runRules);
|
|
38
36
|
put(out, path.posix.join(root, rel), content, usecaseGroup(usecase.id));
|
|
39
37
|
}
|
|
40
|
-
// The quota guard in the run rules calls this helper
|
|
38
|
+
// The quota guard in the run rules calls this helper.
|
|
41
39
|
put(out, path.posix.join(root, 'scripts/quota-check.mjs'), fs.readFileSync(QUOTA_CHECK), usecaseGroup(usecase.id));
|
|
42
|
-
if (dir === CODEX_SKILL_DIR) {
|
|
43
|
-
put(out, path.posix.join(root, 'agents/openai.yaml'), CODEX_POLICY, usecaseGroup(usecase.id));
|
|
44
|
-
// The source skills remain portable Markdown. Codex gets this small durable-state
|
|
45
|
-
// helper so its dedicated runners can resume an interrupted run from files.
|
|
46
|
-
put(out, path.posix.join(root, 'scripts/codex-run-state.mjs'), fs.readFileSync(CODEX_RUN_STATE), usecaseGroup(usecase.id));
|
|
47
|
-
}
|
|
48
40
|
}
|
|
49
41
|
|
|
50
|
-
// `prepare` adapts an agent
|
|
51
|
-
function addAgents(out, agents,
|
|
52
|
-
for (const
|
|
53
|
-
const target = AGENT_TARGETS[tool];
|
|
54
|
-
for (const agent of agents) put(out, path.posix.join(target.dir, agent.name + target.ext), target.render(prepare(agent, tool)), group);
|
|
55
|
-
}
|
|
42
|
+
// `prepare` adapts an agent before it is rendered (team agents get their role skills).
|
|
43
|
+
function addAgents(out, agents, group, prepare = (agent) => agent) {
|
|
44
|
+
for (const agent of agents) put(out, path.posix.join(AGENT_DIR, `${agent.name}.md`), renderAgent(prepare(agent)), group);
|
|
56
45
|
}
|
|
57
46
|
|
|
58
47
|
// The `levi` entry point is generated from whatever usecases are installed.
|
|
59
|
-
function addRouter(out, usecases, team
|
|
48
|
+
function addRouter(out, usecases, team) {
|
|
60
49
|
if (!usecases.length) return;
|
|
61
|
-
|
|
62
|
-
const root = path.posix.join(dir, ROUTER_NAME);
|
|
63
|
-
put(out, path.posix.join(root, 'SKILL.md'), renderRouter(dir, usecases, team), 'router');
|
|
64
|
-
if (dir === CODEX_SKILL_DIR) put(out, path.posix.join(root, 'agents/openai.yaml'), CODEX_POLICY, 'router');
|
|
65
|
-
}
|
|
50
|
+
put(out, path.posix.join(SKILL_DIR, ROUTER_NAME, 'SKILL.md'), renderRouter(SKILL_DIR, usecases, team), 'router');
|
|
66
51
|
}
|
|
67
52
|
|
|
68
53
|
// `ids` plus every usecase they require, directly or not, each once.
|
|
@@ -77,10 +62,10 @@ function withRequired(byId, ids) {
|
|
|
77
62
|
return all;
|
|
78
63
|
}
|
|
79
64
|
|
|
80
|
-
// The files a clean install of `ids` (and what they require)
|
|
65
|
+
// The files a clean install of `ids` (and what they require) would contain: Map of
|
|
81
66
|
// project-relative path to { content, group }. Nothing is written here. Usecases that are a team
|
|
82
67
|
// role's skill are always installed, since the team always is and its agents rely on them.
|
|
83
|
-
function build(kit, ids
|
|
68
|
+
function build(kit, ids) {
|
|
84
69
|
const byId = new Map(kit.usecases.map((u) => [u.id, u]));
|
|
85
70
|
const out = new Map();
|
|
86
71
|
const missing = [];
|
|
@@ -93,11 +78,11 @@ function build(kit, ids, tools) {
|
|
|
93
78
|
}
|
|
94
79
|
const usecase = byId.get(id);
|
|
95
80
|
present.push(usecase);
|
|
96
|
-
|
|
97
|
-
addAgents(out, usecase.agents,
|
|
81
|
+
addSkill(out, usecase, kit.runRules);
|
|
82
|
+
addAgents(out, usecase.agents, usecaseGroup(id));
|
|
98
83
|
}
|
|
99
|
-
addRouter(out, present, kit.team
|
|
100
|
-
addAgents(out, kit.team,
|
|
84
|
+
addRouter(out, present, kit.team);
|
|
85
|
+
addAgents(out, kit.team, 'team', (agent) => withRoleSkills(agent, present, SKILL_DIR));
|
|
101
86
|
return { files: out, missing, ids: present.map((u) => u.id) };
|
|
102
87
|
}
|
|
103
88
|
|
package/src/lib/sync.js
CHANGED
|
@@ -98,10 +98,10 @@ function recordFiles(actions, ids) {
|
|
|
98
98
|
return config;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Brings the project in line with the kit for `ids
|
|
101
|
+
// Brings the project in line with the kit for `ids`, touching only files the user
|
|
102
102
|
// has not changed. `previous` is the stored config. With dryRun nothing is written.
|
|
103
|
-
function sync(projectDir, ids,
|
|
104
|
-
const desired = build(loadKit(), ids
|
|
103
|
+
function sync(projectDir, ids, previous, { force = false, dryRun = false } = {}) {
|
|
104
|
+
const desired = build(loadKit(), ids);
|
|
105
105
|
const actions = plan(projectDir, desired, trackedFiles(previous), force);
|
|
106
106
|
if (!dryRun) apply(projectDir, actions);
|
|
107
107
|
return { actions, missing: desired.missing, ...recordFiles(actions, desired.ids) };
|
package/src/lib/tools.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const TOOL_INFO = {
|
|
5
|
-
claude: { label: 'Claude Code', invoke: '/' },
|
|
6
|
-
codex: { label: 'Codex', invoke: '$' },
|
|
7
|
-
copilot: { label: 'Copilot', invoke: '/' },
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Claude Code reads only .claude/skills; Codex reads .agents/skills; Copilot reads both
|
|
11
|
-
// of those, so it only needs its own copy when Claude is not selected.
|
|
12
|
-
function skillDirs(tools) {
|
|
13
|
-
const dirs = new Set();
|
|
14
|
-
if (tools.includes('claude')) dirs.add('.claude/skills');
|
|
15
|
-
if (tools.includes('codex')) dirs.add('.agents/skills');
|
|
16
|
-
if (tools.includes('copilot') && !tools.includes('claude')) dirs.add('.agents/skills');
|
|
17
|
-
return [...dirs];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// The skill folder an agent of `tool` reads: Copilot uses .claude/skills when Claude is installed.
|
|
21
|
-
function skillDirFor(tool, tools) {
|
|
22
|
-
return tool === 'claude' || (tool === 'copilot' && tools.includes('claude')) ? '.claude/skills' : '.agents/skills';
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Codex ignores SKILL.md frontmatter flags and reads its invocation policy from this file.
|
|
26
|
-
const CODEX_SKILL_DIR = '.agents/skills';
|
|
27
|
-
const CODEX_POLICY = 'policy:\n allow_implicit_invocation: false\n';
|
|
1
|
+
// levi installs for Claude Code only: skills go to .claude/skills, subagents to .claude/agents.
|
|
2
|
+
const SKILL_DIR = '.claude/skills';
|
|
3
|
+
const AGENT_DIR = '.claude/agents';
|
|
28
4
|
|
|
29
5
|
// Subagents are picked from their description, so scope them to levi to keep the agent
|
|
30
6
|
// from reaching for them on requests that did not go through levi.
|
|
@@ -34,65 +10,18 @@ function agentDescription(agent) {
|
|
|
34
10
|
return `${text} Used only when ${by} delegates to it; never select it for other requests.`;
|
|
35
11
|
}
|
|
36
12
|
|
|
37
|
-
// Tool-neutral capabilities and model tiers (see agents.js), mapped
|
|
38
|
-
// keeps the
|
|
13
|
+
// Tool-neutral capabilities and model tiers (see agents.js), mapped to Claude Code. Omitting
|
|
14
|
+
// `tools` keeps the defaults, including MCP servers, which an explicit list would cut off.
|
|
39
15
|
const CLAUDE_TOOLS = { read: ['Read', 'Grep', 'Glob'], edit: ['Edit', 'Write'], execute: ['Bash'], web: ['WebFetch', 'WebSearch'] };
|
|
40
|
-
const COPILOT_TOOLS = { read: ['read', 'search'], edit: ['edit'], execute: ['execute'], web: ['web'] };
|
|
41
16
|
const CLAUDE_MODELS = { strong: 'opus', standard: 'sonnet', fast: 'haiku' };
|
|
42
|
-
const CODEX_EFFORT = { strong: 'high', standard: 'medium', fast: 'low' };
|
|
43
|
-
|
|
44
|
-
function mapTools(tools, table) {
|
|
45
|
-
return tools.flatMap((t) => table[t]);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function tomlString(text) {
|
|
49
|
-
return '"""\n' + text.replace(/\\/g, '\\\\').replace(/"""/g, '\\"""').trim() + '\n"""';
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function renderMarkdown(agent, extra) {
|
|
53
|
-
return ['---', `name: ${agent.name}`, `description: ${JSON.stringify(agentDescription(agent))}`, ...extra, '---', '', agent.body.trim(), ''].join(
|
|
54
|
-
'\n'
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
17
|
|
|
58
|
-
function
|
|
18
|
+
function renderAgent(agent) {
|
|
59
19
|
const extra = [];
|
|
60
|
-
if (agent.tools) extra.push(`tools: ${
|
|
20
|
+
if (agent.tools) extra.push(`tools: ${agent.tools.flatMap((t) => CLAUDE_TOOLS[t]).join(', ')}`);
|
|
61
21
|
if (agent.model) extra.push(`model: ${CLAUDE_MODELS[agent.model]}`);
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Copilot model names change often, so agents keep the user's selected model.
|
|
66
|
-
function renderCopilot(agent) {
|
|
67
|
-
const extra = agent.tools ? [`tools: ${JSON.stringify(mapTools(agent.tools, COPILOT_TOOLS))}`] : [];
|
|
68
|
-
return renderMarkdown(agent, extra);
|
|
22
|
+
return ['---', `name: ${agent.name}`, `description: ${JSON.stringify(agentDescription(agent))}`, ...extra, '---', '', agent.body.trim(), ''].join('\n');
|
|
69
23
|
}
|
|
70
24
|
|
|
71
|
-
|
|
72
|
-
function renderToml(agent) {
|
|
73
|
-
const lines = [`name = ${JSON.stringify(agent.name)}`, `description = ${JSON.stringify(agentDescription(agent))}`];
|
|
74
|
-
if (agent.model) lines.push(`model_reasoning_effort = "${CODEX_EFFORT[agent.model]}"`);
|
|
75
|
-
if (agent.tools) {
|
|
76
|
-
const writes = agent.tools.includes('edit') || agent.tools.includes('execute');
|
|
77
|
-
lines.push(`sandbox_mode = "${writes ? 'workspace-write' : 'read-only'}"`);
|
|
78
|
-
}
|
|
79
|
-
lines.push(`developer_instructions = ${tomlString(agent.body)}`, '');
|
|
80
|
-
return lines.join('\n');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const AGENT_TARGETS = {
|
|
84
|
-
claude: { dir: '.claude/agents', ext: '.md', render: renderClaude },
|
|
85
|
-
codex: { dir: '.codex/agents', ext: '.toml', render: renderToml },
|
|
86
|
-
copilot: { dir: '.github/agents', ext: '.agent.md', render: renderCopilot },
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
function invocationHelp(tools) {
|
|
90
|
-
return tools
|
|
91
|
-
.map((tool) => {
|
|
92
|
-
const { label, invoke } = TOOL_INFO[tool];
|
|
93
|
-
return ` ${label.padEnd(11)} ${invoke}levi <request> ${invoke}levi-<usecase> <request>`;
|
|
94
|
-
})
|
|
95
|
-
.join('\n');
|
|
96
|
-
}
|
|
25
|
+
const INVOCATION_HELP = ' /levi <request> /levi-<usecase> <request>';
|
|
97
26
|
|
|
98
|
-
module.exports = {
|
|
27
|
+
module.exports = { SKILL_DIR, AGENT_DIR, renderAgent, INVOCATION_HELP };
|