@coda-console/plugin-check 0.8.23 → 0.8.25
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 +16 -3
- package/bin/check.mjs +18 -2
- package/check/coda/adapters/plugin-command.mjs +5 -4
- package/check/coda/adapters/plugin-events.mjs +2 -0
- package/check/coda/adapters/plugin-modules.mjs +18 -8
- package/check/coda/adapters/plugin-test-host.d.mts +81 -3
- package/check/coda/adapters/plugin-test-host.mjs +19 -12
- package/check/coda/api-surface.txt +335 -0
- package/check/coda/builtin.json +178 -30
- package/check/coda/components/plugins/plugin-extensions.mjs +12 -4
- package/check/coda/components/plugins/plugin-rules.mjs +41 -4
- package/check/coda/components/plugins/plugin-source-rules.mjs +6 -2
- package/check/coda/contract.json +13 -11
- package/check/index.mjs +6 -2
- package/check/init.mjs +33 -0
- package/check/level.mjs +70 -0
- package/check/manifest.mjs +5 -2
- package/check/module.mjs +133 -0
- package/check/report.mjs +2 -2
- package/package.json +8 -3
- package/templates/agent/agent/entry.mjs +128 -0
- package/templates/agent/icons/README.md +14 -0
- package/templates/agent/icons/echo.pdf +0 -0
- package/templates/agent/icons/echo.svg +8 -0
- package/templates/agent/package.json +20 -0
- package/templates/module/main.mjs +37 -0
- package/templates/module/package-lock.json +306 -0
- package/templates/module/package.json +80 -0
- package/templates/module/test/main.test.mjs +65 -0
- package/templates/resource/package.json +22 -0
- package/templates/resource/scripts/mark.mjs +6 -0
- package/templates/resource/scripts/resources.mjs +35 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// 回声 Agent:Coda Agent 插件的最小模板。
|
|
2
|
+
//
|
|
3
|
+
// Coda 用 `sh -c` 运行清单里的 command,经标准输入输出讲 ACP(一行一个 JSON-RPC 消息),外加 Coda 的等待项登记
|
|
4
|
+
// `_coda/wait`(见协议仓库 coda-console/coda-protocol 的 docs/agent-protocol.md)。这里全部手写,只用 Node 自带的模块:从仓库安装的插件没有 npm 依赖。
|
|
5
|
+
//
|
|
6
|
+
// - 每轮把提示词原样回显,几个字一段地流式发出,所以「停止」能落在一轮中间。
|
|
7
|
+
// - 会话指令(systemPrompt):Coda 要求声明。回声 Agent 没有原生的系统提示词,就照协议在这个会话第一次 session/prompt 时
|
|
8
|
+
// 把指令作为单独分隔的一段放在用户输入前面;它没有模型,「送入」就是把这一段也回显出来。
|
|
9
|
+
// - 插话(_session/steering):一轮进行中收到的加进这一轮,说完提示词接着说;一轮已经结束就回 promptRequired,不自己另开一轮。
|
|
10
|
+
// - 提示词以 wait 开头时登记一个后台任务(kind: task),两秒后在一轮之外报 handling:Coda 为它开一轮自主轮次,
|
|
11
|
+
// 这时说的话归这一项;说完报 done,自主轮次结束。
|
|
12
|
+
// - session/cancel:停止本轮;没有轮次在进行时,停止正在处理(handling)的等待项。
|
|
13
|
+
// - 日志只能写标准错误:标准输出里每一行都必须是 JSON-RPC 消息。
|
|
14
|
+
import { randomUUID } from 'node:crypto';
|
|
15
|
+
import { createInterface } from 'node:readline';
|
|
16
|
+
|
|
17
|
+
const send = message => process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', ...message })}\n`);
|
|
18
|
+
const reply = (id, result) => send({ id, result });
|
|
19
|
+
const refuse = (id, code, message) => send({ id, error: { code, message } });
|
|
20
|
+
const notify = (method, params) => send({ method, params });
|
|
21
|
+
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
22
|
+
// 把一段话作为回复发出,四个字一段;`stopped()` 为真时不再往下说。返回是否说完了。
|
|
23
|
+
async function speak(sessionId, text, stopped) {
|
|
24
|
+
for (const piece of text.match(/.{1,4}/gsu) ?? []) {
|
|
25
|
+
if (stopped()) return false;
|
|
26
|
+
notify('session/update', { sessionId, update: { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: piece } } });
|
|
27
|
+
await sleep(20);
|
|
28
|
+
}
|
|
29
|
+
return !stopped();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Coda 每轮开始前要知道会话用的是哪个模型:没有模型的 Agent 也报一个。
|
|
33
|
+
const MODEL = { id: 'model', name: '模型', category: 'model', type: 'select', currentValue: 'echo', options: [{ value: 'echo', name: '回声' }] };
|
|
34
|
+
// sessionId → { turn:进行中的一轮或 null,waits:waitId → { state, timer },count:取 waitId 用,
|
|
35
|
+
// instructions:会话指令还没送入时是它的正文,送入后为 null }
|
|
36
|
+
const sessions = new Map();
|
|
37
|
+
const session = sessionId => {
|
|
38
|
+
const found = sessions.get(sessionId);
|
|
39
|
+
if (!found) throw Object.assign(new Error(`没有会话 ${sessionId}`), { code: -32002 });
|
|
40
|
+
return found;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// ---- 等待项 ----
|
|
44
|
+
// 报告一项的新状态;结束(done、failed、cancelled)后这个 waitId 不再说话。
|
|
45
|
+
function report(sessionId, waitId, state, fields = {}) {
|
|
46
|
+
const s = sessions.get(sessionId), wait = s?.waits.get(waitId);
|
|
47
|
+
if (!wait) return;
|
|
48
|
+
wait.state = state;
|
|
49
|
+
if (['done', 'failed', 'cancelled'].includes(state)) { clearTimeout(wait.timer); s.waits.delete(waitId); }
|
|
50
|
+
notify('_coda/wait', { sessionId, waitId, state, ...fields });
|
|
51
|
+
}
|
|
52
|
+
function startWait(sessionId, text) {
|
|
53
|
+
const s = session(sessionId), waitId = `wait-${++s.count}`;
|
|
54
|
+
s.waits.set(waitId, { state: 'waiting', timer: setTimeout(() => handle(sessionId, waitId, text), 2000) });
|
|
55
|
+
report(sessionId, waitId, 'waiting', { kind: 'task', title: '两秒后回来', detail: text.slice(0, 4000), stoppable: true });
|
|
56
|
+
}
|
|
57
|
+
// 到点了:报 handling(一轮之外时 Coda 开一轮自主轮次),说完报 done。被停下就不再说。
|
|
58
|
+
async function handle(sessionId, waitId, text) {
|
|
59
|
+
report(sessionId, waitId, 'handling');
|
|
60
|
+
const wait = sessions.get(sessionId)?.waits.get(waitId);
|
|
61
|
+
if (await speak(sessionId, `两秒到了,接着说:${text}`, () => wait.state !== 'handling')) report(sessionId, waitId, 'done');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ---- 请求 ----
|
|
65
|
+
const methods = {
|
|
66
|
+
// 声明会话指令(sessionCapabilities.systemPrompt)、会登记等待项(_meta.coda.waits)与插话(顶层 _meta.steering);
|
|
67
|
+
// 不支持恢复会话,Coda 就不会发 session/load(支持的,恢复的会话已经送过指令,不再送)。
|
|
68
|
+
initialize: () => ({ protocolVersion: 1, agentCapabilities: { loadSession: false, sessionCapabilities: { systemPrompt: {} }, _meta: { coda: { waits: {} } } },
|
|
69
|
+
authMethods: [], _meta: { steering: { supported: true } } }),
|
|
70
|
+
'session/new': ({ systemPrompt }) => {
|
|
71
|
+
// Coda 只用 append 模式、一个文本块;应用不了的指令回错误,不建立会话。
|
|
72
|
+
if (systemPrompt && systemPrompt.mode !== 'append') throw Object.assign(new Error(`不支持 systemPrompt 模式 ${systemPrompt.mode}`), { code: -32602 });
|
|
73
|
+
const instructions = (systemPrompt?.content ?? []).filter(block => block.type === 'text').map(block => block.text).join('\n').trim() || null;
|
|
74
|
+
const sessionId = randomUUID();
|
|
75
|
+
sessions.set(sessionId, { turn: null, waits: new Map(), count: 0, instructions });
|
|
76
|
+
return { sessionId, configOptions: [MODEL] };
|
|
77
|
+
},
|
|
78
|
+
'session/set_config_option': ({ sessionId, configId, value }) => {
|
|
79
|
+
session(sessionId);
|
|
80
|
+
if (configId !== 'model' || value !== 'echo') throw Object.assign(new Error(`不支持 ${configId}=${value}`), { code: -32602 });
|
|
81
|
+
return { configOptions: [MODEL] };
|
|
82
|
+
},
|
|
83
|
+
'session/prompt': async ({ sessionId, prompt }) => {
|
|
84
|
+
const s = session(sessionId), turn = s.turn = { cancelled: false, steers: [] };
|
|
85
|
+
const text = (prompt ?? []).filter(block => block.type === 'text').map(block => block.text).join('\n').trim();
|
|
86
|
+
try {
|
|
87
|
+
if (/^wait\b/i.test(text)) startWait(sessionId, text);
|
|
88
|
+
// 第一轮:指令作为单独分隔的一段在用户输入前面,整段一次说出。
|
|
89
|
+
if (s.instructions) {
|
|
90
|
+
notify('session/update', { sessionId, update: { sessionUpdate: 'agent_message_chunk',
|
|
91
|
+
content: { type: 'text', text: `<coda-instructions>\n${s.instructions}\n</coda-instructions>\n\n` } } });
|
|
92
|
+
s.instructions = null;
|
|
93
|
+
}
|
|
94
|
+
let said = await speak(sessionId, `回声:${text}`, () => turn.cancelled);
|
|
95
|
+
while (said && turn.steers.length) said = await speak(sessionId, `\n插话:${turn.steers.shift()}`, () => turn.cancelled);
|
|
96
|
+
return { stopReason: turn.cancelled ? 'cancelled' : 'end_turn' };
|
|
97
|
+
} finally { if (s.turn === turn) s.turn = null; }
|
|
98
|
+
},
|
|
99
|
+
// 插话:一轮进行中就加进这一轮,之后的回复与结束都属于原来那次 session/prompt;没有轮次在进行时不收,等 Coda 作为下一轮发来。
|
|
100
|
+
'_session/steering': ({ sessionId, prompt }) => {
|
|
101
|
+
const s = session(sessionId);
|
|
102
|
+
if (!s.turn || s.turn.cancelled) return { outcome: 'promptRequired', reason: 'noRunningTurn' };
|
|
103
|
+
s.turn.steers.push((prompt ?? []).filter(block => block.type === 'text').map(block => block.text).join('\n').trim());
|
|
104
|
+
return { outcome: 'injected' };
|
|
105
|
+
},
|
|
106
|
+
// Coda 停一个声明了 stoppable 的等待项:回 {} 只表示收到,随后用 _coda/wait 报它结束。
|
|
107
|
+
'_coda/wait/stop': ({ sessionId, waitId }) => {
|
|
108
|
+
setImmediate(() => report(sessionId, waitId, 'cancelled'));
|
|
109
|
+
return {};
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
function cancel({ sessionId }) {
|
|
113
|
+
const s = sessions.get(sessionId);
|
|
114
|
+
if (!s) return;
|
|
115
|
+
if (s.turn) s.turn.cancelled = true;
|
|
116
|
+
for (const [waitId, wait] of s.waits) if (wait.state === 'handling') report(sessionId, waitId, 'cancelled');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
createInterface({ input: process.stdin }).on('line', async line => {
|
|
120
|
+
let message;
|
|
121
|
+
try { message = JSON.parse(line); } catch { return; }
|
|
122
|
+
if (typeof message?.method !== 'string') return;
|
|
123
|
+
if (!('id' in message)) { if (message.method === 'session/cancel') cancel(message.params ?? {}); return; }
|
|
124
|
+
const method = methods[message.method];
|
|
125
|
+
if (!method) { refuse(message.id, -32601, `Method not found: ${message.method}`); return; }
|
|
126
|
+
try { reply(message.id, await method(message.params ?? {})); }
|
|
127
|
+
catch (error) { refuse(message.id, error.code ?? -32603, error.message); }
|
|
128
|
+
}).on('close', () => process.exit(0));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# 回声图标
|
|
2
|
+
|
|
3
|
+
为这个模板画的单色图标(一个点和三道声波),随本仓库以 MIT 许可。清单里 `template: true`:只用黑色,客户端随文字颜色着色。
|
|
4
|
+
|
|
5
|
+
图标的规矩(Coda 读清单时核对):插件目录里的 PDF,不超过 32 KiB;可另给深色外观用的 `dark`。画布照 Coda 自带图标定为 256 px:
|
|
6
|
+
iOS 按 96 pt 光栅化 PDF 时只缩不放,页面太小会画成一个点。SVG 是可审阅的源文件,PDF 由 CairoSVG 转换(开发工具,不是运行依赖):
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
uv run --with cairosvg python - <<'PY'
|
|
10
|
+
import cairosvg
|
|
11
|
+
for name in ['echo']:
|
|
12
|
+
cairosvg.svg2pdf(url=f'{name}.svg', write_to=f'{name}.pdf')
|
|
13
|
+
PY
|
|
14
|
+
```
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">
|
|
2
|
+
<circle cx="56" cy="128" r="24" fill="black"/>
|
|
3
|
+
<g fill="none" stroke="black" stroke-width="18" stroke-linecap="round">
|
|
4
|
+
<path d="M95.6 88.4A56 56 0 0 1 95.6 167.6"/>
|
|
5
|
+
<path d="M126.7 57.3A100 100 0 0 1 126.7 198.7"/>
|
|
6
|
+
<path d="M157.8 26.2A144 144 0 0 1 157.8 229.8"/>
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "echo",
|
|
3
|
+
"displayName": "回声(模板)",
|
|
4
|
+
"description": "最小的 Agent 插件模板:手写 ACP 的回声 Agent,没有依赖;提示词以 wait 开头时演示等待项登记与自主轮次。",
|
|
5
|
+
"version": "1.1.0",
|
|
6
|
+
"contributes": {
|
|
7
|
+
"agents": [
|
|
8
|
+
{
|
|
9
|
+
"id": "echo",
|
|
10
|
+
"displayName": "回声",
|
|
11
|
+
"icon": {
|
|
12
|
+
"light": "icons/echo.pdf",
|
|
13
|
+
"template": true
|
|
14
|
+
},
|
|
15
|
+
"command": "exec \"$CODA_NODE\" \"$CODA_PLUGIN_PATH/agent/entry.mjs\"",
|
|
16
|
+
"setupHint": "回声 Agent 不需要登录,也不联网;起不来时看运行机上 Coda 后端的 Node。"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/** @import { Coda, Json } from '@coda-console/plugin-check/types' */
|
|
3
|
+
|
|
4
|
+
const NOTE = 'notes/note@1';
|
|
5
|
+
|
|
6
|
+
/** @param {Coda} coda */
|
|
7
|
+
export async function activate(coda) {
|
|
8
|
+
// A query: the notes this plugin holds, those whose title has `query` in it, and how many note_notes.added this module has been told of.
|
|
9
|
+
let seen = 0;
|
|
10
|
+
coda.handle(NOTE, 'find', async input => {
|
|
11
|
+
const { query = '' } = /** @type {{ query?: string }} */ (input);
|
|
12
|
+
const entries = await coda.list(NOTE, { scope: 'local' });
|
|
13
|
+
return { seen, notes: entries.filter(entry => String(entry.spec.title).includes(query)).map(entry => ({ key: String(entry.key), title: String(entry.spec.title) })) };
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// A doing call: the input's limits (the schema) refuse what cannot be written before anything is. Once the note is saved the call
|
|
17
|
+
// does not fail: if note_notes.added cannot be published, it says so (`notified`), for the note is there. Each call publishes one.
|
|
18
|
+
coda.handle(NOTE, 'add', async input => {
|
|
19
|
+
const { title, body, project } = /** @type {{ title: string, body: string, project: string }} */ (input);
|
|
20
|
+
const entry = await coda.put({ kind: NOTE, key: title }, { spec: { title, body } });
|
|
21
|
+
/** @type {Json} */
|
|
22
|
+
let result = { key: title, notified: true };
|
|
23
|
+
try {
|
|
24
|
+
await coda.emit('note_notes.added', { key: title, title, body }, { subject: `note:${entry.id}`, project });
|
|
25
|
+
} catch (e) {
|
|
26
|
+
result = { key: title, notified: false, reason: String(e) };
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// The welcome note, only while there are no notes: `replace` gives every record of the kind whole, so it would wipe the others.
|
|
32
|
+
if (!(await coda.list(NOTE, { scope: 'local' })).length)
|
|
33
|
+
await coda.replace(NOTE, [{ key: '欢迎', spec: { title: '欢迎', body: '这是模板自带的一条便条。' } }]);
|
|
34
|
+
|
|
35
|
+
// The event group `watch` of the protocol, in `uses`: it only reads the events.
|
|
36
|
+
coda.on('note_notes.added', () => { seen++; });
|
|
37
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "notes",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "notes",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@coda-console/plugin-check": "0.8.25"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"coda": 3
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"node_modules/@0dep/piso": {
|
|
18
|
+
"version": "5.2.0",
|
|
19
|
+
"resolved": "https://registry.npmjs.org/@0dep/piso/-/piso-5.2.0.tgz",
|
|
20
|
+
"integrity": "sha512-2XQye5870MQZsUvJ5M5p+WtqN6q7jp+e0OeHrXORNm5HJmsmKTSYgkao5RNnWS6tFmsBbIx5hgbxJPEuaQZneg==",
|
|
21
|
+
"dev": true,
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"workspaces": [
|
|
24
|
+
"bench"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=14"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"node_modules/@agentclientprotocol/sdk": {
|
|
31
|
+
"version": "2.6.0",
|
|
32
|
+
"resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-2.6.0.tgz",
|
|
33
|
+
"integrity": "sha512-3FtL6MkAV5F9qxg0FQV8wmBszIm2xuVPoDWOILIFSDQ+Vq3Twdh7Cw6Hk2GOPUbevgrTUpUAqZXQy7Geaj79mw==",
|
|
34
|
+
"dev": true,
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
38
|
+
"zod": "^3.25.76 || ^4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependenciesMeta": {
|
|
41
|
+
"@modelcontextprotocol/server": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"node_modules/@coda-console/plugin-check": {
|
|
47
|
+
"version": "0.8.25",
|
|
48
|
+
"resolved": "https://registry.npmjs.org/@coda-console/plugin-check/-/plugin-check-0.8.25.tgz",
|
|
49
|
+
"dev": true,
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@0dep/piso": "5.2.0",
|
|
53
|
+
"@agentclientprotocol/sdk": "2.6.0",
|
|
54
|
+
"@coda-console/protocol": "6.15.0",
|
|
55
|
+
"ajv": "8.20.0",
|
|
56
|
+
"yaml": "2.9.1"
|
|
57
|
+
},
|
|
58
|
+
"bin": {
|
|
59
|
+
"coda-plugin-check": "bin/check.mjs"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=24"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"node_modules/@coda-console/protocol": {
|
|
66
|
+
"version": "6.15.0",
|
|
67
|
+
"resolved": "https://registry.npmjs.org/@coda-console/protocol/-/protocol-6.15.0.tgz",
|
|
68
|
+
"integrity": "sha512-xTcQdwb1QX0dNiAIh5Qz966dWoB5kqpkpZja51nJg/86+ABhIoqG4FsdlaizMYMUnyEBvdfxq1Lf89HSix1FnA==",
|
|
69
|
+
"dev": true,
|
|
70
|
+
"license": "MIT",
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@0dep/piso": "5.2.0",
|
|
73
|
+
"ajv": "8.20.0",
|
|
74
|
+
"bpmn-moddle": "10.3.1",
|
|
75
|
+
"feelin": "8.2.0"
|
|
76
|
+
},
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=24"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"node_modules/@lezer/common": {
|
|
82
|
+
"version": "1.5.5",
|
|
83
|
+
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.5.tgz",
|
|
84
|
+
"integrity": "sha512-Pw7PVCndruF1pb3ebCxpSVpkMHSDjwRCLcTRw+RizUKco5QbWylwq2g4lnG/RYN7yTTQDXE9F77MwtkAyphrjg==",
|
|
85
|
+
"dev": true,
|
|
86
|
+
"license": "MIT"
|
|
87
|
+
},
|
|
88
|
+
"node_modules/@lezer/highlight": {
|
|
89
|
+
"version": "1.2.5",
|
|
90
|
+
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.5.tgz",
|
|
91
|
+
"integrity": "sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==",
|
|
92
|
+
"dev": true,
|
|
93
|
+
"license": "MIT",
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"@lezer/common": "^1.3.0"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"node_modules/@lezer/lr": {
|
|
99
|
+
"version": "1.4.12",
|
|
100
|
+
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.12.tgz",
|
|
101
|
+
"integrity": "sha512-On9HU4oMMiHPMkQDgoTnGahjgG5n/MkN38CgG77sMraKLL+3JBbeQNi1FcCXV9QRqwF9/BUXP3caHyJC1fBOTQ==",
|
|
102
|
+
"dev": true,
|
|
103
|
+
"license": "MIT",
|
|
104
|
+
"dependencies": {
|
|
105
|
+
"@lezer/common": "^1.0.0"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"node_modules/ajv": {
|
|
109
|
+
"version": "8.20.0",
|
|
110
|
+
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
|
|
111
|
+
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
|
|
112
|
+
"dev": true,
|
|
113
|
+
"license": "MIT",
|
|
114
|
+
"dependencies": {
|
|
115
|
+
"fast-deep-equal": "^3.1.3",
|
|
116
|
+
"fast-uri": "^3.0.1",
|
|
117
|
+
"json-schema-traverse": "^1.0.0",
|
|
118
|
+
"require-from-string": "^2.0.2"
|
|
119
|
+
},
|
|
120
|
+
"funding": {
|
|
121
|
+
"type": "github",
|
|
122
|
+
"url": "https://github.com/sponsors/epoberezkin"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"node_modules/bpmn-moddle": {
|
|
126
|
+
"version": "10.3.1",
|
|
127
|
+
"resolved": "https://registry.npmjs.org/bpmn-moddle/-/bpmn-moddle-10.3.1.tgz",
|
|
128
|
+
"integrity": "sha512-xjJ8GzseRkjjM0MX/rODVB6iv+rhGLt8FCHJIovLAjJsDEAUjITfyiJZYczJ4pp3wmesbY3sQR7eRT+q5uroVA==",
|
|
129
|
+
"dev": true,
|
|
130
|
+
"license": "MIT",
|
|
131
|
+
"dependencies": {
|
|
132
|
+
"min-dash": "^5.1.0",
|
|
133
|
+
"moddle": "^8.2.1",
|
|
134
|
+
"moddle-xml": "^12.3.1"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"node_modules/fast-deep-equal": {
|
|
138
|
+
"version": "3.1.3",
|
|
139
|
+
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
|
140
|
+
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
|
141
|
+
"dev": true,
|
|
142
|
+
"license": "MIT"
|
|
143
|
+
},
|
|
144
|
+
"node_modules/fast-uri": {
|
|
145
|
+
"version": "3.1.9",
|
|
146
|
+
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
|
|
147
|
+
"integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
|
|
148
|
+
"dev": true,
|
|
149
|
+
"funding": [
|
|
150
|
+
{
|
|
151
|
+
"type": "github",
|
|
152
|
+
"url": "https://github.com/sponsors/fastify"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"type": "opencollective",
|
|
156
|
+
"url": "https://opencollective.com/fastify"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"license": "BSD-3-Clause"
|
|
160
|
+
},
|
|
161
|
+
"node_modules/feelin": {
|
|
162
|
+
"version": "8.2.0",
|
|
163
|
+
"resolved": "https://registry.npmjs.org/feelin/-/feelin-8.2.0.tgz",
|
|
164
|
+
"integrity": "sha512-o/oUBp7hzcsupV3Pf+Kn+43y+gul/sSVqYYkJq9+hkYuFuBfk0rocy//H2goKlWJJbuONnE59Iqb4U34VyZpjA==",
|
|
165
|
+
"dev": true,
|
|
166
|
+
"license": "MIT",
|
|
167
|
+
"dependencies": {
|
|
168
|
+
"@lezer/common": "^1.5.2",
|
|
169
|
+
"lezer-feel": "^3.0.1",
|
|
170
|
+
"min-dash": "^5.1.0",
|
|
171
|
+
"temporal-polyfill": "^1.0.4"
|
|
172
|
+
},
|
|
173
|
+
"engines": {
|
|
174
|
+
"node": ">= 20.12.0"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"node_modules/json-schema-traverse": {
|
|
178
|
+
"version": "1.0.0",
|
|
179
|
+
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
|
|
180
|
+
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
|
|
181
|
+
"dev": true,
|
|
182
|
+
"license": "MIT"
|
|
183
|
+
},
|
|
184
|
+
"node_modules/lezer-feel": {
|
|
185
|
+
"version": "3.0.1",
|
|
186
|
+
"resolved": "https://registry.npmjs.org/lezer-feel/-/lezer-feel-3.0.1.tgz",
|
|
187
|
+
"integrity": "sha512-tTOBq2ZOwfekNXg7eflg9WK/jl4LW4pryR3wiGRp1/ODXBG3ngo2mqXcriULylTjdxCnz42ByMMFEgbOK0L7kg==",
|
|
188
|
+
"dev": true,
|
|
189
|
+
"license": "MIT",
|
|
190
|
+
"dependencies": {
|
|
191
|
+
"@lezer/highlight": "^1.2.3",
|
|
192
|
+
"@lezer/lr": "^1.4.10",
|
|
193
|
+
"min-dash": "^5.0.0"
|
|
194
|
+
},
|
|
195
|
+
"engines": {
|
|
196
|
+
"node": ">= 20.12.0"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"node_modules/min-dash": {
|
|
200
|
+
"version": "5.1.0",
|
|
201
|
+
"resolved": "https://registry.npmjs.org/min-dash/-/min-dash-5.1.0.tgz",
|
|
202
|
+
"integrity": "sha512-HAvN6XzmCQj+js43G9sJRRw8kj/7DvoxN7qhoIN9Xo5ZN1NMljtpyKs/NunXmw0QSWwlgZzNv6tLeEa4xaZ0tg==",
|
|
203
|
+
"dev": true,
|
|
204
|
+
"license": "MIT"
|
|
205
|
+
},
|
|
206
|
+
"node_modules/moddle": {
|
|
207
|
+
"version": "8.2.1",
|
|
208
|
+
"resolved": "https://registry.npmjs.org/moddle/-/moddle-8.2.1.tgz",
|
|
209
|
+
"integrity": "sha512-20qzO/ZpMGO9j9gdQgXk9bfGxb9wA3JKnGth/21YZKODLrZE4RW/uVMIL5pTskYm34Z61DucBEPkq93qByNsBQ==",
|
|
210
|
+
"dev": true,
|
|
211
|
+
"license": "MIT",
|
|
212
|
+
"dependencies": {
|
|
213
|
+
"min-dash": "^5.1.0"
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
"node_modules/moddle-xml": {
|
|
217
|
+
"version": "12.3.2",
|
|
218
|
+
"resolved": "https://registry.npmjs.org/moddle-xml/-/moddle-xml-12.3.2.tgz",
|
|
219
|
+
"integrity": "sha512-fo6DSZdLr7Lr4ydgpHbEQEXu63QxxRPNmu5k2n3B/+oRTT9ybBLrcxo/hIK6Bo16ORVtw8FoZbwRCwZRr5l19g==",
|
|
220
|
+
"dev": true,
|
|
221
|
+
"license": "MIT",
|
|
222
|
+
"dependencies": {
|
|
223
|
+
"min-dash": "^5.1.0",
|
|
224
|
+
"saxen": "^11.2.0"
|
|
225
|
+
},
|
|
226
|
+
"engines": {
|
|
227
|
+
"node": ">= 18"
|
|
228
|
+
},
|
|
229
|
+
"peerDependencies": {
|
|
230
|
+
"moddle": ">= 6.2.0"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
"node_modules/require-from-string": {
|
|
234
|
+
"version": "2.0.2",
|
|
235
|
+
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
|
236
|
+
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
|
237
|
+
"dev": true,
|
|
238
|
+
"license": "MIT",
|
|
239
|
+
"engines": {
|
|
240
|
+
"node": ">=0.10.0"
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
"node_modules/saxen": {
|
|
244
|
+
"version": "11.2.0",
|
|
245
|
+
"resolved": "https://registry.npmjs.org/saxen/-/saxen-11.2.0.tgz",
|
|
246
|
+
"integrity": "sha512-2bG564AAJcm/3vyZC0Uhs/mACrH+4AHMaKHKAB2M5xMqomUZa27FQ7MYaQGFKVcJk/MVzSEQ34A8QZWW+eiWEw==",
|
|
247
|
+
"dev": true,
|
|
248
|
+
"license": "MIT",
|
|
249
|
+
"engines": {
|
|
250
|
+
"node": ">= 20.12"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"node_modules/temporal-polyfill": {
|
|
254
|
+
"version": "1.0.8",
|
|
255
|
+
"resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-1.0.8.tgz",
|
|
256
|
+
"integrity": "sha512-RCCGa0GddT099XG49ijdD0tDf86L8vfuZun1+JyJiO4Y2NP9PACQsG0OnvNPXwVLisdvhr/zqL2nhKQmXXx08A==",
|
|
257
|
+
"dev": true,
|
|
258
|
+
"license": "MIT",
|
|
259
|
+
"dependencies": {
|
|
260
|
+
"temporal-spec": "1.0.1",
|
|
261
|
+
"temporal-utils": "1.0.4"
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
"node_modules/temporal-spec": {
|
|
265
|
+
"version": "1.0.1",
|
|
266
|
+
"resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-1.0.1.tgz",
|
|
267
|
+
"integrity": "sha512-wxVoanmDeavXie1vu2JaQ3WIc3JZnWAOYFBsJyATaVsXsycKYUflGsyBmrRSnoCpZJpwPyr38VpgSUlQ8CbFxg==",
|
|
268
|
+
"dev": true,
|
|
269
|
+
"license": "Apache-2.0"
|
|
270
|
+
},
|
|
271
|
+
"node_modules/temporal-utils": {
|
|
272
|
+
"version": "1.0.4",
|
|
273
|
+
"resolved": "https://registry.npmjs.org/temporal-utils/-/temporal-utils-1.0.4.tgz",
|
|
274
|
+
"integrity": "sha512-4mAcgbWlaxe+gn23gk8g0iHxCVGVOhKzSCfF5HM3lfvH8BdT+/pBmH/R/E4CrIse+koUgs8ThkPzCLnui6Fi8w==",
|
|
275
|
+
"dev": true,
|
|
276
|
+
"license": "MIT"
|
|
277
|
+
},
|
|
278
|
+
"node_modules/yaml": {
|
|
279
|
+
"version": "2.9.1",
|
|
280
|
+
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz",
|
|
281
|
+
"integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==",
|
|
282
|
+
"dev": true,
|
|
283
|
+
"license": "ISC",
|
|
284
|
+
"bin": {
|
|
285
|
+
"yaml": "bin.mjs"
|
|
286
|
+
},
|
|
287
|
+
"engines": {
|
|
288
|
+
"node": ">= 14.6"
|
|
289
|
+
},
|
|
290
|
+
"funding": {
|
|
291
|
+
"url": "https://github.com/sponsors/eemeli"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"node_modules/zod": {
|
|
295
|
+
"version": "4.6.7",
|
|
296
|
+
"resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
|
|
297
|
+
"integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
|
|
298
|
+
"dev": true,
|
|
299
|
+
"license": "MIT",
|
|
300
|
+
"peer": true,
|
|
301
|
+
"funding": {
|
|
302
|
+
"url": "https://github.com/sponsors/colinhacks"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "notes",
|
|
3
|
+
"displayName": "便条(模板)",
|
|
4
|
+
"description": "带模块的插件模板:自己的协议 notes/note@1(一个查询、一个做事的操作、一个事件),模块登记操作、写记录、发布并订阅事件,附测试。",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"categories": ["工作流程"],
|
|
7
|
+
"main": "main.mjs",
|
|
8
|
+
"engines": { "coda": 3 },
|
|
9
|
+
"uses": { "notes/note@1": ["watch"] },
|
|
10
|
+
"scripts": { "test": "node --test" },
|
|
11
|
+
"devDependencies": { "@coda-console/plugin-check": "0.8.25" },
|
|
12
|
+
"contributes": {
|
|
13
|
+
"protocols": [
|
|
14
|
+
{
|
|
15
|
+
"name": "notes/note@1",
|
|
16
|
+
"title": "便条",
|
|
17
|
+
"description": "一条便条:标题与正文。",
|
|
18
|
+
"spec": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": { "title": { "type": "string", "minLength": 1, "maxLength": 100 }, "body": { "type": "string", "maxLength": 10000 } },
|
|
21
|
+
"required": ["title", "body"],
|
|
22
|
+
"additionalProperties": false
|
|
23
|
+
},
|
|
24
|
+
"status": { "type": "object", "properties": {}, "additionalProperties": false },
|
|
25
|
+
"operations": {
|
|
26
|
+
"find": {
|
|
27
|
+
"safe": true,
|
|
28
|
+
"description": "按标题里含的字查便条,不写就是全部;seen 是模块这次启动以来收到的 note_notes.added 事件数。",
|
|
29
|
+
"input": { "type": "object", "properties": { "query": { "type": "string" } }, "additionalProperties": false },
|
|
30
|
+
"result": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"seen": { "type": "integer", "minimum": 0 },
|
|
34
|
+
"notes": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": { "key": { "type": "string" }, "title": { "type": "string" } },
|
|
39
|
+
"required": ["key", "title"],
|
|
40
|
+
"additionalProperties": false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"required": ["notes", "seen"],
|
|
45
|
+
"additionalProperties": false
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"add": {
|
|
49
|
+
"description": "记一条便条(同标题是同一条),先写入,写入成功后才发布 note_notes.added;每次调用都发一条事件,同标题再记也发。发布失败时调用不失败(便条已存下):结果里 notified 为 false,reason 写原因。标题与正文的长度在输入里限住,超了在写入前就拒绝;project 是事件发布在哪个项目。",
|
|
50
|
+
"input": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"properties": { "title": { "type": "string", "minLength": 1, "maxLength": 100 }, "body": { "type": "string", "maxLength": 10000 }, "project": { "type": "string", "minLength": 1 } },
|
|
53
|
+
"required": ["title", "body", "project"],
|
|
54
|
+
"additionalProperties": false
|
|
55
|
+
},
|
|
56
|
+
"result": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": { "key": { "type": "string" }, "notified": { "type": "boolean" }, "reason": { "type": "string" } },
|
|
59
|
+
"required": ["key", "notified"],
|
|
60
|
+
"additionalProperties": false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"events": {
|
|
65
|
+
"note_notes.added": {
|
|
66
|
+
"description": "记了一条便条。",
|
|
67
|
+
"payload": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": { "key": { "type": "string" }, "title": { "type": "string" }, "body": { "type": "string" } },
|
|
70
|
+
"required": ["key", "title", "body"],
|
|
71
|
+
"additionalProperties": false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"permissions": { "watch": { "title": "订阅便条事件", "events": ["note_notes.added"] } }
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"protocolImplementations": ["notes/note@1"]
|
|
79
|
+
}
|
|
80
|
+
}
|