@coda-console/plugin-check 0.8.18 → 0.8.20

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 CHANGED
@@ -24,7 +24,7 @@ plugins/network-log/ 网络记录:默认关闭,按需开启建连等待
24
24
  plugins/review/ PR 生命流程:会话开的 PR 先跑项目的检查、再交叉评审,你批准后合并、部署与发布,别人的 PR 只评审;也是写 PR 流程的样例
25
25
  plugins/desktop-pet/ 桌面宠物:Coda 娘待在 Mac 桌面上,Agent 在跑时打字,有事等你时举卡片叫你(Coda 的浮窗)
26
26
  plugins/testbed/ 测试机:长插在 Mac 上的 iPhone、iPad 只经 use-testbed 使用,排到后装 App、交给会话操作、用完切黑屏;依赖宿主资源
27
- plugins/composer/ 输入框模式与开发流程:监督开发(一个需求一条泳道,主 Agent 用泳道 PR 合进泳道,用户批准一次)与需求交付;Ultra 名单引用 composer.templates
27
+ plugins/composer/ 输入框模式与开发流程:监督开发(一个需求一条需求分支,主 Agent 把一块块改动合进需求分支,用户批准一次)与需求交付;Ultra 名单引用 composer.templates
28
28
  templates/agent/ 最小的 Agent 插件:手写 ACP 的回声 Agent,演示会话指令、插话、Agent 活动与自主轮次
29
29
  templates/resource/ 最小的资源插件:一个资源、两个读数、一个按钮
30
30
  bin/、check/ 契约检查(仓库根的 package.json 就是它,@coda-console/plugin-check);check/coda/ 是 Coda 同步来的规则副本,不要手改
@@ -61,7 +61,7 @@ Coda 插件页的「商店」列出 Coda 自带的插件,以及 npm 上 `@coda
61
61
 
62
62
  | 插件 | npm 依赖(与 Coda 后端同版本) | 运行机上另要 |
63
63
  | --- | --- | --- |
64
- | `codex` | `@agentclientprotocol/codex-acp` 1.12.0、`@openai/codex` 0.165.0;`overrides` 让 codex-acp 用同一个 `@openai/codex` | — |
64
+ | `codex` | `@agentclientprotocol/codex-acp` 1.12.0、`@openai/codex` 0.169.0;`overrides` 让 codex-acp 用同一个 `@openai/codex` | — |
65
65
  | `claude` | `@agentclientprotocol/sdk` 1.4.0、`@anthropic-ai/claude-agent-sdk` 0.3.312(平台二进制是 SDK 自己的可选依赖) | — |
66
66
  | `codex-accounts` | `proper-lockfile` 4.1.2;用依赖插件 `codex` 的 Codex CLI | 无;依赖 `codex` 插件 |
67
67
  | `kimi` | 无 | Kimi CLI 2.1.1 及以上(缺失或更旧时设置动作装入口核对过的 2.1.1,更新的不动;资源页上可从 Coda 安装、登录) |
@@ -3,7 +3,7 @@
3
3
  "packages": {
4
4
  "@0dep/piso": "5.2.0",
5
5
  "@agentclientprotocol/sdk": "2.6.0",
6
- "@coda-console/protocol": "6.5.0",
6
+ "@coda-console/protocol": "6.6.0",
7
7
  "ajv": "8.20.0",
8
8
  "yaml": "2.9.1"
9
9
  },
@@ -0,0 +1,48 @@
1
+ // A panel's command run once to its end, as Coda's panels module ran it before it took `runPluginCommand`
2
+ // (check/coda/resources/plugins/resources/panels/command.mjs, which a sync drops): `sh -c` in its own process group, its
3
+ // standard output kept apart from what it says on standard error, both bounded. Kept here so the checker runs with the
4
+ // panels module of either version: `start`, `cwd` and `input`, which the newer one passes, are ignored, and the command's
5
+ // standard input stays closed.
6
+ import { spawn } from 'node:child_process';
7
+ import { tmpdir } from 'node:os';
8
+
9
+ const ansi = /\x1b\[[0-9;]*[A-Za-z]/g;
10
+ // The last thing a failed command said, for the one line the user sees.
11
+ export const lastLine = text => text.replace(ansi, '').split('\n').map(line => line.trim()).filter(Boolean).at(-1)?.slice(0, 200) ?? '';
12
+
13
+ export function runCommand(command, { env, timeoutMs, signal: aborted, maxBytes = 64 * 1024 }) {
14
+ return new Promise(resolve => {
15
+ const child = spawn('/bin/sh', ['-c', command], { cwd: tmpdir(), env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
16
+ const out = [], err = [];
17
+ let sizes = [0, 0], overflow = false, timedOut = false, finished = false, hard = null;
18
+ const signal = name => { try { process.kill(-child.pid, name); } catch {} };
19
+ const stop = () => { signal('SIGTERM'); hard = setTimeout(() => signal('SIGKILL'), 2000); };
20
+ const due = setTimeout(() => { timedOut = true; stop(); }, timeoutMs);
21
+ const abort = () => { if (!finished) signal('SIGKILL'); };
22
+ aborted?.addEventListener('abort', abort, { once: true });
23
+ const keep = (chunks, i) => chunk => {
24
+ if (sizes[i] + chunk.length > maxBytes) { if (i === 0 && !overflow) { overflow = true; stop(); } return; }
25
+ sizes[i] += chunk.length; chunks.push(chunk);
26
+ };
27
+ child.stdout.on('data', keep(out, 0));
28
+ child.stderr.on('data', keep(err, 1));
29
+ const finish = (code, error) => {
30
+ if (finished) return;
31
+ finished = true; clearTimeout(due); clearTimeout(hard); aborted?.removeEventListener('abort', abort);
32
+ // Whatever it left behind in its group goes with it.
33
+ if (child.pid) signal('SIGKILL');
34
+ resolve({ code, stdout: Buffer.concat(out).toString('utf8'), stderr: Buffer.concat(err).toString('utf8'), timedOut, overflow, ...(error ? { error } : {}) });
35
+ };
36
+ child.on('error', error => finish(null, error.message));
37
+ child.on('close', code => finish(code));
38
+ });
39
+ }
40
+ // A command ended well: by itself, with 0. One stopped for its deadline or its output may still say 0 on the way out.
41
+ export const ended = result => result.code === 0 && !result.timedOut && !result.overflow;
42
+ // Why a command did not end well, in one line.
43
+ export function outcome(result, what) {
44
+ if (result.timedOut) return `${what}超时`;
45
+ if (result.overflow) return '输出过长';
46
+ if (result.error) return `${what}没有开始:${result.error}`;
47
+ return lastLine(result.stderr) || lastLine(result.stdout) || `${what}没有完成(退出码 ${result.code ?? '无'})`;
48
+ }
package/check/panel.mjs CHANGED
@@ -5,7 +5,7 @@
5
5
  // Its actions are not run: a button may change things (switch an account, spend a reset), and only a person presses it.
6
6
  import { dirname } from 'node:path';
7
7
  import { cleared } from './coda/components/plugins/plugin-rules.mjs';
8
- import { ended, runCommand } from './coda/resources/plugins/resources/panels/command.mjs';
8
+ import { ended, runCommand } from './command.mjs';
9
9
  import { Panels } from './coda/resources/plugins/resources/panels/panels.mjs';
10
10
  import { OUTPUT_LIMIT, panelItems, resourceItems } from './coda/resources/plugins/resources/panels/rules.mjs';
11
11
  import { closing, temporary } from './leftovers.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.8.18",
3
+ "version": "0.8.20",
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": "2.6.0",
27
- "@coda-console/protocol": "6.5.0",
27
+ "@coda-console/protocol": "6.6.0",
28
28
  "ajv": "8.20.0",
29
29
  "yaml": "2.9.1"
30
30
  },