lean-agent-harness 1.3.2 → 2.0.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 +1 -1
- package/CHANGELOG.md +19 -0
- package/CLAUDE.md +2 -1
- package/GLOSSARY.md +5 -4
- package/README.md +5 -5
- package/adapters/opencode/commands/{review.md → review-audit.md} +1 -1
- package/bin/cli.js +55 -9
- package/install.sh +51 -1
- package/manifest.tsv +11 -9
- package/package.json +1 -1
- package/skills/orchestrate/SKILL.md +1 -1
- package/skills/review-audit/SKILL.md +32 -0
- package/skills/security-audit/SKILL.md +18 -8
- package/skills/security-audit/references/exclusions.md +19 -0
- package/adapters/opencode/commands/audit-code.md +0 -5
- package/skills/audit-code/SKILL.md +0 -14
- package/skills/code-review/SKILL.md +0 -42
- package/skills/review/SKILL.md +0 -22
- package/skills/review/agents/openai.yaml +0 -2
- /package/skills/{audit-code → review-audit}/agents/openai.yaml +0 -0
package/AGENTS.md
CHANGED
|
@@ -21,7 +21,7 @@ Single source of truth for all coding agents. Engineering rigor, deterministic e
|
|
|
21
21
|
* **State:** the plan and `- [ ]` checklist live in `.tasks/current.md` so a compacted session resumes without re-asking. Delete it after a clean `commit`.
|
|
22
22
|
* **Branch:** tracked work happens on `feature/<task-slug>`, never `main`/`master`.
|
|
23
23
|
|
|
24
|
-
Workflow skills (explicit invocation only): `plan-flow <task>` → `orchestrate` → `review` → `commit [hint]
|
|
24
|
+
Workflow skills (explicit invocation only): `plan-flow <task>` → `orchestrate` → `review-audit` → `commit [hint]`. Skills are referenced by name; each agent resolves them from its own skills directory.
|
|
25
25
|
|
|
26
26
|
## 3. Hard Rules
|
|
27
27
|
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ All notable changes to this project are documented here. Format based on [Keep a
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [2.0.0] - 2026-11-06
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- **Breaking:** the `review` workflow skill is now `review-audit` (command `/review-audit`), and `code-audit` and `code-review` are removed (see Removed). The workflow goes from five skills to four.
|
|
12
|
+
- `review-audit` no longer collides with the review commands built into the agents. It takes an optional effort level (`low|medium|high`), runs one reviewer per axis (Correctness, Readability & Bloat, Architecture & Boundaries, Safety & Performance), verifies each finding before reporting it, and lists security hotspots as WARNINGs for human review. It only reports; fixes stay in `orchestrate`.
|
|
13
|
+
- `security-audit` owns the scan scope (a path, else the whole workspace), verifies findings with a confidence threshold of 8 out of 10, reports an exploit scenario per finding, adds a data-exposure vector, and keeps its exclusions in `references/exclusions.md`.
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
- The `code-audit` skill and its OpenCode command: a thin wrapper over `security-audit`, whose scope section now covers it. Use `security-audit` on a path instead of `/audit-code`.
|
|
18
|
+
- The `code-review` skill: its axes now live inside `review-audit`. Directories left over from an older install (`skills/review`, `skills/audit-code`, `skills/code-review`) are not deleted by the installer; remove them by hand.
|
|
19
|
+
|
|
20
|
+
## [1.4.0] - 2026-11-04
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- A divergent user `AGENTS.md`/`CLAUDE.md` is now merged instead of only backed up: the original is still saved as `.bak` (`.bak.1`, ...), and its rules survive in the agent's context as a `## Project Rules` section delimited by `lah:project-rules` comments. Reinstalls over a merged file are a no-op; payload upgrades replace only the harness part and keep the section. Files the harness itself deployed (the `lean-agent-harness` marker or the 1.x signature lines — `Single source of truth for all coding agents`, `# Claude Code Project Configuration`) are replaced without absorbing the old harness text. The affected `manifest.tsv` rows carry the new `merge` mode, and installer parity now runs the merge through both installers.
|
|
25
|
+
|
|
7
26
|
## [1.3.2] - 2026-10-31
|
|
8
27
|
|
|
9
28
|
### Added
|
package/CLAUDE.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- Managed by lean-agent-harness. -->
|
|
1
2
|
# Claude Code Project Configuration
|
|
2
3
|
|
|
3
4
|
Single source of truth is defined in `AGENTS.md`. All directives, subagents, skills, and lifecycle commands apply here.
|
|
@@ -8,5 +9,5 @@ Read and adhere strictly to:
|
|
|
8
9
|
## Fast Command Reference
|
|
9
10
|
- `/plan-flow <task>`: Read-only architecture analysis & ODD milestone checklist.
|
|
10
11
|
- `/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
|
+
- `/review-audit [target]`: Risk-based git diff audit against SonarQube quality gates.
|
|
12
13
|
- `/commit [hint]`: Quality gate verification and atomic Conventional Commit.
|
package/GLOSSARY.md
CHANGED
|
@@ -14,17 +14,18 @@ Single source of truth for the domain vocabulary of this project. Both human eng
|
|
|
14
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
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
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 are kept as `.bak`, or the next free `.bak.N`,
|
|
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 are kept as `.bak`, or the next free `.bak.N`, and in `merge` mode also survive in context as the Project Rules Section; an existing backup is never overwritten. |
|
|
18
|
+
| **Project Rules Section** | The `## Project Rules` block, delimited by `lah:project-rules:start`/`:end` comments, that a `merge`-mode instruction file appends to hold the rules of the user's previous file. | Delimited block at the end of a deployed Instruction Stub | Preserved verbatim across reinstalls and payload upgrades; a file the harness itself deployed (identity marker or the 1.x signature lines) is replaced bare and never absorbed into it. |
|
|
18
19
|
| **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
20
|
| **Slice** | One feature-complete ODD unit (e.g., migration + model + service + tests). | `- [ ] Slice N:` checklist item | No fragmented single-line micro-slices. |
|
|
20
21
|
| **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
22
|
| **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
|
|
23
|
+
| **Workflow Skill** | A skill invoked explicitly (`plan-flow`, `orchestrate`, `review-audit`, `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
24
|
| **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
25
|
| **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
|
+
| **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-audit`); low-risk slices keep the single DoD gate. |
|
|
26
27
|
| **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
|
+
| **Blocker** | A review finding (Blocker or Critical) that blocks `commit` until fixed. | `review-audit` verdict | WARNING and SUGGESTION never block and never trigger fixes. |
|
|
28
29
|
| **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
30
|
| **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
31
|
| **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. |
|
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@ One rule file and one skill format for **Claude Code**, **Pi**, **OpenCode**, **
|
|
|
8
8
|
|
|
9
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
10
|
|
|
11
|
-
* **Domain skills** (`testing`, `security-audit`, `db-migration`, `diagnosing-bugs`, `
|
|
12
|
-
* **Workflow skills** (`plan-flow`, `orchestrate`, `review
|
|
11
|
+
* **Domain skills** (`testing`, `security-audit`, `db-migration`, `diagnosing-bugs`, `impeccable`, `humanizer`, `diagram-design`) load on demand when the task matches their description.
|
|
12
|
+
* **Workflow skills** (`plan-flow`, `orchestrate`, `review-audit`, `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
13
|
|
|
14
14
|
```text
|
|
15
|
-
plan-flow <task> → orchestrate → review [target] → commit [hint]
|
|
15
|
+
plan-flow <task> → orchestrate → review-audit [low|medium|high] [target] → commit [hint]
|
|
16
16
|
(read-only plan) (RED-GREEN, DoD) (audit git diff) (atomic commit) (security scan)
|
|
17
17
|
```
|
|
18
18
|
|
|
@@ -41,12 +41,12 @@ curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/ins
|
|
|
41
41
|
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | bash -s -- --global --auto
|
|
42
42
|
```
|
|
43
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`
|
|
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 never lost: the original is saved as `.bak` (then `.bak.1`, `.bak.2`, ...), and its rules are merged into the deployed file under a `## Project Rules` section delimited by `lah:project-rules` comments, so they stay in the agent's context. Reinstalls change nothing over a merged file; upgrades replace only the harness part and keep the section. A file the harness itself deployed (the `lean-agent-harness` marker, the 1.x `Single source of truth` line or the 1.x `# Claude Code Project Configuration` heading) is replaced without absorbing the old harness text. An existing `GLOSSARY.md` is never touched; a missing one is seeded from `templates/GLOSSARY.md`.
|
|
45
45
|
|
|
46
46
|
**Pinning and verifying the `curl` install.** The one-liner runs the `main` branch unless you pin it:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | LAH_VERSION=
|
|
49
|
+
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | LAH_VERSION=2.0.0 LAH_SHA256=<sha256-of-the-archive> bash -s -- --global --auto
|
|
50
50
|
```
|
|
51
51
|
|
|
52
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.
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
description: Risk-based audit of uncommitted changes against quality gates before committing. Invoke explicitly.
|
|
3
3
|
argument-hint: "[target]"
|
|
4
4
|
---
|
|
5
|
-
Load the `review` skill and follow it. Arguments: $ARGUMENTS
|
|
5
|
+
Load the `review-audit` skill and follow it. Arguments: $ARGUMENTS
|
package/bin/cli.js
CHANGED
|
@@ -32,7 +32,9 @@ const PKG_ROOT = path.resolve(__dirname, "..");
|
|
|
32
32
|
* opencode-permission = merge permission rules into an OpenCode opencode.json
|
|
33
33
|
* @property {string} src Path relative to the package root
|
|
34
34
|
* @property {string} dest Path relative to the target base
|
|
35
|
-
* @property {string} mode ""
|
|
35
|
+
* @property {string} mode "" | "if-missing" (file kind: never overwrite an existing dest)
|
|
36
|
+
* | "merge" (file kind: back up a divergent dest and merge its rules into the
|
|
37
|
+
* deployed file as a "Project Rules" section)
|
|
36
38
|
*
|
|
37
39
|
* @typedef {Object} Target
|
|
38
40
|
* @property {string} name Human-readable label
|
|
@@ -162,10 +164,40 @@ function backupPath(destPath) {
|
|
|
162
164
|
return candidate;
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
/** Merge mode: markers delimiting the user's rules inside a deployed instruction file. */
|
|
168
|
+
const MERGE_START = "<!-- lah:project-rules:start -->";
|
|
169
|
+
const MERGE_END = "<!-- lah:project-rules:end -->";
|
|
170
|
+
const MERGE_HEADING = "## Project Rules\n\n";
|
|
171
|
+
/** Strings identifying a file the harness itself deployed (any version): replaced bare, never absorbed. */
|
|
172
|
+
const HARNESS_MARKS = [
|
|
173
|
+
"lean-agent-harness",
|
|
174
|
+
"Single source of truth for all coding agents",
|
|
175
|
+
"# Claude Code Project Configuration",
|
|
176
|
+
];
|
|
177
|
+
|
|
165
178
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
179
|
+
* The user's section inside a managed instruction file (between the markers, trimmed),
|
|
180
|
+
* or null when the file carries no markers.
|
|
181
|
+
* @param {string} text
|
|
182
|
+
* @returns {string | null}
|
|
183
|
+
*/
|
|
184
|
+
function sectionOf(text) {
|
|
185
|
+
const at = text.indexOf(MERGE_START);
|
|
186
|
+
if (at === -1) return null;
|
|
187
|
+
let body = text.slice(at + MERGE_START.length);
|
|
188
|
+
const end = body.indexOf(MERGE_END);
|
|
189
|
+
if (end !== -1) body = body.slice(0, end);
|
|
190
|
+
return body.trim();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Write an instruction file. A destination that differs from the package payload is
|
|
195
|
+
* preserved as "<name>.bak" (or the next free "<name>.bak.N") first. With mode
|
|
196
|
+
* "if-missing" an existing destination is left untouched (seed files). With mode
|
|
197
|
+
* "merge" the divergent destination's rules also survive in context: a user file is
|
|
198
|
+
* merged as a "Project Rules" section, a managed file keeps its section across
|
|
199
|
+
* payload upgrades, and a file the harness itself deployed is replaced bare.
|
|
200
|
+
* Writing a byte-identical result is a no-op, so reinstalling is stable.
|
|
169
201
|
*
|
|
170
202
|
* @param {string} srcPath
|
|
171
203
|
* @param {string} destPath
|
|
@@ -173,18 +205,32 @@ function backupPath(destPath) {
|
|
|
173
205
|
*/
|
|
174
206
|
function writeInstruction(srcPath, destPath, mode = "") {
|
|
175
207
|
if (mode === "if-missing" && fs.existsSync(destPath)) return;
|
|
208
|
+
const payload = fs.readFileSync(srcPath, "utf8");
|
|
176
209
|
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
210
|
+
let current = null;
|
|
177
211
|
try {
|
|
178
|
-
|
|
179
|
-
if (current !== fs.readFileSync(srcPath, "utf8")) {
|
|
180
|
-
fs.copyFileSync(destPath, backupPath(destPath));
|
|
181
|
-
}
|
|
212
|
+
current = fs.readFileSync(destPath, "utf8");
|
|
182
213
|
} catch (err) {
|
|
183
214
|
if (err.code !== "ENOENT") {
|
|
184
215
|
throw err;
|
|
185
216
|
}
|
|
186
217
|
}
|
|
187
|
-
|
|
218
|
+
if (current === null) {
|
|
219
|
+
fs.copyFileSync(srcPath, destPath);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (current === payload) return;
|
|
223
|
+
let next = null;
|
|
224
|
+
if (mode === "merge") {
|
|
225
|
+
const marked = sectionOf(current);
|
|
226
|
+
const userRules = marked === null && !HARNESS_MARKS.some((m) => current.includes(m)) ? current.trim() : "";
|
|
227
|
+
const body = marked ?? (userRules ? MERGE_HEADING + userRules : "");
|
|
228
|
+
next = body ? `${payload.replace(/\s+$/, "")}\n\n${MERGE_START}\n${body}\n${MERGE_END}\n` : payload;
|
|
229
|
+
}
|
|
230
|
+
if (next !== null && next === current) return;
|
|
231
|
+
fs.copyFileSync(destPath, backupPath(destPath));
|
|
232
|
+
if (next !== null) fs.writeFileSync(destPath, next);
|
|
233
|
+
else fs.copyFileSync(srcPath, destPath);
|
|
188
234
|
}
|
|
189
235
|
|
|
190
236
|
/**
|
package/install.sh
CHANGED
|
@@ -207,14 +207,64 @@ backup_path() {
|
|
|
207
207
|
printf '%s' "$candidate"
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
# Merge mode: markers delimiting the user's rules inside a deployed instruction file,
|
|
211
|
+
# and the strings identifying a file the harness itself deployed (replaced bare, never absorbed).
|
|
212
|
+
MERGE_START='<!-- lah:project-rules:start -->'
|
|
213
|
+
MERGE_END='<!-- lah:project-rules:end -->'
|
|
214
|
+
MERGE_HEADING=$'## Project Rules\n\n'
|
|
215
|
+
|
|
216
|
+
# Leading and trailing whitespace (newlines included), matching the JS side's String.trim().
|
|
217
|
+
trim_ws() {
|
|
218
|
+
local t="$1"
|
|
219
|
+
t="${t#"${t%%[![:space:]]*}"}"
|
|
220
|
+
printf '%s' "${t%"${t##*[![:space:]]}"}"
|
|
221
|
+
}
|
|
222
|
+
|
|
210
223
|
# Instruction file: a divergent existing destination is preserved as .bak (or the next free .bak.N).
|
|
211
224
|
# mode "if-missing": an existing destination is left untouched (seed files).
|
|
225
|
+
# mode "merge": the divergent destination's rules also survive in context — a user file is merged
|
|
226
|
+
# as a "Project Rules" section, a managed file keeps its section across payload upgrades, and a
|
|
227
|
+
# file the harness itself deployed is replaced bare. Writing a byte-identical result is a no-op.
|
|
212
228
|
write_instruction() {
|
|
213
229
|
local src="$1" dest="$2" mode="${3:-}"
|
|
214
230
|
if [ "$mode" = "if-missing" ] && [ -e "$dest" ]; then return 0; fi
|
|
215
231
|
mkdir -p "$(dirname "$dest")"
|
|
216
|
-
if [ -
|
|
232
|
+
if [ ! -e "$dest" ]; then cp "$src" "$dest"; return 0; fi
|
|
233
|
+
if cmp -s "$src" "$dest"; then return 0; fi
|
|
234
|
+
if [ "$mode" != "merge" ]; then
|
|
235
|
+
cp "$dest" "$(backup_path "$dest")"
|
|
236
|
+
cp "$src" "$dest"
|
|
237
|
+
return 0
|
|
238
|
+
fi
|
|
239
|
+
local current section composed payload
|
|
240
|
+
payload="$(cat "$src")"
|
|
241
|
+
payload="${payload%"${payload##*[![:space:]]}"}"
|
|
242
|
+
current="$(cat "$dest")"
|
|
243
|
+
case "$current" in
|
|
244
|
+
*"$MERGE_START"*)
|
|
245
|
+
section="$current"
|
|
246
|
+
section="${section#*"$MERGE_START"}"
|
|
247
|
+
section="${section%%"$MERGE_END"*}"
|
|
248
|
+
section="$(trim_ws "$section")"
|
|
249
|
+
;;
|
|
250
|
+
*lean-agent-harness*|*"Single source of truth for all coding agents"*|*"# Claude Code Project Configuration"*)
|
|
251
|
+
section=""
|
|
252
|
+
;;
|
|
253
|
+
*)
|
|
254
|
+
section="$(trim_ws "$current")"
|
|
255
|
+
if [ -n "$section" ]; then section="${MERGE_HEADING}${section}"; fi
|
|
256
|
+
;;
|
|
257
|
+
esac
|
|
258
|
+
if [ -n "$section" ]; then
|
|
259
|
+
composed="$(printf '%s\n\n%s\n%s\n%s\n' "$payload" "$MERGE_START" "$section" "$MERGE_END")"
|
|
260
|
+
if printf '%s\n' "$composed" | cmp -s - "$dest"; then return 0; fi
|
|
261
|
+
cp "$dest" "$(backup_path "$dest")"
|
|
262
|
+
printf '%s\n' "$composed" > "$dest"
|
|
263
|
+
return 0
|
|
264
|
+
fi
|
|
265
|
+
cp "$dest" "$(backup_path "$dest")"
|
|
217
266
|
cp "$src" "$dest"
|
|
267
|
+
return 0
|
|
218
268
|
}
|
|
219
269
|
|
|
220
270
|
# Skill folders omitted by --profile core (profile-extras.txt, shared with bin/cli.js).
|
package/manifest.tsv
CHANGED
|
@@ -6,25 +6,27 @@
|
|
|
6
6
|
# | settings-hook (merge the hook in src into the Claude Code settings.json at dest)
|
|
7
7
|
# | opencode-permission (merge the permission rules in src into the OpenCode opencode.json at dest)
|
|
8
8
|
# mode: if-missing (file kind only: never overwrite an existing dest)
|
|
9
|
+
# merge (file kind only: back up a divergent dest and merge its rules into the deployed
|
|
10
|
+
# file as a "Project Rules" section; a dest the harness itself deployed is replaced bare)
|
|
9
11
|
# Target "agents" = the cross-tool Agent Skills location (.agents/skills), read natively by
|
|
10
12
|
# Pi, OpenCode, Codex, Copilot and Cursor. Claude Code reads .claude/skills instead.
|
|
11
|
-
local core file AGENTS.md AGENTS.md
|
|
12
|
-
local core file CLAUDE.md CLAUDE.md
|
|
13
|
+
local core file AGENTS.md AGENTS.md merge
|
|
14
|
+
local core file CLAUDE.md CLAUDE.md merge
|
|
13
15
|
local core file templates/GLOSSARY.md GLOSSARY.md if-missing
|
|
14
16
|
local claude dir skills .claude/skills
|
|
15
17
|
local agents dir skills .agents/skills
|
|
16
18
|
local opencode dir adapters/opencode/commands .opencode/commands
|
|
17
19
|
local commandcode dir skills .commandcode/skills
|
|
18
|
-
global claude file AGENTS.md .claude/AGENTS.md
|
|
19
|
-
global claude file CLAUDE.md .claude/CLAUDE.md
|
|
20
|
+
global claude file AGENTS.md .claude/AGENTS.md merge
|
|
21
|
+
global claude file CLAUDE.md .claude/CLAUDE.md merge
|
|
20
22
|
global claude dir skills .claude/skills
|
|
21
23
|
global agents dir skills .agents/skills
|
|
22
|
-
global pi file AGENTS.md .pi/agent/AGENTS.md
|
|
23
|
-
global opencode file AGENTS.md .config/opencode/AGENTS.md
|
|
24
|
+
global pi file AGENTS.md .pi/agent/AGENTS.md merge
|
|
25
|
+
global opencode file AGENTS.md .config/opencode/AGENTS.md merge
|
|
24
26
|
global opencode dir adapters/opencode/commands .config/opencode/commands
|
|
25
|
-
global codex file AGENTS.md .codex/AGENTS.md
|
|
26
|
-
global copilot file AGENTS.md .copilot/copilot-instructions.md
|
|
27
|
-
global commandcode file AGENTS.md .commandcode/AGENTS.md
|
|
27
|
+
global codex file AGENTS.md .codex/AGENTS.md merge
|
|
28
|
+
global copilot file AGENTS.md .copilot/copilot-instructions.md merge
|
|
29
|
+
global commandcode file AGENTS.md .commandcode/AGENTS.md merge
|
|
28
30
|
global commandcode dir skills .commandcode/skills
|
|
29
31
|
global-guard pi-guard dir guard/pi/lah-guard .pi/agent/extensions/lah-guard
|
|
30
32
|
global-guard claude-guard dir guard/claude/lah-guard .claude/hooks/lah-guard
|
package/package.json
CHANGED
|
@@ -35,4 +35,4 @@ After the DoD, verify in a fresh context (subagent or new session; if the host h
|
|
|
35
35
|
## Failure
|
|
36
36
|
Apply the Circuit Breaker from `AGENTS.md`, reverting only this slice's files.
|
|
37
37
|
|
|
38
|
-
Mark `- [x]` in `.tasks/current.md`, advance, and when all are done ask the user to run `review`.
|
|
38
|
+
Mark `- [x]` in `.tasks/current.md`, advance, and when all are done ask the user to run `review-audit`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-audit
|
|
3
|
+
description: Risk-based audit of uncommitted changes against quality gates before committing. Invoke explicitly.
|
|
4
|
+
argument-hint: [low|medium|high] [target]
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# review-audit
|
|
9
|
+
|
|
10
|
+
Arguments: optional effort level, then optional target (file, branch or PR). Default: **medium**.
|
|
11
|
+
|
|
12
|
+
* **low**: report only Blocker/Critical findings you are certain of.
|
|
13
|
+
* **medium**: add WARNING findings you verified in the code.
|
|
14
|
+
* **high**: add SUGGESTION findings and uncertain ones, each marked PLAUSIBLE.
|
|
15
|
+
|
|
16
|
+
1. Run `git diff` (or inspect the given target file/branch).
|
|
17
|
+
2. Check new symbols against `GLOSSARY.md` (skip if absent).
|
|
18
|
+
3. Review by axis: one reviewer per axis. Report only actionable defects, each with its exact structural remedy.
|
|
19
|
+
* **Correctness:** null dereferences, type coercion, resource leaks, off-by-one, inverted conditions, unchecked errors.
|
|
20
|
+
* **Readability & Bloat:** dead code and commented-out code, cyclomatic complexity > 10, nesting > 3 levels, functions > 30 lines, duplicated blocks, cryptic names (`data`, `temp`, `res`).
|
|
21
|
+
* **Architecture & Boundaries:** transport or DB logic leaking into domain layers, refactors that only shuffle lines, premature interfaces and shallow wrappers.
|
|
22
|
+
* **Safety & Performance:** injection, authorization gaps, unsanitized input at system borders (load `security-audit` if touching persistence/auth), unbounded queries, N+1, heavy work inside hot loops.
|
|
23
|
+
Security hotspots (crypto, CORS, cookies, regex on user input, deserialization, dependency/config changes) are not defects: list each once as a WARNING for human review, with the reason.
|
|
24
|
+
If the host has subagents, run the axis reviewers in parallel, each with only the diff and its axis. Otherwise run them sequential in this context and state that in the verdict.
|
|
25
|
+
4. Verify pass: re-read the cited code for every candidate finding and drop any you cannot reproduce from the code. Mark survivors CONFIRMED, or PLAUSIBLE when the level allows uncertain ones.
|
|
26
|
+
5. Verify the diff fulfils the planned slice with no scope creep.
|
|
27
|
+
If any slice is `Risk: high`, run this review in a fresh context (subagent or new session) so it does not judge code it just wrote; if the host has neither, state that the review ran in the authoring context.
|
|
28
|
+
Record the hash of the diff you judged (`git add -N <new files>`, then `git diff HEAD | git hash-object --stdin`) in the verdict; a later change to that hash needs a new review. If the work is already committed, `git diff HEAD` is empty and always hashes the same: hash `git diff <base>...HEAD` instead.
|
|
29
|
+
6. Verdict: any Blocker/Critical → list required fixes, each with the exact structural remedy, and block `commit`. Clean → approve and tell the user to run `commit`.
|
|
30
|
+
WARNING and SUGGESTION are listed once in the verdict. They never trigger fixes or another review round.
|
|
31
|
+
|
|
32
|
+
Report only. Never edit code in a review: fixes go through `orchestrate`, so the judged hash stays valid.
|
|
@@ -7,26 +7,36 @@ description: Static and architectural security review. Identifies injection risk
|
|
|
7
7
|
|
|
8
8
|
Inspect the codebase for concrete security defects where an untrusted principal crosses a real trust boundary or abuses application logic.
|
|
9
9
|
|
|
10
|
+
## Scope
|
|
11
|
+
|
|
12
|
+
The given path, else the whole workspace. Skip `.git`, `node_modules`, `.env*`, vendored code and binaries.
|
|
13
|
+
|
|
10
14
|
## Audit Vectors
|
|
11
15
|
|
|
12
16
|
1. **Authentication & Authorization:** Missing guards on routes/handlers, broken object-level authorization (IDOR), privilege escalation, unsafe token/session handling.
|
|
13
17
|
2. **Input Validation & Injection:** Raw SQL/NoSQL queries, unsanitized command execution (`os/exec`, `eval`), unescaped template rendering (XSS), path traversal (`../`).
|
|
14
18
|
3. **Secrets & Configurations:** Hardcoded API keys, exposed `.env` values, secrets leaked in logs or error traces, weak CORS policies, insecure crypto defaults.
|
|
15
19
|
4. **Data Boundaries & Deserialization:** Insecure deserialization, mass assignment vulnerabilities, improper SSRF protections on external fetches.
|
|
16
|
-
5. **Supply Chain & Dependencies:** Known CVEs
|
|
20
|
+
5. **Supply Chain & Dependencies:** Known CVEs reported by the project's auditor, deprecated packages, unsafe imports.
|
|
21
|
+
6. **Data Exposure:** PII or secrets in logs, API responses leaking fields, debug information in production.
|
|
22
|
+
|
|
23
|
+
## Verification
|
|
24
|
+
|
|
25
|
+
Verify pass: for each candidate, re-read the code and trace the data from the untrusted source to the sensitive sink. Give it a confidence from 1 to 10 and drop anything below 8. Apply `references/exclusions.md` before reporting. Subagents may verify findings in parallel; without them, verify sequentially and say so.
|
|
17
26
|
|
|
18
27
|
## Reporting Standard
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
- **Location:**
|
|
22
|
-
- **Vulnerability:**
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
29
|
+
Per finding:
|
|
30
|
+
- **Location:** file path and line range.
|
|
31
|
+
- **Vulnerability:** classification and mechanism of failure.
|
|
32
|
+
- **Severity:** Critical, High, Medium or Low, with the concrete blast radius.
|
|
33
|
+
- **Exploit Scenario:** the attacker's steps from untrusted input to impact. No path, no finding.
|
|
34
|
+
- **Surgical Fix:** minimal diff or exact remediation.
|
|
25
35
|
|
|
26
36
|
## Output Format
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
A Markdown matrix, then the exploit scenarios:
|
|
29
39
|
|
|
30
40
|
| Severity | Category | File:Line | Description | Remediation |
|
|
31
41
|
| :--- | :--- | :--- | :--- | :--- |
|
|
32
|
-
| High | Injection | `server/db.go:45` | Unsanitized query input | Use parameterized query |
|
|
42
|
+
| High | Injection | `server/db.go:45` | Unsanitized query input | Use parameterized query |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Exclusions
|
|
2
|
+
|
|
3
|
+
Do not report:
|
|
4
|
+
|
|
5
|
+
1. Denial of service, resource exhaustion, rate limiting, memory or CPU consumption.
|
|
6
|
+
2. Missing hardening or best practices with no concrete vulnerability.
|
|
7
|
+
3. Outdated third-party libraries, unless the project's own auditor (`npm audit`, `pip-audit`, `govulncheck`) flags them.
|
|
8
|
+
4. Race conditions or timing attacks that are only theoretical.
|
|
9
|
+
5. Regex injection, regex DoS, log spoofing, missing audit logs.
|
|
10
|
+
6. Path-only SSRF: it matters only if the host or protocol is controllable.
|
|
11
|
+
7. Findings in documentation or in test-only files.
|
|
12
|
+
8. Client-side missing auth checks: the server is responsible for them.
|
|
13
|
+
9. Memory-safety issues in memory-safe languages.
|
|
14
|
+
|
|
15
|
+
Trusted inputs:
|
|
16
|
+
|
|
17
|
+
* Environment variables and CLI flags are trusted. An attack that needs to control one is invalid.
|
|
18
|
+
* UUIDs are unguessable and need no validation.
|
|
19
|
+
* Logging non-PII data is not a finding. Logging secrets, passwords or PII is.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: audit-code
|
|
3
|
-
description: Deep static security audit of a path or the whole workspace. Invoke explicitly.
|
|
4
|
-
argument-hint: [path]
|
|
5
|
-
disable-model-invocation: true
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# audit-code
|
|
9
|
-
|
|
10
|
-
Scope: the given path, else the whole workspace. Skip `.git`, `node_modules`, `.env*`, vendored code, binaries.
|
|
11
|
-
|
|
12
|
-
1. Load the `security-audit` skill.
|
|
13
|
-
2. Scan: broken authn/authz (IDOR, missing guards), injection (SQL/NoSQL/XSS/command), hardcoded secrets, insecure deserialization, SSRF, unsanitized trust-boundary crossings, dependency CVEs.
|
|
14
|
-
3. Report a severity matrix (Critical/High/Med/Low) with `file:line`, failure mechanism, blast radius and the surgical fix. Every finding needs a concrete attack path; no theoretical issues.
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: code-review
|
|
3
|
-
description: Fast, multi-axis technical code review targeting SonarQube quality gates (Bugs, Code Smells), architectural debt, and diff hygiene.
|
|
4
|
-
disable-model-invocation: true
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Code Review
|
|
8
|
-
|
|
9
|
-
Evaluate diffs and PRs strictly against four technical axes. Focus on defects that fail SonarQube quality gates and produce technical debt. Propose the exact remedy, not just the critique.
|
|
10
|
-
|
|
11
|
-
## The Review Axes
|
|
12
|
-
|
|
13
|
-
1. **Correctness (SonarQube Bugs):**
|
|
14
|
-
- Null pointer dereferences, unhandled nil/null checks, and type-coercion bugs.
|
|
15
|
-
- Resource leaks: unclosed files, DB connections, HTTP request/response bodies.
|
|
16
|
-
- Logic defects: off-by-one errors, infinite loops, inverted conditions, unchecked error returns.
|
|
17
|
-
|
|
18
|
-
2. **Readability & Bloat (SonarQube Code Smells):**
|
|
19
|
-
- Dead code: unreachable branches, unused variables, orphan imports, commented-out legacy code.
|
|
20
|
-
- Cyclomatic complexity: deep nesting (>3 levels), massive switch statements without default cases.
|
|
21
|
-
- Duplication: identical logic blocks that must be consolidated.
|
|
22
|
-
- Naming: cryptic variable names without domain meaning (`data`, `temp`, `res`).
|
|
23
|
-
|
|
24
|
-
3. **Architecture & Boundaries:**
|
|
25
|
-
- Layer leaks: transport or DB logic leaking into domain/business layers.
|
|
26
|
-
- Relocated complexity: refactors that merely shuffle lines instead of eliminating branches.
|
|
27
|
-
- Unnecessary abstractions: premature interfaces, boilerplate wrappers with only one implementation.
|
|
28
|
-
|
|
29
|
-
4. **Safety & Performance:**
|
|
30
|
-
- Unbounded queries, N+1 patterns, unconstrained pagination.
|
|
31
|
-
- Input validation at system borders (complements `security-audit`).
|
|
32
|
-
- Heavy allocations or redundant calculations inside loops or hot paths.
|
|
33
|
-
|
|
34
|
-
## Findings Format
|
|
35
|
-
|
|
36
|
-
Report only actionable issues ordered by severity:
|
|
37
|
-
|
|
38
|
-
- **Critical:** Blocks merge / SonarQube red gate. Runtime crash, resource leak, or data corruption.
|
|
39
|
-
- **Required:** Must fix. Code smells, complexity spikes, unhandled boundary cases, broken invariants.
|
|
40
|
-
- **Nit / Optional:** Style suggestions, minor syntactic sugar. Non-blocking.
|
|
41
|
-
|
|
42
|
-
For every reported issue, prescribe the exact structural remedy: *extract helper*, *close resource with defer/finally*, *dispatch via map*, or *collapse redundant branch*.
|
package/skills/review/SKILL.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: review
|
|
3
|
-
description: Risk-based audit of uncommitted changes against quality gates before committing. Invoke explicitly.
|
|
4
|
-
argument-hint: [target]
|
|
5
|
-
disable-model-invocation: true
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# review
|
|
9
|
-
|
|
10
|
-
1. Run `git diff` (or inspect the given target file/branch).
|
|
11
|
-
2. Check new symbols against `GLOSSARY.md` (skip if absent).
|
|
12
|
-
3. Quality gates:
|
|
13
|
-
* **Bugs:** logic anomalies, unhandled null/undefined, resource leaks.
|
|
14
|
-
* **Vulnerabilities:** injection, authorization gaps, unsanitized input (load `security-audit` if touching persistence/auth).
|
|
15
|
-
* **Smells:** cyclomatic complexity > 10, functions > 30 lines, shallow wrappers, dead code.
|
|
16
|
-
4. Verify the diff fulfils the planned slice with no scope creep.
|
|
17
|
-
If any slice is `Risk: high`, run this review in a fresh context (subagent or new session) so it does not judge code it just wrote; if the host has neither, state that the review ran in the authoring context.
|
|
18
|
-
Record the hash of the diff you judged (`git add -N <new files>`, then `git diff HEAD | git hash-object --stdin`) in the verdict; a later change to that hash needs a new review. If the work is already committed, `git diff HEAD` is empty and always hashes the same: hash `git diff <base>...HEAD` instead.
|
|
19
|
-
5. Verdict: any Blocker/Critical → list required fixes and block `commit`. Clean → approve and tell the user to run `commit`.
|
|
20
|
-
WARNING and SUGGESTION are listed once in the verdict. They never trigger fixes or another review round.
|
|
21
|
-
|
|
22
|
-
For deeper multi-axis review rules use the `code-review` skill.
|
|
File without changes
|