levi-gear 0.0.0-stage → 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 +130 -2
- package/agents/_team-protocol.md +34 -0
- package/agents/designer.md +25 -0
- package/agents/developer.md +23 -0
- package/agents/pm.md +25 -0
- package/agents/qa.md +24 -0
- package/agents/teamlead.md +26 -0
- package/bin/levi.js +2 -0
- package/package.json +16 -4
- package/src/cli.js +51 -0
- package/src/commands/init.js +43 -0
- package/src/commands/list.js +18 -0
- package/src/commands/status.js +17 -0
- package/src/commands/update.js +29 -0
- package/src/lib/agents.js +55 -0
- package/src/lib/config.js +27 -0
- package/src/lib/desired-state.js +77 -0
- package/src/lib/frontmatter.js +36 -0
- package/src/lib/report.js +21 -0
- package/src/lib/router.js +38 -0
- package/src/lib/sync.js +110 -0
- package/src/lib/tools.js +93 -0
- package/src/lib/usecases.js +70 -0
- package/usecases/.gitkeep +0 -0
- package/usecases/brainstorming/SKILL.md +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nguyen Quang Linh
|
|
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
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# levi-gear
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An agentic kit for AI agents. Each **usecase** is a self-contained workflow (a skill, optionally with subagents) that gets installed for Claude Code, Codex and GitHub Copilot, together with a shared **team** of role agents that usecases can delegate to.
|
|
4
|
+
|
|
5
|
+
Requires Node.js 18 or newer. There are no runtime dependencies.
|
|
6
|
+
|
|
7
|
+
**Full documentation: [docs/](docs/README.md)**: installation, usage, updating, the CLI reference and more.
|
|
8
|
+
|
|
9
|
+
## Install into a project
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx levi-gear@latest init # all usecases, all tools
|
|
13
|
+
npx levi-gear@latest init brainstorming # only some usecases
|
|
14
|
+
npx levi-gear@latest init --tools claude,codex # only some tools
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Installed files are recorded in `.levi.json`. Commit the generated folders and `.levi.json` so teammates get everything by cloning.
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
| Command | What it does |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `levi init [usecase...] [--tools claude,codex,copilot]` | Install usecases (all by default) for the chosen tools |
|
|
24
|
+
| `levi update [--force [path...]]` | Refresh installed files to this package version, keeping files you changed |
|
|
25
|
+
| `levi status` | Show what `update` would do, without changing anything |
|
|
26
|
+
| `levi list` | List usecases in the kit and print how to invoke them |
|
|
27
|
+
|
|
28
|
+
## Using it
|
|
29
|
+
|
|
30
|
+
levi only runs when you ask for it. A prompt that does not start with the levi command is handled by your tool as usual.
|
|
31
|
+
|
|
32
|
+
| Tool | Let levi pick the usecase | Call a usecase directly |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Claude Code | `/levi <request>` | `/levi-<usecase> <request>` |
|
|
35
|
+
| Copilot | `/levi <request>` | `/levi-<usecase> <request>` |
|
|
36
|
+
| Codex | `$levi <request>` | `$levi-<usecase> <request>` |
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
`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.
|
|
41
|
+
|
|
42
|
+
## The team
|
|
43
|
+
|
|
44
|
+
Every install includes the team agents from `agents/`. Usecases delegate to them; they never run on their own and never call each other.
|
|
45
|
+
|
|
46
|
+
| Agent | Role |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `levi-pm` | Spec and acceptance criteria, scope, task assignments, progress and risks, plan approval, final acceptance and release notes |
|
|
49
|
+
| `levi-teamlead` | Architecture, database and migrations, conventions, task breakdown and estimates, code review, CI/CD |
|
|
50
|
+
| `levi-developer` | Implements tasks, writes unit and integration tests |
|
|
51
|
+
| `levi-designer` | User flows, wireframes, screens in SVG and HTML prototypes, design tokens, states, accessibility, handoff notes |
|
|
52
|
+
| `levi-qa` | Test plans and test cases from the spec, E2E and automated tests, bug reports, quality sign-off |
|
|
53
|
+
|
|
54
|
+
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`, `design/`, `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.
|
|
55
|
+
|
|
56
|
+
## Update
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx levi-gear@latest update
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The installed files are yours: edit them to fit your project. `update` never overwrites or deletes a file you changed. At install time levi records a hash of every file it writes in `.levi.json` (commit it), and `update` compares each file with that hash:
|
|
63
|
+
|
|
64
|
+
| State of the file | What `update` does |
|
|
65
|
+
|---|---|
|
|
66
|
+
| Untouched | Replaces it with the new version, or deletes it if the kit dropped it |
|
|
67
|
+
| You changed it | Keeps your file and ignores the kit's version |
|
|
68
|
+
| You deleted it | Does not recreate it |
|
|
69
|
+
| New in the kit | Adds it |
|
|
70
|
+
| Path already exists and was not written by levi | Keeps your file and ignores the kit's version |
|
|
71
|
+
|
|
72
|
+
`levi status` shows what `update` would do without changing anything. To take the kit version of a file you customized, run `levi update --force <path>` (or `--force` alone for all of them).
|
|
73
|
+
|
|
74
|
+
levi does not merge: a file you changed is yours from then on and stops receiving kit updates until you run `--force` on it.
|
|
75
|
+
|
|
76
|
+
## Where things go
|
|
77
|
+
|
|
78
|
+
| Tool | Skill | Subagents |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| Claude Code | `.claude/skills/levi/`, `.claude/skills/levi-<usecase>/` | `.claude/agents/levi-<usecase>-<role>.md` |
|
|
81
|
+
| Codex | `.agents/skills/levi/`, `.agents/skills/levi-<usecase>/` | `.codex/agents/levi-<usecase>-<role>.toml` |
|
|
82
|
+
| Copilot | reads `.claude/skills` and `.agents/skills` (gets `.agents/skills` itself only if Claude is not selected) | `.github/agents/levi-<usecase>-<role>.agent.md` |
|
|
83
|
+
|
|
84
|
+
## Authoring a usecase
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
usecases/<id>/
|
|
88
|
+
SKILL.md # entry point; frontmatter name: levi-<id>, description
|
|
89
|
+
references/, scripts/ # optional, copied along with the skill
|
|
90
|
+
agents/<role>.md # optional subagents; frontmatter name: levi-<id>-<role>, description
|
|
91
|
+
agents/<role>.md # team agents shared by all usecases; frontmatter name: levi-<role>
|
|
92
|
+
agents/_*.md # partials appended to every team agent
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Agent frontmatter (usecase and team agents alike):
|
|
96
|
+
|
|
97
|
+
| Field | Values | Claude Code | Codex | Copilot |
|
|
98
|
+
|---|---|---|---|---|
|
|
99
|
+
| `name`, `description` | required | as is | as is | as is |
|
|
100
|
+
| `tools` | comma list of `read`, `edit`, `execute`, `web`; omit for the tool's defaults | `Read, Grep, Glob` / `Edit, Write` / `Bash` / `WebFetch, WebSearch` | `sandbox_mode = "read-only"` without `edit`/`execute`, else `"workspace-write"` | `read, search` / `edit` / `execute` / `web` |
|
|
101
|
+
| `model` | `strong`, `standard`, `fast`; omit to inherit | `opus` / `sonnet` / `haiku` | `model_reasoning_effort` `high` / `medium` / `low` | not set (keeps the user's model) |
|
|
102
|
+
|
|
103
|
+
An explicit `tools` list also cuts off MCP tools on Claude Code and Copilot, so leave it out for agents that need a browser or other MCP servers.
|
|
104
|
+
|
|
105
|
+
- Every usecase is manual-only: the installer sets `disable-model-invocation: true` in the installed `SKILL.md` (Claude Code, Copilot) and writes `agents/openai.yaml` with `allow_implicit_invocation: false` (Codex). The tool never triggers it by itself.
|
|
106
|
+
- 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.
|
|
107
|
+
- 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.
|
|
108
|
+
- The installer appends a note to each subagent description so the tool delegates to it only through its usecase.
|
|
109
|
+
- Subagent files use the same format for every tool; the installer converts them (Codex needs TOML).
|
|
110
|
+
- 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.
|
|
111
|
+
- Write everything in the repo in English: usecase files, code, comments and docs. Requests to the entry point can still be in any language.
|
|
112
|
+
- Test in a scratch project with `node /path/to/levi-gear/bin/levi.js init`, then `npm version <patch|minor>` and `npm publish`.
|
|
113
|
+
|
|
114
|
+
## Customize
|
|
115
|
+
|
|
116
|
+
Edit the installed files directly, for example `.claude/agents/levi-qa.md` to add your project's test conventions. `update` keeps them (see Update). To keep a file out of levi's control entirely, copy it to a name without the `levi-` prefix. A copy is not managed by levi: it is not manual-only unless you set that yourself, and `/levi` does not list it.
|
|
117
|
+
|
|
118
|
+
## Contributing
|
|
119
|
+
|
|
120
|
+
Commit messages, branch names and pull requests are written in English, using short conventional prefixes (`feat:`, `fix:`, `docs:`).
|
|
121
|
+
|
|
122
|
+
## Status
|
|
123
|
+
|
|
124
|
+
Checked in the real clients (Claude Code 2.1.276, Codex 0.154.0 and GitHub Copilot CLI 1.0.91):
|
|
125
|
+
|
|
126
|
+
- The installed skills and agents are picked up.
|
|
127
|
+
- A prompt without the levi command does not use levi.
|
|
128
|
+
- `/levi` (Claude Code, Copilot) and `$levi` (Codex) route a request to the matching usecase.
|
|
129
|
+
- The team agents run when a usecase delegates to them (Claude Code and Copilot run the full `brainstorming` flow; Codex runs a team agent when asked).
|
|
130
|
+
|
|
131
|
+
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.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
## Team protocol
|
|
2
|
+
|
|
3
|
+
You are one member of the levi team: `levi-pm`, `levi-teamlead`, `levi-developer`, `levi-designer` and `levi-qa`. A levi usecase (a skill or a workflow) runs the team: it calls each member in turn. The PM records who owns each task in `status.md`; the workflow follows those assignments. No member calls another.
|
|
4
|
+
|
|
5
|
+
- **Do not delegate.** Never spawn or call another agent, including other team members. If the task needs another role, say so in your report and the workflow will route it.
|
|
6
|
+
- **Stay in your role.** Do the part of the task that belongs to you. When you notice work that belongs to another role, list it under "Handoffs" instead of doing it.
|
|
7
|
+
- **Hand off through files.** Other members do not see your conversation; they see only what you write. Put every decision, artifact and open question in the work folder.
|
|
8
|
+
- **Work folder.** Use the folder the workflow gives you. If it gives none, use `docs/levi/<short-slug>/` at the project root. Standard files:
|
|
9
|
+
|
|
10
|
+
| File | Owner |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `spec.md` | PM: requirements and acceptance criteria |
|
|
13
|
+
| `status.md` | PM: task assignments, progress, decisions, risks, blockers |
|
|
14
|
+
| `design/` | Designer: SVG files, HTML prototypes, `design-notes.md` |
|
|
15
|
+
| `architecture.md` | Teamlead: technical design and decisions |
|
|
16
|
+
| `tasks.md` | Teamlead: task breakdown and estimates |
|
|
17
|
+
| `review.md` | Teamlead: code review findings |
|
|
18
|
+
| `test-plan.md` | QA: test plan and test cases |
|
|
19
|
+
| `test-report.md` | QA: results, bugs, sign-off |
|
|
20
|
+
|
|
21
|
+
Edit only the files you own. Read the others as input.
|
|
22
|
+
- **Never ask the user directly.** You run without the user in the loop. When information is missing, finish what you can and return the questions.
|
|
23
|
+
- **Language.** Write artifacts in the language of the request, unless the project already uses another one for its docs. Code, identifiers and commit messages stay in English.
|
|
24
|
+
- **Do not guess.** Mark assumptions as assumptions. Do not invent requirements, data, or results you did not observe.
|
|
25
|
+
|
|
26
|
+
End every reply with this report:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
**Status:** DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT
|
|
30
|
+
**Summary:** one or two sentences
|
|
31
|
+
**Files:** files you created or changed
|
|
32
|
+
**Handoffs:** work for other roles, or "none"
|
|
33
|
+
**Questions:** open questions for the user, or "none"
|
|
34
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: levi-designer
|
|
3
|
+
description: UI/UX designer of the levi team. Designs and revises user interfaces, working mainly in SVG files and HTML prototypes - user flows, wireframes, screens, design tokens, states and handoff specs for developers.
|
|
4
|
+
tools: read, edit, web
|
|
5
|
+
model: standard
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are the designer. You decide how the product looks and how people move through it, and you hand developers a design they can build without guessing.
|
|
9
|
+
|
|
10
|
+
## Responsibilities
|
|
11
|
+
|
|
12
|
+
- **Flows and wireframes.** Start from the user stories in `spec.md`: map the user flow and wireframe the screens before adding detail.
|
|
13
|
+
- **Screens.** Produce the designs as SVG files in `design/`. For full screens, also provide an HTML/CSS prototype when it helps developers build it and QA compare against it.
|
|
14
|
+
- **Design tokens.** Define colors, typography, spacing, radii and shadows once, and use them everywhere. Reuse the project's existing tokens when it has them.
|
|
15
|
+
- **States.** Cover every state a screen can be in: default, hover, focus, active, disabled, loading, empty, error, and success.
|
|
16
|
+
- **Responsive.** Show how each screen adapts at mobile, tablet and desktop widths.
|
|
17
|
+
- **Accessibility.** Meet WCAG 2.1 AA: text contrast, visible focus, touch targets of at least 44px, and meaning that does not rely on color alone.
|
|
18
|
+
- **Handoff.** Write `design/design-notes.md`: tokens, component list, measurements, behavior and the assets developers need.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- SVG files must be valid and readable: name layers and groups after what they are, use the tokens, and avoid embedded raster images unless the asset requires one.
|
|
23
|
+
- Keep a consistent visual language across screens. A new component needs a reason the existing ones do not cover.
|
|
24
|
+
- Do not invent product content or data. Use what the spec gives you, and mark placeholders as placeholders.
|
|
25
|
+
- When you revise a design, note what changed and why in `design-notes.md`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: levi-developer
|
|
3
|
+
description: Fullstack developer of the levi team. Implements assigned tickets and tasks following the teamlead's architecture and conventions, and writes unit and integration tests for the code it changes.
|
|
4
|
+
model: standard
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a fullstack developer. You implement the tasks you are given, the way the teamlead designed them, and you prove they work with tests.
|
|
8
|
+
|
|
9
|
+
## Responsibilities
|
|
10
|
+
|
|
11
|
+
- **Implement.** Build the assigned task from `tasks.md`, following `architecture.md`, the project's conventions and the design in `design/`.
|
|
12
|
+
- **Test.** Write unit tests for the logic you add or change, and integration tests where your change crosses a boundary (API, database, another module). A test must be able to fail on a real bug.
|
|
13
|
+
- **Self-check.** Before handing off, run the build, the linter and the tests that cover your change, and report the real results.
|
|
14
|
+
- **Review fixes.** Address every finding in `review.md` that concerns your work, or explain why not.
|
|
15
|
+
- **Docs.** Update the technical docs of the code you changed.
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
- Do not change the architecture, the database schema or a public API contract on your own. If the design does not fit, stop and raise it for the teamlead.
|
|
20
|
+
- Do not guess at unclear requirements. Implement what is clear and return the questions.
|
|
21
|
+
- Never weaken, skip or delete a test to make it pass. A failing test is either a bug in the code or a mismatch with the spec; say which.
|
|
22
|
+
- No placeholder implementations, fake data or mocks standing in for the real behavior.
|
|
23
|
+
- Keep the change scoped to the task. Note unrelated problems under "Handoffs" instead of fixing them.
|
package/agents/pm.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: levi-pm
|
|
3
|
+
description: Project manager of the levi team. Turns a request into a spec with acceptance criteria, keeps scope, progress, risks and tickets, approves plans, and accepts the product before it is delivered to the end user.
|
|
4
|
+
tools: read, edit
|
|
5
|
+
model: standard
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are the project manager. You own the outcome: what gets built, in what order, and whether it is ready to hand to the end user. You do not write code, you do not make technical decisions, and you do not call other agents: you assign the work and the workflow carries out the assignment.
|
|
9
|
+
|
|
10
|
+
## Responsibilities
|
|
11
|
+
|
|
12
|
+
- **Requirements.** Turn the request into `spec.md`: goal, users, scope, out of scope, user stories, and acceptance criteria that can be checked one by one. Until the team has a dedicated analyst, this is your job.
|
|
13
|
+
- **Clarification.** List every gap that would change what gets built: unclear rules, missing states, edge cases, priorities. Return them as questions instead of filling them in.
|
|
14
|
+
- **Scope.** Decide priority. When the request changes mid-way, record the change, its cost and the decision in `status.md`.
|
|
15
|
+
- **Assignment.** Decide which role owns each task in `tasks.md` and in what order, and record it in the assignments table of `status.md` (task ID, assignee role, status). You only assign; the workflow reads the table and dispatches the agents.
|
|
16
|
+
- **Plan approval.** Review `architecture.md`, `tasks.md` and the design against `spec.md`. Approve, or reject with the exact mismatch.
|
|
17
|
+
- **Progress.** Keep `status.md` current: done, in progress, blocked (and by what), risks and their mitigation.
|
|
18
|
+
- **Acceptance.** Before delivery, check every acceptance criterion against `test-report.md` and the product. Accept only when each criterion has evidence. Write release notes for the end user.
|
|
19
|
+
|
|
20
|
+
## Rules
|
|
21
|
+
|
|
22
|
+
- Acceptance criteria describe observable behavior, not implementation.
|
|
23
|
+
- A plan that does not cover an acceptance criterion is not approved.
|
|
24
|
+
- Never mark something done without evidence from QA or the Teamlead.
|
|
25
|
+
- Escalate a risk as soon as you see it, with an owner and a proposed action.
|
package/agents/qa.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: levi-qa
|
|
3
|
+
description: QA engineer of the levi team. Ensures quality independently of the developers - writes test plans and test cases from the spec, runs manual and E2E tests on the UI, writes automated tests, reports bugs, and signs off quality.
|
|
4
|
+
model: standard
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are the QA engineer. You check that the product does what the spec says, independently of how it was built. Your value comes from that independence.
|
|
8
|
+
|
|
9
|
+
## Responsibilities
|
|
10
|
+
|
|
11
|
+
- **Test plan.** Write `test-plan.md` from `spec.md` and the design: scope, approach, environments, and test cases. Each test case has an ID, the acceptance criterion it covers, preconditions, steps, and the expected result.
|
|
12
|
+
- **Coverage.** Every acceptance criterion has at least one test case. Cover the happy path, edge cases, invalid input, error states and permissions.
|
|
13
|
+
- **E2E testing.** Run the test cases against the real UI, through the project's E2E runner or a browser tool when one is available.
|
|
14
|
+
- **Automation.** Write automated E2E and acceptance tests for the cases worth repeating. Developers own unit tests; you own E2E and acceptance tests.
|
|
15
|
+
- **Visual check.** Compare the UI against the files in `design/` and report mismatches. The designer confirms what is intended.
|
|
16
|
+
- **Bugs.** Report each bug in `test-report.md` with steps to reproduce, expected and actual result, severity, and evidence. Verify the fix when it lands, and rerun regression tests.
|
|
17
|
+
- **Sign-off.** Summarize what passed, what failed and what was not tested, then give the PM a clear go or no-go.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- Write test cases from the spec and the design, not from the implementation. Do not read the application code to decide what a test expects.
|
|
22
|
+
- Do not change application code. If a test fails, report the bug; do not fix it.
|
|
23
|
+
- Never adjust an expected result to match what the product does. If you think the spec is wrong, raise it as a question for the PM.
|
|
24
|
+
- Report only results you actually observed, with the real exit code or evidence. Untested is not passed.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: levi-teamlead
|
|
3
|
+
description: Teamlead and senior developer of the levi team. Owns the technical side - system design, database, project structure, conventions, task breakdown and estimates, and code review before merge.
|
|
4
|
+
tools: read, edit, execute, web
|
|
5
|
+
model: strong
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are the teamlead, the most senior developer on the team. You make the technical decisions and set the path the developers follow. You do not implement tickets yourself unless the workflow asks you to.
|
|
9
|
+
|
|
10
|
+
## Responsibilities
|
|
11
|
+
|
|
12
|
+
- **Architecture.** Write `architecture.md`: components and how they interact, data flow, technology choices with the trade-off behind each, and the decisions that are hard to reverse.
|
|
13
|
+
- **Data.** Design the database schema and every migration. Any schema change goes through you.
|
|
14
|
+
- **Structure and conventions.** Define the folder structure, naming, coding conventions and API contracts. Follow what the project already does before introducing anything new.
|
|
15
|
+
- **Task breakdown.** Write `tasks.md`: small tasks, each with a goal, the files it touches, done criteria, dependencies, and an estimate. A developer must be able to start a task without guessing.
|
|
16
|
+
- **Estimates.** Give a range and the assumptions behind it, and name the riskiest task.
|
|
17
|
+
- **Code review.** Review the change for correctness, security (input validation, authorization, secrets), performance, and fit with the architecture. Write findings in `review.md`, graded critical / warning / suggestion, each with a concrete fix. You are the gate before merge.
|
|
18
|
+
- **Unblocking.** Answer the technical questions developers raise, and update `architecture.md` when the answer changes the design.
|
|
19
|
+
- **Delivery pipeline.** Own CI/CD and deployment configuration until the team has a dedicated DevOps role.
|
|
20
|
+
|
|
21
|
+
## Rules
|
|
22
|
+
|
|
23
|
+
- Prefer the simplest design that meets the spec. Do not build for requirements that are not in it.
|
|
24
|
+
- Every task traces back to something in `spec.md` or `architecture.md`.
|
|
25
|
+
- In review, a critical finding blocks the merge. Do not soften it.
|
|
26
|
+
- When you review code you also designed, judge it against the spec, not against your own intent.
|
package/bin/levi.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "levi-gear",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An agentic kit: Agent Skills for Claude Code, Codex and Copilot, installable via npm",
|
|
5
|
+
"bin": {
|
|
6
|
+
"levi": "./bin/levi.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"agents",
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"usecases"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT"
|
|
18
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const { init } = require('./commands/init');
|
|
2
|
+
const { update } = require('./commands/update');
|
|
3
|
+
const { list } = require('./commands/list');
|
|
4
|
+
const { status } = require('./commands/status');
|
|
5
|
+
const { kitVersion } = require('./lib/usecases');
|
|
6
|
+
|
|
7
|
+
const HELP = `levi ${kitVersion()}
|
|
8
|
+
|
|
9
|
+
Usage: levi <command>
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
init [usecase...] [--tools claude,codex,copilot]
|
|
13
|
+
Install usecases (all by default) for the chosen tools
|
|
14
|
+
update [--force [path...]]
|
|
15
|
+
Refresh installed files to this package version. Files you changed are kept;
|
|
16
|
+
--force overwrites them (all, or only the given paths)
|
|
17
|
+
status Show what update would do, without changing anything
|
|
18
|
+
list List usecases available in the kit
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
function main(argv) {
|
|
22
|
+
const [command, ...rest] = argv;
|
|
23
|
+
const projectDir = process.cwd();
|
|
24
|
+
try {
|
|
25
|
+
switch (command) {
|
|
26
|
+
case 'init':
|
|
27
|
+
return init(projectDir, rest);
|
|
28
|
+
case 'update':
|
|
29
|
+
return update(projectDir, rest);
|
|
30
|
+
case 'status':
|
|
31
|
+
return status(projectDir);
|
|
32
|
+
case 'list':
|
|
33
|
+
return list(projectDir);
|
|
34
|
+
case undefined:
|
|
35
|
+
case '-h':
|
|
36
|
+
case '--help':
|
|
37
|
+
return console.log(HELP);
|
|
38
|
+
case '-v':
|
|
39
|
+
case '--version':
|
|
40
|
+
return console.log(kitVersion());
|
|
41
|
+
default:
|
|
42
|
+
console.error(`Unknown command: ${command}\n\n${HELP}`);
|
|
43
|
+
process.exitCode = 1;
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error(err.message);
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = { main };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const config = require('../lib/config');
|
|
2
|
+
const { sync } = require('../lib/sync');
|
|
3
|
+
const { printReport } = require('../lib/report');
|
|
4
|
+
const { listUsecases, kitVersion } = require('../lib/usecases');
|
|
5
|
+
const { TOOLS, invocationHelp } = require('../lib/tools');
|
|
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
|
+
}
|
|
18
|
+
|
|
19
|
+
function init(projectDir, argv) {
|
|
20
|
+
const { names, tools: requested } = parseArgs(argv);
|
|
21
|
+
const existing = config.read(projectDir) || { tools: null, usecases: {}, router: { files: {} }, team: { files: {} } };
|
|
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(', ')}`);
|
|
26
|
+
process.exitCode = 1;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const wanted = names.length ? names : listUsecases().map((u) => u.id);
|
|
30
|
+
const ids = [...new Set([...Object.keys(existing.usecases), ...wanted])];
|
|
31
|
+
const result = sync(projectDir, ids, tools, existing);
|
|
32
|
+
config.write(projectDir, { version: kitVersion(), tools, usecases: result.usecases, router: result.router, team: result.team });
|
|
33
|
+
console.log(`Installed ${Object.keys(result.usecases).length} usecase(s) for: ${tools.join(', ')}`);
|
|
34
|
+
for (const id of Object.keys(result.usecases)) console.log(` - ${id}`);
|
|
35
|
+
printReport(result.actions);
|
|
36
|
+
if (Object.keys(result.usecases).length) console.log(`\nInvoke with:\n${invocationHelp(tools)}`);
|
|
37
|
+
if (result.missing.length) {
|
|
38
|
+
console.error(`Not found in kit: ${result.missing.join(', ')}`);
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = { init };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const config = require('../lib/config');
|
|
2
|
+
const { listUsecases } = require('../lib/usecases');
|
|
3
|
+
const { TOOLS, invocationHelp } = require('../lib/tools');
|
|
4
|
+
|
|
5
|
+
function list(projectDir) {
|
|
6
|
+
const usecases = listUsecases();
|
|
7
|
+
if (!usecases.length) console.log('No usecases in the kit yet.');
|
|
8
|
+
for (const u of usecases) {
|
|
9
|
+
const roles = u.agents.length ? ` [agents: ${u.agents.map((a) => a.name).join(', ')}]` : '';
|
|
10
|
+
console.log(`${u.id}${roles}\n ${u.description}`);
|
|
11
|
+
}
|
|
12
|
+
if (usecases.length) {
|
|
13
|
+
const installed = config.read(projectDir);
|
|
14
|
+
console.log(`\nInvoke with:\n${invocationHelp(installed ? installed.tools : TOOLS)}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { list };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const config = require('../lib/config');
|
|
2
|
+
const { sync } = require('../lib/sync');
|
|
3
|
+
const { printReport } = require('../lib/report');
|
|
4
|
+
|
|
5
|
+
// Shows what `update` would do, without writing anything.
|
|
6
|
+
function status(projectDir) {
|
|
7
|
+
const existing = config.read(projectDir);
|
|
8
|
+
if (!existing) {
|
|
9
|
+
console.error(`No ${config.CONFIG_FILE} found. Run "levi init" first.`);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const { actions } = sync(projectDir, Object.keys(existing.usecases), existing.tools, existing, { dryRun: true });
|
|
14
|
+
printReport(actions, { dryRun: true });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { status };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const config = require('../lib/config');
|
|
2
|
+
const { sync } = require('../lib/sync');
|
|
3
|
+
const { printReport } = require('../lib/report');
|
|
4
|
+
const { kitVersion } = require('../lib/usecases');
|
|
5
|
+
const { invocationHelp } = require('../lib/tools');
|
|
6
|
+
|
|
7
|
+
// `--force` alone overwrites every file the user changed; with paths it only overwrites those.
|
|
8
|
+
function parseForce(argv) {
|
|
9
|
+
const paths = argv.filter((a) => a !== '--force');
|
|
10
|
+
if (!argv.includes('--force')) return false;
|
|
11
|
+
return paths.length ? new Set(paths) : true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function update(projectDir, argv = []) {
|
|
15
|
+
const existing = config.read(projectDir);
|
|
16
|
+
if (!existing) {
|
|
17
|
+
console.error(`No ${config.CONFIG_FILE} found. Run "levi init" first.`);
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const result = sync(projectDir, Object.keys(existing.usecases), existing.tools, existing, { force: parseForce(argv) });
|
|
22
|
+
config.write(projectDir, { version: kitVersion(), tools: existing.tools, usecases: result.usecases, router: result.router, team: result.team });
|
|
23
|
+
console.log(`Updated ${existing.version} -> ${kitVersion()} (${Object.keys(result.usecases).length} usecase(s))`);
|
|
24
|
+
printReport(result.actions);
|
|
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${invocationHelp(existing.tools)}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = { update };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { parse } = require('./frontmatter');
|
|
4
|
+
|
|
5
|
+
const PREFIX = 'levi-';
|
|
6
|
+
const TEAM_DIR = path.join(__dirname, '..', '..', 'agents');
|
|
7
|
+
// Files in agents/ starting with "_" are not agents: they are appended to every team agent.
|
|
8
|
+
const PARTIAL = '_';
|
|
9
|
+
|
|
10
|
+
// Tool-neutral fields. The installer maps them to each tool in tools.js.
|
|
11
|
+
const CAPABILITIES = ['read', 'edit', 'execute', 'web'];
|
|
12
|
+
const MODEL_TIERS = ['strong', 'standard', 'fast'];
|
|
13
|
+
|
|
14
|
+
function parseList(value) {
|
|
15
|
+
return value ? value.split(',').map((s) => s.trim()).filter(Boolean) : null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Reads one agent file. `owner` is the skill that delegates to it, or null for team agents.
|
|
19
|
+
function readAgent(file, label, expectedName, owner, appendix = '') {
|
|
20
|
+
const { data, body } = parse(fs.readFileSync(file, 'utf8'));
|
|
21
|
+
if (data.name !== expectedName) {
|
|
22
|
+
throw new Error(`${label}: name must be "${expectedName}", got "${data.name}"`);
|
|
23
|
+
}
|
|
24
|
+
if (!data.description) throw new Error(`${label}: missing description`);
|
|
25
|
+
const tools = parseList(data.tools);
|
|
26
|
+
const badTools = (tools || []).filter((t) => !CAPABILITIES.includes(t));
|
|
27
|
+
if (badTools.length) {
|
|
28
|
+
throw new Error(`${label}: unknown tools ${badTools.join(', ')}; use ${CAPABILITIES.join(', ')}`);
|
|
29
|
+
}
|
|
30
|
+
if (data.model && !MODEL_TIERS.includes(data.model)) {
|
|
31
|
+
throw new Error(`${label}: unknown model "${data.model}"; use ${MODEL_TIERS.join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
name: data.name,
|
|
35
|
+
description: data.description,
|
|
36
|
+
body: appendix ? `${body.trim()}\n\n${appendix.trim()}\n` : body,
|
|
37
|
+
owner,
|
|
38
|
+
tools,
|
|
39
|
+
model: data.model || null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function loadTeam() {
|
|
44
|
+
if (!fs.existsSync(TEAM_DIR)) return [];
|
|
45
|
+
const files = fs.readdirSync(TEAM_DIR).filter((f) => f.endsWith('.md')).sort();
|
|
46
|
+
const appendix = files
|
|
47
|
+
.filter((f) => f.startsWith(PARTIAL))
|
|
48
|
+
.map((f) => fs.readFileSync(path.join(TEAM_DIR, f), 'utf8'))
|
|
49
|
+
.join('\n\n');
|
|
50
|
+
return files
|
|
51
|
+
.filter((f) => !f.startsWith(PARTIAL))
|
|
52
|
+
.map((f) => readAgent(path.join(TEAM_DIR, f), `agents/${f}`, PREFIX + f.slice(0, -3), null, appendix));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = { PREFIX, CAPABILITIES, MODEL_TIERS, readAgent, loadTeam };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const CONFIG_FILE = '.levi.json';
|
|
5
|
+
|
|
6
|
+
// Early configs listed files as an array; hashes are unknown there, so each file reads as null.
|
|
7
|
+
function normalize(entry) {
|
|
8
|
+
if (!entry) return { files: {} };
|
|
9
|
+
const files = Array.isArray(entry.files) ? Object.fromEntries(entry.files.map((p) => [p, null])) : entry.files || {};
|
|
10
|
+
return { ...entry, files };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function read(projectDir) {
|
|
14
|
+
const file = path.join(projectDir, CONFIG_FILE);
|
|
15
|
+
if (!fs.existsSync(file)) return null;
|
|
16
|
+
const data = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
17
|
+
data.usecases = Object.fromEntries(Object.entries(data.usecases || {}).map(([id, e]) => [id, normalize(e)]));
|
|
18
|
+
data.router = normalize(data.router);
|
|
19
|
+
data.team = normalize(data.team);
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function write(projectDir, config) {
|
|
24
|
+
fs.writeFileSync(path.join(projectDir, CONFIG_FILE), JSON.stringify(config, null, 2) + '\n');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = { CONFIG_FILE, read, write };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { ROUTER_NAME, skillName } = require('./usecases');
|
|
4
|
+
const { CODEX_SKILL_DIR, CODEX_POLICY, skillDirs, AGENT_TARGETS } = require('./tools');
|
|
5
|
+
const { setField } = require('./frontmatter');
|
|
6
|
+
const { renderRouter } = require('./router');
|
|
7
|
+
|
|
8
|
+
// Group keys say which part of the kit a file belongs to; they decide where its hash is
|
|
9
|
+
// recorded in .levi.json.
|
|
10
|
+
const usecaseGroup = (id) => `usecase:${id}`;
|
|
11
|
+
|
|
12
|
+
// Relative posix paths of every file under `dir`, leaving out the top-level agents/ folder
|
|
13
|
+
// (those become subagent files elsewhere).
|
|
14
|
+
function walk(dir, skipAgents, base = '') {
|
|
15
|
+
return fs.readdirSync(path.join(dir, base), { withFileTypes: true }).flatMap((entry) => {
|
|
16
|
+
const rel = base ? `${base}/${entry.name}` : entry.name;
|
|
17
|
+
if (entry.isDirectory()) return skipAgents && !base && entry.name === 'agents' ? [] : walk(dir, skipAgents, rel);
|
|
18
|
+
return [rel];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function put(out, rel, content, group) {
|
|
23
|
+
out.set(rel, { content: Buffer.from(content), group });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Every levi skill runs only when the user invokes it: Claude Code and Copilot read the
|
|
27
|
+
// frontmatter flag, Codex reads agents/openai.yaml (only written where Codex looks).
|
|
28
|
+
function addSkill(out, usecase, dir) {
|
|
29
|
+
const root = path.posix.join(dir, skillName(usecase.id));
|
|
30
|
+
for (const rel of walk(usecase.dir, true)) {
|
|
31
|
+
let content = fs.readFileSync(path.join(usecase.dir, rel));
|
|
32
|
+
if (rel === 'SKILL.md') content = setField(content.toString('utf8'), 'disable-model-invocation', 'true');
|
|
33
|
+
put(out, path.posix.join(root, rel), content, usecaseGroup(usecase.id));
|
|
34
|
+
}
|
|
35
|
+
if (dir === CODEX_SKILL_DIR) put(out, path.posix.join(root, 'agents/openai.yaml'), CODEX_POLICY, usecaseGroup(usecase.id));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function addAgents(out, agents, tools, group) {
|
|
39
|
+
for (const tool of tools) {
|
|
40
|
+
const target = AGENT_TARGETS[tool];
|
|
41
|
+
for (const agent of agents) put(out, path.posix.join(target.dir, agent.name + target.ext), target.render(agent), group);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The `levi` entry point is generated from whatever usecases are installed.
|
|
46
|
+
function addRouter(out, usecases, team, tools) {
|
|
47
|
+
if (!usecases.length) return;
|
|
48
|
+
for (const dir of skillDirs(tools)) {
|
|
49
|
+
const root = path.posix.join(dir, ROUTER_NAME);
|
|
50
|
+
put(out, path.posix.join(root, 'SKILL.md'), renderRouter(dir, usecases, team), 'router');
|
|
51
|
+
if (dir === CODEX_SKILL_DIR) put(out, path.posix.join(root, 'agents/openai.yaml'), CODEX_POLICY, 'router');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The files a clean install of `ids` for `tools` would contain: Map of project-relative path
|
|
56
|
+
// to { content, group }. Nothing is written here.
|
|
57
|
+
function build(kit, ids, tools) {
|
|
58
|
+
const byId = new Map(kit.usecases.map((u) => [u.id, u]));
|
|
59
|
+
const out = new Map();
|
|
60
|
+
const missing = [];
|
|
61
|
+
const present = [];
|
|
62
|
+
for (const id of ids) {
|
|
63
|
+
if (!byId.has(id)) {
|
|
64
|
+
missing.push(id);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const usecase = byId.get(id);
|
|
68
|
+
present.push(usecase);
|
|
69
|
+
for (const dir of skillDirs(tools)) addSkill(out, usecase, dir);
|
|
70
|
+
addAgents(out, usecase.agents, tools, usecaseGroup(id));
|
|
71
|
+
}
|
|
72
|
+
addRouter(out, present, kit.team, tools);
|
|
73
|
+
addAgents(out, kit.team, tools, 'team');
|
|
74
|
+
return { files: out, missing, ids: present.map((u) => u.id) };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { build, usecaseGroup };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const FRONTMATTER = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
2
|
+
const BLOCK_SCALAR = /^([>|])[+-]?$/;
|
|
3
|
+
|
|
4
|
+
// Flat "key: value" pairs, plus YAML folded (>) and literal (|) multi-line values.
|
|
5
|
+
function parse(text) {
|
|
6
|
+
const match = FRONTMATTER.exec(text);
|
|
7
|
+
if (!match) return { data: {}, body: text };
|
|
8
|
+
const data = {};
|
|
9
|
+
const lines = match[1].split(/\r?\n/);
|
|
10
|
+
for (let i = 0; i < lines.length; i++) {
|
|
11
|
+
const idx = lines[i].indexOf(':');
|
|
12
|
+
if (idx === -1) continue;
|
|
13
|
+
const key = lines[i].slice(0, idx).trim();
|
|
14
|
+
let value = lines[i].slice(idx + 1).trim();
|
|
15
|
+
const block = BLOCK_SCALAR.exec(value);
|
|
16
|
+
if (block) {
|
|
17
|
+
const parts = [];
|
|
18
|
+
while (i + 1 < lines.length && /^\s+\S|^\s*$/.test(lines[i + 1])) parts.push(lines[++i].trim());
|
|
19
|
+
value = parts.join(block[1] === '>' ? ' ' : '\n').trim();
|
|
20
|
+
} else {
|
|
21
|
+
value = value.replace(/^["']|["']$/g, '');
|
|
22
|
+
}
|
|
23
|
+
if (key) data[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return { data, body: match[2] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Sets a single-line top-level field, replacing any existing line with the same key.
|
|
29
|
+
function setField(text, key, value) {
|
|
30
|
+
const match = FRONTMATTER.exec(text);
|
|
31
|
+
if (!match) return text;
|
|
32
|
+
const lines = match[1].split(/\r?\n/).filter((line) => !line.startsWith(`${key}:`));
|
|
33
|
+
return `---\n${[...lines, `${key}: ${value}`].join('\n')}\n---\n${match[2]}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { parse, setField };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const paths = (actions, op) => actions.filter((a) => a.op === op).map((a) => a.path);
|
|
2
|
+
|
|
3
|
+
function section(title, list) {
|
|
4
|
+
if (list.length) console.log(`\n${title}\n${list.map((p) => ` ${p}`).join('\n')}`);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// Summarizes what a sync did (or, for dryRun, would do) to the user's files.
|
|
8
|
+
function printReport(actions, { dryRun = false } = {}) {
|
|
9
|
+
const verb = dryRun ? ['Would add', 'update', 'remove'] : ['Added', 'updated', 'removed'];
|
|
10
|
+
const count = (op) => actions.filter((a) => a.op === op).length;
|
|
11
|
+
console.log(`${verb[0]} ${count('add')}, ${verb[1]} ${count('update')}, ${verb[2]} ${count('remove')} file(s).`);
|
|
12
|
+
section('Changed by you (kept as is):', paths(actions, 'customized'));
|
|
13
|
+
section('Already exist and are not managed by levi (kept as is):', paths(actions, 'conflict'));
|
|
14
|
+
section('Deleted by you (not recreated):', paths(actions, 'keep-deleted'));
|
|
15
|
+
section('No longer in the kit, kept because you changed them:', paths(actions, 'orphan'));
|
|
16
|
+
if (actions.some((a) => ['customized', 'conflict', 'keep-deleted'].includes(a.op))) {
|
|
17
|
+
console.log('\nTo take the kit version of a file instead: levi update --force [path...]');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { printReport };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const { skillName } = require('./usecases');
|
|
2
|
+
|
|
3
|
+
// Builds the SKILL.md of the `levi` entry point for one skill directory. Usecase skills
|
|
4
|
+
// are manual-only, so the router cannot call them through the tool's skill mechanism; it
|
|
5
|
+
// reads their SKILL.md by path instead.
|
|
6
|
+
function renderRouter(skillDir, usecases, team) {
|
|
7
|
+
const teamNames = team.map((a) => `\`${a.name}\``).join(', ');
|
|
8
|
+
const catalog = usecases
|
|
9
|
+
.map((u) => `- **${u.id}**: ${u.description}\n File: \`${skillDir}/${skillName(u.id)}/SKILL.md\``)
|
|
10
|
+
.join('\n');
|
|
11
|
+
return `---
|
|
12
|
+
name: levi
|
|
13
|
+
description: ${JSON.stringify('Entry point of the levi kit. Run only when the user explicitly invokes it with a request; picks the matching levi usecase and runs it.')}
|
|
14
|
+
argument-hint: "<request>"
|
|
15
|
+
disable-model-invocation: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# levi
|
|
19
|
+
|
|
20
|
+
The request is whatever the user typed after invoking \`levi\`. It may be written in any language; answer in the language the user used.
|
|
21
|
+
|
|
22
|
+
## Usecases
|
|
23
|
+
|
|
24
|
+
${catalog}
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
1. If the request is empty, list the usecases above with one line each and ask what the user wants. Stop.
|
|
29
|
+
2. Pick the usecase whose description best matches the request.
|
|
30
|
+
- No usecase fits: say so, list the available usecases, and stop. Do not improvise a substitute.
|
|
31
|
+
- One or more fit: run the best match. When several fit about equally, take the one whose description names the request's main goal most specifically. Do not ask the user to choose.
|
|
32
|
+
- Say which one you chose in one line, and when another was a close match, name it and add that \`/levi-<usecase>\` runs it directly.
|
|
33
|
+
3. Read that usecase's file and follow it, treating the request as its input. Resolve relative paths in that file from its own directory. Do not call it through a skill tool: usecases are manual-only.
|
|
34
|
+
4. Use the usecase's subagents (\`${skillName('<usecase>')}-<role>\`)${teamNames ? ` and the levi team agents (${teamNames})` : ''} only as that usecase instructs.
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = { renderRouter };
|
package/src/lib/sync.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const { loadKit } = require('./usecases');
|
|
5
|
+
const { build } = require('./desired-state');
|
|
6
|
+
|
|
7
|
+
// Git may rewrite line endings (core.autocrlf), which must not count as a user edit, so text
|
|
8
|
+
// is hashed with CRLF folded to LF. Binary files (any NUL byte) are hashed as they are.
|
|
9
|
+
function sha(buf) {
|
|
10
|
+
const text = buf.includes(0) ? buf : Buffer.from(buf.toString('latin1').replace(/\r\n/g, '\n'), 'latin1');
|
|
11
|
+
return crypto.createHash('sha256').update(text).digest('hex');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Path -> hash recorded at install time (null when the config predates hashing).
|
|
15
|
+
function trackedFiles(config) {
|
|
16
|
+
const map = new Map();
|
|
17
|
+
const add = (entry) => Object.entries((entry && entry.files) || {}).forEach(([p, h]) => map.set(p, h));
|
|
18
|
+
Object.values(config.usecases || {}).forEach(add);
|
|
19
|
+
add(config.router);
|
|
20
|
+
add(config.team);
|
|
21
|
+
return map;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readHash(abs) {
|
|
25
|
+
return fs.existsSync(abs) && fs.statSync(abs).isFile() ? sha(fs.readFileSync(abs)) : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Decides what to do with one file levi wants to have. The recorded hash tells whether the
|
|
29
|
+
// user changed it since levi wrote it; a changed file is never overwritten without force.
|
|
30
|
+
function planWanted(p, wanted, recorded, diskHash, forced) {
|
|
31
|
+
const newHash = sha(wanted.content);
|
|
32
|
+
const base = { path: p, group: wanted.group, newHash, recorded };
|
|
33
|
+
if (diskHash === null) {
|
|
34
|
+
return recorded !== undefined && !forced ? { ...base, op: 'keep-deleted' } : { ...base, op: 'add' };
|
|
35
|
+
}
|
|
36
|
+
if (diskHash === newHash) return { ...base, op: 'same' };
|
|
37
|
+
if (recorded === undefined) return { ...base, op: forced ? 'update' : 'conflict' };
|
|
38
|
+
if (recorded !== null && diskHash === recorded) return { ...base, op: 'update' };
|
|
39
|
+
if (forced) return { ...base, op: 'update' };
|
|
40
|
+
return { ...base, op: 'customized' };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function plan(projectDir, desired, tracked, force) {
|
|
44
|
+
const forced = (p) => force === true || (force instanceof Set && force.has(p));
|
|
45
|
+
const actions = [];
|
|
46
|
+
for (const [p, wanted] of desired.files) {
|
|
47
|
+
const recorded = tracked.has(p) ? tracked.get(p) : undefined;
|
|
48
|
+
actions.push({ ...planWanted(p, wanted, recorded, readHash(path.join(projectDir, p)), forced(p)), content: wanted.content });
|
|
49
|
+
}
|
|
50
|
+
for (const [p, recorded] of tracked) {
|
|
51
|
+
if (desired.files.has(p)) continue;
|
|
52
|
+
const diskHash = readHash(path.join(projectDir, p));
|
|
53
|
+
if (diskHash === null) actions.push({ path: p, op: 'drop' });
|
|
54
|
+
else if (recorded !== null && diskHash === recorded) actions.push({ path: p, op: 'remove' });
|
|
55
|
+
else actions.push({ path: p, op: 'orphan' });
|
|
56
|
+
}
|
|
57
|
+
return actions;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Removes now-empty folders below the tool folders (.claude/skills/..., not .claude/skills).
|
|
61
|
+
function pruneEmptyDirs(projectDir, rel) {
|
|
62
|
+
let dir = path.posix.dirname(rel);
|
|
63
|
+
while (dir.split('/').length >= 3) {
|
|
64
|
+
const abs = path.join(projectDir, dir);
|
|
65
|
+
if (!fs.existsSync(abs) || fs.readdirSync(abs).length) return;
|
|
66
|
+
fs.rmdirSync(abs);
|
|
67
|
+
dir = path.posix.dirname(dir);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function writeFile(projectDir, rel, content) {
|
|
72
|
+
const abs = path.join(projectDir, rel);
|
|
73
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
74
|
+
fs.writeFileSync(abs, content);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function apply(projectDir, actions) {
|
|
78
|
+
for (const a of actions) {
|
|
79
|
+
if (a.op === 'add' || a.op === 'update') writeFile(projectDir, a.path, a.content);
|
|
80
|
+
else if (a.op === 'remove') {
|
|
81
|
+
fs.rmSync(path.join(projectDir, a.path), { force: true });
|
|
82
|
+
pruneEmptyDirs(projectDir, a.path);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// What .levi.json should remember: the hash of each file as levi last wrote it. A file
|
|
88
|
+
// the user changed keeps its old hash so it stays flagged; a path levi never owned is not tracked.
|
|
89
|
+
function recordFiles(actions, ids) {
|
|
90
|
+
const config = { usecases: {}, router: { files: {} }, team: { files: {} } };
|
|
91
|
+
for (const id of ids) config.usecases[id] = { files: {} };
|
|
92
|
+
for (const a of actions) {
|
|
93
|
+
if (!a.group || a.op === 'conflict') continue;
|
|
94
|
+
const hash = ['add', 'update', 'same'].includes(a.op) ? a.newHash : a.recorded;
|
|
95
|
+
const target = a.group.startsWith('usecase:') ? config.usecases[a.group.slice(8)] : config[a.group];
|
|
96
|
+
target.files[a.path] = hash;
|
|
97
|
+
}
|
|
98
|
+
return config;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Brings the project in line with the kit for `ids` and `tools`, touching only files the user
|
|
102
|
+
// has not changed. `previous` is the stored config. With dryRun nothing is written.
|
|
103
|
+
function sync(projectDir, ids, tools, previous, { force = false, dryRun = false } = {}) {
|
|
104
|
+
const desired = build(loadKit(), ids, tools);
|
|
105
|
+
const actions = plan(projectDir, desired, trackedFiles(previous), force);
|
|
106
|
+
if (!dryRun) apply(projectDir, actions);
|
|
107
|
+
return { actions, missing: desired.missing, ...recordFiles(actions, desired.ids) };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = { sync };
|
package/src/lib/tools.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const TOOLS = ['claude', 'codex', 'copilot'];
|
|
2
|
+
|
|
3
|
+
// `invoke` is the character that starts an explicit skill call in each tool.
|
|
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
|
+
// Codex ignores SKILL.md frontmatter flags and reads its invocation policy from this file.
|
|
21
|
+
const CODEX_SKILL_DIR = '.agents/skills';
|
|
22
|
+
const CODEX_POLICY = 'policy:\n allow_implicit_invocation: false\n';
|
|
23
|
+
|
|
24
|
+
// Subagents are picked from their description, so scope them to levi to keep the agent
|
|
25
|
+
// from reaching for them on requests that did not go through levi.
|
|
26
|
+
function agentDescription(agent) {
|
|
27
|
+
const by = agent.owner ? `the ${agent.owner} workflow` : 'a levi workflow';
|
|
28
|
+
const text = /[.!?]$/.test(agent.description) ? agent.description : `${agent.description}.`;
|
|
29
|
+
return `${text} Used only when ${by} delegates to it; never select it for other requests.`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Tool-neutral capabilities and model tiers (see agents.js), mapped per tool. Omitting `tools`
|
|
33
|
+
// keeps the tool's defaults, including MCP servers, which an explicit list would cut off.
|
|
34
|
+
const CLAUDE_TOOLS = { read: ['Read', 'Grep', 'Glob'], edit: ['Edit', 'Write'], execute: ['Bash'], web: ['WebFetch', 'WebSearch'] };
|
|
35
|
+
const COPILOT_TOOLS = { read: ['read', 'search'], edit: ['edit'], execute: ['execute'], web: ['web'] };
|
|
36
|
+
const CLAUDE_MODELS = { strong: 'opus', standard: 'sonnet', fast: 'haiku' };
|
|
37
|
+
const CODEX_EFFORT = { strong: 'high', standard: 'medium', fast: 'low' };
|
|
38
|
+
|
|
39
|
+
function mapTools(tools, table) {
|
|
40
|
+
return tools.flatMap((t) => table[t]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function tomlString(text) {
|
|
44
|
+
return '"""\n' + text.replace(/\\/g, '\\\\').replace(/"""/g, '\\"""').trim() + '\n"""';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function renderMarkdown(agent, extra) {
|
|
48
|
+
return ['---', `name: ${agent.name}`, `description: ${JSON.stringify(agentDescription(agent))}`, ...extra, '---', '', agent.body.trim(), ''].join(
|
|
49
|
+
'\n'
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function renderClaude(agent) {
|
|
54
|
+
const extra = [];
|
|
55
|
+
if (agent.tools) extra.push(`tools: ${mapTools(agent.tools, CLAUDE_TOOLS).join(', ')}`);
|
|
56
|
+
if (agent.model) extra.push(`model: ${CLAUDE_MODELS[agent.model]}`);
|
|
57
|
+
return renderMarkdown(agent, extra);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Copilot model names change often, so agents keep the user's selected model.
|
|
61
|
+
function renderCopilot(agent) {
|
|
62
|
+
const extra = agent.tools ? [`tools: ${JSON.stringify(mapTools(agent.tools, COPILOT_TOOLS))}`] : [];
|
|
63
|
+
return renderMarkdown(agent, extra);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Codex has no per-tool list: an agent that can neither edit nor execute runs read-only.
|
|
67
|
+
function renderToml(agent) {
|
|
68
|
+
const lines = [`name = ${JSON.stringify(agent.name)}`, `description = ${JSON.stringify(agentDescription(agent))}`];
|
|
69
|
+
if (agent.model) lines.push(`model_reasoning_effort = "${CODEX_EFFORT[agent.model]}"`);
|
|
70
|
+
if (agent.tools) {
|
|
71
|
+
const writes = agent.tools.includes('edit') || agent.tools.includes('execute');
|
|
72
|
+
lines.push(`sandbox_mode = "${writes ? 'workspace-write' : 'read-only'}"`);
|
|
73
|
+
}
|
|
74
|
+
lines.push(`developer_instructions = ${tomlString(agent.body)}`, '');
|
|
75
|
+
return lines.join('\n');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const AGENT_TARGETS = {
|
|
79
|
+
claude: { dir: '.claude/agents', ext: '.md', render: renderClaude },
|
|
80
|
+
codex: { dir: '.codex/agents', ext: '.toml', render: renderToml },
|
|
81
|
+
copilot: { dir: '.github/agents', ext: '.agent.md', render: renderCopilot },
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
function invocationHelp(tools) {
|
|
85
|
+
return tools
|
|
86
|
+
.map((tool) => {
|
|
87
|
+
const { label, invoke } = TOOL_INFO[tool];
|
|
88
|
+
return ` ${label.padEnd(11)} ${invoke}levi <request> ${invoke}levi-<usecase> <request>`;
|
|
89
|
+
})
|
|
90
|
+
.join('\n');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = { TOOLS, CODEX_SKILL_DIR, CODEX_POLICY, skillDirs, AGENT_TARGETS, invocationHelp };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { parse } = require('./frontmatter');
|
|
4
|
+
const { PREFIX, readAgent, loadTeam } = require('./agents');
|
|
5
|
+
|
|
6
|
+
const ROUTER_NAME = 'levi';
|
|
7
|
+
const KIT_DIR = path.join(__dirname, '..', '..', 'usecases');
|
|
8
|
+
|
|
9
|
+
function skillName(id) {
|
|
10
|
+
return PREFIX + id;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function kitVersion() {
|
|
14
|
+
return require('../../package.json').version;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function loadAgents(id, dir) {
|
|
18
|
+
const agentsDir = path.join(dir, 'agents');
|
|
19
|
+
if (!fs.existsSync(agentsDir)) return [];
|
|
20
|
+
return fs
|
|
21
|
+
.readdirSync(agentsDir)
|
|
22
|
+
.filter((f) => f.endsWith('.md'))
|
|
23
|
+
.map((file) =>
|
|
24
|
+
readAgent(path.join(agentsDir, file), `usecases/${id}/agents/${file}`, `${skillName(id)}-${file.slice(0, -3)}`, skillName(id))
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function load(id) {
|
|
29
|
+
const dir = path.join(KIT_DIR, id);
|
|
30
|
+
const skillFile = path.join(dir, 'SKILL.md');
|
|
31
|
+
if (!fs.existsSync(skillFile)) throw new Error(`usecases/${id}: missing SKILL.md`);
|
|
32
|
+
const { data } = parse(fs.readFileSync(skillFile, 'utf8'));
|
|
33
|
+
if (data.name !== skillName(id)) {
|
|
34
|
+
throw new Error(`usecases/${id}/SKILL.md: name must be "${skillName(id)}", got "${data.name}"`);
|
|
35
|
+
}
|
|
36
|
+
if (!data.description) throw new Error(`usecases/${id}/SKILL.md: missing description`);
|
|
37
|
+
return { id, dir, description: data.description, agents: loadAgents(id, dir) };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Every agent name must be unique across the team and all usecases, and a usecase id must not
|
|
41
|
+
// reuse a team role, or `levi-<id>` would name both a skill and an agent.
|
|
42
|
+
function checkNames(usecases, team) {
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
for (const agent of [...team, ...usecases.flatMap((u) => u.agents)]) {
|
|
45
|
+
if (seen.has(agent.name)) throw new Error(`Agent name "${agent.name}" is defined twice in the kit`);
|
|
46
|
+
seen.add(agent.name);
|
|
47
|
+
}
|
|
48
|
+
for (const u of usecases) {
|
|
49
|
+
if (seen.has(skillName(u.id))) throw new Error(`usecases/${u.id}: id clashes with team agent "${skillName(u.id)}"`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Loads and validates the whole kit, so a broken file fails before anything is touched.
|
|
54
|
+
function loadKit() {
|
|
55
|
+
const usecases = fs.existsSync(KIT_DIR)
|
|
56
|
+
? fs
|
|
57
|
+
.readdirSync(KIT_DIR, { withFileTypes: true })
|
|
58
|
+
.filter((e) => e.isDirectory())
|
|
59
|
+
.map((e) => load(e.name))
|
|
60
|
+
: [];
|
|
61
|
+
const team = loadTeam();
|
|
62
|
+
checkNames(usecases, team);
|
|
63
|
+
return { usecases, team };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function listUsecases() {
|
|
67
|
+
return loadKit().usecases;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { PREFIX, ROUTER_NAME, kitVersion, skillName, loadKit, listUsecases };
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: levi-brainstorming
|
|
3
|
+
description: Brainstorm any problem or idea with the PM and Teamlead and turn it into an execution plan - a list of small tasks, each with the team agent that owns it and an estimate in hours. Uses the project's spec in docs/specs/ as a basis when one exists; never creates or edits specs. Fits requests such as "brainstorm X", "how should we approach X", "break X into tasks and estimate it".
|
|
4
|
+
argument-hint: "<problem or idea to brainstorm>"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Brainstorming
|
|
8
|
+
|
|
9
|
+
Turn a problem into an execution plan. `levi-pm` frames the problem and owns the plan; `levi-teamlead` explores the approaches and breaks the work into tasks. You run them in turn, relay their questions to the user, and never do their part yourself. A plan with more than 10 tasks is a hard ticket: it gets a second, independent review before it is final.
|
|
10
|
+
|
|
11
|
+
The problem can be anything the team could work on: a feature, a refactor, a migration, a process change.
|
|
12
|
+
|
|
13
|
+
This usecase plans; it does not write specs. Never create or edit anything under `docs/specs/`. An existing spec is read-only input. If the user wants a spec written or changed, they will ask for it separately.
|
|
14
|
+
|
|
15
|
+
## Files
|
|
16
|
+
|
|
17
|
+
| File | Owner | Purpose |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `docs/brainstorming/<slug>.md` | PM | **The deliverable**: the plan |
|
|
20
|
+
| `docs/levi/<slug>/brief.md` | PM | Scratch: the problem framed in a few lines. Written only when there is no spec. Deleted at the end |
|
|
21
|
+
| `docs/levi/<slug>/architecture.md` | Teamlead | Scratch: approaches considered and the one chosen. Deleted at the end |
|
|
22
|
+
| `docs/levi/<slug>/tasks.md` | Teamlead | Scratch: task breakdown with suggested roles and estimates. Deleted at the end |
|
|
23
|
+
| `docs/levi/<slug>/status.md` | PM | Scratch: task assignments. Deleted at the end |
|
|
24
|
+
|
|
25
|
+
`<slug>` is a short kebab-case name for the problem, in English (for example `export-orders-csv`). Create folders as needed. Pass each agent the exact paths it should read and write. When the run finishes, only the plan is left behind (and the spec, untouched, if the project had one).
|
|
26
|
+
|
|
27
|
+
## Steps
|
|
28
|
+
|
|
29
|
+
1. **Intake.** The request is the problem. If it is empty, ask what to brainstorm and stop. Derive the slug and a plain-language problem name.
|
|
30
|
+
2. **Find the spec.** List `docs/specs/` and match files against the problem by name and title.
|
|
31
|
+
- One clear match: use it as the basis. Say which in one line.
|
|
32
|
+
- Two or more equally plausible: ask the user which one (or "none"), then continue.
|
|
33
|
+
- None: there is no spec, and the PM frames the problem itself in step 3.
|
|
34
|
+
3. **PM frames the problem.** Call `levi-pm` with the problem, the spec path if any, and the mode:
|
|
35
|
+
- *Spec exists:* read it as the basis, without editing it. Return only the gaps and questions that matter for this problem.
|
|
36
|
+
- *No spec:* write `docs/levi/<slug>/brief.md`: goal, users, scope, out of scope, what done looks like as checkable points, and open questions. Mark every assumption as an assumption. Do not write a spec.
|
|
37
|
+
|
|
38
|
+
From here on, "the basis" means the spec when there is one, otherwise `brief.md`.
|
|
39
|
+
4. **Teamlead explores.** Call `levi-teamlead` with the problem and the basis path. It reads the basis and the project, then writes `architecture.md`: two or three genuinely different approaches with their trade-offs, a recommendation, and the forks only the user can decide. It does not break the work down yet.
|
|
40
|
+
5. **Ask the user once.** Merge the questions from steps 3 and 4, drop duplicates, and ask them all in a single round (use the tool's structured question feature if it has one). Give each question two to four options with the recommended one first. Add one more question if `docs/brainstorming/<slug>.md` already exists: replace it, or write the new plan under another name. Skip this step when there are no questions. An unanswered question takes its recommended option, recorded as an assumption. After this step the user's part is done; do not ask again unless an agent is BLOCKED.
|
|
41
|
+
6. **Finalize the inputs.** Run these in parallel when the tool allows, with the user's answers as input:
|
|
42
|
+
- `levi-pm`, only when it wrote `brief.md`: fold the answers into it and clear the open questions that were answered.
|
|
43
|
+
- `levi-teamlead`: update `architecture.md` with the chosen approach, then write `tasks.md`. Every task is small (split anything over about 8 hours) and has: ID, goal, files or areas touched, done criteria, dependencies, the suggested role (`levi-pm`, `levi-teamlead`, `levi-developer`, `levi-designer` or `levi-qa`) and an estimate in hours. Include design, review, QA and acceptance tasks, not only implementation. Name the riskiest task.
|
|
44
|
+
7. **PM writes the plan.** Call `levi-pm` with the basis, `architecture.md` and `tasks.md`. It checks that every goal and done-criterion in the basis is covered by a task, decides the owner of each task (the Teamlead's suggestion unless it has a reason to change it), records the assignments in `status.md`, and writes `docs/brainstorming/<slug>.md` in the format below. The scratch files are deleted later, so the plan's Notes must carry the chosen approach, what was rejected and why, and the riskiest task.
|
|
45
|
+
- If the PM reports uncovered criteria, send them to `levi-teamlead` to add tasks, then call the PM once more. The PM must settle any criterion that is still uncovered by itself: add the missing task and assign it, or rule the criterion out of scope with a one-line note in the plan's Notes. It never edits the spec, and it does not leave a gap open.
|
|
46
|
+
8. **Review a hard plan.** Count the rows of the task table. With 10 tasks or fewer, skip to step 9. With more than 10, run an independent review, once:
|
|
47
|
+
- Use fresh agent calls that get only the paths of the basis and the plan, never the conversation, the scratch files or your own opinion of the plan. A new call starts with no memory of the earlier steps, which is what makes the review independent.
|
|
48
|
+
- First call `levi-teamlead` to review the plan: task size, dependencies and order, estimates, missing or redundant tasks, technical risk. It edits `docs/brainstorming/<slug>.md` in place and decides: it may change tasks, estimates and even the chosen approach, and its calls override the first round.
|
|
49
|
+
- Then call `levi-pm` as a second fresh call to review the result against the basis: coverage of every goal and done-criterion, owner of each task, the total and the agent list. The PM edits the same file, decides on scope, coverage and ownership, and writes the final version over the old one. Its calls override the first round and the Teamlead's review where they conflict. Each reply lists what changed in the review.
|
|
50
|
+
- The reviewers settle every point themselves, with their best judgment; they do not defer a point, hand it back as a question, or park it in Notes. Notes only add information to a decision already made, such as a changed approach and why, or an assumption behind it. Update the Notes to match the final plan. Do not start a second round.
|
|
51
|
+
9. **Clean up.** Delete `architecture.md`, `tasks.md`, `status.md` and `brief.md` (if it exists) from `docs/levi/<slug>/`, then remove the folder if it is now empty. Remove `docs/levi` too if that is empty. Delete only those files, and only after the plan is final. Keep the plan, and never touch the spec.
|
|
52
|
+
10. **Check and report.** Open the plan and confirm that the total equals the sum of the task estimates and that the agent list equals the agents in the task table; fix it if not. Tell the user the plan path, the spec used (if any), the total hours, the agents involved, whether the plan was reviewed (and what the review changed), and any assumption taken in place of an unanswered question.
|
|
53
|
+
|
|
54
|
+
## Plan format
|
|
55
|
+
|
|
56
|
+
`docs/brainstorming/<slug>.md`, written in the language of the request:
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
# <Problem name>
|
|
60
|
+
|
|
61
|
+
- **Total estimate:** <N> hours
|
|
62
|
+
- **Agents:** levi-pm, levi-teamlead, levi-developer
|
|
63
|
+
|
|
64
|
+
## Tasks
|
|
65
|
+
|
|
66
|
+
| # | Task | Agent | Estimate (h) | Depends on |
|
|
67
|
+
|---|---|---|---|---|
|
|
68
|
+
| 1 | <small, concrete task> | levi-teamlead | 2 | - |
|
|
69
|
+
| 2 | <small, concrete task> | levi-developer | 4 | 1 |
|
|
70
|
+
|
|
71
|
+
## Notes
|
|
72
|
+
|
|
73
|
+
<Only when there is something to add: the chosen approach and what was rejected, assumptions,
|
|
74
|
+
risks (the riskiest task), work that needs a human. Notes supplement the plan and never hold an
|
|
75
|
+
undecided point. Omit this whole section otherwise.>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- The total is the sum of the task estimates. It is agent working time, not the calendar duration, so tasks that can run in parallel are still added up.
|
|
79
|
+
- An estimate is the hours the assigned agent needs for that task, including checking its own work, in steps of 0.5 hours. It does not include waiting for the user.
|
|
80
|
+
- The agent list contains each agent that owns at least one task, once.
|