@atom63/cli 0.0.0-stage → 0.1.0-beta.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/LICENSE +27 -0
- package/README.md +88 -2
- package/generated/agent-index.json +32062 -0
- package/package.json +40 -3
- package/src/agents-md.mjs +77 -0
- package/src/bin.mjs +153 -0
- package/src/commands.mjs +172 -0
- package/src/core.mjs +502 -0
- package/src/format.mjs +232 -0
- package/src/mcp.mjs +72 -0
- package/src/rules.mjs +83 -0
- package/src/synonyms.mjs +497 -0
- package/src/templates.mjs +342 -0
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atom63/cli",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "Query the Atom63 design system from the command line or an MCP host: components, contracts, tokens, examples and docs",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/atom63/atom63-design-system.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"bin": {
|
|
13
|
+
"atom63": "./src/bin.mjs"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./src/core.mjs",
|
|
17
|
+
"./agents-md": "./src/agents-md.mjs",
|
|
18
|
+
"./agent-index.json": "./generated/agent-index.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"generated",
|
|
22
|
+
"src",
|
|
23
|
+
"!src/**/*.test.mjs"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@modelcontextprotocol/client": "2.3.1",
|
|
30
|
+
"vite": "8.3.4"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@modelcontextprotocol/server": "2.3.0",
|
|
34
|
+
"zod": "^4.6.5"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"generate:index": "node scripts/build-index.mjs",
|
|
38
|
+
"check:index": "node scripts/build-index.mjs --check",
|
|
39
|
+
"test": "node --test \"src/**/*.test.mjs\"",
|
|
40
|
+
"sync:agents-md": "node scripts/sync-agents-md.mjs",
|
|
41
|
+
"check:agents-md": "node scripts/sync-agents-md.mjs --check"
|
|
42
|
+
}
|
|
6
43
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AGENTS.md section for a project that builds UI with Atom63, generated
|
|
3
|
+
* from the rule table so `atom63 rules`, `atom63 agents` and every AGENTS.md
|
|
4
|
+
* that embeds the section say the same thing.
|
|
5
|
+
*/
|
|
6
|
+
import { rules } from './rules.mjs'
|
|
7
|
+
|
|
8
|
+
export const markers = {
|
|
9
|
+
start:
|
|
10
|
+
'<!-- atom63:agents:start — generated by `atom63 agents`; edit packages/cli/src/rules.mjs instead -->',
|
|
11
|
+
end: '<!-- atom63:agents:end -->',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const cliQueries = [
|
|
15
|
+
'Ask the design system before writing UI, and start each screen with `atom63 build <idea>`, the idea in your own words. The `atom63` CLI and its MCP server (`atom63 mcp`) answer from the same generated index as the packages:',
|
|
16
|
+
'',
|
|
17
|
+
'- `atom63 build <idea>`: a kit for what you are building: the closest page templates and blocks, the components they use, the foundation and the rules. For a phone screen it leads with `AppView layout="phone"` and a snippet to start from.',
|
|
18
|
+
'- `atom63 template <id>` and `atom63 copy <id> <dir>`: read a page or block template, then copy it and the blocks it uses into your project to adapt.',
|
|
19
|
+
'- `atom63 search <words>`: find a component, template, docs page, story example or token.',
|
|
20
|
+
'- `atom63 component <slug>`: the import line, contract (axes, defaults, slots, states, web and iOS), related components and examples.',
|
|
21
|
+
'- `atom63 example <slug> [story]`: a known-good usage sample to start from.',
|
|
22
|
+
'- `atom63 token <name or words>`: a token with its values per theme and mode, Figma path and Swift name.',
|
|
23
|
+
'- `atom63 rules`: the rules below, with their reasons.',
|
|
24
|
+
'',
|
|
25
|
+
'Add `--json` for a typed `{ type, data }` envelope. `atom63 manifest` lists every command and error code.',
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const docsQueries = [
|
|
29
|
+
'Ask the design system before writing UI. Its documentation is published for agents:',
|
|
30
|
+
'',
|
|
31
|
+
'- `https://system.atom63.io/llms.txt` lists every page with a one-line summary.',
|
|
32
|
+
'- Every page has a Markdown twin at its path plus `.md`, for example `https://system.atom63.io/components/component-dialog.md`. A component page gives the import line, the contract (axes, defaults, slots, states, web and iOS) and related components.',
|
|
33
|
+
'- Start each screen from the closest page or block template: `https://system.atom63.io/r/registry.json` lists them with a description each, and `npx shadcn add https://system.atom63.io/r/<id>.json` installs one with the blocks it uses.',
|
|
34
|
+
'- Start from a component that exists before writing markup of your own.',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `variant: 'cli'` points agents at the `atom63` CLI and MCP server; `'docs'`
|
|
39
|
+
* points them at the published docs, for projects that cannot run the CLI yet.
|
|
40
|
+
*/
|
|
41
|
+
export function agentsSection({ variant = 'cli' } = {}) {
|
|
42
|
+
const ruleLines = rules.map(
|
|
43
|
+
(rule, position) =>
|
|
44
|
+
`${position + 1}. ${rule.rule} ${rule.why}${
|
|
45
|
+
rule.check
|
|
46
|
+
? ` In the design system repo, \`check:craft\` enforces it as ${[rule.check]
|
|
47
|
+
.flat()
|
|
48
|
+
.map(check => `\`${check}\``)
|
|
49
|
+
.join(' and ')}.`
|
|
50
|
+
: ''
|
|
51
|
+
}`
|
|
52
|
+
)
|
|
53
|
+
return [
|
|
54
|
+
'## Building UI with Atom63',
|
|
55
|
+
'',
|
|
56
|
+
...(variant === 'docs' ? docsQueries : cliQueries),
|
|
57
|
+
'',
|
|
58
|
+
'### Rules',
|
|
59
|
+
'',
|
|
60
|
+
...ruleLines,
|
|
61
|
+
].join('\n')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The section wrapped in markers, ready to paste into or sync with an AGENTS.md. */
|
|
65
|
+
export function agentsBlock(options) {
|
|
66
|
+
return `${markers.start}\n\n${agentsSection(options)}\n\n${markers.end}`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Replace the marked block in an AGENTS.md; throws when the markers are missing. */
|
|
70
|
+
export function syncAgentsBlock(markdown) {
|
|
71
|
+
const start = markdown.indexOf('<!-- atom63:agents:start')
|
|
72
|
+
const end = markdown.indexOf(markers.end)
|
|
73
|
+
if (start === -1 || end === -1 || end < start) {
|
|
74
|
+
throw new Error('AGENTS.md has no atom63:agents block to update')
|
|
75
|
+
}
|
|
76
|
+
return markdown.slice(0, start) + agentsBlock() + markdown.slice(end + markers.end.length)
|
|
77
|
+
}
|
package/src/bin.mjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* atom63 — query the Atom63 design system.
|
|
4
|
+
*
|
|
5
|
+
* atom63 <command> [args] [--json]
|
|
6
|
+
* atom63 manifest every command, argument, flag and response type
|
|
7
|
+
* atom63 mcp serve the same commands as MCP tools over stdio
|
|
8
|
+
*
|
|
9
|
+
* Exit codes: 0 answered, 1 the query failed (unknown component, no match),
|
|
10
|
+
* 2 the command line was wrong. With --json every result, failures included,
|
|
11
|
+
* is one envelope on stdout, so a caller parses one stream and branches on
|
|
12
|
+
* `type` and, for errors, `code`.
|
|
13
|
+
*/
|
|
14
|
+
import { realpathSync } from 'node:fs'
|
|
15
|
+
import process from 'node:process'
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
import { parseArgs } from 'node:util'
|
|
18
|
+
|
|
19
|
+
import { commands } from './commands.mjs'
|
|
20
|
+
import { AtomError, loadIndex } from './core.mjs'
|
|
21
|
+
import { formatEnvelope } from './format.mjs'
|
|
22
|
+
|
|
23
|
+
export function runCli(argv) {
|
|
24
|
+
const [name, ...rest] = argv
|
|
25
|
+
const json = rest.includes('--json') || name === '--json'
|
|
26
|
+
|
|
27
|
+
const fail = (error, exitCode) => ({
|
|
28
|
+
exitCode,
|
|
29
|
+
json,
|
|
30
|
+
output: json ? JSON.stringify(error.toEnvelope(), null, 2) : formatEnvelope(error.toEnvelope()),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
if (!name || name === '--help' || name === '-h' || name === 'help' || name === '--json') {
|
|
34
|
+
return run(
|
|
35
|
+
commands.find(command => command.name === 'manifest'),
|
|
36
|
+
[],
|
|
37
|
+
json
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const command = commands.find(candidate => candidate.name === name)
|
|
42
|
+
if (!command) {
|
|
43
|
+
return fail(
|
|
44
|
+
new AtomError(
|
|
45
|
+
'usage.unknown_command',
|
|
46
|
+
`Unknown command "${name}".`,
|
|
47
|
+
commands.map(candidate => candidate.name)
|
|
48
|
+
),
|
|
49
|
+
2
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
return run(command, rest, json)
|
|
53
|
+
|
|
54
|
+
function run(chosen, rawArgs, asJson) {
|
|
55
|
+
// A CSS variable (`--a63-surface-page`) is an argument, not a flag. Flags
|
|
56
|
+
// are single words, so a dashed name that is not one of them is a value.
|
|
57
|
+
const flagNames = new Set(['json', ...chosen.flags.map(flag => flag.name)])
|
|
58
|
+
const variables = rawArgs.filter(
|
|
59
|
+
arg => /^--[a-z0-9]+-[a-z0-9-]+$/.test(arg) && !flagNames.has(arg.slice(2))
|
|
60
|
+
)
|
|
61
|
+
const args = [...rawArgs.filter(arg => !variables.includes(arg)), '--', ...variables]
|
|
62
|
+
let parsed
|
|
63
|
+
try {
|
|
64
|
+
parsed = parseArgs({
|
|
65
|
+
args,
|
|
66
|
+
allowPositionals: true,
|
|
67
|
+
options: {
|
|
68
|
+
json: { type: 'boolean', default: false },
|
|
69
|
+
...Object.fromEntries(
|
|
70
|
+
chosen.flags.map(flag => [
|
|
71
|
+
flag.name,
|
|
72
|
+
{ type: flag.type === 'boolean' ? 'boolean' : 'string' },
|
|
73
|
+
])
|
|
74
|
+
),
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return fail(new AtomError('usage.invalid_flag', error.message), 2)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const input = {}
|
|
82
|
+
const required = chosen.args.filter(arg => !arg.optional)
|
|
83
|
+
if (parsed.positionals.length < required.length) {
|
|
84
|
+
const missing = required[parsed.positionals.length]
|
|
85
|
+
return fail(
|
|
86
|
+
new AtomError(
|
|
87
|
+
'usage.missing_argument',
|
|
88
|
+
`atom63 ${chosen.name} needs <${missing.name}>: ${missing.description}`
|
|
89
|
+
),
|
|
90
|
+
2
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
// The last argument takes the rest, so `atom63 search date picker` works unquoted.
|
|
94
|
+
chosen.args.forEach((arg, position) => {
|
|
95
|
+
const isLast = position === chosen.args.length - 1
|
|
96
|
+
const value = isLast
|
|
97
|
+
? parsed.positionals.slice(position).join(' ')
|
|
98
|
+
: parsed.positionals[position]
|
|
99
|
+
if (value) input[arg.name] = value
|
|
100
|
+
})
|
|
101
|
+
for (const flag of chosen.flags) {
|
|
102
|
+
const raw = parsed.values[flag.name]
|
|
103
|
+
if (raw === undefined) continue
|
|
104
|
+
if (flag.type === 'boolean') {
|
|
105
|
+
input[flag.name] = raw
|
|
106
|
+
} else if (flag.type === 'number') {
|
|
107
|
+
const value = Number(raw)
|
|
108
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
109
|
+
return fail(
|
|
110
|
+
new AtomError('usage.invalid_flag', `--${flag.name} takes a positive whole number.`),
|
|
111
|
+
2
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
input[flag.name] = value
|
|
115
|
+
} else {
|
|
116
|
+
if (flag.choices && !flag.choices.includes(raw)) {
|
|
117
|
+
return fail(
|
|
118
|
+
new AtomError(
|
|
119
|
+
'usage.invalid_flag',
|
|
120
|
+
`--${flag.name} must be one of: ${flag.choices.join(', ')}`
|
|
121
|
+
),
|
|
122
|
+
2
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
input[flag.name] = raw
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
const envelope = chosen.run(loadIndex(), input)
|
|
131
|
+
return {
|
|
132
|
+
exitCode: 0,
|
|
133
|
+
json: asJson,
|
|
134
|
+
output: asJson ? JSON.stringify(envelope, null, 2) : formatEnvelope(envelope),
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (error instanceof AtomError) return fail(error, 1)
|
|
138
|
+
throw error
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Run when executed directly, including through the node_modules/.bin symlink.
|
|
144
|
+
const invoked = process.argv[1] ? realpathSync(process.argv[1]) : ''
|
|
145
|
+
if (invoked === fileURLToPath(import.meta.url) && process.argv[2] === 'mcp') {
|
|
146
|
+
// Loaded only here, so plain queries never pay for the MCP SDK.
|
|
147
|
+
const { serve } = await import('./mcp.mjs')
|
|
148
|
+
serve()
|
|
149
|
+
} else if (invoked === fileURLToPath(import.meta.url)) {
|
|
150
|
+
const { exitCode, json, output } = runCli(process.argv.slice(2))
|
|
151
|
+
;(exitCode === 0 || json ? process.stdout : process.stderr).write(`${output}\n`)
|
|
152
|
+
process.exitCode = exitCode
|
|
153
|
+
}
|
package/src/commands.mjs
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command table. The CLI, the MCP server and `manifest` are all built
|
|
3
|
+
* from it, so the three can never describe different commands.
|
|
4
|
+
*
|
|
5
|
+
* Each command names its positional arguments and flags with types, and the
|
|
6
|
+
* envelope `type`s it can return. A command with `writes: true` changes files,
|
|
7
|
+
* so the MCP server, whose tools are read-only, leaves it out. `run` receives the index and the parsed
|
|
8
|
+
* input and returns an envelope, or throws an AtomError.
|
|
9
|
+
*/
|
|
10
|
+
import { agentsBlock } from './agents-md.mjs'
|
|
11
|
+
import { component, docsPage, example, rules, search, searchKinds, token } from './core.mjs'
|
|
12
|
+
import { build, copy, template, templateKinds } from './templates.mjs'
|
|
13
|
+
|
|
14
|
+
export const commands = [
|
|
15
|
+
{
|
|
16
|
+
name: 'search',
|
|
17
|
+
summary: 'Search components, docs pages, story examples and tokens in one ranked list.',
|
|
18
|
+
args: [{ name: 'query', description: 'What you are looking for, in words or by name.' }],
|
|
19
|
+
flags: [
|
|
20
|
+
{ name: 'kind', type: 'string', choices: searchKinds, description: 'Only this kind.' },
|
|
21
|
+
{ name: 'limit', type: 'number', default: 10, description: 'At most this many results.' },
|
|
22
|
+
],
|
|
23
|
+
returns: ['search.results'],
|
|
24
|
+
run: (index, { query, kind, limit }) => search(index, query, { kind, limit }),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'component',
|
|
28
|
+
summary:
|
|
29
|
+
'How to use a component: import line, one line of guidance per variant, size and state where written, contract (axes, defaults, slots, states, web + iOS), related components and examples.',
|
|
30
|
+
args: [{ name: 'slug', description: 'Component slug, e.g. dialog or segmented-control.' }],
|
|
31
|
+
flags: [],
|
|
32
|
+
returns: ['component.detail'],
|
|
33
|
+
run: (index, { slug }) => component(index, slug),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'example',
|
|
37
|
+
summary: "A story's code, as a known-good usage sample, with the file's imports.",
|
|
38
|
+
args: [
|
|
39
|
+
{ name: 'slug', description: 'Component slug.' },
|
|
40
|
+
{ name: 'story', optional: true, description: 'Story export name; defaults to the first.' },
|
|
41
|
+
],
|
|
42
|
+
flags: [],
|
|
43
|
+
returns: ['example.source'],
|
|
44
|
+
run: (index, { slug, story }) => example(index, slug, story),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'build',
|
|
48
|
+
summary:
|
|
49
|
+
'A composition kit for an idea: the closest page templates and blocks, the components it needs, the foundation and the rules. For a phone screen, it leads with AppView layout="phone"; for a balance, a price or an amount to send, it adds the display amount. For a dense product screen (a table, an inbox, an issue tracker, an admin dashboard, a file list), it adds compact density. With no idea, the build playbook.',
|
|
50
|
+
args: [
|
|
51
|
+
{
|
|
52
|
+
name: 'idea',
|
|
53
|
+
optional: true,
|
|
54
|
+
description: 'What you are building, e.g. "billing settings page".',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
flags: [],
|
|
58
|
+
returns: ['build.kit', 'build.playbook'],
|
|
59
|
+
run: (index, { idea }) => build(index, idea),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'template',
|
|
63
|
+
summary:
|
|
64
|
+
'Page and block templates: with no id, the list; with an id, its source files and those of the blocks it uses (enough to paste: templates ship in no package), the components and packages it uses, and how to copy it.',
|
|
65
|
+
args: [{ name: 'id', optional: true, description: 'Template id, e.g. settings-page.' }],
|
|
66
|
+
flags: [
|
|
67
|
+
{ name: 'kind', type: 'string', choices: templateKinds, description: 'Only this kind.' },
|
|
68
|
+
],
|
|
69
|
+
returns: ['template.list', 'template.detail'],
|
|
70
|
+
run: (index, { id, kind }) => template(index, id, { kind }),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'copy',
|
|
74
|
+
summary:
|
|
75
|
+
'Copy a template and the blocks it uses into a directory of your project, keeping their layout so the imports resolve. Existing files are left alone.',
|
|
76
|
+
args: [
|
|
77
|
+
{ name: 'id', description: 'Template id, e.g. settings-page.' },
|
|
78
|
+
{ name: 'dir', description: 'Directory to copy into, e.g. src/templates.' },
|
|
79
|
+
],
|
|
80
|
+
flags: [{ name: 'force', type: 'boolean', description: 'Overwrite files that already exist.' }],
|
|
81
|
+
returns: ['template.copied'],
|
|
82
|
+
writes: true,
|
|
83
|
+
run: (index, { id, dir, force }) => copy(index, id, dir, { force }),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'token',
|
|
87
|
+
summary:
|
|
88
|
+
'A token by CSS variable, or matching tokens by words: values per scope, Figma path and Swift name.',
|
|
89
|
+
args: [{ name: 'query', description: 'e.g. --a63-surface-page, surface-page or "on media".' }],
|
|
90
|
+
flags: [],
|
|
91
|
+
returns: ['token.detail', 'token.results'],
|
|
92
|
+
run: (index, { query }) => token(index, query),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'docs',
|
|
96
|
+
summary: 'A docs page as Markdown.',
|
|
97
|
+
args: [{ name: 'slug', description: 'Page slug, e.g. theme-system.' }],
|
|
98
|
+
flags: [],
|
|
99
|
+
returns: ['docs.page'],
|
|
100
|
+
run: (index, { slug }) => docsPage(index, slug),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'rules',
|
|
104
|
+
summary: 'The rules to follow when building UI with Atom63, each with its reason.',
|
|
105
|
+
args: [],
|
|
106
|
+
flags: [],
|
|
107
|
+
returns: ['rules'],
|
|
108
|
+
run: () => rules(),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'agents',
|
|
112
|
+
summary:
|
|
113
|
+
'The AGENTS.md section for a project that builds UI with Atom63: how to query the system and the rules, wrapped in markers so it can be kept in sync.',
|
|
114
|
+
args: [],
|
|
115
|
+
flags: [
|
|
116
|
+
{
|
|
117
|
+
name: 'variant',
|
|
118
|
+
type: 'string',
|
|
119
|
+
choices: ['cli', 'docs'],
|
|
120
|
+
default: 'cli',
|
|
121
|
+
description:
|
|
122
|
+
'cli: point agents at atom63 and its MCP server; docs: at the published docs, for projects without the CLI.',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
returns: ['agents.md'],
|
|
126
|
+
run: (_, { variant }) => ({ type: 'agents.md', data: { markdown: agentsBlock({ variant }) } }),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'manifest',
|
|
130
|
+
summary: 'Every command with its arguments, flags and response types.',
|
|
131
|
+
args: [],
|
|
132
|
+
flags: [],
|
|
133
|
+
returns: ['manifest'],
|
|
134
|
+
run: () => manifest(),
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
/** Error codes a caller can branch on. Append only: a shipped code keeps its meaning. */
|
|
139
|
+
export const errorCodes = [
|
|
140
|
+
'usage.unknown_command',
|
|
141
|
+
'usage.missing_argument',
|
|
142
|
+
'usage.invalid_flag',
|
|
143
|
+
'search.empty_query',
|
|
144
|
+
'search.unknown_kind',
|
|
145
|
+
'component.not_found',
|
|
146
|
+
'example.none',
|
|
147
|
+
'example.not_found',
|
|
148
|
+
'token.empty_query',
|
|
149
|
+
'token.not_found',
|
|
150
|
+
'docs.not_found',
|
|
151
|
+
'template.not_found',
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
/** The self-describing manifest an agent reads once to learn the interface. */
|
|
155
|
+
export function manifest() {
|
|
156
|
+
return {
|
|
157
|
+
type: 'manifest',
|
|
158
|
+
data: {
|
|
159
|
+
name: 'atom63',
|
|
160
|
+
envelope:
|
|
161
|
+
'{ type, data }; errors are { type: "error", data: { code, message, suggestions } }',
|
|
162
|
+
commands: commands.map(({ name, summary, args, flags, returns }) => ({
|
|
163
|
+
name,
|
|
164
|
+
summary,
|
|
165
|
+
args,
|
|
166
|
+
flags,
|
|
167
|
+
returns,
|
|
168
|
+
})),
|
|
169
|
+
errorCodes,
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
}
|