@sockulags/agent-os 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +102 -49
  2. package/cli/doctor.mjs +307 -0
  3. package/cli/index.mjs +328 -151
  4. package/cli/index.test.mjs +406 -9
  5. package/package.json +5 -6
  6. package/plugins/agent-os-core/.claude-plugin/plugin.json +18 -0
  7. package/plugins/agent-os-core/.codex-plugin/plugin.json +24 -0
  8. package/plugins/agent-os-core/skills/capture-intent/SKILL.md +65 -0
  9. package/plugins/agent-os-core/skills/capture-intent/references/intent-template.md +47 -0
  10. package/plugins/agent-os-core/skills/explain-work/SKILL.md +42 -0
  11. package/{skills → plugins/agent-os-core/skills}/list-skills/SKILL.md +13 -6
  12. package/{skills → plugins/agent-os-core/skills}/plain-voice/SKILL.md +7 -4
  13. package/plugins/agent-os-core/skills/plan-work/SKILL.md +133 -0
  14. package/plugins/agent-os-core/skills/plan-work/references/elicitation.md +32 -0
  15. package/plugins/agent-os-core/skills/plan-work/references/map.md +108 -0
  16. package/plugins/agent-os-core/skills/plan-work/references/spec-template.md +64 -0
  17. package/plugins/agent-os-core/skills/record-lesson/SKILL.md +47 -0
  18. package/plugins/agent-os-core/skills/scope-guard/SKILL.md +53 -0
  19. package/{skills → plugins/agent-os-core/skills}/verify-before-done/SKILL.md +6 -2
  20. package/plugins/agent-os-dev/.claude-plugin/plugin.json +18 -0
  21. package/plugins/agent-os-dev/.codex-plugin/plugin.json +24 -0
  22. package/plugins/agent-os-dev/hooks/hooks.json +42 -0
  23. package/{skills → plugins/agent-os-dev/skills}/batch-work/SKILL.md +9 -4
  24. package/{skills → plugins/agent-os-dev/skills}/batch-work/references/manifest.md +8 -0
  25. package/{skills → plugins/agent-os-dev/skills}/check-work/SKILL.md +31 -14
  26. package/{skills/deliver-work/workflow.md → plugins/agent-os-dev/skills/deliver-work/SKILL.md} +85 -17
  27. package/plugins/agent-os-dev/skills/design-work/SKILL.md +145 -0
  28. package/plugins/agent-os-dev/skills/design-work/scripts/render-sketch.mjs +233 -0
  29. package/plugins/agent-os-dev/skills/design-work/scripts/render-sketch.test.mjs +73 -0
  30. package/plugins/agent-os-dev/skills/diagnose-before-fix/SKILL.md +29 -0
  31. package/{skills → plugins/agent-os-dev/skills}/dispatch-next/SKILL.md +10 -4
  32. package/plugins/agent-os-dev/skills/init-agent-os/SKILL.md +121 -0
  33. package/plugins/agent-os-dev/skills/init-agent-os/policy.md +88 -0
  34. package/plugins/agent-os-dev/skills/init-agent-os/references/guards.md +39 -0
  35. package/{skills → plugins/agent-os-dev/skills}/init-agent-os/references/repository-init.md +41 -9
  36. package/plugins/agent-os-dev/skills/init-agent-os/references/review-template.md +35 -0
  37. package/plugins/agent-os-dev/skills/init-agent-os/scripts/policy-block.mjs +187 -0
  38. package/plugins/agent-os-dev/skills/init-agent-os/templates/agent-review.yml +59 -0
  39. package/plugins/agent-os-dev/skills/init-agent-os/templates/lint-intents.yml +30 -0
  40. package/{skills → plugins/agent-os-dev/skills}/proportional-testing/SKILL.md +1 -1
  41. package/plugins/agent-os-dev/skills/quality-ratchet/SKILL.md +103 -0
  42. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/references/project-controls.md +31 -3
  43. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/analyzers.mjs +145 -0
  44. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/analyzers.test.mjs +158 -0
  45. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/guards.mjs +372 -0
  46. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/guards.test.mjs +138 -0
  47. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/intent-files.mjs +322 -0
  48. package/plugins/agent-os-dev/skills/quality-ratchet/scripts/intent-files.test.mjs +172 -0
  49. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/project-controls.mjs +59 -8
  50. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/project-controls.test.mjs +134 -8
  51. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/quality-delta.mjs +296 -22
  52. package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/scripts/quality-delta.test.mjs +114 -6
  53. package/plugins/agent-os-dev/skills/shape-work/SKILL.md +124 -0
  54. package/plugins/agent-os-dev/skills/shape-work/references/implementation-issues.md +143 -0
  55. package/{skills/chart-work → plugins/agent-os-dev/skills/shape-work}/references/prototypes.md +11 -13
  56. package/plugins/agent-os-dev/skills/simplify/SKILL.md +91 -0
  57. package/plugins/agent-os-dev/skills/simplify/scripts/audit-evidence.mjs +166 -0
  58. package/plugins/agent-os-dev/skills/simplify/scripts/audit-evidence.test.mjs +49 -0
  59. package/policy.md +53 -20
  60. package/hooks/hooks.json +0 -17
  61. package/skills/chart-work/SKILL.md +0 -42
  62. package/skills/chart-work/references/elicitation.md +0 -25
  63. package/skills/chart-work/references/map.md +0 -84
  64. package/skills/deliver-work/SKILL.md +0 -12
  65. package/skills/diagnose-before-fix/SKILL.md +0 -24
  66. package/skills/explain-work/SKILL.md +0 -27
  67. package/skills/guide-me/SKILL.md +0 -36
  68. package/skills/init-agent-os/SKILL.md +0 -54
  69. package/skills/init-agent-os/scripts/policy-block.ps1 +0 -87
  70. package/skills/notice-lesson/SKILL.md +0 -20
  71. package/skills/quality-ratchet/SKILL.md +0 -72
  72. package/skills/record-lesson/SKILL.md +0 -31
  73. package/skills/scope-guard/SKILL.md +0 -32
  74. package/skills/shape-work/SKILL.md +0 -48
  75. package/skills/shape-work/references/implementation-issues.md +0 -69
  76. package/skills/shape-work/references/mockups.md +0 -23
  77. package/skills/simplifier/SKILL.md +0 -35
  78. package/skills/simplifier/agents/openai.yaml +0 -2
  79. package/skills/simplifier-audit/SKILL.md +0 -30
  80. package/skills/simplifier-review/SKILL.md +0 -40
  81. package/skills/understand-work/SKILL.md +0 -31
  82. package/skills/understand-work/agents/openai.yaml +0 -2
  83. package/skills/writing-skills/SKILL.md +0 -68
  84. package/skills/writing-skills/agents/openai.yaml +0 -2
  85. /package/{skills/batch-work → plugins/agent-os-core/skills/capture-intent}/agents/openai.yaml +0 -0
  86. /package/{skills/chart-work → plugins/agent-os-core/skills/explain-work}/agents/openai.yaml +0 -0
  87. /package/{skills/deliver-work → plugins/agent-os-core/skills/list-skills}/agents/openai.yaml +0 -0
  88. /package/{skills → plugins/agent-os-core/skills}/plain-voice/references/tells.md +0 -0
  89. /package/{skills/dispatch-next → plugins/agent-os-core/skills/plan-work}/agents/openai.yaml +0 -0
  90. /package/{skills/explain-work → plugins/agent-os-dev/skills/batch-work}/agents/openai.yaml +0 -0
  91. /package/{skills → plugins/agent-os-dev/skills}/batch-work/scripts/manifest-hash.mjs +0 -0
  92. /package/{skills → plugins/agent-os-dev/skills}/batch-work/scripts/test-manifest-hash.mjs +0 -0
  93. /package/{skills → plugins/agent-os-dev/skills}/check-work/references/findings.md +0 -0
  94. /package/{skills/guide-me → plugins/agent-os-dev/skills/deliver-work}/agents/openai.yaml +0 -0
  95. /package/{skills/init-agent-os → plugins/agent-os-dev/skills/design-work}/agents/openai.yaml +0 -0
  96. /package/{skills/list-skills → plugins/agent-os-dev/skills/dispatch-next}/agents/openai.yaml +0 -0
  97. /package/{skills/record-lesson → plugins/agent-os-dev/skills/init-agent-os}/agents/openai.yaml +0 -0
  98. /package/{skills → plugins/agent-os-dev/skills}/proportional-testing/references/strategy.md +0 -0
  99. /package/{skills → plugins/agent-os-dev/skills}/quality-ratchet/references/structure.md +0 -0
  100. /package/{skills → plugins/agent-os-dev/skills}/shape-work/agents/openai.yaml +0 -0
  101. /package/{skills/simplifier-audit → plugins/agent-os-dev/skills/simplify}/agents/openai.yaml +0 -0
@@ -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,16 +11,22 @@ 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. A spec or plan whose `built_on` revision is older than its source is not ready; route it to
19
+ `plan-work` or `shape-work`. Prioritize work already in
15
20
  flight when it has an actionable review or failure. Select one target using the repository's
16
21
  priority rules and explain why it wins.
17
22
 
18
23
  Within those priorities, prefer the action that removes a consequential uncertainty or unlocks
19
24
  dependent work at reasonable effort. When observation would settle an open decision, recommend a
20
- bounded experiment through chart-work or shape-work; a ready coding task need not always win.
25
+ bounded experiment through plan-work or shape-work; a ready coding task need not always win.
21
26
 
22
- Route broad decision work to `chart-work`, a bounded open decision to `shape-work`, and one selected
23
- implementation-ready issue to `deliver-work`. Route to `batch-work` only when the developer
27
+ Route broad or mission-level planning to `plan-work`, a bounded open delivery choice to
28
+ `shape-work`, and one selected implementation-ready issue to `deliver-work`. Route to `batch-work`
29
+ only when the developer
24
30
  explicitly asks to execute an existing ready issue graph as an integrated batch; issue count alone
25
31
  does not choose the workflow.
26
32
 
@@ -0,0 +1,121 @@
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 three 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); and anything the agent should always or
28
+ never do. When it exists, show it and ask what to change; "nothing" writes nothing. These are
29
+ style only: they yield to project policy and never grant merge, deploy, or external-effect
30
+ authority.
31
+
32
+ ## Mode: repo init (default)
33
+
34
+ Invoked in a repo working directory. Read [repository-init.md](references/repository-init.md)
35
+ for the detailed contract.
36
+
37
+ Facts and preferences are collected differently. Facts, such as commands, paths, and CI, come from
38
+ the repository. Preferences, how the developer wants to work here, can only come from the developer:
39
+ evidence may recommend an answer but does not settle one. Repo init never asks or writes the personal
40
+ preferences that belong to global mode.
41
+
42
+ Use the first run when the repository has neither a `## Working agreement` section nor an
43
+ `.agent-os/` directory. Otherwise use the return run.
44
+
45
+ ### Working agreement
46
+
47
+ These are the preferences a repository records, under `## Working agreement` in its policy:
48
+
49
+ - who works here and who approves: solo, or a team and its reviewer;
50
+ - the default stopping point: local change, pull request, merge, or deployment;
51
+ - the default path for a new feature: deliver directly, spec first, or intent, spec, and plan;
52
+ - where delivery units live: `plan.md` or a tracker;
53
+ - the language of commits, docs, and issues;
54
+ - with the frontend module active, whether interfaces are sketched before they are built and, if
55
+ so, in which medium and where the sketches live, recommending a workshop the repository already
56
+ has and `html` otherwise.
57
+
58
+ Ask them in at most two rounds of at most four questions, through the host's structured question
59
+ tool when it has one. Each question leads with its recommended answer and states the consequence of
60
+ choosing differently. "Use your recommendations for the rest" is always an available answer and
61
+ holds for the whole run: an evidence-backed recommendation counts as confirmed, including on later
62
+ fact questions, and a fact with no evidence goes under **Open setup questions** without being asked.
63
+ An answer that settles a core field is written once.
64
+
65
+ ### First run
66
+
67
+ 1. Inspect broadly before asking: instruction and policy surfaces, README and docs, package/build
68
+ files, test and CI configuration, and evidence of conditional areas. Before writing, every live
69
+ host-consumed policy surface must have unambiguous ownership and precedence. Shared identical
70
+ content or a clear canonical cross-reference is sufficient; do not select one file while
71
+ conflicting applicable rules remain elsewhere. If target ownership cannot be resolved, ask one
72
+ ownership question and block the write.
73
+ 2. Maintain a transient completeness ledger while working. Every applicable material field ends as
74
+ repository-evidenced or confirmed, `N/A`, explicitly deferred/open, or conflicting. Do not
75
+ guess through a conflict, and do not write the ledger or interview history to the policy.
76
+ 3. Before writing, each mandatory core field must reach one allowed terminal state: repository-
77
+ evidenced or confirmed, `N/A`, explicitly deferred/open, or conflicting. The core covers policy
78
+ ownership and canonical instruction surface; delivery boundary, stopping point, and external
79
+ effects; verification and ground truth, including when commands are insufficient; coherent
80
+ planning identities, claims, handoffs, readiness, epic ownership, and dependencies; and
81
+ maintenance of durable lessons and gotchas. Only
82
+ an unresolved policy ownership/write-target conflict blocks writing; other explicit deferrals
83
+ may be written concisely under **Open setup questions**.
84
+ 4. Activate only conditional modules supported by repository evidence: frontend/design/rendered QA;
85
+ package/release/docs; CI/deploy; auth/security/billing/external writes; database/migration/
86
+ concurrency; batch/monorepo; and native/desktop. Omit inactive modules from the output.
87
+ 5. Before the first question, say in a few plain lines what you found and what you are about to ask.
88
+ Ask the working agreement. Then ask only unresolved material fact questions, one at a time, with
89
+ a recommendation and consequence. Explicit deferral is an answer: record it under **Open setup
90
+ questions** without inventing a default. Do not ask feature-specific outcome, acceptance, or
91
+ UI-product questions.
92
+ 6. Write only durable behavior-changing defaults and relevant sections to the resolved existing
93
+ instruction surface. When none exists, write a new `policy.md`, plus a `CLAUDE.md` holding
94
+ `@policy.md` and an `AGENTS.md` that says to read it, so the hosts load it. Preserve unrelated
95
+ instructions, show the resulting diff, and do not request a second approval for this setup write.
96
+ 7. Write the Agent OS repository files the reference lists: `.agent-os/guards.json`,
97
+ `.agent-os/quality.json`, `REVIEW.md`, and, for GitHub Actions repositories, the `lint-intents` and `agent-review` workflows. Propose a
98
+ `CODEOWNERS` entry for intents and specs without writing it.
99
+ 8. Close with how you will work here, in at most six plain lines, and one recommended first action.
100
+
101
+ ### Return run
102
+
103
+ A return run adjusts a setup; it never repeats the interview.
104
+
105
+ 1. Inspect as in the first run, and resolve policy ownership the same way.
106
+ 2. Show a short plain-language summary of what is set today: working agreement, delivery,
107
+ verification, and planning. Under it, flag only what needs attention: drift where the policy
108
+ contradicts the repository, such as a command that no longer exists; any core field, working
109
+ agreement item, or active module the policy does not cover; and **Open setup questions**.
110
+ 3. Ask one question: what do you want to change? Offer working agreement, delivery, verification,
111
+ planning, and what the summary flagged, plus "nothing, this was a check".
112
+ 4. Ask only about the chosen areas, under the first run's question rules.
113
+ 5. Write only the chosen areas and show the diff; everything else stays byte for byte. Agent OS
114
+ repository files change only when a chosen area needs it. "Nothing" writes nothing and leaves any
115
+ flagged drift reported.
116
+ 6. Close with what changed, what stays flagged, and one recommended next action when one remains.
117
+
118
+ Block handling remains deterministic: add one missing block, update only well-formed managed content,
119
+ and stop on duplicate or malformed markers. Global mode touches no repository files; repo mode
120
+ touches one repository. The direct request or recorded delivery defaults govern merge and deploy
121
+ actions.
@@ -0,0 +1,88 @@
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 such as `capture-intent`, `plan-work`,
42
+ `explain-work`, `record-lesson`, and `list-skills` run only when invoked through the name the host
43
+ exposes (`/plan-work` for direct Claude skills, `/agent-os-core:plan-work` for the Claude plugin,
44
+ or `$plan-work` for Codex). Never self-invoke them or any other manual agent-os skill. Planning
45
+ depth is chosen internally by plan-work, and its use does not add a general summary approval gate.
46
+ Planning alone never starts implementation.
47
+ - Always recommend one concrete next action when planning or a delivery unit ends, with the reason
48
+ it wins and any blocker. Existing authority persists across unit boundaries, but never expands to
49
+ unrelated backlog work. If the goal is complete and no useful next action remains, say so instead
50
+ of manufacturing work.
51
+ - Scope has two independent axes: classify discoveries as required, adjacent, or unrelated to the
52
+ mission, then classify the work as covered by the existing mandate or requiring a new decision or
53
+ external action. Risk guides implementation and verification and can reveal a missing decision;
54
+ risk-area membership does not grant permission. Required covered work normally stays in scope,
55
+ while adjacent work is a follow-up and unrelated work gets no invented proposal.
56
+ - No skill grants external tracker write access automatically. An explicit tracker mandate in the
57
+ request or the project policy's `## Tracker mandate` section may include implementation detail and
58
+ technical ordering/readiness inside the authorized set, but not acceptance changes, new owners or
59
+ deliveries, or closure. Without that mandate, keep corrections local and report the unsynced delta.
60
+ - Decisions that outlive a session live in versioned files: `intents/<id>/intent.md` for what is
61
+ needed and why, and `spec.md` beside it for behavior, interface, boundaries, decisions, and
62
+ ground truth. They change only through a reviewed change, and a file whose `built_on` revision
63
+ is older than its source is stale until it is reconsidered.
64
+
65
+ ## Preferences (seed defaults; project policy overrides)
66
+
67
+ - UI feedback under ~250 ms; feedback must not block the next interaction.
68
+ - Own design identity; do not imitate the look of well-known apps.
69
+ - Every repo keeps a living project policy (planning surface, design system location, verify
70
+ commands, conventions, gotchas, and delivery defaults). It grows over time; `init-agent-os`
71
+ seeds it and `record-lesson` grows it.
72
+
73
+ ## Development workflows
74
+
75
+ - Use the Git identity configured by the repository or current session. Never add AI attribution or `Co-Authored-By` trailers.
76
+ - The development skills `design-work`, `shape-work`, `deliver-work`, `batch-work`, `dispatch-next`,
77
+ `simplify`, and `init-agent-os` are manual too (`/agent-os-dev:deliver-work` for the Claude
78
+ plugin). Existing authority may continue into the workflow a skill's exit contract names, as
79
+ `plan-work` does into `design-work`. Continuing sequentially
80
+ through already shaped units is allowed when the active implementation request covers that bounded
81
+ set; parallel batch execution still requires explicit selection. The automatic `check-work` review
82
+ workflow is also available from supported implicit review requests; its report mode is read-only
83
+ and its fix mode requires explicit authority.
84
+ - `plan.md` beside a spec lists delivery units and dependencies only. Delivery status is never
85
+ written into it: a unit is claimed by a draft pull request whose body carries
86
+ `Intent-Unit: <intent-id>/<unit-key>`, and status is read from open and merged pull requests.
87
+ - Agent OS hooks read `.agent-os/guards.json`. A hook block is a boundary, not an obstacle: change
88
+ course or ask, and never work around it by another tool or path.
@@ -0,0 +1,39 @@
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"],
13
+ "secretScan": true
14
+ }
15
+ ```
16
+
17
+ - `protectedPaths`: globs relative to the repository root. An agent edit to a matching path is
18
+ blocked with a message asking the agent to get the developer's explicit go-ahead. `*` matches within
19
+ one path segment and `**` across segments.
20
+ - `frozen`: globs for accepted intent and spec files. While a quality-ratchet delivery baseline is
21
+ active in the session, an edit to a matching file whose frontmatter `status` is `accepted` is
22
+ blocked, because delivery never changes the decisions it delivers. Planning sessions, which have no
23
+ delivery baseline, can still change them through a review.
24
+ - `secretScan`: when `true`, a `git commit` run by the agent is blocked if the staged diff adds a
25
+ line that looks like a private key, a cloud or provider access key, or an assignment of a long
26
+ literal to a name such as `password`, `secret`, `token`, or `api_key`. A false positive is resolved
27
+ by the developer, not by rewording the secret.
28
+
29
+ The guards cover the agent's file-edit tools (Edit, Write, MultiEdit, NotebookEdit, and Codex
30
+ `apply_patch`) and `git commit`. They do not inspect other shell commands, so a shell redirect into
31
+ a protected path is not caught; they reduce mistakes and are not a sandbox. Paths compare without
32
+ case on Windows and macOS. A malformed `guards.json` blocks every edit except the one that repairs it.
33
+
34
+ Locked tests are not configured here. `diagnose-before-fix` locks one with
35
+ `node <quality-ratchet>/scripts/guards.mjs lock-test <path>` after committing it and unlocks it with
36
+ `unlock-test <path>` once the fix passes. Locks live in the Git directory and are never committed.
37
+
38
+ The delivery ground truth belongs in `.agent-os/quality.json` as a `required` check, where the
39
+ quality-ratchet Stop hook enforces it after the developer has trusted the repository's controls.