@coda-console/plugin-check 0.5.26 → 0.5.28
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 +1 -1
- package/check/coda/adapters/admission-api.mjs +11 -0
- package/check/coda/adapters/provider-api.mjs +37 -0
- package/check/coda/builtin.json +3 -3
- package/check/coda/components/protocols/provider-definition.mjs +11 -0
- package/check/coda/components/protocols/types.mjs +76 -0
- package/check/coda/contract.json +9 -2
- package/check/coda/domain/plugin-services.mjs +5 -0
- package/check/coda/domain/resource-admission.mjs +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,13 +16,13 @@ plugins/grok-bot/ Grok Bot:把 xAI 云端 Bot 接成长期会话,原
|
|
|
16
16
|
plugins/opencode/ OpenCode:在运行机的 opencode acp 与 Coda 之间转发,送入会话指令与所选模型服务,模型按来源分组
|
|
17
17
|
plugins/codex-accounts/ Codex 多账号:管理登录、自动续期与账号选择,接管 Codex 额度面板
|
|
18
18
|
plugins/cursor/ Cursor:在运行机的 cursor-agent acp 与 Coda 之间转发,送入会话指令
|
|
19
|
+
plugins/git/ Git 源与快照:本机仓库 provider、运行关联的工作树/提交快照、临时 ref 回收与只读 smart HTTP v2
|
|
19
20
|
plugins/host/ 宿主资源:Xcode 构建、Apple 模拟器与项目要求排队的命令共用这台机器的一组名额(组 host、持锁执行 run-held、host-sim),面板「构建与模拟器名额」
|
|
20
21
|
plugins/magpie/ Magpie:把本机的 Magpie 网关作为模型服务提供给 Pi 等插件,安装时装好 Magpie 并让网关常驻
|
|
21
22
|
plugins/network-log/ 网络记录:默认关闭,按需开启建连等待与定时探测采集;关闭后仍可查看历史
|
|
22
23
|
plugins/review/ PR 生命流程:会话开的 PR 先跑项目的检查、再交叉评审,你批准后合并、部署与发布;也是写 PR 流程的样例
|
|
23
24
|
plugins/testbed/ 测试机:长插在 Mac 上的 iPhone、iPad 只经 use-testbed 使用,排到后装 App、交给会话操作、用完切黑屏;依赖宿主资源
|
|
24
25
|
plugins/composer/ 输入框模式:交接到新会话、子会话、! 执行命令、Ultra 与 /loop 循环;Ultra 模板设置为 composer.templates
|
|
25
|
-
plugins/ultra/ Ultra(已并入 @coda-console/composer,暂时保留旧包):输入框的协调模式,主 Agent 负责拆解、调度和验收,子会话负责实现、排查和测试;名单与模板在模式参数和设置里
|
|
26
26
|
templates/agent/ 最小的 Agent 插件:手写 ACP 的回声 Agent,演示会话指令、插话、Agent 活动与自主轮次
|
|
27
27
|
templates/panel/ 最小的面板插件:一张卡片、一条进度条、一个按钮
|
|
28
28
|
bin/、check/ 契约检查(仓库根的 package.json 就是它,@coda-console/plugin-check);check/coda/ 是 Coda 同步来的规则副本,不要手改
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { admissionFeatures } from '../domain/resource-admission.mjs';
|
|
2
|
+
|
|
3
|
+
// The module's local ledger API, exported unchanged to plugin-check.
|
|
4
|
+
export function admissionAPI(call) {
|
|
5
|
+
return {
|
|
6
|
+
features: admissionFeatures,
|
|
7
|
+
acquire: request => call('acquire', [request]),
|
|
8
|
+
release: lease => call('release', [lease]),
|
|
9
|
+
list: () => call('list', []),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The plugin host's local API. Controllers consume accepted objects serially per ID; they choose their own actions.
|
|
2
|
+
export function providerAPI({ call, watch, connection, report = console.error }) {
|
|
3
|
+
const observe = (kind, fn, scope = 'available') => watch(`provider:${kind}`, fn, { scope });
|
|
4
|
+
return {
|
|
5
|
+
async resolve(ref, service) {
|
|
6
|
+
const { resource, path } = await call('resolve', [ref, service]);
|
|
7
|
+
const api = connection();
|
|
8
|
+
return { resource, url: `${api.url}${path}`, headers: { authorization: `Bearer ${api.token}` } };
|
|
9
|
+
},
|
|
10
|
+
define: definition => call('define', [definition]),
|
|
11
|
+
put: object => call('put', [object]),
|
|
12
|
+
update: (kind, id, spec, revision) => call('update', [kind, id, spec, revision]),
|
|
13
|
+
setStatus: (kind, id, status, revision) => call('setStatus', [kind, id, status, revision]),
|
|
14
|
+
delete: (kind, id) => call('delete', [kind, id]),
|
|
15
|
+
publish: (kind, id, enabled = true) => call('publish', [kind, id, enabled]),
|
|
16
|
+
observe,
|
|
17
|
+
async control(kind, handler, scope = 'local') {
|
|
18
|
+
if (typeof handler !== 'function') throw new TypeError('controller 须为函数');
|
|
19
|
+
const pending = new Map(), running = new Set();
|
|
20
|
+
let disposed = false;
|
|
21
|
+
const subscription = await observe(kind, event => {
|
|
22
|
+
pending.set(event.id, event);
|
|
23
|
+
if (running.has(event.id)) return;
|
|
24
|
+
running.add(event.id);
|
|
25
|
+
void (async () => {
|
|
26
|
+
try {
|
|
27
|
+
while (!disposed && pending.has(event.id)) {
|
|
28
|
+
const next = pending.get(event.id); pending.delete(event.id);
|
|
29
|
+
try { await handler(next); } catch (error) { report('[protocol controller]', error); }
|
|
30
|
+
}
|
|
31
|
+
} finally { running.delete(event.id); }
|
|
32
|
+
})();
|
|
33
|
+
}, scope);
|
|
34
|
+
return { dispose() { disposed = true; pending.clear(); subscription.dispose(); } };
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
package/check/coda/builtin.json
CHANGED
|
@@ -1561,14 +1561,14 @@
|
|
|
1561
1561
|
"id": "review",
|
|
1562
1562
|
"displayName": "PR 生命流程",
|
|
1563
1563
|
"description": "会话开的 PR 从开出来起一条流程:每个新版本先跑项目声明的检查,再请另一家 Agent 评审,要求修改时交给开 PR 的会话处理、有分歧时交给你仲裁;通过后请你批准合并,跑过项目的合并前检查再合并,合并后按你的选择删除远程分支、调用项目的部署和发布流程,PR 合并或关闭时结束。",
|
|
1564
|
-
"version": "2.9.
|
|
1564
|
+
"version": "2.9.1",
|
|
1565
1565
|
"category": "工作流程",
|
|
1566
1566
|
"source": {
|
|
1567
1567
|
"kind": "builtin",
|
|
1568
1568
|
"package": "@coda-console/review",
|
|
1569
1569
|
"tag": "latest",
|
|
1570
|
-
"version": "2.9.
|
|
1571
|
-
"integrity": "sha512-
|
|
1570
|
+
"version": "2.9.1",
|
|
1571
|
+
"integrity": "sha512-gbg46xKbJv8TTnjfQpae5+bGE+Jt22m2nB3JWkpmMWwQdtLoHcODWdel1MJvJ8DHkITHvUAJmeImvi9bS40aZQ==",
|
|
1572
1572
|
"repo": "https://github.com/coda-console/coda-plugins.git",
|
|
1573
1573
|
"path": "plugins/review"
|
|
1574
1574
|
},
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The provider declaration contract, shared verbatim with plugin-check. No topology or runtime policy here.
|
|
2
|
+
import { ProtocolTypes } from './types.mjs';
|
|
3
|
+
import { requireCondition as check } from '../../domain/errors.mjs';
|
|
4
|
+
|
|
5
|
+
export function providerDefinition(input) {
|
|
6
|
+
const { kind, spec, status, controllers = [], target = null } = input ?? {};
|
|
7
|
+
check(Array.isArray(controllers) && controllers.every(id => typeof id === 'string' && id), 'invalid_input', 'controllers 须为插件 ID 列表');
|
|
8
|
+
check(target === null || (typeof target === 'string' && Object.hasOwn(spec?.properties ?? {}, target)), 'invalid_input', 'target 须为 spec 声明的资源引用栏');
|
|
9
|
+
new ProtocolTypes().register({ kind, spec, status, participants: () => [] });
|
|
10
|
+
return structuredClone({ kind, spec, status, controllers, target });
|
|
11
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
|
|
3
|
+
// Only JSON Schema rules: no coercion, custom keywords or executable constraints. Only the type's schemas
|
|
4
|
+
// supply defaults. An absent field without a declared default stays absent.
|
|
5
|
+
const ajv = new Ajv({ allErrors: true, addUsedSchema: false });
|
|
6
|
+
const defaults = new Ajv({ allErrors: true, addUsedSchema: false, useDefaults: true });
|
|
7
|
+
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
8
|
+
const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
9
|
+
|
|
10
|
+
const compile = (schema, compiler = ajv) => {
|
|
11
|
+
const check = compiler.compile(schema);
|
|
12
|
+
if (check.$async) throw new TypeError('协议只允许同步 JSON Schema 校验');
|
|
13
|
+
return check;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function validate(check, value, who) {
|
|
17
|
+
if (!check(value)) throw new TypeError(`${who}: ${ajv.errorsText(check.errors)}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ProtocolTypes {
|
|
21
|
+
constructor() { this.types = new Map(); }
|
|
22
|
+
register({ kind, spec, status, contributions = {}, participants }, registered = () => {}) {
|
|
23
|
+
if (typeof kind !== 'string' || !/^[a-z][a-zA-Z0-9-]*$/.test(kind) || this.types.has(kind)) throw new TypeError(`协议类型无效或已登记:${kind}`);
|
|
24
|
+
if (spec?.type !== 'object' || status?.type !== 'object') throw new TypeError(`${kind}: spec 与 status 须为对象 schema`);
|
|
25
|
+
if (typeof participants !== 'function' || !object(contributions)) throw new TypeError(`${kind}: 需要 participants 与 contributions`);
|
|
26
|
+
const properties = {};
|
|
27
|
+
for (const [field, { merge, schema }] of Object.entries(contributions)) {
|
|
28
|
+
const type = merge === 'append' ? 'array' : merge === 'or' ? 'boolean' : null;
|
|
29
|
+
if (!type || schema?.type !== type || spec?.properties?.[field]?.type !== type) {
|
|
30
|
+
throw new TypeError(`${kind}.${field}: 补充只允许 append 列表或 or 开关,单值栏不可补充`);
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(properties, field, { value: schema, enumerable: true });
|
|
33
|
+
}
|
|
34
|
+
const type = { kind, participants, contributions: structuredClone(contributions),
|
|
35
|
+
spec: compile(spec, defaults), status: compile(status, defaults),
|
|
36
|
+
// Before supplementation only merge operands must be shaped correctly. Required fields and counts apply to the
|
|
37
|
+
// complete spec, so a participant can supply a required list that the initial object does not have yet.
|
|
38
|
+
base: compile({ type: 'object', properties: Object.fromEntries(Object.entries(properties).map(([field, schema]) => [field, { type: schema.type }])) }),
|
|
39
|
+
answer: compile({ type: 'object', properties, additionalProperties: false }, defaults) };
|
|
40
|
+
registered(type);
|
|
41
|
+
this.types.set(kind, type);
|
|
42
|
+
return type;
|
|
43
|
+
}
|
|
44
|
+
get(kind) {
|
|
45
|
+
const type = this.types.get(kind);
|
|
46
|
+
if (!type) throw new TypeError(`未登记协议类型:${kind}`);
|
|
47
|
+
return type;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function checkParticipants(answers) {
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
for (const { plugin, key } of answers) {
|
|
54
|
+
const id = JSON.stringify([plugin, key]);
|
|
55
|
+
if (typeof plugin !== 'string' || !plugin || typeof key !== 'string' || !key || seen.has(id)) throw new TypeError(`参与者无效或重复:${id}`);
|
|
56
|
+
seen.add(id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Each answer is atomic. Append in participant identity order, preserving each answer's own list order and duplicates;
|
|
61
|
+
// neither the participants' enumeration nor their completion order supplies precedence.
|
|
62
|
+
export function mergeContributions(type, spec, answers) {
|
|
63
|
+
validate(type.base, spec, `${type.kind}.spec`);
|
|
64
|
+
checkParticipants(answers);
|
|
65
|
+
const replies = structuredClone(answers);
|
|
66
|
+
for (const { plugin, key, value } of replies) validate(type.answer, value, `插件 ${plugin}(${key})的补充`);
|
|
67
|
+
const result = structuredClone(spec);
|
|
68
|
+
for (const { value } of replies.sort((a, b) => compare(a.plugin, b.plugin) || compare(a.key, b.key))) {
|
|
69
|
+
for (const [field, added] of Object.entries(value)) {
|
|
70
|
+
const merged = type.contributions[field].merge === 'append' ? [...(result[field] ?? []), ...structuredClone(added)] : (result[field] ?? false) || added;
|
|
71
|
+
Object.defineProperty(result, field, { value: merged, enumerable: true, writable: true, configurable: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
validate(type.spec, result, `${type.kind}.spec`);
|
|
75
|
+
return result;
|
|
76
|
+
}
|
package/check/coda/contract.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "76b1759d9058652bc11eb1f2b62e574fc5c61f21",
|
|
3
3
|
"packages": {
|
|
4
4
|
"@0dep/piso": "5.2.0",
|
|
5
5
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
6
6
|
"@coda-console/protocol": "1.10.0",
|
|
7
|
+
"ajv": "8.20.0",
|
|
7
8
|
"yaml": "2.9.1"
|
|
8
9
|
},
|
|
9
10
|
"files": {
|
|
11
|
+
"check/coda/components/protocols/provider-definition.mjs": "98327f1900f84109fd5493d2de8f683eb020754245f3049869ca3b30468821f9",
|
|
12
|
+
"check/coda/components/protocols/types.mjs": "c214787505f3b493eae8c89da79a3e7ea89e54945424ce227bea1fbcf35e826e",
|
|
13
|
+
"check/coda/adapters/provider-api.mjs": "33f69042b3437b436fc5c1ceddacf99fff2fa849834bcb065e5d9ae35a2fa7ec",
|
|
14
|
+
"check/coda/adapters/admission-api.mjs": "47524434710b250e5aa4c5b41fefe40684186a88f33ccf5a4fa44f8b0dd3a45a",
|
|
10
15
|
"check/coda/components/plugins/agent-plugins.mjs": "d117702f83c988aa89c2e5ae26aafd6ae3e8ba0829adaeedf9e8640f5f8282be",
|
|
11
16
|
"check/coda/components/plugins/plugin-extensions.mjs": "4d7963185195ba6d21a4e49a66987613d5892210b1eb1dc02cffb7b816407776",
|
|
12
17
|
"check/coda/components/plugins/plugin-rules.mjs": "bf2eecafaf3a3c3a8b4719c3252db30a582fce5f11946926cd6a2bc03920c702",
|
|
@@ -18,12 +23,14 @@
|
|
|
18
23
|
"check/coda/domain/agent-protocol.mjs": "769cc10dc21b3cef7718f94272aaef2d17d4882d42617b408cb47357abfc3bcb",
|
|
19
24
|
"check/coda/domain/duration.mjs": "15dd64ef9b02342ad521c66e5968a569432a89dc7568d11afd3e6f3fe37e104b",
|
|
20
25
|
"check/coda/domain/errors.mjs": "ddc00aef9bb6f9a56845a9926c82200628a906230d31212d88fcde48e36dfd36",
|
|
26
|
+
"check/coda/domain/resource-admission.mjs": "775b1d7067f9d8487a3504d737f3f4bea31adf77af3357ed42e313805e5188e7",
|
|
27
|
+
"check/coda/domain/plugin-services.mjs": "940a72a14da980188a32c790c7f341d3ec0062a6e87ef1ebc9ef051798ea0a75",
|
|
21
28
|
"check/coda/domain/values.mjs": "01cc72b8d9c09e3fe16c93ec332ca01148bba859b1c672586d9d07444d7816c4",
|
|
22
29
|
"check/coda/kernel/agent-failures.mjs": "cbc215e2403d86f0acc765c2077197e0b529fc01e213db465c388361238ea8ce",
|
|
23
30
|
"check/coda/resources/plugins/resources/panels/command.mjs": "606f28bf87f87dded9df2db892bc7624c770d795ffab88f2409998346920ae42",
|
|
24
31
|
"check/coda/resources/plugins/resources/panels/panels.mjs": "9e25cfbc16ed9f68101fc7bfc34b8056c13a29d2368c5561e65e333233eb921e",
|
|
25
32
|
"check/coda/resources/plugins/resources/panels/rules.mjs": "8418ed83b796f18047c154d8dea8dca7d98244af8ddfe3ddf188520c59324ee8",
|
|
26
33
|
"check/coda/resources/plugins/resources/panels/sign-in.mjs": "1271a24e33b1b882a1fb9bee03b8e240db8b9bee1b5208f0e1c84499cfb1be7e",
|
|
27
|
-
"check/coda/builtin.json": "
|
|
34
|
+
"check/coda/builtin.json": "cb4cb30ea2ae9abd67627761c2931811228a4d9084da308c3c4d5dd3519533f0"
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { requireCondition as check } from './errors.mjs';
|
|
2
|
+
|
|
3
|
+
export const admissionFeatures = Object.freeze({ multiResource: false, multiUnit: false, exclusive: true });
|
|
4
|
+
|
|
5
|
+
export function admissionRequest(request) {
|
|
6
|
+
check(request && typeof request === 'object' && !Array.isArray(request) &&
|
|
7
|
+
Object.keys(request).every(key => ['requestId', 'group', 'resources', 'exclusive'].includes(key)), 'invalid_input', '无效的资源申请');
|
|
8
|
+
const { requestId, group, resources, exclusive = false } = request;
|
|
9
|
+
check(typeof requestId === 'string' && requestId.length > 0 && requestId.length <= 500, 'invalid_input', 'requestId 须为 1–500 字的稳定申请标识');
|
|
10
|
+
check(typeof group === 'string' && group.length > 0 && group.length <= 100, 'invalid_input', 'group 须为本机组名');
|
|
11
|
+
check(resources && Object.keys(resources).length === 1 && resources.slots === 1 && !Array.isArray(resources),
|
|
12
|
+
'invalid_input', '只支持 resources: { slots: 1 },不支持多资源或多单位');
|
|
13
|
+
check(typeof exclusive === 'boolean', 'invalid_input', 'exclusive 须为 boolean');
|
|
14
|
+
return { requestId, group, exclusive };
|
|
15
|
+
}
|