@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
@@ -0,0 +1,233 @@
1
+ #!/usr/bin/env node
2
+ // Renders a sketch to one PNG per width with a Chrome or Edge already on the machine, and reports the
3
+ // page's errors. It speaks the DevTools protocol over --remote-debugging-pipe, so it has no dependency.
4
+
5
+ import { spawn } from 'node:child_process'
6
+ import fs from 'node:fs'
7
+ import os from 'node:os'
8
+ import path from 'node:path'
9
+ import { fileURLToPath, pathToFileURL } from 'node:url'
10
+
11
+ const DEFAULT_WIDTHS = [390, 768, 1280]
12
+ const VIEWPORT_HEIGHT = 900
13
+ const LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]'])
14
+ const USAGE = 'Usage: render-sketch <file or local URL> --out <dir> [--widths 390,768,1280] [--name <name>] [--browser <path>]'
15
+
16
+ export class RenderError extends Error {}
17
+
18
+ export function parseArgs(argv) {
19
+ const options = { widths: DEFAULT_WIDTHS }
20
+ const positional = []
21
+ for (let index = 0; index < argv.length; index += 1) {
22
+ const argument = argv[index]
23
+ if (!argument.startsWith('--')) {
24
+ positional.push(argument)
25
+ continue
26
+ }
27
+ const key = argument.slice(2)
28
+ if (!['out', 'widths', 'name', 'browser'].includes(key)) throw new RenderError(`Unknown option ${argument}. ${USAGE}`)
29
+ const value = argv[index + 1]
30
+ if (!value || value.startsWith('--')) throw new RenderError(`${argument} needs a value. ${USAGE}`)
31
+ index += 1
32
+ options[key] = key === 'widths' ? value.split(',').map(Number) : value
33
+ }
34
+ if (positional.length !== 1 || !options.out) throw new RenderError(USAGE)
35
+ if (!options.widths.length || !options.widths.every((width) => Number.isInteger(width) && width > 0)) {
36
+ throw new RenderError('--widths must be positive whole numbers separated by commas.')
37
+ }
38
+ return { ...options, target: positional[0] }
39
+ }
40
+
41
+ // A sketch is a local file or a local workshop. Anything else is not this script's to open.
42
+ export function resolveTarget(target) {
43
+ if (/^https?:\/\//i.test(target)) {
44
+ if (!LOCAL_HOSTS.has(new URL(target).hostname)) throw new RenderError(`Only local addresses are rendered, not ${target}.`)
45
+ return target
46
+ }
47
+ const file = path.resolve(target)
48
+ if (!fs.existsSync(file)) throw new RenderError(`No such file: ${file}`)
49
+ return pathToFileURL(file).href
50
+ }
51
+
52
+ export function browserCandidates(platform = process.platform, env = process.env) {
53
+ if (platform === 'win32') {
54
+ const roots = [env.ProgramFiles, env['ProgramFiles(x86)'], env.LOCALAPPDATA].filter(Boolean)
55
+ return roots.flatMap((root) => [
56
+ path.win32.join(root, 'Google', 'Chrome', 'Application', 'chrome.exe'),
57
+ path.win32.join(root, 'Microsoft', 'Edge', 'Application', 'msedge.exe')
58
+ ])
59
+ }
60
+ if (platform === 'darwin') {
61
+ return ['Google Chrome', 'Microsoft Edge', 'Chromium'].map((app) => `/Applications/${app}.app/Contents/MacOS/${app}`)
62
+ }
63
+ const names = ['google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser', 'microsoft-edge']
64
+ return (env.PATH ?? '').split(':').filter(Boolean).flatMap((dir) => names.map((name) => path.posix.join(dir, name)))
65
+ }
66
+
67
+ export function findBrowser(candidates = browserCandidates()) {
68
+ return candidates.find((candidate) => fs.existsSync(candidate)) ?? null
69
+ }
70
+
71
+ function withTimeout(promise, ms, message) {
72
+ let timer
73
+ const timeout = new Promise((_, reject) => {
74
+ timer = setTimeout(() => reject(new RenderError(message)), ms)
75
+ })
76
+ return Promise.race([promise, timeout]).finally(() => clearTimeout(timer))
77
+ }
78
+
79
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
80
+
81
+ function connect(child) {
82
+ const [input, output] = [child.stdio[3], child.stdio[4]]
83
+ const pending = new Map()
84
+ const listeners = new Set()
85
+ let buffer = Buffer.alloc(0)
86
+ let nextId = 1
87
+
88
+ const failAll = (message) => {
89
+ for (const { reject } of pending.values()) reject(new RenderError(message))
90
+ pending.clear()
91
+ }
92
+ input.on('error', () => failAll('The browser closed its connection.'))
93
+ child.on('error', (error) => failAll(`The browser could not start: ${error.message}`))
94
+ child.on('exit', () => failAll('The browser exited before rendering finished.'))
95
+ output.on('data', (chunk) => {
96
+ buffer = Buffer.concat([buffer, chunk])
97
+ for (let end = buffer.indexOf(0); end >= 0; end = buffer.indexOf(0)) {
98
+ const message = JSON.parse(buffer.subarray(0, end).toString('utf8'))
99
+ buffer = buffer.subarray(end + 1)
100
+ const call = pending.get(message.id)
101
+ if (!call) {
102
+ for (const listener of listeners) listener(message)
103
+ } else {
104
+ pending.delete(message.id)
105
+ if (message.error) call.reject(new RenderError(`${call.method}: ${message.error.message}`))
106
+ else call.resolve(message.result)
107
+ }
108
+ }
109
+ })
110
+
111
+ return {
112
+ listeners,
113
+ send(method, params = {}, sessionId) {
114
+ return new Promise((resolve, reject) => {
115
+ const id = nextId
116
+ nextId += 1
117
+ pending.set(id, { resolve, reject, method })
118
+ input.write(`${JSON.stringify({ id, method, params, sessionId })}\0`)
119
+ })
120
+ }
121
+ }
122
+ }
123
+
124
+ function pageError({ method, params }) {
125
+ if (method === 'Runtime.exceptionThrown') {
126
+ const details = params.exceptionDetails
127
+ return details.exception?.description ?? details.text
128
+ }
129
+ if (method === 'Runtime.consoleAPICalled' && ['error', 'assert'].includes(params.type)) {
130
+ return params.args.map((arg) => arg.value ?? arg.description ?? '').join(' ')
131
+ }
132
+ if (method === 'Log.entryAdded' && params.entry.level === 'error' && !params.entry.url?.endsWith('/favicon.ico')) {
133
+ return params.entry.url ? `${params.entry.text} (${params.entry.url})` : params.entry.text
134
+ }
135
+ return null
136
+ }
137
+
138
+ async function renderWidth(pipe, sessionId, url, width, file, timeoutMs) {
139
+ const send = (method, params) => pipe.send(method, params, sessionId)
140
+ const errors = []
141
+ let loaded
142
+ const load = new Promise((resolve) => {
143
+ loaded = resolve
144
+ })
145
+ const listener = (message) => {
146
+ if (message.sessionId !== sessionId) return
147
+ if (message.method === 'Page.loadEventFired') loaded()
148
+ const error = pageError(message)
149
+ if (error) errors.push(error)
150
+ }
151
+ pipe.listeners.add(listener)
152
+ try {
153
+ await send('Emulation.setDeviceMetricsOverride', { width, height: VIEWPORT_HEIGHT, deviceScaleFactor: 1, mobile: false })
154
+ const navigation = await send('Page.navigate', { url })
155
+ if (navigation.errorText) throw new RenderError(`Could not open ${url}: ${navigation.errorText}`)
156
+ await withTimeout(load, timeoutMs, `${url} did not finish loading within ${timeoutMs} ms.`)
157
+ await send('Runtime.evaluate', { expression: 'document.fonts.ready.then(() => true)', awaitPromise: true })
158
+ await delay(150)
159
+ const { cssContentSize: size } = await send('Page.getLayoutMetrics')
160
+ const height = Math.max(1, Math.ceil(size.height))
161
+ // Side-by-side alternatives can be wider than the width under test, and must not be cut off.
162
+ const contentWidth = Math.max(width, Math.ceil(size.width))
163
+ const { data } = await send('Page.captureScreenshot', {
164
+ format: 'png',
165
+ captureBeyondViewport: true,
166
+ clip: { x: 0, y: 0, width: contentWidth, height, scale: 1 }
167
+ })
168
+ fs.writeFileSync(file, Buffer.from(data, 'base64'))
169
+ return { width, height, file, errors, contentWidth }
170
+ } finally {
171
+ pipe.listeners.delete(listener)
172
+ }
173
+ }
174
+
175
+ export async function renderSketch({ target, out, widths = DEFAULT_WIDTHS, name, browser, timeoutMs = 30000 }) {
176
+ const url = resolveTarget(target)
177
+ const executable = browser ?? findBrowser()
178
+ if (!executable) throw new RenderError('No Chrome or Edge was found. Pass one with --browser <path>.')
179
+ const stem = name ?? (url.startsWith('file:') ? path.parse(target).name : 'sketch')
180
+ fs.mkdirSync(out, { recursive: true })
181
+ const profile = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-os-render-'))
182
+ const flags = [
183
+ '--headless=new', '--remote-debugging-pipe', `--user-data-dir=${profile}`, '--no-first-run',
184
+ '--no-default-browser-check', '--disable-extensions', '--disable-gpu', '--hide-scrollbars', '--mute-audio',
185
+ // Chrome refuses to start as root with its sandbox on, which is how many CI containers run.
186
+ ...(process.getuid?.() === 0 ? ['--no-sandbox'] : [])
187
+ ]
188
+ const child = spawn(executable, [...flags, 'about:blank'], { stdio: ['ignore', 'ignore', 'ignore', 'pipe', 'pipe'] })
189
+ const exited = new Promise((resolve) => {
190
+ child.once('exit', resolve)
191
+ child.once('error', resolve)
192
+ })
193
+ const pipe = connect(child)
194
+ try {
195
+ const { targetId } = await withTimeout(pipe.send('Target.createTarget', { url: 'about:blank' }), timeoutMs, 'The browser did not respond.')
196
+ const { sessionId } = await pipe.send('Target.attachToTarget', { targetId, flatten: true })
197
+ for (const domain of ['Page', 'Runtime', 'Log']) await pipe.send(`${domain}.enable`, {}, sessionId)
198
+ const results = []
199
+ for (const width of widths) {
200
+ results.push(await renderWidth(pipe, sessionId, url, width, path.join(out, `${stem}-${width}.png`), timeoutMs))
201
+ }
202
+ return results
203
+ } finally {
204
+ await withTimeout(pipe.send('Browser.close'), 3000, 'close').catch(() => {})
205
+ await withTimeout(exited, 3000, 'exit').catch(() => child.kill())
206
+ try {
207
+ fs.rmSync(profile, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
208
+ } catch {
209
+ // A leftover profile in the temp directory does not affect the result.
210
+ }
211
+ }
212
+ }
213
+
214
+ // Exit 0: rendered with no page errors. Exit 1: rendered, with page errors. Exit 2: could not render.
215
+ export async function main(argv, output = process.stdout) {
216
+ try {
217
+ const results = await renderSketch(parseArgs(argv))
218
+ for (const { width, height, file, errors, contentWidth } of results) {
219
+ output.write(`RENDERED ${width}x${height} ${file}\n`)
220
+ if (contentWidth > width) output.write(`WARN ${width}: the content is ${contentWidth} px wide and overflows this width\n`)
221
+ for (const error of errors) output.write(`ERROR ${width}: ${error}\n`)
222
+ }
223
+ return results.some((result) => result.errors.length > 0) ? 1 : 0
224
+ } catch (error) {
225
+ if (!(error instanceof RenderError)) throw error
226
+ output.write(`CANNOT RENDER: ${error.message}\n`)
227
+ return 2
228
+ }
229
+ }
230
+
231
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
232
+ process.exitCode = await main(process.argv.slice(2))
233
+ }
@@ -0,0 +1,73 @@
1
+ import assert from 'node:assert/strict'
2
+ import fs from 'node:fs'
3
+ import os from 'node:os'
4
+ import path from 'node:path'
5
+ import test from 'node:test'
6
+ import { browserCandidates, findBrowser, main, parseArgs, RenderError, resolveTarget } from './render-sketch.mjs'
7
+
8
+ const browser = findBrowser()
9
+ const needsBrowser = { skip: browser ? false : 'no Chrome or Edge on this machine' }
10
+
11
+ function workspace() {
12
+ return fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'agent-os-sketch-')))
13
+ }
14
+
15
+ async function run(argv) {
16
+ let text = ''
17
+ const code = await main(argv, { write(chunk) { text += chunk } })
18
+ return { code, text }
19
+ }
20
+
21
+ function pngSize(file) {
22
+ const bytes = fs.readFileSync(file)
23
+ assert.equal(bytes.subarray(1, 4).toString(), 'PNG')
24
+ return { width: bytes.readUInt32BE(16), height: bytes.readUInt32BE(20) }
25
+ }
26
+
27
+ test('arguments need a target and an output folder, and widths must be whole numbers', () => {
28
+ assert.deepEqual(parseArgs(['a.html', '--out', 'x', '--widths', '390,1280']).widths, [390, 1280])
29
+ assert.throws(() => parseArgs(['a.html']), RenderError)
30
+ assert.throws(() => parseArgs(['a.html', '--out', 'x', '--widths', '390,wide']), /positive whole numbers/)
31
+ assert.throws(() => parseArgs(['a.html', '--out', 'x', '--bogus', '1']), /Unknown option/)
32
+ })
33
+
34
+ test('only local files and local addresses are opened', () => {
35
+ assert.equal(resolveTarget('http://localhost:6006/iframe.html'), 'http://localhost:6006/iframe.html')
36
+ assert.throws(() => resolveTarget('https://example.com/'), /Only local addresses/)
37
+ assert.throws(() => resolveTarget(path.join(os.tmpdir(), 'agent-os-no-such-sketch.html')), /No such file/)
38
+ })
39
+
40
+ test('browser candidates follow the platform', () => {
41
+ assert.ok(browserCandidates('win32', { ProgramFiles: 'C:\\PF' }).includes('C:\\PF\\Google\\Chrome\\Application\\chrome.exe'))
42
+ assert.ok(browserCandidates('darwin', {}).some((candidate) => candidate.includes('Microsoft Edge.app')))
43
+ assert.ok(browserCandidates('linux', { PATH: '/usr/bin' }).includes('/usr/bin/chromium'))
44
+ assert.equal(findBrowser([path.join(os.tmpdir(), 'agent-os-no-such-browser')]), null)
45
+ })
46
+
47
+ test('a missing browser cannot render and says so', async () => {
48
+ const dir = workspace()
49
+ fs.writeFileSync(path.join(dir, 'a.html'), '<p>x</p>')
50
+ const { code, text } = await run([path.join(dir, 'a.html'), '--out', dir, '--browser', path.join(dir, 'no-browser.exe')])
51
+ assert.equal(code, 2, text)
52
+ assert.match(text, /CANNOT RENDER/)
53
+ })
54
+
55
+ test('a clean sketch renders the full page at each width', needsBrowser, async () => {
56
+ const dir = workspace()
57
+ fs.writeFileSync(path.join(dir, 'tall.html'), '<!doctype html><body style="margin:0"><div style="height:2000px">x</div>')
58
+ const { code, text } = await run([path.join(dir, 'tall.html'), '--out', path.join(dir, 'out'), '--widths', '390,1280'])
59
+ assert.equal(code, 0, text)
60
+ assert.deepEqual(pngSize(path.join(dir, 'out', 'tall-390.png')), { width: 390, height: 2000 })
61
+ assert.deepEqual(pngSize(path.join(dir, 'out', 'tall-1280.png')), { width: 1280, height: 2000 })
62
+ })
63
+
64
+ test('console errors, uncaught exceptions, and overflow are reported', needsBrowser, async () => {
65
+ const dir = workspace()
66
+ fs.writeFileSync(path.join(dir, 'bad.html'), '<!doctype html><body style="margin:0"><div style="width:800px">x</div><script>console.error("boom"); missingFunction()</script>')
67
+ const { code, text } = await run([path.join(dir, 'bad.html'), '--out', dir, '--widths', '390'])
68
+ assert.equal(code, 1, text)
69
+ assert.match(text, /ERROR 390: boom/)
70
+ assert.match(text, /ERROR 390: ReferenceError: missingFunction is not defined/)
71
+ assert.match(text, /WARN 390: the content is 800 px wide/)
72
+ assert.equal(pngSize(path.join(dir, 'bad-390.png')).width, 800)
73
+ })
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: diagnose-before-fix
3
+ description: Bug, crash, error, regression, or failing test whose cause is unknown. Reproduces the failure and finds the root cause before any code changes. Use when the user says things like figure out why, this broke, it returns a 500, this test is flaky, what is going on with this error, or fix this bug. Not for edits whose cause is already known, new features, code review, or checking that a finished fix works.
4
+ ---
5
+
6
+ # Diagnose before fix
7
+
8
+ Find the smallest supported explanation that accounts for the failure and predicts a useful check.
9
+
10
+ ## Contract
11
+
12
+ - **Ground truth:** the narrowest reliable reproduction or observed failure.
13
+ - **Working surface:** tests, diagnostics, logs, and instrumentation inside the task scope.
14
+ - **Boundary:** do not commit a production fix whose causal story is still guesswork.
15
+
16
+ ## Loop
17
+
18
+ Reproduce, reduce, trace the nearest seam, and compare plausible causes with high-information checks.
19
+ Use temporary instrumentation when it helps. When the failure can be captured as an automated test,
20
+ write that test first and confirm it fails for the diagnosed reason. In a delivery that commits, commit
21
+ the failing test before the fix, and when agent-os-dev guards are installed run
22
+ `guards.mjs lock-test <path>` from the quality-ratchet skill's `scripts/` so the test cannot be bent
23
+ to fit the fix. Once evidence supports a cause, implement the smallest fix. Re-run the original
24
+ failing path, then `guards.mjs unlock-test <path>`. Changing a locked test needs the developer's
25
+ explicit agreement, because it changes what counts as fixed.
26
+
27
+ If the failure cannot be reproduced or competing explanations cannot be distinguished, report the
28
+ bounded uncertainty and the next discriminating check. Do not turn a plausible hypothesis into a
29
+ confirmed diagnosis.
@@ -11,7 +11,13 @@ choice or dispatch it.
11
11
 
12
12
  ## Loop
13
13
 
14
- Read project policy, queue conventions, issues, pull requests, and CI. Prioritize work already in
14
+ Read project policy, queue conventions, the units in `intents/*/plan.md`, issues, pull requests, and
15
+ CI. A unit's status comes from pull requests, never from the plan: a unit with an open pull request
16
+ carrying its `Intent-Unit: <intent-id>/<unit-key>` line is claimed, one whose pull request merged is
17
+ delivered, and one whose dependencies are delivered and whose line carries no `blocked:` note is
18
+ ready. An issue without an intent is claimed by an open pull request that links it and delivered
19
+ when that pull request merges. A spec or plan whose `built_on` revision is older than its source is not ready; route it to
20
+ `plan-work` or `shape-work`. Prioritize work already in
15
21
  flight when it has an actionable review or failure. Select one target using the repository's
16
22
  priority rules and explain why it wins.
17
23
 
@@ -19,8 +25,10 @@ Within those priorities, prefer the action that removes a consequential uncertai
19
25
  dependent work at reasonable effort. When observation would settle an open decision, recommend a
20
26
  bounded experiment through plan-work or shape-work; a ready coding task need not always win.
21
27
 
22
- Route broad or mission-level planning to `plan-work`, a bounded open delivery choice to
23
- `shape-work`, and one selected implementation-ready issue to `deliver-work`. Route to `batch-work`
28
+ Follow the route for the kind of work from `.agent-os/workflow.md`, or the global policy's default
29
+ routes, and end with the route line. Route broad or mission-level planning to `plan-work`, a bounded open delivery choice to
30
+ `shape-work`, and one selected implementation-ready issue to `deliver-work`, which also takes an
31
+ intent the developer asks to finish. Route to `batch-work`
24
32
  only when the developer
25
33
  explicitly asks to execute an existing ready issue graph as an integrated batch; issue count alone
26
34
  does not choose the workflow.
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: init-agent-os
3
+ description: Sets up agent-os globally on a machine with personal preferences, or initializes and later adjusts a repo's living project policy through an interview. User-invoked only, at machine setup, when onboarding a repo, or when changing how a repo works. Not for ordinary tasks.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # init-agent-os
8
+
9
+ The invocation authorizes setup writes for the named target. Use one mode per run.
10
+
11
+ ## Mode: `global` (once per machine)
12
+
13
+ Invoked as `init-agent-os global`.
14
+
15
+ 1. Verify the agent-os skills are visible on this platform: under the `agent-os` namespace for a
16
+ plugin install, or as top-level skills for a direct install. Report what you find.
17
+ 2. Resolve `scripts/policy-block.mjs` relative to this loaded `SKILL.md` and run it with Node and
18
+ `--check`. Report drift between the policy source and the managed blocks. Without
19
+ `--platform`, it targets `~/.claude/CLAUDE.md` and `~/.codex/AGENTS.md` for the hosts present on
20
+ this machine.
21
+ 3. Run the same script without `--check` to apply the managed blocks and show the resulting diff.
22
+ The npm installer imports this writer, so both share one marker contract. Each block starts with
23
+ an `<!-- agent-os version X -->` line taken from the installed release.
24
+ 4. Settle personal preferences in a `## My working preferences` section outside the managed block
25
+ of each target file. When the section is absent, ask four things with a recommendation each:
26
+ when unsure, ask early or decide and report (recommend decide and report for reversible choices);
27
+ explanations short or walked through (recommend short); what happens when a step of a route
28
+ ends, written as a `Next step:` line with `ask` (ask once whether to start the next step),
29
+ `continue` (start the next planning step without asking and ask once before delivery), or
30
+ `recommend` (only recommend), recommending `ask`; and anything the agent should always or never
31
+ do. When it exists, show it and ask what to change; "nothing" writes nothing. These are
32
+ style only: they yield to project policy and never grant merge, deploy, or external-effect
33
+ authority. The one exception is `Next step: continue`, which lets a planning workflow go on into
34
+ `shape-work` and so lets it create its new issues without asking first.
35
+
36
+ ## Mode: repo init (default)
37
+
38
+ Invoked in a repo working directory. Read [repository-init.md](references/repository-init.md)
39
+ for the detailed contract.
40
+
41
+ Facts and preferences are collected differently. Facts, such as commands, paths, and CI, come from
42
+ the repository. Preferences, how the developer wants to work here, can only come from the developer:
43
+ evidence may recommend an answer but does not settle one. Repo init never asks or writes the personal
44
+ preferences that belong to global mode.
45
+
46
+ Use the first run when the repository has neither a `## Working agreement` section nor an
47
+ `.agent-os/` directory. Otherwise use the return run.
48
+
49
+ ### Working agreement
50
+
51
+ These are the preferences a repository records, under `## Working agreement` in its policy:
52
+
53
+ - who works here and who approves: solo, or a team and its reviewer;
54
+ - the default stopping point: local change, pull request, merge, or deployment;
55
+ - the routes: show the default route for each kind of work (a bug with a known fix, a small change,
56
+ a feature, an initiative) and ask what to change, recommending the defaults, where every route
57
+ gives the work an issue before delivery and only initiatives get intent and spec files;
58
+ - which tracker holds issues, and where an initiative's units live: `plan.md` or that tracker;
59
+ - where an initiative is documented when it is finished, beyond its pull request, such as a
60
+ changelog or a wiki page, recommending the changelog when the repository has one;
61
+ - the language of commits, docs, and issues;
62
+ - with the frontend module active, when interfaces are sketched (before delivery, after it, asked
63
+ each time, or never) and, unless never, in which medium and where the sketches live,
64
+ recommending asking each time, a workshop the repository already has, and `html` otherwise.
65
+
66
+ Ask them in at most two rounds of at most four questions, through the host's structured question
67
+ tool when it has one. Each question leads with its recommended answer and states the consequence of
68
+ choosing differently. "Use your recommendations for the rest" is always an available answer and
69
+ holds for the whole run: an evidence-backed recommendation counts as confirmed, including on later
70
+ fact questions, and a fact with no evidence goes under **Open setup questions** without being asked.
71
+ An answer that settles a core field is written once.
72
+
73
+ ### First run
74
+
75
+ 1. Inspect broadly before asking: instruction and policy surfaces, README and docs, package/build
76
+ files, test and CI configuration, and evidence of conditional areas. Before writing, every live
77
+ host-consumed policy surface must have unambiguous ownership and precedence. Shared identical
78
+ content or a clear canonical cross-reference is sufficient; do not select one file while
79
+ conflicting applicable rules remain elsewhere. If target ownership cannot be resolved, ask one
80
+ ownership question and block the write.
81
+ 2. Maintain a transient completeness ledger while working. Every applicable material field ends as
82
+ repository-evidenced or confirmed, `N/A`, explicitly deferred/open, or conflicting. Do not
83
+ guess through a conflict, and do not write the ledger or interview history to the policy.
84
+ 3. Before writing, each mandatory core field must reach one allowed terminal state: repository-
85
+ evidenced or confirmed, `N/A`, explicitly deferred/open, or conflicting. The core covers policy
86
+ ownership and canonical instruction surface; delivery boundary, stopping point, and external
87
+ effects; verification and ground truth, including when commands are insufficient; coherent
88
+ planning identities, claims, handoffs, readiness, epic ownership, and dependencies; and
89
+ maintenance of durable lessons and gotchas. Only
90
+ an unresolved policy ownership/write-target conflict blocks writing; other explicit deferrals
91
+ may be written concisely under **Open setup questions**.
92
+ 4. Activate only conditional modules supported by repository evidence: frontend/design/rendered QA;
93
+ package/release/docs; CI/deploy; auth/security/billing/external writes; database/migration/
94
+ concurrency; batch/monorepo; and native/desktop. Omit inactive modules from the output.
95
+ 5. Before the first question, say in a few plain lines what you found and what you are about to ask.
96
+ Ask the working agreement. Then ask only unresolved material fact questions, one at a time, with
97
+ a recommendation and consequence. Explicit deferral is an answer: record it under **Open setup
98
+ questions** without inventing a default. Do not ask feature-specific outcome, acceptance, or
99
+ UI-product questions.
100
+ 6. Write only durable behavior-changing defaults and relevant sections to the resolved existing
101
+ instruction surface. When none exists, write a new `policy.md`, plus a `CLAUDE.md` holding
102
+ `@policy.md` and an `AGENTS.md` that says to read it, so the hosts load it. Preserve unrelated
103
+ instructions, show the resulting diff, and do not request a second approval for this setup write.
104
+ 7. Write `.agent-os/workflow.md` from [workflow-template.md](references/workflow-template.md) with the
105
+ routes, tracker, tracker mandate, where information goes, and finishing tasks, and point to it
106
+ from the policy in one line. Write the other Agent OS repository files the reference lists: `.agent-os/guards.json`,
107
+ `.agent-os/quality.json`, `REVIEW.md`, and, for GitHub Actions repositories, the `lint-intents` and `agent-review` workflows. Propose a
108
+ `CODEOWNERS` entry for intents and specs without writing it.
109
+ 8. Close with how you will work here, in at most six plain lines, and one recommended first action.
110
+
111
+ ### Return run
112
+
113
+ A return run adjusts a setup; it never repeats the interview.
114
+
115
+ 1. Inspect as in the first run, and resolve policy ownership the same way.
116
+ 2. Show a short plain-language summary of what is set today: working agreement, delivery,
117
+ verification, planning, and the workflow file's routes and finishing tasks. Under it, flag only what needs attention: drift where the policy
118
+ contradicts the repository, such as a command that no longer exists; any core field, working
119
+ agreement item, or active module the policy does not cover; and **Open setup questions**.
120
+ 3. Ask one question: what do you want to change? Offer working agreement, delivery, verification,
121
+ planning, routes and finishing tasks, and what the summary flagged, plus "nothing, this was a check".
122
+ 4. Ask only about the chosen areas, under the first run's question rules.
123
+ 5. Write only the chosen areas and show the diff; everything else stays byte for byte. Agent OS
124
+ repository files change only when a chosen area needs it. "Nothing" writes nothing and leaves any
125
+ flagged drift reported.
126
+ 6. Close with what changed, what stays flagged, and one recommended next action when one remains.
127
+
128
+ Block handling remains deterministic: add one missing block, update only well-formed managed content,
129
+ and stop on duplicate or malformed markers. Global mode touches no repository files; repo mode
130
+ touches one repository. The direct request or recorded delivery defaults govern merge and deploy
131
+ actions.
@@ -0,0 +1,91 @@
1
+ # Agent OS global policy
2
+
3
+ Source of truth for the managed policy block installed into `~/.claude/CLAUDE.md` and
4
+ `~/.codex/AGENTS.md` by the installer and `init-agent-os global`. Edit here, never inside the
5
+ installed blocks. Everything above `## Development workflows` is the core policy; the installer adds
6
+ that section only when `agent-os-dev` is installed.
7
+
8
+ ## Core policy
9
+
10
+ Priority order when instructions conflict:
11
+
12
+ 1. Direct user instruction in the current session.
13
+ 2. The repo's project policy and nearest `CLAUDE.md`/`AGENTS.md`.
14
+ 3. The active explicit workflow (an invoked agent-os skill).
15
+ 4. This global policy.
16
+
17
+ Rules:
18
+
19
+ - Authority follows the request: an inspection, planning, or review request is read-only apart from
20
+ the requested artifact; an implementation request authorizes repository changes inside its scope.
21
+ Merging, deploying, destructive cleanup, and effects on external systems or people require the
22
+ direct request or project policy to include them.
23
+ - Evidence before claims: verify before calling anything done, and show how it was verified.
24
+ - Keep scope and diffs narrow; when work drifts beyond the task, flag it instead of building on.
25
+ - Escalate only product decisions that cannot be resolved from context and would materially change
26
+ the outcome. Make reversible implementation choices and report them.
27
+ - Respond in the language used by the user. Code, commits, and technical artifacts are English unless the project says otherwise.
28
+ - Lead with the outcome: the first sentence answers "what happened" or "what did you find". Supporting detail comes after.
29
+ - Readable beats brief: shorten by leaving out what does not change the reader's next step, not by compressing language. Full sentences; no arrow chains, fragment style, or invented shorthand the reader must decode.
30
+ - Plain voice in every reply and every text you write: each sentence carries a fact, an instruction,
31
+ or a number. Cut claims with no source or mechanism, promotional adjectives, filler openers,
32
+ restated questions, stacked hedges, abstract metaphors in place of the concrete noun, structure
33
+ forced onto the content (ideas in threes, "not just X but Y", bold labels that repeat their line),
34
+ and closing offers of help. State a claim that stays unverified after checking once, plainly. No
35
+ dashes in running text. Established technical terms stay in English in any language. Never rewrite
36
+ code, identifiers, structured data, quoted source material, or the user's own prose unless asked.
37
+ The `plain-voice` skill holds the full checklist for documentation, commits, and pull request text.
38
+ - Never force the reader to cross-reference labels or numbering invented earlier in the text; say what you mean in place.
39
+ - Explanations belong in prose; tables only for short enumerable facts.
40
+ - Calibrate tone to the topic: playfulness is fine, neutral and factual the moment the subject is serious. When in doubt, it is serious.
41
+ - Orchestration is opt-in: manual agent-os skills run only when the person invokes them by the name
42
+ the host exposes (`/plan-work`, `/agent-os-core:plan-work`, or `$plan-work`). Never self-invoke one.
43
+ When a request clearly matches a manual skill the person did not name, suggest it once in one
44
+ sentence with its invocation and why it fits, then do what was asked. Planning alone never starts
45
+ implementation.
46
+ - End every agent-os workflow with a route line: the kind of work, the steps done and left, and the
47
+ exact command that resumes it, such as `/deliver-work #42`. Take the route from the project's
48
+ `.agent-os/workflow.md` when the project policy points to one, else from a default path the policy
49
+ states, else from the default routes; with agent-os-core alone, name the next installed step. Then
50
+ follow the `Next step:` line in the person's `## My working preferences`: `ask`, the default, asks
51
+ once whether to start the next step; `continue` starts the next planning step, including the
52
+ issues `shape-work` creates, and asks before delivery; `recommend` only recommends. Never skip a
53
+ step, decide an open product question, merge, or deploy on that basis.
54
+ - Recommend one concrete next action with its reason and any blocker. Authority persists across unit
55
+ boundaries but never expands to unrelated backlog work; when nothing useful remains, say so.
56
+ - Sort discoveries with `scope-guard`: required work the mandate covers stays in scope, adjacent work
57
+ is a follow-up, unrelated work gets no proposal, and risk never grants permission by itself.
58
+ - Tracker writes need a tracker mandate in the request or the project policy's `## Tracker mandate`,
59
+ except the new issues an invoked `shape-work` creates. A mandate never covers acceptance, owners,
60
+ new deliveries, or closure. Without one, keep corrections local and report the unsynced delta.
61
+ - Only an initiative, work that several pull requests deliver and whose product decisions someone
62
+ other than the requester must agree to, or work the person or project policy asks files for, gets
63
+ `intents/<id>/intent.md` and `spec.md`. Other work lives in tracker issues and pull requests. Those
64
+ files change only through review, and one whose `built_on` revision is older than its source is
65
+ stale until it is reconsidered.
66
+
67
+ ## Preferences (seed defaults; project policy overrides)
68
+
69
+ - UI feedback under ~250 ms; feedback must not block the next interaction.
70
+ - Own design identity; do not imitate the look of well-known apps.
71
+ - Every repo keeps a living project policy (planning surface, design system location, verify
72
+ commands, conventions, gotchas, and delivery defaults). It grows over time; `init-agent-os`
73
+ seeds it and `record-lesson` grows it.
74
+
75
+ ## Development workflows
76
+
77
+ - Use the Git identity configured by the repository or current session. Never add AI attribution or `Co-Authored-By` trailers.
78
+ - The development skills are manual too. Authority may continue into the workflow a skill's exit
79
+ contract names. A request that covers a bounded set of shaped units, or finishing an intent, covers
80
+ delivering them one at a time; parallel batch execution needs explicit selection. `check-work` may
81
+ start from an implicit review request; its report mode is read-only and its fix mode needs explicit
82
+ authority.
83
+ - Default routes: a bug with a known fix, `shape-work` for one issue and then `deliver-work`; a small
84
+ change or a bug whose fix holds a choice, `plan-work`, `shape-work`, and `deliver-work`; a feature,
85
+ the same with `plan-work` only when something is unclear; an initiative, every step and the
86
+ project's finishing tasks. Each route gives the work an issue unless the request skips it, and
87
+ routes guide only agent-os workflows: a request made without one is done as asked.
88
+ - Delivery status is never written into `plan.md`: a draft pull request claims a unit, by its
89
+ `Intent-Unit: <intent-id>/<unit-key>` line or by linking its issue, and its merge delivers it.
90
+ - Agent OS hooks read `.agent-os/guards.json`. A hook block is a boundary, not an obstacle: change
91
+ course or ask, and never work around it by another tool or path.
@@ -0,0 +1,40 @@
1
+ # Guards configuration
2
+
3
+ `.agent-os/guards.json` tells the agent-os-dev guard hooks what to protect. The hooks run
4
+ `quality-ratchet/scripts/guards.mjs`. It reads only this file, Git, and the intent files. It never
5
+ runs a command the repository declares, so it needs no trust step. Without the file, the hooks do
6
+ nothing.
7
+
8
+ ```json
9
+ {
10
+ "schema": 1,
11
+ "protectedPaths": ["migrations/**", ".github/workflows/**"],
12
+ "frozen": ["intents/*/intent.md", "intents/*/spec.md", "intents/*/plan.md"],
13
+ "secretScan": true
14
+ }
15
+ ```
16
+
17
+ - `protectedPaths`: globs relative to the repository root. An agent edit to a matching path asks
18
+ the developer in Claude Code. Codex has no ask decision, so there the edit is blocked with a
19
+ message asking the agent to get the developer's explicit go-ahead. `*` matches within one path
20
+ segment and `**` across segments.
21
+ - `frozen`: globs for accepted intent, spec, and plan files. While a quality-ratchet delivery baseline is
22
+ active in the session, an edit to a matching file whose frontmatter `status` is `accepted` is
23
+ blocked, because delivery never changes the decisions it delivers. Planning sessions, which have no
24
+ delivery baseline, can still change them through a review.
25
+ - `secretScan`: when `true`, a `git commit` run by the agent is blocked if the staged diff adds a
26
+ line that looks like a private key, a cloud or provider access key, or an assignment of a long
27
+ literal to a name such as `password`, `secret`, `token`, or `api_key`. A false positive is resolved
28
+ by the developer, not by rewording the secret.
29
+
30
+ The guards cover the agent's file-edit tools (Edit, Write, MultiEdit, NotebookEdit, and Codex
31
+ `apply_patch`) and `git commit`. They do not inspect other shell commands, so a shell redirect into
32
+ a protected path is not caught; they reduce mistakes and are not a sandbox. Paths compare without
33
+ case on Windows and macOS. A malformed `guards.json` blocks every edit except the one that repairs it.
34
+
35
+ Locked tests are not configured here. `diagnose-before-fix` locks one with
36
+ `node <quality-ratchet>/scripts/guards.mjs lock-test <path>` after committing it and unlocks it with
37
+ `unlock-test <path>` once the fix passes. Locks live in the Git directory and are never committed.
38
+
39
+ The delivery ground truth belongs in `.agent-os/quality.json` as a `required` check, where the
40
+ quality-ratchet Stop hook enforces it after the developer has trusted the repository's controls.