harnessed 4.21.0 → 4.22.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.
Files changed (52) hide show
  1. package/bin/harnessed-inject-state.mjs +68 -8
  2. package/dist/cli.mjs +428 -102
  3. package/dist/cli.mjs.map +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/workflows/auto/SKILL.md +5 -1
  8. package/workflows/auto/SKILL.zh-Hans.md +5 -1
  9. package/workflows/plan/architecture/SKILL.md +4 -0
  10. package/workflows/plan/architecture/SKILL.zh-Hans.md +4 -0
  11. package/workflows/plan/auto/SKILL.md +4 -0
  12. package/workflows/plan/auto/SKILL.zh-Hans.md +4 -0
  13. package/workflows/plan/phase/SKILL.md +4 -0
  14. package/workflows/plan/phase/SKILL.zh-Hans.md +4 -0
  15. package/workflows/research/SKILL.md +4 -0
  16. package/workflows/research/SKILL.zh-Hans.md +4 -0
  17. package/workflows/retro/SKILL.md +4 -0
  18. package/workflows/retro/SKILL.zh-Hans.md +4 -0
  19. package/workflows/ship/auto/SKILL.md +4 -0
  20. package/workflows/ship/auto/SKILL.zh-Hans.md +4 -0
  21. package/workflows/ship/preflight/SKILL.md +4 -0
  22. package/workflows/ship/preflight/SKILL.zh-Hans.md +4 -0
  23. package/workflows/task/auto/SKILL.md +4 -0
  24. package/workflows/task/auto/SKILL.zh-Hans.md +4 -0
  25. package/workflows/task/code/SKILL.md +4 -0
  26. package/workflows/task/code/SKILL.zh-Hans.md +4 -0
  27. package/workflows/task/deliver/SKILL.md +4 -0
  28. package/workflows/task/deliver/SKILL.zh-Hans.md +4 -0
  29. package/workflows/task/test/SKILL.md +4 -0
  30. package/workflows/task/test/SKILL.zh-Hans.md +4 -0
  31. package/workflows/verify/auto/SKILL.md +4 -0
  32. package/workflows/verify/auto/SKILL.zh-Hans.md +4 -0
  33. package/workflows/verify/code-review/SKILL.md +4 -0
  34. package/workflows/verify/code-review/SKILL.zh-Hans.md +4 -0
  35. package/workflows/verify/design/SKILL.md +4 -0
  36. package/workflows/verify/design/SKILL.zh-Hans.md +4 -0
  37. package/workflows/verify/eval-review/SKILL.md +4 -0
  38. package/workflows/verify/eval-review/SKILL.zh-Hans.md +4 -0
  39. package/workflows/verify/multispec/SKILL.md +4 -0
  40. package/workflows/verify/multispec/SKILL.zh-Hans.md +4 -0
  41. package/workflows/verify/paranoid/SKILL.md +4 -0
  42. package/workflows/verify/paranoid/SKILL.zh-Hans.md +4 -0
  43. package/workflows/verify/progress/SKILL.md +4 -0
  44. package/workflows/verify/progress/SKILL.zh-Hans.md +4 -0
  45. package/workflows/verify/qa/SKILL.md +4 -0
  46. package/workflows/verify/qa/SKILL.zh-Hans.md +4 -0
  47. package/workflows/verify/security/SKILL.md +4 -0
  48. package/workflows/verify/security/SKILL.zh-Hans.md +4 -0
  49. package/workflows/verify/simplify/SKILL.md +4 -0
  50. package/workflows/verify/simplify/SKILL.zh-Hans.md +4 -0
  51. package/workflows/verify/validate-phase/SKILL.md +4 -0
  52. package/workflows/verify/validate-phase/SKILL.zh-Hans.md +4 -0
@@ -52,19 +52,71 @@ function sessionIdEnvName() {
52
52
 
53
53
  // Phase 35 — try the session-scoped slot first, then the bare repoKey slot, then
54
54
  // the legacy singleton (dual-write anchor). `keys` is ordered most→least specific.
55
+ // 4.22.0 — also surfaces the intent sidecar (same key order) for the freestyle nag.
55
56
  function readWorkflow(root, keys) {
57
+ let wf = null
58
+ let intent = null
56
59
  try {
57
60
  const store = JSON.parse(readFileSync(join(root, 'workflows.json'), 'utf8'))
58
61
  if (store?.workflows) {
59
62
  for (const k of keys) {
60
- if (store.workflows[k]) return store.workflows[k]
63
+ if (store.workflows[k]) {
64
+ wf = store.workflows[k]
65
+ break
66
+ }
67
+ }
68
+ }
69
+ if (store?.intents) {
70
+ for (const k of keys) {
71
+ if (store.intents[k]) {
72
+ intent = store.intents[k]
73
+ break
74
+ }
61
75
  }
62
76
  }
63
77
  } catch {}
64
- try {
65
- return JSON.parse(readFileSync(join(root, 'current-workflow.json'), 'utf8'))
66
- } catch {}
67
- return null
78
+ if (!wf) {
79
+ try {
80
+ wf = JSON.parse(readFileSync(join(root, 'current-workflow.json'), 'utf8'))
81
+ } catch {}
82
+ }
83
+ return { wf, intent }
84
+ }
85
+
86
+ // 4.22.0 — parity with injectState.ts INTENT_TTL_MS / formatIntentAge /
87
+ // buildIntentBlock (the parity test compares stdout byte-for-byte).
88
+ const INTENT_TTL_MS = 24 * 60 * 60 * 1000
89
+
90
+ function formatIntentAge(ms) {
91
+ const m = Math.floor(ms / 60_000)
92
+ if (m < 1) return '<1m'
93
+ if (m < 60) return `${m}m`
94
+ return `${Math.floor(m / 60)}h`
95
+ }
96
+
97
+ function intentBlock(intent, nowMs) {
98
+ if (!intent) return ''
99
+ const born = Date.parse(intent.ts)
100
+ if (Number.isNaN(born)) return ''
101
+ const age = nowMs - born
102
+ if (age < 0 || age > INTENT_TTL_MS) return ''
103
+ const m = intent.master
104
+ // 4.22.0 T6 — leaf variant (MUST stay byte-equivalent to injectState.ts
105
+ // buildIntentBlock; the parity test compares the two). kind-absent = master.
106
+ if (intent.kind === 'leaf') {
107
+ return [
108
+ '<workflow-intent>',
109
+ `intent: /${m} invoked ${formatIntentAge(age)} ago — sub NOT checkpointed`,
110
+ `ENGINE: /${m} is registered but not engaged — freestyle risk. Run: \`harnessed prompt ${m} --task "<spec>" --json\` → spawn per SOP → \`harnessed checkpoint complete ${m}\` (or \`harnessed checkpoint fail ${m}\`).`,
111
+ '</workflow-intent>',
112
+ ].join('\n')
113
+ }
114
+ return [
115
+ '<workflow-intent>',
116
+ `intent: /${m} invoked ${formatIntentAge(age)} ago — ledger NOT seeded`,
117
+ `ENGINE: /${m} is registered but not engaged — freestyle risk. Run: \`harnessed gates ${m} --task "<locked spec>"\` → \`harnessed checkpoint start ${m} --plan '<gates JSON>'\`; then drive each sub via \`harnessed prompt\` / \`harnessed checkpoint complete|fail\`.`,
118
+ '</workflow-intent>',
119
+ ].join('\n')
68
120
  }
69
121
 
70
122
  // Phase 39 (D6) — plain-JS replicas of planningScan/deriveNext/describeUnit for the
@@ -269,8 +321,15 @@ try {
269
321
  const key = repoKey(process.cwd())
270
322
  const envName = sessionIdEnvName()
271
323
  const sid = envName ? process.env[envName]?.trim() : undefined
272
- const wf = readWorkflow(root, sid ? [`${key}::${sid}`, key] : [key])
273
- if (!wf) process.exit(0)
324
+ const { wf, intent } = readWorkflow(root, sid ? [`${key}::${sid}`, key] : [key])
325
+ // 4.22.0 — freestyle nag: a fresh intent whose ledger was never seeded (start
326
+ // absorbs the intent) keeps reminding until steps 2-3 (gates → start) run.
327
+ const ledgerEmpty = (wf?.sub_progress ?? []).length === 0
328
+ const ib = ledgerEmpty ? intentBlock(intent, Date.now()) : ''
329
+ if (!wf) {
330
+ if (ib) process.stdout.write(`${ib}\n`)
331
+ process.exit(0)
332
+ }
274
333
 
275
334
  const budget = Number(process.env.HARNESSED_INJECT_BUDGET) || DEFAULT_INJECT_BUDGET
276
335
  // Phase 39 (D6) — derive the forward pointer only when the subs are all resolved
@@ -293,7 +352,8 @@ try {
293
352
  const ctx = findPhaseContextExcerpt(key, wf.phase, Math.max(0, budget - used))
294
353
  const pc = projectContextBlock(rel, ctx ?? undefined)
295
354
 
296
- process.stdout.write(`${pc ? `${ws}\n${pc}` : ws}\n`)
355
+ const normal = pc ? `${ws}\n${pc}` : ws
356
+ process.stdout.write(`${ib ? `${ib}\n${normal}` : normal}\n`)
297
357
  } catch {
298
358
  // no state / corrupt / not a harnessed session -> inject nothing
299
359
  }