@agent-workshop/adoc 0.1.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 ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (C) 2026 adoc contributors
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # adoc
2
+
3
+ adoc is a place where you and a coding agent work on documents together. The documents are plain files in your
4
+ repository, such as notes, TODO lists, task work orders, boards and drawings, and each kind comes from a **plugin**.
5
+
6
+ - **The agent edits the files** with the `adoc` command line or its MCP tool, and commits them.
7
+ - **You read them rendered in a web UI**, comment on a section or on selected text, edit them, or press their buttons.
8
+ Each of those reaches the agent as a **message**; in a herdr pane it arrives as a prompt, and the
9
+ web UI shows the agent's terminal beside the documents.
10
+
11
+ adoc does not depend on one agent: any agent that can run a command or use MCP can work with it.
12
+
13
+ ## How it looks
14
+
15
+ Select text in a document and comment on it; the comment carries the quote and its `file:line`.
16
+
17
+ ![Commenting on selected text](https://raw.githubusercontent.com/dirty49374/adoc/HEAD/samples/screenshots/comment.png)
18
+
19
+ Send it, and it reaches the agent's herdr pane as a prompt. The web UI shows that terminal beside the documents.
20
+
21
+ ![The agent receives the comment and works](https://raw.githubusercontent.com/dirty49374/adoc/HEAD/samples/screenshots/agent-working.png)
22
+
23
+ When the agent has edited the documents, the web UI marks what changed since you last looked.
24
+
25
+ ![Changed sections marked after the agent's edit](https://raw.githubusercontent.com/dirty49374/adoc/HEAD/samples/screenshots/changes.png)
26
+
27
+ Plugins bring their own views and actions: a click on a TODO item asks the agent to do it, a board shows where work
28
+ stands, and a sketch shows the agent what you mean.
29
+
30
+ ![Asking the agent to do a TODO item](https://raw.githubusercontent.com/dirty49374/adoc/HEAD/samples/screenshots/todo-request.png)
31
+
32
+ | KANBAN | SKETCH |
33
+ |---|---|
34
+ | ![A KANBAN board](https://raw.githubusercontent.com/dirty49374/adoc/HEAD/samples/screenshots/kanban.png) | ![A SKETCH wireframe](https://raw.githubusercontent.com/dirty49374/adoc/HEAD/samples/screenshots/sketch.png) |
35
+
36
+ The screenshots come from [`samples/`](https://github.com/dirty49374/adoc/blob/HEAD/samples/), a todo app team's workspace with Claude Code as its agent.
37
+
38
+ ## Requirements
39
+
40
+ - Node.js 24 or later
41
+ - git (recommended: the agent commits every change)
42
+ - herdr 0.9.3 or later (recommended), for pushed messages and the terminal in the web UI
43
+
44
+ ## Install
45
+
46
+ ```sh
47
+ npm install -g @agent-workshop/adoc
48
+ ```
49
+
50
+ This installs the `adoc` command, the web UI and the five plugins of adoc: NOTE (shared notes), TODO (task lists), TASK
51
+ (work orders), KANBAN (a board) and SKETCH (drawings).
52
+
53
+ ## Quick start
54
+
55
+ ```sh
56
+ cd my-project # a git repository
57
+ adoc init # .adoc/adoc.yaml with the five plugins, and docs/
58
+ adoc skill install # teaches your agents adoc and each plugin (agent skills)
59
+ adoc server run # the web UI at http://127.0.0.1:7700
60
+ ```
61
+
62
+ Then start your agent in a herdr pane and let it run `adoc agent claim`: your comments and actions in the web UI are
63
+ pushed into that pane. Without herdr, set `agent.transport.kind: wait` in `.adoc/adoc.yaml`, and the agent takes its
64
+ messages with `adoc message wait`.
65
+
66
+ The agent learns the rest from its skills: `adoc skill view adoc` shows what it reads.
67
+
68
+ ## Configuration
69
+
70
+ `.adoc/adoc.yaml` declares which plugins the workspace uses, as `KEY: <source>`, laid over your own
71
+ `~/.config/adoc/adoc.yaml`. Paths are relative to the file:
72
+
73
+ ```yaml
74
+ plugins:
75
+ NOTE: npm:@agent-workshop/adoc-plugin-note # an npm package (the five come with adoc)
76
+ TASK: ./plugins/task # a folder, here .adoc/plugins/task
77
+ MIND: github:someone/adoc-plugins/mindmap#v1 # fetched by `adoc plugin install`
78
+ watch:
79
+ - ../docs
80
+ ui:
81
+ tabs: [NOTE, TASK, MIND]
82
+ ```
83
+
84
+ A plugin is a folder with `index.ts` and `skill/SKILL.md`; `adoc skill view adoc-plugin-authoring` explains how to write
85
+ one.
86
+
87
+ ## Security
88
+
89
+ The server listens on `127.0.0.1` by default. With `server.host: 0.0.0.0` it accepts the internal network **without
90
+ authentication**: anyone who reaches the port can read and edit the documents and control the agent's terminal.
91
+
92
+ ## License
93
+
94
+ adoc is released under the [Zero-Clause BSD License](https://github.com/dirty49374/adoc/blob/HEAD/LICENSE). The bundled browser code and fonts keep their own
95
+ licenses; see [THIRD_PARTY_NOTICES.md](https://github.com/dirty49374/adoc/blob/HEAD/THIRD_PARTY_NOTICES.md). To work on adoc itself, see
96
+ [CONTRIBUTING.md](https://github.com/dirty49374/adoc/blob/HEAD/CONTRIBUTING.md).
@@ -0,0 +1,49 @@
1
+ # Third-party notices
2
+
3
+ adoc's original code and documentation use the Zero-Clause BSD License (0BSD). That license does not replace the
4
+ licenses of third-party components, and no third-party component is relicensed by this repository.
5
+
6
+ ## Browser distributions
7
+
8
+ Two packages carry bundled browser code:
9
+
10
+ - `@agent-workshop/adoc-webapp`: the web UI in `dist/`. Its build records the packages actually bundled in
11
+ `dist/licenses/packages.json` and copies their upstream LICENSE, COPYING, COPYRIGHT and NOTICE files beneath
12
+ `dist/licenses/`.
13
+ - `@agent-workshop/adoc-plugin-sketch`: the drawing board in `client/`, with its inventory and license files in
14
+ `client/licenses/`.
15
+
16
+ Keep these files when redistributing the built browser assets.
17
+
18
+ The main browser dependencies are React, React DOM, React Router, Mermaid (with KaTeX), xterm.js and Lucide in the web
19
+ UI, and Excalidraw with React and Radix UI in the drawing board. Most use MIT, ISC, BSD or Apache-2.0.
20
+
21
+ - DOMPurify offers MPL-2.0 OR Apache-2.0; adoc uses the Apache-2.0 option.
22
+ - Some packages are published without a license file although their manifest names one: Excalidraw, the Radix UI
23
+ primitives, react-remove-scroll-bar and fastdom (all MIT). The build includes the upstream texts kept in
24
+ `tooling/licenses/`.
25
+
26
+ ### Eclipse Layout Kernel / elkjs
27
+
28
+ Mermaid bundles elkjs, a separately licensed layout engine, which adoc uses under EPL-2.0 without modifying it. Its
29
+ license is included in the generated license inventory. Corresponding source is available from:
30
+
31
+ - https://github.com/kieler/elkjs (select the release matching the inventory version)
32
+ - https://github.com/eclipse/elk (the underlying Eclipse Layout Kernel)
33
+ - https://www.eclipse.org/legal/epl-2.0/
34
+
35
+ Recipients may obtain, modify and redistribute the EPL-covered source under EPL-2.0. adoc's 0BSD license applies to its
36
+ independent code, not to ELK.
37
+
38
+ ## Fonts
39
+
40
+ - The web UI serves Pretendard, D2Coding (both SIL Open Font License 1.1) and Symbols Nerd Font Mono; their license
41
+ files are next to them in `dist/assets/fonts/`.
42
+ - The drawing board serves the fonts that Excalidraw ships in `client/fonts/` (Excalifont, Virgil, Nunito, Lilita One,
43
+ Comic Shanns, Cascadia Code, Liberation Sans, Assistant and Xiaolai); they are distributed under the terms that
44
+ Excalidraw states for them in https://github.com/excalidraw/excalidraw.
45
+
46
+ ## Installed runtime dependencies
47
+
48
+ The packages that npm installs next to adoc, such as the MCP SDK, ws, yaml, zod, semver, commander, markdown-it and
49
+ highlight.js, are not bundled: each keeps its own license in its own package.
@@ -0,0 +1,9 @@
1
+ import type { CommandContext, CommandDefinition } from './contracts.js';
2
+ type Options = Record<string, unknown> & {
3
+ home?: string;
4
+ };
5
+ /** The _Skill_Check_ findings for the workspace of the command; none when there is no workspace. */
6
+ export declare function skillWarnings(options: Options, context: CommandContext): Promise<string[]>;
7
+ export declare const commands: readonly CommandDefinition[];
8
+ export declare const groups: Record<string, string>;
9
+ export {};
@@ -0,0 +1,383 @@
1
+ import { mkdir, writeFile, access } from 'node:fs/promises';
2
+ import { join, resolve } from 'node:path';
3
+ import { AdocError, AdocServer, CONFIG_TEMPLATE, checkSkills, discoverHome, fetchGithubPlugins, formatCheck, installSkills, listSkills, readClaim, readConfig, resolveAgentPane, writeClaim, CLAIM_FILE, ServerClient, uninstallSkills, viewSkill, Workspace, } from '@agent-workshop/adoc-core';
4
+ import { createMcpEndpoint, serveStdio } from './mcp.js';
5
+ const WAIT_ROUND_MS = 60_000;
6
+ const opened = new WeakMap();
7
+ /** Opens the workspace once per command run; the command and the _Skill_Check_ after it share it. */
8
+ function openWorkspace(options, context) {
9
+ let workspace = opened.get(context);
10
+ if (!workspace) {
11
+ workspace = discoverHome(context.cwd, options.home, context.env).then((home) => Workspace.open(home, context.env));
12
+ opened.set(context, workspace);
13
+ }
14
+ return workspace;
15
+ }
16
+ /** The _Skill_Check_ findings for the workspace of the command; none when there is no workspace. */
17
+ export async function skillWarnings(options, context) {
18
+ let workspace;
19
+ try {
20
+ workspace = await openWorkspace(options, context);
21
+ }
22
+ catch {
23
+ return [];
24
+ }
25
+ return (await checkSkills(workspace, context.env.HOME)).map((entry) => entry.message);
26
+ }
27
+ async function client(options, context) {
28
+ const home = await discoverHome(context.cwd, options.home, context.env);
29
+ const server = await ServerClient.find(await readConfig(home, context.env), home.workspace);
30
+ await server.ensure();
31
+ return server;
32
+ }
33
+ function agentsOption(options) {
34
+ return Array.isArray(options.agent) ? options.agent.map(String) : undefined;
35
+ }
36
+ /** An ISO time as local `YYYY-MM-DD HH:MM`. */
37
+ function localTime(iso) {
38
+ const t = new Date(iso);
39
+ const two = (n) => String(n).padStart(2, '0');
40
+ return `${t.getFullYear()}-${two(t.getMonth() + 1)}-${two(t.getDate())} ${two(t.getHours())}:${two(t.getMinutes())}`;
41
+ }
42
+ /** The options of the _Document_Find_Command_. */
43
+ function findOptions(options) {
44
+ return { ...(typeof options.plugin === 'string' ? { pluginKey: options.plugin } : {}), archived: options.archived === true };
45
+ }
46
+ function table(rows) {
47
+ if (!rows.length)
48
+ return '';
49
+ const widths = rows[0].map((_, i) => Math.max(...rows.map((r) => (r[i] ?? '').length)));
50
+ return rows.map((r) => r.map((cell, i) => (i === r.length - 1 ? cell : cell.padEnd(widths[i]))).join(' ')).join('\n');
51
+ }
52
+ /** Runs until SIGINT, SIGTERM or the given promise settles. */
53
+ async function foreground(stop) {
54
+ await new Promise((done) => {
55
+ const finish = () => {
56
+ process.off('SIGINT', finish);
57
+ process.off('SIGTERM', finish);
58
+ void stop().then(done, done);
59
+ };
60
+ process.on('SIGINT', finish);
61
+ process.on('SIGTERM', finish);
62
+ });
63
+ }
64
+ function messagesResult(body, empty) {
65
+ const data = body.messages.map(({ formatted: _formatted, ...fields }) => fields);
66
+ return { data, text: body.messages.length ? body.messages.map((m) => m.formatted).join('\n') : empty };
67
+ }
68
+ /** `adoc plugin install` and `adoc plugin update`: one line per GitHub source; fails when one could not be fetched. */
69
+ async function fetchCommand(options, context, choice) {
70
+ const home = await discoverHome(context.cwd, options.home, context.env);
71
+ const outcomes = await fetchGithubPlugins(await readConfig(home, context.env), choice, context.env);
72
+ const text = outcomes.length
73
+ ? outcomes.map((o) => `${o.key} ${o.status}${o.commit ? ` ${o.commit.slice(0, 12)}` : ''}${o.reason ? `: ${o.reason}` : ''}`).join('\n')
74
+ : 'No GitHub plugin sources are declared.';
75
+ const failed = outcomes.filter((o) => o.status === 'refused' || o.status === 'failed');
76
+ if (failed.length)
77
+ throw new AdocError('plugin.fetch', text);
78
+ return { data: outcomes, text };
79
+ }
80
+ export const commands = [
81
+ {
82
+ name: 'init',
83
+ argument: '[directory]',
84
+ options: [],
85
+ summary: 'Create .adoc/adoc.yaml, declaring the five plugins of adoc, and a docs folder in a directory.',
86
+ behavior: 'Refuses when the directory already has an .adoc folder with adoc.yaml. Does not run git init; keep the workspace in a git repository so that the agent can commit.',
87
+ example: 'adoc init .',
88
+ localOnly: true,
89
+ async run(args, _options, context) {
90
+ const root = resolve(context.cwd, args[0] ?? '.');
91
+ const configPath = join(root, '.adoc', 'adoc.yaml');
92
+ try {
93
+ await access(configPath);
94
+ throw new AdocError('init.exists', `${configPath} already exists.`);
95
+ }
96
+ catch (error) {
97
+ if (error instanceof AdocError)
98
+ throw error;
99
+ }
100
+ await mkdir(join(root, '.adoc'), { recursive: true });
101
+ await mkdir(join(root, 'docs'), { recursive: true });
102
+ await writeFile(configPath, CONFIG_TEMPLATE);
103
+ await writeFile(join(root, '.adoc', '.gitignore'), `${CLAIM_FILE}\n`);
104
+ return { data: { configPath }, text: `Initialized ${configPath} with the five plugins of adoc.\nNext: adoc skill install, then adoc server run.` };
105
+ },
106
+ },
107
+ {
108
+ name: 'server run',
109
+ options: [
110
+ ['--host <address>', 'override server.host'],
111
+ ['--port <port>', 'override server.port'],
112
+ ['--agent-pane <pane>', 'claim this herdr pane for the assigned agent before starting'],
113
+ ],
114
+ summary: 'Run the adoc server for this workspace in the foreground.',
115
+ behavior: 'Serves the web UI, the REST API, live events and MCP at /mcp; watches the watch paths; holds user messages until delivery. Refuses to start on a port in use. Prints the adoc check report at start. Ctrl-C stops it.',
116
+ example: 'adoc server run --port 7700',
117
+ localOnly: true,
118
+ async run(_args, options, context) {
119
+ const workspace = await openWorkspace(options, context);
120
+ if (typeof options.agentPane === 'string')
121
+ await writeClaim(workspace.home, await resolveAgentPane(context.env, { pane: options.agentPane }));
122
+ const serverOptions = { extensions: [createMcpEndpoint(context)], log: (line) => context.streams.stderr(line + '\n') };
123
+ if (typeof options.host === 'string')
124
+ serverOptions.host = options.host;
125
+ if (options.port !== undefined)
126
+ serverOptions.port = Number(options.port);
127
+ const server = new AdocServer(workspace, serverOptions);
128
+ await server.start();
129
+ await foreground(() => server.stop());
130
+ },
131
+ },
132
+ {
133
+ name: 'mcp run',
134
+ options: [
135
+ ['--with-server', 'also host the adoc server in this process'],
136
+ ['--port <port>', 'override server.port; requires --with-server'],
137
+ ],
138
+ summary: 'Serve the adoc MCP tool over stdio.',
139
+ behavior: 'Exposes one tool, adoc({cmd, stdin}), that runs any adoc command without the executable prefix. Standard output carries only MCP messages. With --with-server the adoc server runs in the same process and stops when stdio closes.',
140
+ example: 'adoc mcp run --with-server',
141
+ localOnly: true,
142
+ async run(_args, options, context) {
143
+ let server;
144
+ if (options.withServer) {
145
+ const workspace = await openWorkspace(options, context);
146
+ const serverOptions = { extensions: [createMcpEndpoint(context)], log: (line) => context.streams.stderr(line + '\n') };
147
+ if (options.port !== undefined)
148
+ serverOptions.port = Number(options.port);
149
+ server = new AdocServer(workspace, serverOptions);
150
+ await server.start();
151
+ }
152
+ else if (options.port !== undefined) {
153
+ throw new AdocError('cli.option', '--port requires --with-server');
154
+ }
155
+ await serveStdio(context);
156
+ await server?.stop();
157
+ },
158
+ },
159
+ {
160
+ name: 'message wait',
161
+ options: [['--timeout <seconds>', 'return with no message after this many seconds']],
162
+ summary: 'Wait for user messages and receive every held message.',
163
+ behavior: 'Blocks until the adoc server holds at least one user message, then returns all held messages in creation order, each in the adoc message format, and the server forgets them. Without --timeout it waits indefinitely. Fails when no adoc server is running.',
164
+ example: 'adoc message wait --timeout 600',
165
+ async run(_args, options, context) {
166
+ const server = await client(options, context);
167
+ // Long-poll in rounds shorter than fetch's own response timeout, until messages arrive or --timeout ends.
168
+ const deadline = options.timeout !== undefined ? Date.now() + Number(options.timeout) * 1000 : Infinity;
169
+ for (;;) {
170
+ const round = Math.max(0, Math.min(WAIT_ROUND_MS, deadline - Date.now()));
171
+ const body = await server.get(`/api/messages/wait?timeout=${round}`);
172
+ if (body.messages.length || Date.now() >= deadline)
173
+ return messagesResult(body, '(no messages)');
174
+ }
175
+ },
176
+ },
177
+ {
178
+ name: 'message list',
179
+ options: [],
180
+ summary: 'Show held user messages without delivering them.',
181
+ behavior: 'Lists the messages the adoc server still holds, in the adoc message format. Fails when no adoc server is running.',
182
+ example: 'adoc message list',
183
+ async run(_args, options, context) {
184
+ const server = await client(options, context);
185
+ return messagesResult(await server.get('/api/messages'), '(no held messages)');
186
+ },
187
+ },
188
+ {
189
+ name: 'plugin list',
190
+ options: [],
191
+ summary: 'List the plugins declared in adoc.yaml.',
192
+ behavior: 'Shows each plugin key in tab order, its number of documents (archived ones left out), its source and its description, or its load error.',
193
+ example: 'adoc plugin list',
194
+ async run(_args, options, context) {
195
+ const plugins = (await openWorkspace(options, context)).pluginInfos();
196
+ const rows = [['KEY', 'DOCUMENTS', 'SOURCE', 'DESCRIPTION'], ...plugins.map((p) => [p.key, String(p.documents), p.source, p.error ? `ERROR: ${p.error}` : p.description ?? ''])];
197
+ return { data: plugins, text: plugins.length ? table(rows) : 'No plugins are declared in adoc.yaml.' };
198
+ },
199
+ },
200
+ {
201
+ name: 'plugin install',
202
+ options: [],
203
+ summary: 'Fetch the GitHub plugin sources that are declared but not fetched yet.',
204
+ behavior: 'Fetches each github:<owner>/<repo>/<folder>#<ref> source into plugins/<key in lowercase>/ next to the config file that declares it, and records the commit in plugins-lock.json there. npm sources are installed with npm. Then run adoc skill install, and restart a running server.',
205
+ example: 'adoc plugin install',
206
+ localOnly: true,
207
+ async run(_args, options, context) {
208
+ return fetchCommand(options, context, { update: false });
209
+ },
210
+ },
211
+ {
212
+ name: 'plugin update',
213
+ argument: '[keys...]',
214
+ options: [],
215
+ summary: 'Fetch GitHub plugin sources again, all or the given plugin keys.',
216
+ behavior: 'Refuses a fetched folder whose files were changed; copy it to another folder to change a plugin. npm sources are updated with npm. Then run adoc skill update, and restart a running server.',
217
+ example: 'adoc plugin update SKETCH',
218
+ localOnly: true,
219
+ async run(args, options, context) {
220
+ return fetchCommand(options, context, { update: true, keys: args });
221
+ },
222
+ },
223
+ {
224
+ name: 'document list',
225
+ options: [
226
+ ['--plugin <key>', 'only documents of this plugin key, such as TASK'],
227
+ ['--archived', 'only archived documents (inside an _archive folder)'],
228
+ ],
229
+ summary: 'List documents, newest first, without archived ones.',
230
+ behavior: 'Shows the key, status, last update, title and path of every document, by last update, newest first. Archived documents (inside an _archive folder) are left out; --archived shows only them.',
231
+ example: 'adoc document list --plugin TASK',
232
+ async run(_args, options, context) {
233
+ const found = (await openWorkspace(options, context)).findDocuments(findOptions(options));
234
+ const rows = [['KEY', 'STATUS', 'UPDATED', 'TITLE', 'PATH'], ...found.map((d) => [d.key, d.summary?.status ?? 'ERROR', localTime(d.updatedAt), d.summary?.title ?? d.error ?? '', d.path])];
235
+ return { data: found, text: found.length ? table(rows) : `No ${options.archived ? 'archived ' : ''}documents.` };
236
+ },
237
+ },
238
+ {
239
+ name: 'document search',
240
+ argument: '<text>',
241
+ options: [
242
+ ['--plugin <key>', 'only documents of this plugin key, such as TASK'],
243
+ ['--archived', 'only archived documents (inside an _archive folder)'],
244
+ ],
245
+ summary: 'Find the lines of documents that contain a text, without archived documents.',
246
+ behavior: 'Prints every line of a document file that contains the text, case-insensitive, as path:line, key and line. Archived documents (inside an _archive folder) are left out; --archived searches only them.',
247
+ example: 'adoc document search "cursor paging"',
248
+ async run(args, options, context) {
249
+ const hits = (await openWorkspace(options, context)).searchDocuments(args[0], findOptions(options));
250
+ return { data: hits, text: hits.length ? hits.map((h) => `${h.path}:${h.line} ${h.key} ${h.text}`).join('\n') : `No ${options.archived ? 'archived ' : ''}document contains "${args[0]}".` };
251
+ },
252
+ },
253
+ {
254
+ name: 'skill list',
255
+ options: [],
256
+ summary: 'List the agent skills adoc can show or install.',
257
+ behavior: 'Lists the skill adoc (the assigned agent\'s workflow) and adoc-plugin-authoring in user scope, and the skill of every loaded plugin in the scope of that plugin, with its folder.',
258
+ example: 'adoc skill list',
259
+ async run(_args, options, context) {
260
+ const skills = await listSkills(await openWorkspace(options, context));
261
+ return { data: skills, text: table([['NAME', 'SCOPE', 'DESCRIPTION'], ...skills.map((s) => [s.name, s.scope, s.description])]) };
262
+ },
263
+ },
264
+ {
265
+ name: 'skill view',
266
+ argument: '<name>',
267
+ options: [],
268
+ summary: 'Show one agent skill by its name from adoc skill list.',
269
+ behavior: 'Prints the SKILL.md of the skill without its front matter. Plugin skills are named adoc-<plugin key in lowercase>, such as adoc-todo.',
270
+ example: 'adoc skill view adoc-todo',
271
+ async run(args, options, context) {
272
+ const { entry, body } = await viewSkill(await openWorkspace(options, context), args[0]);
273
+ return { data: { ...entry, body }, text: body };
274
+ },
275
+ },
276
+ ...['install', 'update'].map((verb) => ({
277
+ name: `skill ${verb}`,
278
+ options: [['--agent <names...>', 'the agents to install for, such as claude-code codex (default: what the skills CLI detects)']],
279
+ summary: verb === 'install' ? 'Install every agent skill for the agents.' : 'Install every agent skill again, replacing the installed copies.',
280
+ behavior: 'Runs the Vercel skills CLI (npx -y skills@1, or ADOC_SKILLS_CLI) as `skills add <folder>` for each skill listed by adoc skill list: user scope (--global) for adoc and adoc-plugin-authoring and for plugins outside the workspace, project scope for plugins inside it. Only the skill/ folder is installed, never plugin code.',
281
+ example: `adoc skill ${verb} --agent claude-code codex`,
282
+ localOnly: true,
283
+ async run(_args, options, context) {
284
+ const skills = await installSkills(await openWorkspace(options, context), { agents: agentsOption(options), env: context.env });
285
+ return { data: skills, text: `Installed ${skills.length} skills: ${skills.map((s) => `${s.name} (${s.scope})`).join(', ')}` };
286
+ },
287
+ })),
288
+ {
289
+ name: 'skill uninstall',
290
+ options: [['--agent <names...>', 'the agents to remove the skills from (default: what the skills CLI detects)']],
291
+ summary: 'Remove every agent skill of the workspace from the agents.',
292
+ behavior: 'Runs `skills remove <names>` of the Vercel skills CLI for the skills listed by adoc skill list, per scope.',
293
+ example: 'adoc skill uninstall',
294
+ localOnly: true,
295
+ async run(_args, options, context) {
296
+ const skills = await uninstallSkills(await openWorkspace(options, context), { agents: agentsOption(options), env: context.env });
297
+ return { data: skills, text: `Removed ${skills.map((s) => s.name).join(', ')}` };
298
+ },
299
+ },
300
+ {
301
+ name: 'ui list',
302
+ options: [],
303
+ summary: 'List the browser sessions of the adoc web UI, most recent first.',
304
+ behavior: 'Shows each browser tab connected to the adoc server: its session id, whether it is connected, its last access and the page it shows. Fails when no adoc server is running.',
305
+ example: 'adoc ui list',
306
+ async run(_args, options, context) {
307
+ const server = await client(options, context);
308
+ const { sessions } = await server.get('/api/ui/sessions');
309
+ const rows = [['SESSION', 'STATE', 'LAST ACCESS', 'LOCATION'], ...sessions.map((s) => [s.id, s.connected ? 'connected' : 'closed', s.lastAccess, s.location])];
310
+ return { data: sessions, text: sessions.length ? table(rows) : 'No browser session has connected yet.' };
311
+ },
312
+ },
313
+ {
314
+ name: 'ui open',
315
+ argument: '<target>',
316
+ options: [['--session <id>', 'the browser session to move (default: the connected session accessed last)']],
317
+ summary: 'Show a document, an anchor or a plugin in a browser session.',
318
+ behavior: 'Sends the browser session accessed most recently, or the one named by --session, to the target: a document key such as NOTE-261002-idea, a key with an anchor such as TASK-a#goal, or a plugin key such as TODO. Fails when no browser session is connected.',
319
+ example: 'adoc ui open NOTE-261002-note-plugin',
320
+ async run(args, options, context) {
321
+ const server = await client(options, context);
322
+ const body = { target: args[0] };
323
+ if (typeof options.session === 'string')
324
+ body.session = options.session;
325
+ const opened = await server.post('/api/ui/open', body);
326
+ return { data: opened, text: `Opened ${opened.location} in browser session ${opened.session}.` };
327
+ },
328
+ },
329
+ {
330
+ name: 'agent claim',
331
+ options: [
332
+ ['--pane <pane>', 'the herdr pane to claim, such as w2B:p1'],
333
+ ['--herdr-session <name>', 'look for the pane only in this herdr session'],
334
+ ],
335
+ summary: 'Make your herdr pane the assigned agent of this workspace.',
336
+ behavior: 'Finds your herdr pane: --pane if given; else the pane whose agent session is your session id (CLAUDE_CODE_SESSION_ID or CODEX_SESSION_ID); else HERDR_PANE_ID, unless you run under a shared agent daemon. Writes .adoc/claim.yaml; a running adoc server follows it at once, pushes user messages to that pane and shows its terminal. Claiming from another pane takes the role over.',
337
+ example: 'adoc agent claim',
338
+ async run(_args, options, context) {
339
+ const home = await discoverHome(context.cwd, options.home, context.env);
340
+ const resolveOptions = {};
341
+ if (typeof options.pane === 'string')
342
+ resolveOptions.pane = options.pane;
343
+ if (typeof options.herdrSession === 'string')
344
+ resolveOptions.herdrSession = options.herdrSession;
345
+ const resolved = await resolveAgentPane(context.env, resolveOptions);
346
+ const claim = await writeClaim(home, resolved);
347
+ return { data: { ...claim, via: resolved.via }, text: `Claimed herdr pane ${claim.pane} (${claim.herdrSession}${claim.agent ? `, ${claim.agent}` : ''}) as the assigned agent, found by ${resolved.via}.` };
348
+ },
349
+ },
350
+ {
351
+ name: 'agent show',
352
+ options: [],
353
+ summary: 'Show which herdr pane is the assigned agent.',
354
+ behavior: 'Prints the claim in .adoc/claim.yaml, or says that no agent has claimed the workspace.',
355
+ example: 'adoc agent show',
356
+ async run(_args, options, context) {
357
+ const claim = await readClaim(await discoverHome(context.cwd, options.home, context.env));
358
+ return { data: claim ?? null, text: claim ? `herdr pane ${claim.pane} (${claim.herdrSession}${claim.agent ? `, ${claim.agent}` : ''}), claimed ${claim.claimedAt}` : 'No agent has claimed this workspace; run adoc agent claim in the agent pane.' };
359
+ },
360
+ },
361
+ {
362
+ name: 'check',
363
+ options: [],
364
+ summary: 'Report every warning and error of the workspace.',
365
+ behavior: 'Reports plugins that fail to load, duplicate document keys, invalid local ids, files whose prefix is not a declared plugin key, documents that fail to parse and broken document references. Changes nothing. Exits with status 1 when it reports an error.',
366
+ example: 'adoc check',
367
+ async run(_args, options, context) {
368
+ const entries = (await openWorkspace(options, context)).check();
369
+ return { data: entries, text: formatCheck(entries), exitCode: entries.some((e) => e.level === 'error') ? 1 : 0 };
370
+ },
371
+ },
372
+ ];
373
+ export const groups = {
374
+ server: 'Run the adoc server',
375
+ mcp: 'Serve the adoc MCP tool',
376
+ message: 'Receive user messages',
377
+ plugin: 'Inspect declared plugins',
378
+ document: 'Find documents',
379
+ skill: 'Show and install agent skills',
380
+ ui: 'Inspect and control browser sessions of the web UI',
381
+ agent: 'Claim and show the assigned agent',
382
+ };
383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B,KAAK,EAAE,+BAA+B;IACtC,EAAE,EAAE,oDAAoD;IACxD,KAAK,EAAE,mCAAmC;CAC3C,CAAC"}
@@ -0,0 +1,38 @@
1
+ export type OutputFormat = 'text' | 'markdown' | 'json' | 'yaml';
2
+ export interface Streams {
3
+ stdout(text: string): void;
4
+ stderr(text: string): void;
5
+ }
6
+ /** What every command receives besides its arguments. */
7
+ export interface CommandContext {
8
+ readonly cwd: string;
9
+ readonly env: NodeJS.ProcessEnv;
10
+ readonly streams: Streams;
11
+ /** True when the command runs through the _Adoc_MCP_Tool_. */
12
+ readonly mcp: boolean;
13
+ /** Reads what the command would read from standard input. */
14
+ stdin(): Promise<string>;
15
+ }
16
+ /** A finite command result: structured data for json/yaml, text for text/markdown. */
17
+ export interface CommandResult {
18
+ data: unknown;
19
+ text: string;
20
+ markdown?: string;
21
+ exitCode?: number;
22
+ }
23
+ export type OptionSpec = readonly [flags: string, description: string];
24
+ /** One `adoc <noun> <verb>` command. */
25
+ export interface CommandDefinition {
26
+ readonly name: string;
27
+ readonly argument?: string;
28
+ readonly options: readonly OptionSpec[];
29
+ readonly summary: string;
30
+ readonly behavior: string;
31
+ readonly example: string;
32
+ /** Refused through MCP: process and installation commands. */
33
+ readonly localOnly?: boolean;
34
+ /** Returns a result, or nothing for a long-running command that has finished. */
35
+ run(args: string[], options: Record<string, unknown> & {
36
+ home?: string;
37
+ }, context: CommandContext): Promise<CommandResult | void>;
38
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/entry.js ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
3
+ import { runCommand } from './program.js';
4
+ process.stdout.on('error', (error) => {
5
+ if (error.code === 'EPIPE')
6
+ process.exit(process.exitCode ?? 0);
7
+ throw error;
8
+ });
9
+ process.exitCode = await runCommand(process.argv.slice(2), {
10
+ cwd: process.cwd(),
11
+ env: process.env,
12
+ mcp: false,
13
+ streams: { stdout: (t) => process.stdout.write(t), stderr: (t) => process.stderr.write(t) },
14
+ stdin: async () => readFileSync(0, 'utf8'),
15
+ });
16
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAA4B,EAAE,EAAE;IAC1D,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC;IAChE,MAAM,KAAK,CAAC;AACd,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACzD,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;IAClB,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC3F,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC;CAC3C,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { buildProgram, runCommand } from './program.js';
2
+ export { commands, groups } from './commands.js';
3
+ export { commandArguments, runCaptured, createMcpEndpoint, serveStdio } from './mcp.js';
4
+ export type { CommandContext, CommandDefinition, CommandResult, OutputFormat, Streams } from './contracts.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { buildProgram, runCommand } from './program.js';
2
+ export { commands, groups } from './commands.js';
3
+ export { commandArguments, runCaptured, createMcpEndpoint, serveStdio } from './mcp.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { type ServerExtension } from '@agent-workshop/adoc-core';
2
+ import type { CommandContext } from './contracts.js';
3
+ /** Splits `cmd` like a shell would, refusing operators, globs and comments. */
4
+ export declare function commandArguments(cmd: string): string[];
5
+ /** Runs a command through the same code as the terminal and captures its output. */
6
+ export declare function runCaptured(cmd: string, stdin: string | undefined, base: Pick<CommandContext, 'cwd' | 'env'>): Promise<{
7
+ stdout: string;
8
+ stderr: string;
9
+ exitCode: number;
10
+ }>;
11
+ /** Serves the _Adoc_MCP_Tool_ over stdio until the client closes. */
12
+ export declare function serveStdio(context: CommandContext): Promise<void>;
13
+ /** The `/mcp` route of the _Adoc_Server_: stateless, one connection per request. */
14
+ export declare function createMcpEndpoint(context: Pick<CommandContext, 'cwd' | 'env'>): ServerExtension;
package/dist/mcp.js ADDED
@@ -0,0 +1,95 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
5
+ import { parse } from 'shell-quote';
6
+ import { z } from 'zod';
7
+ import { AdocError, errorMessage } from '@agent-workshop/adoc-core';
8
+ import { commands } from './commands.js';
9
+ import { runCommand } from './program.js';
10
+ import { VERSION } from './version.js';
11
+ const toolInput = z.object({ cmd: z.string().min(1), stdin: z.string().optional() });
12
+ /** The tool, described from the command definitions so that its list of commands always matches the CLI. */
13
+ function tool() {
14
+ const names = commands.filter((command) => !command.localOnly).map((command) => command.name);
15
+ return {
16
+ name: 'adoc',
17
+ description: 'Run one adoc CLI command without the leading "adoc", for example {"cmd": "message wait --timeout 600"} or {"cmd": "skill view adoc-todo"}. ' +
18
+ `Commands: ${names.join(', ')}. The other commands and --home work only on the command line. Use stdin for text the command reads from standard input.`,
19
+ inputSchema: z.toJSONSchema(toolInput),
20
+ };
21
+ }
22
+ /** Splits `cmd` like a shell would, refusing operators, globs and comments. */
23
+ export function commandArguments(cmd) {
24
+ if (!cmd.trim())
25
+ throw new AdocError('command.empty', 'Supply one adoc command, without the executable prefix.');
26
+ const words = parse(cmd, (name) => '$' + name);
27
+ if (words.some((word) => typeof word !== 'string'))
28
+ throw new AdocError('command.syntax', 'Supply one command; quote shell operators, globs and # characters.');
29
+ return words;
30
+ }
31
+ /** Runs a command through the same code as the terminal and captures its output. */
32
+ export async function runCaptured(cmd, stdin, base) {
33
+ let stdout = '';
34
+ let stderr = '';
35
+ const context = {
36
+ cwd: base.cwd,
37
+ env: base.env,
38
+ mcp: true,
39
+ streams: { stdout: (t) => (stdout += t), stderr: (t) => (stderr += t) },
40
+ stdin: async () => stdin ?? '',
41
+ };
42
+ let exitCode;
43
+ try {
44
+ exitCode = await runCommand(commandArguments(cmd), context);
45
+ }
46
+ catch (error) {
47
+ stderr += `adoc: ${errorMessage(error)}\n`;
48
+ exitCode = 1;
49
+ }
50
+ return { stdout, stderr, exitCode };
51
+ }
52
+ function createConnection(base) {
53
+ const server = new Server({ name: 'adoc', version: VERSION }, { capabilities: { tools: {} } });
54
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [tool()] }));
55
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
56
+ if (request.params.name !== 'adoc')
57
+ return { content: [{ type: 'text', text: `unknown tool ${request.params.name}` }], isError: true };
58
+ const input = toolInput.safeParse(request.params.arguments ?? {});
59
+ if (!input.success)
60
+ return { content: [{ type: 'text', text: 'adoc needs {"cmd": "<command without adoc>"}' }], isError: true };
61
+ const result = await runCaptured(input.data.cmd, input.data.stdin, base);
62
+ const text = result.stdout + (result.stderr ? `${result.stdout ? '\n' : ''}[stderr]\n${result.stderr}` : '');
63
+ return { content: [{ type: 'text', text: text || '(no output)' }], structuredContent: { ...result }, isError: result.exitCode !== 0 };
64
+ });
65
+ return server;
66
+ }
67
+ /** Serves the _Adoc_MCP_Tool_ over stdio until the client closes. */
68
+ export async function serveStdio(context) {
69
+ const server = createConnection(context);
70
+ const transport = new StdioServerTransport();
71
+ const closed = new Promise((done) => {
72
+ transport.onclose = () => done();
73
+ process.stdin.once('end', () => done());
74
+ });
75
+ await server.connect(transport);
76
+ await closed;
77
+ await server.close().catch(() => undefined);
78
+ }
79
+ /** The `/mcp` route of the _Adoc_Server_: stateless, one connection per request. */
80
+ export function createMcpEndpoint(context) {
81
+ return async (request, response) => {
82
+ if (request.url?.split('?')[0] !== '/mcp')
83
+ return false;
84
+ const server = createConnection(context);
85
+ const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
86
+ response.once('close', () => {
87
+ void transport.close();
88
+ void server.close();
89
+ });
90
+ await server.connect(transport);
91
+ await transport.handleRequest(request, response);
92
+ return true;
93
+ };
94
+ }
95
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","s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,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACzC,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC,EAAE,kBAAkB,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;QACjH,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YAC1B,KAAK,SAAS,CAAC,KAAK,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ import type { CommandContext } from './contracts.js';
3
+ /** Builds the `adoc` command line. `exitCode` receives the status of the command that ran. */
4
+ export declare function buildProgram(context: CommandContext, exitCode: (code: number) => void): Command;
5
+ /** Runs one command line with the given context and returns its exit status. */
6
+ export declare function runCommand(argv: readonly string[], context: CommandContext): Promise<number>;
@@ -0,0 +1,100 @@
1
+ import { Command, CommanderError, Option } from 'commander';
2
+ import { stringify } from 'yaml';
3
+ import { AdocError, errorMessage } from '@agent-workshop/adoc-core';
4
+ import { commands, groups, skillWarnings } from './commands.js';
5
+ import { VERSION } from './version.js';
6
+ function render(result, format) {
7
+ switch (format) {
8
+ case 'json':
9
+ return JSON.stringify(result.data, null, 2);
10
+ case 'yaml':
11
+ return stringify(result.data, { lineWidth: 0 }).trimEnd();
12
+ case 'markdown':
13
+ return result.markdown ?? result.text;
14
+ case 'text':
15
+ return result.text;
16
+ }
17
+ }
18
+ /** Builds the `adoc` command line. `exitCode` receives the status of the command that ran. */
19
+ export function buildProgram(context, exitCode) {
20
+ const program = new Command('adoc')
21
+ .description('adoc: plugin-defined documents kept in git, edited by an agent, commented on from a web UI.')
22
+ .version(VERSION)
23
+ .option('--home <path>', 'the .adoc directory to use (default: ADOC_HOME, then the nearest .adoc upward)')
24
+ .addOption(new Option('--output <format>', 'result format').choices(['text', 'markdown', 'json', 'yaml']).default('text'))
25
+ .showHelpAfterError()
26
+ .allowExcessArguments(false);
27
+ const execute = async (definition, args, options) => {
28
+ try {
29
+ if (context.mcp && (definition.localOnly || options.home !== undefined)) {
30
+ throw new AdocError('command.mcp', `adoc ${definition.name} and --home are local-only; run them from a terminal. MCP uses the workspace it was started in.`);
31
+ }
32
+ const result = await definition.run(args, options, context);
33
+ if (result) {
34
+ const text = render(result, options.output ?? 'text');
35
+ if (text)
36
+ context.streams.stdout(text.endsWith('\n') ? text : text + '\n');
37
+ exitCode(result.exitCode ?? 0);
38
+ }
39
+ else {
40
+ exitCode(0);
41
+ }
42
+ }
43
+ catch (error) {
44
+ context.streams.stderr(`adoc: ${errorMessage(error)}\n`);
45
+ exitCode(1);
46
+ }
47
+ // _Skill_Check_ after every command, also through MCP (whose result carries stderr).
48
+ for (const warning of await skillWarnings(options, context))
49
+ context.streams.stderr(`adoc: warning: ${warning}\n`);
50
+ };
51
+ for (const definition of commands) {
52
+ const parts = definition.name.split(' ');
53
+ const leaf = parts.pop();
54
+ let parent = program;
55
+ for (const part of parts) {
56
+ let group = parent.commands.find((c) => c.name() === part);
57
+ if (!group) {
58
+ const description = groups[part];
59
+ if (!description)
60
+ throw new Error(`no group description for ${part}`);
61
+ group = parent.command(part).description(description).allowExcessArguments(false);
62
+ const created = group;
63
+ created.action(() => created.outputHelp());
64
+ }
65
+ parent = group;
66
+ }
67
+ const command = parent.command(leaf + (definition.argument ? ` ${definition.argument}` : '')).description(definition.summary).allowExcessArguments(false);
68
+ for (const [flags, description] of definition.options)
69
+ command.option(flags, description);
70
+ command.addHelpText('after', `\nBehavior: ${definition.behavior}\n\nExample:\n ${definition.example}\n`);
71
+ command.action(async (...received) => {
72
+ const current = received.at(-1);
73
+ const args = received.slice(0, -2).filter((a) => typeof a === 'string');
74
+ await execute(definition, args, current.optsWithGlobals());
75
+ });
76
+ }
77
+ return program;
78
+ }
79
+ /** Runs one command line with the given context and returns its exit status. */
80
+ export async function runCommand(argv, context) {
81
+ let status = 0;
82
+ const program = buildProgram(context, (code) => {
83
+ status = code;
84
+ });
85
+ const configure = (command) => {
86
+ command.exitOverride().configureOutput({ writeOut: (t) => context.streams.stdout(t), writeErr: (t) => context.streams.stderr(t) });
87
+ command.commands.forEach(configure);
88
+ };
89
+ configure(program);
90
+ try {
91
+ await program.parseAsync([...argv], { from: 'user' });
92
+ }
93
+ catch (error) {
94
+ if (error instanceof CommanderError)
95
+ return error.code === 'commander.helpDisplayed' || error.code === 'commander.version' || error.exitCode === 0 ? 0 : 1;
96
+ throw error;
97
+ }
98
+ return status;
99
+ }
100
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,SAAS,MAAM,CAAC,MAAqB,EAAE,MAAoB;IACzD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9C,KAAK,MAAM;YACT,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC5D,KAAK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AU,UAAU,CAAC,IAAuB,EAAE,OAAuB;IAC/E,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE;QACrC,OAAO,CAAC,YAAY,EAAE,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACnI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,SAAS,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,cAAc;YAAE,OAAO,KAAK,CAAC,IAAI,KAAK,yBAAyB,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3J,MAAM,KAAK,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const VERSION: string;
@@ -0,0 +1,3 @@
1
+ import { createRequire } from 'node:module';
2
+ export const VERSION = createRequire(import.meta.url)('../package.json').version;
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAY,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAyB,CAAC,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@agent-workshop/adoc",
3
+ "version": "0.1.0",
4
+ "license": "0BSD",
5
+ "type": "module",
6
+ "description": "adoc: the command line and MCP tool for a user and an agent working on plugin-defined documents.",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/dirty49374/adoc.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
15
+ "publishConfig": {
16
+ "registry": "https://registry.npmjs.org",
17
+ "access": "public"
18
+ },
19
+ "bin": {
20
+ "adoc": "./dist/entry.js"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "1.30.1",
30
+ "commander": "15.0.0",
31
+ "shell-quote": "1.10.0",
32
+ "yaml": "2.9.0",
33
+ "zod": "4.5.4",
34
+ "@agent-workshop/adoc-core": "0.1.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/shell-quote": "1.7.5",
38
+ "@agent-workshop/adoc-testing": "0.1.0"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "LICENSE",
43
+ "THIRD_PARTY_NOTICES.md",
44
+ "README.md"
45
+ ],
46
+ "scripts": {
47
+ "build": "tsc -b && node build.mjs",
48
+ "check": "tsc -b && tsc -p test",
49
+ "test": "vitest run --testTimeout 20000"
50
+ }
51
+ }