@coda-console/plugin-check 0.8.28 → 0.8.30

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.
Files changed (32) hide show
  1. package/README.md +13 -23
  2. package/check/coda/adapters/plugin-events.mjs +3 -10
  3. package/check/coda/adapters/plugin-modules.mjs +19 -23
  4. package/check/coda/adapters/plugin-setup-api.mjs +5 -0
  5. package/check/coda/adapters/plugin-test-host.d.mts +0 -13
  6. package/check/coda/adapters/plugin-test-host.mjs +6 -25
  7. package/check/coda/api-surface.txt +3 -6
  8. package/check/coda/application/contributions.mjs +1 -0
  9. package/check/coda/builtin.json +15 -49
  10. package/check/coda/components/plugins/contribution-points.mjs +1 -2
  11. package/check/coda/components/plugins/git-contributions.mjs +10 -6
  12. package/check/coda/components/plugins/plugin-extensions.mjs +9 -72
  13. package/check/coda/components/plugins/plugin-rules.mjs +16 -20
  14. package/check/coda/components/plugins/plugin-source-rules.mjs +13 -29
  15. package/check/coda/components/plugins/self-contributions.mjs +13 -0
  16. package/check/coda/components/protocols/record-rules.mjs +8 -0
  17. package/check/coda/contract.json +18 -26
  18. package/check/manifest.mjs +10 -8
  19. package/package.json +2 -2
  20. package/templates/module/main.mjs +6 -13
  21. package/templates/module/package.json +7 -7
  22. package/templates/module/test/main.test.mjs +7 -23
  23. package/check/coda/application/host-protocols.mjs +0 -19
  24. package/check/coda/components/workflows/workflow-protocol-definitions.mjs +0 -362
  25. package/check/coda/domain/accord.mjs +0 -144
  26. package/check/coda/domain/jcs.mjs +0 -58
  27. package/check/coda/domain/usage.mjs +0 -56
  28. package/check/coda/kernel/accord-protocol.mjs +0 -168
  29. package/check/coda/kernel/plugin-protocol.mjs +0 -56
  30. package/check/coda/kernel/project-protocol.mjs +0 -52
  31. package/check/coda/kernel/thread-protocol.mjs +0 -167
  32. package/check/coda/kernel/usage-protocol.mjs +0 -97
@@ -1,53 +1,19 @@
1
- // How one plugin builds on another (docs/plugins.md「依赖与扩展点」): it names the plugins it needs (`extensionDependencies`), and
2
- // may plug into a point one of them declares for it (`contributes.extensionPoints` there, `contributes.extensions` here).
3
- // Coda checks the names and hands each plugin what is plugged into its points, as declared: what passes between the two
4
- // is the extended plugin's own contract, which Coda neither reads nor shapes. A point may instead take what any plugin
5
- // writes under a key of its `contributes` (`contributes` there): of the schema the point
6
- // declares, kept as written, for the declaring plugin to read, only the commands in it listed where installing confirms them.
1
+ // How one plugin builds on another (docs/plugins.md「依赖与扩展点」): it names the plugins it needs (`extensionDependencies`),
2
+ // and Coda checks the names: each is there, and none needs itself round about.
7
3
  import { CORE_PROTOCOLS } from '@coda-console/protocol/protocol';
8
- import { pointProblem, valueProblem } from '@coda-console/protocol/validate';
4
+ import { valueProblem } from '@coda-console/protocol/validate';
9
5
  import { requireCondition as check } from '../../domain/errors.mjs';
10
6
  import { payloadProblem } from '../protocols/protocol-events.mjs';
11
7
 
12
8
  const code = 'invalid_plugin';
13
9
 
14
- // The point that takes what is written under this key of `contributes`, with the plugin declaring it, or null.
15
- export function offerPoint(plugins, key) {
16
- for (const plugin of plugins.values()) for (const [point, declared] of Object.entries(plugin.extensionPoints ?? {}))
17
- if (declared.contributes === key) return { plugin, point, declared };
18
- return null;
19
- }
20
- // The commands in what a plugin writes for a point (`raw`), each with what it is for, as installing it confirms them:
21
- // `<title>「<the thing's title, ID or place>」的<label>`, and the keys a `*` stood for. How many things it writes.
22
- export function offeredCommands(raw, declared) {
23
- const items = Array.isArray(raw) ? raw.map((value, i) => [typeof value?.title === 'string' ? value.title : typeof value?.id === 'string' ? value.id : String(i + 1), value])
24
- : raw && typeof raw === 'object' ? Object.entries(raw) : [];
25
- const commands = [];
26
- const walk = (value, rest, stood, label, name) => {
27
- if (!rest.length) {
28
- if (typeof value === 'string' && value.trim()) commands.push({ label: `${declared.title}「${name}」的${label}${stood.length ? ` ${stood.join(' ')}` : ''}`, command: value });
29
- return;
30
- }
31
- if (!value || typeof value !== 'object') return;
32
- const [head, ...tail] = rest;
33
- if (head === '*') for (const [key, next] of Object.entries(value)) walk(next, tail, [...stood, key], label, name);
34
- else if (Object.hasOwn(value, head)) walk(value[head], tail, stood, label, name);
35
- };
36
- for (const [name, item] of items) for (const [path, label] of Object.entries(declared.commands ?? {})) walk(item, path.split('.'), [], label, name);
37
- return { count: items.length, commands };
38
- }
39
- // The catalog as a whole: every plugin needed is there, nothing needs itself round about, every point plugged into is
40
- // one its plugin declares, what is written under a key of `contributes` not Coda's own a point takes, and every operation a
41
- // plugin's commands implement is one of its protocol's definition, Coda's own or a plugin's here.
10
+ // The catalog as a whole: every plugin needed is there, nothing needs itself round about, and every operation a plugin's
11
+ // commands implement is one of its protocol's definition, Coda's own or a plugin's here.
42
12
  export function checkCatalog(plugins) {
43
13
  for (const plugin of plugins.values()) {
44
14
  for (const id of plugin.dependencies) check(plugins.has(id), code, `插件 ${plugin.id} 依赖的 ${id} 不在 Coda 里`);
45
- for (const e of plugin.extensions) check(Object.hasOwn(plugins.get(e.plugin).extensionPoints, e.point), code,
46
- `插件 ${plugin.id} 接的 ${e.plugin}/${e.point} 不是 ${e.plugin} 声明的扩展点`);
47
15
  const operation = operationProblem(plugin, plugins);
48
16
  check(!operation, code, operation);
49
- const problem = offerProblem(plugin, plugins);
50
- check(!problem, code, `插件 ${plugin.id}:${problem}`);
51
17
  }
52
18
  const visiting = new Set(), done = new Set();
53
19
  const visit = (id, path) => {
@@ -98,7 +64,7 @@ export function implementsMissing(plugin, plugins, defined) {
98
64
  }
99
65
  // This Coda's API Level (docs/plugins.md「兼容」): what it offers plugins, counted. A manifest's `engines.coda` names the least
100
66
  // a plugin needs; one naming none needs 0, which any Coda has.
101
- export const API_LEVEL = 6;
67
+ export const API_LEVEL = 8;
102
68
  // The API Level a package's registry metadata asks for in its `engines`: a positive integer, or its digits as text (what
103
69
  // npm's registry may make of one); undefined when it asks for none, null when it is anything else. A manifest read from
104
70
  // its directory has the schema's shape (plugin-rules.mjs readPlugin).
@@ -109,7 +75,7 @@ export function wantedLevel(engines) {
109
75
  return typeof value === 'string' && /^[1-9][0-9]{0,8}$/.test(value) ? Number(value) : null;
110
76
  }
111
77
  // The keys of `contributes` Coda once read and no longer does: a manifest still writing one was made for what Coda took away.
112
- const RETIRED_CONTRIBUTES = ['endpoints', 'groups', 'events', 'resources', 'panels'];
78
+ const RETIRED_CONTRIBUTES = ['endpoints', 'groups', 'events', 'resources', 'panels', 'extensionPoints', 'extensions'];
113
79
  // Those of them `contributes` writes, a manifest's or a version's registry metadata: what either is read with as its `retired`.
114
80
  export const retiredContributes = contributes => RETIRED_CONTRIBUTES.filter(key => Object.hasOwn(contributes ?? {}, key));
115
81
  // Whether a plugin runs on this machine (docs/plugins.md「兼容」): the one judgment reading a source, installing, the store and
@@ -155,13 +121,12 @@ export const ownsProtocol = (plugin, kind) =>
155
121
  (plugin.protocols ?? []).some(one => one.name === kind) || (plugin.protocolImplementations ?? []).some(one => one.kind === kind);
156
122
  // What an event is about: `<kind>:<ID>`, at most 500 characters.
157
123
  const SUBJECT = /^(?=.{3,500}$)[a-z][a-z0-9_-]*:\S+$/;
158
- // Why plugin `plugin` (its catalog entry) may not publish (by `how`: publish-event, coda event, coda.emit) event `name`
124
+ // Why plugin `plugin` (its catalog entry) may not publish (by `how`: publish-event, coda event) event `name`
159
125
  // about `subject`, saying `payload`, or null — `event` the event of that name on this machine (components/protocols/
160
126
  // protocol-events.mjs), or none: it is one of a protocol the plugin defines or implements and not Coda's own (`codaOnly`:
161
127
  // application/host-protocols.mjs; a plugin implementing coda/thread@1 publishes no session's), about a subject it names (not a
162
128
  // session's: `thread:` is Coda's), saying a JSON object its payload schema has, no more than 100 KB of it and nothing of
163
- // `coda` (Coda's, beside it in a run). Where it is published is the backend's to check, as the backend and the plugin host
164
- // for a plugin's tests (adapters/plugin-test-host.mjs) both check the rest.
129
+ // `coda` (Coda's, beside it in a run). Where it is published is the backend's to check, as the backend checks the rest.
165
130
  export function publishedProblem(how, plugin, event, { name, subject, payload }) {
166
131
  if (!event || !ownsProtocol(plugin, event.kind)) return `插件 ${plugin.id} 定义或实现的协议里没有事件 ${name}`;
167
132
  if (event.codaOnly) return `插件 ${plugin.id} 不能发布事件 ${name}:它是 Coda 自己的协议 ${event.kind} 的,只由 Coda 发布`;
@@ -199,19 +164,6 @@ export function usesRefusal(plugin, kind, need, definition, owned = true) {
199
164
  return group ? `插件 ${plugin.id} 要${what},须在清单的 uses 里写 ${kind} 的权限组 ${group}`
200
165
  : `插件 ${plugin.id} 不能${what}:它不在 ${kind} 的任何权限组里,不对插件开放`;
201
166
  }
202
- // Why what a plugin writes under the keys of `contributes` not Coda's own cannot be taken here (`plugins`: the catalog
203
- // beside it), or null: no point takes one of them, or what it writes is not of the schema the point declares.
204
- export function offerProblem(plugin, plugins) {
205
- const others = new Map([...plugins, [plugin.id, plugin]]), offers = Object.entries(plugin.offers ?? {});
206
- const unknown = offers.map(([key]) => key).filter(key => !offerPoint(others, key));
207
- if (unknown.length) return `contributes 里的 ${unknown.join('、')} 不是 Coda 的类型,也没有插件的扩展点声明它`;
208
- for (const [key, value] of offers) {
209
- const { schema } = offerPoint(others, key).declared;
210
- const problem = schema !== undefined ? pointProblem(schema, value, `contributes.${key}`, plugin.dir) : null;
211
- if (problem) return problem;
212
- }
213
- return null;
214
- }
215
167
  // What installing a plugin installs: what it needs, before it, then it.
216
168
  export function withDependencies(catalog, id) {
217
169
  const order = [], seen = new Set();
@@ -247,18 +199,3 @@ export function dependents(catalog, installed, id) {
247
199
  }
248
200
  return [...found].sort();
249
201
  }
250
- // What installed plugins plug into this plugin's points, by point, in plugin ID order: each one's command, its directory,
251
- // the directory it keeps its state in (`stateDir`) and its settings for every project (`settingsOf`), for the extended
252
- // plugin to run it as its own contract says, the command answering by its own settings.
253
- export function extensionsFor(catalog, installed, id, stateDir = () => null, settingsOf = () => null) {
254
- const points = {};
255
- for (const plugin of [...catalog.values()].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0)) {
256
- if (!installed.has(plugin.id)) continue;
257
- for (const e of plugin.extensions) {
258
- if (e.plugin !== id || !Object.hasOwn(catalog.get(id)?.extensionPoints ?? {}, e.point)) continue;
259
- const state = stateDir(plugin.id), settings = settingsOf(plugin.id);
260
- (points[e.point] ??= []).push({ plugin: plugin.id, command: e.command, path: plugin.dir, ...(state ? { state } : {}), ...(settings ? { settings } : {}) });
261
- }
262
- }
263
- return points;
264
- }
@@ -17,7 +17,7 @@ import { durationMs, isDuration } from '../../domain/duration.mjs';
17
17
  import { AGENT_ID } from '../../domain/values.mjs';
18
18
  import { THREAD_ENV, TOKEN_ENV } from '../../domain/session-env.mjs';
19
19
  import { iconFiles } from './plugin-icons.mjs';
20
- import { checkCatalog, extensionsFor, retiredContributes } from './plugin-extensions.mjs';
20
+ import { API_LEVEL, checkCatalog, retiredContributes } from './plugin-extensions.mjs';
21
21
  import { contributionProblem, manifestProblem, TYPES } from '@coda-console/protocol/validate';
22
22
  import { ownedProtocolsProblem } from '@coda-console/protocol/protocol';
23
23
  import { claims, npmPluginId, repoAddress, sourcePath } from './plugin-source-rules.mjs';
@@ -27,8 +27,8 @@ const ID = /^[a-z][a-z0-9-]{0,39}$/;
27
27
  // Plugins that ship with Coda, as VS Code's built-in extensions ship with it: updated with Coda itself.
28
28
  export const BUILTIN_DIR = fileURLToPath(new URL('../../resources/plugins/', import.meta.url));
29
29
  // What the plugins' base reads of `contributes` itself, the general types schemas/plugin.json names; any other key is a
30
- // contribution point's (contribution-points.mjs), or for a point another plugin declares to take it, refused when
31
- // neither does.
30
+ // contribution point's (contribution-points.mjs) or one Coda retired (plugin-extensions.mjs retiredContributes), refused
31
+ // when it is none of these.
32
32
  export const CONTRIBUTES = TYPES;
33
33
  // The shortest a kind's records are given again by its command on their own (`contributes.records`' `every`).
34
34
  const EVERY_LEAST = 60_000;
@@ -102,6 +102,12 @@ export function readPlugin(dir, source, points = CONTRIBUTION_POINTS) {
102
102
  check(manifest && typeof manifest === 'object' && !Array.isArray(manifest), 'invalid_plugin', 'package.json 须为对象');
103
103
  const problem = manifestProblem(manifest, dir);
104
104
  check(!problem, 'invalid_plugin', problem);
105
+ // One still writing a key Coda retired needs an update (plugin-extensions.mjs compatibility): what else it writes for
106
+ // what Coda took away (what a retired extension point took) is not a key it got wrong. Nor is one asking for a Level above
107
+ // this Coda's (`engines.coda`): it may write what a later Coda takes, and is read for that Coda to be upgraded (`need: coda`).
108
+ const retired = retiredContributes(manifest.contributes);
109
+ const unknown = !retired.length && !((manifest.engines?.coda ?? 0) > API_LEVEL) && Object.keys(manifest.contributes ?? {}).find(key => !CONTRIBUTES.includes(key) && !points.get(key));
110
+ check(!unknown, 'invalid_plugin', `contributes 里的 ${unknown} 不是 Coda 的类型`);
105
111
  for (const point of points.values()) if (manifest.contributes?.[point.key] !== undefined) {
106
112
  const wrong = contributionProblem(point.schema, manifest, point.key, dir);
107
113
  check(!wrong, 'invalid_plugin', wrong);
@@ -113,7 +119,7 @@ export function readPlugin(dir, source, points = CONTRIBUTION_POINTS) {
113
119
  const contributes = manifest.contributes ?? {}, configuration = contributes.configuration ?? {};
114
120
  const protocolsProblem = ownedProtocolsProblem({ id, contributes: { protocols: contributes.protocols } });
115
121
  check(!protocolsProblem, 'invalid_plugin', protocolsProblem);
116
- const records = recordCommands(contributes, dir), self = selfCommands(contributes, dir), retired = retiredContributes(contributes);
122
+ const records = recordCommands(contributes, dir), self = selfCommands(contributes, dir);
117
123
  const properties = Object.fromEntries(Object.entries(configuration.properties ?? {}).map(([key, value]) => {
118
124
  check(key.split('.')[0] === id, 'invalid_plugin', `设置名须以「${id}.」开头:${key}`);
119
125
  return [key, setting(value, key)];
@@ -121,8 +127,6 @@ export function readPlugin(dir, source, points = CONTRIBUTION_POINTS) {
121
127
  const files = sub => existsSync(join(dir, sub)) ? [...new Set(readdirSync(join(dir, sub)).map(f => /^(.+)\.bpmn$/.exec(f)?.[1]).filter(Boolean))].sort() : [];
122
128
  const required = configuration.required ?? [], activation = manifest.activationEvents ?? [], dependencies = manifest.extensionDependencies ?? [];
123
129
  const displayName = typeof manifest.displayName === 'string' ? manifest.displayName : id;
124
- // What it writes under keys of `contributes` that are none of Coda's: for the points other plugins declare (checkCatalog).
125
- const offers = Object.fromEntries(Object.entries(contributes).filter(([key]) => !CONTRIBUTES.includes(key) && !points.get(key)));
126
130
  const read = Object.assign({}, ...[...points.values()].map(point => point.read(contributes[point.key], dir)));
127
131
  const icon = pluginIcon(manifest.icon, dir) ?? [...points.values()].map(point => point.icon?.(read)).find(Boolean);
128
132
  return { id, displayName, description: typeof manifest.description === 'string' ? manifest.description : '', version: String(manifest.version ?? ''),
@@ -147,18 +151,11 @@ export function readPlugin(dir, source, points = CONTRIBUTION_POINTS) {
147
151
  ...(contributes.protocolImplementations?.length ? { protocolImplementations: implementations(contributes.protocolImplementations) } : {}),
148
152
  ...(records.length ? { records } : {}),
149
153
  ...(Object.keys(self).length ? { self } : {}),
150
- ...(Object.keys(offers).length ? { offers } : {}),
151
- dependencies: [...dependencies], extensionPoints: extensionPoints(contributes.extensionPoints, dir),
152
- extensions: Object.entries(contributes.extensions ?? {}).map(([key, value]) => { const [plugin, point] = key.split('/'); return { plugin, point, command: value.command }; }),
154
+ dependencies: [...dependencies],
153
155
  ...(contributes.setup ? { setup: { command: contributes.setup.command } } : {}),
154
156
  ...(Object.keys(contributes.environment ?? {}).length ? { environment: Object.entries(contributes.environment).map(([name, value]) => ({ name, value })) } : {}),
155
157
  ...(contributes.path?.length ? { path: contributes.path.map(entry => pathEntry(entry)) } : {}) };
156
158
  }
157
- // Its extension points (schemas/extension-points.json), each with what it says of itself: the schema of what others write for
158
- // one, read from its file.
159
- const extensionPoints = (raw = {}, dir) => Object.fromEntries(Object.entries(raw).map(([name, value]) => [name, value.contributes === undefined
160
- ? { description: value.description } : { description: value.description, contributes: value.contributes, title: value.title, commands: { ...(value.commands ?? {}) },
161
- ...(value.schema ? { schema: JSON.parse(readFileSync(join(dir, value.schema), 'utf8')) } : {}) }]));
162
159
  // The directories it puts on the PATH of what starts in a project it applies to: one of its own (relative, as a Skill's),
163
160
  // or one in its state on the backend (`${CODA_PLUGIN_STATE}/…`), which its setup may make.
164
161
  function pathEntry(entry) {
@@ -235,20 +232,19 @@ export function publishedFrom(repository) {
235
232
  // What Coda gives each process it runs for a plugin (docs/plugins.md「插件进程的环境」) — its agents', the steps
236
233
  // of its workflows, the commands it puts on sessions' PATH —, beside the environment the process runs in: Coda's own Node,
237
234
  // the plugin's directory and its state on this backend (`stateDir(id)`, none without one), its settings as they apply
238
- // (`settings`), what installed plugins plug into its points and where the plugins it depends on are, whose files (an npm
239
- // package one of them brings) it may use, none of either when there is none; the files its secrets set there are in
235
+ // (`settings`), and where the plugins it depends on are, whose files (an npm package one of them brings) it may use, none
236
+ // when it depends on none; the files its secrets set there are in
240
237
  // (`secrets`, by setting), none when none is; whether this backend is its environment's own (`arbiter`); and the PATH
241
238
  // without Coda's own directories, for what it hands to a program that is not Coda's (`userPath`, adapters/installation.mjs).
242
239
  export const PLUGIN_VARIABLES = ['CODA_NODE', 'CODA_ARBITER', 'CODA_PLUGIN_PATH', 'CODA_PLUGIN_STATE', 'CODA_PLUGIN_SETTINGS', 'CODA_PLUGIN_SECRETS',
243
- 'CODA_PLUGIN_EXTENSIONS', 'CODA_PLUGIN_DEPENDENCIES', 'CODA_MODEL_PROVIDERS', 'CODA_USER_PATH'];
240
+ 'CODA_PLUGIN_DEPENDENCIES', 'CODA_MODEL_PROVIDERS', 'CODA_USER_PATH'];
244
241
  // `providers`: the model services of this machine, for a plugin that chooses them (choosesModelProviders); none for any other.
245
- export function pluginEnv({ catalog, installed, id, stateDir = () => null, settingsOf = () => null, settings, secrets = {}, providers = null, arbiter = false, userPath = null }) {
246
- const plugin = catalog.get(id), state = stateDir(id), points = extensionsFor(catalog, installed, id, stateDir, settingsOf);
242
+ export function pluginEnv({ catalog, id, stateDir = () => null, settings, secrets = {}, providers = null, arbiter = false, userPath = null }) {
243
+ const plugin = catalog.get(id), state = stateDir(id);
247
244
  return { CODA_NODE: process.execPath, CODA_PLUGIN_PATH: plugin.dir, ...(state ? { CODA_PLUGIN_STATE: state } : {}),
248
245
  ...(userPath !== null ? { CODA_USER_PATH: userPath } : {}),
249
246
  CODA_PLUGIN_SETTINGS: JSON.stringify(settings), ...(Object.keys(secrets).length ? { CODA_PLUGIN_SECRETS: JSON.stringify(secrets) } : {}),
250
247
  ...(providers ? { CODA_MODEL_PROVIDERS: JSON.stringify(providers) } : {}),
251
- ...(Object.keys(points).length ? { CODA_PLUGIN_EXTENSIONS: JSON.stringify(points) } : {}),
252
248
  ...(plugin.dependencies.length ? { CODA_PLUGIN_DEPENDENCIES: JSON.stringify(Object.fromEntries(plugin.dependencies.map(d => [d, catalog.get(d).dir]))) } : {}),
253
249
  ...(arbiter ? { CODA_ARBITER: '1' } : {}) };
254
250
  }
@@ -7,7 +7,7 @@
7
7
  import { createHash } from 'node:crypto';
8
8
  import { normalize } from 'node:path';
9
9
  import { requireCondition as check } from '../../domain/errors.mjs';
10
- import { installingIncompatibility, offerPoint, offeredCommands, offerProblem, protocolDefinition, withDependencies } from './plugin-extensions.mjs';
10
+ import { installingIncompatibility, protocolDefinition, withDependencies } from './plugin-extensions.mjs';
11
11
  import { CONTRIBUTION_POINTS } from './contribution-points.mjs';
12
12
  import { definedEvents, eventsProblem } from '../protocols/protocol-events.mjs';
13
13
 
@@ -260,24 +260,18 @@ export function builtinProblem(id, builtin) {
260
260
  }
261
261
  // What only one plugin may declare, as said to the user: what a component's contribution point says (its `claim`: an
262
262
  // agent, which sessions name by its ID alone; a concurrency group, which any process takes by its name; Git's credentials
263
- // for an address; a composer mode's name and the character typed to enter one), opening a kind of reference (a view's
264
- // `handles`) and a key of `contributes` a point takes. A command, as a Skill or a variable, is a project's: one two plugins
263
+ // for an address; a composer mode's name and the character typed to enter one) and opening a kind of reference (a view's
264
+ // `handles`). A command, as a Skill or a variable, is a project's: one two plugins
265
265
  // of a project bring is neither's there (components/plugins/plugins.mjs launch).
266
266
  export const claims = plugin => [...[...CONTRIBUTION_POINTS.values()].flatMap(point => point.claim?.(plugin) ?? []),
267
- ...(plugin.views ?? []).flatMap(v => (v.handles ?? []).map(kind => `打开 ${kind} 引用`)),
268
- ...Object.values(plugin.extensionPoints ?? {}).filter(p => p.contributes).map(p => `扩展点 contributes.${p.contributes}`)];
267
+ ...(plugin.views ?? []).flatMap(v => (v.handles ?? []).map(kind => `打开 ${kind} 引用`))];
269
268
  // Why a plugin cannot sit beside those this machine has (`catalog`: built-in and installed, by ID; `builtin`: the plugins
270
- // Coda ships, by ID), or null: a built-in one's ID or Coda's own (builtinProblem), what a component's
271
- // contribution point lets only a built-in plugin bring (its `builtinOnly`, of the plugin read: why, none when it brings none
272
- // of it), or what only one plugin may declare (claims), a protocol or an event of one, another plugin declares. What it needs of the others — the plugins it depends on,
273
- // the points it plugs into or writes for (plugin-extensions.mjs offerProblem) — is checked once all of them are there.
269
+ // Coda ships, by ID), or null: a built-in one's ID or Coda's own (builtinProblem), or what only one plugin may declare
270
+ // (claims), a protocol or an event of one, another plugin declares. What it needs of the others — the plugins it depends
271
+ // on — is checked once all of them are there.
274
272
  export function catalogProblem(plugin, catalog, builtin) {
275
273
  const named = builtinProblem(plugin.id, builtin);
276
274
  if (named) return named;
277
- if (plugin.source?.kind !== 'builtin') for (const point of CONTRIBUTION_POINTS.values()) {
278
- const only = point.builtinOnly?.(plugin);
279
- if (only) return only;
280
- }
281
275
  const own = claims(plugin), twice = own.find((claim, i) => own.indexOf(claim) !== i);
282
276
  if (twice) return `${twice} 在插件里声明了两次`;
283
277
  for (const claim of own) {
@@ -311,28 +305,22 @@ export function together(plugin, { catalog, installed, siblings, defined = () =>
311
305
  : siblings.has(each) ? { id: each, from: 'source', path: siblings.get(each).path, ...shown(siblings.get(each).plugin) } : { id: each, from: 'missing' });
312
306
  }
313
307
  // The catalog once a plugin from a source is installed: this machine's, what of the same commit is installed with it
314
- // (what it needs, directly or through another, as together finds it), and it. Not the other plugins of the commit: what
315
- // it and those write for points is confirmed as the points installed say.
308
+ // (what it needs, directly or through another, as together finds it), and it. Not the other plugins of the commit.
316
309
  export function catalogAfter(plugin, { catalog, siblings }) {
317
310
  const known = new Map([...[...siblings].map(([sibling, at]) => [sibling, at.plugin]), ...catalog, [plugin.id, plugin]]);
318
311
  const along = withDependencies(known, plugin.id).filter(each => each !== plugin.id && !catalog.has(each) && siblings.has(each));
319
312
  return new Map([...catalog, ...along.map(each => [each, siblings.get(each).plugin]), [plugin.id, plugin]]);
320
313
  }
321
- // What installing it brings, as the confirmation lists it: every command it runs, word for word (those it plugs into
322
- // another plugin's points too, which that plugin runs — those it writes for a point under a key of `contributes`, where
323
- // the point says, the catalog beside it (`catalog`) declaring it —, those it puts on every session's PATH, those
314
+ // What installing it brings, as the confirmation lists it: every command it runs, word for word (those it puts on every
315
+ // session's PATH, those
324
316
  // answering clients' requests, those implementing operations of its protocols (by kind, operation and file), those giving
325
317
  // the records of its kinds and answering its own queries, and the one that makes each
326
318
  // machine ready for it, run as it is installed or updated), what a component's contribution point confirms (its
327
319
  // `confirm`: its agents and the commands it puts on sessions' PATH, the Agent Skills it lays into projects, the MCP
328
320
  // servers their agents start and what it tells every agent; the groups it brings, what it calls its capabilities; the
329
- // modes it puts the composer in), what it calls its workflows and how many settings; and the permission groups it uses of
321
+ // modes it puts the composer in; each address it answers Git for and the command listing repositories to choose from), what it calls its workflows and how many settings; and the permission groups it uses of
330
322
  // others' protocols, as those define them in the catalog beside it or Coda does (`defined`: plugin-extensions.mjs protocolDefinition).
331
323
  export function contributions(plugin, catalog = new Map(), defined = () => null) {
332
- const offers = Object.entries(plugin.offers ?? {}).flatMap(([key, raw]) => {
333
- const found = offerPoint(new Map([...catalog, [plugin.id, plugin]]), key);
334
- return found ? [{ plugin: found.plugin.id, point: found.point, title: found.declared.title, ...offeredCommands(raw, found.declared) }] : [];
335
- });
336
324
  return {
337
325
  // The variables it gives what starts in the projects it applies to, each with its value as written, and the
338
326
  // directories it puts on their PATH.
@@ -351,10 +339,6 @@ export function contributions(plugin, catalog = new Map(), defined = () => null)
351
339
  ...(plugin.views?.length ? { views: plugin.views.map(v => ({ id: v.id, title: v.title, ...(v.in ? { in: v.in } : {}), ...(v.icon ? { icon: v.icon } : {}), ...(v.handles ? { handles: v.handles } : {}), ...(v.readout ? { readout: v.readout } : {}),
352
340
  ...(v.checkout ? { checkout: v.checkout } : {}), ...(v.provides ? { provides: v.provides } : {}) })) } : {}),
353
341
  ...Object.assign({}, ...[...CONTRIBUTION_POINTS.values()].map(point => point.confirm?.(plugin))),
354
- extensions: plugin.extensions.map(e => ({ plugin: e.plugin, point: e.point, command: e.command })),
355
- // What it writes for points under keys of `contributes`: by point, how many and the
356
- // commands in them, each with what it is for.
357
- ...(offers.length ? { offers } : {}),
358
342
  ...(plugin.setup ? { setup: { command: plugin.setup.command } } : {}),
359
343
  workflows: plugin.workflows, settings: Object.keys(plugin.properties).length,
360
344
  // What each machine installs for it from npm, as read from its repository (components/plugins/plugin-sources.mjs inspect).
@@ -389,13 +373,13 @@ export function candidate({ path, manifest, plugin, problem, fallback }, { catal
389
373
  const missing = along.filter(each => each.from === 'missing').map(each => each.id);
390
374
  // One coming along from the source is installed as it is (components/plugins/plugins.mjs installFrom): judged by its ID the same.
391
375
  const reserved = along.filter(each => each.from === 'source').map(each => [each.id, builtinProblem(each.id, builtin)]).find(([, why]) => why);
392
- // What this machine has once it is installed, those installed with it among them: the points it may write for.
376
+ // What this machine has once it is installed, those installed with it among them.
393
377
  const after = plugin ? catalogAfter(plugin, { catalog, siblings }) : catalog;
394
378
  const incompatible = plugin ? installingIncompatibility(after, installed, id, { channel, level, defined }) : null;
395
379
  return { path, id, displayName: plugin?.displayName ?? (typeof manifest?.displayName === 'string' ? manifest.displayName : id),
396
380
  description: plugin?.description ?? (typeof manifest?.description === 'string' ? manifest.description : ''), version: plugin?.version ?? '',
397
381
  installed: row ? row.source ?? { kind: 'builtin' } : null,
398
- problem: problem ?? incompatible?.error ?? (plugin ? catalogProblem(plugin, catalog, builtin) ?? offerProblem(plugin, after) : null) ?? (reserved ? reserved.join(':') : null)
382
+ problem: problem ?? incompatible?.error ?? (plugin ? catalogProblem(plugin, catalog, builtin) : null) ?? (reserved ? reserved.join(':') : null)
399
383
  ?? (missing.length ? `要一起装的 ${missing.join('、')} 不在这台机器上${plugin.source?.kind === 'npm' ? '' : ',也不在这个提交里'}` : null),
400
384
  ...(!problem && incompatible ? { incompatible } : {}), together: along.filter(each => each.from !== 'missing'),
401
385
  ...(plugin ? { contributes: contributions(plugin, after, defined) } : {}) };
@@ -0,0 +1,13 @@
1
+ // What the plugin host takes of plugins (components/plugins/contribution-points.mjs): the commands that answer a plugin's
2
+ // own queries (docs/plugins.md「只给自己用的查询」), by the name its page or process asks them by, defined as this module
3
+ // loads. The commands are read where the plugin is (plugin-rules.mjs `selfCommands`: each file one Coda runs itself), so
4
+ // what a point reads of it here is nothing. Descriptions only: nothing here imports a component.
5
+ import { defineContributionPoint } from './contribution-points.mjs';
6
+
7
+ defineContributionPoint({ key: 'self',
8
+ schema: { title: 'contributes.self:只给自己用的查询',
9
+ description: '名字 → 插件目录里的文件(相对路径,不离开插件目录),由命令回答插件自己的页面与进程的 self 查询;同一个名字写了命令就交给命令,没有再找模块。至多 50 个。',
10
+ type: 'object', maxProperties: 50,
11
+ propertyNames: { $ref: 'https://coda.pub/schemas/protocol/v1/definition.json#/$defs/operationName' },
12
+ additionalProperties: { type: 'string', 'x-file': { type: 'file' } } },
13
+ read: () => ({}) });
@@ -1,6 +1,7 @@
1
1
  // What a plugin's reads and writes of the records (coda#2749 3.7, `coda.get`, `list`, `put`, `replace`) are held to,
2
2
  // wherever they are answered: by the backend (./mirror.mjs, ./providers.mjs, ./protocols.mjs) and by a plugin's test host
3
3
  // (adapters/plugin-test-host.mjs).
4
+ import { protocolShortName } from '@coda-console/protocol/protocol';
4
5
  import { requireCondition as check } from '../../domain/errors.mjs';
5
6
  import { derivedUUID } from '../../domain/values.mjs';
6
7
 
@@ -13,6 +14,13 @@ import { derivedUUID } from '../../domain/values.mjs';
13
14
  // the record directory, which the other backends of a space copy.
14
15
  export const LOCAL_KINDS = new Set(['coda/composer@1', 'coda/submission@1', 'coda/run@1', 'coda/thread@1', 'coda/project@1', 'coda/card@1',
15
16
  'coda/plugin@1', 'coda/usage@1', 'coda/accord@1', 'coda/workflow@1', 'coda/workflow-run@1']);
17
+ export const mirrorPlural = kind => protocolShortName(kind);
18
+ // A kind's records in the record directory are of its plural: the one its definition names, which only Coda's own
19
+ // definitions do (the core protocols'; a plugin's definition's `plural` is dropped as it is
20
+ // installed, providers.mjs `install`), else its short name. migrate-v254.mjs keeps a fixed copy of this rule.
21
+ export const pluralOf = definition => definition.plural ?? mirrorPlural(definition.kind);
22
+ /** What the directory says as it refuses a record over its size (coda-directory src/directory.mjs `put`). */
23
+ export const TOO_LARGE = /^the record is \d+ bytes, more than \d+$/;
16
24
  // `list(kind, { scope?, id?, labels? })`: this machine's records (`local`) or this machine's and the others' (`available`,
17
25
  // unsaid), all of them, those of an ID, or those whose labels have each of these values (`labels`, as Kubernetes' equality
18
26
  // selector: nothing but equality).
@@ -1,63 +1,55 @@
1
1
  {
2
- "commit": "b5d62fd390b27f300bb43d6c5b6bb6bb133a8515",
3
- "apiLevel": 6,
2
+ "commit": "6b6dba1b6e1fc82c2a5703c7513a2612f7342051",
3
+ "apiLevel": 8,
4
4
  "packages": {
5
5
  "@0dep/piso": "5.2.0",
6
6
  "@agentclientprotocol/sdk": "2.6.0",
7
- "@coda-console/protocol": "6.17.0",
7
+ "@coda-console/protocol": "6.18.0",
8
8
  "ajv": "8.20.0",
9
9
  "yaml": "2.9.1"
10
10
  },
11
11
  "files": {
12
- "check/coda/application/contributions.mjs": "861c363d06cdabfc4ce15435126fbc7ad7dafd3c93ca2ad9e9534a6f5a237942",
13
- "check/coda/application/host-protocols.mjs": "1153b5e35f59ab04bef50dc4cecbca4fb2326096eb556978dd7d51736611e970",
12
+ "check/coda/application/contributions.mjs": "30fb6eb01a4a26cc34df79655818a15aa6e846f34128752ca3c7a892939179da",
14
13
  "check/coda/components/protocols/protocol-events.mjs": "076f335287d0398c602ad6db286ab0001dc00ac42d32a23918a66ee37c3e9a2f",
15
- "check/coda/components/protocols/record-rules.mjs": "c6bbafdaa869543ea4759be526ca8cf1ff5a03dad999f6ad724a602703c92a44",
14
+ "check/coda/components/protocols/record-rules.mjs": "9b3b8f4307a77f9beb658e62c11c9e8fa39ec6b3cc93516e845e7083e303df44",
16
15
  "check/coda/components/protocols/types.mjs": "283cd0f4516f10637d6fe257fe645ead87912219d471c06408d56617f244e1d1",
17
16
  "check/coda/adapters/provider-api.mjs": "70441ea2a417ede13e04113ec254496883be3186f291ef5ee65834f35009eb9e",
18
17
  "check/coda/adapters/call-limit.mjs": "7e86d95ff7b0a88955015904ec91ae55e78fad816d06f710d6e62af53ccbdeab",
19
18
  "check/coda/adapters/clock.mjs": "79733b9ac3807b3da147fe8b782318a1cb42d1d51b9c8b81a507c13c7a8025fd",
20
19
  "check/coda/adapters/plugin-command.mjs": "47bd580f7142780933315f64d4562d23a61f996b3f411cfb583333261b590ee8",
21
- "check/coda/adapters/plugin-events.mjs": "5b6b98063a2a2f3d112908ad9fdc08119ec1bd577ca765811799ef6d1030dfe4",
22
- "check/coda/adapters/plugin-modules.mjs": "9a86b356897864a9f0dabc5ec73deaf0c54e4913e538cd5f759f4a1959213cc9",
20
+ "check/coda/adapters/plugin-events.mjs": "4435aabd04b072069bf8af58663c81130b42821faf4905133fbf523bc64f9f6d",
21
+ "check/coda/adapters/plugin-modules.mjs": "0ae151faa26c5682ace16c36d42c32f02986e16b15674a55dbadefd79766aa63",
22
+ "check/coda/adapters/plugin-setup-api.mjs": "82239b1572de05367c134c9a9f0491fa8cc54a56655dcc7b0e346227e0a900b1",
23
23
  "check/coda/adapters/plugin-stream-services.mjs": "1e92eb3dd9d844d4f2773a60bc2941aae3c9cda10d9e96e31de9f09f51e672e5",
24
- "check/coda/adapters/plugin-test-host.d.mts": "c86b3244f3f5d58fe5f25b50c2e7bd00983d72b841ca4a978f10d4dfa6ceae87",
25
- "check/coda/adapters/plugin-test-host.mjs": "7c8e5ee46792181bfd3b2f4d67d1ac6844c64c2af678655308cfdeb5ecf84c42",
24
+ "check/coda/adapters/plugin-test-host.d.mts": "7cb271a61cdb8f704e21e003e70d9962308aeecc4f95ec1ff3bf92cdf134b6be",
25
+ "check/coda/adapters/plugin-test-host.mjs": "6cebdef12df571ad8bbd340844deeeb12e1a44af443c6038b43573944883334d",
26
26
  "check/coda/adapters/process-relay.mjs": "5d379bd7ad07138d69c7accbe769d71294843399539bdf1fab8b6a1ddf13b9d8",
27
27
  "check/coda/components/composers/contributions.mjs": "43d3e15fb1f63b7b5c20716030d9537613809ed5cc2fb466a3678bfa308f9f92",
28
28
  "check/coda/components/concurrency-groups/schemas.mjs": "3c422044c637dee10565fb1b8bdc75b9c6a31e3b600ed223b7e5e345e1baf092",
29
29
  "check/coda/components/composers/schemas.mjs": "31656d6534fbfcb1e325bc551aefad4abbb867325872acea1ce9274eb9787c23",
30
- "check/coda/components/plugins/contribution-points.mjs": "2dade9fe4f3fa2b4e89f49a1ac4378ab2621e5ac542eb175967091f04568b45c",
31
- "check/coda/components/plugins/git-contributions.mjs": "532917cd3ec45e12535e9e6c206ae14fa598bebc789ab0c8f15609d1699fa1cd",
30
+ "check/coda/components/plugins/contribution-points.mjs": "914b902f9c9b882584a2db7a55c30fa486f5d0b1319f799c130d47555613ff32",
31
+ "check/coda/components/plugins/git-contributions.mjs": "5f10cf079a63343c130702d368c550d533784b439fe7e58d31bb33b77807906b",
32
32
  "check/coda/components/plugins/model-contributions.mjs": "018a7157954b2326887ba1a780b37d3beb33338e41a28936b313562c2939d563",
33
- "check/coda/components/plugins/plugin-extensions.mjs": "31ce03ceec14ef36cb5db5a197e444567286de43a2162eec3af7d005697daa63",
33
+ "check/coda/components/plugins/plugin-extensions.mjs": "3f679c737892c33af748e4fc6263647b3c16231ece9e24554db994bac0a5e7f2",
34
34
  "check/coda/components/plugins/plugin-icons.mjs": "ec29cadce4948ecacabfe911a2ceb45414b96e28971358acbc4e952bedc78e1a",
35
- "check/coda/components/plugins/plugin-rules.mjs": "546785b38813791ea6cd423952178d880524184cc782003bba7f3387787c1fd5",
36
- "check/coda/components/plugins/plugin-source-rules.mjs": "2ed213f001929a54b05237e7bce4bf561f20068f552234ef74648c1ec53e3d09",
35
+ "check/coda/components/plugins/plugin-rules.mjs": "4c1eb1c0f2c851e36ddaddbf432a61bf3a28e9ca3dd771553ed629af64246867",
36
+ "check/coda/components/plugins/plugin-source-rules.mjs": "1fc9302f3a3d42f06964555e9b5bec868f5317cfce850baa5435bb88d50511d9",
37
37
  "check/coda/components/plugins/process-contributions.mjs": "6d39a904f52956b87c04351398f79a4fc34981fa01453195bd7a3b9f2c5d237b",
38
+ "check/coda/components/plugins/self-contributions.mjs": "d6e072fddb9b59d753c397c8cb90bb2f66079695415871d2b56ac0c14f702c19",
38
39
  "check/coda/components/plugins/skill-document.mjs": "153ad3c096c7c9b7774bcf7dcc0ba603c962ee1ac8697c8a71e3f2c9ba9c92e6",
39
40
  "check/coda/components/prompt-recovery/prompt-recovery.mjs": "25477742af8a9134ae343af6ab702926692bdd8dd07844f3cba47e8b702c0e49",
40
41
  "check/coda/components/session-config/commands.mjs": "5276f81fc430a6eef7d7a0dbdecfffdb4a77f8c192cb0238ed73b7722641ce17",
41
42
  "check/coda/components/session-config/contributions.mjs": "74d52d65dc7b6f13ef301a211bdf50cc91ae468c462cbe201f5dc34f7437b97b",
42
43
  "check/coda/components/workflows/contributions.mjs": "f16e36e5e591d7ab6c6e63f252e780717ba17bb4642aedd2797c5ff017df9d95",
43
- "check/coda/components/workflows/workflow-protocol-definitions.mjs": "094ab1b2676f05fa88eb7ccd558b4eb4dce609fdf412f7663f84906ac2732186",
44
- "check/coda/domain/accord.mjs": "35cb6c2f918433b72aa44996efe2212d9b9c4ea807858d80947c8aa089b85fa2",
45
44
  "check/coda/domain/agent-protocol.mjs": "f1d7c939c240664b773c04d9a1c1e9457cc8396fd8f99f1d5b6b6964150843c0",
46
45
  "check/coda/domain/duration.mjs": "3f07411812362adcacfc288b1513f10e7d0ea1addcdc1b47ae553561f1d3430b",
47
46
  "check/coda/domain/errors.mjs": "15ad3348ea0e173a1a8602ec72766592cb41c0221420d9e5884bd68090ecc84b",
48
- "check/coda/domain/jcs.mjs": "2f1074ac2dd23d397567c01c7a7107ad3607bad6995a8a5c9115a6705a015afe",
49
47
  "check/coda/domain/resume-prompt.mjs": "9895ccf235808b9bf3f4836999c65ddd6d764fcaa6e8a9a9647612faf0c9629a",
50
48
  "check/coda/domain/plugin-services.mjs": "940a72a14da980188a32c790c7f341d3ec0062a6e87ef1ebc9ef051798ea0a75",
51
49
  "check/coda/domain/session-env.mjs": "283bbc2e8ae9ea22b53747865a651a4dac9c6cfc242f27612e0c82e6e9cc151a",
52
- "check/coda/domain/usage.mjs": "9077cfb738016fed72e4fb43f415aab258bdfa213e466740f2c0535dbba45ed3",
53
50
  "check/coda/domain/values.mjs": "afb8bf30e374bed27fe41ee4b6d8c3c0b4dbe1dcfb6b62dad9d3d53b966706a1",
54
- "check/coda/kernel/accord-protocol.mjs": "f9a5c59f9b278f0ceebb9c1c5f6c2b49be0300ce3bde04e46dcf1c10acf2f0ac",
55
51
  "check/coda/kernel/agent-failures.mjs": "cbc215e2403d86f0acc765c2077197e0b529fc01e213db465c388361238ea8ce",
56
- "check/coda/kernel/plugin-protocol.mjs": "c514f9b6237404f8877dea568e4d425f1e380c19f3cb87764edf56f6c92ebd69",
57
- "check/coda/kernel/project-protocol.mjs": "69874b2b226f111b156724454c968e829018f1caac0a02883f13e1f980482739",
58
- "check/coda/kernel/thread-protocol.mjs": "58bbd66c0058552f26c1b4ed08231e9afd142f2b7a9f50ed6bd66cbfe8f579e1",
59
- "check/coda/kernel/usage-protocol.mjs": "4bd07a4d4c63c75e5328ef7e907bfa4e83af430f7f04a08cf8eb883a23ddc51f",
60
- "check/coda/builtin.json": "a69fb8a1978b7cdb602f76cfae487e9b683026cf5c35a92c83fdd1b23b4eec83",
61
- "check/coda/api-surface.txt": "7b21d96b9ccb36cf6dbbc04904ceb39299acc4e05488815297660b1e1c5caca3"
52
+ "check/coda/builtin.json": "9ac25bb0c6b01dc6f7aa46cc00378e9c0123e72e8048975329aac703bcea71b5",
53
+ "check/coda/api-surface.txt": "2038b8f2b7b262443af3ffc32a9d9366a3cf39f327e30c9b553a761b0840d6cf"
62
54
  }
63
55
  }
@@ -9,13 +9,18 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
9
9
  import { dirname, join } from 'node:path';
10
10
  import { inflateSync } from 'node:zlib';
11
11
  import './coda/application/contributions.mjs';
12
- import { HOST_PROTOCOLS } from './coda/application/host-protocols.mjs';
12
+ import { composerType, submissionType } from './coda/components/composers/schemas.mjs';
13
+ import { groupType } from './coda/components/concurrency-groups/schemas.mjs';
13
14
  import shipped from './coda/builtin.json' with { type: 'json' };
14
15
  import { CORE_PROTOCOLS } from '@coda-console/protocol/protocol';
15
16
  import { manifestProblem } from '@coda-console/protocol/validate';
16
- import { offerProblem, ownIncompatibility, protocolDefinition, usesMissing } from './coda/components/plugins/plugin-extensions.mjs';
17
+ import { ownIncompatibility, protocolDefinition, usesMissing } from './coda/components/plugins/plugin-extensions.mjs';
17
18
  import { choosesModelProviders, pluginEnv, readPlugin, resolveSettings } from './coda/components/plugins/plugin-rules.mjs';
18
19
 
20
+ // Coda's own protocols, the definitions that are in the copy of its contract (check/coda): a composer's, its submission's and a
21
+ // group's. The rest it defines are in the protocol package (CORE_PROTOCOLS) or not here, and a definition not here is only said.
22
+ const HOST_PROTOCOLS = [composerType, submissionType, groupType];
23
+
19
24
  // The plugins Coda ships, by ID. Their files are Coda's, not here: none has a directory on this machine.
20
25
  const builtin = new Map(shipped.map(plugin => [plugin.id, { ...plugin, dir: undefined }]));
21
26
  // Those it installs from the start, as rows without a source (components/plugins/plugins.mjs).
@@ -104,17 +109,14 @@ export function checkManifest(dir, say) {
104
109
  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)出图`);
105
110
  }
106
111
  });
107
- // What it writes for other plugins' points (Coda's own keys aside) is of the types they declare: one no plugin Coda ships, and
108
- // none it depends on beside it (directly or through another), declares is of no type.
112
+ // The plugins it depends on, directly or through another, found beside it.
109
113
  const found = besideAll(dir, plugin.dependencies);
110
- const offered = offerProblem(plugin, new Map([...builtin, ...found]));
111
- if (offered) say.fail('manifest.offers', offered);
112
114
  // The events its own protocols define (protocol definitions' `events`), and the permission groups of protocols it uses (`uses`; a
113
115
  // group with `events` is subscribing to all of them), as far as the protocols are here: its own, Coda's core, or a plugin's beside it.
114
116
  for (const definition of plugin.protocols ?? [])
115
117
  for (const [name, event] of Object.entries(definition.events ?? {})) say.pass('manifest.events', `协议 ${definition.name} 定义的事件 ${name}:starts ${event.starts ?? true},ends ${event.ends ?? false}`);
116
118
  const protocols = new Map([...builtin, ...found, [plugin.id, plugin]]);
117
- // Coda's own protocols, as Coda judges a plugin's `uses` against them (application/host-protocols.mjs).
119
+ // Coda's own protocols, as Coda judges a plugin's `uses` against them (HOST_PROTOCOLS above).
118
120
  const hosted = kind => HOST_PROTOCOLS.find(one => one.kind === kind);
119
121
  for (const [kind, groups] of Object.entries(plugin.uses ?? {})) {
120
122
  const definition = protocolDefinition(kind, protocols, hosted);
@@ -131,7 +133,7 @@ export function checkManifest(dir, say) {
131
133
  else say.pass('manifest.events', `用到 ${kind} 的权限组 ${group}:不含事件`);
132
134
  }
133
135
  }
134
- // The keys of `contributes` Coda retired (`resources`, `panels`): a manifest still writing one is one Coda calls for an update
136
+ // The keys of `contributes` Coda retired (the list in check/coda/components/plugins/plugin-extensions.mjs, as it is): a manifest still writing one is one Coda calls for an update
135
137
  // (ownIncompatibility, of the retired keys alone: the Level and the channel are another level's and the installing machine's).
136
138
  const retired = ownIncompatibility({ retired: plugin.retired }, {});
137
139
  if (retired) say.fail('manifest.retired', retired.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.8.28",
3
+ "version": "0.8.30",
4
4
  "description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读资源记录。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@0dep/piso": "5.2.0",
32
32
  "@agentclientprotocol/sdk": "2.6.0",
33
- "@coda-console/protocol": "6.17.0",
33
+ "@coda-console/protocol": "6.18.0",
34
34
  "ajv": "8.20.0",
35
35
  "yaml": "2.9.1"
36
36
  },
@@ -13,25 +13,18 @@ export async function activate(coda) {
13
13
  return { seen, notes: entries.filter(entry => String(entry.spec.title).includes(query)).map(entry => ({ key: String(entry.key), title: String(entry.spec.title) })) };
14
14
  });
15
15
 
16
- // A doing call: the input's limits (the schema) refuse what cannot be written before anything is. Once the note is saved the call
17
- // does not fail: if note_notes.added cannot be published, it says so (`notified`), for the note is there. Each call publishes one.
16
+ // A doing call: the input's limits (the schema) refuse what cannot be written before anything is; the note is saved, same title, same note.
18
17
  coda.handle(NOTE, 'add', async input => {
19
- const { title, body, project } = /** @type {{ title: string, body: string, project: string }} */ (input);
20
- const entry = await coda.put({ kind: NOTE, key: title }, { spec: { title, body } });
21
- /** @type {Json} */
22
- let result = { key: title, notified: true };
23
- try {
24
- await coda.emit('note_notes.added', { key: title, title, body }, { subject: `note:${entry.id}`, project });
25
- } catch (e) {
26
- result = { key: title, notified: false, reason: String(e) };
27
- }
28
- return result;
18
+ const { title, body } = /** @type {{ title: string, body: string }} */ (input);
19
+ await coda.put({ kind: NOTE, key: title }, { spec: { title, body } });
20
+ return { key: title };
29
21
  });
30
22
 
31
23
  // The welcome note, only while there are no notes: `replace` gives every record of the kind whole, so it would wipe the others.
32
24
  if (!(await coda.list(NOTE, { scope: 'local' })).length)
33
25
  await coda.replace(NOTE, [{ key: '欢迎', spec: { title: '欢迎', body: '这是模板自带的一条便条。' } }]);
34
26
 
35
- // The event group `watch` of the protocol, in `uses`: it only reads the events.
27
+ // The event group `watch` of the protocol, in `uses`: it only reads the events. A module does not publish events: the command
28
+ // line (`coda event`) and a workflow's `publish-event` action do, and this is told of each.
36
29
  coda.on('note_notes.added', () => { seen++; });
37
30
  }