k-harness 0.1.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.
@@ -0,0 +1,55 @@
1
+ # Project State
2
+
3
+ > **Keep this file under 200 lines.** Move completed items to an archive if needed.
4
+
5
+ ## Quick Summary
6
+
7
+ <!-- 3-line summary for new sessions. Update this EVERY time before ending a chat session. -->
8
+ <!-- Line 1: What was accomplished in the last session -->
9
+ <!-- Line 2: What is currently in progress -->
10
+ <!-- Line 3: What should be done next -->
11
+
12
+ ## Current Sprint
13
+
14
+ - Sprint: 1 — Initial Setup
15
+ - Started: <!-- TODO: date -->
16
+ - Branch: main
17
+
18
+ ## Story Status
19
+
20
+ | ID | Title | Status | Assignee |
21
+ |----|-------|--------|----------|
22
+ | S1-1 | Project scaffolding | ⬜ todo | |
23
+ | S1-2 | Core feature implementation | ⬜ todo | |
24
+ | S1-3 | Test coverage | ⬜ todo | |
25
+
26
+ ## Module Registry
27
+
28
+ <!-- Summary of current modules. Full details in dependency-map.md -->
29
+ | Module | Layer | Status |
30
+ |--------|-------|--------|
31
+ <!-- Fill as modules are created -->
32
+
33
+ ## Technical Decisions
34
+
35
+ <!-- Record key architectural decisions here -->
36
+
37
+ ## Recent Changes
38
+
39
+ <!-- Log recent completions here -->
40
+
41
+ ---
42
+
43
+ ## Session Handoff Protocol
44
+
45
+ Before ending a chat session, you MUST:
46
+ 1. Update the **Quick Summary** section above (3 lines)
47
+ 2. Update **Story Status** table with current progress
48
+ 3. Add any new failure patterns to `failure-patterns.md`
49
+ 4. Update `features.md` if any features were added/changed
50
+
51
+ When starting a new chat session, read these files first:
52
+ 1. `project-state.md` (this file) — where we are
53
+ 2. `features.md` — what exists
54
+ 3. `failure-patterns.md` — what to watch out for
55
+ 4. `project-brief.md` — why we're building this
@@ -0,0 +1,80 @@
1
+ # Feature Breakdown
2
+
3
+ ## Purpose
4
+
5
+ Decompose a feature into implementation tasks ordered by dependency.
6
+ Ensures bottom-up implementation: foundations first, then layers that depend on them.
7
+
8
+ ## When to Apply
9
+
10
+ - Starting a new feature or Story
11
+ - A feature touches 3+ modules
12
+ - Unsure which module to build first
13
+ - After the Planner agent creates a high-level plan
14
+
15
+ ## Procedure
16
+
17
+ 1. **Describe the feature** in one sentence
18
+ 2. **Read dependency-map.md** to understand current module relationships
19
+ 3. **Identify affected modules**: List every module that needs changes
20
+ 4. **Classify changes per module**:
21
+ - NEW_MODULE: Entirely new module to create
22
+ - INTERFACE_CHANGE: Existing module's public interface changes
23
+ - INTERNAL_CHANGE: Only internal implementation changes
24
+ - TEST_ONLY: Only test updates needed
25
+ 5. **Build dependency order**:
26
+ - Draw a mini dependency graph for just the affected modules
27
+ - Sort topologically: modules with no dependencies come first
28
+ - Group into implementation waves (parallel-safe batches)
29
+ 6. **Create task sequence**: Convert waves into numbered tasks
30
+ 7. **Annotate each task** with:
31
+ - Module name
32
+ - Change type (from step 4)
33
+ - Files to create/modify
34
+ - Tests to write
35
+ - Dependency (which prior task must finish first)
36
+
37
+ ## Output Format
38
+
39
+ ```markdown
40
+ ## Feature: [one-sentence description]
41
+
42
+ ### Wave 1 (no dependencies)
43
+ - [ ] Task 1: [Module A] — Create entity + repository interface
44
+ - Files: src/domain/entities/X.ts, src/domain/repositories/XRepository.ts
45
+ - Tests: tests/domain/X.test.ts
46
+ - Depends on: none
47
+
48
+ ### Wave 2 (depends on Wave 1)
49
+ - [ ] Task 2: [Module B] — Implement use case
50
+ - Files: src/application/usecases/DoX.ts
51
+ - Tests: tests/application/DoX.test.ts
52
+ - Depends on: Task 1
53
+
54
+ ### Wave 3 (depends on Wave 2)
55
+ - [ ] Task 3: [Module C] — Add API endpoint
56
+ - Files: src/presentation/routes/x.ts, src/presentation/dto/XDto.ts
57
+ - Tests: tests/presentation/x.test.ts
58
+ - Depends on: Task 2
59
+
60
+ ### Dependency Map Updates
61
+ - [ ] Register Module A in dependency-map.md
62
+ - [ ] Update Module B's "Depends On" column
63
+ ```
64
+
65
+ ## Rules
66
+
67
+ - Never implement a module before its dependencies exist
68
+ - Each task should be completable in one session
69
+ - Every task must include its test files
70
+ - New modules MUST be registered in dependency-map.md (Iron Law #6)
71
+ - If a task exceeds Story scope, stop and report to user
72
+
73
+ ## Anti-patterns
74
+
75
+ | Anti-pattern | Correct Approach |
76
+ |---|---|
77
+ | Start from UI, work backward | Start from domain, work forward |
78
+ | One giant task for the whole feature | Break into single-module tasks |
79
+ | Skip dependency-map registration | Register immediately when creating module |
80
+ | Tests "later" | Tests in the same task |
@@ -0,0 +1,63 @@
1
+ # Impact Analysis
2
+
3
+ ## Purpose
4
+
5
+ Before modifying any module, trace all affected modules to prevent cascade failures.
6
+ The most common cause of regressions in growing projects is changing one module without updating its dependents.
7
+
8
+ ## When to Apply
9
+
10
+ - Adding, removing, or changing a module's public interface
11
+ - Modifying shared types, entities, or DTOs
12
+ - Refactoring that touches more than 2 files
13
+ - When a test fails in a module you didn't directly change
14
+
15
+ ## Procedure
16
+
17
+ 1. **Identify the target module**: Which module are you about to change?
18
+ 2. **Read dependency-map.md**: Find the target module's row
19
+ 3. **List dependents**: Read the "Depended By" column — these are the blast radius
20
+ 4. **Check interface impact**: Does your change affect the module's public interface?
21
+ - If NO (internal-only change) → proceed, but still run dependent tests
22
+ - If YES → continue to step 5
23
+ 5. **Trace each dependent**:
24
+ - List files in each dependent module that import from the target
25
+ - Identify which functions/types they use
26
+ - Determine if the interface change breaks them
27
+ 6. **Plan updates**: Create a task list of all files that need modification
28
+ 7. **Verify scope**: Confirm all files are within the current Story scope (project-state.md)
29
+
30
+ ## Checklist
31
+
32
+ - [ ] Target module identified in dependency-map.md
33
+ - [ ] All dependent modules listed
34
+ - [ ] Interface vs internal change classified
35
+ - [ ] Files importing from target module enumerated
36
+ - [ ] Mock/test updates planned for each dependent (FP-001)
37
+ - [ ] All changes within current Story scope
38
+ - [ ] Escalated to user if scope exceeds current Story
39
+
40
+ ## Example
41
+
42
+ ### Good
43
+ ```
44
+ Target: auth module
45
+ Change: Added `resetPassword(email: string): Promise<void>`
46
+ Dependents: api, admin
47
+ Impact:
48
+ - api/routes/auth.ts imports AuthService → needs new route
49
+ - admin/controllers/user.ts imports AuthService → needs admin endpoint
50
+ - tests/__mocks__/AuthService.ts → needs new mock method
51
+ Plan: 4 files to update, all within S3-2 scope
52
+ ```
53
+
54
+ ### Bad
55
+ ```
56
+ "I'll just add this method and see what breaks."
57
+ → Tests fail in 3 modules, mock out of sync, 2 hours wasted
58
+ ```
59
+
60
+ ## Related Failure Patterns
61
+
62
+ - FP-001: Interface changed, mock not updated → Checklist item 5
63
+ - FP-002: Type confusion across modules → Step 5 verification
@@ -0,0 +1,73 @@
1
+ # Investigate
2
+
3
+ ## Purpose
4
+
5
+ Debug bugs systematically. Prevent "symptom patching" — fixing without understanding root cause.
6
+ 4-phase debugging process inspired by gstack's /investigate.
7
+
8
+ ## When to Apply
9
+
10
+ - Test failures with unclear cause
11
+ - Runtime errors
12
+ - Regression bugs ("it worked yesterday")
13
+ - Unexplained behavior
14
+
15
+ ## Procedure
16
+
17
+ ### Phase 1: Evidence Collection (NO FIXES)
18
+
19
+ 1. Record the full error message and stack trace
20
+ 2. Trace the code path backwards from the error
21
+ 3. Check recent changes: `git log --oneline -20 -- <related files>`
22
+ 4. Verify the bug is reproducible
23
+
24
+ **Do NOT modify code in this phase.**
25
+
26
+ ### Phase 2: Scope Lock
27
+
28
+ 1. Identify the module/directory containing the root cause
29
+ 2. Exclude files outside that scope from modification
30
+ 3. Check failure-patterns.md for matching patterns
31
+
32
+ ### Phase 3: Hypothesis + Fix
33
+
34
+ 1. State the root cause hypothesis in one sentence
35
+ 2. Implement the minimal fix based on the hypothesis
36
+ 3. Verify the fix does not break existing tests
37
+
38
+ ### Phase 4: Verify + Record
39
+
40
+ 1. Run all related tests after the fix
41
+ 2. Add a regression test (prevent the same bug from recurring)
42
+ 3. Decide if the pattern should be recorded in failure-patterns.md
43
+
44
+ ## Checklist
45
+
46
+ - [ ] Root cause hypothesis is stated explicitly
47
+ - [ ] Did NOT skip Phase 1 (evidence collection) and jump straight to fixing
48
+ - [ ] Fix scope is limited to the problem's scope
49
+ - [ ] All related tests pass after the fix
50
+ - [ ] Regression test is added
51
+ - [ ] Escalated to user after 3 failed attempts
52
+
53
+ ## Example
54
+
55
+ ### Good
56
+ ```
57
+ Phase 1: TypeError: Cannot read property 'id' of undefined at UserService.ts:45
58
+ Phase 2: Scope → src/application/services/UserService.ts, src/domain/entities/User.ts
59
+ Phase 3: Hypothesis — findById returns null but no null check exists
60
+ Fix — add null guard at UserService.ts:44
61
+ Phase 4: Tests pass, null case test added
62
+ ```
63
+
64
+ ### Bad
65
+ ```
66
+ "Error occurred so I added an if statement."
67
+ → Root cause unknown, no reproduction conditions recorded, same error possible elsewhere
68
+ ```
69
+
70
+ ## Related Failure Patterns
71
+
72
+ - FP-002: Type confusion → Phase 1 requires verifying actual types
73
+ - FP-001: Mock not updated → Phase 4 requires checking mock sync
@@ -0,0 +1,49 @@
1
+ # Security Checklist
2
+
3
+ ## Purpose
4
+
5
+ Inspect for security risks before committing code.
6
+ Prevents credential leaks and accidental commits of sensitive files. (FP-004)
7
+
8
+ ## When to Apply
9
+
10
+ - Before running `git add` or committing
11
+ - When creating new files
12
+ - When modifying config or environment files
13
+ - When changing authentication/authorization code
14
+
15
+ ## Procedure
16
+
17
+ 1. **Check staging area**: Run `git diff --cached --name-only` to list files staged for commit
18
+ 2. **Scan for forbidden files**: Check if .env, credentials, *.pem, *.key files are staged
19
+ 3. **Scan for hardcoded secrets**: Search staged files for passwords, API keys, tokens
20
+ 4. **Verify .gitignore**: Ensure new environment files are covered by .gitignore
21
+ 5. **Check for temp files**: Verify tmp_*, debug_*, coverage_* files are not staged
22
+
23
+ ## Checklist
24
+
25
+ - [ ] (FP-004) No .env, credentials, *.key files in staging area
26
+ - [ ] (FP-004) No hardcoded passwords, API keys, or tokens in code
27
+ - [ ] Sensitive file patterns are registered in .gitignore
28
+ - [ ] No temp files (tmp_*, debug_*, coverage_*) in staging area
29
+ - [ ] Using explicit per-file staging, not `git add .`
30
+
31
+ ## Example
32
+
33
+ ### Good
34
+ ```bash
35
+ git add src/auth/login.ts tests/auth/login.test.ts
36
+ # Environment variable via config module
37
+ const dbPassword = process.env.DB_PASSWORD;
38
+ ```
39
+
40
+ ### Bad
41
+ ```bash
42
+ git add .
43
+ # Hardcoded password
44
+ const dbPassword = "super_secret_123";
45
+ ```
46
+
47
+ ## Related Failure Patterns
48
+
49
+ - FP-004: Dangerous file committed → Checklist items 1, 4
@@ -0,0 +1,46 @@
1
+ # Test Integrity
2
+
3
+ ## Purpose
4
+
5
+ Ensure test mocks stay synchronized when repository/service interfaces change.
6
+ Prevents the most common LLM coding failure: updating an interface but forgetting to update corresponding mocks. (FP-001)
7
+
8
+ ## When to Apply
9
+
10
+ - Adding, removing, or modifying methods on a repository/service interface
11
+ - Creating a new repository or service
12
+ - When a use case starts calling a new interface method
13
+
14
+ ## Procedure
15
+
16
+ 1. **Identify changed interfaces**: Find modified files in your interface directory
17
+ 2. **Map to mock files**: Locate the corresponding mock file for each changed interface
18
+ 3. **Sync methods**: Verify every interface method exists in the mock
19
+ 4. **Verify return types**: Confirm mock return values match the interface return types
20
+ 5. **Check consumers**: Verify use case tests configure the mock correctly for new methods
21
+
22
+ ## Checklist
23
+
24
+ - [ ] (FP-001) Every changed interface method is reflected in its mock
25
+ - [ ] Mock return types match interface signatures
26
+ - [ ] New methods have default mock return values set
27
+ - [ ] Use case tests correctly use the new mock methods
28
+ - [ ] Existing tests still pass
29
+
30
+ ## Example
31
+
32
+ ### Good
33
+ ```
34
+ Interface adds findByFilters() → Mock adds findByFilters with mockResolvedValue([])
35
+ Both changes in the same commit.
36
+ ```
37
+
38
+ ### Bad
39
+ ```
40
+ Interface adds findByFilters() → Mock unchanged
41
+ → Runtime error: method not found on mock object
42
+ ```
43
+
44
+ ## Related Failure Patterns
45
+
46
+ - FP-001: Interface changed, mock not updated → Checklist item 1
@@ -0,0 +1,21 @@
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 bare `jest.fn()` only. Set default return values with `mockResolvedValue` etc.
15
+ - Committing with `skip` or `only` left in test files.
16
+ - Committing with `console.log` debugging statements.
17
+
18
+ ## References
19
+
20
+ - test-integrity skill
21
+ - failure-patterns.md FP-001: Mock not updated
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "k-harness",
3
+ "version": "0.1.0",
4
+ "description": "LLM Development Harness — IDE-agnostic rules, skills, and agents that prevent common AI coding failures",
5
+ "keywords": [
6
+ "llm",
7
+ "ai",
8
+ "copilot",
9
+ "claude",
10
+ "cursor",
11
+ "codex",
12
+ "windsurf",
13
+ "harness",
14
+ "development",
15
+ "agents",
16
+ "skills"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/OG056501-Opensource-Poc/k-harness.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "",
24
+ "main": "src/init.js",
25
+ "bin": {
26
+ "k-harness": "bin/cli.js"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "src/",
31
+ "harness/",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "engines": {
36
+ "node": ">=18.0.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }