harnessed 4.9.1 → 4.10.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 (64) hide show
  1. package/README.md +43 -6
  2. package/bin/harnessed-inject-state.mjs +103 -2
  3. package/dist/cli.mjs +1758 -1419
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/index.mjs.map +1 -1
  7. package/manifests/skill-packs/frontend-design.yaml +1 -1
  8. package/manifests/skill-packs/gstack.yaml +1 -1
  9. package/manifests/skill-packs/ui-ux-pro-max.yaml +1 -1
  10. package/package.json +1 -1
  11. package/workflows/auto/SKILL.md +26 -12
  12. package/workflows/auto/SKILL.zh-Hans.md +25 -10
  13. package/workflows/discuss/auto/SKILL.md +15 -12
  14. package/workflows/discuss/auto/SKILL.zh-Hans.md +12 -8
  15. package/workflows/discuss/phase/SKILL.md +15 -12
  16. package/workflows/discuss/phase/SKILL.zh-Hans.md +12 -8
  17. package/workflows/discuss/strategic/SKILL.md +15 -12
  18. package/workflows/discuss/strategic/SKILL.zh-Hans.md +12 -8
  19. package/workflows/discuss/subtask/SKILL.md +15 -12
  20. package/workflows/discuss/subtask/SKILL.zh-Hans.md +12 -8
  21. package/workflows/plan/architecture/SKILL.md +14 -12
  22. package/workflows/plan/architecture/SKILL.zh-Hans.md +11 -8
  23. package/workflows/plan/auto/SKILL.md +26 -12
  24. package/workflows/plan/auto/SKILL.zh-Hans.md +25 -10
  25. package/workflows/plan/phase/SKILL.md +14 -12
  26. package/workflows/plan/phase/SKILL.zh-Hans.md +11 -8
  27. package/workflows/research/SKILL.md +14 -12
  28. package/workflows/research/SKILL.zh-Hans.md +11 -8
  29. package/workflows/retro/SKILL.md +14 -12
  30. package/workflows/retro/SKILL.zh-Hans.md +11 -8
  31. package/workflows/role-prompts.yaml +34 -0
  32. package/workflows/role-prompts.zh-Hans.yaml +33 -0
  33. package/workflows/ship/auto/SKILL.md +29 -0
  34. package/workflows/ship/auto/SKILL.zh-Hans.md +28 -0
  35. package/workflows/ship/preflight/SKILL.md +17 -0
  36. package/workflows/ship/preflight/SKILL.zh-Hans.md +16 -0
  37. package/workflows/task/auto/SKILL.md +26 -12
  38. package/workflows/task/auto/SKILL.zh-Hans.md +25 -10
  39. package/workflows/task/clarify/SKILL.md +15 -12
  40. package/workflows/task/clarify/SKILL.zh-Hans.md +12 -8
  41. package/workflows/task/code/SKILL.md +14 -12
  42. package/workflows/task/code/SKILL.zh-Hans.md +11 -8
  43. package/workflows/task/deliver/SKILL.md +14 -12
  44. package/workflows/task/deliver/SKILL.zh-Hans.md +11 -8
  45. package/workflows/task/test/SKILL.md +14 -12
  46. package/workflows/task/test/SKILL.zh-Hans.md +11 -8
  47. package/workflows/verify/auto/SKILL.md +26 -12
  48. package/workflows/verify/auto/SKILL.zh-Hans.md +25 -10
  49. package/workflows/verify/code-review/SKILL.md +14 -12
  50. package/workflows/verify/code-review/SKILL.zh-Hans.md +11 -8
  51. package/workflows/verify/design/SKILL.md +14 -12
  52. package/workflows/verify/design/SKILL.zh-Hans.md +11 -8
  53. package/workflows/verify/multispec/SKILL.md +14 -12
  54. package/workflows/verify/multispec/SKILL.zh-Hans.md +11 -8
  55. package/workflows/verify/paranoid/SKILL.md +14 -12
  56. package/workflows/verify/paranoid/SKILL.zh-Hans.md +11 -8
  57. package/workflows/verify/progress/SKILL.md +14 -12
  58. package/workflows/verify/progress/SKILL.zh-Hans.md +11 -8
  59. package/workflows/verify/qa/SKILL.md +14 -12
  60. package/workflows/verify/qa/SKILL.zh-Hans.md +11 -8
  61. package/workflows/verify/security/SKILL.md +14 -12
  62. package/workflows/verify/security/SKILL.zh-Hans.md +11 -8
  63. package/workflows/verify/simplify/SKILL.md +14 -12
  64. package/workflows/verify/simplify/SKILL.zh-Hans.md +11 -8
package/README.md CHANGED
@@ -12,8 +12,6 @@
12
12
 
13
13
  > Not affiliated with, endorsed by, or sponsored by Harness Inc. (see [NOTICE](./NOTICE))
14
14
 
15
- > **How it compares** to [comet](https://github.com/rpamis/comet) and [Trellis](https://github.com/mindfold-ai/Trellis) — an honest, snapshot-dated comparison (including where harnessed lags): [`docs/comparison.md`](./docs/comparison.md).
16
-
17
15
  ---
18
16
 
19
17
  ## ✨ TL;DR
@@ -39,6 +37,24 @@ flowchart LR
39
37
 
40
38
  ---
41
39
 
40
+ ## 🧱 What is the three-layer stack?
41
+
42
+ harnessed's three-layer stack is a software-engineering implementation of the established **BDD → SDD → TDD** nesting: three nested feedback loops, each answering a different question. The **three layers are the loops** (the stable theory); harnessed **composes** the open-source ecosystem into each loop — and the components **overlap**, which is exactly what a composition orchestrator arbitrates.
43
+
44
+ | Layer | Loop | Question it answers | Composed from (overlapping) |
45
+ |---|---|---|---|
46
+ | **① Behavior** | BDD | *What* to build + how we know it's done | gstack `/office-hours` governance · GSD discuss · superpowers brainstorming → acceptance criteria |
47
+ | **② Spec** | SDD | *How* it's structured | GSD plan-phase → requirements / design / tasks · contracts (Spec Kit / ECC patterns) |
48
+ | **③ Implementation** | TDD | Does it actually *work* | superpowers TDD red-green · subagent execution · GSD verify-work · ralph-loop completion |
49
+
50
+ The loops are **nested lenses, not phases** — the classic Cucumber BDD-outer + TDD-inner double-loop, extended with a GenAI-era SDD spec ring into a triple-loop. harnessed runs the default outer→inner traversal as its 5-stage cadence, plus the **back-edges it ships today**: Verify kicks failing work back to Task, a subagent that hits a gray area round-trips to clarification before continuing, and every shipped cycle feeds learnings back into the next Discuss. (Finer-grained structured back-edges — e.g. a contract contradiction routing straight to Spec, an ambiguous requirement to Behavior — are on the roadmap, not shipped. harnessed is the linear-cadence realization of the triple-loop; the full routed graph is its evolution path.)
51
+
52
+ **The components overlap — that's the point.** **GSD** threads through all three loops as the orchestration backbone, **gstack** spans Behavior + Review, **superpowers** spans Behavior (brainstorm) + Implementation (TDD). harnessed wires them — and arbitrates the overlap — into one engine. Two **cross-cutting disciplines** run through every layer: **karpathy principles** (*how* to code — simplicity-first, surgical diffs) + **mattpocock moves** (on-demand tactical tools like `/diagnose`, `/zoom-out`).
53
+
54
+ Mapped to the runtime loop above: **Discuss = Behavior (BDD) · Plan = Spec (SDD) · Build = Implementation (TDD)**, then **Verify + Ship** close it with evidence gates.
55
+
56
+ ---
57
+
42
58
  > Wait — can harnessed really go toe-to-toe with upstream giants like superpowers / gstack / GSD?
43
59
  > Of course — we **stand on the shoulders of giants**. See further, Newton said. 🧐
44
60
  > ... *(whispers)* Though on closer look, more like the parrot perched on said shoulder.
@@ -48,12 +64,32 @@ flowchart LR
48
64
 
49
65
  ## 🎯 Key Differentiators
50
66
 
51
- - **Three-layer stack machine-executed** — `gstack governance` + `GSD project manager` + `superpowers senior engineer` + `karpathy 4 principles` + `mattpocock 23 moves`, 5 pillars at 100% capture
67
+ - **Three-layer stack machine-executed** — the **BDD→SDD→TDD nested triple-loop** ([what's that?](#-what-is-the-three-layer-stack)), composed from `gstack` + `GSD` + `superpowers` (overlapping, GSD as the backbone) with `karpathy 4 principles` + `mattpocock 23 moves` as cross-cutting disciplines
52
68
  - **No vendoring of upstream** — manifests describe install/check; on upstream upgrade users just re-install to get the latest version
53
69
  - **Composition Skill** — in-house workflow skills act as the conductor's baton, orchestrating multiple upstreams in concert. **1 super-master `/auto` + 5 stage masters + 19 sub-workflows + 2 standalones = 27 namespace-layered workflows**, full 5-stage machine-execution (`/auto` one-shot across stages / `/discuss /plan /task /verify /ship` single stage / 19 three-layer-stack subs / `/research /retro` 2 standalones)
54
70
  - **L0 Discipline Substrate** — global cross-stage behavior baseline (karpathy principles + output-style + language + operational + priority + protocols), applied universally
55
71
  - **Package manager mindset** — install dependency graph auto-resolves, doctor health check, install-base one-shot full install
56
72
  - **Unified entry point** — users face `/discuss /plan /task /verify /ship` master slash commands without learning each upstream's terminology; sub commands explicitly invoke a single stage (e.g. `/discuss-strategic` runs only the strategic-layer clarification)
73
+ - **Forward continuation** — `harnessed next` / `harnessed advance` carry you across tasks and phases: when one finishes, the next is **derived from `.planning/` disk state** (a phase is done when its `PLAN` has a matching `SUMMARY`) — no queue to maintain, so a mid-stream new phase is picked up automatically, and resume re-derives from disk. A per-turn `NEXT-UNIT` breadcrumb points at what's next
74
+
75
+ ---
76
+
77
+ ## 🆚 vs Native Claude Code / Codex
78
+
79
+ Native agents give you primitives; harnessed wires them into a methodology. Where a native cell says a primitive "exists," you still design, wire, and maintain it yourself per project — harnessed ships it pre-composed and engine-driven.
80
+
81
+ | Dimension | Native Claude Code | Native Codex | harnessed |
82
+ |---|---|---|---|
83
+ | **Workflow / methodology** | Primitives only — you design the flow each time | Fewer primitives — freestyle per prompt | Codified **Discuss→Ship** 5-stage three-layer-stack engine — BDD + SDD + TDD loops + 2 cross-cutting (Review + Ship) |
84
+ | **Instruction injection** | `CLAUDE.md` + skills + hooks exist, but static & wired by hand | `AGENTS.md` only — no skills/hooks | Per-turn breadcrumb hook + task-scoped routing + learnings injected each cycle |
85
+ | **State / progress** | Chat context — lost on `/clear` / compaction | Chat context — no persistence layer | On-disk `.planning/` + `current-workflow.json` ledger + checkpoint evidence |
86
+ | **Cross-session recovery** | Re-explain the context by hand | Re-explain the context by hand | `harnessed status --recover`: you-are-here + next step |
87
+ | **Verification / "done"** | Agent self-reports "done" | Agent self-reports "done" | Independent review subagents + **fail-CLOSED evidence guard** (missing artifact = not done) |
88
+ | **Subagent orchestration** | Subagents + Agent Teams available, but orchestrated by hand | No subagent/team primitive | `gates → prompt → spawn → checkpoint`; Agent Teams auto-enabled per task |
89
+ | **Learning loop** | None | None | `LEARNINGS.md` auto-captured + injected into the next cycle |
90
+ | **Platform reach** | Claude Code only | Codex only | **Cross-harness** — Claude Code primary, Codex via platform layer |
91
+
92
+ > Native agents win on zero-setup, zero-overhead for trivial one-off edits. harnessed earns its keep the moment work spans multiple steps, sessions, or subagents — where freestyle drift and lost-in-chat state start costing you.
57
93
 
58
94
  ---
59
95
 
@@ -134,7 +170,7 @@ In order of increasing user intervention:
134
170
  /verify "phase-1" # 7 subs conditional verification
135
171
  ```
136
172
 
137
- > Want to decide which stage to start from / review intermediate outputs — 4 masters callable independently, and each master still auto-fans-out all of that stage's subs internally.
173
+ > Want to decide which stage to start from / review intermediate outputs — 5 masters callable independently, and each master still auto-fans-out all of that stage's subs internally.
138
174
 
139
175
  ### 🔬 Surgical Mode (Expert mode / you know what you want)
140
176
 
@@ -439,7 +475,8 @@ planning-with-files /plan (cross-cutting tool) → write artifacts to .planning/
439
475
  | `harnessed prompt <sub>` | Output a spawn-ready prompt (role + checklist + disciplines + completion/clarification protocols) for a sub-workflow. |
440
476
  | `harnessed checkpoint <action> <sub>` | Record sub-workflow start/complete/fail to `~/.claude/harnessed/checkpoints/`. |
441
477
  | `harnessed` (no args) | Zero-arg you-are-here: active-workflow dashboard + `NEXT: auto\|manual\|done` + run hint; `--json` machine-readable; no active workflow → onboarding hint (comet `/comet` analog, read-only). |
442
- | `harnessed next` | Deterministic next-step contract (`NEXT: auto\|manual\|done`) for the active workflow. |
478
+ | `harnessed next` | Deterministic next-step contract. Within a workflow: `NEXT: auto\|manual\|done`. When the workflow's subs are all resolved it falls through to the next **cross-unit** (next phase/task derived from `.planning/` disk state) with an exit-code contract (`0` advance · `2` done · `10` blocked). |
479
+ | `harnessed advance` | Forward continuation — print the next work unit (next phase/task) across the milestone and the command to run it. Print-only (the main session runs the next `/auto`); refuses to step past an incomplete earlier phase (`--force` overrides); `--json` drives a `while harnessed advance --json; do :; done` loop. |
443
480
  | `harnessed reject <sub>` | Mark a sub as user-rejected (terminal, distinct from `failed`). |
444
481
  | `harnessed compact [--tokens <n>]` | Summarize+evict resolved ledger entries (G6-safe: `fail_count>0` never evicted); auto-triggers on `checkpoint complete --tokens`. |
445
482
  | `harnessed workflows` | List in-flight workflows (one per repo). |
@@ -486,7 +523,7 @@ planning-with-files /plan (cross-cutting tool) → write artifacts to .planning/
486
523
  Yes, but **the user experience = one command**:
487
524
 
488
525
  ```bash
489
- harnessed setup # Auto-installs gstack + GSD + superpowers + planning-with-files; 25 workflow skills land in ~/.claude/skills/ + Agent Teams env var auto-written to ~/.claude.json
526
+ harnessed setup # Auto-installs gstack + GSD + superpowers + planning-with-files; 26 workflow skills land in ~/.claude/skills/ + Agent Teams env var auto-written to ~/.claude.json
490
527
  ```
491
528
 
492
529
  Think `brew install <formula>` pulling the full dependency set — you don't need to `brew install` each dependency separately.
@@ -67,7 +67,91 @@ function readWorkflow(root, keys) {
67
67
  return null
68
68
  }
69
69
 
70
- function workflowStateBlock(wf) {
70
+ // Phase 39 (D6) — plain-JS replicas of planningScan/deriveNext/describeUnit for the
71
+ // hot path. MUST stay byte-equivalent to src/checkpoint/{planningScan,deriveNext,
72
+ // forwardStep}.ts — the parity test compares this file's stdout to buildInjection.
73
+ // includeTasks:false (the per-turn phase-level floor) → tasks are never scanned, so
74
+ // the derived next is always phase-level here.
75
+ const PHASE_DIR = /^(\d+(?:\.\d+)?)-(.*)$/
76
+
77
+ function scanPhases(repoRoot) {
78
+ try {
79
+ const phasesDir = join(repoRoot, '.planning', 'phases')
80
+ if (!existsSync(phasesDir)) return []
81
+ const out = []
82
+ for (const dir of readdirSync(phasesDir)) {
83
+ const m = PHASE_DIR.exec(dir)
84
+ const num = m?.[1]
85
+ if (!num) continue
86
+ const dirPath = join(phasesDir, dir)
87
+ let entries
88
+ try {
89
+ entries = readdirSync(dirPath)
90
+ } catch {
91
+ continue
92
+ }
93
+ let plans = 0
94
+ let summaries = 0
95
+ const prefix = `${num}-`
96
+ for (const f of entries) {
97
+ if (!f.startsWith(prefix)) continue
98
+ if (f.endsWith('-PLAN.md')) plans++
99
+ else if (f.endsWith('-SUMMARY.md')) summaries++
100
+ }
101
+ const complete = plans > 0 && summaries >= plans
102
+ out.push({
103
+ phase: num,
104
+ name: m?.[2] ?? '',
105
+ plans,
106
+ summaries,
107
+ complete,
108
+ order: Number.parseFloat(num),
109
+ })
110
+ }
111
+ out.sort((a, b) => a.order - b.order)
112
+ return out
113
+ } catch {
114
+ return []
115
+ }
116
+ }
117
+
118
+ function describeUnit(unit) {
119
+ switch (unit.kind) {
120
+ case 'phase':
121
+ return `phase ${unit.phase} '${unit.name}'`
122
+ case 'task':
123
+ return `task '${unit.task}' in phase ${unit.phase}`
124
+ case 'sub':
125
+ return `sub '${unit.sub}'`
126
+ default:
127
+ return null
128
+ }
129
+ }
130
+
131
+ /** Mirror deriveNext for the per-turn path (ledger already resolved when called).
132
+ * includeTasks:false → no task branch; first-incomplete phase is the floor. */
133
+ function deriveNextUnit(wf, phases) {
134
+ const ledger = wf.sub_progress ?? []
135
+ const pendingSub = ledger.find((e) => e.status === 'pending')?.sub ?? null
136
+ if (pendingSub !== null) return { kind: 'sub', sub: pendingSub }
137
+ const failed = ledger.find((e) => e.status === 'failed' && (e.fail_count ?? 0) > 0)
138
+ if (failed) return { kind: 'blocked', unit: failed.sub, reason: '' }
139
+ const firstIncomplete = phases.find((p) => !p.complete)
140
+ if (firstIncomplete)
141
+ return { kind: 'phase', phase: firstIncomplete.phase, name: firstIncomplete.name }
142
+ return { kind: 'done' }
143
+ }
144
+
145
+ /** Impure forward pointer (parity with injectState.ts:forwardPointer). null unless
146
+ * the next is a concrete phase|task. */
147
+ function forwardPointer(repoRoot, wf) {
148
+ const phases = scanPhases(repoRoot)
149
+ const unit = deriveNextUnit(wf, phases)
150
+ if (unit.kind !== 'phase' && unit.kind !== 'task') return null
151
+ return { unit, remainingPhases: phases.filter((p) => !p.complete).length }
152
+ }
153
+
154
+ function workflowStateBlock(wf, forward) {
71
155
  const ledger = wf.sub_progress ?? []
72
156
  const next = ledger.find((e) => e.status === 'pending')?.sub ?? null
73
157
  const lines = [
@@ -76,6 +160,19 @@ function workflowStateBlock(wf) {
76
160
  `status: ${wf.status}`,
77
161
  next ? `next: ${next}` : 'next: (none — all subs resolved)',
78
162
  ]
163
+ // issue #2 (T2) — anti-freestyle enforcement (parity with injectState.ts).
164
+ if (next) {
165
+ lines.push(
166
+ `ENGINE: mid state-machine — drive sub '${next}' via \`harnessed prompt ${next}\` → spawn → \`harnessed checkpoint complete/fail\`. Do NOT freestyle the orchestration or skip the ledger; run \`harnessed status --recover\` if unsure where you are.`,
167
+ )
168
+ }
169
+ // Phase 39 (D6) — per-turn current→next pointer (parity with injectState.ts).
170
+ if (!next && forward && (forward.unit.kind === 'phase' || forward.unit.kind === 'task')) {
171
+ const n = forward.remainingPhases
172
+ lines.push(
173
+ `NEXT-UNIT: current workflow complete → next is ${describeUnit(forward.unit)} (run /auto or \`harnessed advance\`); ${n} phase${n === 1 ? '' : 's'} remain`,
174
+ )
175
+ }
79
176
  for (const e of ledger) {
80
177
  if ((e.fail_count ?? 0) >= 3)
81
178
  lines.push(
@@ -176,7 +273,11 @@ try {
176
273
  if (!wf) process.exit(0)
177
274
 
178
275
  const budget = Number(process.env.HARNESSED_INJECT_BUDGET) || DEFAULT_INJECT_BUDGET
179
- const ws = workflowStateBlock(wf)
276
+ // Phase 39 (D6) — derive the forward pointer only when the subs are all resolved
277
+ // (parity with buildInjection). `key` is the repo root holding .planning/.
278
+ const pending = (wf.sub_progress ?? []).find((e) => e.status === 'pending')?.sub ?? null
279
+ const forward = pending === null ? forwardPointer(key, wf) : null
280
+ const ws = workflowStateBlock(wf, forward)
180
281
 
181
282
  let learningsMd = ''
182
283
  try {