@coda-console/plugin-check 0.5.10 → 0.5.12
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 +6 -6
- package/bin/check.mjs +2 -2
- package/check/coda/components/plugins/agent-plugins.mjs +19 -70
- package/check/coda/components/plugins/plugin-extensions.mjs +1 -70
- package/check/coda/components/plugins/plugin-rules.mjs +120 -513
- package/check/coda/components/plugins/plugin-schema.mjs +177 -0
- package/check/coda/components/plugins/plugin-source-rules.mjs +3 -1
- package/check/coda/components/plugins/schemas/agents.json +50 -0
- package/check/coda/components/plugins/schemas/capabilities.json +16 -0
- package/check/coda/components/plugins/schemas/commands.json +21 -0
- package/check/coda/components/plugins/schemas/common.json +25 -0
- package/check/coda/components/plugins/schemas/composer-modes.json +79 -0
- package/check/coda/components/plugins/schemas/configuration.json +23 -0
- package/check/coda/components/plugins/schemas/endpoints.json +19 -0
- package/check/coda/components/plugins/schemas/environment.json +22 -0
- package/check/coda/components/plugins/schemas/events.json +23 -0
- package/check/coda/components/plugins/schemas/executors.json +26 -0
- package/check/coda/components/plugins/schemas/extension-points.json +57 -0
- package/check/coda/components/plugins/schemas/extensions.json +13 -0
- package/check/coda/components/plugins/schemas/git-credentials.json +17 -0
- package/check/coda/components/plugins/schemas/groups.json +21 -0
- package/check/coda/components/plugins/schemas/instructions.json +9 -0
- package/check/coda/components/plugins/schemas/mcp-servers.json +29 -0
- package/check/coda/components/plugins/schemas/model-providers.json +39 -0
- package/check/coda/components/plugins/schemas/path.json +16 -0
- package/check/coda/components/plugins/schemas/plugin.json +46 -0
- package/check/coda/components/plugins/schemas/repositories.json +7 -0
- package/check/coda/components/plugins/schemas/services.json +9 -0
- package/check/coda/components/plugins/schemas/setting.json +242 -0
- package/check/coda/components/plugins/schemas/setup.json +7 -0
- package/check/coda/components/plugins/schemas/skills.json +15 -0
- package/check/coda/components/plugins/schemas/views.json +30 -0
- package/check/coda/components/session-config/commands.mjs +17 -2
- package/check/coda/contract.json +35 -9
- package/check/coda/domain/errors.mjs +3 -0
- package/check/index.mjs +2 -1
- package/check/manifest.mjs +56 -164
- package/package.json +2 -1
- package/check/coda/components/plugins/model-protocols.mjs +0 -39
package/check/manifest.mjs
CHANGED
|
@@ -1,125 +1,47 @@
|
|
|
1
|
-
// The manifest level:
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { basename, join, relative, sep } from 'node:path';
|
|
1
|
+
// The manifest level: whether the plugin is of the types it names (Coda's docs/plugins.md「插件的内容」, #1917). Its
|
|
2
|
+
// package.json is checked against the schemas of Coda's types (check/coda/components/plugins/schemas/, copied as they are
|
|
3
|
+
// from the Coda commit check/coda/contract.json names) by the checker Coda runs itself, and then read as Coda reads it: its
|
|
4
|
+
// ID, and its settings named under it. What Coda says only where it installs one — the repository it comes from, its npm
|
|
5
|
+
// lock, the plugins of that machine beside it — is that machine's to say, not a question of the plugin's types: the checker
|
|
6
|
+
// does not run it. The plugins Coda ships (check/coda/builtin.json) and those beside this one in its directory's parent
|
|
7
|
+
// stand in for what it depends on, for the levels after this one.
|
|
8
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
9
|
+
import { dirname, join } from 'node:path';
|
|
11
10
|
import { inflateSync } from 'node:zlib';
|
|
12
11
|
import shipped from './coda/builtin.json' with { type: 'json' };
|
|
12
|
+
import { manifestProblem } from './coda/components/plugins/plugin-schema.mjs';
|
|
13
|
+
import { offerProblem } from './coda/components/plugins/plugin-extensions.mjs';
|
|
13
14
|
import { choosesModelProviders, pluginEnv, readPlugin, resolveSettings } from './coda/components/plugins/plugin-rules.mjs';
|
|
14
|
-
import { candidate, candidates, catalogAfter, manifestId, manifestProblem, npmPackages, repoAddress, sameSource, sourcePath, treeProblem } from './coda/components/plugins/plugin-source-rules.mjs';
|
|
15
15
|
import { panelEntries } from './coda/resources/plugins/resources/panels/rules.mjs';
|
|
16
16
|
|
|
17
|
-
// The plugins Coda ships, by ID. Their files are Coda's, not here: none has a directory on this machine
|
|
18
|
-
// a plugin's processes of them names none.
|
|
17
|
+
// The plugins Coda ships, by ID. Their files are Coda's, not here: none has a directory on this machine.
|
|
19
18
|
const builtin = new Map(shipped.map(plugin => [plugin.id, { ...plugin, dir: undefined }]));
|
|
20
|
-
// Those it installs from the start, as rows without a source (components/plugins/plugins.mjs)
|
|
21
|
-
// they and nothing installed from elsewhere yet.
|
|
19
|
+
// Those it installs from the start, as rows without a source (components/plugins/plugins.mjs).
|
|
22
20
|
const installed = new Map(shipped.filter(plugin => plugin.defaultInstalled).map(plugin => [plugin.id, { id: plugin.id, source: null }]));
|
|
23
|
-
const catalog = new Map(builtin);
|
|
24
21
|
// The categories Coda's own plugins use, which its plugin pages list first, in this order.
|
|
25
22
|
export const CATEGORIES = ['Agent', '模型与账号', '工作流程', '机器与资源', 'Skills 与工具'];
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// Git tracks, and those it would once they are committed (`untracked`). Outside Git, the directory is a repository of its own.
|
|
33
|
-
function repository(dir) {
|
|
34
|
-
const real = realpathSync(dir);
|
|
35
|
-
const git = (at, args) => execFileSync('git', ['-C', at, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
36
|
-
let top = null;
|
|
37
|
-
try { top = git(real, ['rev-parse', '--show-toplevel']).trim(); } catch {}
|
|
38
|
-
if (!top) return { top: null, at: real, repo: real, path: '', commit: null, files: walk(real) };
|
|
39
|
-
const tracked = git(top, ['ls-files', '-s', '-z']).split('\0').filter(Boolean).map(entry => {
|
|
40
|
-
const tab = entry.indexOf('\t'), [mode] = entry.slice(0, tab).split(' ');
|
|
41
|
-
return { mode, name: entry.slice(tab + 1) };
|
|
42
|
-
});
|
|
43
|
-
const untracked = git(top, ['ls-files', '-o', '--exclude-standard', '-z']).split('\0').filter(Boolean).map(name => ({ name, untracked: true }));
|
|
44
|
-
let repo = top, commit = null;
|
|
45
|
-
try { repo = repoAddress(git(top, ['remote', 'get-url', 'origin']).trim()); } catch {}
|
|
46
|
-
try { commit = git(top, ['rev-parse', 'HEAD']).trim(); } catch {}
|
|
47
|
-
// Git names the top by its real path; so is the directory measured.
|
|
48
|
-
return { top, at: top, repo, commit, path: relative(top, real).split(sep).filter(Boolean).join('/'), files: [...tracked, ...untracked].map(e => withStat(top, e)) };
|
|
23
|
+
// A plugin it depends on, beside it in its parent directory (as coda-plugins keeps them) and of the ID asked for: read as Coda
|
|
24
|
+
// reads one, or none.
|
|
25
|
+
function beside(dir, id) {
|
|
26
|
+
const at = join(dirname(realpathSync(dir)), id);
|
|
27
|
+
if (!existsSync(join(at, 'package.json'))) return null;
|
|
28
|
+
try { const plugin = readPlugin(at, { kind: 'git' }); return plugin.id === id ? plugin : null; } catch { return null; }
|
|
49
29
|
}
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
const visit =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
30
|
+
// The plugins it depends on, directly or through another, found beside it (`ids`: those it names), by ID; one Coda ships is
|
|
31
|
+
// Coda's, not looked for here.
|
|
32
|
+
function besideAll(dir, ids) {
|
|
33
|
+
const found = new Map(), seen = new Set();
|
|
34
|
+
const visit = id => {
|
|
35
|
+
if (seen.has(id) || builtin.has(id)) return;
|
|
36
|
+
seen.add(id);
|
|
37
|
+
const there = beside(dir, id);
|
|
38
|
+
if (!there) return;
|
|
39
|
+
found.set(id, there);
|
|
40
|
+
for (const next of there.dependencies) visit(next);
|
|
61
41
|
};
|
|
62
|
-
visit(
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
function withStat(dir, entry) {
|
|
66
|
-
let stat = null;
|
|
67
|
-
try { stat = lstatSync(join(dir, entry.name)); } catch {}
|
|
68
|
-
const mode = entry.mode ?? (stat?.isSymbolicLink() ? '120000' : '100644');
|
|
69
|
-
return { ...entry, mode, size: stat && !stat.isSymbolicLink() && stat.isFile() ? stat.size : 0, missing: !stat && mode !== '160000' };
|
|
70
|
-
}
|
|
71
|
-
// The files of the directory at `path`, named within it, as `git ls-tree -r -l <commit>:<path>` lists them for Coda.
|
|
72
|
-
const within = (files, path) => path ? files.filter(f => f.name.startsWith(`${path}/`)).map(f => ({ ...f, name: f.name.slice(path.length + 1) })) : files;
|
|
73
|
-
// Coda's reading of a commit takes a directory as a plugin by its manifest saying what it contributes.
|
|
74
|
-
const contributing = manifest => !!manifest && typeof manifest === 'object' && !Array.isArray(manifest) && 'contributes' in manifest;
|
|
75
|
-
|
|
76
|
-
// What a directory is as a plugin, as Coda's inspect says it (`found`: `{ plugin }` and why it cannot be installed, or only
|
|
77
|
-
// why), with the rule the first refusal is said under. `plugin` is read even where Coda stopped before it, for the levels
|
|
78
|
-
// after this one; `lock` is the package-lock.json a commit would hold (null without one, undefined when it does not parse).
|
|
79
|
-
// A file system's error reading it (a file where Coda reads a directory, say) is no problem of the directory's own to Coda:
|
|
80
|
-
// it fails Coda's reading of the whole repository (`broken`).
|
|
81
|
-
function inspect(dir, files, source) {
|
|
82
|
-
let plugin = null, manifest = null, unread = null, broken = false;
|
|
83
|
-
try { plugin = readPlugin(dir, source); manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')); }
|
|
84
|
-
catch (e) {
|
|
85
|
-
if (e.code !== 'invalid_plugin' && !e.syscall) throw e;
|
|
86
|
-
unread = e.code === 'invalid_plugin' ? e.message : `读不了:${e.message}`; broken = !!e.syscall && e.code !== 'ENOENT';
|
|
87
|
-
}
|
|
88
|
-
let lock = null;
|
|
89
|
-
if (files.some(f => f.name === 'package-lock.json' && !f.missing)) try { lock = JSON.parse(readFileSync(join(dir, 'package-lock.json'), 'utf8')); } catch { lock = undefined; }
|
|
90
|
-
const tree = treeProblem(files);
|
|
91
|
-
if (tree) return { found: { problem: tree }, rule: 'source.files', plugin, lock };
|
|
92
|
-
if (unread) return { found: { problem: unread }, rule: 'manifest.read', plugin, lock, broken };
|
|
93
|
-
const npm = manifestProblem(manifest, lock);
|
|
94
|
-
plugin = { ...plugin, npm: npmPackages(manifest, lock) };
|
|
95
|
-
return { found: { plugin, problem: npm }, rule: npm ? 'source.npm' : null, plugin, lock };
|
|
96
|
-
}
|
|
97
|
-
// Why Coda's reading of the repository does not get to the directory at `path`, or null: it looks for plugins only so deep
|
|
98
|
-
// (candidates), and a source names only some directories (sourcePath; readSource says so in these words).
|
|
99
|
-
function located(path) {
|
|
100
|
-
if (!candidates([path ? `${path}/package.json` : 'package.json']).length)
|
|
101
|
-
return { problem: `插件目录 ${path} 在仓库根下超过 2 层(或在 node_modules 里):Coda 读仓库时扫不到它`, rule: 'source.depth' };
|
|
102
|
-
try { sourcePath(path); } catch { return { problem: `目录名 ${path} 只能用字母、数字和「._-」`, rule: 'source.segment' }; }
|
|
103
|
-
return null;
|
|
42
|
+
for (const id of ids) visit(id);
|
|
43
|
+
return found;
|
|
104
44
|
}
|
|
105
|
-
// The other plugins of the same commit, by ID → `{ path, plugin }`: those that read, as Coda's readSource finds them; and
|
|
106
|
-
// those whose reading fails Coda's reading of the whole repository (`broken`: path → why).
|
|
107
|
-
function siblingsOf(repo, own) {
|
|
108
|
-
const found = new Map(), broken = new Map();
|
|
109
|
-
for (const path of candidates(repo.files.filter(f => !f.missing).map(f => f.name))) {
|
|
110
|
-
if (path === own) continue;
|
|
111
|
-
const dir = join(repo.at, path);
|
|
112
|
-
let manifest = null;
|
|
113
|
-
try { manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')); } catch {}
|
|
114
|
-
if (!contributing(manifest)) continue;
|
|
115
|
-
try { sourcePath(path); } catch { continue; }
|
|
116
|
-
const read = inspect(dir, within(repo.files, path), { kind: 'git', repo: repo.repo, path, ref: '', commit: repo.commit });
|
|
117
|
-
if (read.broken) broken.set(path, read.found.problem);
|
|
118
|
-
else if (read.plugin && !read.found.problem) found.set(read.plugin.id, { path, plugin: read.plugin });
|
|
119
|
-
}
|
|
120
|
-
return { found, broken };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
45
|
// iOS draws an icon's PDF at 96 points and only ever scales it down: a smaller page comes out as a dot (Coda's own icons are
|
|
124
46
|
// 256 points). The page box may sit in a compressed object stream (PDF 1.5 and later, as CairoSVG writes them).
|
|
125
47
|
function pageSize(data) {
|
|
@@ -139,43 +61,22 @@ function pageSize(data) {
|
|
|
139
61
|
|
|
140
62
|
// Checks the manifest in `dir` and reports under `say` (report.mjs). Returns what the later levels need — the plugin as Coda
|
|
141
63
|
// reads it, its agents and the panels the resources plugin can read, its settings for every project, the directories of the
|
|
142
|
-
// plugins it depends on that are here, and `env(stateDir)`, what Coda gives each of its processes —; null when
|
|
143
|
-
// plugin
|
|
64
|
+
// plugins it depends on that are here, and `env(stateDir)`, what Coda gives each of its processes —; null when it is no
|
|
65
|
+
// plugin, or not of the types it names.
|
|
144
66
|
export function checkManifest(dir, say) {
|
|
145
67
|
let manifest;
|
|
146
68
|
try { manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')); }
|
|
147
69
|
catch (e) { say.fail('manifest.read', `没有可读的 package.json:${e.message}`); return null; }
|
|
148
|
-
if (!
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const where = located(path), read = inspect(dir, files, source), { found: siblings, broken } = siblingsOf(repo, path);
|
|
158
|
-
for (const [at, why] of broken) say.fail('source.read', `同一仓库的 ${at} ${why}:Coda 读这个仓库时整个出错,这个插件也装不了`);
|
|
159
|
-
const judged = candidate({ path, manifest, ...(where ? { problem: where.problem } : read.found), fallback: basename(path || repo.repo).replace(/\.git$/, '') },
|
|
160
|
-
{ catalog, installed, builtin }, siblings);
|
|
161
|
-
const refused = judged.problem ? where?.rule ?? read.rule ?? 'source.catalog' : null;
|
|
162
|
-
const reached = rule => !refused || ORDER.indexOf(rule) < ORDER.indexOf(refused);
|
|
163
|
-
if (refused) say.fail(refused, refused === 'manifest.read' ? `Coda 读不成插件:${judged.problem}`
|
|
164
|
-
: refused === 'source.npm' && read.lock === null && existsSync(join(dir, 'package-lock.json')) ? `${judged.problem}(有这个文件,但被 .gitignore 忽略了,不在提交里)` : judged.problem);
|
|
165
|
-
|
|
166
|
-
// What a commit of the directory holds, said after what Coda read of it.
|
|
167
|
-
const commit = () => {
|
|
168
|
-
const size = files.reduce((sum, e) => sum + e.size, 0), untracked = files.filter(e => e.untracked), missing = files.filter(e => e.missing);
|
|
169
|
-
if (reached('source.files') && refused !== 'source.files') say.pass('source.files', `从仓库安装的限制:无符号链接与子模块,整个目录 ${(size / 1024).toFixed(1)} KiB`);
|
|
170
|
-
if (untracked.length) say.warn('source.untracked', `${untracked.length} 个文件还没提交(如 ${untracked[0].name}):Coda 只读提交里的文件`);
|
|
171
|
-
if (missing.length) say.warn('source.missing', `${missing.length} 个已跟踪的文件在工作区里不见了(如 ${missing[0].name})`);
|
|
172
|
-
if (!repo.top) say.info('source.git', '目录不在 Git 仓库里:按目录里的文件检查,提交后以 Coda 读到的为准');
|
|
173
|
-
};
|
|
174
|
-
const { plugin } = read;
|
|
175
|
-
if (!plugin) { commit(); return null; }
|
|
70
|
+
if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest) || !('contributes' in manifest)) {
|
|
71
|
+
say.fail('manifest.contributes', 'package.json 没有 contributes:Coda 读仓库时不把这个目录当插件'); return null;
|
|
72
|
+
}
|
|
73
|
+
const problem = manifestProblem(manifest, dir);
|
|
74
|
+
if (problem) { say.fail('manifest.read', `不合它用到的类型:${problem}`); return null; }
|
|
75
|
+
let plugin;
|
|
76
|
+
try { plugin = readPlugin(dir, { kind: 'git' }); }
|
|
77
|
+
catch (e) { if (e.code !== 'invalid_plugin') throw e; say.fail('manifest.read', `Coda 读不成插件:${e.message}`); return null; }
|
|
176
78
|
|
|
177
|
-
say.pass('manifest.name', `package.json
|
|
178
|
-
? ` npm 上 ${own.source.package} 的一个版本` : ` ${own.source.repo} 的一个提交`},这里是它同一来源的新版本,可以盖过它)` : ''}`);
|
|
79
|
+
say.pass('manifest.name', `package.json 合乎它用到的类型,插件 ID ${plugin.id}${builtin.has(plugin.id) ? `(Coda 也自带 ${plugin.id}:装同一来源的新版本才能盖过它)` : ''}`);
|
|
179
80
|
if (typeof manifest.version !== 'string') say.warn('manifest.version', 'package.json 没有 version:Coda 只认提交,version 只作显示,但安装确认里会空着');
|
|
180
81
|
// Coda's plugin pages group plugins by the first of their `categories` (Coda's docs/plugins.md「商店」).
|
|
181
82
|
if (!plugin.category) say.warn('manifest.categories', `package.json 没有 categories:Coda 的插件页把它归「其他」;分类用 ${CATEGORIES.join('、')} 之一`);
|
|
@@ -196,12 +97,17 @@ export function checkManifest(dir, say) {
|
|
|
196
97
|
const icons = [['light', declared.light], ...(agent.icon.dark ? [['dark', declared.dark]] : [])].map(([key, at]) => ({ at, data: Buffer.from(agent.icon[key], 'base64') }));
|
|
197
98
|
say.pass('manifest.agents', `Agent ${agent.id}「${agent.displayName}」:command 一行,图标 PDF(${icons.map(i => `${i.at} ${(i.data.length / 1024).toFixed(1)} KiB`).join(',')})`);
|
|
198
99
|
// Sessions from before #1069 store the agent ID `claude`: a plugin that declares it takes them over.
|
|
199
|
-
if (agent.id === 'claude') say.warn('manifest.agent-id', 'Agent ID claude 是 Coda 早先的 Claude 会话存的 ID
|
|
100
|
+
if (agent.id === 'claude') say.warn('manifest.agent-id', 'Agent ID claude 是 Coda 早先的 Claude 会话存的 ID:装上会接管那些旧会话,换一个 ID');
|
|
200
101
|
for (const icon of icons) {
|
|
201
102
|
const page = pageSize(icon.data);
|
|
202
103
|
if (page && Math.min(page.width, page.height) < 64) say.warn('manifest.icon-page', `${icon.at} 的页面只有 ${page.width}×${page.height} pt:iOS 按 96 pt 光栅化图标、只缩不放,页面太小会画成一个点;照 Coda 自带图标按 256 px(192 pt)出图`);
|
|
203
104
|
}
|
|
204
105
|
});
|
|
106
|
+
// What it writes for other plugins' points (Coda's own keys aside) is of the types they declare: one no plugin Coda ships, and
|
|
107
|
+
// none it depends on beside it (directly or through another), declares is of no type.
|
|
108
|
+
const found = besideAll(dir, plugin.dependencies);
|
|
109
|
+
const offered = offerProblem(plugin, new Map([...builtin, ...found]));
|
|
110
|
+
if (offered) say.fail('manifest.offers', offered);
|
|
205
111
|
// Its panels, as the resources plugin reads what is written for its point: one it cannot read shows there as such.
|
|
206
112
|
const panels = [];
|
|
207
113
|
for (const entry of panelEntries(plugin.offers?.panels, plugin.displayName)) {
|
|
@@ -211,33 +117,19 @@ export function checkManifest(dir, say) {
|
|
|
211
117
|
say.pass('manifest.panels', `面板 ${panel.id}「${panel.title}」:动作 ${Object.keys(panel.actions).join('、') || '无'}${panel.signIn ? ',可从 Coda 登录' : ''}`);
|
|
212
118
|
}
|
|
213
119
|
|
|
214
|
-
// What its processes are given (pluginEnv)
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const kept = id => { const at = siblings.get(id), shipped = builtin.get(id);
|
|
219
|
-
return at && shipped && sameSource(shipped.source, { repo: repo.repo, path: at.path }) ? at.plugin.dir : undefined; };
|
|
220
|
-
const local = catalogAfter(plugin, { catalog, siblings });
|
|
221
|
-
const given = new Map([...[...local].map(([id, each]) => [id, each.dir ? each : { ...each, dir: kept(id) }]),
|
|
222
|
-
[plugin.id, { ...plugin, dependencies: plugin.dependencies.filter(d => local.has(d)) }]]);
|
|
223
|
-
const dependencies = Object.fromEntries(plugin.dependencies.flatMap(d => given.get(d)?.dir ? [[d, given.get(d).dir]] : []));
|
|
120
|
+
// What its processes are given (pluginEnv): the plugins it depends on, those beside it here; one Coda ships has its
|
|
121
|
+
// directory in Coda, not here, even with one of its ID beside it (Coda picks its own), and one found nowhere is not named.
|
|
122
|
+
const given = new Map([...builtin, ...found, [plugin.id, { ...plugin, dependencies: plugin.dependencies.filter(d => found.has(d) || builtin.has(d)) }]]);
|
|
123
|
+
const dependencies = Object.fromEntries([...found].filter(([id]) => plugin.dependencies.includes(id)).map(([id, each]) => [id, each.dir]));
|
|
224
124
|
if (plugin.dependencies.length) {
|
|
225
|
-
const absent = plugin.dependencies.filter(d => !
|
|
226
|
-
say.info('manifest.extensions', `依赖 ${plugin.dependencies.join('、')}:Coda
|
|
125
|
+
const absent = plugin.dependencies.filter(d => !found.has(d));
|
|
126
|
+
say.info('manifest.extensions', `依赖 ${plugin.dependencies.join('、')}:Coda 装它时先装它们,它的进程从 CODA_PLUGIN_DEPENDENCIES 拿到它们的目录${absent.length
|
|
227
127
|
? `;${absent.join('、')} 不在旁边,检查时不带` : ''}`);
|
|
228
128
|
}
|
|
229
|
-
commit();
|
|
230
|
-
if (reached('source.npm') && refused !== 'source.npm' && plugin.npm?.length)
|
|
231
|
-
say.pass('source.npm', `npm 依赖 ${plugin.npm.length} 个,带 package-lock.json:Coda 在插件的版本目录里 npm ci 装它们`);
|
|
232
|
-
if (!refused) {
|
|
233
|
-
const along = judged.together.map(each => each.from === 'source' ? `${each.id}(同一提交的 ${each.path})` : `${each.id}(Coda 自带)`);
|
|
234
|
-
say.pass('source.catalog', `与刚装好的 Coda 自带、默认装的插件不冲突${along.length ? `;一起装 ${along.join('、')}` : ''}`);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
129
|
// Its settings for every project, as nobody has set any: the declarations' defaults.
|
|
238
130
|
const settings = resolveSettings(plugin).values;
|
|
239
131
|
// The model services of a machine with none, for one that chooses them; the PATH has no directories of Coda's own here.
|
|
240
132
|
const env = stateDir => pluginEnv({ catalog: given, installed, id: plugin.id, stateDir: id => id === plugin.id ? stateDir : null, settings,
|
|
241
133
|
providers: choosesModelProviders(plugin) ? {} : null, userPath: process.env.PATH ?? '' });
|
|
242
|
-
return { id: plugin.id, manifest, plugin, agents: plugin.agents, panels, settings, dependencies,
|
|
134
|
+
return { id: plugin.id, manifest, plugin, agents: plugin.agents, panels, settings, dependencies, env };
|
|
243
135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coda-console/plugin-check",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读面板。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@0dep/piso": "5.2.0",
|
|
26
26
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
27
|
+
"ajv": "8.20.0",
|
|
27
28
|
"yaml": "2.9.1"
|
|
28
29
|
},
|
|
29
30
|
"publishConfig": {
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// The interfaces a model service may speak (docs/plugins.md「模型服务」): a closed table. A plugin providing a service names
|
|
2
|
-
// one of these (`api`), and so does one choosing services by what it speaks (`modelApis`). Each is a kind of resource of its
|
|
3
|
-
// own (model-services.mjs): a service speaking OpenAI's is nothing like one speaking Anthropic's, whoever provides them. The
|
|
4
|
-
// node delivers a service with its key where its interface carries it (model-services.mjs), Coda lists its models as a
|
|
5
|
-
// client of it would (model-check.mjs), and what an agent is told of calling one is its kind's definition, from here
|
|
6
|
-
// (coda-resources explain). A new interface is a row here: the node would not know where its key goes otherwise.
|
|
7
|
-
// Each: what it is called and where it is defined; how its clients send a key (`key`) and what else (`also`); how the node
|
|
8
|
-
// hands a key on to the service (`delivered`); how it is called and an example, templates of `{base}` (the service's
|
|
9
|
-
// address), `{v1}` (that with `/v1` once: Anthropic's clients take the API's root and add `/v1` themselves, and a service
|
|
10
|
-
// whose address is its versioned base has it already) and `{model}`.
|
|
11
|
-
export const MODEL_PROTOCOLS = {
|
|
12
|
-
'openai-completions': {
|
|
13
|
-
title: 'OpenAI Chat', spec: 'https://platform.openai.com/docs/api-reference/chat',
|
|
14
|
-
description: '讲 OpenAI Chat Completions 接口的服务',
|
|
15
|
-
key: key => ({ Authorization: `Bearer ${key}` }), also: {},
|
|
16
|
-
delivered: key => ({ authorization: `Bearer ${key}` }),
|
|
17
|
-
call: 'POST {base}/chat/completions,body 带 model 与 messages',
|
|
18
|
-
example: `curl -s {base}/chat/completions -H 'Authorization: Bearer coda' -H 'Content-Type: application/json' \\\n -d '{"model": "{model}", "messages": [{"role": "user", "content": "你好"}]}'`,
|
|
19
|
-
},
|
|
20
|
-
'openai-responses': {
|
|
21
|
-
title: 'OpenAI Responses', spec: 'https://platform.openai.com/docs/api-reference/responses',
|
|
22
|
-
description: '讲 OpenAI Responses 接口的服务',
|
|
23
|
-
key: key => ({ Authorization: `Bearer ${key}` }), also: {},
|
|
24
|
-
delivered: key => ({ authorization: `Bearer ${key}` }),
|
|
25
|
-
call: 'POST {base}/responses,body 带 model 与 input',
|
|
26
|
-
example: `curl -s {base}/responses -H 'Authorization: Bearer coda' -H 'Content-Type: application/json' \\\n -d '{"model": "{model}", "input": "你好"}'`,
|
|
27
|
-
},
|
|
28
|
-
'anthropic-messages': {
|
|
29
|
-
title: 'Anthropic', spec: 'https://docs.anthropic.com/en/api/messages',
|
|
30
|
-
description: '讲 Anthropic Messages 接口的服务',
|
|
31
|
-
key: key => ({ 'x-api-key': key }), also: { 'anthropic-version': '2023-06-01' },
|
|
32
|
-
// Some of its clients send the key as a bearer token: the node sends it both ways.
|
|
33
|
-
delivered: key => ({ 'x-api-key': key, authorization: `Bearer ${key}` }),
|
|
34
|
-
call: 'POST {v1}/messages,body 带 model、max_tokens 与 messages;带请求头 anthropic-version',
|
|
35
|
-
example: `curl -s {v1}/messages -H 'x-api-key: coda' -H 'anthropic-version: 2023-06-01' -H 'Content-Type: application/json' \\\n -d '{"model": "{model}", "max_tokens": 256, "messages": [{"role": "user", "content": "你好"}]}'`,
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
export const MODEL_APIS = Object.keys(MODEL_PROTOCOLS);
|
|
39
|
-
export const isModelApi = api => typeof api === 'string' && Object.hasOwn(MODEL_PROTOCOLS, api);
|