@coda-console/plugin-check 0.8.1 → 0.8.2
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 +0 -1
- package/check/coda/components/plugins/contribution-points.mjs +4 -2
- package/check/coda/components/plugins/plugin-rules.mjs +4 -10
- package/check/coda/components/protocols/types.mjs +3 -2
- package/check/coda/components/session-config/contributions.mjs +19 -4
- package/check/coda/contract.json +7 -7
- package/check/coda/domain/duration.mjs +12 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,6 @@ plugins/magpie/ Magpie:把本机的 Magpie 网关作为模型服务
|
|
|
22
22
|
plugins/network-log/ 网络记录:默认关闭,按需开启建连等待与定时探测采集;关闭后仍可查看历史
|
|
23
23
|
plugins/review/ PR 生命流程:会话开的 PR 先跑项目的检查、再交叉评审,你批准后合并、部署与发布;也是写 PR 流程的样例
|
|
24
24
|
plugins/testbed/ 测试机:长插在 Mac 上的 iPhone、iPad 只经 use-testbed 使用,排到后装 App、交给会话操作、用完切黑屏;依赖宿主资源
|
|
25
|
-
plugins/wechat/ 微信:把手机上的微信群提供为 coda/session@1 外部会话(只读),经手机桥读数据,装在安卓手机节点上
|
|
26
25
|
plugins/composer/ 输入框模式与开发流程:Ultra 用 develop 委派代码修改,主 Agent 审查,设备验收后检查、批准、合并与部署;名单引用 composer.templates
|
|
27
26
|
templates/agent/ 最小的 Agent 插件:手写 ACP 的回声 Agent,演示会话指令、插话、Agent 活动与自主轮次
|
|
28
27
|
templates/resource/ 最小的资源插件:一个资源、两个读数、一个按钮
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// checked in the whole manifest, @coda-console/protocol's contributionProblem), what a plugin's value of it is on the plugin (`read`, given
|
|
4
4
|
// the value written, none when it writes none), what of it only one plugin may declare (`claim`, of the plugin read), and
|
|
5
5
|
// what installing it confirms of it (`confirm`), how a plugin drawing no icon of its own is drawn (`icon`, of the plugin
|
|
6
|
-
// read, none when it says nothing),
|
|
7
|
-
// of the plugin read, none when it may)
|
|
6
|
+
// read, none when it says nothing), why one from elsewhere than Coda's own may not bring what it does (`builtinOnly`,
|
|
7
|
+
// of the plugin read, none when it may), and the formats of a setting's value it defines (`formats`, by the name a
|
|
8
|
+
// declaration writes: `(value, where, code)` checks one and returns it normalised, components/plugins/plugin-rules.mjs
|
|
9
|
+
// checkValue). The plugins' base knows none of the keys, nor those formats: it asks the point a key or a format names.
|
|
8
10
|
// A component defines its points as its module loads (components/workflows/contributions.mjs); what puts Coda together
|
|
9
11
|
// loads those before any plugin is read (application/contributions.mjs), as the wait kinds are (kernel/wait-kinds.mjs).
|
|
10
12
|
export class ContributionPoints {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
import { readFileSync, readdirSync, existsSync } from 'node:fs';
|
|
13
13
|
import { join, normalize, posix } from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
|
-
import { settings as agentSettings } from '../session-config/commands.mjs';
|
|
16
15
|
import { requireCondition as check, ContractError } from '../../domain/errors.mjs';
|
|
17
16
|
import { isDuration } from '../../domain/duration.mjs';
|
|
18
17
|
import { AGENT_ID } from '../../domain/values.mjs';
|
|
@@ -302,17 +301,12 @@ export function pickMatch(entries, session) {
|
|
|
302
301
|
(!m.agent || m.agent === session?.agent) && (!m.model || m.model === session?.model) && (!m.effort || m.effort === session?.effort))
|
|
303
302
|
.sort((a, b) => matchSpecificity(b[0]) - matchSpecificity(a[0]))[0]?.[0] ?? null;
|
|
304
303
|
}
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
function agentValue(value, where, code) {
|
|
308
|
-
check(value && typeof value === 'object' && !Array.isArray(value) && typeof value.agent === 'string' && AGENT_ID.test(value.agent), code,
|
|
309
|
-
`${where} 须为 Agent 组合,并指明 Agent`);
|
|
310
|
-
const { agent, ...rest } = value;
|
|
311
|
-
try { return { agent, ...agentSettings(rest) }; } catch (e) { throw new ContractError(code, `${where}:${e.message}`); }
|
|
312
|
-
}
|
|
304
|
+
// A value of a format a contribution point defines (`formats`, components/plugins/contribution-points.mjs), as it checks it.
|
|
305
|
+
const pointFormat = name => [...CONTRIBUTION_POINTS.values()].map(point => point.formats?.[name]).find(Boolean);
|
|
313
306
|
// A value as the declaration allows it; returns it normalised.
|
|
314
307
|
export function checkValue(spec, value, where, code = 'invalid_input') {
|
|
315
|
-
|
|
308
|
+
const format = pointFormat(spec.format);
|
|
309
|
+
if (format) return format(value, where, code);
|
|
316
310
|
// A whole row, as a table's default has it: its secrets are only ever written one by one, never declared.
|
|
317
311
|
if (spec.columns) {
|
|
318
312
|
check(value && typeof value === 'object' && !Array.isArray(value), code, `${where}须为一行`);
|
|
@@ -27,7 +27,8 @@ export class ProtocolTypes {
|
|
|
27
27
|
if (typeof participants !== 'function' || !object(contributions)) throw new TypeError(`${kind}: 需要 participants 与 contributions`);
|
|
28
28
|
// Each operation is an input and either an immediate result or a run reference, as the protocol package defines them.
|
|
29
29
|
// `join` names an input field holding the run of an open call that the operation adds to instead of opening one;
|
|
30
|
-
// `safe`, one that only reads and answers at once, whose request and answer neither side keeps
|
|
30
|
+
// `safe`, one that only reads and answers at once, whose request and answer neither side keeps; `idempotent`, one that
|
|
31
|
+
// may change what it acts on but does the same again when sent again, kept by neither side as `safe` is.
|
|
31
32
|
if (!object(operations)) throw new TypeError(`${kind}: operations 须为对象`);
|
|
32
33
|
const compiled = new Map();
|
|
33
34
|
for (const [name, operation] of Object.entries(operations)) {
|
|
@@ -36,7 +37,7 @@ export class ProtocolTypes {
|
|
|
36
37
|
if (run === Object.hasOwn(operation, 'result') || !operation.input) throw new TypeError(`${kind}.${name}: 操作要写 input,并恰写 result 或 run`);
|
|
37
38
|
if (join !== undefined && (!run || typeof join !== 'string' || !join)) throw new TypeError(`${kind}.${name}: join 只能用于运行,并写出输入里的字段`);
|
|
38
39
|
compiled.set(name, { input: compile(operation.input), ...(run ? { run } : { result: compile(operation.result) }), ...(join ? { join } : {}),
|
|
39
|
-
...(operation.safe === true ? { safe: true } : {}) });
|
|
40
|
+
...(operation.safe === true ? { safe: true } : {}), ...(operation.idempotent === true ? { idempotent: true } : {}) });
|
|
40
41
|
}
|
|
41
42
|
const properties = {};
|
|
42
43
|
for (const [field, { merge, schema }] of Object.entries(contributions)) {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
// What sessions take of plugins (components/plugins/contribution-points.mjs): the agents a plugin brings (schemas/agents.json)
|
|
2
|
-
// what it tells every agent (instructions), the Agent Skills it lays
|
|
3
|
-
// PATH (commands) and the MCP servers their agents start
|
|
1
|
+
// What sessions take of plugins (components/plugins/contribution-points.mjs): the agents a plugin brings (schemas/agents.json)
|
|
2
|
+
// and the settings naming one of them (`coda-agent`), what it tells every agent (instructions), the Agent Skills it lays
|
|
3
|
+
// into projects (skills), the commands it puts on their PATH (commands) and the MCP servers their agents start
|
|
4
|
+
// (mcpServers), defined as this module loads.
|
|
4
5
|
// Descriptions only: nothing here imports a component, for the plugins read with them are read before any is made.
|
|
5
6
|
import { join, normalize } from 'node:path';
|
|
6
7
|
import { defineContributionPoint } from '../plugins/contribution-points.mjs';
|
|
7
8
|
import { SCHEMAS } from '@coda-console/protocol/validate';
|
|
9
|
+
import { requireCondition as check, ContractError } from '../../domain/errors.mjs';
|
|
10
|
+
import { AGENT_ID } from '../../domain/values.mjs';
|
|
11
|
+
import { settings } from './commands.mjs';
|
|
8
12
|
import { iconFiles } from '../plugins/plugin-icons.mjs';
|
|
9
13
|
import { readSkillDocument } from '../plugins/skill-document.mjs';
|
|
10
14
|
|
|
@@ -36,11 +40,22 @@ function skills(raw, dir) {
|
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
// A setting's value that is an Agent combination (`format: coda-agent`): the agent it names, with the settings a session of it
|
|
44
|
+
// starts with. Whether that agent is installed is asked where it is used (a review, a step): a setting stays readable while
|
|
45
|
+
// a plugin it names is uninstalled.
|
|
46
|
+
function agentValue(value, where, code) {
|
|
47
|
+
check(value && typeof value === 'object' && !Array.isArray(value) && typeof value.agent === 'string' && AGENT_ID.test(value.agent), code,
|
|
48
|
+
`${where} 须为 Agent 组合,并指明 Agent`);
|
|
49
|
+
const { agent, ...rest } = value;
|
|
50
|
+
try { return { agent, ...settings(rest) }; } catch (e) { throw new ContractError(code, `${where}:${e.message}`); }
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
// An agent is one plugin's: sessions name it by its ID alone. A plugin that draws no icon of its own and brings one agent
|
|
40
54
|
// is drawn as that agent.
|
|
41
55
|
defineContributionPoint({ key: 'agents', schema: SCHEMAS['agents.json'], read: (raw, dir) => ({ agents: agentDeclarations(raw, dir) }),
|
|
42
56
|
claim: plugin => plugin.agents.map(a => `Agent ${a.id}`), icon: plugin => plugin.agents.length === 1 ? plugin.agents[0].icon : null,
|
|
43
|
-
confirm: plugin => ({ agents: plugin.agents.map(a => ({ id: a.id, displayName: a.displayName, command: a.command })) })
|
|
57
|
+
confirm: plugin => ({ agents: plugin.agents.map(a => ({ id: a.id, displayName: a.displayName, command: a.command })) }),
|
|
58
|
+
formats: { 'coda-agent': agentValue } });
|
|
44
59
|
defineContributionPoint({ key: 'instructions', schema: SCHEMAS['instructions.json'], read: raw => raw ? { instructions: raw.trim() } : {},
|
|
45
60
|
confirm: plugin => plugin.instructions ? { instructions: plugin.instructions } : {} });
|
|
46
61
|
// Confirmed by name, each with what its SKILL.md says it is for.
|
package/check/coda/contract.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "0eab9b16ec304580b6a03c96b14ba18ded392081",
|
|
3
3
|
"packages": {
|
|
4
4
|
"@0dep/piso": "5.2.0",
|
|
5
5
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
6
|
-
"@coda-console/protocol": "
|
|
6
|
+
"@coda-console/protocol": "git+https://github.com/coda-console/coda-protocol.git#95abb122c6435df77bc35f620767123338a33f44",
|
|
7
7
|
"ajv": "8.20.0",
|
|
8
8
|
"yaml": "2.9.1"
|
|
9
9
|
},
|
|
10
10
|
"files": {
|
|
11
11
|
"check/coda/application/contributions.mjs": "7460dc676171e24802b165a72e83ec72c4115f5ed169abcad08963bd2d9d251f",
|
|
12
12
|
"check/coda/components/protocols/creation.mjs": "2b4a400d3064af4b5106077dc783c567910fef3c47b2d52af3f0d838c5accf19",
|
|
13
|
-
"check/coda/components/protocols/types.mjs": "
|
|
13
|
+
"check/coda/components/protocols/types.mjs": "6876689142866bd45fc085951f6ea9e1fc303334e3657e97cc9cf5e277311248",
|
|
14
14
|
"check/coda/adapters/provider-api.mjs": "a584316c3e0dafa19667f4288c54b8f894b49de72d9f62098d592b9084dec482",
|
|
15
15
|
"check/coda/adapters/admission-api.mjs": "461b5a8a1ad73d7afed5db308813d02324e29c643b8e773ad127d4bdb00fb524",
|
|
16
16
|
"check/coda/components/composers/contributions.mjs": "43d3e15fb1f63b7b5c20716030d9537613809ed5cc2fb466a3678bfa308f9f92",
|
|
17
17
|
"check/coda/components/composers/schemas.mjs": "6d497f58147756e789f9a566b2366f2fe36c0c72310421fb02508bf24a04f2c0",
|
|
18
|
-
"check/coda/components/plugins/contribution-points.mjs": "
|
|
18
|
+
"check/coda/components/plugins/contribution-points.mjs": "2dade9fe4f3fa2b4e89f49a1ac4378ab2621e5ac542eb175967091f04568b45c",
|
|
19
19
|
"check/coda/components/plugins/git-contributions.mjs": "532917cd3ec45e12535e9e6c206ae14fa598bebc789ab0c8f15609d1699fa1cd",
|
|
20
20
|
"check/coda/components/plugins/model-contributions.mjs": "018a7157954b2326887ba1a780b37d3beb33338e41a28936b313562c2939d563",
|
|
21
21
|
"check/coda/components/plugins/plugin-extensions.mjs": "4d7963185195ba6d21a4e49a66987613d5892210b1eb1dc02cffb7b816407776",
|
|
22
22
|
"check/coda/components/plugins/plugin-icons.mjs": "ec29cadce4948ecacabfe911a2ceb45414b96e28971358acbc4e952bedc78e1a",
|
|
23
|
-
"check/coda/components/plugins/plugin-rules.mjs": "
|
|
23
|
+
"check/coda/components/plugins/plugin-rules.mjs": "d457e46bbd49bac4e0f2f45c352dd501aa8254115c6213712e7d49c1644d40fd",
|
|
24
24
|
"check/coda/components/plugins/plugin-source-rules.mjs": "375bd284d4c29278d9ad0a476b743a378cca40be550fc68c6e86a78ffcd60a39",
|
|
25
25
|
"check/coda/components/plugins/skill-document.mjs": "153ad3c096c7c9b7774bcf7dcc0ba603c962ee1ac8697c8a71e3f2c9ba9c92e6",
|
|
26
26
|
"check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
|
|
27
27
|
"check/coda/components/session-config/commands.mjs": "b8505802e25590435bf48d741522d85c8b185e8f2ae190d49e53eebd35a1d453",
|
|
28
|
-
"check/coda/components/session-config/contributions.mjs": "
|
|
28
|
+
"check/coda/components/session-config/contributions.mjs": "830be1bf9e158d0090f16ed4be0ead4e33c7392531312299a3a637db8f470aa8",
|
|
29
29
|
"check/coda/components/workflows/contributions.mjs": "824c9b29584821b5e75bad00f02f21adc5031369db4ee9a4a5a836dfd44f98f5",
|
|
30
30
|
"check/coda/components/workflows/executor-labels.mjs": "dceca6ae60c0a4f3c3cc72a6c84f1489831790774c93caab96e4ddb493bc89e1",
|
|
31
31
|
"check/coda/domain/agent-protocol.mjs": "769cc10dc21b3cef7718f94272aaef2d17d4882d42617b408cb47357abfc3bcb",
|
|
32
|
-
"check/coda/domain/duration.mjs": "
|
|
32
|
+
"check/coda/domain/duration.mjs": "d6d7235c6166e8fcf4155999b1e9a514cf2ef91da179d4c0e48162cff4b692f5",
|
|
33
33
|
"check/coda/domain/errors.mjs": "8319c6759c5b16b692f5e0a6208d066e43882c571da1075bff8698761020daef",
|
|
34
34
|
"check/coda/domain/resource-admission.mjs": "775b1d7067f9d8487a3504d737f3f4bea31adf77af3357ed42e313805e5188e7",
|
|
35
35
|
"check/coda/domain/plugin-services.mjs": "940a72a14da980188a32c790c7f341d3ec0062a6e87ef1ebc9ef051798ea0a75",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// ISO 8601 durations (`P30D`, `PT6H`), as JSON Schema's `format: duration` is and bpmn-engine reads its timers
|
|
2
|
-
// (@0dep/piso): what plugin settings, panels and workflows all write a length of time in.
|
|
2
|
+
// (@0dep/piso): what plugin settings, panels and workflows all write a length of time in. And a length of time as whoever
|
|
3
|
+
// is told it reads it, in words.
|
|
3
4
|
import { parseDuration } from '@0dep/piso';
|
|
4
5
|
|
|
5
6
|
// A duration, not negative.
|
|
@@ -9,3 +10,13 @@ export function isDuration(text) {
|
|
|
9
10
|
}
|
|
10
11
|
// How long a duration is, counted back from `at` (a month is the one before it).
|
|
11
12
|
export const durationMs = (text, at = Date.now()) => at - parseDuration(text).getStartAt(new Date(at)).getTime();
|
|
13
|
+
|
|
14
|
+
// How long, in words, for whom it is told to: to the second under a minute, to the minute after.
|
|
15
|
+
export function duration(ms) {
|
|
16
|
+
const seconds = Math.max(0, Math.round(ms / 1000));
|
|
17
|
+
if (seconds < 60) return `${seconds} 秒`;
|
|
18
|
+
const minutes = Math.round(seconds / 60);
|
|
19
|
+
if (minutes < 60) return `${minutes} 分钟`;
|
|
20
|
+
const hours = Math.floor(minutes / 60), rest = minutes % 60;
|
|
21
|
+
return rest ? `${hours} 小时 ${rest} 分钟` : `${hours} 小时`;
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coda-console/plugin-check",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读资源类型(与旧的面板)。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@0dep/piso": "5.2.0",
|
|
26
26
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
27
|
-
"@coda-console/protocol": "
|
|
27
|
+
"@coda-console/protocol": "git+https://github.com/coda-console/coda-protocol.git#95abb122c6435df77bc35f620767123338a33f44",
|
|
28
28
|
"ajv": "8.20.0",
|
|
29
29
|
"yaml": "2.9.1"
|
|
30
30
|
},
|