@coda-console/plugin-check 0.5.17 → 0.5.18
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 +2 -2
- package/check/index.mjs +5 -3
- package/check/workflows.mjs +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -399,7 +399,7 @@ gh workflow run publish.yml --repo coda-console/coda-plugins --ref main
|
|
|
399
399
|
|
|
400
400
|
## 契约检查
|
|
401
401
|
|
|
402
|
-
扮演 Coda 去读一个插件目录:清单对 Coda 的类型 schema
|
|
402
|
+
扮演 Coda 去读一个插件目录:清单对 Coda 的类型 schema 校验,流程按 Coda 的流程方言读,Agent 照 Coda 的样子启动、说 Coda 说的话,面板由 Coda 的资源插件模块读一次。
|
|
403
403
|
插件写的合乎它用到的类型就对:清单的写法只在协议包 `@coda-console/protocol`([coda-console/coda-protocol](https://github.com/coda-console/coda-protocol))的 schema 里,由 Coda 自己用的同一个校验器判,
|
|
404
404
|
检查包不另写规则,Coda 加字段只是改 schema。`check/coda/` 是 Coda 文件的原样副本(见[契约副本](#契约副本)),检查包手写的只有怎样扮演 Coda、怎样判。
|
|
405
405
|
只在装到一台机器上才知道的(仓库里扫不扫得到、npm 锁文件、和那台已装插件冲突)是那台 Coda 安装时说的,不是插件类型的问题,检查不跑。
|
|
@@ -414,7 +414,7 @@ npx github:coda-console/coda-plugins#<提交> <插件目录>
|
|
|
414
414
|
|
|
415
415
|
| 级 | 要不要登录 | 查什么 |
|
|
416
416
|
| --- | --- | --- |
|
|
417
|
-
| 清单(总是) | 不要 | `package.json` 对 Coda 的类型 schema 校验(`manifestProblem`),再照 Coda 读成插件(`readPlugin`:ID、设置名在 ID 之下);写给别的插件扩展点的键,要有 Coda
|
|
417
|
+
| 清单(总是) | 不要 | `package.json` 对 Coda 的类型 schema 校验(`manifestProblem`),再照 Coda 读成插件(`readPlugin`:ID、设置名在 ID 之下);写给别的插件扩展点的键,要有 Coda 自带的或旁边依赖的插件声明这个类型。面板写法按资源插件给扩展点 `panels` 带的 schema 查。`.coda/workflows/` 里的每个流程(含能力)按协议的流程方言读(`workflowProblem`):不是 BPMN、认不出的 `coda:` 属性或元素、没有的动作或动作不接受的参数都算失败。另有只提醒的:分类、版本、图标页面太小、旧的 Agent ID `claude` |
|
|
418
418
|
| 握手(默认) | 不要 | `sh -c` 启动 `command`(环境是 Coda 的 `pluginEnv` 给的:`CODA_NODE`、`CODA_PLUGIN_PATH`、临时的 `CODA_PLUGIN_STATE`、设置默认值的 `CODA_PLUGIN_SETTINGS`;依赖的插件在旁边(同一个父目录里同名的目录)时 `CODA_PLUGIN_DEPENDENCIES` 给它的目录,Coda 自带的不在这里、不给),发与 Coda 相同的 `initialize`,要求 `protocolVersion` 为 1、声明会话指令(`sessionCapabilities.systemPrompt`,没声明算失败);`session/new` 带会话指令,给出会话与当前模型,回 -32000 记为未登录、跳过后面的检查(不算失败);像 Coda 一样对进程组发 SIGTERM,5 秒内要退出(超过 0.8 秒提醒);另起一个进程,关掉标准输入后 5 秒内不退出只提醒。面板由 Coda 资源插件的 `Panels` 读一次(30 秒),输出合格式 |
|
|
419
419
|
| 一轮(`--live`) | 要 | 第一轮问会话指令里的检查词(一个随机词),回复里要有它;再发一轮提示词(默认「只回复 ok」)收到 `stopReason`;每条 `session/update` 过 ACP SDK 的 schema;`_coda/wait` 按 Coda 的 `validWait` 与协议的规则核对(子 Agent 不带 `childSessionId`、定时不带 `at` 只提醒);审批与提问一律回拒绝,在一轮之外发来的算失败;再发一轮并 `session/cancel`,30 秒内要结束,读到取消后还在做事或拖过 5 秒才答复却不回 `cancelled` 算失败(见下);有自主轮次的也取消一次;声明插话的,一轮结束后插话要回 `promptRequired` 且不自己另开一轮,一轮进行中插话要回 `injected` 或 `promptRequired`(`injected` 的那一轮照常回 `stopReason`);声明 `loadSession` 的,新开进程 `session/load`(同样带会话指令)要成功,随后在新进程里再跑一轮也要收到 `stopReason` |
|
|
420
420
|
|
package/check/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
// The contract check of one plugin directory: the manifest, then each agent's handshake (and with `live`, a
|
|
2
|
-
// panel's reading. The manifest is checked against Coda's schemas of its types
|
|
3
|
-
// a plugin is written.
|
|
1
|
+
// The contract check of one plugin directory: the manifest and its workflows, then each agent's handshake (and with `live`, a
|
|
2
|
+
// turn) and each panel's reading. The manifest is checked against Coda's schemas of its types and its workflows against Coda's
|
|
3
|
+
// dialect of BPMN (both the protocol's), the rest by Coda's own code (check/coda/), run where a plugin is written.
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { checkAgent } from './agent.mjs';
|
|
6
6
|
import { checkManifest } from './manifest.mjs';
|
|
7
7
|
import { checkPanel } from './panel.mjs';
|
|
8
|
+
import { checkWorkflows } from './workflows.mjs';
|
|
8
9
|
import { Report } from './report.mjs';
|
|
9
10
|
|
|
10
11
|
// `agent`: only this agent of the plugin; `manifestOnly`: nothing is run; `live`: one turn each with `prompt`.
|
|
@@ -12,6 +13,7 @@ export async function checkPlugin(dir, { agent: only = null, manifestOnly = fals
|
|
|
12
13
|
const pluginDir = resolve(dir), report = new Report();
|
|
13
14
|
const plugin = checkManifest(pluginDir, report.scope('manifest'));
|
|
14
15
|
if (!plugin) return { report, plugin };
|
|
16
|
+
await checkWorkflows(plugin, report.scope('manifest'));
|
|
15
17
|
const agents = only ? plugin.agents.filter(a => a.id === only) : plugin.agents;
|
|
16
18
|
if (only && !agents.length) report.scope('manifest').fail('options.agent', `清单里没有能检查的 Agent ${only}`);
|
|
17
19
|
if (manifestOnly) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The plugin's workflows (and capabilities: workflows too), at the manifest level: each `.coda/workflows/<name>.bpmn` read
|
|
2
|
+
// with Coda's dialect of BPMN, as the protocol has it (@coda-console/protocol/workflow) and Coda reads it: not BPMN, a coda:
|
|
3
|
+
// attribute or element the dialect does not have, an action it does not have or a parameter the action does not take, is
|
|
4
|
+
// a workflow Coda does not take. What each value may be Coda checks as it reads one; this check does not yet (coda#2027).
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { workflowProblem } from '@coda-console/protocol/workflow';
|
|
8
|
+
|
|
9
|
+
export async function checkWorkflows({ plugin }, say) {
|
|
10
|
+
for (const name of plugin.workflows) {
|
|
11
|
+
const problem = await workflowProblem(readFileSync(join(plugin.dir, '.coda/workflows', `${name}.bpmn`), 'utf8'), name);
|
|
12
|
+
if (problem) say.fail('manifest.workflows', problem);
|
|
13
|
+
else say.pass('manifest.workflows', `流程 ${name}:合乎 Coda 的流程方言`);
|
|
14
|
+
}
|
|
15
|
+
}
|