@sockulags/agent-os 0.14.0 → 0.16.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 (101) hide show
  1. package/README.md +102 -49
  2. package/cli/doctor.mjs +307 -0
  3. package/cli/index.mjs +328 -151
  4. package/cli/index.test.mjs +406 -9
  5. package/package.json +5 -6
  6. package/plugins/agent-os-core/.claude-plugin/plugin.json +18 -0
  7. package/plugins/agent-os-core/.codex-plugin/plugin.json +24 -0
  8. package/plugins/agent-os-core/skills/capture-intent/SKILL.md +65 -0
  9. package/plugins/agent-os-core/skills/capture-intent/references/intent-template.md +47 -0
  10. package/plugins/agent-os-core/skills/explain-work/SKILL.md +42 -0
  11. package/{skills → plugins/agent-os-core/skills}/list-skills/SKILL.md +13 -6
  12. package/{skills → plugins/agent-os-core/skills}/plain-voice/SKILL.md +7 -4
  13. package/plugins/agent-os-core/skills/plan-work/SKILL.md +133 -0
  14. package/plugins/agent-os-core/skills/plan-work/references/elicitation.md +32 -0
  15. package/plugins/agent-os-core/skills/plan-work/references/map.md +108 -0
  16. package/plugins/agent-os-core/skills/plan-work/references/spec-template.md +64 -0
  17. package/plugins/agent-os-core/skills/record-lesson/SKILL.md +47 -0
  18. package/plugins/agent-os-core/skills/scope-guard/SKILL.md +53 -0
  19. package/{skills → plugins/agent-os-core/skills}/verify-before-done/SKILL.md +6 -2
  20. package/plugins/agent-os-dev/.claude-plugin/plugin.json +18 -0
  21. package/plugins/agent-os-dev/.codex-plugin/plugin.json +24 -0
  22. package/plugins/agent-os-dev/hooks/hooks.json +42 -0
  23. package/{skills → plugins/agent-os-dev/skills}/batch-work/SKILL.md +9 -4
  24. package/{skills → plugins/agent-os-dev/skills}/batch-work/references/manifest.md +8 -0
  25. package/{skills → plugins/agent-os-dev/skills}/check-work/SKILL.md +31 -14
  26. package/{skills/deliver-work/workflow.md → plugins/agent-os-dev/skills/deliver-work/SKILL.md} +85 -17
  27. package/plugins/agent-os-dev/skills/design-work/SKILL.md +145 -0
  28. package/plugins/agent-os-dev/skills/design-work/scripts/render-sketch.mjs +233 -0
  29. package/plugins/agent-os-dev/skills/design-work/scripts/render-sketch.test.mjs +73 -0
  30. package/plugins/agent-os-dev/skills/diagnose-before-fix/SKILL.md +29 -0
  31. package/{skills → plugins/agent-os-dev/skills}/dispatch-next/SKILL.md +10 -4
  32. package/plugins/agent-os-dev/skills/init-agent-os/SKILL.md +121 -0
  33. package/plugins/agent-os-dev/skills/init-agent-os/policy.md +88 -0
  34. package/plugins/agent-os-dev/skills/init-agent-os/references/guards.md +39 -0
  35. package/{skills → plugins/agent-os-dev/skills}/init-agent-os/references/repository-init.md +41 -9
  36. package/plugins/agent-os-dev/skills/init-agent-os/references/review-template.md +35 -0
  37. package/plugins/agent-os-dev/skills/init-agent-os/scripts/policy-block.mjs +187 -0
  38. package/plugins/agent-os-dev/skills/init-agent-os/templates/agent-review.yml +59 -0
  39. package/plugins/agent-os-dev/skills/init-agent-os/templates/lint-intents.yml +30 -0
  40. package/{skills → plugins/agent-os-dev/skills}/proportional-testing/SKILL.md +1 -1
  41. package/plugins/agent-os-dev/skills/quality-ratchet/SKILL.md +103 -0
  42. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/references/project-controls.md +31 -3
  43. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/analyzers.mjs +145 -0
  44. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/analyzers.test.mjs +158 -0
  45. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/guards.mjs +372 -0
  46. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/guards.test.mjs +138 -0
  47. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/intent-files.mjs +322 -0
  48. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/intent-files.test.mjs +172 -0
  49. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/project-controls.mjs +59 -8
  50. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/project-controls.test.mjs +134 -8
  51. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/quality-delta.mjs +296 -22
  52. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/quality-delta.test.mjs +114 -6
  53. package/plugins/agent-os-dev/skills/shape-work/SKILL.md +124 -0
  54. package/plugins/agent-os-dev/skills/shape-work/references/implementation-issues.md +143 -0
  55. package/{skills/chart-work → plugins/agent-os-dev/skills/shape-work}/references/prototypes.md +11 -13
  56. package/plugins/agent-os-dev/skills/simplify/SKILL.md +91 -0
  57. package/plugins/agent-os-dev/skills/simplify/scripts/audit-evidence.mjs +166 -0
  58. package/plugins/agent-os-dev/skills/simplify/scripts/audit-evidence.test.mjs +49 -0
  59. package/policy.md +53 -20
  60. package/hooks/hooks.json +0 -17
  61. package/skills/chart-work/SKILL.md +0 -42
  62. package/skills/chart-work/references/elicitation.md +0 -25
  63. package/skills/chart-work/references/map.md +0 -84
  64. package/skills/deliver-work/SKILL.md +0 -12
  65. package/skills/diagnose-before-fix/SKILL.md +0 -24
  66. package/skills/explain-work/SKILL.md +0 -27
  67. package/skills/guide-me/SKILL.md +0 -36
  68. package/skills/init-agent-os/SKILL.md +0 -54
  69. package/skills/init-agent-os/scripts/policy-block.ps1 +0 -87
  70. package/skills/notice-lesson/SKILL.md +0 -20
  71. package/skills/quality-ratchet/SKILL.md +0 -72
  72. package/skills/record-lesson/SKILL.md +0 -31
  73. package/skills/scope-guard/SKILL.md +0 -32
  74. package/skills/shape-work/SKILL.md +0 -48
  75. package/skills/shape-work/references/implementation-issues.md +0 -69
  76. package/skills/shape-work/references/mockups.md +0 -23
  77. package/skills/simplifier/SKILL.md +0 -35
  78. package/skills/simplifier/agents/openai.yaml +0 -2
  79. package/skills/simplifier-audit/SKILL.md +0 -30
  80. package/skills/simplifier-review/SKILL.md +0 -40
  81. package/skills/understand-work/SKILL.md +0 -31
  82. package/skills/understand-work/agents/openai.yaml +0 -2
  83. package/skills/writing-skills/SKILL.md +0 -68
  84. package/skills/writing-skills/agents/openai.yaml +0 -2
  85. /package/{skills/batch-work → plugins/agent-os-core/skills/capture-intent}/agents/openai.yaml +0 -0
  86. /package/{skills/chart-work → plugins/agent-os-core/skills/explain-work}/agents/openai.yaml +0 -0
  87. /package/{skills/deliver-work → plugins/agent-os-core/skills/list-skills}/agents/openai.yaml +0 -0
  88. /package/{skills → plugins/agent-os-core/skills}/plain-voice/references/tells.md +0 -0
  89. /package/{skills/dispatch-next → plugins/agent-os-core/skills/plan-work}/agents/openai.yaml +0 -0
  90. /package/{skills/explain-work → plugins/agent-os-dev/skills/batch-work}/agents/openai.yaml +0 -0
  91. /package/{skills → plugins/agent-os-dev/skills}/batch-work/scripts/manifest-hash.mjs +0 -0
  92. /package/{skills → plugins/agent-os-dev/skills}/batch-work/scripts/test-manifest-hash.mjs +0 -0
  93. /package/{skills → plugins/agent-os-dev/skills}/check-work/references/findings.md +0 -0
  94. /package/{skills/guide-me → plugins/agent-os-dev/skills/deliver-work}/agents/openai.yaml +0 -0
  95. /package/{skills/init-agent-os → plugins/agent-os-dev/skills/design-work}/agents/openai.yaml +0 -0
  96. /package/{skills/list-skills → plugins/agent-os-dev/skills/dispatch-next}/agents/openai.yaml +0 -0
  97. /package/{skills/record-lesson → plugins/agent-os-dev/skills/init-agent-os}/agents/openai.yaml +0 -0
  98. /package/{skills → plugins/agent-os-dev/skills}/proportional-testing/references/strategy.md +0 -0
  99. /package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/references/structure.md +0 -0
  100. /package/{skills → plugins/agent-os-dev/skills}/shape-work/agents/openai.yaml +0 -0
  101. /package/{skills/simplifier-audit → plugins/agent-os-dev/skills/simplify}/agents/openai.yaml +0 -0
@@ -9,7 +9,9 @@ import {
9
9
  begin,
10
10
  check,
11
11
  clear,
12
- hook
12
+ finish,
13
+ hook,
14
+ STALE_STATE_DAYS
13
15
  } from './quality-delta.mjs'
14
16
 
15
17
  const temporaryRoots = []
@@ -120,6 +122,8 @@ test('reports the first committed source delta from an unborn baseline', () => {
120
122
  assert.deepEqual(evidence.sourceFiles.changed, [])
121
123
  assert.deepEqual(evidence.sourceFiles.deleted, [])
122
124
  assert.deepEqual(hook(root, { stop_hook_active: false }), {})
125
+ assert.equal(fs.existsSync(started.statePath), true)
126
+ assert.equal(finish(root, { detect: unavailableAnalyzers }).closed, true)
123
127
  assert.equal(fs.existsSync(started.statePath), false)
124
128
  })
125
129
 
@@ -255,15 +259,15 @@ test('rejects corrupted entry heads before Stop inspection', () => {
255
259
  }
256
260
  })
257
261
 
258
- test('Stop hook remains fail-closed until a fresh check, then clears state', () => {
262
+ test('Stop hook blocks until a fresh check and keeps the baseline until finish', () => {
259
263
  const root = repository()
260
264
  const started = begin(root, { detect: unavailableAnalyzers })
261
265
  const blocked = hook(root, { stop_hook_active: false })
262
266
  assert.equal(blocked.decision, 'block')
263
- assert.match(blocked.reason, /no check/)
267
+ assert.match(blocked.reason, /has not run/)
264
268
  const reentered = hook(root, { stop_hook_active: true })
265
269
  assert.equal(reentered.decision, 'block')
266
- assert.match(reentered.reason, /no check/)
270
+ assert.match(reentered.reason, /has not run/)
267
271
  assert.equal(fs.existsSync(started.statePath), true)
268
272
 
269
273
  check(root, { detect: unavailableAnalyzers })
@@ -274,10 +278,66 @@ test('Stop hook remains fail-closed until a fresh check, then clears state', ()
274
278
 
275
279
  check(root, { detect: unavailableAnalyzers })
276
280
  assert.deepEqual(hook(root, { stop_hook_active: true }), {})
281
+ assert.equal(fs.existsSync(started.statePath), true)
282
+ assert.deepEqual(hook(root, { stop_hook_active: false }), {})
283
+
284
+ const finished = finish(root, { detect: unavailableAnalyzers })
285
+ assert.equal(finished.closed, true)
286
+ assert.deepEqual(finished.evidence.sourceFiles.added, ['src/new.js'])
277
287
  assert.equal(fs.existsSync(started.statePath), false)
278
288
  assert.deepEqual(hook(root, { stop_hook_active: false }), {})
279
289
  })
280
290
 
291
+ test('a turn that ends mid-delivery keeps comparing against the exact entry state', () => {
292
+ const root = repository()
293
+ begin(root, { detect: unavailableAnalyzers })
294
+ fs.writeFileSync(path.join(root, 'src', 'legacy.js'), 'export function legacy() {\n return 2\n}\n')
295
+ assert.equal(hook(root, { stop_hook_active: false }).decision, 'block')
296
+ check(root, { detect: unavailableAnalyzers })
297
+ assert.deepEqual(hook(root, { stop_hook_active: true }), {})
298
+
299
+ fs.writeFileSync(path.join(root, 'src', 'added.js'), 'export const added = true\n')
300
+ const resumed = check(root, { detect: unavailableAnalyzers })
301
+ assert.deepEqual(resumed.sourceFiles.changed, ['src/legacy.js'])
302
+ assert.deepEqual(resumed.sourceFiles.added, ['src/added.js'])
303
+ })
304
+
305
+ test('a check that never becomes fresh releases Stop after the bounded limit', () => {
306
+ const root = repository()
307
+ const started = begin(root, { detect: unavailableAnalyzers })
308
+ assert.equal(hook(root, { stop_hook_active: false }).decision, 'block')
309
+ assert.equal(hook(root, { stop_hook_active: true }).decision, 'block')
310
+ assert.equal(hook(root, { stop_hook_active: true }).decision, 'block')
311
+ const released = hook(root, { stop_hook_active: true })
312
+ assert.equal(released.decision, undefined)
313
+ assert.match(released.systemMessage, /has not run for this candidate/)
314
+ assert.match(released.systemMessage, /delivery stays blocked/)
315
+ assert.equal(hook(root, { stop_hook_active: false }).decision, undefined)
316
+ assert.equal(fs.existsSync(started.statePath), true)
317
+
318
+ fs.writeFileSync(path.join(root, 'src', 'new.js'), 'export const later = true\n')
319
+ assert.equal(hook(root, { stop_hook_active: false }).decision, 'block')
320
+ })
321
+
322
+ test('begin prunes state from other sessions that has been idle past the retention limit', () => {
323
+ const root = repository()
324
+ const gitDir = path.join(root, '.git')
325
+ const old = path.join(gitDir, '.agent-os-quality-ratchet.json.claude-' + 'a'.repeat(32))
326
+ const oldReport = old + '.report.json'
327
+ const recent = path.join(gitDir, '.agent-os-quality-ratchet.json.codex-' + 'b'.repeat(32))
328
+ const unrelated = path.join(gitDir, 'unrelated-old-file')
329
+ for (const file of [old, oldReport, recent, unrelated]) fs.writeFileSync(file, '{}\n')
330
+ const past = new Date(Date.now() - (STALE_STATE_DAYS + 1) * 24 * 60 * 60 * 1000)
331
+ for (const file of [old, oldReport, unrelated]) fs.utimesSync(file, past, past)
332
+
333
+ const started = begin(root, { detect: unavailableAnalyzers })
334
+ assert.equal(fs.existsSync(old), false)
335
+ assert.equal(fs.existsSync(oldReport), false)
336
+ assert.equal(fs.existsSync(recent), true)
337
+ assert.equal(fs.existsSync(unrelated), true)
338
+ assert.equal(fs.existsSync(started.statePath), true)
339
+ })
340
+
281
341
  test('Stop hook resolves current Codex and Claude payload session identities', () => {
282
342
  const scenarios = [
283
343
  {
@@ -297,7 +357,7 @@ test('Stop hook resolves current Codex and Claude payload session identities', (
297
357
  const started = begin(root, { detect: unavailableAnalyzers, env: scenario.env })
298
358
  const first = hook(root, { ...scenario.payload, stop_hook_active: false }, { env: {} })
299
359
  assert.equal(first.decision, 'block', scenario.name)
300
- assert.match(first.reason, /no check/, scenario.name)
360
+ assert.match(first.reason, /has not run/, scenario.name)
301
361
  const reentered = hook(root, { ...scenario.payload, stop_hook_active: true }, { env: {} })
302
362
  assert.equal(reentered.decision, 'block', scenario.name)
303
363
  assert.equal(fs.existsSync(started.statePath), true, scenario.name)
@@ -308,6 +368,8 @@ test('Stop hook resolves current Codex and Claude payload session identities', (
308
368
  {},
309
369
  scenario.name
310
370
  )
371
+ assert.equal(fs.existsSync(started.statePath), true, scenario.name)
372
+ clear(root, { env: scenario.env })
311
373
  assert.equal(fs.existsSync(started.statePath), false, scenario.name)
312
374
  }
313
375
  })
@@ -335,6 +397,8 @@ test('Codex takes precedence when both host environment IDs are present', () =>
335
397
 
336
398
  check(root, { detect: unavailableAnalyzers, env })
337
399
  assert.deepEqual(hook(root, { ...payload, stop_hook_active: false }, { env: {} }), {})
400
+ assert.equal(fs.existsSync(started.statePath), true)
401
+ assert.equal(finish(root, { detect: unavailableAnalyzers, env }).closed, true)
338
402
  assert.equal(fs.existsSync(started.statePath), false)
339
403
  })
340
404
 
@@ -370,6 +434,7 @@ test('state files are isolated between host sessions in the same worktree', () =
370
434
 
371
435
  check(root, { detect: unavailableAnalyzers, env: claudeSession })
372
436
  assert.deepEqual(hook(root, { stop_hook_active: false }, { env: claudeSession }), {})
437
+ assert.equal(finish(root, { detect: unavailableAnalyzers, env: claudeSession }).closed, true)
373
438
  assert.equal(fs.existsSync(first.statePath), false)
374
439
  assert.equal(fs.existsSync(second.statePath), true)
375
440
 
@@ -432,7 +497,7 @@ test('Stop hook does not read unchanged tracked files', () => {
432
497
  }
433
498
  })
434
499
 
435
- test('Stop accepts and clears a fresh check after a committed source change', () => {
500
+ test('Stop accepts a fresh check after a committed source change and finish closes it', () => {
436
501
  const root = repository()
437
502
  const started = begin(root, { detect: unavailableAnalyzers })
438
503
  fs.writeFileSync(path.join(root, 'src', 'legacy.js'), 'export function legacy() {\n return 2\n}\n')
@@ -442,6 +507,8 @@ test('Stop accepts and clears a fresh check after a committed source change', ()
442
507
  const evidence = check(root, { detect: unavailableAnalyzers })
443
508
  assert.deepEqual(evidence.sourceFiles.changed, ['src/legacy.js'])
444
509
  assert.deepEqual(hook(root, { stop_hook_active: false }), {})
510
+ assert.equal(fs.existsSync(started.statePath), true)
511
+ assert.equal(finish(root, { detect: unavailableAnalyzers }).closed, true)
445
512
  assert.equal(fs.existsSync(started.statePath), false)
446
513
  })
447
514
 
@@ -456,6 +523,8 @@ test('reports both sides of a committed source rename after begin', () => {
456
523
  assert.deepEqual(evidence.sourceFiles.changed, [])
457
524
  assert.deepEqual(evidence.sourceFiles.deleted, ['src/legacy.js'])
458
525
  assert.deepEqual(hook(root, { stop_hook_active: false }), {})
526
+ assert.equal(fs.existsSync(started.statePath), true)
527
+ assert.equal(finish(root, { detect: unavailableAnalyzers }).closed, true)
459
528
  assert.equal(fs.existsSync(started.statePath), false)
460
529
  })
461
530
 
@@ -512,3 +581,42 @@ test('Codex Stop contract accepts structured exit 0 and uses stderr on exit 2',
512
581
  })
513
582
  assert.throws(() => parseCodexStopResult({ ...exitTwo, stderr: '' }), /Codex rejected/)
514
583
  })
584
+
585
+ test('an uninspectable candidate is bounded and its release resets once inspection works', () => {
586
+ const root = repository()
587
+ begin(root, { detect: unavailableAnalyzers })
588
+ const index = path.join(root, '.git', 'index')
589
+ const saved = fs.readFileSync(index)
590
+ fs.writeFileSync(index, 'not an index')
591
+
592
+ assert.match(hook(root, { stop_hook_active: false }).reason, /could not inspect the candidate/)
593
+ assert.equal(hook(root, { stop_hook_active: true }).decision, 'block')
594
+ assert.equal(hook(root, { stop_hook_active: true }).decision, 'block')
595
+ assert.match(hook(root, { stop_hook_active: true }).systemMessage, /still cannot inspect/)
596
+
597
+ fs.writeFileSync(index, saved)
598
+ assert.match(hook(root, { stop_hook_active: false }).reason, /has not run/)
599
+ fs.writeFileSync(index, 'broken again')
600
+ assert.equal(hook(root, { stop_hook_active: false }).decision, 'block')
601
+ fs.writeFileSync(index, saved)
602
+ })
603
+
604
+ test('finish command reports JSON, accepts a policy reason, and exits 1 when the baseline stays', () => {
605
+ const runner = path.join(path.dirname(fileURLToPath(import.meta.url)), 'quality-delta.mjs')
606
+ const root = repository()
607
+ const env = { ...process.env, CLAUDE_CODE_SESSION_ID: 'finish-cli', CODEX_THREAD_ID: '' }
608
+ const run = (...args) => spawnSync(process.execPath, [runner, ...args, '--root', root], { encoding: 'utf8', env })
609
+
610
+ assert.equal(run('begin').status, 0)
611
+ const closed = run('finish', '--json')
612
+ assert.equal(closed.status, 0)
613
+ const result = JSON.parse(closed.stdout)
614
+ assert.equal(result.closed, true)
615
+ assert.equal(result.evidence.status, 'ok')
616
+ assert.equal(fs.existsSync(result.statePath), false)
617
+
618
+ assert.equal(run('finish').status, 1)
619
+ assert.equal(run('begin', '--accept-policy-change', 'reason').status, 2)
620
+ assert.equal(run('begin').status, 0)
621
+ assert.equal(run('finish', '--accept-policy-change', 'authorized reason').status, 0)
622
+ })
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: shape-work
3
+ description: Shapes a bounded mission or accepted spec into coherent delivery units with dependencies, written as plan.md beside the spec or as implementation-ready tracker issues, backed by settled product decisions. User-invoked when delivery structure or an epic contract still needs shaping. Not for small fixes or work whose outcome and delivery unit are already clear.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Shape work
8
+
9
+ Produce the smallest coherent delivery structure that lets delivery proceed without inventing
10
+ product intent. A delivery unit is the smallest independently useful or assessable result that has
11
+ its own meaningful boundary; technical layers are not delivery units by themselves.
12
+
13
+ Read [references/implementation-issues.md](references/implementation-issues.md) before shaping. It
14
+ defines `plan.md`, the unit line format, and the tracker alternative.
15
+
16
+ ## Unit contract
17
+
18
+ A unit is a self-contained work order, not a design document: someone holding only the unit and the
19
+ repository knows what to change, where, what done means, and how to prove it, and nothing more. The
20
+ spec stays the authority. A unit writes out what it is accountable for and cites its source, and
21
+ when the two disagree the spec wins. `built_on` already marks restated text stale when the spec
22
+ changes.
23
+
24
+ Every unit carries these fields, in its `plan.md` section or its tracker issue. Write `none` only
25
+ where that is the true answer:
26
+
27
+ - **Outcome:** the observable change once this unit is delivered, for a person or a caller, in a
28
+ sentence or two.
29
+ - **Boundaries:** the non-goals a worker would plausibly cross, and what neighboring units own
30
+ instead.
31
+ - **Change surface:** the modules, interfaces, and existing code to extend, found by reading the
32
+ repository, in a few lines. It names seams and does not list steps or every file.
33
+ - **Acceptance:** the checks that decide done, written out in the unit as given, when, then or as
34
+ assertions, one line each, each citing its spec example. Cover the behaviors this unit owns, not
35
+ every variation. A spec example shared between units states exactly this unit's part. A bare
36
+ pointer such as "behaviors 1 to 3" is not acceptance.
37
+ - **Ground truth:** the commands to run and the named cases or observations they must show.
38
+ - **Dependencies:** for each dependency, what this unit consumes from it, in a line.
39
+ - **Evidence and settled decisions:** only the decisions a worker could otherwise get wrong, one
40
+ line each with its link. Do not retell the spec's decisions.
41
+ - **Delivery target:** pull request, commit, or local change.
42
+ - **Open risks:** at most three risks that could change this unit's approach, each with what to do.
43
+ Routine engineering concerns are not risks.
44
+
45
+ Match depth to the unit: a one-line change gets one-line fields, and a typical unit fits in about
46
+ 4,000 characters. A longer unit is too broad or is retelling the spec or the architecture: cut it,
47
+ or split it for one of the concrete reasons below. Do not write code or implementation steps;
48
+ choices the implementer can reverse stay with the implementer.
49
+
50
+ Before publishing, read each unit as a worker who has only it and the repository. Whatever they
51
+ would have to guess, or look up in the spec to know what done means, is missing from the unit.
52
+ Whatever would not change what they build or check comes out.
53
+
54
+ ## Loop
55
+
56
+ Read the repository, project policy, the intent and spec when they exist, and any linked `plan-work`
57
+ decisions or handoffs before asking questions. Resolve facts from those sources. For each remaining
58
+ material choice, recommend an answer, explain the consequence, and ask only what the developer must
59
+ decide. A pre-existing specification is a valid starting point; a plan-work run is not required.
60
+
61
+ A spec whose `built_on` revision is older than its intent is stale. Do not shape from it: return it
62
+ to `plan-work` for reconsideration and report which revision changed.
63
+
64
+ Shape-work does not settle the interface; the spec's `## Interface` section does. Link it from the
65
+ units that build those screens instead of restating it. When that section lists a decision as
66
+ open, is missing while the work changes what a person sees or does, or a unit would change a screen
67
+ the section does not cover, return that interface question to `design-work` and keep the affected
68
+ units blocked until it is settled. Units the open question does not touch can still be shaped. Use
69
+ a diagram when it makes dependencies or boundaries materially easier to judge.
70
+
71
+ When a solution-changing technical assumption needs observation, apply the
72
+ [experiment decision](references/prototypes.md). Do not turn a question with sufficient evidence
73
+ into a prototype.
74
+
75
+ Deliver the coherent product shape: outcome, boundaries, acceptance examples, affected seams,
76
+ ground truth, settled decisions, and open risks. Then write the delivery units to the unit
77
+ contract: `intents/<id>/plan.md` by default, or
78
+ create or reuse its implementation issues on the tracker when the project policy makes the tracker the source
79
+ of truth for units. Link real dependencies and report the first claimable delivery frontier to the
80
+ developer; it is derived from the plan and is not written into it.
81
+
82
+ Start from one coherent delivery unit. Split only for a concrete reason such as an independently
83
+ usable or assessable result, different ownership, a separate migration, a delivery boundary, or a
84
+ material risk and verification boundary. A separate commit, session, file, or technical layer is
85
+ not enough. Keep necessary schema, API, UI, configuration, error handling, and verification with
86
+ the behavior they support.
87
+
88
+ The result may be one unit, several independent units, or several units with an epic contract when
89
+ one shared end result needs an owner. Before publishing, check that the whole mission is covered,
90
+ each unit contributes, dependencies are real, and the complete set can be verified.
91
+
92
+ One shape may produce one or several sequential or parallel units. Multiple issues do not imply
93
+ `batch-work`: each ready unit can be delivered with `deliver-work`, while `batch-work` remains an
94
+ explicit developer choice for integrated parallel execution. Do not start either workflow unless
95
+ the request includes implementation.
96
+
97
+ When shaping started from a plan-work handoff, reconcile the issue links and readiness back into the
98
+ origin handoff and map. A handoff alone is not delivery-ready. Shape-work is complete only when
99
+ every selected branch points to implementation-ready units or is explicitly parked or rejected.
100
+
101
+ An epic has an explicit contract in [implementation issues](references/implementation-issues.md):
102
+ shared outcome and acceptance, children or delivery units, aggregate verification, and an owner
103
+ for final verification. A child issue does not authorize the rest of the epic or permit closing its
104
+ parent. `deliver-work` performs aggregate verification when the request covers the epic;
105
+ `batch-work` uses the same contract for an explicitly selected integrated run.
106
+
107
+ A plan built on an older spec revision is stale. Reshape it from the current spec, increase its
108
+ `rev`, and keep unit keys stable so delivered work and open pull requests still point at the right
109
+ unit.
110
+
111
+ Planning-surface writes do not grant product implementation or external tracker authority. Commit
112
+ `plan.md` and open its review only when the request or the project's delivery defaults include
113
+ that. Creating tracker issues needs the project policy's `## Tracker mandate`; keep it within the
114
+ requested set and do not silently change acceptance, ownership, delivery scope, or closure. A ready
115
+ unit is not an authorization. Without that mandate, keep corrections local and report the pending
116
+ tracker delta.
117
+
118
+ Recommend one concrete next action with its reason and blocker, weighing uncertainty and downstream
119
+ work unlocked as well as project priority. A ready frontier alone is not enough guidance. Continue
120
+ into authorized sequential delivery only when the request includes that bounded implementation;
121
+ otherwise finish with the recommendation.
122
+
123
+ The invocation authorizes planning artifacts, not product code. A deferred product choice remains
124
+ explicit; a reversible implementation choice does not need to become a question.
@@ -0,0 +1,143 @@
1
+ # Implementation issues
2
+
3
+ Shaping writes delivery units where the next person and agent will find them. Research, grilling,
4
+ and prototypes are decision evidence; the durable output of shaping is the unit set that a developer
5
+ can choose to run with `deliver-work` or `batch-work`.
6
+
7
+ ## Where units live
8
+
9
+ - **`source: files` (default).** `intents/<id>/plan.md` beside the spec lists every unit and holds
10
+ each unit's contract.
11
+ - **`source: issues`.** When the project policy makes a tracker the source of truth for units,
12
+ `plan.md` lists the units by tracker key and the tracker issues hold each unit's contract. The
13
+ plan then contains links, never copies.
14
+
15
+ With no intent folder, write a minimal `intent.md` with the settled outcome first, following
16
+ `capture-intent`'s template, so the plan has a place and a revision to build on.
17
+
18
+ When a plan-work run supplied a plain-language summary for an actual decision, it is the spec's
19
+ `## Summary`. Do not turn summary approval into a second gate or copy the plan into a competing
20
+ specification.
21
+
22
+ ## Completion invariant
23
+
24
+ A selected product branch is not `delivery-ready`, and shape-work is not complete, until one or
25
+ more implementation units have been written or reused. A parked or rejected branch needs no unit.
26
+
27
+ Each unit represents one coherent delivery unit: an independently useful or assessable result with
28
+ a reviewable change boundary and ground truth that can verify it. The unit may depend on earlier
29
+ units, but technical layers that support the same behavior stay together. Split only for a concrete
30
+ delivery, ownership, migration, risk, or verification boundary; separate commits, sessions, files,
31
+ or technical layers are not sufficient reasons.
32
+
33
+ ## plan.md
34
+
35
+ ```markdown
36
+ ---
37
+ intent: <YYYY-MM>-<slug>
38
+ rev: 1
39
+ built_on: spec@1
40
+ status: accepted
41
+ source: files
42
+ ---
43
+
44
+ # Plan: <the outcome in one line>
45
+
46
+ ## Units
47
+
48
+ - [U1] <title>
49
+ - [U2] <title> — depends on U1
50
+ - [U3] <title> — depends on U1 — blocked: <the open decision>
51
+
52
+ ### U1 <title>
53
+
54
+ Outcome:
55
+ Boundaries:
56
+ Change surface:
57
+ Acceptance:
58
+ Ground truth:
59
+ Dependencies:
60
+ Evidence and settled decisions:
61
+ Delivery target:
62
+ Open risks:
63
+ ```
64
+
65
+ What each field must hold is the unit contract in `SKILL.md`. A field value may run over several
66
+ lines, and Acceptance is usually a list.
67
+
68
+ Rules:
69
+
70
+ - Identity is `(origin, unit key)`, where the origin is the intent id. Unit keys never change once
71
+ written, so pull requests and history keep pointing at the right unit. Search the plan and the
72
+ tracker before creating anything so retrying the same shape updates units instead of duplicating
73
+ them.
74
+ - Each line under `## Units` is `- [<KEY>] <title>`, optionally followed by ` — depends on <KEY>,
75
+ <KEY>` and ` — blocked: <reason>`. With `source: issues` the key is the tracker key and the
76
+ `###` sections are omitted.
77
+ - `status` is `accepted`, `done`, or `superseded`. Delivery status is never written into the plan.
78
+ A unit is claimed by a draft pull request whose body carries `Intent-Unit: <intent-id>/<unit-key>`,
79
+ and it is delivered when that pull request merges.
80
+ - `built_on` names the spec revision. A plan built on an older spec revision is stale.
81
+
82
+ With `source: issues`, each tracker issue carries the same fields as headings:
83
+
84
+ ```text
85
+ ## Implementation issue
86
+ Origin: <intent id and plan link>
87
+ Unit key: <stable key>
88
+ Status: ready | blocked
89
+
90
+ ## Outcome
91
+ ## Boundaries
92
+ ## Change surface
93
+ ## Acceptance
94
+ ## Ground truth
95
+ ## Dependencies
96
+ ## Evidence and settled decisions
97
+ ## Delivery target
98
+ ## Open risks
99
+ ```
100
+
101
+ Use dependencies to distinguish order from execution strategy. A unit is ready when its product
102
+ decisions are settled and its dependencies are delivered; otherwise record the exact blocker on its
103
+ line. The delivery frontier is the set of ready, unblocked units without an open pull request. Use
104
+ the tracker's existing status and label conventions rather than inventing a parallel queue
105
+ vocabulary.
106
+
107
+ ## Epic contract
108
+
109
+ When one shared end result needs an owner, add an epic contract to the plan instead of splitting
110
+ every technical layer into a child:
111
+
112
+ ```text
113
+ ## Epic contract
114
+ Epic outcome: <shared observable result>
115
+ Acceptance: <aggregate acceptance examples, usually the spec's Behavior section>
116
+ Children or delivery units: <unit keys and why each boundary exists>
117
+ Aggregate verification: <checks for the complete result>
118
+ Final verification owner: <person or delivery role>
119
+ ```
120
+
121
+ The contract belongs to shape-work and is consumed by delivery. A child issue contributes to the
122
+ epic but does not authorize its siblings, change its acceptance, or close the parent. Green child
123
+ checks are not aggregate verification. `deliver-work` owns the whole-result check when the request
124
+ covers the epic, and `batch-work` reuses this same contract for an explicitly selected batch.
125
+
126
+ ## Routing belongs to the developer
127
+
128
+ Expose the frontier without choosing an execution workflow:
129
+
130
+ - `deliver-work` can deliver any one ready unit, including units from a larger sequential graph;
131
+ - `batch-work` consumes an existing dependency-mapped unit set only when the developer explicitly
132
+ requests integrated parallel execution;
133
+ - the existence of several issues never invokes or recommends batch-work by itself.
134
+
135
+ Writing units is a planning write, not implementation authority. Do not edit product code, start a
136
+ batch, merge, deploy, or perform external delivery effects under a planning-only shape-work invocation.
137
+
138
+ ## Plan-work reconciliation
139
+
140
+ When the origin is a plan-work handoff, update the handoff and map idempotently after materializing
141
+ the units. Link every unit, record the ready or blocked frontier, and move the
142
+ branch from shaping to `delivery-ready` only when the completion invariant holds. Preserve concurrent map entries and
143
+ keep decision tickets canonical for their evidence.
@@ -6,22 +6,21 @@ A prototype exists to settle a decision, not to become an accidental product imp
6
6
 
7
7
  Propose a prototype when an unresolved assumption could change the solution and executing the
8
8
  smallest experiment is cheaper or more decisive than further reading or discussion. Examples are
9
- uncertain transaction behavior, integration limits, a performance hypothesis, or competing UI
10
- interactions the developer needs to try. Existing evidence that already settles the question, a
11
- routine implementation, or a preference answerable directly needs no prototype. This is a decision
12
- rule, not a required phase for every task.
9
+ uncertain transaction behavior, integration limits, or a performance hypothesis. Existing evidence
10
+ that already settles the question, a routine implementation, or a preference answerable directly
11
+ needs no prototype. Competing screens or interactions are interface questions: sketch them with
12
+ [design-work](../../design-work/SKILL.md) instead.
13
13
 
14
14
  Within an authorized planning or implementation task, run a small isolated local experiment when
15
- it can answer that question without new external effects or product changes. For UI choices, build
16
- comparable alternatives and ask the developer to judge them. Announce the question, smallest
17
- artifact, observation that would settle it, and a bounded effort budget before starting; no separate
18
- approval is needed inside existing authority. Ask before crossing that authority, not merely
19
- because the artifact is called a prototype.
15
+ it can answer that question without new external effects or product changes. Announce the
16
+ question, smallest artifact, observation that would settle it, and a bounded effort budget before
17
+ starting; no separate approval is needed inside existing authority. Ask before crossing that
18
+ authority, not merely because the artifact is called a prototype.
20
19
 
21
20
  Stop when the evidence is sufficient or the budget is exhausted. Inconclusive evidence leaves the
22
21
  decision open; report the remaining uncertainty and recommend the next action instead of silently
23
- growing the experiment. Keep experimental code isolated from production paths. Retain useful
24
- evidence; promoting code to production requires the normal implementation and review contract.
22
+ growing the experiment. Keep experimental code isolated from production paths. Retaining useful
23
+ evidence does not promote code to production; normal implementation and review still apply.
25
24
 
26
25
  ## Capture the result
27
26
 
@@ -40,5 +39,4 @@ Record:
40
39
  - Open uncertainty:
41
40
  ```
42
41
 
43
- Keep the artifact inspectable while the decision depends on it. Frontend prototypes also follow the
44
- shared [mockup guidance](../../shape-work/references/mockups.md).
42
+ Keep the artifact inspectable while the decision depends on it.
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: simplify
3
+ description: Finds or removes unnecessary code, abstractions, dependencies, and solution layers while preserving required behavior, in one of three modes, review a diff, audit a repository, or apply. check-work and deliver-work use its review mode as their simplification lens. Use manually when the developer asks to simplify, review a diff for over-engineering, audit a repository for deletion candidates, or find a more direct solution. Not for code golf, speculative rewrites, initial feature design, changing product behavior, or a general correctness, security, or performance audit.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Simplify
8
+
9
+ Make the solution smaller in concepts and code without making it harder to understand.
10
+
11
+ ## Choose the mode
12
+
13
+ - **`simplify review`** reads the current diff and reports findings without changing files. This is
14
+ the lens `check-work` and `deliver-work` apply.
15
+ - **`simplify audit`** reads the whole repository and reports its strongest opportunities without
16
+ changing files.
17
+ - **`simplify apply`** edits an existing implementation or diff. An explicit request to simplify,
18
+ reduce code, or remove over-engineering in named code is apply mode.
19
+
20
+ When the request does not say whether files may change, use review mode for a diff and audit mode
21
+ for a repository, and report findings first.
22
+
23
+ ## What counts as unnecessary
24
+
25
+ Look for:
26
+
27
+ - code, branches, configuration, options, files, or dependencies with no current requirement;
28
+ - duplicated behavior already provided by the project;
29
+ - custom machinery covered by the standard library, native platform behavior, or an installed
30
+ dependency;
31
+ - wrappers, layers, factories, and abstractions without a current responsibility or requirement;
32
+ - indirect or dense code that has a more direct, readable form.
33
+
34
+ Preserve required behavior, public contracts, validation at trust boundaries, security,
35
+ accessibility, error handling that prevents data loss, justified performance characteristics, and
36
+ tests that protect real behavior. Preserve a cohesive named responsibility even with one caller.
37
+ Do not recommend code golf: a clear loop can be simpler than a clever one-liner, and fewer lines is
38
+ a result of a simpler solution, never the goal.
39
+
40
+ ## Review mode
41
+
42
+ Read the request, diff, affected code, project conventions, and relevant checks. Apply the
43
+ [finding calibration](../check-work/references/findings.md): require a concrete benefit from a
44
+ replacement, and do not turn a reasonable alternative into a required correction.
45
+
46
+ When [`quality-ratchet`](../quality-ratchet/SKILL.md) evidence is available, consume it before
47
+ forming findings. Read the diff and implementation yourself: added, changed, and deleted files,
48
+ NLOC, legacy before and after, dependency deltas, complexity deltas, and unavailable optional
49
+ analyzers are evidence, not an oracle or threshold. Start with the functions whose complexity rose
50
+ most, and judge whether the added paths are required behavior. Report at most one materially
51
+ constraining adjacent opportunity and leave unrelated debt to `scope-guard`.
52
+
53
+ For each supported finding, name the location, the unnecessary complexity, and the simpler
54
+ replacement. Rank material deletions and dependency removals first. Do not invent a line-savings
55
+ total. If there is nothing worth changing, report `No simplification findings.` This review
56
+ complements correctness, security, and scope review and never replaces them.
57
+
58
+ ## Audit mode
59
+
60
+ Start with deterministic evidence. Resolve `scripts/audit-evidence.mjs` relative to this loaded
61
+ `SKILL.md` and run it with Node from the repository root. It ranks the most complex functions
62
+ (lizard), duplicated blocks (jscpd), and unused code (knip for JavaScript and TypeScript, vulture
63
+ for Python) when those tools are installed, and reports each missing tool as unavailable. Do not
64
+ install them. The output is a candidate list that tells you where to read, not a list of findings.
65
+
66
+ Inspect the project structure, dependencies, conventions, representative flows, and the usages of
67
+ each candidate before reporting it. Prefer a short ranked list of high-confidence findings over a
68
+ large speculative inventory. For each finding, name the location, the evidence that the complexity
69
+ is unnecessary, the simpler replacement, and any behavior or migration constraint that must be
70
+ preserved. If the repository is already simple, say so.
71
+
72
+ ## Apply mode
73
+
74
+ Read the request, affected code, project conventions, current diff, and relevant checks. Establish
75
+ the required behavior before editing. Then simplify in this order:
76
+
77
+ 1. Delete code, options, branches, configuration, and files that serve no current requirement.
78
+ 2. Reuse an existing project helper or pattern instead of maintaining a duplicate.
79
+ 3. Prefer the standard library, native platform behavior, or an already-installed dependency over
80
+ custom machinery.
81
+ 4. Collapse wrappers, layers, and abstractions that add indirection without a current
82
+ responsibility or requirement.
83
+ 5. Express the remaining behavior directly and readably.
84
+
85
+ Stay inside the requested surface. Do not turn a focused simplification into an architectural
86
+ rewrite or introduce a new dependency to save a few lines. Keep tests that protect behavior; remove
87
+ only tests for behavior that no longer exists or tests that duplicate the same signal without value.
88
+
89
+ After editing, inspect the final diff and run the smallest relevant checks. Report what was removed
90
+ or made more direct, the verification result, and any complexity that remains because it serves a
91
+ real requirement. If the implementation is already simple, leave it unchanged and say so.