@harness-engineering/cli 1.3.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/personas/architecture-enforcer.yaml +1 -0
- package/dist/agents/personas/code-reviewer.yaml +41 -0
- package/dist/agents/personas/codebase-health-analyst.yaml +27 -0
- package/dist/agents/personas/documentation-maintainer.yaml +2 -0
- package/dist/agents/personas/entropy-cleaner.yaml +3 -0
- package/dist/agents/personas/graph-maintainer.yaml +27 -0
- package/dist/agents/personas/parallel-coordinator.yaml +29 -0
- package/dist/agents/personas/task-executor.yaml +41 -0
- package/dist/agents/skills/README.md +8 -0
- package/dist/agents/skills/claude-code/add-harness-component/SKILL.md +10 -0
- package/dist/agents/skills/claude-code/align-documentation/SKILL.md +19 -0
- package/dist/agents/skills/claude-code/cleanup-dead-code/SKILL.md +19 -0
- package/dist/agents/skills/claude-code/detect-doc-drift/SKILL.md +8 -0
- package/dist/agents/skills/claude-code/enforce-architecture/SKILL.md +9 -0
- package/dist/agents/skills/claude-code/harness-architecture-advisor/SKILL.md +9 -0
- package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +10 -0
- package/dist/agents/skills/claude-code/harness-debugging/SKILL.md +10 -0
- package/dist/agents/skills/claude-code/harness-dependency-health/SKILL.md +150 -0
- package/dist/agents/skills/claude-code/harness-dependency-health/skill.yaml +41 -0
- package/dist/agents/skills/claude-code/harness-execution/SKILL.md +19 -0
- package/dist/agents/skills/claude-code/harness-hotspot-detector/SKILL.md +135 -0
- package/dist/agents/skills/claude-code/harness-hotspot-detector/skill.yaml +44 -0
- package/dist/agents/skills/claude-code/harness-impact-analysis/SKILL.md +139 -0
- package/dist/agents/skills/claude-code/harness-impact-analysis/skill.yaml +44 -0
- package/dist/agents/skills/claude-code/harness-knowledge-mapper/SKILL.md +154 -0
- package/dist/agents/skills/claude-code/harness-knowledge-mapper/skill.yaml +49 -0
- package/dist/agents/skills/claude-code/harness-onboarding/SKILL.md +10 -0
- package/dist/agents/skills/claude-code/harness-parallel-agents/SKILL.md +9 -0
- package/dist/agents/skills/claude-code/harness-planning/SKILL.md +9 -0
- package/dist/agents/skills/claude-code/harness-pre-commit-review/SKILL.md +6 -0
- package/dist/agents/skills/claude-code/harness-refactoring/SKILL.md +19 -0
- package/dist/agents/skills/claude-code/harness-tdd/SKILL.md +10 -0
- package/dist/agents/skills/claude-code/harness-test-advisor/SKILL.md +131 -0
- package/dist/agents/skills/claude-code/harness-test-advisor/skill.yaml +44 -0
- package/dist/agents/skills/claude-code/initialize-harness-project/SKILL.md +10 -0
- package/dist/agents/skills/claude-code/validate-context-engineering/SKILL.md +9 -0
- package/dist/agents/skills/gemini-cli/harness-dependency-health/SKILL.md +150 -0
- package/dist/agents/skills/gemini-cli/harness-dependency-health/skill.yaml +41 -0
- package/dist/agents/skills/gemini-cli/harness-hotspot-detector/SKILL.md +135 -0
- package/dist/agents/skills/gemini-cli/harness-hotspot-detector/skill.yaml +44 -0
- package/dist/agents/skills/gemini-cli/harness-impact-analysis/SKILL.md +139 -0
- package/dist/agents/skills/gemini-cli/harness-impact-analysis/skill.yaml +44 -0
- package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/SKILL.md +154 -0
- package/dist/agents/skills/gemini-cli/harness-knowledge-mapper/skill.yaml +49 -0
- package/dist/agents/skills/gemini-cli/harness-test-advisor/SKILL.md +131 -0
- package/dist/agents/skills/gemini-cli/harness-test-advisor/skill.yaml +44 -0
- package/dist/agents/skills/tests/platform-parity.test.ts +131 -0
- package/dist/agents/skills/tests/schema.ts +2 -0
- package/dist/bin/harness.js +2 -2
- package/dist/{chunk-EFZOLZFB.js → chunk-ACMDUQJG.js} +4 -2
- package/dist/{chunk-APYEWOCR.js → chunk-VS4OTOKZ.js} +1393 -350
- package/dist/{create-skill-4GKJZB5R.js → create-skill-NZDLMMR6.js} +1 -1
- package/dist/index.d.ts +265 -143
- package/dist/index.js +30 -4
- package/package.json +3 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
name: Code Reviewer
|
|
3
|
+
description: Full-lifecycle code review with harness methodology
|
|
4
|
+
role: >
|
|
5
|
+
Perform AI-powered code review incorporating harness validation,
|
|
6
|
+
architectural analysis, and project-specific calibration.
|
|
7
|
+
Produces structured Strengths/Issues/Assessment output.
|
|
8
|
+
skills:
|
|
9
|
+
- harness-code-review
|
|
10
|
+
steps:
|
|
11
|
+
- command: validate
|
|
12
|
+
when: always
|
|
13
|
+
- command: check-deps
|
|
14
|
+
when: always
|
|
15
|
+
- command: check-docs
|
|
16
|
+
when: on_pr
|
|
17
|
+
- skill: harness-code-review
|
|
18
|
+
when: on_pr
|
|
19
|
+
output: auto
|
|
20
|
+
- skill: harness-code-review
|
|
21
|
+
when: manual
|
|
22
|
+
output: auto
|
|
23
|
+
triggers:
|
|
24
|
+
- event: on_pr
|
|
25
|
+
conditions:
|
|
26
|
+
paths:
|
|
27
|
+
- "src/**"
|
|
28
|
+
- "packages/**"
|
|
29
|
+
- event: on_commit
|
|
30
|
+
conditions:
|
|
31
|
+
branches:
|
|
32
|
+
- main
|
|
33
|
+
- develop
|
|
34
|
+
config:
|
|
35
|
+
severity: error
|
|
36
|
+
autoFix: false
|
|
37
|
+
timeout: 600000
|
|
38
|
+
outputs:
|
|
39
|
+
agents-md: true
|
|
40
|
+
ci-workflow: true
|
|
41
|
+
runtime-config: true
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: Codebase Health Analyst
|
|
3
|
+
description: Proactively identifies structural problems, coupling risks, and architectural drift
|
|
4
|
+
role: Run health checks, detect hotspots, analyze impact, surface risks before they become incidents
|
|
5
|
+
skills:
|
|
6
|
+
- harness-hotspot-detector
|
|
7
|
+
- harness-dependency-health
|
|
8
|
+
- harness-impact-analysis
|
|
9
|
+
- cleanup-dead-code
|
|
10
|
+
commands:
|
|
11
|
+
- graph status
|
|
12
|
+
- check-deps
|
|
13
|
+
triggers:
|
|
14
|
+
- event: scheduled
|
|
15
|
+
cron: "0 6 * * 1"
|
|
16
|
+
- event: on_pr
|
|
17
|
+
conditions:
|
|
18
|
+
min_files: 10
|
|
19
|
+
- event: manual
|
|
20
|
+
config:
|
|
21
|
+
severity: warning
|
|
22
|
+
autoFix: false
|
|
23
|
+
timeout: 600000
|
|
24
|
+
outputs:
|
|
25
|
+
agents-md: false
|
|
26
|
+
ci-workflow: true
|
|
27
|
+
runtime-config: true
|
|
@@ -5,9 +5,11 @@ role: Detect documentation drift, validate doc coverage, align docs with code ch
|
|
|
5
5
|
skills:
|
|
6
6
|
- detect-doc-drift
|
|
7
7
|
- align-documentation
|
|
8
|
+
- harness-knowledge-mapper
|
|
8
9
|
commands:
|
|
9
10
|
- check-docs
|
|
10
11
|
- validate
|
|
12
|
+
- scan
|
|
11
13
|
triggers:
|
|
12
14
|
- event: on_pr
|
|
13
15
|
conditions:
|
|
@@ -5,9 +5,12 @@ role: Run scheduled cleanup, detect documentation drift, fix pattern violations
|
|
|
5
5
|
skills:
|
|
6
6
|
- cleanup-dead-code
|
|
7
7
|
- detect-doc-drift
|
|
8
|
+
- harness-hotspot-detector
|
|
9
|
+
- harness-impact-analysis
|
|
8
10
|
commands:
|
|
9
11
|
- cleanup
|
|
10
12
|
- fix-drift
|
|
13
|
+
- scan
|
|
11
14
|
triggers:
|
|
12
15
|
- event: scheduled
|
|
13
16
|
cron: "0 6 * * 1"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: Graph Maintainer
|
|
3
|
+
description: Keeps the knowledge graph fresh, monitors connector health, and ensures data quality
|
|
4
|
+
role: Re-scan codebase, sync external connectors, detect graph anomalies, maintain graph freshness
|
|
5
|
+
skills:
|
|
6
|
+
- harness-dependency-health
|
|
7
|
+
- harness-knowledge-mapper
|
|
8
|
+
- validate-context-engineering
|
|
9
|
+
commands:
|
|
10
|
+
- scan
|
|
11
|
+
- ingest
|
|
12
|
+
- graph status
|
|
13
|
+
triggers:
|
|
14
|
+
- event: scheduled
|
|
15
|
+
cron: "0 4 * * *"
|
|
16
|
+
- event: on_commit
|
|
17
|
+
conditions:
|
|
18
|
+
branches: ["main"]
|
|
19
|
+
- event: manual
|
|
20
|
+
config:
|
|
21
|
+
severity: warning
|
|
22
|
+
autoFix: false
|
|
23
|
+
timeout: 600000
|
|
24
|
+
outputs:
|
|
25
|
+
agents-md: false
|
|
26
|
+
ci-workflow: true
|
|
27
|
+
runtime-config: true
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
name: Parallel Coordinator
|
|
3
|
+
description: Dispatches independent work across isolated Task Executor instances
|
|
4
|
+
role: >
|
|
5
|
+
Verify task independence, create focused agent briefs, dispatch
|
|
6
|
+
Task Executor instances in isolated worktrees, integrate results,
|
|
7
|
+
and run full validation after all agents complete.
|
|
8
|
+
skills:
|
|
9
|
+
- harness-parallel-agents
|
|
10
|
+
steps:
|
|
11
|
+
- command: validate
|
|
12
|
+
when: always
|
|
13
|
+
- skill: harness-parallel-agents
|
|
14
|
+
when: manual
|
|
15
|
+
output: inline
|
|
16
|
+
triggers:
|
|
17
|
+
- event: on_pr
|
|
18
|
+
conditions:
|
|
19
|
+
paths:
|
|
20
|
+
- "src/**"
|
|
21
|
+
- "packages/**"
|
|
22
|
+
config:
|
|
23
|
+
severity: error
|
|
24
|
+
autoFix: false
|
|
25
|
+
timeout: 1800000
|
|
26
|
+
outputs:
|
|
27
|
+
agents-md: true
|
|
28
|
+
ci-workflow: true
|
|
29
|
+
runtime-config: true
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
name: Task Executor
|
|
3
|
+
description: Executes approved plans with state tracking, TDD, and verification
|
|
4
|
+
role: >
|
|
5
|
+
Execute implementation plans task-by-task using harness methodology.
|
|
6
|
+
Maintains persistent state, follows TDD rhythm, runs verification
|
|
7
|
+
after each task, and respects checkpoint protocol.
|
|
8
|
+
skills:
|
|
9
|
+
- harness-execution
|
|
10
|
+
steps:
|
|
11
|
+
- command: validate
|
|
12
|
+
when: always
|
|
13
|
+
- command: check-deps
|
|
14
|
+
when: always
|
|
15
|
+
- command: scan
|
|
16
|
+
when: manual
|
|
17
|
+
- skill: harness-execution
|
|
18
|
+
when: on_plan_approved
|
|
19
|
+
output: auto
|
|
20
|
+
- skill: harness-execution
|
|
21
|
+
when: manual
|
|
22
|
+
output: auto
|
|
23
|
+
triggers:
|
|
24
|
+
- event: on_pr
|
|
25
|
+
conditions:
|
|
26
|
+
paths:
|
|
27
|
+
- "src/**"
|
|
28
|
+
- "packages/**"
|
|
29
|
+
- event: on_commit
|
|
30
|
+
conditions:
|
|
31
|
+
branches:
|
|
32
|
+
- main
|
|
33
|
+
- develop
|
|
34
|
+
config:
|
|
35
|
+
severity: error
|
|
36
|
+
autoFix: false
|
|
37
|
+
timeout: 900000
|
|
38
|
+
outputs:
|
|
39
|
+
agents-md: true
|
|
40
|
+
ci-workflow: true
|
|
41
|
+
runtime-config: true
|
|
@@ -37,6 +37,14 @@ agents/skills/
|
|
|
37
37
|
- `initialize-harness-project` - Scaffold new project
|
|
38
38
|
- `add-harness-component` - Add components
|
|
39
39
|
|
|
40
|
+
### Graph Integration Levels
|
|
41
|
+
|
|
42
|
+
**Graph-Transformed** (7 skills): harness-code-review, validate-context-engineering, detect-doc-drift, cleanup-dead-code, harness-parallel-agents, enforce-architecture, harness-onboarding
|
|
43
|
+
|
|
44
|
+
**Graph-Enhanced** (5 skills): harness-execution, harness-planning, harness-architecture-advisor, harness-refactoring, align-documentation
|
|
45
|
+
|
|
46
|
+
**Graph-Enabled** (5 new skills): harness-impact-analysis, harness-dependency-health, harness-hotspot-detector, harness-test-advisor, harness-knowledge-mapper
|
|
47
|
+
|
|
40
48
|
## Usage
|
|
41
49
|
|
|
42
50
|
### Claude Code
|
|
@@ -73,6 +73,16 @@
|
|
|
73
73
|
|
|
74
74
|
2. **Run `harness check-deps`** to verify no dependency violations were introduced. The new component's imports must respect layer boundaries.
|
|
75
75
|
|
|
76
|
+
### Graph Refresh
|
|
77
|
+
|
|
78
|
+
If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
harness scan [path]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
|
|
85
|
+
|
|
76
86
|
3. **If validation fails,** fix the issues before committing. Common causes:
|
|
77
87
|
- New layer not properly registered in `harness.yaml`
|
|
78
88
|
- Component placed in wrong directory for its declared layer
|
|
@@ -31,6 +31,15 @@
|
|
|
31
31
|
|
|
32
32
|
3. **Run `harness check-docs`** to identify any documentation that already has broken references due to the changes.
|
|
33
33
|
|
|
34
|
+
### Graph-Enhanced Context (when available)
|
|
35
|
+
|
|
36
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
|
|
37
|
+
|
|
38
|
+
- `query_graph` — find `documents` edges pointing to nodes changed in this diff
|
|
39
|
+
- `get_impact` — auto-suggest which docs need updating after code changes
|
|
40
|
+
|
|
41
|
+
Replaces manual doc-to-code correlation. Fall back to file-based commands if no graph is available.
|
|
42
|
+
|
|
34
43
|
### Phase 2: Map — Connect Code Changes to Documentation
|
|
35
44
|
|
|
36
45
|
For each changed file, identify all documentation that references it:
|
|
@@ -84,6 +93,16 @@ For each affected documentation location:
|
|
|
84
93
|
|
|
85
94
|
4. **Run `harness fix-drift`** to catch any remaining simple drift issues that manual review missed.
|
|
86
95
|
|
|
96
|
+
### Graph Refresh
|
|
97
|
+
|
|
98
|
+
If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
harness scan [path]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
|
|
105
|
+
|
|
87
106
|
5. **Commit the documentation update.** Use a commit message that references the original change: "docs: update AGENTS.md for notification service refactoring" or "docs: sync API docs after auth module rename."
|
|
88
107
|
|
|
89
108
|
## What to Update
|
|
@@ -28,6 +28,15 @@
|
|
|
28
28
|
|
|
29
29
|
3. **Review the report summary.** Note the total count and distribution. A few dead exports are normal; dozens suggest accumulated entropy from incomplete refactorings.
|
|
30
30
|
|
|
31
|
+
### Graph-Enhanced Context (when available)
|
|
32
|
+
|
|
33
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate dead code detection:
|
|
34
|
+
|
|
35
|
+
- `query_graph` — perform graph reachability analysis from entry point nodes to identify truly unreachable code
|
|
36
|
+
- `get_relationships` — distinguish dynamic imports from genuinely unused code by checking edge types
|
|
37
|
+
|
|
38
|
+
Graph reachability reduces false positives compared to static analysis alone, since it traces the full transitive import graph including re-exports. Fall back to file-based commands if no graph is available.
|
|
39
|
+
|
|
31
40
|
### Phase 2: Categorize — Safe vs. Needs Review
|
|
32
41
|
|
|
33
42
|
**Safe to auto-fix (remove without further analysis):**
|
|
@@ -63,6 +72,16 @@ For each item categorized as safe:
|
|
|
63
72
|
|
|
64
73
|
### Phase 4: Report Remaining Items
|
|
65
74
|
|
|
75
|
+
### Graph Refresh
|
|
76
|
+
|
|
77
|
+
If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
harness scan [path]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Dead code removal changes graph topology — skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
|
|
84
|
+
|
|
66
85
|
For items that need human review, report:
|
|
67
86
|
|
|
68
87
|
1. **What it is** — file path, export name, what it does
|
|
@@ -22,6 +22,14 @@
|
|
|
22
22
|
|
|
23
23
|
3. **Optionally, run `git diff` against a baseline** (last release, last sprint, etc.) to identify which code files changed. This helps prioritize — docs for recently changed files are most likely to be drifted.
|
|
24
24
|
|
|
25
|
+
### Graph-Enhanced Context (when available)
|
|
26
|
+
|
|
27
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate drift detection:
|
|
28
|
+
|
|
29
|
+
- `query_graph` — find `documents` edges where the target code node has changed since the doc node was last updated
|
|
30
|
+
|
|
31
|
+
When a graph is available, drift is simply stale edges: doc-to-code edges where the code side has been modified more recently than the doc side. This replaces regex pattern matching and catches semantic drift that text search misses. Fall back to file-based commands if no graph is available.
|
|
32
|
+
|
|
25
33
|
### Phase 2: Identify — Classify Drift Types
|
|
26
34
|
|
|
27
35
|
Categorize each finding into one of these drift types:
|
|
@@ -28,6 +28,15 @@
|
|
|
28
28
|
- Same-layer imports may or may not be allowed depending on project config
|
|
29
29
|
- Cross-cutting concerns (logging, config) have their own rules
|
|
30
30
|
|
|
31
|
+
### Graph-Enhanced Context (when available)
|
|
32
|
+
|
|
33
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate violation detection:
|
|
34
|
+
|
|
35
|
+
- `query_graph` — traverse `imports` edges against layer constraint nodes to find all violations in a single query
|
|
36
|
+
- `get_relationships` — find all code dependent on a violation target to show the full scope of impact
|
|
37
|
+
|
|
38
|
+
Graph queries show the complete violation scope (not just the first occurrence per file) and reveal transitive violations that single-file analysis misses. Fall back to file-based commands if no graph is available.
|
|
39
|
+
|
|
31
40
|
### Phase 2: Run Dependency Checks
|
|
32
41
|
|
|
33
42
|
1. **Run `harness check-deps`** to analyze all import statements against the constraint model. Capture the full JSON output.
|
|
@@ -104,6 +104,15 @@ Look for existing issues that may affect the decision:
|
|
|
104
104
|
Store analysis in: .harness/architecture/<topic>/analysis.md
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
### Graph-Enhanced Context (when available)
|
|
108
|
+
|
|
109
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
|
|
110
|
+
|
|
111
|
+
- `query_graph` — discover how similar features are structured in the codebase
|
|
112
|
+
- `search_similar` — find analogous patterns and implementations
|
|
113
|
+
|
|
114
|
+
Replaces manual Glob/Grep exploration with graph pattern discovery. Fall back to file-based commands if no graph is available.
|
|
115
|
+
|
|
107
116
|
---
|
|
108
117
|
|
|
109
118
|
### Phase 3: PROPOSE — Present Options with Trade-Offs
|
|
@@ -54,6 +54,16 @@ grep -rl "<component-name>" docs/specs/ docs/design-docs/ docs/plans/
|
|
|
54
54
|
grep -rn "interface\|type\|schema" <changed-file> | head -20
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
### Graph-Enhanced Context (when available)
|
|
58
|
+
|
|
59
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context gathering:
|
|
60
|
+
|
|
61
|
+
- `query_graph` — traverse dependency chain from changed files to find all imports and transitive dependencies (replaces grep for import tracing)
|
|
62
|
+
- `get_impact` — find all affected tests, docs, and downstream code that may break from the change
|
|
63
|
+
- `find_context_for` — assemble review context for changed files within token budget, ranked by relevance
|
|
64
|
+
|
|
65
|
+
Graph queries replace manual grep/find commands and discover transitive dependencies that file search misses. Fall back to file-based commands if no graph is available.
|
|
66
|
+
|
|
57
67
|
### Commit History Context
|
|
58
68
|
|
|
59
69
|
As part of context assembly (priority item #5), retrieve recent commit history for every affected file:
|
|
@@ -233,6 +233,16 @@ Characteristics of a bad fix (revert immediately):
|
|
|
233
233
|
4. Run `harness check-deps` — must PASS
|
|
234
234
|
5. Manually verify the original failing scenario works
|
|
235
235
|
|
|
236
|
+
### Graph Refresh
|
|
237
|
+
|
|
238
|
+
If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
harness scan [path]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
|
|
245
|
+
|
|
236
246
|
#### Step 4: Verify the Test Catches the Bug
|
|
237
247
|
|
|
238
248
|
Apply the regression test verification protocol:
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Harness Dependency Health
|
|
2
|
+
|
|
3
|
+
> Analyze structural health of the codebase and surface problems before they become incidents.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
- Weekly scheduled health check on the codebase
|
|
8
|
+
- Before major refactoring — understand current structural health
|
|
9
|
+
- When onboarding to a new project — assess codebase quality
|
|
10
|
+
- NOT for checking layer violations (use enforce-architecture)
|
|
11
|
+
- NOT for finding dead code (use cleanup-dead-code)
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
A knowledge graph must exist at `.harness/graph/`. Run `harness scan` if no graph is available.
|
|
16
|
+
If the graph exists but code has changed since the last scan, re-run `harness scan` first — stale graph data leads to inaccurate results.
|
|
17
|
+
|
|
18
|
+
## Process
|
|
19
|
+
|
|
20
|
+
### Phase 1: METRICS — Compute Graph Structural Metrics
|
|
21
|
+
|
|
22
|
+
Query the graph for five key structural indicators:
|
|
23
|
+
|
|
24
|
+
1. **Hub detection**: Find nodes with high fan-in (>10 inbound `imports` edges).
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
query_graph(rootNodeIds=[all file nodes], includeEdges=["imports"])
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Hubs are single points of failure — changes to them have outsized blast radius.
|
|
31
|
+
|
|
32
|
+
2. **Orphan detection**: Find file nodes with zero inbound `imports` edges that are not entry points.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
get_relationships(nodeId=<file>, direction="inbound")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Orphans may be dead code or missing from the module system.
|
|
39
|
+
|
|
40
|
+
3. **Cycle detection**: Use `check_dependencies` to find circular import chains.
|
|
41
|
+
Cycles create fragile coupling — any change in the cycle affects all members.
|
|
42
|
+
|
|
43
|
+
4. **Deep chain detection**: Find import chains longer than N hops (default: 7).
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
query_graph(rootNodeIds=[entry points], maxDepth=10, includeEdges=["imports"])
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Deep chains are fragile — a change at the bottom propagates unpredictably.
|
|
50
|
+
|
|
51
|
+
5. **Module cohesion**: For each module (directory), count internal vs external edges. Low internal cohesion (many external edges, few internal) suggests misplaced code.
|
|
52
|
+
|
|
53
|
+
### Phase 2: SCORE — Calculate Health Score
|
|
54
|
+
|
|
55
|
+
Compute a weighted health score (0-100):
|
|
56
|
+
|
|
57
|
+
| Metric | Weight | Scoring |
|
|
58
|
+
| ----------------- | ------ | ----------------------------------------- |
|
|
59
|
+
| Hubs (>10 fan-in) | 25% | 0 hubs = 100, 1-3 = 70, 4-6 = 40, >6 = 10 |
|
|
60
|
+
| Orphans | 20% | 0 = 100, 1-5 = 80, 6-15 = 50, >15 = 20 |
|
|
61
|
+
| Cycles | 25% | 0 = 100, 1 = 60, 2-3 = 30, >3 = 0 |
|
|
62
|
+
| Deep chains (>7) | 15% | 0 = 100, 1-3 = 70, >3 = 30 |
|
|
63
|
+
| Cohesion (avg) | 15% | >0.7 = 100, 0.5-0.7 = 70, <0.5 = 30 |
|
|
64
|
+
|
|
65
|
+
**Grades**: A (90-100), B (75-89), C (60-74), D (40-59), F (<40)
|
|
66
|
+
|
|
67
|
+
### Phase 3: RECOMMEND — Generate Recommendations
|
|
68
|
+
|
|
69
|
+
For each problem found, generate a specific, actionable recommendation:
|
|
70
|
+
|
|
71
|
+
- **Hubs**: "Split `src/utils/helpers.ts` (14 importers) into domain-specific utilities"
|
|
72
|
+
- **Orphans**: "Remove `src/legacy/old-parser.ts` (0 importers, not an entry point)"
|
|
73
|
+
- **Cycles**: "Break cycle A→B→C→A by extracting shared types to `src/types/shared.ts`"
|
|
74
|
+
- **Deep chains**: "Consider flattening chain: entry→A→B→C→D→E→F→G (8 hops)"
|
|
75
|
+
- **Low cohesion**: "Module `src/services/` has 80% external edges — consider splitting"
|
|
76
|
+
|
|
77
|
+
### Output
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
## Dependency Health Report
|
|
81
|
+
|
|
82
|
+
### Score: B (78/100)
|
|
83
|
+
|
|
84
|
+
### Metrics
|
|
85
|
+
| Metric | Count | Score |
|
|
86
|
+
|--------|-------|-------|
|
|
87
|
+
| Hubs (>10 fan-in) | 2 | 70/100 |
|
|
88
|
+
| Orphans | 3 | 80/100 |
|
|
89
|
+
| Cycles | 0 | 100/100 |
|
|
90
|
+
| Deep chains (>7) | 1 | 70/100 |
|
|
91
|
+
| Module cohesion | 0.62 avg | 70/100 |
|
|
92
|
+
|
|
93
|
+
### Top Issues
|
|
94
|
+
1. **Hub**: src/utils/helpers.ts — 14 importers (split recommended)
|
|
95
|
+
2. **Hub**: src/types/index.ts — 12 importers (acceptable for type barrel)
|
|
96
|
+
3. **Orphan**: src/legacy/old-parser.ts — 0 importers
|
|
97
|
+
4. **Deep chain**: entry→auth→user→db→pool→config→env→loader (8 hops)
|
|
98
|
+
|
|
99
|
+
### Recommendations
|
|
100
|
+
1. Split src/utils/helpers.ts into domain-specific modules
|
|
101
|
+
2. Investigate src/legacy/old-parser.ts for removal
|
|
102
|
+
3. Flatten auth chain by having auth import db directly
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Harness Integration
|
|
106
|
+
|
|
107
|
+
- **`harness scan`** — Must run before this skill to ensure graph is current.
|
|
108
|
+
- **`harness validate`** — Run after acting on findings to verify project health.
|
|
109
|
+
- **Graph tools** — This skill uses `query_graph`, `get_relationships`, and `check_dependencies` MCP tools.
|
|
110
|
+
|
|
111
|
+
## Success Criteria
|
|
112
|
+
|
|
113
|
+
- Health score computed on 0-100 scale with letter grade (A-F)
|
|
114
|
+
- All five structural metrics gathered (hubs, orphans, cycles, deep chains, cohesion)
|
|
115
|
+
- Recommendations are specific and actionable (name files, suggest concrete fixes)
|
|
116
|
+
- Report follows the structured output format
|
|
117
|
+
- All findings are backed by graph query evidence, not heuristics
|
|
118
|
+
|
|
119
|
+
## Examples
|
|
120
|
+
|
|
121
|
+
### Example: Weekly Health Check on Monorepo
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Input: Scheduled weekly run on project root
|
|
125
|
+
|
|
126
|
+
1. METRICS — query_graph for hubs: 2 found (helpers.ts, index.ts)
|
|
127
|
+
get_relationships for orphans: 3 found
|
|
128
|
+
check_dependencies for cycles: 0 found
|
|
129
|
+
query_graph for deep chains: 1 found (8 hops)
|
|
130
|
+
Module cohesion average: 0.62
|
|
131
|
+
2. SCORE — Weighted score: 78/100 (Grade: B)
|
|
132
|
+
3. RECOMMEND — "Split helpers.ts (14 importers) into domain modules"
|
|
133
|
+
"Investigate old-parser.ts for removal (0 importers)"
|
|
134
|
+
"Flatten auth chain — 8 hops exceeds threshold"
|
|
135
|
+
|
|
136
|
+
Output:
|
|
137
|
+
Score: B (78/100)
|
|
138
|
+
Top issues: 2 hubs, 3 orphans, 1 deep chain
|
|
139
|
+
3 actionable recommendations generated
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Gates
|
|
143
|
+
|
|
144
|
+
- **No analysis without graph.** If no graph exists, stop and instruct to run `harness scan`.
|
|
145
|
+
- **No guessing.** All metrics must come from graph queries, not heuristics.
|
|
146
|
+
|
|
147
|
+
## Escalation
|
|
148
|
+
|
|
149
|
+
- **When score is F (<40)**: Flag as critical and recommend immediate architectural review.
|
|
150
|
+
- **When graph is stale**: Warn and suggest re-scanning before trusting results.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: harness-dependency-health
|
|
2
|
+
version: "1.0.0"
|
|
3
|
+
description: Analyze structural health of the codebase using graph metrics
|
|
4
|
+
cognitive_mode: analytical-reporter
|
|
5
|
+
triggers:
|
|
6
|
+
- manual
|
|
7
|
+
- scheduled
|
|
8
|
+
platforms:
|
|
9
|
+
- claude-code
|
|
10
|
+
- gemini-cli
|
|
11
|
+
tools:
|
|
12
|
+
- Bash
|
|
13
|
+
- Read
|
|
14
|
+
- Glob
|
|
15
|
+
- Grep
|
|
16
|
+
cli:
|
|
17
|
+
command: harness skill run harness-dependency-health
|
|
18
|
+
args:
|
|
19
|
+
- name: path
|
|
20
|
+
description: Project root path
|
|
21
|
+
required: false
|
|
22
|
+
mcp:
|
|
23
|
+
tool: run_skill
|
|
24
|
+
input:
|
|
25
|
+
skill: harness-dependency-health
|
|
26
|
+
path: string
|
|
27
|
+
type: rigid
|
|
28
|
+
phases:
|
|
29
|
+
- name: metrics
|
|
30
|
+
description: Compute graph structural metrics
|
|
31
|
+
required: true
|
|
32
|
+
- name: score
|
|
33
|
+
description: Calculate health score and identify problems
|
|
34
|
+
required: true
|
|
35
|
+
- name: recommend
|
|
36
|
+
description: Generate specific remediation recommendations
|
|
37
|
+
required: true
|
|
38
|
+
state:
|
|
39
|
+
persistent: false
|
|
40
|
+
files: []
|
|
41
|
+
depends_on: []
|
|
@@ -41,6 +41,15 @@ Deviating from the plan mid-execution introduces untested assumptions, breaks ta
|
|
|
41
41
|
|
|
42
42
|
7. **If prerequisites fail,** do not proceed. Report what is missing and which task is blocked.
|
|
43
43
|
|
|
44
|
+
### Graph-Enhanced Context (when available)
|
|
45
|
+
|
|
46
|
+
When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate context:
|
|
47
|
+
|
|
48
|
+
- `query_graph` — check file overlap between current and next task for conflict detection
|
|
49
|
+
- `get_impact` — understand blast radius before executing a task
|
|
50
|
+
|
|
51
|
+
Enables smarter execution ordering and blockage detection. Fall back to file-based commands if no graph is available.
|
|
52
|
+
|
|
44
53
|
---
|
|
45
54
|
|
|
46
55
|
### Phase 2: EXECUTE — Implement Tasks Atomically
|
|
@@ -137,6 +146,16 @@ Between tasks (especially between sessions):
|
|
|
137
146
|
}
|
|
138
147
|
```
|
|
139
148
|
|
|
149
|
+
### Graph Refresh
|
|
150
|
+
|
|
151
|
+
If a knowledge graph exists at `.harness/graph/`, refresh it after code changes to keep graph queries accurate:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
harness scan [path]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Skipping this step means subsequent graph queries (impact analysis, dependency health, test advisor) may return stale results.
|
|
158
|
+
|
|
140
159
|
2. **Append tagged learnings to `.harness/learnings.md`.** Tag every entry with skill and outcome:
|
|
141
160
|
|
|
142
161
|
```markdown
|