@sockulags/agent-os 0.15.0 → 0.17.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 (99) hide show
  1. package/README.md +105 -59
  2. package/cli/doctor.mjs +351 -0
  3. package/cli/index.mjs +328 -151
  4. package/cli/index.test.mjs +436 -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 +68 -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 +16 -7
  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 +151 -0
  14. package/{skills → plugins/agent-os-core/skills}/plan-work/references/elicitation.md +7 -3
  15. package/plugins/agent-os-core/skills/plan-work/references/spec-template.md +65 -0
  16. package/plugins/agent-os-core/skills/record-lesson/SKILL.md +47 -0
  17. package/{skills → plugins/agent-os-core/skills}/scope-guard/SKILL.md +11 -6
  18. package/{skills → plugins/agent-os-core/skills}/verify-before-done/SKILL.md +6 -2
  19. package/plugins/agent-os-dev/.claude-plugin/plugin.json +18 -0
  20. package/plugins/agent-os-dev/.codex-plugin/plugin.json +24 -0
  21. package/plugins/agent-os-dev/hooks/hooks.json +42 -0
  22. package/{skills → plugins/agent-os-dev/skills}/batch-work/SKILL.md +6 -2
  23. package/{skills → plugins/agent-os-dev/skills}/check-work/SKILL.md +33 -14
  24. package/{skills/deliver-work/workflow.md → plugins/agent-os-dev/skills/deliver-work/SKILL.md} +126 -57
  25. package/plugins/agent-os-dev/skills/deliver-work/references/work-records.md +20 -0
  26. package/plugins/agent-os-dev/skills/design-work/SKILL.md +160 -0
  27. package/plugins/agent-os-dev/skills/design-work/scripts/render-sketch.mjs +233 -0
  28. package/plugins/agent-os-dev/skills/design-work/scripts/render-sketch.test.mjs +73 -0
  29. package/plugins/agent-os-dev/skills/diagnose-before-fix/SKILL.md +29 -0
  30. package/{skills → plugins/agent-os-dev/skills}/dispatch-next/SKILL.md +11 -3
  31. package/plugins/agent-os-dev/skills/init-agent-os/SKILL.md +131 -0
  32. package/plugins/agent-os-dev/skills/init-agent-os/policy.md +91 -0
  33. package/plugins/agent-os-dev/skills/init-agent-os/references/guards.md +40 -0
  34. package/plugins/agent-os-dev/skills/init-agent-os/references/repository-init.md +115 -0
  35. package/plugins/agent-os-dev/skills/init-agent-os/references/review-template.md +35 -0
  36. package/plugins/agent-os-dev/skills/init-agent-os/references/workflow-template.md +80 -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 +104 -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 +177 -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 +135 -0
  54. package/plugins/agent-os-dev/skills/shape-work/references/implementation-issues.md +163 -0
  55. package/{skills/plan-work → plugins/agent-os-dev/skills/shape-work}/references/prototypes.md +9 -10
  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 +57 -30
  60. package/hooks/hooks.json +0 -17
  61. package/skills/deliver-work/SKILL.md +0 -12
  62. package/skills/diagnose-before-fix/SKILL.md +0 -24
  63. package/skills/explain-work/SKILL.md +0 -28
  64. package/skills/init-agent-os/SKILL.md +0 -55
  65. package/skills/init-agent-os/references/repository-init.md +0 -75
  66. package/skills/init-agent-os/scripts/policy-block.ps1 +0 -87
  67. package/skills/notice-lesson/SKILL.md +0 -20
  68. package/skills/plan-work/SKILL.md +0 -100
  69. package/skills/quality-ratchet/SKILL.md +0 -72
  70. package/skills/record-lesson/SKILL.md +0 -31
  71. package/skills/shape-work/SKILL.md +0 -71
  72. package/skills/shape-work/references/implementation-issues.md +0 -90
  73. package/skills/shape-work/references/mockups.md +0 -23
  74. package/skills/simplifier/SKILL.md +0 -35
  75. package/skills/simplifier-audit/SKILL.md +0 -30
  76. package/skills/simplifier-review/SKILL.md +0 -40
  77. package/skills/understand-work/SKILL.md +0 -32
  78. package/skills/understand-work/agents/openai.yaml +0 -2
  79. package/skills/writing-skills/SKILL.md +0 -68
  80. package/skills/writing-skills/agents/openai.yaml +0 -2
  81. /package/{skills/batch-work → plugins/agent-os-core/skills/capture-intent}/agents/openai.yaml +0 -0
  82. /package/{skills/deliver-work → plugins/agent-os-core/skills/explain-work}/agents/openai.yaml +0 -0
  83. /package/{skills/dispatch-next → plugins/agent-os-core/skills/list-skills}/agents/openai.yaml +0 -0
  84. /package/{skills → plugins/agent-os-core/skills}/plain-voice/references/tells.md +0 -0
  85. /package/{skills/explain-work → plugins/agent-os-core/skills/plan-work}/agents/openai.yaml +0 -0
  86. /package/{skills → plugins/agent-os-core/skills}/plan-work/references/map.md +0 -0
  87. /package/{skills/init-agent-os → plugins/agent-os-dev/skills/batch-work}/agents/openai.yaml +0 -0
  88. /package/{skills → plugins/agent-os-dev/skills}/batch-work/references/manifest.md +0 -0
  89. /package/{skills → plugins/agent-os-dev/skills}/batch-work/scripts/manifest-hash.mjs +0 -0
  90. /package/{skills → plugins/agent-os-dev/skills}/batch-work/scripts/test-manifest-hash.mjs +0 -0
  91. /package/{skills → plugins/agent-os-dev/skills}/check-work/references/findings.md +0 -0
  92. /package/{skills/list-skills → plugins/agent-os-dev/skills/deliver-work}/agents/openai.yaml +0 -0
  93. /package/{skills/plan-work → plugins/agent-os-dev/skills/design-work}/agents/openai.yaml +0 -0
  94. /package/{skills/record-lesson → plugins/agent-os-dev/skills/dispatch-next}/agents/openai.yaml +0 -0
  95. /package/{skills/shape-work → plugins/agent-os-dev/skills/init-agent-os}/agents/openai.yaml +0 -0
  96. /package/{skills → plugins/agent-os-dev/skills}/proportional-testing/references/strategy.md +0 -0
  97. /package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/references/structure.md +0 -0
  98. /package/{skills/simplifier-audit → plugins/agent-os-dev/skills/shape-work}/agents/openai.yaml +0 -0
  99. /package/{skills/simplifier → 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,135 @@
1
+ ---
2
+ name: shape-work
3
+ description: Shapes a request, bounded mission, or accepted spec into coherent delivery units with dependencies, written as implementation-ready tracker issues, or as plan.md beside an initiative's spec, backed by settled product decisions. User-invoked when delivery structure or an epic contract still needs shaping. Not for work whose delivery unit is already shaped; a known fix that needs an issue gets one without an interview.
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 where units live, the issue format, and `plan.md` for an initiative.
15
+
16
+ Work without an intent is shaped into tracker issues only: the issue is the whole record, and no
17
+ intent, spec, or plan file is written. Only an initiative, work that already has an intent, gets a
18
+ `plan.md` beside its spec.
19
+
20
+ ## Unit contract
21
+
22
+ A unit is a self-contained work order, not a design document: someone holding only the unit and the
23
+ repository knows what to change, where, what done means, and how to prove it, and nothing more. The
24
+ spec stays the authority. A unit writes out what it is accountable for and cites its source, and
25
+ when the two disagree the spec wins. `built_on` already marks restated text stale when the spec
26
+ changes.
27
+
28
+ Every unit carries these fields, in its tracker issue or its `plan.md` section. Write `none` only
29
+ where that is the true answer:
30
+
31
+ - **Outcome:** the observable change once this unit is delivered, for a person or a caller, in a
32
+ sentence or two.
33
+ - **Boundaries:** the non-goals a worker would plausibly cross, and what neighboring units own
34
+ instead.
35
+ - **Change surface:** the modules, interfaces, and existing code to extend, found by reading the
36
+ repository, in a few lines. It names seams and does not list steps or every file.
37
+ - **Acceptance:** the checks that decide done, written out in the unit as given, when, then or as
38
+ assertions, one line each, each citing its spec example. Cover the behaviors this unit owns, not
39
+ every variation. A spec example shared between units states exactly this unit's part. A bare
40
+ pointer such as "behaviors 1 to 3" is not acceptance.
41
+ - **Ground truth:** the commands to run and the named cases or observations they must show.
42
+ - **Dependencies:** for each dependency, what this unit consumes from it, in a line.
43
+ - **Evidence and settled decisions:** only the decisions a worker could otherwise get wrong, one
44
+ line each with its link. Do not retell the spec's decisions.
45
+ - **Delivery target:** pull request, commit, or local change.
46
+ - **Open risks:** at most three risks that could change this unit's approach, each with what to do.
47
+ Routine engineering concerns are not risks.
48
+
49
+ Match depth to the unit: a known fix becomes one issue without questions, a one-line change gets one-line fields, and a typical unit fits in about
50
+ 4,000 characters. A longer unit is too broad or is retelling the spec or the architecture: cut it,
51
+ or split it for one of the concrete reasons below. Do not write code or implementation steps;
52
+ choices the implementer can reverse stay with the implementer.
53
+
54
+ Before publishing, read each unit as a worker who has only it and the repository. Whatever they
55
+ would have to guess, or look up in the spec to know what done means, is missing from the unit.
56
+ Whatever would not change what they build or check comes out.
57
+
58
+ ## Loop
59
+
60
+ Read the repository, project policy, the intent and spec when they exist, and any linked `plan-work`
61
+ decisions or handoffs before asking questions. Resolve facts from those sources. For each remaining
62
+ material choice, recommend an answer, explain the consequence, and ask only what the developer must
63
+ decide. A pre-existing specification is a valid starting point; a plan-work run is not required.
64
+
65
+ A spec whose `built_on` revision is older than its intent is stale. Do not shape from it: return it
66
+ to `plan-work` for reconsideration and report which revision changed.
67
+
68
+ Without a spec, a screen whose layout or flow is still open is a material product question: ask
69
+ it while shaping, recommend `design-work` in one line when sketching would help, and write the
70
+ answer into the unit. With a spec, the spec decides. Shape-work does not settle the interface; the
71
+ spec's `## Interface` section does. Link it from the units that build those screens instead of restating it. When that section lists a decision as
72
+ open, is missing while the work changes what a person sees or does, or a unit would change a screen
73
+ the section does not cover, return that interface question to `plan-work`, where the developer
74
+ decides it, sketches it with `design-work`, or leaves it to delivery, and keep the affected units
75
+ blocked until it is settled. A surface left to delivery blocks nothing: name in its unit what
76
+ delivery may decide. Units the open question does not touch can still be shaped. Use
77
+ a diagram when it makes dependencies or boundaries materially easier to judge.
78
+
79
+ When a solution-changing technical assumption needs observation, apply the
80
+ [experiment decision](references/prototypes.md). Do not turn a question with sufficient evidence
81
+ into a prototype.
82
+
83
+ Deliver the coherent product shape: outcome, boundaries, acceptance examples, affected seams,
84
+ ground truth, settled decisions, and open risks. Then write the delivery units to the unit
85
+ contract. For work without an intent, create or reuse its implementation issues on the tracker. For
86
+ an initiative, write `intents/<id>/plan.md`, with its units as tracker issues when the project policy
87
+ makes the tracker the source of truth. Link real dependencies and report the first claimable delivery frontier to the
88
+ developer; it is derived from the issues or the plan and is not written into them.
89
+
90
+ Start from one coherent delivery unit. Split only for a concrete reason such as an independently
91
+ usable or assessable result, different ownership, a separate migration, a delivery boundary, or a
92
+ material risk and verification boundary. A separate commit, session, file, or technical layer is
93
+ not enough. Keep necessary schema, API, UI, configuration, error handling, and verification with
94
+ the behavior they support.
95
+
96
+ The result may be one unit, several independent units, or several units with an epic contract when
97
+ one shared end result needs an owner. Before publishing, check that the whole mission is covered,
98
+ each unit contributes, dependencies are real, and the complete set can be verified.
99
+
100
+ One shape may produce one or several sequential or parallel units. Multiple issues do not imply
101
+ `batch-work`: each ready unit can be delivered with `deliver-work`, while `batch-work` remains an
102
+ explicit developer choice for integrated parallel execution. Do not start either workflow unless
103
+ the request includes implementation.
104
+
105
+ When shaping started from a plan-work handoff, reconcile the issue links and readiness back into the
106
+ origin handoff and map. A handoff alone is not delivery-ready. Shape-work is complete only when
107
+ every selected branch points to implementation-ready units or is explicitly parked or rejected.
108
+
109
+ An epic has an explicit contract in [implementation issues](references/implementation-issues.md):
110
+ shared outcome and acceptance, children or delivery units, aggregate verification, and an owner
111
+ for final verification. A child issue does not authorize the rest of the epic or permit closing its
112
+ parent. `deliver-work` performs aggregate verification when the request covers the epic;
113
+ `batch-work` uses the same contract for an explicitly selected integrated run.
114
+
115
+ A plan built on an older spec revision is stale. Reshape it from the current spec, increase its
116
+ `rev`, and keep unit keys stable so delivered work and open pull requests still point at the right
117
+ unit.
118
+
119
+ Planning-surface writes do not grant product implementation. Commit `plan.md` and open its review
120
+ only when the request or the project's delivery defaults include that. The invocation authorizes
121
+ creating the new issues this shape needs, and updating the ones it created for the same origin on a
122
+ retry. Any other tracker write needs the project policy's `## Tracker mandate`; keep it within the
123
+ requested set and do not silently change acceptance, ownership, delivery scope, or closure. When no
124
+ tracker can be written, return the issue texts in the reply and write no file. A ready
125
+ unit is not an authorization. Without that mandate, keep corrections local and report the pending
126
+ tracker delta.
127
+
128
+ Recommend one concrete next action with its reason and blocker, weighing uncertainty and downstream
129
+ work unlocked as well as project priority, and end with the route line naming the issues created and
130
+ the `deliver-work` command that takes the first one. A ready frontier alone is not enough guidance. Continue
131
+ into authorized sequential delivery only when the request includes that bounded implementation;
132
+ otherwise finish with the recommendation.
133
+
134
+ The invocation authorizes planning artifacts, not product code. A deferred product choice remains
135
+ explicit; a reversible implementation choice does not need to become a question.
@@ -0,0 +1,163 @@
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
+ Choose from the size of the work. Never create an intent, spec, or plan file only to give units a
10
+ place to live.
11
+
12
+ - **Issues only (the default).** Work without an intent: a feature, change, or fix that one or a few
13
+ pull requests deliver. Each unit is an issue in the project's tracker, and the issue is the whole
14
+ record. No `intent.md`, `spec.md`, or `plan.md` is written. Origin is the request or the issue the
15
+ work came from, dependencies are the tracker's issue links or a `Depends on` line, and an epic
16
+ contract goes in a parent issue.
17
+ - **Intent plan.** Work that already has an intent, which is an initiative. `intents/<id>/plan.md`
18
+ beside the spec lists every unit. With `source: files` it holds each unit's contract; with
19
+ `source: issues`, set when the project policy makes a tracker the source of truth for units, it
20
+ lists the tracker keys and the issues hold the contracts. The plan contains links, never copies.
21
+
22
+ The tracker is the one `.agent-os/workflow.md` or the project policy names, with the labels or board
23
+ the workflow file asks for, otherwise the repository host's issue tracker when
24
+ the session can write to it, such as GitHub Issues. Invoking `shape-work` authorizes creating new
25
+ issues there, and updating the issues it created for the same origin when shaping is retried. Any
26
+ other tracker write, such as editing, commenting on, relabeling, or closing other issues, still
27
+ needs the project policy's `## Tracker mandate`. When no tracker can be written, return each
28
+ issue's text in the reply for the person to create, and write no file.
29
+
30
+ When a plan-work run supplied a plain-language summary for an actual decision, it is the spec's
31
+ `## Summary`, or on the issues-only path the opening of the first issue. Do not turn summary
32
+ approval into a second gate or copy the plan into a competing specification.
33
+
34
+ ## Completion invariant
35
+
36
+ A selected product branch is not `delivery-ready`, and shape-work is not complete, until one or
37
+ more implementation units have been written or reused. A parked or rejected branch needs no unit.
38
+
39
+ Each unit represents one coherent delivery unit: an independently useful or assessable result with
40
+ a reviewable change boundary and ground truth that can verify it. The unit may depend on earlier
41
+ units, but technical layers that support the same behavior stay together. Split only for a concrete
42
+ delivery, ownership, migration, risk, or verification boundary; separate commits, sessions, files,
43
+ or technical layers are not sufficient reasons.
44
+
45
+ ## plan.md
46
+
47
+ ```markdown
48
+ ---
49
+ intent: <YYYY-MM>-<slug>
50
+ rev: 1
51
+ built_on: spec@1
52
+ status: accepted
53
+ source: files
54
+ ---
55
+
56
+ # Plan: <the outcome in one line>
57
+
58
+ ## Units
59
+
60
+ - [U1] <title>
61
+ - [U2] <title> — depends on U1
62
+ - [U3] <title> — depends on U1 — blocked: <the open decision>
63
+
64
+ ### U1 <title>
65
+
66
+ Outcome:
67
+ Boundaries:
68
+ Change surface:
69
+ Acceptance:
70
+ Ground truth:
71
+ Dependencies:
72
+ Evidence and settled decisions:
73
+ Delivery target:
74
+ Open risks:
75
+ ```
76
+
77
+ What each field must hold is the unit contract in `SKILL.md`. A field value may run over several
78
+ lines, and Acceptance is usually a list.
79
+
80
+ Rules:
81
+
82
+ - Identity is `(origin, unit key)`, where the origin is the intent id. Unit keys never change once
83
+ written, so pull requests and history keep pointing at the right unit. Search the plan and the
84
+ tracker before creating anything so retrying the same shape updates units instead of duplicating
85
+ them.
86
+ - Each line under `## Units` is `- [<KEY>] <title>`, optionally followed by ` — depends on <KEY>,
87
+ <KEY>` and ` — blocked: <reason>`. With `source: issues` the key is the tracker key and the
88
+ `###` sections are omitted.
89
+ - `status` is `accepted`, `done`, or `superseded`. Delivery status is never written into the plan.
90
+ A unit is claimed by a draft pull request whose body carries `Intent-Unit: <intent-id>/<unit-key>`,
91
+ and it is delivered when that pull request merges.
92
+ - `built_on` names the spec revision. A plan built on an older spec revision is stale.
93
+
94
+ ## Issues
95
+
96
+ A tracker issue carries the same fields as headings, on both paths. On the issues-only path it also
97
+ opens with the need in one or two sentences, because no intent holds it, and it is claimed by a
98
+ draft pull request that links it with the tracker's closing reference, such as `Closes #12` on
99
+ GitHub. It is delivered when that pull request merges. Its origin is not a stable file, so before
100
+ creating issues on this path, search the tracker's open issues for ones that already cover the same
101
+ outcome and reuse them instead of creating duplicates.
102
+
103
+ ```text
104
+ ## Implementation issue
105
+ Origin: <intent id and plan link, or the request or issue the work came from>
106
+ Unit key: <stable key>
107
+ Status: ready | blocked
108
+
109
+ ## Why (issues-only path)
110
+ ## Outcome
111
+ ## Boundaries
112
+ ## Change surface
113
+ ## Acceptance
114
+ ## Ground truth
115
+ ## Dependencies
116
+ ## Evidence and settled decisions
117
+ ## Delivery target
118
+ ## Open risks
119
+ ```
120
+
121
+ Use dependencies to distinguish order from execution strategy. A unit is ready when its product
122
+ decisions are settled and its dependencies are delivered; otherwise record the exact blocker on its
123
+ line. The delivery frontier is the set of ready, unblocked units without an open pull request. Use
124
+ the tracker's existing status and label conventions rather than inventing a parallel queue
125
+ vocabulary.
126
+
127
+ ## Epic contract
128
+
129
+ When one shared end result needs an owner, add an epic contract to the plan, or to a parent issue
130
+ on the issues-only path, instead of splitting every technical layer into a child:
131
+
132
+ ```text
133
+ ## Epic contract
134
+ Epic outcome: <shared observable result>
135
+ Acceptance: <aggregate acceptance examples, usually the spec's Behavior section>
136
+ Children or delivery units: <unit keys and why each boundary exists>
137
+ Aggregate verification: <checks for the complete result>
138
+ Final verification owner: <person or delivery role>
139
+ ```
140
+
141
+ The contract belongs to shape-work and is consumed by delivery. A child issue contributes to the
142
+ epic but does not authorize its siblings, change its acceptance, or close the parent. Green child
143
+ checks are not aggregate verification. `deliver-work` owns the whole-result check when the request
144
+ covers the epic, and `batch-work` reuses this same contract for an explicitly selected batch.
145
+
146
+ ## Routing belongs to the developer
147
+
148
+ Expose the frontier without choosing an execution workflow:
149
+
150
+ - `deliver-work` can deliver any one ready unit, including units from a larger sequential graph;
151
+ - `batch-work` consumes an existing dependency-mapped unit set only when the developer explicitly
152
+ requests integrated parallel execution;
153
+ - the existence of several issues never invokes or recommends batch-work by itself.
154
+
155
+ Writing units is a planning write, not implementation authority. Do not edit product code, start a
156
+ batch, merge, deploy, or perform external delivery effects under a planning-only shape-work invocation.
157
+
158
+ ## Plan-work reconciliation
159
+
160
+ When the origin is a plan-work handoff, update the handoff and map idempotently after materializing
161
+ the units. Link every unit, record the ready or blocked frontier, and move the
162
+ branch from shaping to `delivery-ready` only when the completion invariant holds. Preserve concurrent map entries and
163
+ keep decision tickets canonical for their evidence.
@@ -6,16 +6,16 @@ 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.
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.
12
13
 
13
14
  Within an authorized planning or implementation task, run a small isolated local experiment when
14
- it can answer that question without new external effects or product changes. For UI choices, build
15
- comparable alternatives and ask the developer to judge them. Announce the question, smallest
16
- artifact, observation that would settle it, and a bounded effort budget before starting; no
17
- separate approval is needed inside existing authority. Ask before crossing that authority, not
18
- merely 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.
19
19
 
20
20
  Stop when the evidence is sufficient or the budget is exhausted. Inconclusive evidence leaves the
21
21
  decision open; report the remaining uncertainty and recommend the next action instead of silently
@@ -39,5 +39,4 @@ Record:
39
39
  - Open uncertainty:
40
40
  ```
41
41
 
42
- Keep the artifact inspectable while the decision depends on it. Frontend prototypes also follow the
43
- 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.