@sockulags/agent-os 0.9.1 → 0.11.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.
- package/README.md +65 -48
- package/cli/index.mjs +735 -735
- package/cli/index.test.mjs +300 -300
- package/package.json +32 -31
- package/policy.md +6 -6
- package/skills/deliver-work/workflow.md +7 -3
- package/skills/init-agent-os/SKILL.md +2 -2
- package/skills/init-agent-os/scripts/policy-block.ps1 +87 -87
- package/skills/list-skills/SKILL.md +42 -0
- package/skills/list-skills/agents/openai.yaml +2 -0
- package/skills/proportional-testing/SKILL.md +30 -0
- package/skills/proportional-testing/references/strategy.md +75 -0
- package/skills/simplifier/SKILL.md +34 -0
- package/skills/simplifier/agents/openai.yaml +2 -0
- package/skills/simplifier-audit/SKILL.md +28 -0
- package/skills/simplifier-audit/agents/openai.yaml +2 -0
- package/skills/simplifier-review/SKILL.md +29 -0
package/cli/index.test.mjs
CHANGED
|
@@ -1,300 +1,300 @@
|
|
|
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, { after } from 'node:test'
|
|
6
|
-
import {
|
|
7
|
-
buildPlan,
|
|
8
|
-
executeInstall,
|
|
9
|
-
INSTALL_MANIFEST,
|
|
10
|
-
PACKAGE_NAME,
|
|
11
|
-
parseArgs,
|
|
12
|
-
planPolicyUpdate,
|
|
13
|
-
resolveOptions,
|
|
14
|
-
run,
|
|
15
|
-
targetSkillRoot,
|
|
16
|
-
VERSION
|
|
17
|
-
} from './index.mjs'
|
|
18
|
-
|
|
19
|
-
const temporaryRoots = []
|
|
20
|
-
|
|
21
|
-
function temporaryRoot() {
|
|
22
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-os-cli-'))
|
|
23
|
-
temporaryRoots.push(root)
|
|
24
|
-
return root
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function silentOutput() {
|
|
28
|
-
return { write() {} }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
after(() => {
|
|
32
|
-
for (const root of temporaryRoots) fs.rmSync(root, { recursive: true, force: true })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test('defaults to guided direct install', () => {
|
|
36
|
-
assert.deepEqual(parseArgs([]), {
|
|
37
|
-
command: 'install',
|
|
38
|
-
platform: null,
|
|
39
|
-
method: null,
|
|
40
|
-
scope: null,
|
|
41
|
-
policy: null,
|
|
42
|
-
yes: false,
|
|
43
|
-
dryRun: false,
|
|
44
|
-
help: false,
|
|
45
|
-
version: false
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('parses non-interactive direct update flags', () => {
|
|
50
|
-
assert.deepEqual(parseArgs([
|
|
51
|
-
'update',
|
|
52
|
-
'--platform=both',
|
|
53
|
-
'--method',
|
|
54
|
-
'direct',
|
|
55
|
-
'--scope',
|
|
56
|
-
'project',
|
|
57
|
-
'--no-policy',
|
|
58
|
-
'--yes'
|
|
59
|
-
]), {
|
|
60
|
-
command: 'update',
|
|
61
|
-
platform: 'both',
|
|
62
|
-
method: 'direct',
|
|
63
|
-
scope: 'project',
|
|
64
|
-
policy: false,
|
|
65
|
-
yes: true,
|
|
66
|
-
dryRun: false,
|
|
67
|
-
help: false,
|
|
68
|
-
version: false
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('supports Claude Code as a platform alias and upgrade as update', () => {
|
|
73
|
-
assert.deepEqual(parseArgs(['upgrade', '--platform', 'claude-code', '--yes']), {
|
|
74
|
-
command: 'update',
|
|
75
|
-
platform: 'claude',
|
|
76
|
-
method: null,
|
|
77
|
-
scope: null,
|
|
78
|
-
policy: null,
|
|
79
|
-
yes: true,
|
|
80
|
-
dryRun: false,
|
|
81
|
-
help: false,
|
|
82
|
-
version: false
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
test('prints scoped npm commands and explains the direct default', async () => {
|
|
87
|
-
const chunks = []
|
|
88
|
-
await run(['--help'], { output: { write: (chunk) => chunks.push(chunk) } })
|
|
89
|
-
const help = chunks.join('')
|
|
90
|
-
assert.match(help, /npx @sockulags\/agent-os install/)
|
|
91
|
-
assert.match(help, /does not require Codex or Claude Code CLI/)
|
|
92
|
-
assert.match(help, /--method <name>\s+direct \(default\) or plugin/)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test('rejects conflicting policy flags and direct local scope', async () => {
|
|
96
|
-
assert.throws(() => parseArgs(['install', '--policy', '--no-policy']), /one of --policy and --no-policy/)
|
|
97
|
-
await assert.rejects(
|
|
98
|
-
resolveOptions(parseArgs([
|
|
99
|
-
'install', '--platform', 'codex', '--method', 'direct', '--scope', 'local', '--yes'
|
|
100
|
-
]), { input: { isTTY: false }, output: { isTTY: false } }),
|
|
101
|
-
/Local scope is available only with --method plugin/
|
|
102
|
-
)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
test('requires explicit non-interactive choices', async () => {
|
|
106
|
-
await assert.rejects(
|
|
107
|
-
resolveOptions(parseArgs(['install']), {
|
|
108
|
-
input: { isTTY: false },
|
|
109
|
-
output: { isTTY: false }
|
|
110
|
-
}),
|
|
111
|
-
/--yes with explicit options/
|
|
112
|
-
)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('builds direct filesystem plans without marketplace commands', () => {
|
|
116
|
-
const root = temporaryRoot()
|
|
117
|
-
const plan = buildPlan({
|
|
118
|
-
command: 'install',
|
|
119
|
-
platform: 'both',
|
|
120
|
-
method: 'direct',
|
|
121
|
-
scope: 'user',
|
|
122
|
-
policy: false
|
|
123
|
-
}, { homeDir: root, cwd: root })
|
|
124
|
-
assert.deepEqual(plan.map((step) => step.kind), ['install-skills', 'install-skills'])
|
|
125
|
-
assert.deepEqual(plan.map((step) => step.command), ['filesystem', 'filesystem'])
|
|
126
|
-
assert.equal(plan[0].args[0], path.join(root, '.claude', 'skills'))
|
|
127
|
-
assert.equal(plan[1].args[0], path.join(root, '.codex', 'skills'))
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
test('maps project and user targets for both hosts', () => {
|
|
131
|
-
const root = temporaryRoot()
|
|
132
|
-
const project = path.join(root, 'project')
|
|
133
|
-
assert.equal(targetSkillRoot('codex', 'user', { homeDir: root, cwd: project }), path.join(root, '.codex', 'skills'))
|
|
134
|
-
assert.equal(targetSkillRoot('claude', 'user', { homeDir: root, cwd: project }), path.join(root, '.claude', 'skills'))
|
|
135
|
-
assert.equal(targetSkillRoot('codex', 'project', { homeDir: root, cwd: project }), path.join(project, '.agents', 'skills'))
|
|
136
|
-
assert.equal(targetSkillRoot('claude', 'project', { homeDir: root, cwd: project }), path.join(project, '.claude', 'skills'))
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test('installs both hosts and policy without either host CLI', async () => {
|
|
140
|
-
const root = temporaryRoot()
|
|
141
|
-
const homeDir = path.join(root, 'home')
|
|
142
|
-
const cwd = path.join(root, 'project')
|
|
143
|
-
await executeInstall({
|
|
144
|
-
command: 'install',
|
|
145
|
-
platform: 'both',
|
|
146
|
-
method: 'direct',
|
|
147
|
-
scope: 'user',
|
|
148
|
-
policy: true
|
|
149
|
-
}, {
|
|
150
|
-
output: silentOutput(),
|
|
151
|
-
homeDir,
|
|
152
|
-
cwd,
|
|
153
|
-
exists: () => { throw new Error('host CLI lookup must not run') },
|
|
154
|
-
execute: () => { throw new Error('external command must not run') }
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
for (const agent of ['.claude', '.codex']) {
|
|
158
|
-
const skillsRoot = path.join(homeDir, agent, 'skills')
|
|
159
|
-
assert.equal(fs.existsSync(path.join(skillsRoot, 'shape-work', 'SKILL.md')), true)
|
|
160
|
-
const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, INSTALL_MANIFEST), 'utf8'))
|
|
161
|
-
assert.equal(manifest.package, PACKAGE_NAME)
|
|
162
|
-
assert.equal(manifest.version, VERSION)
|
|
163
|
-
assert.ok(manifest.skills.includes('shape-work'))
|
|
164
|
-
}
|
|
165
|
-
assert.match(fs.readFileSync(path.join(homeDir, '.claude', 'CLAUDE.md'), 'utf8'), /BEGIN AGENT OS/)
|
|
166
|
-
assert.match(fs.readFileSync(path.join(homeDir, '.codex', 'AGENTS.md'), 'utf8'), /BEGIN AGENT OS/)
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
test('updates only managed skills and preserves unrelated skills', async () => {
|
|
170
|
-
const root = temporaryRoot()
|
|
171
|
-
const homeDir = path.join(root, 'home')
|
|
172
|
-
const options = {
|
|
173
|
-
command: 'install',
|
|
174
|
-
platform: 'codex',
|
|
175
|
-
method: 'direct',
|
|
176
|
-
scope: 'user',
|
|
177
|
-
policy: false
|
|
178
|
-
}
|
|
179
|
-
await executeInstall(options, { output: silentOutput(), homeDir, cwd: root })
|
|
180
|
-
|
|
181
|
-
const skillsRoot = path.join(homeDir, '.codex', 'skills')
|
|
182
|
-
const managedFile = path.join(skillsRoot, 'shape-work', 'SKILL.md')
|
|
183
|
-
const foreignFile = path.join(skillsRoot, 'my-private-skill', 'SKILL.md')
|
|
184
|
-
fs.writeFileSync(managedFile, 'stale managed content\n')
|
|
185
|
-
fs.mkdirSync(path.dirname(foreignFile), { recursive: true })
|
|
186
|
-
fs.writeFileSync(foreignFile, 'private content\n')
|
|
187
|
-
|
|
188
|
-
await executeInstall({ ...options, command: 'update' }, { output: silentOutput(), homeDir, cwd: root })
|
|
189
|
-
assert.notEqual(fs.readFileSync(managedFile, 'utf8'), 'stale managed content\n')
|
|
190
|
-
assert.equal(fs.readFileSync(foreignFile, 'utf8'), 'private content\n')
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
test('refuses to overwrite a same-name skill without an Agent OS manifest', async () => {
|
|
194
|
-
const root = temporaryRoot()
|
|
195
|
-
const homeDir = path.join(root, 'home')
|
|
196
|
-
const collision = path.join(homeDir, '.codex', 'skills', 'shape-work', 'SKILL.md')
|
|
197
|
-
fs.mkdirSync(path.dirname(collision), { recursive: true })
|
|
198
|
-
fs.writeFileSync(collision, 'developer-owned\n')
|
|
199
|
-
|
|
200
|
-
await assert.rejects(
|
|
201
|
-
executeInstall({
|
|
202
|
-
command: 'install',
|
|
203
|
-
platform: 'codex',
|
|
204
|
-
method: 'direct',
|
|
205
|
-
scope: 'user',
|
|
206
|
-
policy: false
|
|
207
|
-
}, { output: silentOutput(), homeDir, cwd: root }),
|
|
208
|
-
/Refusing to overwrite unmanaged skills.*shape-work/
|
|
209
|
-
)
|
|
210
|
-
assert.equal(fs.readFileSync(collision, 'utf8'), 'developer-owned\n')
|
|
211
|
-
assert.equal(fs.existsSync(path.join(homeDir, '.codex', 'skills', INSTALL_MANIFEST)), false)
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
test('policy planning preserves surrounding text and rejects malformed markers', () => {
|
|
215
|
-
const policy = '# Policy\n'
|
|
216
|
-
const original = 'before\n\n<!-- BEGIN AGENT OS -->\nold\n<!-- END AGENT OS -->\nafter\n'
|
|
217
|
-
const updated = planPolicyUpdate(original, policy)
|
|
218
|
-
assert.equal(updated.status, 'UPDATED')
|
|
219
|
-
assert.equal(updated.content, 'before\n\n<!-- BEGIN AGENT OS -->\n# Policy\n<!-- END AGENT OS -->\nafter\n')
|
|
220
|
-
assert.throws(
|
|
221
|
-
() => planPolicyUpdate('<!-- BEGIN AGENT OS -->\nbroken\n', policy),
|
|
222
|
-
/Malformed Agent OS policy markers/
|
|
223
|
-
)
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
test('malformed policy markers abort before direct skill installation', async () => {
|
|
227
|
-
const root = temporaryRoot()
|
|
228
|
-
const homeDir = path.join(root, 'home')
|
|
229
|
-
const target = path.join(homeDir, '.codex', 'AGENTS.md')
|
|
230
|
-
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
231
|
-
fs.writeFileSync(target, '<!-- BEGIN AGENT OS -->\nbroken\n')
|
|
232
|
-
|
|
233
|
-
await assert.rejects(
|
|
234
|
-
executeInstall({
|
|
235
|
-
command: 'install',
|
|
236
|
-
platform: 'codex',
|
|
237
|
-
method: 'direct',
|
|
238
|
-
scope: 'user',
|
|
239
|
-
policy: true
|
|
240
|
-
}, { output: silentOutput(), homeDir, cwd: root }),
|
|
241
|
-
/Malformed Agent OS policy markers/
|
|
242
|
-
)
|
|
243
|
-
assert.equal(fs.existsSync(path.join(homeDir, '.codex', 'skills')), false)
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
test('plugin mode still requires only the selected host CLI', async () => {
|
|
247
|
-
const calls = []
|
|
248
|
-
await assert.rejects(
|
|
249
|
-
executeInstall({
|
|
250
|
-
command: 'install',
|
|
251
|
-
platform: 'codex',
|
|
252
|
-
method: 'plugin',
|
|
253
|
-
scope: 'user',
|
|
254
|
-
policy: false
|
|
255
|
-
}, {
|
|
256
|
-
output: silentOutput(),
|
|
257
|
-
exists: () => false,
|
|
258
|
-
execute: (...args) => calls.push(args)
|
|
259
|
-
}),
|
|
260
|
-
/Native plugin mode requires the selected host CLIs.*Codex/s
|
|
261
|
-
)
|
|
262
|
-
assert.deepEqual(calls, [])
|
|
263
|
-
})
|
|
264
|
-
|
|
265
|
-
test('plugin update skips Git refresh for a registered local Codex marketplace', async () => {
|
|
266
|
-
const calls = []
|
|
267
|
-
await executeInstall({
|
|
268
|
-
command: 'update',
|
|
269
|
-
platform: 'codex',
|
|
270
|
-
method: 'plugin',
|
|
271
|
-
scope: 'user',
|
|
272
|
-
policy: false
|
|
273
|
-
}, {
|
|
274
|
-
output: silentOutput(),
|
|
275
|
-
exists: () => true,
|
|
276
|
-
execute: (command, args) => {
|
|
277
|
-
calls.push([command, args])
|
|
278
|
-
if (args.join(' ') === 'plugin marketplace list --json') {
|
|
279
|
-
return { status: 0, stdout: JSON.stringify({ marketplaces: [{ name: 'agent-os' }] }), stderr: '' }
|
|
280
|
-
}
|
|
281
|
-
if (args.join(' ') === 'plugin list --json') {
|
|
282
|
-
return {
|
|
283
|
-
status: 0,
|
|
284
|
-
stdout: JSON.stringify({ installed: [{
|
|
285
|
-
marketplaceName: 'agent-os',
|
|
286
|
-
marketplaceSource: { sourceType: 'local' }
|
|
287
|
-
}] }),
|
|
288
|
-
stderr: ''
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return { status: 0, stdout: '', stderr: '' }
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
assert.deepEqual(calls.map((call) => call[1]), [
|
|
296
|
-
['plugin', 'marketplace', 'list', '--json'],
|
|
297
|
-
['plugin', 'list', '--json'],
|
|
298
|
-
['plugin', 'add', 'agent-os@agent-os']
|
|
299
|
-
])
|
|
300
|
-
})
|
|
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, { after } from 'node:test'
|
|
6
|
+
import {
|
|
7
|
+
buildPlan,
|
|
8
|
+
executeInstall,
|
|
9
|
+
INSTALL_MANIFEST,
|
|
10
|
+
PACKAGE_NAME,
|
|
11
|
+
parseArgs,
|
|
12
|
+
planPolicyUpdate,
|
|
13
|
+
resolveOptions,
|
|
14
|
+
run,
|
|
15
|
+
targetSkillRoot,
|
|
16
|
+
VERSION
|
|
17
|
+
} from './index.mjs'
|
|
18
|
+
|
|
19
|
+
const temporaryRoots = []
|
|
20
|
+
|
|
21
|
+
function temporaryRoot() {
|
|
22
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-os-cli-'))
|
|
23
|
+
temporaryRoots.push(root)
|
|
24
|
+
return root
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function silentOutput() {
|
|
28
|
+
return { write() {} }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
after(() => {
|
|
32
|
+
for (const root of temporaryRoots) fs.rmSync(root, { recursive: true, force: true })
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('defaults to guided direct install', () => {
|
|
36
|
+
assert.deepEqual(parseArgs([]), {
|
|
37
|
+
command: 'install',
|
|
38
|
+
platform: null,
|
|
39
|
+
method: null,
|
|
40
|
+
scope: null,
|
|
41
|
+
policy: null,
|
|
42
|
+
yes: false,
|
|
43
|
+
dryRun: false,
|
|
44
|
+
help: false,
|
|
45
|
+
version: false
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test('parses non-interactive direct update flags', () => {
|
|
50
|
+
assert.deepEqual(parseArgs([
|
|
51
|
+
'update',
|
|
52
|
+
'--platform=both',
|
|
53
|
+
'--method',
|
|
54
|
+
'direct',
|
|
55
|
+
'--scope',
|
|
56
|
+
'project',
|
|
57
|
+
'--no-policy',
|
|
58
|
+
'--yes'
|
|
59
|
+
]), {
|
|
60
|
+
command: 'update',
|
|
61
|
+
platform: 'both',
|
|
62
|
+
method: 'direct',
|
|
63
|
+
scope: 'project',
|
|
64
|
+
policy: false,
|
|
65
|
+
yes: true,
|
|
66
|
+
dryRun: false,
|
|
67
|
+
help: false,
|
|
68
|
+
version: false
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('supports Claude Code as a platform alias and upgrade as update', () => {
|
|
73
|
+
assert.deepEqual(parseArgs(['upgrade', '--platform', 'claude-code', '--yes']), {
|
|
74
|
+
command: 'update',
|
|
75
|
+
platform: 'claude',
|
|
76
|
+
method: null,
|
|
77
|
+
scope: null,
|
|
78
|
+
policy: null,
|
|
79
|
+
yes: true,
|
|
80
|
+
dryRun: false,
|
|
81
|
+
help: false,
|
|
82
|
+
version: false
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('prints scoped npm commands and explains the direct default', async () => {
|
|
87
|
+
const chunks = []
|
|
88
|
+
await run(['--help'], { output: { write: (chunk) => chunks.push(chunk) } })
|
|
89
|
+
const help = chunks.join('')
|
|
90
|
+
assert.match(help, /npx @sockulags\/agent-os install/)
|
|
91
|
+
assert.match(help, /does not require Codex or Claude Code CLI/)
|
|
92
|
+
assert.match(help, /--method <name>\s+direct \(default\) or plugin/)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('rejects conflicting policy flags and direct local scope', async () => {
|
|
96
|
+
assert.throws(() => parseArgs(['install', '--policy', '--no-policy']), /one of --policy and --no-policy/)
|
|
97
|
+
await assert.rejects(
|
|
98
|
+
resolveOptions(parseArgs([
|
|
99
|
+
'install', '--platform', 'codex', '--method', 'direct', '--scope', 'local', '--yes'
|
|
100
|
+
]), { input: { isTTY: false }, output: { isTTY: false } }),
|
|
101
|
+
/Local scope is available only with --method plugin/
|
|
102
|
+
)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('requires explicit non-interactive choices', async () => {
|
|
106
|
+
await assert.rejects(
|
|
107
|
+
resolveOptions(parseArgs(['install']), {
|
|
108
|
+
input: { isTTY: false },
|
|
109
|
+
output: { isTTY: false }
|
|
110
|
+
}),
|
|
111
|
+
/--yes with explicit options/
|
|
112
|
+
)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('builds direct filesystem plans without marketplace commands', () => {
|
|
116
|
+
const root = temporaryRoot()
|
|
117
|
+
const plan = buildPlan({
|
|
118
|
+
command: 'install',
|
|
119
|
+
platform: 'both',
|
|
120
|
+
method: 'direct',
|
|
121
|
+
scope: 'user',
|
|
122
|
+
policy: false
|
|
123
|
+
}, { homeDir: root, cwd: root })
|
|
124
|
+
assert.deepEqual(plan.map((step) => step.kind), ['install-skills', 'install-skills'])
|
|
125
|
+
assert.deepEqual(plan.map((step) => step.command), ['filesystem', 'filesystem'])
|
|
126
|
+
assert.equal(plan[0].args[0], path.join(root, '.claude', 'skills'))
|
|
127
|
+
assert.equal(plan[1].args[0], path.join(root, '.codex', 'skills'))
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
test('maps project and user targets for both hosts', () => {
|
|
131
|
+
const root = temporaryRoot()
|
|
132
|
+
const project = path.join(root, 'project')
|
|
133
|
+
assert.equal(targetSkillRoot('codex', 'user', { homeDir: root, cwd: project }), path.join(root, '.codex', 'skills'))
|
|
134
|
+
assert.equal(targetSkillRoot('claude', 'user', { homeDir: root, cwd: project }), path.join(root, '.claude', 'skills'))
|
|
135
|
+
assert.equal(targetSkillRoot('codex', 'project', { homeDir: root, cwd: project }), path.join(project, '.agents', 'skills'))
|
|
136
|
+
assert.equal(targetSkillRoot('claude', 'project', { homeDir: root, cwd: project }), path.join(project, '.claude', 'skills'))
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
test('installs both hosts and policy without either host CLI', async () => {
|
|
140
|
+
const root = temporaryRoot()
|
|
141
|
+
const homeDir = path.join(root, 'home')
|
|
142
|
+
const cwd = path.join(root, 'project')
|
|
143
|
+
await executeInstall({
|
|
144
|
+
command: 'install',
|
|
145
|
+
platform: 'both',
|
|
146
|
+
method: 'direct',
|
|
147
|
+
scope: 'user',
|
|
148
|
+
policy: true
|
|
149
|
+
}, {
|
|
150
|
+
output: silentOutput(),
|
|
151
|
+
homeDir,
|
|
152
|
+
cwd,
|
|
153
|
+
exists: () => { throw new Error('host CLI lookup must not run') },
|
|
154
|
+
execute: () => { throw new Error('external command must not run') }
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
for (const agent of ['.claude', '.codex']) {
|
|
158
|
+
const skillsRoot = path.join(homeDir, agent, 'skills')
|
|
159
|
+
assert.equal(fs.existsSync(path.join(skillsRoot, 'shape-work', 'SKILL.md')), true)
|
|
160
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, INSTALL_MANIFEST), 'utf8'))
|
|
161
|
+
assert.equal(manifest.package, PACKAGE_NAME)
|
|
162
|
+
assert.equal(manifest.version, VERSION)
|
|
163
|
+
assert.ok(manifest.skills.includes('shape-work'))
|
|
164
|
+
}
|
|
165
|
+
assert.match(fs.readFileSync(path.join(homeDir, '.claude', 'CLAUDE.md'), 'utf8'), /BEGIN AGENT OS/)
|
|
166
|
+
assert.match(fs.readFileSync(path.join(homeDir, '.codex', 'AGENTS.md'), 'utf8'), /BEGIN AGENT OS/)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
test('updates only managed skills and preserves unrelated skills', async () => {
|
|
170
|
+
const root = temporaryRoot()
|
|
171
|
+
const homeDir = path.join(root, 'home')
|
|
172
|
+
const options = {
|
|
173
|
+
command: 'install',
|
|
174
|
+
platform: 'codex',
|
|
175
|
+
method: 'direct',
|
|
176
|
+
scope: 'user',
|
|
177
|
+
policy: false
|
|
178
|
+
}
|
|
179
|
+
await executeInstall(options, { output: silentOutput(), homeDir, cwd: root })
|
|
180
|
+
|
|
181
|
+
const skillsRoot = path.join(homeDir, '.codex', 'skills')
|
|
182
|
+
const managedFile = path.join(skillsRoot, 'shape-work', 'SKILL.md')
|
|
183
|
+
const foreignFile = path.join(skillsRoot, 'my-private-skill', 'SKILL.md')
|
|
184
|
+
fs.writeFileSync(managedFile, 'stale managed content\n')
|
|
185
|
+
fs.mkdirSync(path.dirname(foreignFile), { recursive: true })
|
|
186
|
+
fs.writeFileSync(foreignFile, 'private content\n')
|
|
187
|
+
|
|
188
|
+
await executeInstall({ ...options, command: 'update' }, { output: silentOutput(), homeDir, cwd: root })
|
|
189
|
+
assert.notEqual(fs.readFileSync(managedFile, 'utf8'), 'stale managed content\n')
|
|
190
|
+
assert.equal(fs.readFileSync(foreignFile, 'utf8'), 'private content\n')
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
test('refuses to overwrite a same-name skill without an Agent OS manifest', async () => {
|
|
194
|
+
const root = temporaryRoot()
|
|
195
|
+
const homeDir = path.join(root, 'home')
|
|
196
|
+
const collision = path.join(homeDir, '.codex', 'skills', 'shape-work', 'SKILL.md')
|
|
197
|
+
fs.mkdirSync(path.dirname(collision), { recursive: true })
|
|
198
|
+
fs.writeFileSync(collision, 'developer-owned\n')
|
|
199
|
+
|
|
200
|
+
await assert.rejects(
|
|
201
|
+
executeInstall({
|
|
202
|
+
command: 'install',
|
|
203
|
+
platform: 'codex',
|
|
204
|
+
method: 'direct',
|
|
205
|
+
scope: 'user',
|
|
206
|
+
policy: false
|
|
207
|
+
}, { output: silentOutput(), homeDir, cwd: root }),
|
|
208
|
+
/Refusing to overwrite unmanaged skills.*shape-work/
|
|
209
|
+
)
|
|
210
|
+
assert.equal(fs.readFileSync(collision, 'utf8'), 'developer-owned\n')
|
|
211
|
+
assert.equal(fs.existsSync(path.join(homeDir, '.codex', 'skills', INSTALL_MANIFEST)), false)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
test('policy planning preserves surrounding text and rejects malformed markers', () => {
|
|
215
|
+
const policy = '# Policy\n'
|
|
216
|
+
const original = 'before\n\n<!-- BEGIN AGENT OS -->\nold\n<!-- END AGENT OS -->\nafter\n'
|
|
217
|
+
const updated = planPolicyUpdate(original, policy)
|
|
218
|
+
assert.equal(updated.status, 'UPDATED')
|
|
219
|
+
assert.equal(updated.content, 'before\n\n<!-- BEGIN AGENT OS -->\n# Policy\n<!-- END AGENT OS -->\nafter\n')
|
|
220
|
+
assert.throws(
|
|
221
|
+
() => planPolicyUpdate('<!-- BEGIN AGENT OS -->\nbroken\n', policy),
|
|
222
|
+
/Malformed Agent OS policy markers/
|
|
223
|
+
)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
test('malformed policy markers abort before direct skill installation', async () => {
|
|
227
|
+
const root = temporaryRoot()
|
|
228
|
+
const homeDir = path.join(root, 'home')
|
|
229
|
+
const target = path.join(homeDir, '.codex', 'AGENTS.md')
|
|
230
|
+
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
231
|
+
fs.writeFileSync(target, '<!-- BEGIN AGENT OS -->\nbroken\n')
|
|
232
|
+
|
|
233
|
+
await assert.rejects(
|
|
234
|
+
executeInstall({
|
|
235
|
+
command: 'install',
|
|
236
|
+
platform: 'codex',
|
|
237
|
+
method: 'direct',
|
|
238
|
+
scope: 'user',
|
|
239
|
+
policy: true
|
|
240
|
+
}, { output: silentOutput(), homeDir, cwd: root }),
|
|
241
|
+
/Malformed Agent OS policy markers/
|
|
242
|
+
)
|
|
243
|
+
assert.equal(fs.existsSync(path.join(homeDir, '.codex', 'skills')), false)
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
test('plugin mode still requires only the selected host CLI', async () => {
|
|
247
|
+
const calls = []
|
|
248
|
+
await assert.rejects(
|
|
249
|
+
executeInstall({
|
|
250
|
+
command: 'install',
|
|
251
|
+
platform: 'codex',
|
|
252
|
+
method: 'plugin',
|
|
253
|
+
scope: 'user',
|
|
254
|
+
policy: false
|
|
255
|
+
}, {
|
|
256
|
+
output: silentOutput(),
|
|
257
|
+
exists: () => false,
|
|
258
|
+
execute: (...args) => calls.push(args)
|
|
259
|
+
}),
|
|
260
|
+
/Native plugin mode requires the selected host CLIs.*Codex/s
|
|
261
|
+
)
|
|
262
|
+
assert.deepEqual(calls, [])
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
test('plugin update skips Git refresh for a registered local Codex marketplace', async () => {
|
|
266
|
+
const calls = []
|
|
267
|
+
await executeInstall({
|
|
268
|
+
command: 'update',
|
|
269
|
+
platform: 'codex',
|
|
270
|
+
method: 'plugin',
|
|
271
|
+
scope: 'user',
|
|
272
|
+
policy: false
|
|
273
|
+
}, {
|
|
274
|
+
output: silentOutput(),
|
|
275
|
+
exists: () => true,
|
|
276
|
+
execute: (command, args) => {
|
|
277
|
+
calls.push([command, args])
|
|
278
|
+
if (args.join(' ') === 'plugin marketplace list --json') {
|
|
279
|
+
return { status: 0, stdout: JSON.stringify({ marketplaces: [{ name: 'agent-os' }] }), stderr: '' }
|
|
280
|
+
}
|
|
281
|
+
if (args.join(' ') === 'plugin list --json') {
|
|
282
|
+
return {
|
|
283
|
+
status: 0,
|
|
284
|
+
stdout: JSON.stringify({ installed: [{
|
|
285
|
+
marketplaceName: 'agent-os',
|
|
286
|
+
marketplaceSource: { sourceType: 'local' }
|
|
287
|
+
}] }),
|
|
288
|
+
stderr: ''
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return { status: 0, stdout: '', stderr: '' }
|
|
292
|
+
}
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
assert.deepEqual(calls.map((call) => call[1]), [
|
|
296
|
+
['plugin', 'marketplace', 'list', '--json'],
|
|
297
|
+
['plugin', 'list', '--json'],
|
|
298
|
+
['plugin', 'add', 'agent-os@agent-os']
|
|
299
|
+
])
|
|
300
|
+
})
|
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sockulags/agent-os",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A lightweight personal agent operating system with an npx installer for Claude Code and Codex.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"agent-os": "./cli/index.mjs"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"cli/",
|
|
11
|
-
"policy.md",
|
|
12
|
-
"skills/"
|
|
13
|
-
],
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">=18.18"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "node --test cli/*.test.mjs",
|
|
19
|
-
"validate": "node scripts/validate-agent-os.mjs"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@sockulags/agent-os",
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "A lightweight personal agent operating system with an npx installer for Claude Code and Codex.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agent-os": "./cli/index.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"cli/",
|
|
11
|
+
"policy.md",
|
|
12
|
+
"skills/"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.18"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "node --test cli/*.test.mjs",
|
|
19
|
+
"validate": "node scripts/validate-agent-os.mjs",
|
|
20
|
+
"verify:release": "node scripts/verify-release.mjs"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"agent",
|
|
24
|
+
"claude-code",
|
|
25
|
+
"codex",
|
|
26
|
+
"workflow",
|
|
27
|
+
"skills",
|
|
28
|
+
"installer"
|
|
29
|
+
],
|
|
30
|
+
"homepage": "https://sockulags.github.io/agent-os/",
|
|
31
|
+
"repository": "https://github.com/sockulags/agent-os"
|
|
32
|
+
}
|