lean-agent-harness 0.0.0-stage → 1.2.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/AGENTS.md +33 -0
- package/CHANGELOG.md +31 -0
- package/CLAUDE.md +12 -0
- package/GLOSSARY.md +50 -0
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/adapters/opencode/commands/audit-code.md +5 -0
- package/adapters/opencode/commands/commit.md +5 -0
- package/adapters/opencode/commands/orchestrate.md +5 -0
- package/adapters/opencode/commands/plan-flow.md +5 -0
- package/adapters/opencode/commands/review.md +5 -0
- package/bin/cli.js +296 -0
- package/install.sh +247 -0
- package/manifest.tsv +25 -0
- package/package.json +51 -4
- package/profile-extras.txt +6 -0
- package/skills/audit-code/SKILL.md +14 -0
- package/skills/audit-code/agents/openai.yaml +2 -0
- package/skills/code-review/SKILL.md +42 -0
- package/skills/commit/SKILL.md +15 -0
- package/skills/commit/agents/openai.yaml +2 -0
- package/skills/db-migration/SKILL.md +40 -0
- package/skills/diagnosing-bugs/SKILL.md +32 -0
- package/skills/diagram-design/SKILL.md +43 -0
- package/skills/diagram-design/references/template.md +33 -0
- package/skills/humanizer/SKILL.md +30 -0
- package/skills/impeccable/SKILL.md +36 -0
- package/skills/orchestrate/SKILL.md +37 -0
- package/skills/orchestrate/agents/openai.yaml +2 -0
- package/skills/plan-flow/SKILL.md +37 -0
- package/skills/plan-flow/agents/openai.yaml +2 -0
- package/skills/review/SKILL.md +22 -0
- package/skills/review/agents/openai.yaml +2 -0
- package/skills/security-audit/SKILL.md +32 -0
- package/skills/testing/SKILL.md +28 -0
- package/templates/GLOSSARY.md +11 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Agent Configuration
|
|
2
|
+
|
|
3
|
+
Single source of truth for all coding agents. Engineering rigor, deterministic execution, zero-compromise delivery.
|
|
4
|
+
|
|
5
|
+
## 1. Core Principles
|
|
6
|
+
|
|
7
|
+
* **Communication:** Explain what you did, why, and the trade-offs, so the user can understand and decide. Offer an alternative only when it is a real option, with its cost. No filler or apologies.
|
|
8
|
+
* **Ubiquitous Language:** Read `GLOSSARY.md` (if present) before naming anything; keep business terms and code symbols 1:1. Register new domain entities and invariants there immediately.
|
|
9
|
+
* **Deep Modules:** High functional depth behind minimal interfaces. No shallow wrappers, anemic layers, or premature fragmentation.
|
|
10
|
+
* **One Question at a Time:** When scope is ambiguous, ask exactly ONE question on the current decision, with a default answerable in one word. Never list questions.
|
|
11
|
+
* **Manifest Pre-flight:** Never assume signatures, versions, or test commands. Read the active manifest (`package.json`, `go.mod`, `pyproject.toml`, `Cargo.toml`, `composer.json`, `Makefile`) first.
|
|
12
|
+
* **Test-First:** Write and run the test before the implementation: RED, then GREEN, then REFACTOR. Never claim a passing test you did not run.
|
|
13
|
+
* **Evidence:** Verification claims must quote the exact terminal summary line (e.g. `Tests: 28 passed, 28 total`).
|
|
14
|
+
* **Stubborn bugs:** use the `diagnosing-bugs` skill instead of blind patching.
|
|
15
|
+
|
|
16
|
+
## 2. Work Sizing
|
|
17
|
+
|
|
18
|
+
* **Inline:** ≤ 1 file, cosmetic, < 30 lines, auditable via `git diff`. Execute immediately.
|
|
19
|
+
* **Tracked:** architectural uncertainty, multi-step work, or **high-risk** change (auth/authz, data migration or deletion, secrets/config, public interface, concurrency). Use the workflow below, grouping cohesive feature-complete slices (migration + model + service + tests), never micro-slices.
|
|
20
|
+
* **State:** the plan and `- [ ]` checklist live in `.tasks/current.md` so a compacted session resumes without re-asking. Delete it after a clean `commit`.
|
|
21
|
+
* **Branch:** tracked work happens on `feature/<task-slug>`, never `main`/`master`.
|
|
22
|
+
|
|
23
|
+
Workflow skills (explicit invocation only): `plan-flow <task>` → `orchestrate` → `review` → `commit [hint]`; plus `audit-code [path]`. Skills are referenced by name; each agent resolves them from its own skills directory.
|
|
24
|
+
|
|
25
|
+
## 3. Hard Rules
|
|
26
|
+
|
|
27
|
+
* **Circuit Breaker:** After 2 consecutive failed fixes on one error: STOP, revert (`git checkout -- <files>`), re-read the full stack trace, state a new root-cause hypothesis before editing again.
|
|
28
|
+
* **Zero-Hang:** Never block on stdin: use non-interactive flags (`-y`, `--no-interaction`, `-m "<msg>"`); no interactive editors or `sudo`.
|
|
29
|
+
* **Strict Typing, no placeholders:** TypeScript: no `any`, explicit types. PHP: `declare(strict_types=1);` and typed signatures. Go: no bare `interface{}`, never discard errors with `_`. Python: full annotations/Pydantic. No stubs (`// ...`, `TODO: implement`), no dead or commented-out code, no AI attribution (`Co-Authored-By: Claude`).
|
|
30
|
+
* **Dependencies:** No installs (`npm i`, `pip install`, `go get`, `composer require`) unless the approved plan lists them.
|
|
31
|
+
* **Secrets:** Never read, print, or commit `.env*` (only `.env.example` for key names), SSH keys, `*.pem`/`*.key`, or `.git/*`. Define env vars as typed validated config.
|
|
32
|
+
* **Destructive commands** (`rm -rf`, DB drops/truncation, `git reset --hard`, `git push --force`) require explicit human confirmation.
|
|
33
|
+
* **Slice rollback:** a slice that fails its Definition of Done is reverted to the last clean passing state.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
|
+
|
|
5
|
+
## [1.2.0]
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `--profile core|full` in both installers. `core` skips the skills listed in `profile-extras.txt`.
|
|
10
|
+
- Risk tiers (`low` | `high`) on every planned slice, with a fresh-context verifier for high-risk slices.
|
|
11
|
+
- 400 changed-lines budget per slice, defined in `orchestrate` and enforced at `commit`.
|
|
12
|
+
- Verification evidence bound to a hash of the working diff, so it goes stale after any edit.
|
|
13
|
+
- `install.sh` env vars: `LAH_VERSION` pins a release tag, `LAH_SHA256` verifies the downloaded archive and aborts on mismatch.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Standing token cost reduced; each `SKILL.md` capped at 3000 bytes, with detail moved to `references/`.
|
|
18
|
+
- `diagram-design` split into a skill and `references/template.md`.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `install.sh --auto` selects the detected environments.
|
|
23
|
+
- Corrected the `curl` install URL.
|
|
24
|
+
- A divergent `AGENTS.md`/`CLAUDE.md` no longer overwrites an earlier `.bak`; later backups become `.bak.1`, `.bak.2`, and so on.
|
|
25
|
+
- `manifest.tsv` rows with the wrong column count now fail with the offending line number.
|
|
26
|
+
|
|
27
|
+
## [1.1.0]
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- `bin/cli.js` reworked and package metadata prepared for the first npm release.
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Claude Code Project Configuration
|
|
2
|
+
|
|
3
|
+
Single source of truth is defined in `AGENTS.md`. All directives, subagents, skills, and lifecycle commands apply here.
|
|
4
|
+
|
|
5
|
+
Read and adhere strictly to:
|
|
6
|
+
@AGENTS.md
|
|
7
|
+
|
|
8
|
+
## Fast Command Reference
|
|
9
|
+
- `/plan-flow <task>`: Read-only architecture analysis & ODD milestone checklist.
|
|
10
|
+
- `/orchestrate <task>`: Step-by-step implementation, RED-GREEN loop, and DoD validation.
|
|
11
|
+
- `/review [target]`: Risk-based git diff audit against SonarQube quality gates.
|
|
12
|
+
- `/commit [hint]`: Quality gate verification and atomic Conventional Commit.
|
package/GLOSSARY.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Domain Glossary & Ubiquitous Language
|
|
2
|
+
|
|
3
|
+
Single source of truth for the domain vocabulary of this project. Both human engineers and coding agents must align terminology here to prevent conceptual divergence and verbose circumlocution.
|
|
4
|
+
|
|
5
|
+
> **For client projects installed via this harness:** replace the harness terms below with your business domain vocabulary, keeping the table format. The installed `GLOSSARY.md` is your project's glossary, not this repo's.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Harness Core Entities & Concepts
|
|
10
|
+
|
|
11
|
+
| Term | Ubiquitous Definition | Canonical Representation | Constraints / Invariants |
|
|
12
|
+
| :--- | :--- | :--- | :--- |
|
|
13
|
+
| **Harness** | The portable rule + command + skill bundle deployed across coding agents. | `lean-agent-harness` root | Deployed files are package-derived; never hand-edit a deployed copy without syncing upstream. |
|
|
14
|
+
| **Target** | One deployment destination with its native layout. `agents` is the cross-tool `.agents/skills` location read by Pi, OpenCode, Codex, Copilot and Cursor; `claude` uses `.claude/skills`. | `target` column of `manifest.tsv` | Declared only in `manifest.tsv`; both installers read it. |
|
|
15
|
+
| **Manifest** | Tab-separated table mapping package sources to destinations per scope (local/global). | `manifest.tsv` | Single source for `bin/cli.js` and `install.sh`; `test/cli.test.js` asserts identical output trees. |
|
|
16
|
+
| **Adapter** | A static file that bridges one agent's native mechanism to a skill (OpenCode command stubs). | `adapters/` | Contains no rules, only a pointer to the skill. |
|
|
17
|
+
| **Instruction Stub** | A file that makes an agent read the shared rules (`AGENTS.md`, `CLAUDE.md`, `copilot-instructions.md`). | `file` rows in `manifest.tsv` | Content must derive from the package `AGENTS.md`; installed once per scope where the agent reads `AGENTS.md` natively; user customizations land in `.bak` on overwrite. |
|
|
18
|
+
| **ODD (Organic Driven Development)** | Decomposition style: complex work becomes small, feature-complete, reviewable milestone slices chained across PRs. | `plan-flow` output in `.tasks/current.md` | A slice must satisfy its DoD before the next starts. |
|
|
19
|
+
| **Slice** | One feature-complete ODD unit (e.g., migration + model + service + tests). | `- [ ] Slice N:` checklist item | No fragmented single-line micro-slices. |
|
|
20
|
+
| **DoD (Definition of Done)** | Verification gate: 0 linter/compiler errors, passing tests with cited terminal output, no debug residue, glossary-aligned naming, isolated `git status`. | `orchestrate` skill DoD; `commit` skill step 1 | Evidence without raw terminal output is invalid. |
|
|
21
|
+
| **RED / GREEN / REFACTOR** | Test-first cycle: prove the gap with a failing test, implement minimally to pass, refactor for SOLID. | `testing` skill | Never assert GREEN without running the runner. |
|
|
22
|
+
| **Workflow Skill** | A skill invoked explicitly (`plan-flow`, `orchestrate`, `review`, `audit-code`, `commit`). It carries `disable-model-invocation: true`, so its description costs no standing tokens. | `skills/<name>/SKILL.md` | Role instructions (Planner, Orchestrator) live inside the skill; no separate agent or command files. |
|
|
23
|
+
| **Skill** | A self-contained Agent Skills playbook (`name` + `description` frontmatter) loaded on demand. | `skills/<name>/SKILL.md` | `name` equals the folder; keep each around 70 lines or fewer. |
|
|
24
|
+
| **Inline Task** | Work small enough to skip planning ceremony (≤ 1 file, < 30 lines, cosmetic). | `AGENTS.md` § 2 | Auditable through `git diff` alone. |
|
|
25
|
+
| **Risk Tier** | `low` or `high` tag on each planned slice. `high` = a high-risk item named in `AGENTS.md` § 2 (auth/authz, data migration or deletion, secrets/config, public interface, concurrency). | `Risk:` field in `plan-flow` output | High-risk slices get a fresh-context verifier (`orchestrate`) and review (`review`); low-risk slices keep the single DoD gate. |
|
|
26
|
+
| **Change Budget** | Limit of 400 changed lines per work unit. | `orchestrate` § Change budget (enforced by `commit`) | Rule text lives only in `orchestrate`. |
|
|
27
|
+
| **Blocker** | A review finding (Blocker or Critical) that blocks `commit` until fixed. | `review` verdict | WARNING and SUGGESTION never block and never trigger fixes. |
|
|
28
|
+
| **Profile** | Installation subset: `full` (default) deploys every skill; `core` omits the skills listed in `profile-extras.txt`. | `--profile core|full` | Only the `skills` directory is filtered; rules and workflow skills always install; both installers must produce identical trees. |
|
|
29
|
+
| **Seed Glossary** | Minimal domain-glossary template deployed to client projects when they have none. | `templates/GLOSSARY.md` | At most 1500 bytes (token budget test); never overwrites an existing `GLOSSARY.md`. |
|
|
30
|
+
| **Source Override** | Testability hook: installers use `LAH_SOURCE` (shell) or `LAH_FAKE_HOME`/`LAH_FAKE_CWD` (CLI exports) in tests. | `install.sh`, `bin/cli.js` | Must never alter default behavior when unset. |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Architectural Seams & Boundaries
|
|
35
|
+
|
|
36
|
+
* **Seam 1 (SSOT):** `AGENTS.md` is the only normative rule set. `CLAUDE.md` and the workflow skills reference it; duplication of normative rules across files is a defect.
|
|
37
|
+
* **Seam 2 (Installer Parity):** Any supported environment must be deployable from both installers (`bin/cli.js` and `install.sh`) with equivalent file placement. Adding a target requires only a `manifest.tsv` row; the parity test enforces it.
|
|
38
|
+
* **Seam 3 (Coupling):** Behavior of the harness must be declarative (`manifest.tsv` driven). No per-platform copy-paste blocks in either installer; there are no transforms; files are copied verbatim.
|
|
39
|
+
* **Seam 4 (Token Budget):** Standing rules (`AGENTS.md`) cost ~0.8k tokens per session; skill descriptions add one line each, and workflow skills add none. Every rule added must earn its tokens by preventing a real, observed failure mode.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Deprecated / Forbidden Jargon
|
|
44
|
+
|
|
45
|
+
* *Do not say:* "the installer script things".
|
|
46
|
+
*Use instead:* "the shell installer (`install.sh`)" or "the CLI (`bin/cli.js`)".
|
|
47
|
+
* *Do not say:* "the md file with the rules".
|
|
48
|
+
*Use instead:* "`AGENTS.md` (SSOT)".
|
|
49
|
+
* *Do not say:* "the todo file".
|
|
50
|
+
*Use instead:* "`.tasks/current.md` (ephemeral execution state)".
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lnardev
|
|
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,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Lean Agent Harness (`lah`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One rule file and one skill format for **Claude Code**, **Pi**, **OpenCode**, **Codex**, **Cursor**, **Copilot** and **CommandCode**. Standing context is `AGENTS.md` (about 0.8k tokens) plus one line per skill.
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
Everything ships as [Agent Skills](https://agentskills.io) (`skills/<name>/SKILL.md`, with `name` and `description` frontmatter) plus a single `AGENTS.md`. There are no separate command or subagent files, so there is nothing to translate per tool.
|
|
10
|
+
|
|
11
|
+
* **Domain skills** (`testing`, `security-audit`, `db-migration`, `diagnosing-bugs`, `code-review`, `impeccable`, `humanizer`, `diagram-design`) load on demand when the task matches their description.
|
|
12
|
+
* **Workflow skills** (`plan-flow`, `orchestrate`, `review`, `audit-code`, `commit`) set `disable-model-invocation: true` (plus `agents/openai.yaml` for Codex). Claude Code, Pi, Cursor and Codex never offer them to the model, so their descriptions cost no tokens until you call them. OpenCode and Copilot ignore the flag and list them (one short line each). The Planner and Orchestrator roles live inside `plan-flow` and `orchestrate`. Slices tagged `Risk: high` are verified and reviewed in a fresh context; every `SKILL.md` stays under 3000 bytes and long detail loads from `references/`.
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
plan-flow <task> → orchestrate → review [target] → commit [hint] audit-code [path]
|
|
16
|
+
(read-only plan) (RED-GREEN, DoD) (audit git diff) (atomic commit) (security scan)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
How you invoke a workflow skill depends on the tool: `/plan-flow` in Claude Code, Cursor and OpenCode (through a command stub in `adapters/`), `/skill:plan-flow` in Pi, `$plan-flow` in Codex.
|
|
20
|
+
|
|
21
|
+
## Where files go
|
|
22
|
+
|
|
23
|
+
| Scope | Files |
|
|
24
|
+
| :--- | :--- |
|
|
25
|
+
| Project | `AGENTS.md`, `CLAUDE.md` (imports `@AGENTS.md`), `GLOSSARY.md` (only if missing) at the root; skills in `.claude/skills/` and `.agents/skills/`; OpenCode command stubs in `.opencode/commands/` |
|
|
26
|
+
| User (`--global`) | `~/.claude/{CLAUDE.md,AGENTS.md,skills}`, `~/.agents/skills`, `~/.pi/agent/AGENTS.md`, `~/.config/opencode/{AGENTS.md,commands}`, `~/.codex/AGENTS.md`, `~/.copilot/copilot-instructions.md`, `~/.commandcode/{AGENTS.md,skills}` |
|
|
27
|
+
|
|
28
|
+
`.agents/skills` is read natively by Pi, OpenCode, Codex, Copilot and Cursor. Claude Code reads `.claude/skills`. Every destination is a row in `manifest.tsv`, which both installers read.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx lean-agent-harness # into the current project
|
|
34
|
+
npx lean-agent-harness --global # into your home directory
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Without Node.js:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | bash
|
|
41
|
+
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | bash -s -- --global --auto
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`install.sh` accepts `--global`, `--local`, `--all`, `--auto`, `--profile core|full`, auto-detects existing environments and never blocks without a TTY. An existing `AGENTS.md`/`CLAUDE.md` that differs is saved as `.bak` before it is replaced; if a `.bak` already exists, the next one is `.bak.1`, `.bak.2`, and so on, so no version is lost. An existing `GLOSSARY.md` is never touched; a missing one is seeded from `templates/GLOSSARY.md`.
|
|
45
|
+
|
|
46
|
+
**Pinning and verifying the `curl` install.** The one-liner runs the `main` branch unless you pin it:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | LAH_VERSION=1.2.0 LAH_SHA256=<sha256-of-the-archive> bash -s -- --global --auto
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`LAH_VERSION` downloads that release tag. `LAH_SHA256` makes the installer abort, before deploying anything, if the archive does not match. Without it the installer says that the checksum is not verified. GitHub does not publish archive checksums, so compute the value once from a copy you trust, for example `shasum -a 256` on the archive of that tag. GitHub's generated archives are not guaranteed to stay byte-identical over time, so if a previously valid checksum stops matching, recompute it from a trusted copy before assuming tampering.
|
|
53
|
+
|
|
54
|
+
**Profiles.** `--profile core` skips the skills listed in `profile-extras.txt` (`impeccable`, `humanizer`, `diagram-design`, `db-migration`), whose descriptions cost standing tokens in every project. `full` is the default. Both installers read the same file.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx lean-agent-harness --global --profile core
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm test # installs with both installers and asserts identical output trees
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Repository layout
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
AGENTS.md Single source of rules
|
|
68
|
+
CLAUDE.md Imports AGENTS.md for Claude Code
|
|
69
|
+
GLOSSARY.md Harness vocabulary (this repo only)
|
|
70
|
+
templates/ GLOSSARY.md seed deployed to client projects when missing
|
|
71
|
+
manifest.tsv Destinations per target and scope (read by both installers)
|
|
72
|
+
profile-extras.txt Skills omitted by --profile core (read by both installers)
|
|
73
|
+
skills/ Domain and workflow skills
|
|
74
|
+
adapters/opencode/ Command stubs that point OpenCode slash commands at skills
|
|
75
|
+
bin/cli.js npx installer
|
|
76
|
+
install.sh curl installer
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Principles
|
|
80
|
+
|
|
81
|
+
* **Token economy:** short standing rules, on-demand skills, explicit-only workflows.
|
|
82
|
+
* **Slices (ODD):** complex work becomes small, feature-complete, reviewable slices tracked in `.tasks/current.md`.
|
|
83
|
+
* **Strict typing, no placeholders, dependency lockdown, confirmation before destructive commands.** Full text in `AGENTS.md`.
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT © [lnardev](https://github.com/lnardev)
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Lean Agent Harness — deployment CLI (npx).
|
|
6
|
+
*
|
|
7
|
+
* Manifest-driven installer: every supported environment is declared once in a
|
|
8
|
+
* declarative table and deployed by a single engine. No per-platform copy-paste.
|
|
9
|
+
*
|
|
10
|
+
* Modes:
|
|
11
|
+
* (default) deploy into the current project
|
|
12
|
+
* --global deploy into the user home (~/.claude, ~/.pi, ~/.config/opencode, ...)
|
|
13
|
+
*
|
|
14
|
+
* Flags: --help | -h | --version | -v | --global | -g | --local | -l
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const fs = require("fs");
|
|
18
|
+
const os = require("os");
|
|
19
|
+
const path = require("path");
|
|
20
|
+
|
|
21
|
+
const { version } = require("../package.json");
|
|
22
|
+
|
|
23
|
+
const PKG_ROOT = path.resolve(__dirname, "..");
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {Object} Entry
|
|
27
|
+
* @property {"file"|"dir"} kind file = instruction file (.bak on divergence); dir = mirrored directory
|
|
28
|
+
* @property {string} src Path relative to the package root
|
|
29
|
+
* @property {string} dest Path relative to the target base
|
|
30
|
+
* @property {string} mode "" or "if-missing" (file kind: never overwrite an existing dest)
|
|
31
|
+
*
|
|
32
|
+
* @typedef {Object} Target
|
|
33
|
+
* @property {string} name Human-readable label
|
|
34
|
+
* @property {string} base Destination base directory (project root or home)
|
|
35
|
+
* @property {Entry[]} entries
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const LABELS = {
|
|
39
|
+
core: "Core",
|
|
40
|
+
claude: "Claude Code",
|
|
41
|
+
agents: "Agent Skills (.agents: Pi · OpenCode · Codex · Copilot · Cursor)",
|
|
42
|
+
pi: "Pi",
|
|
43
|
+
opencode: "OpenCode",
|
|
44
|
+
codex: "Codex",
|
|
45
|
+
copilot: "Copilot",
|
|
46
|
+
commandcode: "CommandCode",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parse manifest.tsv (shared with install.sh).
|
|
51
|
+
* @param {string} text
|
|
52
|
+
* @returns {{scope: string, target: string, entry: Entry}[]}
|
|
53
|
+
*/
|
|
54
|
+
function parseManifest(text) {
|
|
55
|
+
return text
|
|
56
|
+
.replace(/\r/g, "")
|
|
57
|
+
.split("\n")
|
|
58
|
+
.map((line, index) => ({ line, lineNumber: index + 1 }))
|
|
59
|
+
.filter(({ line }) => line.trim() !== "" && !line.startsWith("#"))
|
|
60
|
+
.map(({ line, lineNumber }) => {
|
|
61
|
+
const columns = line.split("\t");
|
|
62
|
+
if (columns.length !== 5 && columns.length !== 6) {
|
|
63
|
+
throw new Error(`manifest.tsv line ${lineNumber}: expected 5 or 6 columns, got ${columns.length}`);
|
|
64
|
+
}
|
|
65
|
+
const [scope, target, kind, src, dest, mode = ""] = columns;
|
|
66
|
+
return {
|
|
67
|
+
scope,
|
|
68
|
+
target,
|
|
69
|
+
entry: {
|
|
70
|
+
kind,
|
|
71
|
+
src,
|
|
72
|
+
dest,
|
|
73
|
+
mode: mode.trim(),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} scope
|
|
81
|
+
* @param {string} base
|
|
82
|
+
* @returns {Target[]}
|
|
83
|
+
*/
|
|
84
|
+
function targetsFor(scope, base) {
|
|
85
|
+
const rows = parseManifest(fs.readFileSync(path.join(PKG_ROOT, "manifest.tsv"), "utf8"));
|
|
86
|
+
/** @type {Map<string, Target>} */
|
|
87
|
+
const byId = new Map();
|
|
88
|
+
for (const row of rows.filter((r) => r.scope === scope)) {
|
|
89
|
+
if (!byId.has(row.target)) {
|
|
90
|
+
byId.set(row.target, { name: LABELS[row.target] || row.target, base, entries: [] });
|
|
91
|
+
}
|
|
92
|
+
byId.get(row.target).entries.push(row.entry);
|
|
93
|
+
}
|
|
94
|
+
return [...byId.values()];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Declarative deployment manifest, resolved against the current environment. */
|
|
98
|
+
const TARGETS = {
|
|
99
|
+
local: () => targetsFor("local", process.env.LAH_FAKE_CWD || process.cwd()),
|
|
100
|
+
global: (home) => targetsFor("global", home),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const c = process.stdout.isTTY
|
|
104
|
+
? { reset: "\x1b[0m", bold: "\x1b[1m", green: "\x1b[32m", cyan: "\x1b[36m", dim: "\x1b[2m" }
|
|
105
|
+
: { reset: "", bold: "", green: "", cyan: "", dim: "" };
|
|
106
|
+
|
|
107
|
+
const PROFILES = ["core", "full"];
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Skill folders omitted by the "core" profile (profile-extras.txt, shared with install.sh).
|
|
111
|
+
* @param {string} profile
|
|
112
|
+
* @returns {Set<string>}
|
|
113
|
+
*/
|
|
114
|
+
function excludedSkills(profile) {
|
|
115
|
+
if (profile !== "core") return new Set();
|
|
116
|
+
const text = fs.readFileSync(path.join(PKG_ROOT, "profile-extras.txt"), "utf8");
|
|
117
|
+
return new Set(
|
|
118
|
+
text
|
|
119
|
+
.replace(/\r/g, "")
|
|
120
|
+
.split("\n")
|
|
121
|
+
.filter((line) => line.trim() !== "" && !line.startsWith("#")),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {string} src
|
|
127
|
+
* @param {string} dest
|
|
128
|
+
* @param {Set<string>} [exclude] top-level entries of src to skip (dotfiles are always skipped)
|
|
129
|
+
*/
|
|
130
|
+
function copyDir(src, dest, exclude = new Set()) {
|
|
131
|
+
fs.cpSync(src, dest, {
|
|
132
|
+
recursive: true,
|
|
133
|
+
force: true,
|
|
134
|
+
filter: (from) => {
|
|
135
|
+
if (path.dirname(from) !== src) return true;
|
|
136
|
+
const name = path.basename(from);
|
|
137
|
+
return !name.startsWith(".") && !exclude.has(name);
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* First free backup name: "<name>.bak", then "<name>.bak.1", "<name>.bak.2", ...
|
|
144
|
+
* Existing backups are never overwritten.
|
|
145
|
+
*
|
|
146
|
+
* @param {string} destPath
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
function backupPath(destPath) {
|
|
150
|
+
let candidate = `${destPath}.bak`;
|
|
151
|
+
for (let n = 1; fs.existsSync(candidate); n++) candidate = `${destPath}.bak.${n}`;
|
|
152
|
+
return candidate;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Write an instruction file. If the destination exists and differs from the
|
|
157
|
+
* package payload, the user's file is preserved as "<name>.bak" (or the next free
|
|
158
|
+
* "<name>.bak.N") first. With mode "if-missing" an existing destination is left untouched (seed files).
|
|
159
|
+
*
|
|
160
|
+
* @param {string} srcPath
|
|
161
|
+
* @param {string} destPath
|
|
162
|
+
* @param {string} [mode]
|
|
163
|
+
*/
|
|
164
|
+
function writeInstruction(srcPath, destPath, mode = "") {
|
|
165
|
+
if (mode === "if-missing" && fs.existsSync(destPath)) return;
|
|
166
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
167
|
+
try {
|
|
168
|
+
const current = fs.readFileSync(destPath, "utf8");
|
|
169
|
+
if (current !== fs.readFileSync(srcPath, "utf8")) {
|
|
170
|
+
fs.copyFileSync(destPath, backupPath(destPath));
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (err.code !== "ENOENT") {
|
|
174
|
+
throw err;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
fs.copyFileSync(srcPath, destPath);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @param {Target} t
|
|
182
|
+
* @param {Set<string>} [exclude] skill folders to skip (profile)
|
|
183
|
+
* @returns {boolean} success
|
|
184
|
+
*/
|
|
185
|
+
function deployTarget(t, exclude = new Set()) {
|
|
186
|
+
try {
|
|
187
|
+
for (const { kind, src, dest, mode } of t.entries) {
|
|
188
|
+
const from = path.join(PKG_ROOT, src);
|
|
189
|
+
const to = path.join(t.base, dest);
|
|
190
|
+
if (kind === "file") writeInstruction(from, to, mode);
|
|
191
|
+
else copyDir(from, to, src === "skills" ? exclude : new Set());
|
|
192
|
+
}
|
|
193
|
+
const label = t.base.replace(process.env.LAH_FAKE_HOME || os.homedir(), "~");
|
|
194
|
+
console.log(` ${c.green}✔${c.reset} ${label} (${t.name})`);
|
|
195
|
+
return true;
|
|
196
|
+
} catch (err) {
|
|
197
|
+
console.error(` ${c.bold}\x1b[31m✖${c.reset} ${t.name}: ${err.message}`);
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @param {Target[]} targets
|
|
204
|
+
* @param {string} profile
|
|
205
|
+
* @returns {{ok: number, failed: number}}
|
|
206
|
+
*/
|
|
207
|
+
function deployAll(targets, profile) {
|
|
208
|
+
const exclude = excludedSkills(profile);
|
|
209
|
+
let ok = 0;
|
|
210
|
+
let failed = 0;
|
|
211
|
+
for (const t of targets) (deployTarget(t, exclude) ? ok++ : failed++);
|
|
212
|
+
return { ok, failed };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function deployLocal(profile = "full") {
|
|
216
|
+
console.log(`\nModo: ${c.bold}Local${c.reset} (${c.dim}${process.env.LAH_FAKE_CWD || process.cwd()}${c.reset})`);
|
|
217
|
+
return deployAll(TARGETS.local(), profile);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function deployGlobal(profile = "full") {
|
|
221
|
+
const home = process.env.LAH_FAKE_HOME || os.homedir();
|
|
222
|
+
console.log(`\nModo: ${c.bold}Global${c.reset} (${c.dim}${home}${c.reset})`);
|
|
223
|
+
return deployAll(TARGETS.global(home), profile);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const HELP = `Lean Agent Harness v${version}
|
|
227
|
+
Despliegue multi-plataforma de reglas, comandos y skills para agentes de código.
|
|
228
|
+
|
|
229
|
+
Uso:
|
|
230
|
+
npx lean-agent-harness Instalar en el proyecto actual (local)
|
|
231
|
+
npx lean-agent-harness --global Instalar en el home del usuario (~/.claude, ...)
|
|
232
|
+
lean | lah Alias si se instaló globalmente
|
|
233
|
+
|
|
234
|
+
Flags:
|
|
235
|
+
-l, --local Desplegar en el proyecto actual (comportamiento por defecto)
|
|
236
|
+
-g, --global Desplegar en carpetas de usuario (~/)
|
|
237
|
+
--profile <p> core = sin skills extra (ver profile-extras.txt) | full (por defecto)
|
|
238
|
+
-h, --help Mostrar esta ayuda
|
|
239
|
+
-v, --version Mostrar versión
|
|
240
|
+
|
|
241
|
+
Entornos: Claude Code · Pi · CommandCode · OpenCode · Cursor · Codex · Copilot (destinos en manifest.tsv)
|
|
242
|
+
`;
|
|
243
|
+
|
|
244
|
+
/** @returns {number} exit code */
|
|
245
|
+
function main(argv) {
|
|
246
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
247
|
+
console.log(HELP);
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
if (argv.includes("--version") || argv.includes("-v")) {
|
|
251
|
+
console.log(version);
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
let profile = "full";
|
|
256
|
+
const rest = [...argv];
|
|
257
|
+
const at = rest.indexOf("--profile");
|
|
258
|
+
if (at !== -1) {
|
|
259
|
+
profile = rest[at + 1] ?? "";
|
|
260
|
+
rest.splice(at, 2);
|
|
261
|
+
if (!PROFILES.includes(profile)) {
|
|
262
|
+
console.error(`Perfil desconocido: "${profile}". Usa: ${PROFILES.join(" | ")}`);
|
|
263
|
+
return 1;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const validFlags = new Set(["--global", "-g", "--local", "-l"]);
|
|
268
|
+
const unknownArgs = rest.filter((a) => !validFlags.has(a));
|
|
269
|
+
|
|
270
|
+
if (unknownArgs.length > 0) {
|
|
271
|
+
console.error(`Flag desconocido: ${unknownArgs.join(" ")}\n\n${HELP}`);
|
|
272
|
+
return 1;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const isGlobal = argv.includes("--global") || argv.includes("-g");
|
|
276
|
+
const { failed } = isGlobal ? deployGlobal(profile) : deployLocal(profile);
|
|
277
|
+
|
|
278
|
+
if (failed > 0) return 1;
|
|
279
|
+
console.log(`\n${c.green}${c.bold}Done!${c.reset} Arnés desplegado correctamente.\n`);
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (require.main === module) {
|
|
284
|
+
process.exit(main(process.argv.slice(2)));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
module.exports = {
|
|
288
|
+
TARGETS,
|
|
289
|
+
parseManifest,
|
|
290
|
+
deployTarget,
|
|
291
|
+
deployLocal,
|
|
292
|
+
deployGlobal,
|
|
293
|
+
writeInstruction,
|
|
294
|
+
PKG_ROOT,
|
|
295
|
+
version,
|
|
296
|
+
};
|