@coda-console/plugin-check 0.5.12 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/check/coda/components/plugins/agent-plugins.mjs +1 -1
- package/check/coda/components/plugins/plugin-rules.mjs +2 -2
- package/check/coda/components/session-config/commands.mjs +1 -1
- package/check/coda/contract.json +7 -34
- package/check/coda/domain/agent-protocol.mjs +1 -1
- package/check/manifest.mjs +3 -4
- package/package.json +2 -1
- package/check/coda/components/plugins/plugin-schema.mjs +0 -177
- package/check/coda/components/plugins/schemas/agents.json +0 -50
- package/check/coda/components/plugins/schemas/capabilities.json +0 -16
- package/check/coda/components/plugins/schemas/commands.json +0 -21
- package/check/coda/components/plugins/schemas/common.json +0 -25
- package/check/coda/components/plugins/schemas/composer-modes.json +0 -79
- package/check/coda/components/plugins/schemas/configuration.json +0 -23
- package/check/coda/components/plugins/schemas/endpoints.json +0 -19
- package/check/coda/components/plugins/schemas/environment.json +0 -22
- package/check/coda/components/plugins/schemas/events.json +0 -23
- package/check/coda/components/plugins/schemas/executors.json +0 -26
- package/check/coda/components/plugins/schemas/extension-points.json +0 -57
- package/check/coda/components/plugins/schemas/extensions.json +0 -13
- package/check/coda/components/plugins/schemas/git-credentials.json +0 -17
- package/check/coda/components/plugins/schemas/groups.json +0 -21
- package/check/coda/components/plugins/schemas/instructions.json +0 -9
- package/check/coda/components/plugins/schemas/mcp-servers.json +0 -29
- package/check/coda/components/plugins/schemas/model-providers.json +0 -39
- package/check/coda/components/plugins/schemas/path.json +0 -16
- package/check/coda/components/plugins/schemas/plugin.json +0 -46
- package/check/coda/components/plugins/schemas/repositories.json +0 -7
- package/check/coda/components/plugins/schemas/services.json +0 -9
- package/check/coda/components/plugins/schemas/setting.json +0 -242
- package/check/coda/components/plugins/schemas/setup.json +0 -7
- package/check/coda/components/plugins/schemas/skills.json +0 -15
- package/check/coda/components/plugins/schemas/views.json +0 -30
package/README.md
CHANGED
|
@@ -400,7 +400,7 @@ gh workflow run publish.yml --repo coda-console/coda-plugins --ref main
|
|
|
400
400
|
## 契约检查
|
|
401
401
|
|
|
402
402
|
扮演 Coda 去读一个插件目录:清单对 Coda 的类型 schema 校验,Agent 照 Coda 的样子启动、说 Coda 说的话,面板由 Coda 的资源插件模块读一次。
|
|
403
|
-
|
|
403
|
+
插件写的合乎它用到的类型就对:清单的写法只在协议包 `@coda-console/protocol`([coda-console/coda-protocol](https://github.com/coda-console/coda-protocol))的 schema 里,由 Coda 自己用的同一个校验器判,
|
|
404
404
|
检查包不另写规则,Coda 加字段只是改 schema。`check/coda/` 是 Coda 文件的原样副本(见[契约副本](#契约副本)),检查包手写的只有怎样扮演 Coda、怎样判。
|
|
405
405
|
只在装到一台机器上才知道的(仓库里扫不扫得到、npm 锁文件、和那台已装插件冲突)是那台 Coda 安装时说的,不是插件类型的问题,检查不跑。
|
|
406
406
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The agents a plugin brings (docs/plugins.md「Agent」, schemas/agents.json): who each is, how the clients draw it, and how
|
|
2
|
-
// Coda starts its process, which speaks ACP with Coda's waits (docs/agent-protocol.md). Nothing here knows any agent by
|
|
2
|
+
// Coda starts its process, which speaks ACP with Coda's waits (coda-protocol docs/agent-protocol.md). Nothing here knows any agent by
|
|
3
3
|
// name: Codex and Claude are plugins like any other.
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
5
|
import { isAbsolute, join, normalize } from 'node:path';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Plugins (docs/plugins.md): what Coda installs once for every project, the way VS Code installs an extension. A plugin
|
|
2
2
|
// is a directory with a VS Code style `package.json`, and the workflows it brings in `.coda/workflows/`. What it may write
|
|
3
|
-
// there is the
|
|
3
|
+
// there is the protocol's to say (@coda-console/protocol, coda-console/coda-protocol): each key of `contributes` is a type with a JSON Schema of its
|
|
4
4
|
// own, and a manifest is right when it is of the types it names. This module reads one that is into what Coda keeps of it:
|
|
5
5
|
// its settings (`contributes.configuration`, declared in JSON Schema), with a value for every project (the plugin's
|
|
6
6
|
// settings) that a project may override, as user and workspace settings do in VS Code, which workflows read as `vars`
|
|
@@ -18,7 +18,7 @@ import { isDuration } from '../../domain/duration.mjs';
|
|
|
18
18
|
import { AGENT_ID } from '../../domain/values.mjs';
|
|
19
19
|
import { agentDeclarations } from './agent-plugins.mjs';
|
|
20
20
|
import { checkCatalog, extensionsFor } from './plugin-extensions.mjs';
|
|
21
|
-
import { manifestProblem, TYPES, valueProblem } from '
|
|
21
|
+
import { manifestProblem, TYPES, valueProblem } from '@coda-console/protocol/validate';
|
|
22
22
|
import { claims, COMMIT, INTEGRITY, NPM_VERSION, npmPluginId, repoAddress, sourcePath } from './plugin-source-rules.mjs';
|
|
23
23
|
import { readSkillDocument } from './skill-document.mjs';
|
|
24
24
|
import { executorLabels } from '../workflows/executor-labels.mjs';
|
|
@@ -2,7 +2,7 @@ import { requireCondition as check } from '../../domain/errors.mjs';
|
|
|
2
2
|
import { AGENT_ID, keys, object, text } from '../../domain/values.mjs';
|
|
3
3
|
|
|
4
4
|
// What a session runs with: its model, effort and mode, and the agent's other config options by their ID (`options`: a
|
|
5
|
-
// choice's ID, or on and off for a switch), as the agent's catalog offers them (docs/agent-protocol.md「ACP 部分」).
|
|
5
|
+
// choice's ID, or on and off for a switch), as the agent's catalog offers them (coda-protocol docs/agent-protocol.md「ACP 部分」).
|
|
6
6
|
// Absence means resolve the adapter default. Actual values belong to Turn.
|
|
7
7
|
export const OPTIONS_LIMIT = 20;
|
|
8
8
|
export function configOptions(value) {
|
package/check/coda/contract.json
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
2
|
+
"commit": "93a0168dc6cb61a169b271da34db1e57d6b5549f",
|
|
3
3
|
"packages": {
|
|
4
4
|
"@0dep/piso": "5.2.0",
|
|
5
5
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
6
|
-
"
|
|
6
|
+
"@coda-console/protocol": "1.0.0",
|
|
7
7
|
"yaml": "2.9.1"
|
|
8
8
|
},
|
|
9
9
|
"files": {
|
|
10
|
-
"check/coda/components/plugins/agent-plugins.mjs": "
|
|
10
|
+
"check/coda/components/plugins/agent-plugins.mjs": "e4b05f8c5601d812eba278bed21e0fee13ce6760c812162c76f1ab253cdd4e4f",
|
|
11
11
|
"check/coda/components/plugins/plugin-extensions.mjs": "a1e8810296fd64d0e7792f1d987bd6ea6f71d1aa5d52a225f4a14eb6681f2758",
|
|
12
|
-
"check/coda/components/plugins/plugin-rules.mjs": "
|
|
13
|
-
"check/coda/components/plugins/plugin-schema.mjs": "ce71d81cff6d5b0ec53dcd9fa148672b1ece2db1d4a9bf9e4b1b35d485aed691",
|
|
12
|
+
"check/coda/components/plugins/plugin-rules.mjs": "3cf99e6aaf688ad496dae00a47768fe118d204cf17f2fed490344bfababc27c9",
|
|
14
13
|
"check/coda/components/plugins/plugin-source-rules.mjs": "4eedfd024c0824b1fed78be106f1a2827ffc3dd35ac0c69b8b0c61a59af42efd",
|
|
15
14
|
"check/coda/components/plugins/skill-document.mjs": "c5b5e815c42cd836572f7b60e22a46af6ac607fd9df0170fa36f955825636ce6",
|
|
16
15
|
"check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
|
|
17
|
-
"check/coda/components/session-config/commands.mjs": "
|
|
16
|
+
"check/coda/components/session-config/commands.mjs": "be07377c153f812a648deb60f023269c1f0a49b91cf2e4516f05b7eac09c28de",
|
|
18
17
|
"check/coda/components/workflows/executor-labels.mjs": "dceca6ae60c0a4f3c3cc72a6c84f1489831790774c93caab96e4ddb493bc89e1",
|
|
19
|
-
"check/coda/domain/agent-protocol.mjs": "
|
|
18
|
+
"check/coda/domain/agent-protocol.mjs": "09243f47df4112d6484b05d6baeb646d9b511b5e21ee58a3f65803b177d5232e",
|
|
20
19
|
"check/coda/domain/duration.mjs": "15dd64ef9b02342ad521c66e5968a569432a89dc7568d11afd3e6f3fe37e104b",
|
|
21
20
|
"check/coda/domain/errors.mjs": "ddc00aef9bb6f9a56845a9926c82200628a906230d31212d88fcde48e36dfd36",
|
|
22
21
|
"check/coda/domain/values.mjs": "01cc72b8d9c09e3fe16c93ec332ca01148bba859b1c672586d9d07444d7816c4",
|
|
@@ -25,32 +24,6 @@
|
|
|
25
24
|
"check/coda/resources/plugins/resources/panels/panels.mjs": "aee040febb37fd6eebaf1a1da5b3299d2b6a9dfc982e649d9a628291af298179",
|
|
26
25
|
"check/coda/resources/plugins/resources/panels/rules.mjs": "c024c5ede7c1516877128aa6d6796fbe5fd0e14642741b0745481bb1c5ca41d3",
|
|
27
26
|
"check/coda/resources/plugins/resources/panels/sign-in.mjs": "1271a24e33b1b882a1fb9bee03b8e240db8b9bee1b5208f0e1c84499cfb1be7e",
|
|
28
|
-
"check/coda/
|
|
29
|
-
"check/coda/components/plugins/schemas/capabilities.json": "e5cb7ca58e12fa9778e015d2cdcd58d96fff8464314c73a950208a1f2a19f6d6",
|
|
30
|
-
"check/coda/components/plugins/schemas/commands.json": "bd520205842e0c7b987f962943898b16e52bf9cb05ddfaf09e34fb99e5b467d6",
|
|
31
|
-
"check/coda/components/plugins/schemas/common.json": "b6781559e4db07fab095d0a171b73f32277aa56ef048f70a4216e94b41c681f3",
|
|
32
|
-
"check/coda/components/plugins/schemas/composer-modes.json": "69d4a97cc330c50052bda104ae623375d79f785b6097e806fc9dbd73bceb5429",
|
|
33
|
-
"check/coda/components/plugins/schemas/configuration.json": "b5ad5e294da0f2282a6b6f051b4e6d5b6bb6fb9e1c737ecd399e2ff1d4baa297",
|
|
34
|
-
"check/coda/components/plugins/schemas/endpoints.json": "20fd2ce0ff4130b537b1b5b87749c8a4462ebd2e28498b4fe78050f39241a2cd",
|
|
35
|
-
"check/coda/components/plugins/schemas/environment.json": "a17b697adff32d0099bf9c93de99363cc7a8450964d2f7a91dddace3ec640e2e",
|
|
36
|
-
"check/coda/components/plugins/schemas/events.json": "d0da29f2b82a24249ca7de944c109a0a849adce3045797b431b47115d662ee7b",
|
|
37
|
-
"check/coda/components/plugins/schemas/executors.json": "30a3134020dabcafbdc5e1b2aa8b907bdfd74d6bac36c408a520bcf2a2d87897",
|
|
38
|
-
"check/coda/components/plugins/schemas/extension-points.json": "01b5fa12aac0de9ef526d8c76281abd4ec4b4ab5bf3c362f144e13eefb4b5cf8",
|
|
39
|
-
"check/coda/components/plugins/schemas/extensions.json": "62c9db6de8199e84f653a7dce404e4f0d6923ae7954347fc8fedc3f8ca69391a",
|
|
40
|
-
"check/coda/components/plugins/schemas/git-credentials.json": "24e98fd31cc0f9f48be928c4792de9bed00b2b1b1f01963a67d6b600ac2fd432",
|
|
41
|
-
"check/coda/components/plugins/schemas/groups.json": "d7b6de75213849846b2e38ef89865e2d33bf41f617c418ee0496d0a425d7c421",
|
|
42
|
-
"check/coda/components/plugins/schemas/instructions.json": "c4c82b29e641a4f68b64b25e2e2bc578f0dbedf35030f1980ce539885517906d",
|
|
43
|
-
"check/coda/components/plugins/schemas/mcp-servers.json": "e395b3ef7ce93ffaa4e7591065de14bc755d8a6e11a605a0318537383a4ed79a",
|
|
44
|
-
"check/coda/components/plugins/schemas/model-providers.json": "2022568128887be53609cff03f6ae1e8f129c1b963709ddfd087814088161ceb",
|
|
45
|
-
"check/coda/components/plugins/schemas/path.json": "12cefad92473711607ea502d05934fb5548c7d900455667017df405cfce2a52e",
|
|
46
|
-
"check/coda/components/plugins/schemas/plugin.json": "453d2fb32a24a995f787f436ef44a77ea2e0a4043d105e5552515d0b32c06354",
|
|
47
|
-
"check/coda/components/plugins/schemas/repositories.json": "a4b5a4cc0367dad92e2f5879a609cfcfb85c2072c2ff2293284d12b976b1c72b",
|
|
48
|
-
"check/coda/components/plugins/schemas/services.json": "a39ce23c985912580dab13df795b3f64d96f5dc0efcba039945c67962cef9973",
|
|
49
|
-
"check/coda/components/plugins/schemas/setting.json": "16e768eefc4402658adb7056c8830a236368e4933509d8c9b5419bbdb8d499bc",
|
|
50
|
-
"check/coda/components/plugins/schemas/setup.json": "b6c78841e9fcd84ec171d8d76da92ff1a70d979f2d0212bb2fd5dceffe9e5535",
|
|
51
|
-
"check/coda/components/plugins/schemas/skills.json": "4b9c8dea5419319481eeb89d503e20390a933052a997a334e2b7568230722791",
|
|
52
|
-
"check/coda/components/plugins/schemas/views.json": "d9db0019d32e05d026292f6a8e0f16158b1ebe148b2c6ede6b52d54207b88fb5",
|
|
53
|
-
"check/coda/builtin.json": "d1865fad1440a62341188458578cf95e1afc5528229ff8a97c2a727ce7985b67",
|
|
54
|
-
"docs/agent-protocol.md": "643482a77eed0978b4f366b604bff87ddb41541c08da1df919811da26e7c0024"
|
|
27
|
+
"check/coda/builtin.json": "d1865fad1440a62341188458578cf95e1afc5528229ff8a97c2a727ce7985b67"
|
|
55
28
|
}
|
|
56
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// What Coda says to an agent and takes from it beside the connection itself (docs/agent-protocol.md): the capabilities it
|
|
1
|
+
// What Coda says to an agent and takes from it beside the connection itself (coda-protocol docs/agent-protocol.md): the capabilities it
|
|
2
2
|
// sends, session instructions, steering, the agent's own waits, and how long Coda waits on it. Part of the plugin contract
|
|
3
3
|
// coda-plugins' check is given as written (scripts/plugin-contract.mjs).
|
|
4
4
|
|
package/check/manifest.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
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 (
|
|
3
|
-
//
|
|
4
|
-
// ID, and its settings named under it. What Coda says only where it installs one — the repository it comes from, its npm
|
|
2
|
+
// package.json is checked against the schemas of Coda's types (the protocol, @coda-console/protocol) by the checker Coda runs
|
|
3
|
+
// itself, and then read as Coda reads it: its ID, and its settings named under it. What Coda says only where it installs one — the repository it comes from, its npm
|
|
5
4
|
// 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
5
|
// does not run it. The plugins Coda ships (check/coda/builtin.json) and those beside this one in its directory's parent
|
|
7
6
|
// stand in for what it depends on, for the levels after this one.
|
|
@@ -9,7 +8,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
|
9
8
|
import { dirname, join } from 'node:path';
|
|
10
9
|
import { inflateSync } from 'node:zlib';
|
|
11
10
|
import shipped from './coda/builtin.json' with { type: 'json' };
|
|
12
|
-
import { manifestProblem } from '
|
|
11
|
+
import { manifestProblem } from '@coda-console/protocol/validate';
|
|
13
12
|
import { offerProblem } from './coda/components/plugins/plugin-extensions.mjs';
|
|
14
13
|
import { choosesModelProviders, pluginEnv, readPlugin, resolveSettings } from './coda/components/plugins/plugin-rules.mjs';
|
|
15
14
|
import { panelEntries } from './coda/resources/plugins/resources/panels/rules.mjs';
|
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.14",
|
|
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
|
+
"@coda-console/protocol": "1.0.0",
|
|
27
28
|
"ajv": "8.20.0",
|
|
28
29
|
"yaml": "2.9.1"
|
|
29
30
|
},
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// A plugin is right when what it writes is of the types it names (#1917「第一步」): each key of a manifest's `contributes` is a
|
|
2
|
-
// type with a JSON Schema of its own (schemas/, `https://coda.pub/schemas/plugin/v1/…`), and a key that is no type of Coda's
|
|
3
|
-
// is one a plugin's extension point declares, for that plugin to read. Checking one is checking it against those schemas,
|
|
4
|
-
// nothing else: a field joins a type by joining its schema, never by a rule here.
|
|
5
|
-
// What JSON Schema cannot say of one value alone it says with five keywords, each meaning one thing wherever it is written,
|
|
6
|
-
// as Kubernetes extends its OpenAPI with `x-kubernetes-*`:
|
|
7
|
-
// - `x-unique-by`: [name or { part }] — in an array, each named property of its objects is unique among the items having it,
|
|
8
|
-
// and so is `part`'s first group of each of its texts (a directory's last name);
|
|
9
|
-
// - `x-max-contains`: { match, max } — of an object's values, at most `max` satisfy `match` (`maxContains` of an object);
|
|
10
|
-
// - `x-ref`: { pointer, part?, match? } — the value (or `part`'s first group of it) names a key of the object, or an element
|
|
11
|
-
// of the array, at `pointer` in the manifest: absolute (`/contributes/configuration/properties`), or relative to the value
|
|
12
|
-
// (`2/properties`: two levels up, then down); what it names satisfies `match` when that is given;
|
|
13
|
-
// - `x-placeholders`: { names?, config? } — every `${…}` in the text is one of `names`, or `config:<setting>` naming one of
|
|
14
|
-
// the plugin's settings that satisfies `config`;
|
|
15
|
-
// - `x-file`: { type, under?, suffix?, contains?, maxBytes?, magic?, absent? } — the value is a path in the plugin's directory
|
|
16
|
-
// (with `under` before it and `suffix` after it) that never leaves it, of that type, holding `contains`, at most
|
|
17
|
-
// `maxBytes` long, starting with `magic`; with `absent`, a path there is none at. Checked when the directory is known.
|
|
18
|
-
// This module and schemas/ are all coda-plugins' contract check runs of a manifest: they import nothing but Node and Ajv.
|
|
19
|
-
import { closeSync, openSync, readdirSync, readFileSync, readSync, statSync } from 'node:fs';
|
|
20
|
-
import { isAbsolute, join, normalize, sep } from 'node:path';
|
|
21
|
-
import { fileURLToPath } from 'node:url';
|
|
22
|
-
import Ajv2020 from 'ajv/dist/2020.js';
|
|
23
|
-
|
|
24
|
-
export const SCHEMA_DIR = fileURLToPath(new URL('./schemas/', import.meta.url));
|
|
25
|
-
const BASE = 'https://coda.pub/schemas/plugin/v1/';
|
|
26
|
-
// The schemas, by file name.
|
|
27
|
-
export const SCHEMAS = Object.fromEntries(readdirSync(SCHEMA_DIR).filter(file => file.endsWith('.json')).sort()
|
|
28
|
-
.map(file => [file, JSON.parse(readFileSync(join(SCHEMA_DIR, file), 'utf8'))]));
|
|
29
|
-
// The types a plugin may contribute to Coda itself, as the manifest's schema names them.
|
|
30
|
-
export const TYPES = Object.keys(SCHEMAS['plugin.json'].properties.contributes.properties);
|
|
31
|
-
|
|
32
|
-
// What a pointer names, from where a keyword is: the manifest's root, or levels up from the value itself.
|
|
33
|
-
function locate(pointer, { rootData, instancePath }) {
|
|
34
|
-
const relative = /^(\d+)(.*)$/.exec(pointer);
|
|
35
|
-
const up = relative ? Number(relative[1]) : 0, rest = relative ? relative[2] : pointer;
|
|
36
|
-
const here = instancePath.split('/').slice(1).map(unescape);
|
|
37
|
-
if (up > here.length) return undefined;
|
|
38
|
-
const steps = [...(relative ? here.slice(0, here.length - up) : []), ...rest.split('/').slice(1).map(unescape)];
|
|
39
|
-
return steps.reduce((at, step) => at !== null && typeof at === 'object' && Object.hasOwn(at, step) ? at[step] : undefined, rootData);
|
|
40
|
-
}
|
|
41
|
-
const unescape = step => step.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
42
|
-
const fail = (validate, keyword, message, parentSchema) => { validate.errors = [{ keyword, message, params: {}, parentSchema }]; return false; };
|
|
43
|
-
|
|
44
|
-
function keywords(ajv) {
|
|
45
|
-
ajv.addKeyword({
|
|
46
|
-
keyword: 'x-max-contains', type: 'object', schemaType: 'object',
|
|
47
|
-
compile({ match, max }) {
|
|
48
|
-
const matcher = ajv.compile(match);
|
|
49
|
-
return value => Object.values(value).filter(each => matcher(each)).length <= max;
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
ajv.addKeyword({
|
|
53
|
-
keyword: 'x-unique-by', type: 'array', schemaType: 'array', errors: true,
|
|
54
|
-
validate: function unique(keys, items, parentSchema) {
|
|
55
|
-
for (const key of keys) {
|
|
56
|
-
const part = typeof key === 'object' ? new RegExp(key.part, 'u') : null, seen = new Set();
|
|
57
|
-
for (const item of items) {
|
|
58
|
-
const value = part ? (typeof item === 'string' ? part.exec(item)?.[1] : undefined)
|
|
59
|
-
: item && typeof item === 'object' && Object.hasOwn(item, key) ? item[key] : undefined;
|
|
60
|
-
if (value === undefined) continue;
|
|
61
|
-
const said = JSON.stringify(value);
|
|
62
|
-
if (seen.has(said)) return fail(unique, 'x-unique-by', part ? `不能重复:${value}` : `${key} 不能重复:${value}`, parentSchema);
|
|
63
|
-
seen.add(said);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
// A reference: whether `name` is a key (or element) of what `pointer` names, and that satisfies `match`.
|
|
70
|
-
const resolves = (ref, matcher, name, cxt) => {
|
|
71
|
-
const at = locate(ref.pointer, cxt);
|
|
72
|
-
if (Array.isArray(at)) return at.includes(name);
|
|
73
|
-
if (!at || typeof at !== 'object' || !Object.hasOwn(at, name)) return false;
|
|
74
|
-
return !matcher || matcher(at[name]);
|
|
75
|
-
};
|
|
76
|
-
ajv.addKeyword({
|
|
77
|
-
keyword: 'x-ref', type: 'string', schemaType: 'object',
|
|
78
|
-
compile(ref) {
|
|
79
|
-
const matcher = ref.match ? ajv.compile(ref.match) : null, part = ref.part ? new RegExp(ref.part, 'u') : null;
|
|
80
|
-
return (value, cxt) => {
|
|
81
|
-
const name = part ? part.exec(value)?.[1] : value;
|
|
82
|
-
return name !== undefined && resolves(ref, matcher, name, cxt);
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
ajv.addKeyword({
|
|
87
|
-
keyword: 'x-placeholders', type: 'string', schemaType: 'object',
|
|
88
|
-
compile(allowed) {
|
|
89
|
-
const config = allowed.config ? { pointer: '/contributes/configuration/properties' } : null, matcher = allowed.config ? ajv.compile(allowed.config) : null;
|
|
90
|
-
return (value, cxt) => [...value.matchAll(/\$\{([^}]*)\}/g)].every(([, place]) => {
|
|
91
|
-
if ((allowed.names ?? []).includes(place)) return true;
|
|
92
|
-
const setting = /^config:(.+)$/.exec(place)?.[1];
|
|
93
|
-
return !!(config && setting && resolves(config, matcher, setting, cxt));
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
ajv.addKeyword({
|
|
98
|
-
keyword: 'x-file', type: 'string', schemaType: 'object', errors: true,
|
|
99
|
-
validate: function file(spec, value, parentSchema) {
|
|
100
|
-
const dir = this?.dir;
|
|
101
|
-
const path = normalize(spec.under ? join(spec.under, `${value}${spec.suffix ?? ''}`) : `${value}${spec.suffix ?? ''}`);
|
|
102
|
-
if (isAbsolute(path) || path === '.' || path === '..' || path.startsWith(`..${sep}`)) return fail(file, 'x-file', `${value} 须为不离开插件目录的相对路径`, parentSchema);
|
|
103
|
-
if (!dir) return true;
|
|
104
|
-
let found;
|
|
105
|
-
try { found = statSync(join(dir, path)); } catch { return spec.absent ? true : fail(file, 'x-file', `插件目录里没有 ${path}`, parentSchema); }
|
|
106
|
-
if (spec.absent) return fail(file, 'x-file', `插件目录里已有 ${path}`, parentSchema);
|
|
107
|
-
if (spec.type === 'directory' ? !found.isDirectory() : !found.isFile()) return fail(file, 'x-file', `${path} 须为插件目录里的${spec.type === 'directory' ? '目录' : '文件'}`, parentSchema);
|
|
108
|
-
if (spec.contains) try { if (!statSync(join(dir, path, spec.contains)).isFile()) throw new Error(); }
|
|
109
|
-
catch { return fail(file, 'x-file', `${path} 里没有 ${spec.contains}`, parentSchema); }
|
|
110
|
-
if (spec.maxBytes !== undefined && found.size > spec.maxBytes) return fail(file, 'x-file', `${path} 超过 ${spec.maxBytes / 1024} KiB`, parentSchema);
|
|
111
|
-
if (spec.magic) {
|
|
112
|
-
const head = Buffer.alloc(spec.magic.length), fd = openSync(join(dir, path), 'r');
|
|
113
|
-
try { readSync(fd, head, 0, head.length, 0); } finally { closeSync(fd); }
|
|
114
|
-
if (head.toString('latin1') !== spec.magic) return fail(file, 'x-file', `${path} 不是 ${spec.magic.replace(/\W/g, '')}`, parentSchema);
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const ajv = new Ajv2020({ allErrors: false, verbose: true, passContext: true, strict: true, strictTypes: false, strictRequired: false, allowUnionTypes: true });
|
|
122
|
-
keywords(ajv);
|
|
123
|
-
for (const schema of Object.values(SCHEMAS)) ajv.addSchema(schema);
|
|
124
|
-
// The validators of the schemas here, by file.
|
|
125
|
-
const compiled = new Map();
|
|
126
|
-
const validator = file => {
|
|
127
|
-
if (!compiled.has(file)) compiled.set(file, ajv.getSchema(`${BASE}${file}`));
|
|
128
|
-
return compiled.get(file);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Where in the manifest a value is, as a person writes it: `contributes.composerModes[0].in`.
|
|
132
|
-
const place = (path, base) => path.split('/').slice(1).map(unescape)
|
|
133
|
-
.reduce((at, step) => /^\d+$/.test(step) ? `${at}[${step}]` : !/^[A-Za-z_$][\w$]*$/.test(step) ? `${at}「${step}」` : at ? `${at}.${step}` : step, base);
|
|
134
|
-
const TYPE_NAMES = { array: '数组', object: '对象', string: '文本', number: '数字', integer: '整数', boolean: '开或关' };
|
|
135
|
-
// What the schema says of a failing value: the description nearest above the keyword that failed (a branch's `then`, a
|
|
136
|
-
// property's), found by where the error says it is, from the schema it failed in (the one a `$ref` names, any of these).
|
|
137
|
-
const nodes = function* (node) {
|
|
138
|
-
if (!node || typeof node !== 'object') return;
|
|
139
|
-
yield node;
|
|
140
|
-
for (const child of Object.values(node)) yield* nodes(child);
|
|
141
|
-
};
|
|
142
|
-
function described(error) {
|
|
143
|
-
if (!error.parentSchema) return undefined;
|
|
144
|
-
if (error.parentSchema.description) return error.parentSchema.description;
|
|
145
|
-
const steps = error.schemaPath.replace(/^#\//, '').split('/').map(unescape).slice(0, -1);
|
|
146
|
-
for (const root of Object.values(SCHEMAS)) for (const from of nodes(root)) {
|
|
147
|
-
const path = [from];
|
|
148
|
-
for (const step of steps) path.push(path.at(-1)?.[step]);
|
|
149
|
-
if (path.at(-1) === error.parentSchema) return path.slice(0, -1).reverse().find(node => typeof node?.description === 'string')?.description;
|
|
150
|
-
}
|
|
151
|
-
return undefined;
|
|
152
|
-
}
|
|
153
|
-
// What is wrong, said once: the first error, by its place and what the schema says of the value there.
|
|
154
|
-
export function explain(errors, base = '') {
|
|
155
|
-
const [error] = errors;
|
|
156
|
-
const at = place(error.instancePath, base) || 'package.json', name = error.propertyName ? `「${error.propertyName}」` : '';
|
|
157
|
-
const said = described(error);
|
|
158
|
-
if (error.keyword === 'required') return `${at} 缺 ${error.params.missingProperty}${said ? `:${said}` : ''}`;
|
|
159
|
-
if (error.keyword === 'additionalProperties' || error.keyword === 'unevaluatedProperties')
|
|
160
|
-
return `${at} 里有不认识的键:${error.params.additionalProperty ?? error.params.unevaluatedProperty}`;
|
|
161
|
-
if (error.keyword === 'type') return `${at}${name} 须为${TYPE_NAMES[error.params.type] ?? error.params.type}${said ? `:${said}` : ''}`;
|
|
162
|
-
if (error.keyword === 'x-file' || error.keyword === 'x-unique-by') return `${at}${name}:${error.message}${said ? `(${said})` : ''}`;
|
|
163
|
-
return `${at}${name}:${said ?? error.message}`;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// A manifest checked against its schema, the files it names in `dir` when given. Returns null, or what is wrong.
|
|
167
|
-
export function manifestProblem(manifest, dir = null) {
|
|
168
|
-
const validate = validator('plugin.json');
|
|
169
|
-
return validate.call({ dir }, manifest) ? null : explain(validate.errors);
|
|
170
|
-
}
|
|
171
|
-
// A value checked against one of the schemas (`ref`: a file, with a fragment, as `composer-modes.json#/$defs/parameters`),
|
|
172
|
-
// as a plugin gives it while it runs: null, or what is wrong, at `where`.
|
|
173
|
-
export function valueProblem(ref, value, where) {
|
|
174
|
-
const validate = ajv.getSchema(`${BASE}${ref}`) ?? null;
|
|
175
|
-
if (!validate) throw new Error(`没有这个 schema:${ref}`);
|
|
176
|
-
return validate.call({ dir: null }, value) ? null : explain(validate.errors, where);
|
|
177
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/agents.json",
|
|
4
|
-
"title": "contributes.agents:插件带来的 Agent",
|
|
5
|
-
"description": "每个是一个讲 ACP(加 Coda 的等待项)的程序:它是谁、客户端怎么画它、Coda 怎么启动它。",
|
|
6
|
-
"type": "array",
|
|
7
|
-
"items": {
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {
|
|
10
|
-
"id": {"$ref": "common.json#/$defs/id"},
|
|
11
|
-
"displayName": {"$ref": "common.json#/$defs/line40"},
|
|
12
|
-
"icon": {
|
|
13
|
-
"description": "图标:light(必填)与 dark 是插件目录里的 PDF,各不超过 32 KiB;template 是开或关",
|
|
14
|
-
"type": "object",
|
|
15
|
-
"properties": {"light": {"$ref": "#/$defs/icon"}, "dark": {"$ref": "#/$defs/icon"}, "template": {"type": "boolean"}},
|
|
16
|
-
"required": ["light"],
|
|
17
|
-
"additionalProperties": false
|
|
18
|
-
},
|
|
19
|
-
"command": {"$ref": "common.json#/$defs/command"},
|
|
20
|
-
"modes": {
|
|
21
|
-
"description": "审批档位的说法:title 不超过 10 字,unset 不超过 20 字,note 不超过 100 字,auto、full 各不超过 200 字",
|
|
22
|
-
"type": "object",
|
|
23
|
-
"properties": {
|
|
24
|
-
"title": {"$ref": "common.json#/$defs/line10"},
|
|
25
|
-
"unset": {"$ref": "common.json#/$defs/line20"},
|
|
26
|
-
"note": {"$ref": "common.json#/$defs/line100"},
|
|
27
|
-
"auto": {"$ref": "common.json#/$defs/line200"},
|
|
28
|
-
"full": {"$ref": "common.json#/$defs/line200"}
|
|
29
|
-
},
|
|
30
|
-
"additionalProperties": false
|
|
31
|
-
},
|
|
32
|
-
"skillsDir": {
|
|
33
|
-
"description": "Agent 读 Skill 的目录:工作区里不离开它的相对路径,至多 3 段",
|
|
34
|
-
"allOf": [{"$ref": "common.json#/$defs/line1000"}, {"pattern": "^(?!/)(?!(.*/)?\\.\\.(/|$))"}, {"pattern": "^[^/]+(/+[^/]+){0,2}/*$"}]
|
|
35
|
-
},
|
|
36
|
-
"configFiles": {"description": "Agent 读模型的配置文件,至多 16 个", "type": "array", "maxItems": 16, "items": {"$ref": "common.json#/$defs/line1000"}},
|
|
37
|
-
"setupHint": {"$ref": "common.json#/$defs/line200"}
|
|
38
|
-
},
|
|
39
|
-
"required": ["id", "displayName", "icon", "command"],
|
|
40
|
-
"additionalProperties": false
|
|
41
|
-
},
|
|
42
|
-
"x-unique-by": ["id"],
|
|
43
|
-
"$defs": {
|
|
44
|
-
"icon": {
|
|
45
|
-
"description": "插件目录里的 PDF,不超过 32 KiB",
|
|
46
|
-
"allOf": [{"$ref": "common.json#/$defs/line1000"}],
|
|
47
|
-
"x-file": {"type": "file", "maxBytes": 32768, "magic": "%PDF-"}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/capabilities.json",
|
|
4
|
-
"title": "contributes.capabilities:插件带来的能力",
|
|
5
|
-
"description": "能力名的数组,每个是 .coda/capabilities/<名>.bpmn;只能被调用(workflow_run、callActivity),没有触发器。",
|
|
6
|
-
"type": "array",
|
|
7
|
-
"uniqueItems": true,
|
|
8
|
-
"items": {
|
|
9
|
-
"description": "能力名:小写字母、数字和「-」,以字母开头,有对应的 .coda/capabilities/<名>.bpmn,不能同时是流程(.coda/workflows/<名>.bpmn)",
|
|
10
|
-
"$ref": "common.json#/$defs/name",
|
|
11
|
-
"allOf": [
|
|
12
|
-
{"x-file": {"type": "file", "under": ".coda/capabilities", "suffix": ".bpmn"}},
|
|
13
|
-
{"x-file": {"type": "file", "under": ".coda/workflows", "suffix": ".bpmn", "absent": true}}
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/commands.json",
|
|
4
|
-
"title": "contributes.commands:放在会话与步骤 PATH 最前的命令",
|
|
5
|
-
"description": "命令名 → 由 sh 运行的一行命令(带上参数)。",
|
|
6
|
-
"type": "array",
|
|
7
|
-
"items": {
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {
|
|
10
|
-
"name": {
|
|
11
|
-
"description": "命令名:小写字母、数字和「-」,以字母开头,不能是 Coda 自己的 coda-run、coda-event、coda-resources",
|
|
12
|
-
"$ref": "common.json#/$defs/id",
|
|
13
|
-
"not": {"enum": ["coda-run", "coda-event", "coda-resources"]}
|
|
14
|
-
},
|
|
15
|
-
"command": {"$ref": "common.json#/$defs/command"}
|
|
16
|
-
},
|
|
17
|
-
"required": ["name", "command"],
|
|
18
|
-
"additionalProperties": false
|
|
19
|
-
},
|
|
20
|
-
"x-unique-by": ["name"]
|
|
21
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/common.json",
|
|
4
|
-
"title": "插件清单里共用的写法",
|
|
5
|
-
"$defs": {
|
|
6
|
-
"id": {"description": "小写字母、数字和「-」,以字母开头,至多 40 个字符", "type": "string", "pattern": "^[a-z][a-z0-9-]{0,39}$"},
|
|
7
|
-
"name": {"description": "小写字母、数字和「-」,以字母开头,至多 64 个字符", "type": "string", "pattern": "^[a-z][a-z0-9-]{0,63}$"},
|
|
8
|
-
"line10": {"description": "不超过 10 字的一行", "type": "string", "maxLength": 10, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
9
|
-
"line20": {"description": "不超过 20 字的一行", "type": "string", "maxLength": 20, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
10
|
-
"line40": {"description": "不超过 40 字的一行", "type": "string", "maxLength": 40, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
11
|
-
"line100": {"description": "不超过 100 字的一行", "type": "string", "maxLength": 100, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
12
|
-
"line200": {"description": "不超过 200 字的一行", "type": "string", "maxLength": 200, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
13
|
-
"line1000": {"description": "不超过 1000 字的一行", "type": "string", "maxLength": 1000, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
14
|
-
"line4096": {"description": "不超过 4096 字的一行", "type": "string", "maxLength": 4096, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
15
|
-
"command": {"description": "一行命令,由 sh 运行,不超过 4000 字", "type": "string", "maxLength": 4000, "pattern": "^(?=.*\\S)[^\\u0000\\r\\n]*$"},
|
|
16
|
-
"symbol": {"description": "SF Symbol 的名字", "type": "string", "maxLength": 100, "pattern": "^[a-z0-9]+(\\.[a-z0-9]+)*$"},
|
|
17
|
-
"commandHolder": {
|
|
18
|
-
"description": "{ command }:command 是一行命令",
|
|
19
|
-
"type": "object",
|
|
20
|
-
"properties": {"command": {"$ref": "#/$defs/command"}},
|
|
21
|
-
"required": ["command"],
|
|
22
|
-
"additionalProperties": false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/composer-modes.json",
|
|
4
|
-
"title": "contributes.composerModes:输入框模式",
|
|
5
|
-
"description": "输入框能处在的模式:显示什么(图标、标题、发出去是什么、占位与发送按钮),发出的给谁(agent:session 会话的 Agent,own 为它另选的、开新会话跑,off 不显示),在哪些输入框里能进(in:session 会话的、new 新任务的),参数(写法同设置)。打字进入的(trigger,如 !)没有参数,发出的就是会话的。",
|
|
6
|
-
"type": "array",
|
|
7
|
-
"maxItems": 10,
|
|
8
|
-
"items": {
|
|
9
|
-
"type": "object",
|
|
10
|
-
"properties": {
|
|
11
|
-
"id": {"$ref": "common.json#/$defs/id"},
|
|
12
|
-
"title": {"$ref": "common.json#/$defs/line40"},
|
|
13
|
-
"icon": {"$ref": "common.json#/$defs/symbol"},
|
|
14
|
-
"hint": {"$ref": "common.json#/$defs/line200"},
|
|
15
|
-
"placeholder": {"$ref": "common.json#/$defs/line40"},
|
|
16
|
-
"sendLabel": {"$ref": "common.json#/$defs/line20"},
|
|
17
|
-
"agent": {"description": "agent 只能是 session、own、off", "enum": ["session", "own", "off"]},
|
|
18
|
-
"trigger": {"description": "trigger 是一个标点:!#$%&*+:;=?^|~ 之一", "type": "string", "pattern": "^[!#$%&*+:;=?^|~]$"},
|
|
19
|
-
"in": {"description": "它出现的输入框:session、new,不重复", "type": "array", "minItems": 1, "uniqueItems": true, "items": {"enum": ["session", "new"]}},
|
|
20
|
-
"parameters": {"$ref": "#/$defs/parameters"}
|
|
21
|
-
},
|
|
22
|
-
"required": ["id", "title", "icon"],
|
|
23
|
-
"additionalProperties": false,
|
|
24
|
-
"allOf": [
|
|
25
|
-
{
|
|
26
|
-
"if": {"required": ["trigger"]},
|
|
27
|
-
"then": {
|
|
28
|
-
"description": "打字进入的模式(trigger)没有参数,也不另选 Agent",
|
|
29
|
-
"not": {"anyOf": [{"required": ["parameters"]}, {"properties": {"agent": {"const": "own"}}, "required": ["agent"]}]}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"if": {"properties": {"agent": {"const": "own"}}, "required": ["agent"]},
|
|
34
|
-
"then": {
|
|
35
|
-
"description": "开新会话的模式(agent: own)要从会话里发出,不能在 new 里",
|
|
36
|
-
"properties": {"in": {"description": "开新会话的模式(agent: own)要从会话里发出,不能在 new 里", "not": {"contains": {"const": "new"}}}}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"x-unique-by": ["id", "trigger"],
|
|
42
|
-
"$defs": {
|
|
43
|
-
"parameters": {
|
|
44
|
-
"description": "模式的参数:{ type: object, properties, required? },1–20 个,每个写法同设置,不能是密文",
|
|
45
|
-
"type": "object",
|
|
46
|
-
"properties": {
|
|
47
|
-
"type": {"const": "object"},
|
|
48
|
-
"properties": {
|
|
49
|
-
"type": "object",
|
|
50
|
-
"minProperties": 1,
|
|
51
|
-
"maxProperties": 20,
|
|
52
|
-
"propertyNames": {"description": "参数名只用字母和数字,以小写字母开头", "pattern": "^[a-z][A-Za-z0-9]{0,39}$"},
|
|
53
|
-
"additionalProperties": {
|
|
54
|
-
"allOf": [
|
|
55
|
-
{"$ref": "setting.json"},
|
|
56
|
-
{
|
|
57
|
-
"description": "参数不能是密文",
|
|
58
|
-
"not": {"properties": {"writeOnly": {"const": true}}, "required": ["writeOnly"]},
|
|
59
|
-
"properties": {
|
|
60
|
-
"additionalProperties": {
|
|
61
|
-
"properties": {"properties": {"additionalProperties": {"not": {"properties": {"writeOnly": {"const": true}}, "required": ["writeOnly"]}}}}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"required": {
|
|
69
|
-
"description": "required 是本模式的参数名,不重复",
|
|
70
|
-
"type": "array",
|
|
71
|
-
"uniqueItems": true,
|
|
72
|
-
"items": {"description": "required 是本模式的参数名,不重复", "type": "string", "x-ref": {"pointer": "2/properties"}}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"required": ["type", "properties"],
|
|
76
|
-
"additionalProperties": false
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/configuration.json",
|
|
4
|
-
"title": "contributes.configuration:插件的设置",
|
|
5
|
-
"description": "照 VS Code 的 contributes.configuration:properties 是设置名 → 声明(setting.json),设置名以「<插件 ID>.」开头;required 是缺了就不能用的设置。",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"properties": {
|
|
8
|
-
"title": {"type": "string"},
|
|
9
|
-
"properties": {
|
|
10
|
-
"description": "设置名 → 声明;单值设置是一组,至多一个模型地址(coda-model-url):检查可用模型按组找它",
|
|
11
|
-
"type": "object",
|
|
12
|
-
"propertyNames": {"description": "设置名是插件 ID 加「.」再加字母和数字", "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][A-Za-z0-9]*)+$"},
|
|
13
|
-
"additionalProperties": {"$ref": "setting.json"},
|
|
14
|
-
"x-max-contains": {"match": {"properties": {"format": {"const": "coda-model-url"}}, "required": ["format"]}, "max": 1}
|
|
15
|
-
},
|
|
16
|
-
"required": {
|
|
17
|
-
"description": "contributes.configuration.required 是本插件声明过的设置名,不重复",
|
|
18
|
-
"type": "array",
|
|
19
|
-
"uniqueItems": true,
|
|
20
|
-
"items": {"description": "contributes.configuration.required 是本插件声明过的设置名,不重复", "type": "string", "x-ref": {"pointer": "2/properties"}}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/endpoints.json",
|
|
4
|
-
"title": "contributes.endpoints:客户端发给插件的请求",
|
|
5
|
-
"description": "id → 回答它的一行命令(请求从标准输入给);checks 是它检查的本插件设置,客户端在那项设置旁提供「检查」,一项设置至多一个端点。",
|
|
6
|
-
"type": "array",
|
|
7
|
-
"maxItems": 20,
|
|
8
|
-
"items": {
|
|
9
|
-
"type": "object",
|
|
10
|
-
"properties": {
|
|
11
|
-
"id": {"$ref": "common.json#/$defs/id"},
|
|
12
|
-
"command": {"$ref": "common.json#/$defs/command"},
|
|
13
|
-
"checks": {"description": "checks 是本插件声明的一项设置", "type": "string", "x-ref": {"pointer": "/contributes/configuration/properties"}}
|
|
14
|
-
},
|
|
15
|
-
"required": ["id", "command"],
|
|
16
|
-
"additionalProperties": false
|
|
17
|
-
},
|
|
18
|
-
"x-unique-by": ["id", "checks"]
|
|
19
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
-
"$id": "https://coda.pub/schemas/plugin/v1/environment.json",
|
|
4
|
-
"title": "contributes.environment:给项目里启动的东西的环境变量",
|
|
5
|
-
"description": "变量名 → 值,不超过 100 个。值里可以写 ${config:<本插件的单值设置>}(不能是密文:密文从 CODA_PLUGIN_SECRETS 给的文件读)、${CODA_PLUGIN_PATH}、${CODA_PLUGIN_STATE}。PATH 由 contributes.path 给;Coda 自己的变量与 shell 的钩子不归插件。",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"maxProperties": 100,
|
|
8
|
-
"propertyNames": {
|
|
9
|
-
"description": "变量名只用字母、数字和「_」,不以数字开头,也不能是 PATH、ZDOTDIR、BASH_ENV 或 CODA_、BASH_FUNC_ 开头的",
|
|
10
|
-
"pattern": "^(?!(PATH|ZDOTDIR|BASH_ENV|CODA_.*|BASH_FUNC_.*)$)[A-Za-z_][A-Za-z0-9_]*$"
|
|
11
|
-
},
|
|
12
|
-
"additionalProperties": {
|
|
13
|
-
"description": "不超过 4096 字的文字;${…} 只能是 config:<本插件的单值设置>、CODA_PLUGIN_PATH 或 CODA_PLUGIN_STATE;密文不进环境变量,插件的进程从 CODA_PLUGIN_SECRETS 给的文件读",
|
|
14
|
-
"type": "string",
|
|
15
|
-
"maxLength": 4096,
|
|
16
|
-
"pattern": "^[^\\u0000]*$",
|
|
17
|
-
"x-placeholders": {
|
|
18
|
-
"names": ["CODA_PLUGIN_PATH", "CODA_PLUGIN_STATE"],
|
|
19
|
-
"config": {"properties": {"type": {"enum": ["string", "number", "integer", "boolean"]}, "writeOnly": {"const": false}}, "required": ["type"]}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|