k-harness 0.6.0 → 0.8.1
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 +11 -13
- package/harness/agents/planner.md +10 -0
- package/harness/agents/reviewer.md +34 -0
- package/harness/agents/sprint-manager.md +5 -0
- package/harness/core-rules.md +17 -119
- package/harness/skills/bootstrap.md +47 -2
- package/harness/skills/investigate.md +6 -0
- package/harness/skills/learn.md +11 -0
- package/harness/skills/test-integrity.md +9 -0
- package/package.json +1 -1
- package/src/init.js +40 -93
- package/harness/backend-rules.md +0 -24
- package/harness/testing-rules.md +0 -21
package/README.md
CHANGED
|
@@ -49,24 +49,22 @@ npx k-harness init --ide antigravity
|
|
|
49
49
|
|
|
50
50
|
## Supported IDEs
|
|
51
51
|
|
|
52
|
-
| IDE |
|
|
53
|
-
|
|
54
|
-
| **VS Code Copilot** | `.github/copilot-instructions.md` | `.
|
|
55
|
-
| **Claude Code** |
|
|
56
|
-
| **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` |
|
|
57
|
-
| **Codex** | `AGENTS.md` |
|
|
58
|
-
| **Windsurf** | `.windsurfrules` | (merged) | (merged) |
|
|
59
|
-
| **Augment Code** | `.augment/rules/core.md` | `.augment/
|
|
60
|
-
| **Google Antigravity** | `.agent/rules/core.md` | `.agent/
|
|
52
|
+
| IDE | Dispatcher (always-on) | Skills | Agents |
|
|
53
|
+
|-----|----------------------|--------|--------|
|
|
54
|
+
| **VS Code Copilot** | `.github/copilot-instructions.md` | `.github/skills/*/SKILL.md` | `.github/agents/*.agent.md` |
|
|
55
|
+
| **Claude Code** | `.claude/rules/core.md` | `.claude/skills/*/SKILL.md` | `.claude/skills/*/SKILL.md` |
|
|
56
|
+
| **Cursor** | `.cursor/rules/core.mdc` | `.cursor/rules/*.mdc` | `.cursor/rules/*.mdc` |
|
|
57
|
+
| **Codex** | `AGENTS.md` | `.agents/skills/*/SKILL.md` | (merged into AGENTS.md) |
|
|
58
|
+
| **Windsurf** | `.windsurfrules` | (merged) | (merged) |
|
|
59
|
+
| **Augment Code** | `.augment/rules/core.md` | `.augment/skills/*/SKILL.md` | `.augment/skills/*/SKILL.md` |
|
|
60
|
+
| **Google Antigravity** | `.agent/rules/core.md` | `.agent/skills/*/SKILL.md` | `.agent/skills/*/SKILL.md` |
|
|
61
61
|
|
|
62
62
|
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
63
|
|
|
64
64
|
## What Gets Installed
|
|
65
65
|
|
|
66
|
-
###
|
|
67
|
-
- **Core 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)
|
|
66
|
+
### Dispatcher (always active)
|
|
67
|
+
- **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
68
|
|
|
71
69
|
### Skills (on-demand procedures)
|
|
72
70
|
- **bootstrap** — Onboard project into K-Harness: scans codebase + fills state files automatically
|
|
@@ -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
|
package/harness/core-rules.md
CHANGED
|
@@ -1,126 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# K-Harness
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
Example:
|
|
7
|
-
TypeScript / Express / PostgreSQL
|
|
8
|
-
Hexagonal Architecture (Port + Adapter)
|
|
9
|
-
-->
|
|
6
|
+
## Session Start
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
Read `docs/project-state.md` first. If all state files are empty, run `bootstrap` skill.
|
|
12
9
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
## Workflow Pipeline
|
|
85
|
-
|
|
86
|
-
Follow this order for different workflows. Each step's output feeds the next.
|
|
87
|
-
|
|
88
|
-
### New Feature
|
|
89
|
-
```
|
|
90
|
-
bootstrap (if state files empty) → planner → [code] → reviewer → sprint-manager → learn
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Bug Fix
|
|
94
|
-
```
|
|
95
|
-
investigate → [fix] → test-integrity → reviewer → learn
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Session Lifecycle
|
|
99
|
-
```
|
|
100
|
-
[session start] → sprint-manager ("where are we?") → [work] → learn → [session end]
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Key Rules
|
|
104
|
-
- **planner before code**: Never start coding a feature without running planner first.
|
|
105
|
-
- **reviewer before commit**: Never commit without running reviewer.
|
|
106
|
-
- **learn before closing**: Run learn as the last skill of every session.
|
|
107
|
-
- **bootstrap once**: Run bootstrap once when state files are empty. Not needed after that.
|
|
108
|
-
|
|
109
|
-
## References
|
|
110
|
-
|
|
111
|
-
- docs/project-brief.md — Project vision, goals, non-goals (the "why")
|
|
112
|
-
- docs/features.md — Feature registry (the "what")
|
|
113
|
-
- docs/project-state.md — Sprint/Story tracking, module registry (the "where")
|
|
114
|
-
- docs/dependency-map.md — Module dependency graph (the "how")
|
|
115
|
-
- docs/failure-patterns.md — Log of known failure patterns (the "watch out")
|
|
116
|
-
- docs/agent-memory/ — Per-agent persistent memory (the "learned")
|
|
117
|
-
|
|
118
|
-
## State File Size Limits
|
|
119
|
-
|
|
120
|
-
State files must stay compact to fit in LLM context windows. Enforce these limits:
|
|
121
|
-
- **docs/project-brief.md**: Max 200 lines. Keep Vision/Goals/Non-Goals concise.
|
|
122
|
-
- **docs/project-state.md**: Max 300 lines. Archive completed sprints when exceeding limit.
|
|
123
|
-
- **docs/failure-patterns.md**: Max 50 patterns. Periodically remove `Status: Resolved` entries.
|
|
124
|
-
- **docs/dependency-map.md**: Max 100 modules. Merge trivial internal modules.
|
|
125
|
-
- **docs/features.md**: Max 50 features. Archive shipped features when exceeding limit.
|
|
126
|
-
- **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
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
Onboard a new or existing project into K-Harness by filling state files automatically.
|
|
5
|
+
Onboard a new or existing project into K-Harness by filling **state files AND rules files** automatically.
|
|
6
6
|
Solves the cold-start problem: users don't know which `.md` files to fill or how.
|
|
7
|
+
One command does everything — no manual editing required.
|
|
7
8
|
|
|
8
9
|
## When to Apply
|
|
9
10
|
|
|
@@ -74,6 +75,23 @@ Using data from Phase 1 + Phase 2, fill the following files:
|
|
|
74
75
|
- Keep FP-001 through FP-004 as templates (Frequency: 0)
|
|
75
76
|
- No changes unless user reports known issues
|
|
76
77
|
|
|
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:
|
|
89
|
+
- Python: `Use Pydantic models for API schemas, not plain dicts.`
|
|
90
|
+
- TypeScript: `Prefer union types ("a" | "b") over enums.`
|
|
91
|
+
- Go: `Use interfaces for dependency injection.`
|
|
92
|
+
- Java: `Use records for DTOs.`
|
|
93
|
+
- Rust: `Use enum variants, not string constants.`
|
|
94
|
+
|
|
77
95
|
### Phase 4: Verify
|
|
78
96
|
|
|
79
97
|
1. Present a summary of all filled state files to the user
|
|
@@ -88,6 +106,7 @@ Using data from Phase 1 + Phase 2, fill the following files:
|
|
|
88
106
|
|
|
89
107
|
### Project: [name]
|
|
90
108
|
### Tech Stack: [detected stack]
|
|
109
|
+
### Language: [detected language]
|
|
91
110
|
### Modules Found: [count]
|
|
92
111
|
### Features Mapped: [count]
|
|
93
112
|
### Dependency Links: [count]
|
|
@@ -104,12 +123,35 @@ STATUS: DONE
|
|
|
104
123
|
|
|
105
124
|
## Rules
|
|
106
125
|
|
|
107
|
-
- Never modify source code — this skill only writes to state files
|
|
126
|
+
- Never modify source code — this skill only writes to state files and rules files
|
|
108
127
|
- Always show the user what was discovered BEFORE writing files
|
|
109
128
|
- If the project has 0 source files, skip Phase 1 scan and go straight to Phase 2
|
|
110
129
|
- If a state file already has content, ask before overwriting
|
|
130
|
+
- Rules file TODO sections can be overwritten without asking (they are placeholders)
|
|
111
131
|
- Run this skill only once per project (or when explicitly requested for refresh)
|
|
112
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
|
+
|
|
113
155
|
## Anti-patterns
|
|
114
156
|
|
|
115
157
|
| Anti-pattern | Correct Approach |
|
|
@@ -118,3 +160,6 @@ STATUS: DONE
|
|
|
118
160
|
| Skip user interview | Phase 1 scan alone is insufficient — always confirm with user |
|
|
119
161
|
| Overwrite existing state files silently | Ask before overwriting non-empty files |
|
|
120
162
|
| Create perfect dependency map on first try | Start with what's detectable, refine over time |
|
|
163
|
+
| Leave rules file TODOs unfilled | Phase 3.5 fills ALL TODO sections — no manual editing needed |
|
|
164
|
+
| Use TypeScript globs for non-TS projects | Detect language in Phase 1 and set correct globs |
|
|
165
|
+
| Only fill state files, skip rules | Bootstrap fills BOTH — state files AND rules files |
|
|
@@ -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
|
package/harness/skills/learn.md
CHANGED
|
@@ -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
package/src/init.js
CHANGED
|
@@ -59,6 +59,25 @@ const AGENT_MEMORY_FILES = [
|
|
|
59
59
|
|
|
60
60
|
const STATE_DEST_DIR = 'docs';
|
|
61
61
|
|
|
62
|
+
// ─── Language detection ──────────────────────────────────────
|
|
63
|
+
function detectLanguage(targetDir) {
|
|
64
|
+
const markers = [
|
|
65
|
+
['python', ['requirements.txt', 'pyproject.toml', 'setup.py', 'Pipfile', 'setup.cfg']],
|
|
66
|
+
['go', ['go.mod']],
|
|
67
|
+
['java', ['pom.xml', 'build.gradle', 'build.gradle.kts']],
|
|
68
|
+
['rust', ['Cargo.toml']],
|
|
69
|
+
['ruby', ['Gemfile']],
|
|
70
|
+
];
|
|
71
|
+
for (const [lang, files] of markers) {
|
|
72
|
+
for (const f of files) {
|
|
73
|
+
if (fs.existsSync(path.join(targetDir, f))) return lang;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return 'typescript';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
62
81
|
// ─── Shared writers ──────────────────────────────────────────
|
|
63
82
|
|
|
64
83
|
function writeStateFiles(targetDir, overwrite) {
|
|
@@ -94,23 +113,10 @@ function writeAgentsAsSkills(targetDir, skillsDir, overwrite) {
|
|
|
94
113
|
|
|
95
114
|
function generateVscode(targetDir, overwrite) {
|
|
96
115
|
const coreRules = readTemplate('core-rules.md');
|
|
97
|
-
const testingRules = readTemplate('testing-rules.md');
|
|
98
|
-
const backendRules = readTemplate('backend-rules.md');
|
|
99
116
|
|
|
100
|
-
// Global instructions
|
|
117
|
+
// Global instructions (dispatcher only — rules are embedded in skills)
|
|
101
118
|
writeFile(targetDir, '.github/copilot-instructions.md', coreRules, overwrite);
|
|
102
119
|
|
|
103
|
-
// File-scoped instructions (add VS Code applyTo frontmatter)
|
|
104
|
-
const testingWithFrontmatter =
|
|
105
|
-
'---\napplyTo: "**/*.test.ts,**/*.test.js,**/*.spec.ts,**/*.spec.js,**/__mocks__/**,**/__tests__/**"\n---\n\n' +
|
|
106
|
-
testingRules;
|
|
107
|
-
writeFile(targetDir, '.vscode/instructions/testing.instructions.md', testingWithFrontmatter, overwrite);
|
|
108
|
-
|
|
109
|
-
const backendWithFrontmatter =
|
|
110
|
-
'---\napplyTo: "src/**/*.ts,src/**/*.js"\n---\n\n' +
|
|
111
|
-
backendRules;
|
|
112
|
-
writeFile(targetDir, '.vscode/instructions/backend.instructions.md', backendWithFrontmatter, overwrite);
|
|
113
|
-
|
|
114
120
|
// Skills (.github/skills — VS Code default search path, SKILL.md with frontmatter)
|
|
115
121
|
writeSkills(targetDir, '.github/skills', overwrite);
|
|
116
122
|
|
|
@@ -128,43 +134,27 @@ function generateVscode(targetDir, overwrite) {
|
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
function generateClaude(targetDir, overwrite) {
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
readTemplate('core-rules.md'),
|
|
134
|
-
'\n---\n\n',
|
|
135
|
-
readTemplate('testing-rules.md'),
|
|
136
|
-
'\n---\n\n',
|
|
137
|
-
readTemplate('backend-rules.md'),
|
|
138
|
-
].join('');
|
|
139
|
-
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);
|
|
140
139
|
|
|
141
|
-
// Skills (SKILL.md with frontmatter
|
|
140
|
+
// Skills (SKILL.md with frontmatter)
|
|
142
141
|
writeSkills(targetDir, '.claude/skills', overwrite);
|
|
143
142
|
|
|
143
|
+
// Agents as skills (Claude Code skills pattern)
|
|
144
|
+
writeAgentsAsSkills(targetDir, '.claude/skills', overwrite);
|
|
145
|
+
|
|
144
146
|
// State files
|
|
145
147
|
writeStateFiles(targetDir, overwrite);
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
function generateCursor(targetDir, overwrite) {
|
|
149
|
-
// .cursor/rules
|
|
151
|
+
// .cursor/rules/core.mdc — dispatcher only
|
|
150
152
|
const coreRules = readTemplate('core-rules.md');
|
|
151
153
|
const coreMdc =
|
|
152
|
-
'---\ndescription:
|
|
154
|
+
'---\ndescription: K-Harness dispatcher — workflow guidance and state file references\nalwaysApply: true\n---\n\n' +
|
|
153
155
|
coreRules;
|
|
154
156
|
writeFile(targetDir, '.cursor/rules/core.mdc', coreMdc, overwrite);
|
|
155
157
|
|
|
156
|
-
const testingRules = readTemplate('testing-rules.md');
|
|
157
|
-
const testingMdc =
|
|
158
|
-
'---\ndescription: Testing rules — mock sync, forbidden patterns\nglobs: "**/*.test.*,**/*.spec.*,**/__mocks__/**,**/__tests__/**"\nalwaysApply: false\n---\n\n' +
|
|
159
|
-
testingRules;
|
|
160
|
-
writeFile(targetDir, '.cursor/rules/testing.mdc', testingMdc, overwrite);
|
|
161
|
-
|
|
162
|
-
const backendRules = readTemplate('backend-rules.md');
|
|
163
|
-
const backendMdc =
|
|
164
|
-
'---\ndescription: Backend code rules — architecture enforcement, type safety\nglobs: "src/**/*.ts,src/**/*.js"\nalwaysApply: false\n---\n\n' +
|
|
165
|
-
backendRules;
|
|
166
|
-
writeFile(targetDir, '.cursor/rules/backend.mdc', backendMdc, overwrite);
|
|
167
|
-
|
|
168
158
|
// Skills as rules
|
|
169
159
|
for (const skill of SKILLS) {
|
|
170
160
|
const content = readTemplate(`skills/${skill.id}.md`);
|
|
@@ -188,15 +178,8 @@ function generateCursor(targetDir, overwrite) {
|
|
|
188
178
|
}
|
|
189
179
|
|
|
190
180
|
function generateCodex(targetDir, overwrite) {
|
|
191
|
-
// AGENTS.md —
|
|
192
|
-
|
|
193
|
-
readTemplate('core-rules.md'),
|
|
194
|
-
'\n---\n\n',
|
|
195
|
-
readTemplate('testing-rules.md'),
|
|
196
|
-
'\n---\n\n',
|
|
197
|
-
readTemplate('backend-rules.md'),
|
|
198
|
-
].join('');
|
|
199
|
-
writeFile(targetDir, 'AGENTS.md', merged, overwrite);
|
|
181
|
+
// AGENTS.md — dispatcher only
|
|
182
|
+
writeFile(targetDir, 'AGENTS.md', readTemplate('core-rules.md'), overwrite);
|
|
200
183
|
|
|
201
184
|
// Skills (SKILL.md with frontmatter for slash commands)
|
|
202
185
|
writeSkills(targetDir, '.agents/skills', overwrite);
|
|
@@ -206,46 +189,21 @@ function generateCodex(targetDir, overwrite) {
|
|
|
206
189
|
}
|
|
207
190
|
|
|
208
191
|
function generateWindsurf(targetDir, overwrite) {
|
|
209
|
-
// .windsurfrules —
|
|
210
|
-
|
|
211
|
-
readTemplate('core-rules.md'),
|
|
212
|
-
readTemplate('testing-rules.md'),
|
|
213
|
-
readTemplate('backend-rules.md'),
|
|
214
|
-
'---\n\n# Skills\n\n',
|
|
215
|
-
];
|
|
216
|
-
for (const skill of SKILLS) {
|
|
217
|
-
sections.push(readTemplate(`skills/${skill.id}.md`));
|
|
218
|
-
}
|
|
219
|
-
sections.push('---\n\n# Agents\n\n');
|
|
220
|
-
for (const agent of AGENTS) {
|
|
221
|
-
sections.push(readTemplate(agent.file));
|
|
222
|
-
}
|
|
223
|
-
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);
|
|
224
194
|
|
|
225
195
|
// State files
|
|
226
196
|
writeStateFiles(targetDir, overwrite);
|
|
227
197
|
}
|
|
228
198
|
|
|
229
199
|
function generateAugment(targetDir, overwrite) {
|
|
230
|
-
// .augment/rules/ —
|
|
200
|
+
// .augment/rules/core.md — dispatcher only
|
|
231
201
|
const coreRules = readTemplate('core-rules.md');
|
|
232
202
|
const coreRule =
|
|
233
|
-
'---\ndescription:
|
|
203
|
+
'---\ndescription: K-Harness dispatcher — workflow guidance and state file references\ntype: always\n---\n\n' +
|
|
234
204
|
coreRules;
|
|
235
205
|
writeFile(targetDir, '.augment/rules/core.md', coreRule, overwrite);
|
|
236
206
|
|
|
237
|
-
const testingRules = readTemplate('testing-rules.md');
|
|
238
|
-
const testingRule =
|
|
239
|
-
'---\ndescription: Testing rules — mock sync, forbidden patterns\ntype: auto\nglobs: "**/*.test.*,**/*.spec.*,**/__mocks__/**,**/__tests__/**"\n---\n\n' +
|
|
240
|
-
testingRules;
|
|
241
|
-
writeFile(targetDir, '.augment/rules/testing.md', testingRule, overwrite);
|
|
242
|
-
|
|
243
|
-
const backendRules = readTemplate('backend-rules.md');
|
|
244
|
-
const backendRule =
|
|
245
|
-
'---\ndescription: Backend code rules — architecture enforcement, type safety\ntype: auto\nglobs: "src/**/*.ts,src/**/*.js"\n---\n\n' +
|
|
246
|
-
backendRules;
|
|
247
|
-
writeFile(targetDir, '.augment/rules/backend.md', backendRule, overwrite);
|
|
248
|
-
|
|
249
207
|
// .augment/skills/ — SKILL.md format (enables / slash commands)
|
|
250
208
|
writeSkills(targetDir, '.augment/skills', overwrite);
|
|
251
209
|
writeAgentsAsSkills(targetDir, '.augment/skills', overwrite);
|
|
@@ -255,25 +213,13 @@ function generateAugment(targetDir, overwrite) {
|
|
|
255
213
|
}
|
|
256
214
|
|
|
257
215
|
function generateAntigravity(targetDir, overwrite) {
|
|
258
|
-
// .agent/rules/ —
|
|
216
|
+
// .agent/rules/core.md — dispatcher only
|
|
259
217
|
const coreRules = readTemplate('core-rules.md');
|
|
260
218
|
const coreRule =
|
|
261
|
-
'---\ndescription:
|
|
219
|
+
'---\ndescription: K-Harness dispatcher — workflow guidance and state file references\ntype: always\n---\n\n' +
|
|
262
220
|
coreRules;
|
|
263
221
|
writeFile(targetDir, '.agent/rules/core.md', coreRule, overwrite);
|
|
264
222
|
|
|
265
|
-
const testingRules = readTemplate('testing-rules.md');
|
|
266
|
-
const testingRule =
|
|
267
|
-
'---\ndescription: Testing rules — mock sync, forbidden patterns\ntype: auto\nglobs: "**/*.test.*,**/*.spec.*,**/__mocks__/**,**/__tests__/**"\n---\n\n' +
|
|
268
|
-
testingRules;
|
|
269
|
-
writeFile(targetDir, '.agent/rules/testing.md', testingRule, overwrite);
|
|
270
|
-
|
|
271
|
-
const backendRules = readTemplate('backend-rules.md');
|
|
272
|
-
const backendRule =
|
|
273
|
-
'---\ndescription: Backend code rules — architecture enforcement, type safety\ntype: auto\nglobs: "src/**/*.ts,src/**/*.js"\n---\n\n' +
|
|
274
|
-
backendRules;
|
|
275
|
-
writeFile(targetDir, '.agent/rules/backend.md', backendRule, overwrite);
|
|
276
|
-
|
|
277
223
|
// .agent/skills/ — SKILL.md format (enables / slash commands)
|
|
278
224
|
writeSkills(targetDir, '.agent/skills', overwrite);
|
|
279
225
|
writeAgentsAsSkills(targetDir, '.agent/skills', overwrite);
|
|
@@ -378,10 +324,11 @@ async function run(argv) {
|
|
|
378
324
|
}
|
|
379
325
|
|
|
380
326
|
const gen = GENERATORS[ide];
|
|
381
|
-
|
|
327
|
+
const lang = detectLanguage(args.dir);
|
|
328
|
+
console.log(`\n Installing for ${gen.name}... (detected language: ${lang})\n`);
|
|
382
329
|
gen.fn(args.dir, args.overwrite);
|
|
383
|
-
console.log(`\n Done!
|
|
330
|
+
console.log(`\n Done! Run "bootstrap" in your AI chat to auto-fill state files and rules.\n`);
|
|
384
331
|
}
|
|
385
332
|
}
|
|
386
333
|
|
|
387
|
-
module.exports = { run };
|
|
334
|
+
module.exports = { run, detectLanguage };
|
package/harness/backend-rules.md
DELETED
|
@@ -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
|
package/harness/testing-rules.md
DELETED
|
@@ -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
|