k-harness 0.7.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # K-Harness
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/k-harness.svg)](https://www.npmjs.com/package/k-harness)
4
+ [![npm downloads](https://img.shields.io/npm/dm/k-harness.svg)](https://www.npmjs.com/package/k-harness)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
3
7
  Project Direction Management Framework for LLM-Driven Development.
4
8
 
5
9
  ## What It Does
@@ -49,24 +53,22 @@ npx k-harness init --ide antigravity
49
53
 
50
54
  ## Supported IDEs
51
55
 
52
- | IDE | Global Rules | File-Scoped Rules | Skills | Agents |
53
- |-----|-------------|-------------------|--------|--------|
54
- | **VS Code Copilot** | `.github/copilot-instructions.md` | `.vscode/instructions/*.instructions.md` | `.github/skills/*/SKILL.md` | `.github/agents/*.agent.md` |
55
- | **Claude Code** | `CLAUDE.md` | (merged into CLAUDE.md) | `.claude/skills/*/SKILL.md` | (merged into CLAUDE.md) |
56
- | **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | (merged into rules) | (merged into rules) |
57
- | **Codex** | `AGENTS.md` | (merged into AGENTS.md) | `.agents/skills/*/SKILL.md` | (merged into AGENTS.md) |
58
- | **Windsurf** | `.windsurfrules` | (merged) | (merged) | (merged) |
59
- | **Augment Code** | `.augment/rules/core.md` | `.augment/rules/*.md` | `.augment/skills/*/SKILL.md` | `.augment/skills/*/SKILL.md` |
60
- | **Google Antigravity** | `.agent/rules/core.md` | `.agent/rules/*.md` | `.agent/skills/*/SKILL.md` | `.agent/skills/*/SKILL.md` |
56
+ | IDE | Dispatcher (always-on) | Skills | Agents |
57
+ |-----|----------------------|--------|--------|
58
+ | **VS Code Copilot** | `.github/copilot-instructions.md` | `.github/skills/*/SKILL.md` | `.github/agents/*.agent.md` |
59
+ | **Claude Code** | `.claude/rules/core.md` | `.claude/skills/*/SKILL.md` | `.claude/skills/*/SKILL.md` |
60
+ | **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | `.cursor/rules/*.mdc` |
61
+ | **Codex** | `AGENTS.md` | `.agents/skills/*/SKILL.md` | (merged into AGENTS.md) |
62
+ | **Windsurf** | `.windsurfrules` | (merged) | (merged) |
63
+ | **Augment Code** | `.augment/rules/core.md` | `.augment/skills/*/SKILL.md` | `.augment/skills/*/SKILL.md` |
64
+ | **Google Antigravity** | `.agent/rules/core.md` | `.agent/skills/*/SKILL.md` | `.agent/skills/*/SKILL.md` |
61
65
 
62
66
  All IDEs also get state files (`project-state.md`, `project-brief.md`, `features.md`, `failure-patterns.md`, `dependency-map.md`) in the `docs/` directory.
63
67
 
64
68
  ## What Gets Installed
65
69
 
66
- ### Rules (always active)
67
- - **Core Rules** — Architecture enforcement, Iron Laws, completion protocol, concreteness rules
68
- - **Testing Rules** — Mock synchronization, forbidden patterns (applied to test files)
69
- - **Backend Rules** — Dependency inversion, type safety, explicit staging (applied to source files)
70
+ ### Dispatcher (always active)
71
+ - **Core Rules** — 22-line dispatcher: session start guidance, workflow references, state file list. Detailed rules are embedded in each skill/agent that enforces them.
70
72
 
71
73
  ### Skills (on-demand procedures)
72
74
  - **bootstrap** — Onboard project into K-Harness: scans codebase + fills state files automatically
@@ -120,18 +122,18 @@ When goals, technology, or scope changes, run the `pivot` skill:
120
122
 
121
123
  See [docs/reference.md](docs/reference.md) for detailed descriptions of every skill, agent, rule, and state file.
122
124
 
123
- ## Why Not BMAD or gstack?
124
-
125
- | | BMAD v6.2.2 | gstack v0.15.1 | K-Harness |
126
- |---|---|---|---|
127
- | Focus | Enterprise SDLC methodology | 1-person software factory | Project direction management |
128
- | Files | 200+ | ~40 | ~20 |
129
- | Dependencies | Node 20+ | Bun + Node + Playwright | Zero |
130
- | IDE support | 20+ (installer) | 5 (setup --host) | 7 (native format) |
131
- | Direction management | ❌ | ❌ | ✅ (Direction Guard + pivot + Decision Log) |
132
- | Cold start | ❌ | ❌ | ✅ (bootstrap) |
133
- | State file audit | ❌ | ❌ | ✅ (reviewer Step 8) |
134
- | Context per task | 4-6 files | 1 file | 2-3 files |
125
+ ## Why K-Harness?
126
+
127
+ | | BMAD v6.2.2 | gstack v0.15.1 | GSD v1.33.0 | K-Harness |
128
+ |---|---|---|---|---|
129
+ | Focus | Enterprise SDLC methodology | 1-person software factory | Full lifecycle automation | Project direction management |
130
+ | Files | 200+ | ~40 | Hundreds | ~20 |
131
+ | Dependencies | Node 20+ | Bun + Node + Playwright | Node 18+ | Zero |
132
+ | IDE support | 20+ (installer) | 5 (setup --host) | 13 (runtime select) | 7 (native format) |
133
+ | Direction management | ❌ | ❌ | ❌ | ✅ (Direction Guard + pivot + Decision Log) |
134
+ | Iron Laws (code quality rules) | ❌ | ❌ | ❌ | ✅ (6 laws embedded in skills) |
135
+ | Cold start | ❌ | ❌ | `/gsd-new-project` | ✅ (`bootstrap` skill) |
136
+ | Context per task | 4-6 files | 1 file | Fresh 200k per plan | 2-3 files (22-line dispatcher) |
135
137
 
136
138
  ## License
137
139
 
@@ -105,6 +105,16 @@ If `docs/project-brief.md` alone is empty → Warn the user but proceed (the pla
105
105
  - Last changed: [Sprint/Story reference]
106
106
  ```
107
107
 
108
+ ## Enforced Rules
109
+
110
+ - **Direction Guard**: Before planning, read `docs/project-brief.md` and check:
111
+ - If it conflicts with **Non-Goals** → stop and ask the user
112
+ - If it contradicts a **Decision Log** entry → warn and recommend `pivot` skill
113
+ - If it represents a direction change → recommend `pivot` skill
114
+ - **Dependency Map**: When the plan adds or modifies modules, include docs/dependency-map.md updates in the plan.
115
+ - **Feature Registry**: When the plan adds a new feature, include docs/features.md registration in the plan.
116
+ - **Type Check**: Before referencing constructors or factories, verify parameters from source files. Do not rely on memory (FP-002).
117
+
108
118
  ## Constraints
109
119
 
110
120
  - Never skip reading docs/dependency-map.md — the plan is only as good as the map
@@ -99,6 +99,40 @@ For each missing update: flag as `[STATE-AUDIT]` in the output and provide the e
99
99
  STATUS: DONE / DONE_WITH_CONCERNS / BLOCKED
100
100
  ```
101
101
 
102
+ ## Embedded Rules
103
+
104
+ These rules are enforced during every review:
105
+
106
+ ### Iron Laws
107
+ 1. **Mock Sync**: Interface change → mock updated in same commit (FP-001)
108
+ 2. **Type Check**: Verify constructor/factory parameters from source, not memory (FP-002)
109
+ 3. **Scope Compliance**: Changes must be within current Story scope (docs/project-state.md)
110
+ 4. **Security**: No credentials, passwords, or API keys in code or commits
111
+ 5. **3-Failure Stop**: Same approach failed 3 times → stop and report
112
+ 6. **Dependency Map**: New/modified module → docs/dependency-map.md updated
113
+ 7. **Feature Registry**: New feature → docs/features.md updated
114
+ 8. **Session Handoff**: Session end → docs/project-state.md Quick Summary updated
115
+
116
+ ### Testing Rules
117
+ - New feature = New test. No feature code without tests.
118
+ - Mocks must implement ALL interface methods with sensible defaults.
119
+ - No `any` type casting on mocks. Use the actual interface type.
120
+ - No `skip`, `only`, or debug statements (`console.log`, `print`) in committed test files.
121
+ - Async tests must use `await`. No floating promises.
122
+
123
+ ### Backend Rules
124
+ - Follow project architecture pattern strictly (e.g., Domain must not import Infrastructure)
125
+ - No hardcoded environment variables or secrets — use centralized config
126
+ - Use explicit file staging (`git add <file>`), never `git add .` or `git add -A`
127
+
128
+ ### Completion Protocol
129
+ Report using: **DONE** | **DONE_WITH_CONCERNS** | **BLOCKED** | **NEEDS_CONTEXT**
130
+
131
+ ### Concreteness
132
+ - Specify exact file paths and line numbers
133
+ - Quote test names and error messages on failure
134
+ - Specify expected vs actual types on type errors
135
+
102
136
  ## Constraints
103
137
 
104
138
  - Do not refactor beyond the review scope
@@ -98,6 +98,11 @@ Progress: {done}/{total} Stories
98
98
  STATUS: DONE
99
99
  ```
100
100
 
101
+ ## Enforced Rules
102
+
103
+ - **Scope Compliance**: Do not modify files outside the current Story scope. If user requests an out-of-scope change, warn first and proceed only after confirmation.
104
+ - **Completion Protocol**: Report using: **DONE** | **DONE_WITH_CONCERNS** | **BLOCKED** | **NEEDS_CONTEXT**
105
+
101
106
  ## Constraints
102
107
 
103
108
  - Do not modify code directly — manage state only
@@ -1,135 +1,24 @@
1
- # Project Instructions
1
+ # K-Harness
2
2
 
3
- ## Architecture
3
+ This project uses K-Harness for structured AI-assisted development.
4
+ Skills and agents work together through shared state files — invoke them as needed.
4
5
 
5
- <!-- TODO: Describe your project's architecture here.
6
- Example:
7
- TypeScript / Express / PostgreSQL
8
- Hexagonal Architecture (Port + Adapter)
9
- -->
6
+ ## Session Start
10
7
 
11
- ## Directory Structure
8
+ Read `docs/project-state.md` first. If all state files are empty, run `bootstrap` skill.
12
9
 
13
- <!-- TODO: Map your directory structure.
14
- Example:
15
- src/
16
- ├── domain/ # Entities, Repository interfaces
17
- ├── application/ # Use Cases
18
- ├── infrastructure/ # DB, HTTP adapters
19
- ├── presentation/ # Controllers, DTOs
20
- └── shared/ # Utils, types, errors
21
- -->
10
+ ## Workflow
22
11
 
23
- ## Core Type Rules
12
+ - New feature → run `planner` before coding
13
+ - Before commit → run `reviewer`
14
+ - Bug or issue → run `investigate`
15
+ - Session end → run `learn`
16
+ - Direction change → run `pivot`
24
17
 
25
- <!-- TODO: Document type decisions that LLMs frequently get wrong.
26
- Example:
27
- - `ServerType` is a union type ("stdio" | "sse"), NOT an enum.
28
- - `UserRole` is a union type ("admin" | "user"), NOT an enum.
29
- -->
18
+ ## State Files
30
19
 
31
- ## Iron Laws
32
-
33
- 1. **Mock Sync**: When you modify a repository/service interface, update corresponding mocks in the same commit.
34
- 2. **Type Check**: Before calling a constructor or factory, read the actual source file to verify parameters. Do not rely on memory.
35
- 3. **Scope Compliance**: Do not modify files outside the current Story scope (see docs/project-state.md) without reporting first.
36
- 4. **Security**: Never include credentials, passwords, or API keys in code or commits.
37
- 5. **3-Failure Stop**: If the same approach fails 3 times, stop and report to the user.
38
- 6. **Dependency Map**: When adding or modifying a module, update docs/dependency-map.md in the same commit. Register new modules, update relationship columns.
39
- 7. **Feature Registry**: When adding a new feature, register it in docs/features.md in the same commit. Include key files and test files.
40
- 8. **Session Handoff**: Before ending a chat session, update docs/project-state.md Quick Summary. Never leave the project in an undocumented state.
41
-
42
- ## Test Rules
43
-
44
- - New feature = New test. Do not commit feature code without tests.
45
- - Test command: <!-- TODO: e.g. npm test, pytest, go test ./..., mvn test -->
46
- - Mock location: <!-- TODO: e.g. tests/__mocks__/, test/fixtures/ -->
47
-
48
- ## Completion Status Protocol
49
-
50
- Report completion using one of:
51
- - **DONE**: All steps completed. Present evidence (test results, file list, etc).
52
- - **DONE_WITH_CONCERNS**: Completed but with concerns. List each concern.
53
- - **BLOCKED**: Cannot proceed. Describe the cause and what was tried.
54
- - **NEEDS_CONTEXT**: Need more information. Describe exactly what is needed.
55
-
56
- ## Concreteness Rules
57
-
58
- - When modifying files, specify exact paths and line numbers.
59
- - When tests fail, quote the test name and error message.
60
- - When type errors occur, specify expected type and actual type.
61
-
62
- ## Direction Guard (Every Request)
63
-
64
- Before starting ANY coding task, do this:
65
-
66
- 1. Read `docs/project-brief.md` — check Vision, Goals, Non-Goals, and Decision Log
67
- 2. If `docs/project-brief.md` is empty → run the `bootstrap` skill first, then return to the request
68
- 3. If the request conflicts with **Non-Goals** → stop and warn: "This falls under Non-Goals. Do you want to proceed? If yes, run `pivot` skill first."
69
- 4. If the request contradicts a **Decision Log** entry → warn: "This conflicts with a previous decision: [entry]. Run `pivot` skill to update direction."
70
- 5. If aligned → proceed
71
-
72
- This applies to EVERY request, not just new sessions. Skip only for trivial questions ("what does this function do?").
73
-
74
- ## New Session Bootstrap
75
-
76
- When starting a NEW chat session, read these files in order before doing any work:
77
- 1. `docs/project-state.md` — Quick Summary tells you where we left off
78
- 2. `docs/features.md` — What features exist in this project
79
- 3. `docs/failure-patterns.md` — What mistakes to avoid
80
- 4. `docs/project-brief.md` — Project vision, goals, and non-goals
81
-
82
- If ALL state files are empty (only TODOs/placeholders), run the `bootstrap` skill before doing anything else.
83
-
84
- ### Health Check (every session start)
85
-
86
- After reading state files, also check this file for unfilled placeholders:
87
- - If the `## Architecture` section still has `<!-- TODO -->` → warn: **"Core rules are incomplete. Run `bootstrap` to auto-fill."**
88
- - If the `## Test Rules` section still has `<!-- TODO -->` for test command → warn the same
89
- - If any rules file has globs that don't match the project language (e.g., `src/**/*.ts` for a Python project) → warn: **"Rules globs don't match your project language. Run `bootstrap` to fix."**
90
-
91
- Do NOT proceed with work until the user acknowledges or resolves these warnings.
92
-
93
- ## Workflow Pipeline
94
-
95
- Follow this order for different workflows. Each step's output feeds the next.
96
-
97
- ### New Feature
98
- ```
99
- bootstrap (if state files empty) → planner → [code] → reviewer → sprint-manager → learn
100
- ```
101
-
102
- ### Bug Fix
103
- ```
104
- investigate → [fix] → test-integrity → reviewer → learn
105
- ```
106
-
107
- ### Session Lifecycle
108
- ```
109
- [session start] → sprint-manager ("where are we?") → [work] → learn → [session end]
110
- ```
111
-
112
- ### Key Rules
113
- - **planner before code**: Never start coding a feature without running planner first.
114
- - **reviewer before commit**: Never commit without running reviewer.
115
- - **learn before closing**: Run learn as the last skill of every session.
116
- - **bootstrap once**: Run bootstrap once when state files are empty. Not needed after that.
117
-
118
- ## References
119
-
120
- - docs/project-brief.md — Project vision, goals, non-goals (the "why")
121
- - docs/features.md — Feature registry (the "what")
122
- - docs/project-state.md — Sprint/Story tracking, module registry (the "where")
123
- - docs/dependency-map.md — Module dependency graph (the "how")
124
- - docs/failure-patterns.md — Log of known failure patterns (the "watch out")
125
- - docs/agent-memory/ — Per-agent persistent memory (the "learned")
126
-
127
- ## State File Size Limits
128
-
129
- State files must stay compact to fit in LLM context windows. Enforce these limits:
130
- - **docs/project-brief.md**: Max 200 lines. Keep Vision/Goals/Non-Goals concise.
131
- - **docs/project-state.md**: Max 300 lines. Archive completed sprints when exceeding limit.
132
- - **docs/failure-patterns.md**: Max 50 patterns. Periodically remove `Status: Resolved` entries.
133
- - **docs/dependency-map.md**: Max 100 modules. Merge trivial internal modules.
134
- - **docs/features.md**: Max 50 features. Archive shipped features when exceeding limit.
135
- - **docs/agent-memory/*.md**: Max 100 lines each. Keep only actionable learnings.
20
+ - docs/project-state.md — current sprint/story and quick summary
21
+ - docs/failure-patterns.md — known pitfalls (FP-NNN)
22
+ - docs/dependency-map.md module dependency graph
23
+ - docs/features.md feature registry
24
+ - docs/project-brief.md project vision, goals, and non-goals
@@ -75,55 +75,23 @@ Using data from Phase 1 + Phase 2, fill the following files:
75
75
  - Keep FP-001 through FP-004 as templates (Frequency: 0)
76
76
  - No changes unless user reports known issues
77
77
 
78
- ### Phase 3.5: Rules Auto-Configuration
79
-
80
- Using language/framework detected in Phase 1 + user answers from Phase 2, auto-configure the project's rules files.
81
-
82
- 1. **Find the core rules file** Search for the file containing `<!-- TODO: Describe your project's architecture here -->`:
83
- - VS Code: `.github/copilot-instructions.md`
84
- - Claude: `CLAUDE.md`
85
- - Cursor: `.cursor/rules/core.mdc`
86
- - Codex: `AGENTS.md`
87
- - Windsurf: `.windsurfrules`
88
- - Augment: `.augment/rules/core.md`
89
- - Antigravity: `.agent/rules/core.md`
90
-
91
- 2. **Fill `## Architecture` section** — Replace the TODO with detected tech stack:
92
- ```
93
- ## Architecture
94
- [Language] / [Framework] / [Database if detected]
95
- [Architecture pattern from user answer #4]
96
- ```
97
-
98
- 3. **Fill `## Directory Structure` section** — Replace the TODO with actual tree from Phase 1:
99
- ```
100
- ## Directory Structure
101
- project-root/
102
- ├── src/ # [purpose from scan]
103
- ├── tests/ # [purpose from scan]
104
- └── ...
105
- ```
106
-
107
- 4. **Fill `## Core Type Rules` section** — Replace the TODO with user answer #5 plus language defaults:
78
+ ### Phase 3.5: Project Brief Auto-Configuration
79
+
80
+ Using language/framework detected in Phase 1 + user answers from Phase 2, enrich `docs/project-brief.md`:
81
+
82
+ 1. **Fill Key Technical Decisions** with detected tech stack:
83
+ - Language, framework, database (from Phase 1)
84
+ - Architecture pattern (from user answer #4)
85
+ - Type conventions (from user answer #5)
86
+ - Test command and mock location (from user answer #6)
87
+
88
+ 2. **Add language-specific defaults** to Key Technical Decisions if not already present:
108
89
  - Python: `Use Pydantic models for API schemas, not plain dicts.`
109
90
  - TypeScript: `Prefer union types ("a" | "b") over enums.`
110
91
  - Go: `Use interfaces for dependency injection.`
111
92
  - Java: `Use records for DTOs.`
112
93
  - Rust: `Use enum variants, not string constants.`
113
94
 
114
- 5. **Fill `## Test Rules`** — Set test command (from user answer #6) and mock location (from Phase 1):
115
- ```
116
- - Test command: [detected or user-provided, e.g. pytest, npm test, go test ./...]
117
- - Mock location: [detected, e.g. tests/conftest.py, tests/__mocks__/]
118
- ```
119
-
120
- 6. **Verify globs** — Check backend and testing rules files have correct globs for the detected language:
121
- - Python: backend `**/*.py`, testing `**/test_*.py,**/tests/**/*.py`
122
- - TypeScript: backend `src/**/*.ts,src/**/*.js`, testing `**/*.test.*,**/*.spec.*`
123
- - Go: backend `**/*.go`, testing `**/*_test.go`
124
- - Java: backend `src/main/**/*.java`, testing `src/test/**/*.java`
125
- - If globs don't match → **edit the file directly** to set correct globs
126
-
127
95
  ### Phase 4: Verify
128
96
 
129
97
  1. Present a summary of all filled state files to the user
@@ -150,12 +118,6 @@ Using language/framework detected in Phase 1 + user answers from Phase 2, auto-c
150
118
  - [x]docs/project-state.md — Sprint 1 initialized
151
119
  - [ ]docs/failure-patterns.md — templates only (no changes)
152
120
 
153
- ### Rules Files Configured:
154
- - [x] Core rules — Architecture, Directory Structure, Type Rules filled
155
- - [x] Test command — [detected command]
156
- - [x] Backend globs — [globs set]
157
- - [x] Testing globs — [globs set]
158
-
159
121
  STATUS: DONE
160
122
  ```
161
123
 
@@ -168,6 +130,28 @@ STATUS: DONE
168
130
  - Rules file TODO sections can be overwritten without asking (they are placeholders)
169
131
  - Run this skill only once per project (or when explicitly requested for refresh)
170
132
 
133
+ ## Embedded Knowledge
134
+
135
+ ### Session Bootstrap Protocol
136
+ When starting a NEW session (not during bootstrap), read these files in order:
137
+ 1. `docs/project-state.md` — Quick Summary tells you where we left off
138
+ 2. `docs/features.md` — What features exist
139
+ 3. `docs/failure-patterns.md` — What mistakes to avoid
140
+ 4. `docs/project-brief.md` — Project vision and non-goals
141
+
142
+ ### Workflow Pipeline
143
+ - New feature: `planner → [code] → reviewer → sprint-manager → learn`
144
+ - Bug fix: `investigate → [fix] → test-integrity → reviewer → learn`
145
+ - Session lifecycle: `sprint-manager ("where are we?") → [work] → learn`
146
+
147
+ ### State File Size Limits
148
+ - docs/project-brief.md: Max 200 lines
149
+ - docs/project-state.md: Max 300 lines
150
+ - docs/failure-patterns.md: Max 50 patterns
151
+ - docs/dependency-map.md: Max 100 modules
152
+ - docs/features.md: Max 50 features
153
+ - docs/agent-memory/*.md: Max 100 lines each
154
+
171
155
  ## Anti-patterns
172
156
 
173
157
  | Anti-pattern | Correct Approach |
@@ -74,6 +74,12 @@ After the fix is verified (Phase 4):
74
74
  - [ ] **docs/failure-patterns.md**: If the root cause is a repeatable pattern, add a new FP-NNN entry or increment the Frequency of an existing one. This is NOT optional.
75
75
  - [ ] **docs/project-state.md**: Add the fix to Recent Changes with the root cause hypothesis.
76
76
 
77
+ ## Enforced Rules
78
+
79
+ - **3-Failure Stop**: If the same fix approach fails 3 times, stop and report to the user. Do not keep trying.
80
+ - **Concreteness**: Specify exact file paths and line numbers. Quote error messages. Specify expected vs actual types.
81
+ - **Scope Lock**: Do not modify files outside the identified problem scope (Phase 2).
82
+
77
83
  ## Related Failure Patterns
78
84
 
79
85
  - FP-002: Type confusion → Phase 1 requires verifying actual types
@@ -108,6 +108,17 @@ STATUS: DONE
108
108
  - Do not modify source code — this skill only updates state files
109
109
  - Quick Summary must be exactly 3 lines — concise enough for the next session to scan instantly
110
110
 
111
+ ## Enforced Rules
112
+
113
+ - **Session Handoff**: Before ending a session, docs/project-state.md Quick Summary MUST be updated. Never leave the project in an undocumented state.
114
+ - **State File Size Limits**: Keep state files compact for LLM context windows:
115
+ - docs/project-brief.md: Max 200 lines
116
+ - docs/project-state.md: Max 300 lines (archive completed sprints)
117
+ - docs/failure-patterns.md: Max 50 patterns (remove resolved entries)
118
+ - docs/dependency-map.md: Max 100 modules
119
+ - docs/features.md: Max 50 features
120
+ - docs/agent-memory/*.md: Max 100 lines each
121
+
111
122
  ## Anti-patterns
112
123
 
113
124
  | Anti-pattern | Correct Approach |
@@ -48,6 +48,15 @@ After synchronizing mocks:
48
48
  - [ ] **docs/failure-patterns.md**: If mock sync was missed and caused a test failure, increment FP-001 Frequency.
49
49
  - [ ] **docs/dependency-map.md**: If the interface change altered module relationships, update the relevant row.
50
50
 
51
+ ## Testing Rules (enforced during this skill)
52
+
53
+ - Mocks must implement ALL interface methods. Missing method = build failure.
54
+ - No `any` type casting on mocks. Create mocks using the actual interface type.
55
+ - New methods must have default mock return values (e.g., `mockResolvedValue`, stub returns).
56
+ - No `skip`, `only`, or debug statements in committed test files.
57
+ - Async tests must use `await`. No floating promises.
58
+ - Each test must be independent. No shared state between tests.
59
+
51
60
  ## Related Failure Patterns
52
61
 
53
62
  - FP-001: Interface changed, mock not updated → Checklist item 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k-harness",
3
- "version": "0.7.0",
3
+ "version": "0.8.2",
4
4
  "description": "LLM Development Harness — IDE-agnostic rules, skills, and agents that prevent common AI coding failures",
5
5
  "keywords": [
6
6
  "llm",
package/src/init.js CHANGED
@@ -76,32 +76,7 @@ function detectLanguage(targetDir) {
76
76
  return 'typescript';
77
77
  }
78
78
 
79
- const LANG_GLOBS = {
80
- typescript: {
81
- backend: 'src/**/*.ts,src/**/*.js',
82
- testing: '**/*.test.ts,**/*.test.js,**/*.spec.ts,**/*.spec.js,**/__mocks__/**,**/__tests__/**',
83
- },
84
- python: {
85
- backend: '**/*.py',
86
- testing: '**/test_*.py,**/tests/**/*.py,**/*_test.py,**/conftest.py',
87
- },
88
- go: {
89
- backend: '**/*.go',
90
- testing: '**/*_test.go',
91
- },
92
- java: {
93
- backend: 'src/main/**/*.java',
94
- testing: 'src/test/**/*.java',
95
- },
96
- rust: {
97
- backend: 'src/**/*.rs',
98
- testing: 'tests/**/*.rs,**/tests.rs',
99
- },
100
- ruby: {
101
- backend: '**/*.rb',
102
- testing: 'spec/**/*.rb,test/**/*.rb',
103
- },
104
- };
79
+
105
80
 
106
81
  // ─── Shared writers ──────────────────────────────────────────
107
82
 
@@ -137,26 +112,11 @@ function writeAgentsAsSkills(targetDir, skillsDir, overwrite) {
137
112
  // ─── IDE Generators ──────────────────────────────────────────
138
113
 
139
114
  function generateVscode(targetDir, overwrite) {
140
- const lang = detectLanguage(targetDir);
141
- const globs = LANG_GLOBS[lang];
142
115
  const coreRules = readTemplate('core-rules.md');
143
- const testingRules = readTemplate('testing-rules.md');
144
- const backendRules = readTemplate('backend-rules.md');
145
116
 
146
- // Global instructions
117
+ // Global instructions (dispatcher only — rules are embedded in skills)
147
118
  writeFile(targetDir, '.github/copilot-instructions.md', coreRules, overwrite);
148
119
 
149
- // File-scoped instructions (add VS Code applyTo frontmatter)
150
- const testingWithFrontmatter =
151
- `---\napplyTo: "${globs.testing}"\n---\n\n` +
152
- testingRules;
153
- writeFile(targetDir, '.vscode/instructions/testing.instructions.md', testingWithFrontmatter, overwrite);
154
-
155
- const backendWithFrontmatter =
156
- `---\napplyTo: "${globs.backend}"\n---\n\n` +
157
- backendRules;
158
- writeFile(targetDir, '.vscode/instructions/backend.instructions.md', backendWithFrontmatter, overwrite);
159
-
160
120
  // Skills (.github/skills — VS Code default search path, SKILL.md with frontmatter)
161
121
  writeSkills(targetDir, '.github/skills', overwrite);
162
122
 
@@ -174,50 +134,32 @@ function generateVscode(targetDir, overwrite) {
174
134
  }
175
135
 
176
136
  function generateClaude(targetDir, overwrite) {
177
- // CLAUDE.md — merge core + testing + backend rules
178
- const merged = [
179
- readTemplate('core-rules.md'),
180
- '\n---\n\n',
181
- readTemplate('testing-rules.md'),
182
- '\n---\n\n',
183
- readTemplate('backend-rules.md'),
184
- ].join('');
185
- writeFile(targetDir, 'CLAUDE.md', merged, overwrite);
137
+ // .claude/rules/core.md — dispatcher only (no paths = always loaded)
138
+ writeFile(targetDir, '.claude/rules/core.md', readTemplate('core-rules.md'), overwrite);
186
139
 
187
- // Skills (SKILL.md with frontmatter for slash commands)
140
+ // Skills (SKILL.md with frontmatter)
188
141
  writeSkills(targetDir, '.claude/skills', overwrite);
189
142
 
143
+ // Agents as skills (Claude Code skills pattern)
144
+ writeAgentsAsSkills(targetDir, '.claude/skills', overwrite);
145
+
190
146
  // State files
191
147
  writeStateFiles(targetDir, overwrite);
192
148
  }
193
149
 
194
150
  function generateCursor(targetDir, overwrite) {
195
- const lang = detectLanguage(targetDir);
196
- const globs = LANG_GLOBS[lang];
197
- // .cursor/rules/*.mdc — each needs frontmatter
151
+ // .cursor/rules/core.mdc dispatcher only
198
152
  const coreRules = readTemplate('core-rules.md');
199
153
  const coreMdc =
200
- '---\ndescription: Core project rules Iron Laws, completion protocol, concreteness\nalwaysApply: true\n---\n\n' +
154
+ '---\ndescription: K-Harness dispatcherworkflow guidance and state file references\nalwaysApply: true\n---\n\n' +
201
155
  coreRules;
202
156
  writeFile(targetDir, '.cursor/rules/core.mdc', coreMdc, overwrite);
203
157
 
204
- const testingRules = readTemplate('testing-rules.md');
205
- const testingMdc =
206
- `---\ndescription: Testing rules — mock sync, forbidden patterns\nglobs: "${globs.testing}"\nalwaysApply: false\n---\n\n` +
207
- testingRules;
208
- writeFile(targetDir, '.cursor/rules/testing.mdc', testingMdc, overwrite);
209
-
210
- const backendRules = readTemplate('backend-rules.md');
211
- const backendMdc =
212
- `---\ndescription: Backend code rules — architecture enforcement, type safety\nglobs: "${globs.backend}"\nalwaysApply: false\n---\n\n` +
213
- backendRules;
214
- writeFile(targetDir, '.cursor/rules/backend.mdc', backendMdc, overwrite);
215
-
216
158
  // Skills as rules
217
159
  for (const skill of SKILLS) {
218
160
  const content = readTemplate(`skills/${skill.id}.md`);
219
161
  const mdc =
220
- `---\ndescription: Skill — ${skill.id}\nalwaysApply: false\n---\n\n` +
162
+ `---\ndescription: ${skill.desc}\nalwaysApply: false\n---\n\n` +
221
163
  content;
222
164
  writeFile(targetDir, `.cursor/rules/${skill.id}.mdc`, mdc, overwrite);
223
165
  }
@@ -226,7 +168,7 @@ function generateCursor(targetDir, overwrite) {
226
168
  for (const agent of AGENTS) {
227
169
  const content = readTemplate(agent.file);
228
170
  const mdc =
229
- `---\ndescription: Agent — ${agent.id}\nalwaysApply: false\n---\n\n` +
171
+ `---\ndescription: ${agent.desc}\nalwaysApply: false\n---\n\n` +
230
172
  content;
231
173
  writeFile(targetDir, `.cursor/rules/${agent.id}.mdc`, mdc, overwrite);
232
174
  }
@@ -236,15 +178,8 @@ function generateCursor(targetDir, overwrite) {
236
178
  }
237
179
 
238
180
  function generateCodex(targetDir, overwrite) {
239
- // AGENTS.md — merge core + testing + backend rules
240
- const merged = [
241
- readTemplate('core-rules.md'),
242
- '\n---\n\n',
243
- readTemplate('testing-rules.md'),
244
- '\n---\n\n',
245
- readTemplate('backend-rules.md'),
246
- ].join('');
247
- writeFile(targetDir, 'AGENTS.md', merged, overwrite);
181
+ // AGENTS.md — dispatcher only
182
+ writeFile(targetDir, 'AGENTS.md', readTemplate('core-rules.md'), overwrite);
248
183
 
249
184
  // Skills (SKILL.md with frontmatter for slash commands)
250
185
  writeSkills(targetDir, '.agents/skills', overwrite);
@@ -254,48 +189,21 @@ function generateCodex(targetDir, overwrite) {
254
189
  }
255
190
 
256
191
  function generateWindsurf(targetDir, overwrite) {
257
- // .windsurfrules — everything in one file
258
- const sections = [
259
- readTemplate('core-rules.md'),
260
- readTemplate('testing-rules.md'),
261
- readTemplate('backend-rules.md'),
262
- '---\n\n# Skills\n\n',
263
- ];
264
- for (const skill of SKILLS) {
265
- sections.push(readTemplate(`skills/${skill.id}.md`));
266
- }
267
- sections.push('---\n\n# Agents\n\n');
268
- for (const agent of AGENTS) {
269
- sections.push(readTemplate(agent.file));
270
- }
271
- writeFile(targetDir, '.windsurfrules', sections.join('\n\n---\n\n'), overwrite);
192
+ // .windsurfrules — dispatcher only (rules are embedded in skills)
193
+ writeFile(targetDir, '.windsurfrules', readTemplate('core-rules.md'), overwrite);
272
194
 
273
195
  // State files
274
196
  writeStateFiles(targetDir, overwrite);
275
197
  }
276
198
 
277
199
  function generateAugment(targetDir, overwrite) {
278
- const lang = detectLanguage(targetDir);
279
- const globs = LANG_GLOBS[lang];
280
- // .augment/rules/ — Always-type rules for core, testing, backend
200
+ // .augment/rules/core.md dispatcher only
281
201
  const coreRules = readTemplate('core-rules.md');
282
202
  const coreRule =
283
- '---\ndescription: Core project rules Iron Laws, completion protocol, concreteness\ntype: always\n---\n\n' +
203
+ '---\ndescription: K-Harness dispatcherworkflow guidance and state file references\ntype: always\n---\n\n' +
284
204
  coreRules;
285
205
  writeFile(targetDir, '.augment/rules/core.md', coreRule, overwrite);
286
206
 
287
- const testingRules = readTemplate('testing-rules.md');
288
- const testingRule =
289
- `---\ndescription: Testing rules — mock sync, forbidden patterns\ntype: auto\nglobs: "${globs.testing}"\n---\n\n` +
290
- testingRules;
291
- writeFile(targetDir, '.augment/rules/testing.md', testingRule, overwrite);
292
-
293
- const backendRules = readTemplate('backend-rules.md');
294
- const backendRule =
295
- `---\ndescription: Backend code rules — architecture enforcement, type safety\ntype: auto\nglobs: "${globs.backend}"\n---\n\n` +
296
- backendRules;
297
- writeFile(targetDir, '.augment/rules/backend.md', backendRule, overwrite);
298
-
299
207
  // .augment/skills/ — SKILL.md format (enables / slash commands)
300
208
  writeSkills(targetDir, '.augment/skills', overwrite);
301
209
  writeAgentsAsSkills(targetDir, '.augment/skills', overwrite);
@@ -305,27 +213,13 @@ function generateAugment(targetDir, overwrite) {
305
213
  }
306
214
 
307
215
  function generateAntigravity(targetDir, overwrite) {
308
- const lang = detectLanguage(targetDir);
309
- const globs = LANG_GLOBS[lang];
310
- // .agent/rules/ — Always-type rules (same as Augment format, read by Antigravity)
216
+ // .agent/rules/core.md dispatcher only
311
217
  const coreRules = readTemplate('core-rules.md');
312
218
  const coreRule =
313
- '---\ndescription: Core project rules Iron Laws, completion protocol, concreteness\ntype: always\n---\n\n' +
219
+ '---\ndescription: K-Harness dispatcherworkflow guidance and state file references\ntype: always\n---\n\n' +
314
220
  coreRules;
315
221
  writeFile(targetDir, '.agent/rules/core.md', coreRule, overwrite);
316
222
 
317
- const testingRules = readTemplate('testing-rules.md');
318
- const testingRule =
319
- `---\ndescription: Testing rules — mock sync, forbidden patterns\ntype: auto\nglobs: "${globs.testing}"\n---\n\n` +
320
- testingRules;
321
- writeFile(targetDir, '.agent/rules/testing.md', testingRule, overwrite);
322
-
323
- const backendRules = readTemplate('backend-rules.md');
324
- const backendRule =
325
- `---\ndescription: Backend code rules — architecture enforcement, type safety\ntype: auto\nglobs: "${globs.backend}"\n---\n\n` +
326
- backendRules;
327
- writeFile(targetDir, '.agent/rules/backend.md', backendRule, overwrite);
328
-
329
223
  // .agent/skills/ — SKILL.md format (enables / slash commands)
330
224
  writeSkills(targetDir, '.agent/skills', overwrite);
331
225
  writeAgentsAsSkills(targetDir, '.agent/skills', overwrite);
@@ -437,4 +331,4 @@ async function run(argv) {
437
331
  }
438
332
  }
439
333
 
440
- module.exports = { run, detectLanguage, LANG_GLOBS };
334
+ module.exports = { run, detectLanguage };
@@ -1,24 +0,0 @@
1
- # Backend Code Rules
2
-
3
- ## Required
4
-
5
- - Follow the project's architecture patterns strictly.
6
- <!-- TODO: Define your architecture layers. Examples:
7
- - Domain layer must not import from infrastructure.
8
- - Application layer accesses data only through domain interfaces.
9
- - Infrastructure implements domain interfaces.
10
- - Controllers/routes handle request/response only. No business logic.
11
- -->
12
- - Before calling any constructor or factory, read the actual source file to verify parameters. Do not trust memory. (FP-002)
13
-
14
- ## Forbidden
15
-
16
- - Violating the project's dependency direction (e.g. importing infrastructure from domain).
17
- - Suppressing type safety without an explicit reason comment.
18
- - Hardcoding environment variables or secrets in code. Use centralized config.
19
- - `git add .` or `git add -A` — use explicit per-file staging.
20
-
21
- ## References
22
-
23
- - docs/failure-patterns.md FP-002: Type confusion
24
- - docs/failure-patterns.md FP-004: Unnecessary files committed
@@ -1,21 +0,0 @@
1
- # Testing Rules
2
-
3
- ## Required
4
-
5
- - When interface changes, update corresponding mocks in the same commit (FP-001).
6
- - Mocks must implement ALL interface methods. Missing method = build failure.
7
- - Do not use real credentials in test data. Use fixtures or fakers.
8
- - Async tests must use `await`. No floating promises.
9
- - Each test must be independent. No shared state between tests.
10
-
11
- ## Forbidden
12
-
13
- - Casting mocks with `any` type. Create mocks using the actual interface type.
14
- - Creating mocks with no default return values. Always set sensible defaults (e.g. `mockResolvedValue`, stub returns).
15
- - Committing with `skip` or `only` left in test files.
16
- - Committing with debugging statements (e.g. `console.log`, `print`, `println`).
17
-
18
- ## References
19
-
20
- - test-integrity skill
21
- - docs/failure-patterns.md FP-001: Mock not updated