@harness-engineering/cli 1.8.0 → 1.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.
Files changed (74) hide show
  1. package/dist/agents/skills/claude-code/harness-autopilot/SKILL.md +2 -2
  2. package/dist/agents/skills/claude-code/harness-brainstorming/SKILL.md +5 -7
  3. package/dist/agents/skills/claude-code/harness-code-review/SKILL.md +2 -2
  4. package/dist/agents/skills/claude-code/harness-planning/SKILL.md +2 -2
  5. package/dist/agents/skills/claude-code/harness-roadmap/SKILL.md +4 -5
  6. package/dist/agents/skills/gemini-cli/add-harness-component/SKILL.md +192 -0
  7. package/dist/agents/skills/gemini-cli/add-harness-component/skill.yaml +32 -0
  8. package/dist/agents/skills/gemini-cli/align-documentation/SKILL.md +213 -0
  9. package/dist/agents/skills/gemini-cli/align-documentation/skill.yaml +31 -0
  10. package/dist/agents/skills/gemini-cli/check-mechanical-constraints/SKILL.md +191 -0
  11. package/dist/agents/skills/gemini-cli/check-mechanical-constraints/skill.yaml +32 -0
  12. package/dist/agents/skills/gemini-cli/cleanup-dead-code/SKILL.md +245 -0
  13. package/dist/agents/skills/gemini-cli/cleanup-dead-code/skill.yaml +33 -0
  14. package/dist/agents/skills/gemini-cli/detect-doc-drift/SKILL.md +179 -0
  15. package/dist/agents/skills/gemini-cli/detect-doc-drift/skill.yaml +30 -0
  16. package/dist/agents/skills/gemini-cli/enforce-architecture/SKILL.md +240 -0
  17. package/dist/agents/skills/gemini-cli/enforce-architecture/skill.yaml +34 -0
  18. package/dist/agents/skills/gemini-cli/harness-architecture-advisor/SKILL.md +397 -0
  19. package/dist/agents/skills/gemini-cli/harness-architecture-advisor/skill.yaml +48 -0
  20. package/dist/agents/skills/gemini-cli/harness-autopilot/SKILL.md +2 -2
  21. package/dist/agents/skills/gemini-cli/harness-brainstorming/SKILL.md +317 -0
  22. package/dist/agents/skills/gemini-cli/harness-brainstorming/skill.yaml +49 -0
  23. package/dist/agents/skills/gemini-cli/harness-code-review/SKILL.md +681 -0
  24. package/dist/agents/skills/gemini-cli/harness-code-review/skill.yaml +45 -0
  25. package/dist/agents/skills/gemini-cli/harness-debugging/SKILL.md +366 -0
  26. package/dist/agents/skills/gemini-cli/harness-debugging/skill.yaml +47 -0
  27. package/dist/agents/skills/gemini-cli/harness-diagnostics/SKILL.md +318 -0
  28. package/dist/agents/skills/gemini-cli/harness-diagnostics/skill.yaml +50 -0
  29. package/dist/agents/skills/gemini-cli/harness-execution/SKILL.md +382 -0
  30. package/dist/agents/skills/gemini-cli/harness-execution/skill.yaml +51 -0
  31. package/dist/agents/skills/gemini-cli/harness-git-workflow/SKILL.md +268 -0
  32. package/dist/agents/skills/gemini-cli/harness-git-workflow/skill.yaml +31 -0
  33. package/dist/agents/skills/gemini-cli/harness-integrity/SKILL.md +167 -0
  34. package/dist/agents/skills/gemini-cli/harness-integrity/skill.yaml +47 -0
  35. package/dist/agents/skills/gemini-cli/harness-onboarding/SKILL.md +288 -0
  36. package/dist/agents/skills/gemini-cli/harness-onboarding/skill.yaml +30 -0
  37. package/dist/agents/skills/gemini-cli/harness-parallel-agents/SKILL.md +171 -0
  38. package/dist/agents/skills/gemini-cli/harness-parallel-agents/skill.yaml +33 -0
  39. package/dist/agents/skills/gemini-cli/harness-planning/SKILL.md +389 -0
  40. package/dist/agents/skills/gemini-cli/harness-planning/skill.yaml +49 -0
  41. package/dist/agents/skills/gemini-cli/harness-pre-commit-review/SKILL.md +262 -0
  42. package/dist/agents/skills/gemini-cli/harness-pre-commit-review/skill.yaml +33 -0
  43. package/dist/agents/skills/gemini-cli/harness-refactoring/SKILL.md +169 -0
  44. package/dist/agents/skills/gemini-cli/harness-refactoring/skill.yaml +33 -0
  45. package/dist/agents/skills/gemini-cli/harness-roadmap/SKILL.md +4 -5
  46. package/dist/agents/skills/gemini-cli/harness-skill-authoring/SKILL.md +292 -0
  47. package/dist/agents/skills/gemini-cli/harness-skill-authoring/skill.yaml +32 -0
  48. package/dist/agents/skills/gemini-cli/harness-state-management/SKILL.md +309 -0
  49. package/dist/agents/skills/gemini-cli/harness-state-management/skill.yaml +32 -0
  50. package/dist/agents/skills/gemini-cli/harness-tdd/SKILL.md +177 -0
  51. package/dist/agents/skills/gemini-cli/harness-tdd/skill.yaml +48 -0
  52. package/dist/agents/skills/gemini-cli/harness-verification/SKILL.md +328 -0
  53. package/dist/agents/skills/gemini-cli/harness-verification/skill.yaml +42 -0
  54. package/dist/agents/skills/gemini-cli/harness-verify/SKILL.md +159 -0
  55. package/dist/agents/skills/gemini-cli/harness-verify/skill.yaml +40 -0
  56. package/dist/agents/skills/gemini-cli/initialize-harness-project/SKILL.md +224 -0
  57. package/dist/agents/skills/gemini-cli/initialize-harness-project/skill.yaml +31 -0
  58. package/dist/agents/skills/gemini-cli/validate-context-engineering/SKILL.md +150 -0
  59. package/dist/agents/skills/gemini-cli/validate-context-engineering/skill.yaml +31 -0
  60. package/dist/bin/harness.js +3 -3
  61. package/dist/{chunk-SJECMKSS.js → chunk-E2RTDBMG.js} +25 -13
  62. package/dist/{chunk-LNI4T7R6.js → chunk-KJANDVVC.js} +20 -18
  63. package/dist/{chunk-3JWCBVUZ.js → chunk-RT2LYQHF.js} +1 -1
  64. package/dist/{dist-NT3GXHQZ.js → dist-CCM3L3UE.js} +1 -1
  65. package/dist/{dist-BDO5GFEM.js → dist-K6KTTN3I.js} +3 -3
  66. package/dist/index.js +3 -3
  67. package/dist/validate-cross-check-ZGKFQY57.js +7 -0
  68. package/package.json +6 -6
  69. package/dist/agents/skills/node_modules/.bin/glob +0 -17
  70. package/dist/agents/skills/node_modules/.bin/vitest +0 -17
  71. package/dist/agents/skills/node_modules/.bin/yaml +0 -17
  72. package/dist/templates/advanced/docs/specs/.gitkeep +0 -0
  73. package/dist/templates/intermediate/docs/specs/.gitkeep +0 -0
  74. package/dist/validate-cross-check-2OPGCGGU.js +0 -7
@@ -0,0 +1,30 @@
1
+ name: detect-doc-drift
2
+ version: "1.0.0"
3
+ description: Detect documentation that has drifted from code
4
+ cognitive_mode: diagnostic-investigator
5
+ triggers:
6
+ - manual
7
+ - on_pr
8
+ platforms:
9
+ - claude-code
10
+ - gemini-cli
11
+ tools:
12
+ - Bash
13
+ - Read
14
+ - Glob
15
+ cli:
16
+ command: harness skill run detect-doc-drift
17
+ args:
18
+ - name: path
19
+ description: Project root path
20
+ required: false
21
+ mcp:
22
+ tool: run_skill
23
+ input:
24
+ skill: detect-doc-drift
25
+ path: string
26
+ type: flexible
27
+ state:
28
+ persistent: false
29
+ files: []
30
+ depends_on: []
@@ -0,0 +1,240 @@
1
+ # Enforce Architecture
2
+
3
+ > Validate architectural layer boundaries and detect dependency violations. No code may violate layer constraints — this is a hard gate, not a suggestion.
4
+
5
+ ## When to Use
6
+
7
+ - Before approving any pull request or merge
8
+ - After writing new imports or module references
9
+ - When adding a new module or package to the project
10
+ - When `on_pre_commit` or `on_architecture_check` triggers fire
11
+ - After refactoring that moves code between layers or modules
12
+ - NOT when editing documentation, configuration, or non-code files
13
+ - NOT when the violation is intentional and requires a constraint update (escalate instead)
14
+
15
+ ## Process
16
+
17
+ ### Phase 1: Load Constraints
18
+
19
+ 1. **Read `harness.config.json`** to understand the project's architectural constraints. The config defines:
20
+ - **Layers** — ordered list of architectural layers (e.g., `ui -> service -> repository -> domain`)
21
+ - **Dependency rules** — which layers may import from which (typically: layers may only import from layers below them)
22
+ - **Forbidden imports** — specific import paths that are never allowed in certain contexts
23
+ - **Boundary definitions** — which directories/packages belong to which layer
24
+
25
+ - **Design constraints** — when `design` config exists, also load design constraint rules:
26
+ - Token compliance — components must reference design tokens, not hardcoded values
27
+ - Accessibility compliance — color pairs must meet WCAG contrast ratios
28
+ - Anti-pattern enforcement — project-specific anti-patterns from `design-system/DESIGN.md`
29
+ - Platform binding — tokens must have appropriate platform bindings for enabled platforms
30
+
31
+ 2. **Understand the layer model.** In a typical layered architecture:
32
+ - Higher layers depend on lower layers (UI depends on Service, Service depends on Repository)
33
+ - Lower layers NEVER depend on higher layers (Repository must not import from UI)
34
+ - Same-layer imports may or may not be allowed depending on project config
35
+ - Cross-cutting concerns (logging, config) have their own rules
36
+
37
+ ### Graph-Enhanced Context (when available)
38
+
39
+ When a knowledge graph exists at `.harness/graph/`, use graph queries for faster, more accurate violation detection:
40
+
41
+ - `query_graph` — traverse `imports` edges against layer constraint nodes to find all violations in a single query
42
+ - `get_relationships` — find all code dependent on a violation target to show the full scope of impact
43
+
44
+ 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.
45
+
46
+ ### Phase 2: Run Dependency Checks
47
+
48
+ 1. **Run `harness check-deps`** to analyze all import statements against the constraint model. Capture the full JSON output.
49
+
50
+ 2. **Parse the results.** Each violation includes:
51
+ - The violating file and line number
52
+ - The forbidden import target
53
+ - The source layer and target layer
54
+ - The specific rule being violated
55
+
56
+ ### Phase 3: Analyze Violations
57
+
58
+ For each violation, determine:
59
+
60
+ 1. **Which layers are involved.** Identify the source file's layer and the imported module's layer. Map them to the constraint model.
61
+
62
+ 2. **What rule is violated.** Common violation types:
63
+ - **Upward dependency** — a lower layer imports from a higher layer (e.g., repository importing from UI). This is the most serious type. It creates coupling that makes the lower layer untestable in isolation.
64
+ - **Skip-layer dependency** — a layer reaches past its immediate neighbor (e.g., UI importing directly from Repository, bypassing Service). This breaks encapsulation and makes the middle layer pointless.
65
+ - **Circular dependency** — two modules or layers depend on each other. This creates fragile coupling where changing either module risks breaking the other.
66
+ - **Forbidden import** — a specific import that is explicitly banned (e.g., importing a database driver outside the repository layer). This prevents implementation details from leaking.
67
+ - **Design constraint violation** — a component uses hardcoded values instead of design tokens, or violates a declared anti-pattern. Severity depends on `design.strictness` in config. These violations surface as DESIGN-xxx codes:
68
+ - `DESIGN-001` [warn] — Hardcoded color/font/spacing instead of token reference
69
+ - `DESIGN-002` [warn] — Value matches a project anti-pattern
70
+ - `DESIGN-003` [error] — WCAG contrast ratio failure (error in strict mode)
71
+ - `DESIGN-004` [info] — Missing platform binding for enabled platform
72
+
73
+ 3. **Explain the impact.** For each violation, state:
74
+ - WHY the constraint exists (what architectural property it protects)
75
+ - WHAT would happen if the violation were allowed to persist
76
+ - HOW it affects testability, maintainability, and changeability
77
+
78
+ ### Phase 3.5: Apply Safe Architecture Fixes
79
+
80
+ Some architecture violations can be auto-fixed. Apply these before surfacing remaining violations.
81
+
82
+ **Import ordering violations:**
83
+
84
+ 1. Identify files where imports are not ordered according to the project's layer convention.
85
+ 2. Reorder imports: external packages first, then by layer (lowest to highest), then relative imports.
86
+ 3. Verify with lint + typecheck. This is a safe, mechanical fix.
87
+
88
+ **Forbidden import replacement (with configured alternative):**
89
+
90
+ 1. Check `harness.config.json` for `forbiddenImports` entries that include an `alternative` field.
91
+ 2. For each violation where an alternative exists, replace the import path with the alternative.
92
+ 3. Verify with typecheck + test. This is "probably safe" -- present as a diff for approval in interactive mode, apply silently in CI mode.
93
+
94
+ **Design token substitution (unambiguous mapping):**
95
+
96
+ 1. When a hardcoded value has exactly one matching design token, replace the literal with the token reference.
97
+ 2. Verify with typecheck + test.
98
+ 3. If the mapping is ambiguous (multiple candidate tokens), surface to user.
99
+
100
+ **Never auto-fix these (always surface to user):**
101
+
102
+ - Upward dependencies
103
+ - Skip-layer dependencies
104
+ - Circular dependencies
105
+ - Forbidden imports without a configured alternative
106
+
107
+ ### Phase 3.6: Convergence Loop (Standalone)
108
+
109
+ When running standalone (not through the orchestrator), apply a single-concern convergence loop:
110
+
111
+ 1. **Re-run detection.** After applying all safe/probably-safe fixes, run `harness check-deps` again.
112
+ 2. **Check if violation count decreased.** Compare the new count to the previous count.
113
+ 3. **If decreased: loop.** Fixing one violation can resolve others (e.g., replacing a forbidden import may eliminate a transitive skip-layer violation). Go back to Phase 2 with the new results.
114
+ 4. **If unchanged: stop.** Proceed to Phase 4 (Guide Resolution) for remaining violations.
115
+ 5. **Maximum iterations: 5.** To prevent infinite loops.
116
+
117
+ **Verification gate:** After each fix batch, run:
118
+
119
+ ```
120
+ pnpm lint && pnpm tsc --noEmit && pnpm test
121
+ ```
122
+
123
+ If any command fails, revert the batch and reclassify those findings as unsafe.
124
+
125
+ ### Phase 4: Guide Resolution
126
+
127
+ For each violation, provide a specific fix:
128
+
129
+ - **Upward dependency:** Introduce an interface or abstraction in the lower layer. The higher layer implements it; the lower layer depends only on the abstraction. Alternatively, use dependency injection.
130
+ - **Skip-layer dependency:** Route the call through the intermediate layer. Add a method to the Service layer that delegates to the Repository, then have the UI call the Service.
131
+ - **Circular dependency:** Break the cycle by extracting shared types into a common module that both can depend on, or restructure so the dependency flows in one direction only.
132
+ - **Forbidden import:** Check `harness.config.json` for an `alternative` field. If present, this should have been auto-fixed in Phase 3.5. If not present, replace the forbidden import with the approved alternative or restructure the code.
133
+ - **Design constraint violation:** Replace hardcoded values with token references from `design-system/tokens.json`. For anti-pattern violations, consult `design-system/DESIGN.md` for the project's aesthetic intent and approved alternatives. For contrast failures, use `harness-accessibility` to find compliant color pairs.
134
+
135
+ ## Common Violation Patterns
136
+
137
+ ### Pattern: "I just need one thing from that layer"
138
+
139
+ A UI component imports a repository function directly because "it is just one query." Fix: add the query to the Service layer. The extra indirection is the architecture working correctly.
140
+
141
+ ### Pattern: "Shared types across layers"
142
+
143
+ Two layers both need the same type definition. Fix: place shared types in the lowest layer that both depend on, or create a dedicated `types` or `shared` module at the bottom of the layer stack.
144
+
145
+ ### Pattern: "Test utilities importing production code from wrong layer"
146
+
147
+ Test helpers import across layer boundaries for convenience. Fix: each layer's tests should only import from that layer and below. Test utilities should follow the same constraints as production code.
148
+
149
+ ### Pattern: "Hardcoded colors in components"
150
+
151
+ A component uses `#3b82f6` directly instead of referencing `color.primary` from the design token system. Fix: import and reference the token. In Tailwind: use the token-mapped utility class. In CSS: use the custom property `var(--color-primary)`.
152
+
153
+ ### Pattern: "Circular dependency through re-exports"
154
+
155
+ Module A re-exports from Module B, and Module B imports from Module A. The circular dependency is hidden by the re-export. Fix: identify the true dependency direction and remove the reverse path.
156
+
157
+ ## Harness Integration
158
+
159
+ - **`harness check-deps`** — Primary tool. Analyzes all imports against the layer model defined in `harness.config.json`. Returns structured violation data including file, line, source layer, target layer, and rule violated.
160
+ - **`harness check-deps --json`** — Machine-readable output for automated pipelines. Use this when parsing results programmatically.
161
+ - **`harness validate`** — Includes dependency checking as part of full project validation. Use when you want a complete health check, not just architecture.
162
+ - **`harness-design-system`** — Provides the design token source of truth (`tokens.json`) that constraints validate against.
163
+ - **`harness-accessibility`** — Provides WCAG contrast validation used by DESIGN-003 constraints.
164
+ - **Design constraint category** — Controlled by `design.strictness` in `harness.config.json`. Design violations surface alongside architectural violations in the same report.
165
+
166
+ ## Success Criteria
167
+
168
+ - `harness check-deps` reports zero violations
169
+ - All imports flow downward through the layer stack (or follow explicitly configured exceptions)
170
+ - No circular dependencies exist between modules or layers
171
+ - No forbidden imports are present anywhere in the codebase
172
+ - Every new module is assigned to the correct layer in the config
173
+ - The layer model in `harness.config.json` accurately reflects the intended architecture
174
+
175
+ ## Examples
176
+
177
+ ### Example: Service layer importing from UI layer
178
+
179
+ **Violation from `harness check-deps`:**
180
+
181
+ ```
182
+ VIOLATION: Upward dependency
183
+ File: src/services/user-service.ts:12
184
+ Import: import { UserForm } from '../components/UserForm'
185
+ Source layer: service (level 2)
186
+ Target layer: ui (level 3)
187
+ Rule: service layer must not depend on ui layer
188
+ ```
189
+
190
+ **Impact:** The UserService now depends on a React component. It cannot be used in a CLI tool, a background job, or tested without a DOM. The service layer should be framework-agnostic.
191
+
192
+ **Resolution:**
193
+
194
+ ```typescript
195
+ // BEFORE (violating)
196
+ import { UserForm } from '../components/UserForm';
197
+ const data = UserForm.defaultValues; // using UI defaults in service
198
+
199
+ // AFTER (fixed)
200
+ // Define the defaults where they belong — in the service layer
201
+ const DEFAULT_USER_DATA: UserInput = { name: '', email: '' };
202
+ ```
203
+
204
+ ### Example: Circular dependency between modules
205
+
206
+ **Violation from `harness check-deps`:**
207
+
208
+ ```
209
+ VIOLATION: Circular dependency detected
210
+ Cycle: src/services/order-service.ts -> src/services/inventory-service.ts -> src/services/order-service.ts
211
+ order-service imports checkStock from inventory-service
212
+ inventory-service imports getOrderQuantity from order-service
213
+ ```
214
+
215
+ **Resolution:** Extract the shared concern into a new module:
216
+
217
+ ```typescript
218
+ // src/services/stock-calculator.ts (new, shared module)
219
+ export function calculateRequiredStock(quantity: number, reserved: number): number {
220
+ return quantity - reserved;
221
+ }
222
+ ```
223
+
224
+ Both services import from `stock-calculator` instead of from each other. The cycle is broken.
225
+
226
+ ## Gates
227
+
228
+ These are hard stops. Architecture violations are not warnings — they are errors.
229
+
230
+ - **No code with layer violations may be approved or merged.** If `harness check-deps` reports violations, the code must be fixed before it proceeds.
231
+ - **No new modules without layer assignment.** Every new directory or package must be mapped to a layer in `harness.config.json` before code is written in it.
232
+ - **No "temporary" violations.** There is no TODO for architecture. Either the code respects the constraints or it does not ship.
233
+ - **No suppressing violations without team approval.** If a violation needs to be allowed, the constraint in `harness.config.json` must be explicitly updated with a comment explaining why.
234
+
235
+ ## Escalation
236
+
237
+ - **When a violation seems impossible to fix within the current architecture:** The architecture may need to evolve. Escalate to the human with a clear explanation of the constraint, the use case, and why they conflict. Propose options: update the constraint, restructure the code, or add a new layer.
238
+ - **When `harness check-deps` reports false positives:** Verify the layer assignments in `harness.config.json` are correct. If a file is assigned to the wrong layer, fix the config. If the tool is genuinely wrong, report the issue.
239
+ - **When fixing one violation creates another:** This usually indicates a deeper structural issue. Step back and look at the dependency graph as a whole rather than fixing violations one at a time.
240
+ - **When the team wants to change the layer model:** This is a significant architectural decision. All existing code must be migrated to the new model. Plan this as a dedicated refactoring effort, not a side task.
@@ -0,0 +1,34 @@
1
+ name: enforce-architecture
2
+ version: "1.1.0"
3
+ description: Validate architectural layer boundaries, detect violations, and auto-fix import ordering and forbidden import replacement
4
+ cognitive_mode: meticulous-verifier
5
+ triggers:
6
+ - manual
7
+ - on_pr
8
+ - on_commit
9
+ platforms:
10
+ - claude-code
11
+ - gemini-cli
12
+ tools:
13
+ - Bash
14
+ - Read
15
+ - Glob
16
+ cli:
17
+ command: harness skill run enforce-architecture
18
+ args:
19
+ - name: path
20
+ description: Project root path
21
+ required: false
22
+ - name: fix
23
+ description: Enable auto-fix with convergence loop
24
+ required: false
25
+ mcp:
26
+ tool: run_skill
27
+ input:
28
+ skill: enforce-architecture
29
+ path: string
30
+ type: rigid
31
+ state:
32
+ persistent: false
33
+ files: []
34
+ depends_on: []