lean-agent-harness 0.0.0-stage → 1.3.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.
Files changed (45) hide show
  1. package/AGENTS.md +34 -0
  2. package/CHANGELOG.md +54 -0
  3. package/CLAUDE.md +12 -0
  4. package/GLOSSARY.md +53 -0
  5. package/LICENSE +21 -0
  6. package/README.md +92 -2
  7. package/adapters/opencode/commands/audit-code.md +5 -0
  8. package/adapters/opencode/commands/commit.md +5 -0
  9. package/adapters/opencode/commands/orchestrate.md +5 -0
  10. package/adapters/opencode/commands/plan-flow.md +5 -0
  11. package/adapters/opencode/commands/review.md +5 -0
  12. package/bin/cli.js +310 -0
  13. package/guard/claude/hook.json +7 -0
  14. package/guard/claude/lah-guard/core.js +101 -0
  15. package/guard/claude/lah-guard/index.js +76 -0
  16. package/guard/claude/lah-guard/policy.json +33 -0
  17. package/guard/claude/merge-settings.js +70 -0
  18. package/guard/codex/lah.rules +74 -0
  19. package/guard/pi/lah-guard/core.js +101 -0
  20. package/guard/pi/lah-guard/index.js +49 -0
  21. package/guard/pi/lah-guard/policy.json +33 -0
  22. package/install.sh +263 -0
  23. package/manifest.tsv +31 -0
  24. package/package.json +54 -4
  25. package/profile-extras.txt +6 -0
  26. package/skills/audit-code/SKILL.md +14 -0
  27. package/skills/audit-code/agents/openai.yaml +2 -0
  28. package/skills/code-review/SKILL.md +42 -0
  29. package/skills/commit/SKILL.md +15 -0
  30. package/skills/commit/agents/openai.yaml +2 -0
  31. package/skills/db-migration/SKILL.md +40 -0
  32. package/skills/diagnosing-bugs/SKILL.md +32 -0
  33. package/skills/diagram-design/SKILL.md +43 -0
  34. package/skills/diagram-design/references/template.md +33 -0
  35. package/skills/humanizer/SKILL.md +30 -0
  36. package/skills/impeccable/SKILL.md +36 -0
  37. package/skills/orchestrate/SKILL.md +38 -0
  38. package/skills/orchestrate/agents/openai.yaml +2 -0
  39. package/skills/plan-flow/SKILL.md +37 -0
  40. package/skills/plan-flow/agents/openai.yaml +2 -0
  41. package/skills/review/SKILL.md +22 -0
  42. package/skills/review/agents/openai.yaml +2 -0
  43. package/skills/security-audit/SKILL.md +32 -0
  44. package/skills/testing/SKILL.md +28 -0
  45. package/templates/GLOSSARY.md +11 -0
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: impeccable
3
+ description: High-craft frontend UI/UX design, layout, spacing, typography, and visual polish across web and mobile interfaces.
4
+ ---
5
+
6
+ # Impeccable UI Craft
7
+
8
+ Produce production-ready, distinct, and high-fidelity interfaces. Avoid generic placeholder designs, timid component library defaults, and visual clutter.
9
+
10
+ ## Craft Principles
11
+
12
+ 1. **Visual Hierarchy & Typography:**
13
+ - Intentional typographic scale: distinct contrast between display, headers, and body text.
14
+ - Generous line-height for readability (`1.5` - `1.6` on body), tight tracking on large headings.
15
+ - Avoid washed-out low-contrast gray text; strictly maintain WCAG AA contrast ratios.
16
+
17
+ 2. **Spacing & Layout Rhythm:**
18
+ - Strict 4px/8px spatial grid for all margins, padding, and gaps.
19
+ - Purposeful whitespace: group related elements tightly, separate distinct sections generously.
20
+ - Mobile-first responsiveness: fluid flex/grid layouts, no horizontal scroll overflows.
21
+
22
+ 3. **Color & Surface Depth:**
23
+ - Cohesive palette: 1 dominant background tone, subtle border/surface elevations, and 1 sharp accent color for key actions.
24
+ - Avoid flat grey boxes: use subtle borders (`1px solid rgba(...)`), soft layered shadows, or subtle gradients.
25
+
26
+ 4. **Interaction & Micro-details:**
27
+ - Polish interactive states on every control: hover, active, focus-visible, disabled, and loading.
28
+ - Smooth micro-interactions: quick transitions (150ms-250ms ease-out) for state changes.
29
+ - Complete states: always design empty states, error boundaries, and skeleton loaders.
30
+
31
+ ## Banned Patterns
32
+
33
+ - Pure `#000000` text on pure `#ffffff` backgrounds (use rich slate/zinc tones).
34
+ - Default browser focus rings (style distinct `:focus-visible`).
35
+ - Giant walls of unchunked text or cluttered dashboard cards.
36
+ - Centered body text longer than two lines.
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: orchestrate
3
+ description: Executes the .tasks/current.md checklist slice by slice with RED-GREEN-REFACTOR and the DoD gate. Invoke explicitly after a plan exists.
4
+ argument-hint: [task or slice]
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # orchestrate — Orchestrator role
9
+
10
+ Task: the arguments given with this invocation (default: the first pending slice).
11
+
12
+ ## Preconditions
13
+ 1. `.tasks/current.md` has a `- [ ]` item. If not, halt and ask the user to run `plan-flow` first.
14
+ 2. `git branch --show-current` is not `main`/`master`. If it is, run `git switch -c feature/<task-slug>` before touching any file.
15
+ 3. Every file the slice will edit is clean in `git status --short`. If not, ask the user to commit or stash it first: the Circuit Breaker revert would discard their edits.
16
+
17
+ ## Change budget
18
+ Before editing, forecast the slice's added + deleted lines. Above 400 changed lines, split the slice into smaller work units, or report the overage with its reason. Never shrink the diff by deleting tests, docs or comments, or by compressing code.
19
+
20
+ ## Per slice (strictly sequential, only the slice's files)
21
+ 1. Load the skills the slice names; skip any that are not installed.
22
+ 2. **Feature:** RED (write/run the test, log the failure) → GREEN (minimal implementation) → REFACTOR (strict typing, no dead code, names match `GLOSSARY.md`).
23
+ 3. **Defect:** follow the `diagnosing-bugs` skill: reproduce (RED) → minimize → hypothesize in writing → instrument → fix → verify and remove instrumentation.
24
+ 4. No package installs unless the plan lists them.
25
+
26
+ ## Definition of Done (all required before `- [x]`)
27
+ * Compiler/linters: 0 errors, 0 new warnings.
28
+ * Target tests pass; **quote the exact terminal summary line**.
29
+ * No debug residue (`console.log`, `print`, `debugger`).
30
+ * `git status` shows no unrelated files.
31
+
32
+ ## High-risk slices (`Risk: high`)
33
+ After the DoD, verify in a fresh context (subagent or new session; if the host has neither, say so). Give the verifier only the slice's DoD commands; it reports each as `<command>: <observed result>` plus the hash of the diff it ran against (`git add -N <new files>`, then `git diff HEAD | git hash-object --stdin`). If that hash changes after the report, the report is stale: run the verifier again. Re-run one reported command yourself before `- [x]`. Low-risk slices skip this.
34
+
35
+ ## Failure
36
+ Apply the Circuit Breaker from `AGENTS.md`, reverting only this slice's files.
37
+
38
+ Mark `- [x]` in `.tasks/current.md`, advance, and when all are done ask the user to run `review`.
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: plan-flow
3
+ description: Read-only analysis that produces an ODD slice plan in .tasks/current.md. Invoke explicitly before non-trivial implementation.
4
+ argument-hint: <task>
5
+ disable-model-invocation: true
6
+ ---
7
+
8
+ # plan-flow — Planner role
9
+
10
+ Task: the arguments given with this invocation. Read-only architect: inspect, design, slice, write the plan. Never modify source, install packages, or mutate git. The only file you may write is `.tasks/current.md`.
11
+
12
+ ## Steps
13
+ 1. **Scope gate:** if the task is broad or ambiguous, STOP and ask exactly ONE question on the main decision, with a recommended default answerable in one word. No questionnaires.
14
+ 2. **Size gate:** ≤ 1 file, cosmetic or < 30 lines → declare an **Inline Task** with a one-step guideline; skip slicing.
15
+ 3. **Ground truth:** read `GLOSSARY.md` (if present) and the active manifest (`package.json`, `go.mod`, `Cargo.toml`, `pyproject.toml`, `Makefile`) for real test/lint commands. Verify paths, exports and signatures before citing them.
16
+ 4. **Design:** deep modules, minimal public interfaces, no shallow pass-through layers.
17
+ 5. **Slice:** feature-complete units (e.g. migration + model + service + tests). Each defines its RED state (failing test) first and names the skills it needs (`testing`, `security-audit`, `diagnosing-bugs`; `db-migration`, `impeccable` if installed).
18
+ 6. **Persist** the plan to `.tasks/current.md`, then tell the user to run `orchestrate`.
19
+
20
+ ## Output format
21
+ ```markdown
22
+ ### Architecture & Context
23
+ * **Affected:** files/modules/interfaces
24
+ * **Verify with:** exact commands from the manifest
25
+ * **Branch:** `feature/<task-slug>` (create before orchestrating; never `main`/`master`)
26
+ * **Skills:** per slice
27
+
28
+ ### Slice N: name
29
+ * **Scope:** files
30
+ * **Risk:** low|high (high = a high-risk item from `AGENTS.md` § 2)
31
+ * **RED:** test file + expected failure
32
+ * **GREEN:** logic, types, integration
33
+ * **DoD:** exact terminal command
34
+
35
+ ### Checklist
36
+ - [ ] Slice 1: summary + test criteria
37
+ ```
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,22 @@
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.
@@ -0,0 +1,2 @@
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: security-audit
3
+ description: Static and architectural security review. Identifies injection risks, auth bypasses, trust boundary violations, and leaked secrets.
4
+ ---
5
+
6
+ # Security Audit
7
+
8
+ Inspect the codebase for concrete security defects where an untrusted principal crosses a real trust boundary or abuses application logic.
9
+
10
+ ## Audit Vectors
11
+
12
+ 1. **Authentication & Authorization:** Missing guards on routes/handlers, broken object-level authorization (IDOR), privilege escalation, unsafe token/session handling.
13
+ 2. **Input Validation & Injection:** Raw SQL/NoSQL queries, unsanitized command execution (`os/exec`, `eval`), unescaped template rendering (XSS), path traversal (`../`).
14
+ 3. **Secrets & Configurations:** Hardcoded API keys, exposed `.env` values, secrets leaked in logs or error traces, weak CORS policies, insecure crypto defaults.
15
+ 4. **Data Boundaries & Deserialization:** Insecure deserialization, mass assignment vulnerabilities, improper SSRF protections on external fetches.
16
+ 5. **Supply Chain & Dependencies:** Known CVEs in dependencies, use of deprecated packages, unsafe imports.
17
+
18
+ ## Reporting Standard
19
+
20
+ For each finding, provide:
21
+ - **Location:** File path and line range.
22
+ - **Vulnerability:** Clear classification and mechanism of failure.
23
+ - **Impact & Severity:** Concrete blast radius (Critical, High, Medium, Low). No theoretical risks without a valid attack path.
24
+ - **Surgical Fix:** Minimal code diff or exact remediation to restore the invariant.
25
+
26
+ ## Output Format
27
+
28
+ Summarize findings in a clean Markdown matrix followed by actionable remediations:
29
+
30
+ | Severity | Category | File:Line | Description | Remediation |
31
+ | :--- | :--- | :--- | :--- | :--- |
32
+ | High | Injection | `server/db.go:45` | Unsanitized query input | Use parameterized query |
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: testing
3
+ description: Universal testing standards (PHP, Go, Python, TS/JS, Rust), parameterized suites, hermetic mocks, and deterministic execution.
4
+ ---
5
+
6
+ # Testing
7
+
8
+ Write resilient, fast, deterministic tests. Test behavior and invariants, never private implementation details.
9
+
10
+ ## Core Rules
11
+
12
+ 1. **AAA Pattern (Arrange, Act, Assert):** Isolate state setup, action, and verification into distinct phases.
13
+ 2. **Parameterized / Datasets:** Use data-driven suites for multi-case logic (e.g., Pest `with()`, PHPUnit `#[DataProvider]`, Go table-driven, Pytest `@pytest.mark.parametrize`).
14
+ 3. **Hermetic State & Isolation:** Tests must not depend on execution order or leak data. Use database transactions with automatic rollback (e.g., `RefreshDatabase`, `DatabaseMigrations`), clean sqlite/in-memory instances, or isolated fixtures.
15
+ 4. **Deterministic Timing:** Never use arbitrary sleeps (`sleep()`, `usleep()`). Await promises, mock clocks/carbon (`Carbon::setTestNow()`), or poll conditions with bounded timeouts.
16
+ 5. **Pragmatic Mocks:** Favor public contracts, stubs, and in-memory fakes over brittle reflection mocks. Mock external boundaries (HTTP clients, payment gateways, mailers), never internal entities.
17
+
18
+ ## Edge Cases to Cover
19
+
20
+ - **Null / Falsy / Empty:** `null`, empty arrays (`[]`), zero values, empty collections, type casting bugs.
21
+ - **Boundaries & Limits:** Integer overflows (`PHP_INT_MAX`), off-by-one errors, pagination limits.
22
+ - **Error / Exception Branches:** Assert specific exception classes (`$this->expectException(DomainException::class)`) or error payloads, not generic errors.
23
+
24
+ ## Validation Checklist
25
+
26
+ - [ ] Target runner executes clean: `vendor/bin/pest`, `vendor/bin/phpunit`, `go test ./...`, `npm test`, `pytest`.
27
+ - [ ] No outbound network calls or active credentials in test suites.
28
+ - [ ] Failures report clear `got` vs `expected` diffs.
@@ -0,0 +1,11 @@
1
+ # Domain Glossary
2
+
3
+ Single source of truth for this project's vocabulary. Agents read it before naming anything; keep terms and code symbols 1:1.
4
+
5
+ | Term | Definition | Canonical representation | Invariants |
6
+ | :--- | :--- | :--- | :--- |
7
+ | _Example_ | _One-sentence business meaning._ | _`path/or/symbol`_ | _Rules that must always hold._ |
8
+
9
+ ## Forbidden jargon
10
+
11
+ * *Do not say:* "<vague term>". *Use instead:* "<canonical term>".