@coda-console/plugin-check 0.7.5 → 0.8.0

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.
@@ -1,45 +0,0 @@
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 (coda-protocol docs/agent-protocol.md). Nothing here knows any agent by
3
- // name: Codex and Claude are plugins like any other.
4
- import { readFileSync } from 'node:fs';
5
- import { isAbsolute, join, normalize } from 'node:path';
6
-
7
- // An icon file, read once with the plugin (its schema says it is a PDF in the plugin's directory): both clients draw it as
8
- // they drew the brand artwork they shipped with.
9
- const icon = (dir, path) => readFileSync(join(dir, normalize(path))).toString('base64');
10
- // The PDFs an icon names (an agent's, or a plugin's own drawn the same way), read: light, dark when there is one, and
11
- // whether it is drawn in the text colour.
12
- export const iconFiles = (dir, spec) => ({ light: icon(dir, spec.light), ...(spec.dark !== undefined ? { dark: icon(dir, spec.dark) } : {}), template: spec.template === true });
13
- // An icon as the clients are given it: PDFs as data, light and dark, and whether they take the text's color; a symbol on
14
- // a colour as it is.
15
- const pdf = data => data ? `data:application/pdf;base64,${data}` : null;
16
- export const shownIcon = icon => icon.symbol ? { symbol: icon.symbol, color: icon.color } : { light: pdf(icon.light), dark: pdf(icon.dark), template: icon.template };
17
- const MODES = ['title', 'unset', 'note', 'auto', 'full'];
18
- // `contributes.agents` of the plugin in `dir`, as its schema has them.
19
- export function agentDeclarations(raw = [], dir) {
20
- return raw.map(agent => ({
21
- id: agent.id, displayName: agent.displayName,
22
- icon: iconFiles(dir, agent.icon),
23
- command: agent.command,
24
- ...(agent.lifecycle !== undefined ? { lifecycle: agent.lifecycle } : {}),
25
- modes: Object.fromEntries(MODES.filter(key => agent.modes?.[key] !== undefined).map(key => [key, agent.modes[key]])),
26
- ...(agent.skillsDir !== undefined ? { skillsDir: normalize(agent.skillsDir) } : {}),
27
- configFiles: [...(agent.configFiles ?? [])],
28
- ...(agent.setupHint !== undefined ? { setupHint: agent.setupHint } : {}),
29
- }));
30
- }
31
- // A configuration file an agent reads its models from, as its plugin names it: `~/` is the home directory, `${VAR}` and
32
- // `${VAR:-default}` the backend's environment (a variable empty and without a default leaves the file out), and a relative
33
- // path is the project's.
34
- export function configFile(spec, { env, home, root }) {
35
- let empty = false;
36
- const expanded = spec.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g, (_, name, fallback) => {
37
- const value = env[name];
38
- if (value) return value;
39
- if (fallback === undefined) { empty = true; return ''; }
40
- return fallback;
41
- });
42
- if (empty || !expanded) return null;
43
- const path = expanded === '~' ? home : expanded.startsWith('~/') ? join(home, expanded.slice(2)) : expanded;
44
- return isAbsolute(path) ? path : join(root, path);
45
- }
@@ -1,4 +0,0 @@
1
- // The resource kinds Coda's own resources are named by until they are protocols (components/protocols/core-operations.mjs).
2
- export const AGENTS = 'agents';
3
- export const THREADS = 'threads';
4
- export const GROUPS = 'groups';