@coda-console/protocol 6.11.0 → 6.13.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/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  版本规矩见 README 的[「版本」一节](README.md#版本)。协议自己的大版本写在协议名里(如 `coda/run@1`),与 npm 包版本、插件清单的 v2 独立;更早的版本见 git 历史。
4
4
 
5
+ ## 6.13.0 — 2026-11-19
6
+
7
+ - 这是在 6.12.0 之上的次版本(6.12.0 由 H9-B 在途,版本号暂排其后,合并时跟上 main 再顺延)。依据 README「版本」一节:清单新增可选根键,旧清单照旧通过;这一键进稳定面,`stable/manifest.json` 加 `engines.coda`,`revision` 加到 3(Coda 宿主设计 H7-A,第 10 题)。
8
+ - 插件清单根加可选的 `engines.coda`:插件要的最低 Coda API Level,正整数;不写视为不限。写了 `0`、负数、小数或字符串,`manifestProblem` 报 `engines.coda`。`engines` 里的其余键(如 `node`)照旧不管,不报错。本包只管形状;API Level 的常量、快照与兼容判定由 Coda 实现。
9
+
10
+ ## 6.12.0 — 2026-11-18
11
+
12
+ - 这是在 6.11.0 之上的次版本。依据 README「版本」一节:`contributes.groups` 与流程方言都是内部面,删改、新增可选参数升次版本。`stable/manifest.json` 里没有 `groups`,删它不动稳定面,`stable-grows` 与 `test/stable.test.mjs` 不受影响。
13
+ - 流程方言:`hold-group` 加参数 `select`,按池子借:逗号分隔的 `键=值`,全部与组记录的 `attributes` 相等才算匹配,只匹配 `attributes`,如 `platform=android`、`platform=ios,model=duo`;`group`、`select` 恰写一个,两个都写或都不写,读流程就拒(`group、select 须恰写一个`)。`select` 写成纯文本时读流程就按 `键=值(,键=值)*` 查(键是 1–100 个不含空白、「=」「,」的字符;值是 1–100 个不含「=」「,」的字符,中间可有空格如 `model=Mi 10 Pro`,首尾不能是空白;长度按字符计,补充平面字符算一个),写成表达式或含 `{{ … }}` 时留到运行时。输出 `group` 是实际排到的那个组的名字。脚本步骤上的 `coda:group` 不加选择器。`workflow/actions.json` 的动作定义因此多了 `oneOf`(列出的参数恰写一个)与 `pattern`(参数写成文字时的写法)。
14
+ - 不兼容:删掉 `contributes.groups`:删去 `schemas/plugin/groups.json`。名额不再由插件在清单里声明,改由插件写 `coda/group@1` 记录,容量取记录的 `capacity`(不写为 1)。`extension-points.json` 里保留键名单的 `groups` 留着,第三方仍不能把它当扩展点的键。清单里再写 `contributes.groups` 的结果与别的不认识的键一样:不查形状,`manifestProblem` 通过。README 里 `contributionProblem` 的示例改用 `modelProviders`。
15
+
5
16
  ## 6.11.0 — 2026-11-18
6
17
 
7
18
  - 这是在 6.10.0 之上的次版本。依据 README「版本」一节:协议定义是内部面,新增可选字段升次版本;`stable/` 不动,`stable/manifest.json` 与 `stable/view.json` 没有任何协议定义的字段,清单与页面接口都没变,旧清单、旧定义照旧通过(Coda 宿主设计 coda#2749 第 12 节,只读记录流)。
package/README.md CHANGED
@@ -40,7 +40,7 @@ import { contributionProblem, manifestProblem, pointProblem, valueProblem, TYPES
40
40
  // 整份清单的外壳与通用键;给出插件目录时,连同它点名的文件一起查(x-file)。合乎类型返回 null,否则是一句说明:哪里、schema 怎么说。
41
41
  const manifest = JSON.parse(readFileSync('plugin/package.json', 'utf8'));
42
42
  const problem = manifestProblem(manifest, 'plugin');
43
- // 不是通用键的一个键,按声明它的一方给的 schema,放在整份清单里查:指针从清单的根算(groups 的 capacity 指向本插件的设置)。
43
+ // 不是通用键的一个键,按声明它的一方给的 schema,放在整份清单里查:指针从清单的根算(modelProviders 的 ${config:…} 指向本插件的设置)。
44
44
  contributionProblem(SCHEMAS['agents.json'], manifest, 'agents', 'plugin');
45
45
  // 某个类型里的一部分,如输入框模式声明的参数。
46
46
  valueProblem('composer-modes.json#/$defs/parameters', parameters, '插件给出的参数');
@@ -89,6 +89,8 @@ optionsProblem([{ id: 'release', name: '发布正式版', default: false, inputs
89
89
 
90
90
  插件清单可以声明 `"coda": { "channels": ["preview"] }`,限定只在预览版后端安装和更新。允许的通道是 `stable`(正式版)和 `preview`(预览版);数组非空、不重复。不写 `channels` 的插件不限制通道。
91
91
 
92
+ 清单根上的 `engines.coda` 是插件要的最低 Coda API Level,正整数;不写视为不限。`engines` 里的其余键(如 `node`)照旧不管。这个键在稳定面里,本包只管形状,数字对应哪一版 Coda 由 Coda 定。
93
+
92
94
  宿主按每台目标后端自己的安装记录判断,不按 Mac / iPhone 客户端版本判断;没有通道记录的后端不满足显式限制。商店和直接从 npm、Git 安装执行同一限制。这是 Coda 的安装约束,不改变 npm 包的公开性,也不能约束不认识该字段的旧宿主。
93
95
 
94
96
  ## 输入框模式
@@ -156,7 +158,7 @@ Coda 与检查包都钉一个确切版本。对第三方的兼容承诺只覆盖
156
158
  三道检查分别守住:
157
159
 
158
160
  - `scripts/stable-grows.mjs <基线>`:两份数据的旧条目及其取值必须全部保留,有新增时对应文件的 revision 必须增大,不能倒退。基线可为 git 提交、解包目录或 `npm:latest`。PR 和目标分支比较,发布前下载并解包 npm latest 比较;基线还没有 stable 文件时通过。
159
- - `test/stable.test.mjs`:54 条路径仍在 schema 中可达,承诺的取值仍被接受。使用固定样本选择条件分支,支持 `$ref`、`allOf`、`anyOf`、`if/then/else`、`not`、`properties`、`items`、`additionalProperties` 及布尔 schema;未知写法失败,不推测其含义。`agents`、`commands`、`skills` 从各自的业务 schema 起步。
161
+ - `test/stable.test.mjs`:55 条路径仍在 schema 中可达,承诺的取值仍被接受。使用固定样本选择条件分支,支持 `$ref`、`allOf`、`anyOf`、`if/then/else`、`not`、`properties`、`items`、`additionalProperties` 及布尔 schema;未知写法失败,不推测其含义。`agents`、`commands`、`skills` 从各自的业务 schema 起步。
160
162
  - `test/third-party.test.mjs`:两版 pi、一版 resource-manager 原文与 company 合成样本,分别跑整份清单和每个贡献键的校验,防止样本用到的约束被收紧。不检查磁盘文件与页面桥行为。这个仓库只守页面接口清单只增不减;页面接口的实现在 Coda 的客户端里,这里不核对。
161
163
 
162
164
  增加稳定面一项时,先补 schema 或页面实现,再把路径、取值或页面条目加进对应 JSON;每加一项,该文件 revision 加一。补充能覆盖新路径和条件分支的测试样本,运行三道检查,并更新次版本与 CHANGELOG。
package/docs/protocol.md CHANGED
@@ -274,6 +274,14 @@ invocationResponseProblem(response); // 恰好有 result 或 run 之一
274
274
 
275
275
  协议名与组名只查写法;协议和组在不在目录里,由 Coda 校验。实现一个协议不用在 `uses` 里申请它。
276
276
 
277
+ 清单根上的 `engines.coda` 写插件要的最低 Coda API Level,正整数(`0`、负数、小数、字符串都被拒);不写视为不限。`engines` 里的其余键(如 `node`)不管:
278
+
279
+ ```json
280
+ {"id": "my-plugin", "engines": {"coda": 3}}
281
+ ```
282
+
283
+ 这里只查形状;Coda 当前的 API Level 与兼容判定由 Coda 实现。
284
+
277
285
  `manifestProblem` 校验清单的外壳与通用键(这两个键在其中);别的键由 Coda 的贡献点登记表或某个插件的扩展点声明,按声明方的 schema 校验,本包不管它们的形状。命名空间约束需要插件 ID,单独用:
278
286
 
279
287
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/protocol",
3
- "version": "6.11.0",
3
+ "version": "6.13.0",
4
4
  "description": "Coda 的协议:插件清单的类型(JSON Schema)、通用校验器、协议定义与调用信封、流程方言与 Agent 接入协议",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,6 +42,12 @@
42
42
  "items": {"$ref": "https://coda.pub/schemas/protocol/v1/definition.json#/$defs/operationName"}
43
43
  }
44
44
  },
45
+ "engines": {
46
+ "description": "对宿主的要求,写法同 VS Code 的 engines;Coda 只读 coda,其余键(如 node)是 npm 的,不管",
47
+ "properties": {
48
+ "coda": {"description": "要的最低 Coda API Level:正整数;不写视为不限。数字对应哪一版 Coda 由 Coda 定,这里只管形状", "type": "integer", "minimum": 1}
49
+ }
50
+ },
45
51
  "contributes": {
46
52
  "description": "插件带来的东西:每个键一种类型。这里只列通用键;其余键由 Coda 的贡献点登记表或某个插件的扩展点声明",
47
53
  "type": "object",
@@ -1,5 +1,5 @@
1
1
  {
2
- "revision": 2,
2
+ "revision": 3,
3
3
  "entries": [
4
4
  {
5
5
  "path": "name"
@@ -31,6 +31,9 @@
31
31
  {
32
32
  "path": "uses.*[]"
33
33
  },
34
+ {
35
+ "path": "engines.coda"
36
+ },
34
37
  {
35
38
  "path": "contributes.agents[].id"
36
39
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "coda:action:serviceTask 上写它,就是 Coda 在后端里做的一步,不写脚本。参数写成 <coda:param name value>,只认 params 列出的,required 列出的必须写;requires 写了某参数就必须同时写它列出的参数;enum 限定某参数写成文字(不是表达式、不含 {{ … }})时的取值",
2
+ "description": "coda:action:serviceTask 上写它,就是 Coda 在后端里做的一步,不写脚本。参数写成 <coda:param name value>,只认 params 列出的,required 列出的必须写;requires 写了某参数就必须同时写它列出的参数;oneOf 列出的参数恰写一个;enum 限定某参数写成文字(不是表达式、不含 {{ … }})时的取值;pattern 限定某参数写成文字时的写法",
3
3
  "actions": {
4
4
  "publish-stage": {"params": ["stage", "detail"],
5
5
  "description": "发布运行主体的会话此刻在流程里的阶段(stage)和放在状态旁的说明(detail),两者都空就是清掉;只用于由会话事件启动的运行"},
@@ -9,8 +9,10 @@
9
9
  "description": "停掉运行主体的会话托管的 Agent 进程,下次发消息时透明恢复;result 是 stopped、absent 或 busy"},
10
10
  "compact-session": {"params": [],
11
11
  "description": "请运行主体的会话的 Agent 压缩上下文(_coda/session/compact,见 docs/agent-protocol.md),从不失败:没压缩就写明原因"},
12
- "hold-group": {"params": ["group", "capacity", "borrow", "exclusive"],
13
- "description": "为这一步所在的那一段排进并发组 group,离开这一段或运行结束才放开;borrow 为 only 只借不排、no 从不借,exclusive 为 true 占满整组"},
12
+ "hold-group": {"params": ["group", "select", "capacity", "borrow", "exclusive"],
13
+ "oneOf": ["group", "select"],
14
+ "pattern": {"select": {"regex": "^[^\\s=,]{1,100}=[^\\s=,](?:[^=,]{0,98}[^\\s=,])?(,[^\\s=,]{1,100}=[^\\s=,](?:[^=,]{0,98}[^\\s=,])?)*$", "hint": "键=值,多个用逗号隔开,值的首尾不能是空白,如 platform=android,model=Mi 10 Pro"}},
15
+ "description": "为这一步所在的那一段排进并发组,离开这一段或运行结束才放开:group 点名一个组;select 按池子借,是逗号分隔的 键=值,全部与组记录的 attributes 相等才算匹配(如 platform=android),从匹配的组里挑一个排;group、select 恰写一个,输出 group 是实际排到的那个组的名字;borrow 为 only 只借不排、no 从不借,exclusive 为 true 占满整组"},
14
16
  "run-workflows": {"params": ["hook", "only", "commit", "inputs"], "required": ["hook"],
15
17
  "description": "在 commit(默认本次运行的)上启动项目里加入挂点 hook 的全部流程(项目自己的和启用插件的),only(流程名的 JSON 数组或逗号分隔)只启动其中这几个;各给它声明了的 inputs(JSON 对象),等它们都结束;有一个失败就失败"},
16
18
  "hook-joiners": {"params": ["hook", "commit"],
package/workflow.mjs CHANGED
@@ -37,9 +37,10 @@ export const CODA_OPTIONS = options;
37
37
  export const CODA_ACTIONS = Object.fromEntries(Object.entries(actions.actions).map(([name, action]) => [name, action.params]));
38
38
  // The parameters an action must be given, by its name; an action with none is not listed.
39
39
  const REQUIRED_PARAMS = Object.fromEntries(Object.entries(actions.actions).filter(([, action]) => action.required).map(([name, action]) => [name, action.required]));
40
- // What an action's parameters must keep to besides being named: the others one needs (`requires`, by parameter), and the
41
- // values a parameter written as plain text may take (`enum`); an action with neither is not listed.
42
- const PARAM_RULES = Object.fromEntries(Object.entries(actions.actions).filter(([, action]) => action.requires || action.enum).map(([name, action]) => [name, action]));
40
+ // What an action's parameters must keep to besides being named: the others one needs (`requires`, by parameter), exactly
41
+ // one of which to write (`oneOf`), and the values (`enum`) or the form (`pattern`) a parameter written as plain text may
42
+ // take; an action with none of them is not listed.
43
+ const PARAM_RULES = Object.fromEntries(Object.entries(actions.actions).filter(([, action]) => action.requires || action.oneOf || action.enum || action.pattern).map(([name, action]) => [name, action]));
43
44
  // The events Coda sends (dialect.json says what each is).
44
45
  export const CODA_EVENTS = Object.keys(dialect.events);
45
46
  export const { lifecycleStart: SESSION_OPENED, lifecycleFacts: SESSION_FACTS, dispatch: DISPATCH_EVENT, cancel: CANCEL_EVENT } = dialect.eventRoles;
@@ -310,6 +311,14 @@ export async function readWorkflow(source, file = 'workflow') {
310
311
  for (const [name, needs] of Object.entries(PARAM_RULES[task.action]?.requires ?? {}))
311
312
  if (given.some(p => p.name === name) && needs.some(need => !given.some(p => p.name === need)))
312
313
  return { problem: `${task.id}:coda:action ${task.action} 写了参数 ${name} 就须写参数 ${needs.join('、')}` };
314
+ const oneOf = PARAM_RULES[task.action]?.oneOf;
315
+ if (oneOf && given.filter(p => oneOf.includes(p.name)).length !== 1)
316
+ return { problem: `${task.id}:coda:action ${task.action} 的参数 ${oneOf.join('、')} 须恰写一个` };
317
+ for (const [name, { regex, hint }] of Object.entries(PARAM_RULES[task.action]?.pattern ?? {})) {
318
+ const value = given.find(p => p.name === name)?.value;
319
+ if (value !== undefined && !isExpression(value) && !value.includes('{{') && !new RegExp(regex, 'u').test(value))
320
+ return { problem: `${task.id}:coda:action ${task.action} 的参数 ${name} 须为 ${hint}` };
321
+ }
313
322
  for (const [name, values] of Object.entries(PARAM_RULES[task.action]?.enum ?? {})) {
314
323
  const value = given.find(p => p.name === name)?.value;
315
324
  if (value !== undefined && !isExpression(value) && !value.includes('{{') && !values.includes(value))
@@ -1,21 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://coda.pub/schemas/plugin/v2/groups.json",
4
- "title": "contributes.groups:并发组",
5
- "description": "有名字、有容量的锁:name 是任何进程都能拿的组名,capacity 是本插件的一项整数设置,说同时放进几个。",
6
- "type": "array",
7
- "items": {
8
- "type": "object",
9
- "properties": {
10
- "name": {"description": "组名:1–100 个非空白字符", "type": "string", "pattern": "^\\S{1,100}$"},
11
- "capacity": {
12
- "description": "capacity 是本插件声明的一项整数设置",
13
- "type": "string",
14
- "x-ref": {"pointer": "/contributes/configuration/properties", "match": {"properties": {"type": {"const": "integer"}}, "required": ["type"]}}
15
- }
16
- },
17
- "required": ["name", "capacity"],
18
- "additionalProperties": false
19
- },
20
- "x-unique-by": ["name"]
21
- }