omnicell-router 0.1.0 → 0.2.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.
- package/RELEASING.md +238 -238
- package/RELEASING.zh-CN.md +230 -230
- package/backend/dist/capture/recorder.js +2 -1
- package/backend/dist/cli/clients/base.js +8 -16
- package/backend/dist/cli/clients/dsh.js +8 -16
- package/backend/dist/cli/clients/pi.js +16 -9
- package/backend/dist/cli/types.d.ts +5 -0
- package/backend/dist/config/env.js +2 -1
- package/backend/dist/config/index.js +2 -0
- package/backend/dist/config/types.d.ts +23 -0
- package/backend/dist/harness/adapters/amp.d.ts +2 -0
- package/backend/dist/harness/adapters/amp.js +7 -0
- package/backend/dist/harness/adapters/claude.d.ts +2 -0
- package/backend/dist/harness/adapters/claude.js +7 -0
- package/backend/dist/harness/adapters/cline.d.ts +2 -0
- package/backend/dist/harness/adapters/cline.js +6 -0
- package/backend/dist/harness/adapters/codex.d.ts +2 -0
- package/backend/dist/harness/adapters/codex.js +6 -0
- package/backend/dist/harness/adapters/cursor.d.ts +5 -0
- package/backend/dist/harness/adapters/cursor.js +10 -0
- package/backend/dist/harness/adapters/declarative.d.ts +62 -0
- package/backend/dist/harness/adapters/declarative.js +202 -0
- package/backend/dist/harness/adapters/dsh.d.ts +5 -0
- package/backend/dist/harness/adapters/dsh.js +6 -0
- package/backend/dist/harness/adapters/gemini-cli.d.ts +2 -0
- package/backend/dist/harness/adapters/gemini-cli.js +7 -0
- package/backend/dist/harness/adapters/github-copilot.d.ts +5 -0
- package/backend/dist/harness/adapters/github-copilot.js +10 -0
- package/backend/dist/harness/adapters/index.d.ts +44 -0
- package/backend/dist/harness/adapters/index.js +99 -0
- package/backend/dist/harness/adapters/opencode.d.ts +2 -0
- package/backend/dist/harness/adapters/opencode.js +55 -0
- package/backend/dist/harness/adapters/pi.d.ts +1 -0
- package/backend/dist/harness/adapters/pi.js +22 -0
- package/backend/dist/harness/adapters/skills-paths.d.ts +15 -0
- package/backend/dist/harness/adapters/skills-paths.js +17 -0
- package/backend/dist/harness/adapters/types.d.ts +174 -0
- package/backend/dist/harness/adapters/types.js +12 -0
- package/backend/dist/harness/adapters/universal.d.ts +6 -0
- package/backend/dist/harness/adapters/universal.js +10 -0
- package/backend/dist/harness/adapters/windsurf.d.ts +2 -0
- package/backend/dist/harness/adapters/windsurf.js +10 -0
- package/backend/dist/harness/adapters/zed.d.ts +2 -0
- package/backend/dist/harness/adapters/zed.js +6 -0
- package/backend/dist/harness/awesome-opencode.d.ts +40 -0
- package/backend/dist/harness/awesome-opencode.js +75 -0
- package/backend/dist/harness/browse.d.ts +202 -0
- package/backend/dist/harness/browse.js +1214 -0
- package/backend/dist/harness/catalog-npm.d.ts +59 -0
- package/backend/dist/harness/catalog-npm.js +145 -0
- package/backend/dist/harness/clawhub.d.ts +212 -0
- package/backend/dist/harness/clawhub.js +426 -0
- package/backend/dist/harness/config-file.d.ts +29 -0
- package/backend/dist/harness/config-file.js +35 -0
- package/backend/dist/harness/detail.d.ts +74 -0
- package/backend/dist/harness/detail.js +330 -0
- package/backend/dist/harness/discover.d.ts +118 -0
- package/backend/dist/harness/discover.js +507 -0
- package/backend/dist/harness/drift.d.ts +21 -0
- package/backend/dist/harness/drift.js +25 -0
- package/backend/dist/harness/hash.d.ts +10 -0
- package/backend/dist/harness/hash.js +63 -0
- package/backend/dist/harness/hosts.d.ts +18 -0
- package/backend/dist/harness/hosts.js +15 -0
- package/backend/dist/harness/install.d.ts +88 -0
- package/backend/dist/harness/install.js +301 -0
- package/backend/dist/harness/inventory.d.ts +10 -0
- package/backend/dist/harness/inventory.js +198 -0
- package/backend/dist/harness/ledger.d.ts +39 -0
- package/backend/dist/harness/ledger.js +83 -0
- package/backend/dist/harness/maintenance.d.ts +115 -0
- package/backend/dist/harness/maintenance.js +603 -0
- package/backend/dist/harness/manifest.d.ts +31 -0
- package/backend/dist/harness/manifest.js +234 -0
- package/backend/dist/harness/net.d.ts +86 -0
- package/backend/dist/harness/net.js +113 -0
- package/backend/dist/harness/opencode-cafe.d.ts +40 -0
- package/backend/dist/harness/opencode-cafe.js +85 -0
- package/backend/dist/harness/opencode-ecosystem.d.ts +34 -0
- package/backend/dist/harness/opencode-ecosystem.js +246 -0
- package/backend/dist/harness/pi-dev.d.ts +81 -0
- package/backend/dist/harness/pi-dev.js +187 -0
- package/backend/dist/harness/probe.d.ts +33 -0
- package/backend/dist/harness/probe.js +85 -0
- package/backend/dist/harness/registry.d.ts +2 -0
- package/backend/dist/harness/registry.js +26 -0
- package/backend/dist/harness/scopes.d.ts +21 -0
- package/backend/dist/harness/scopes.js +22 -0
- package/backend/dist/harness/skill-md.d.ts +18 -0
- package/backend/dist/harness/skill-md.js +71 -0
- package/backend/dist/harness/skills-sh.d.ts +109 -0
- package/backend/dist/harness/skills-sh.js +178 -0
- package/backend/dist/harness/smithery.d.ts +64 -0
- package/backend/dist/harness/smithery.js +146 -0
- package/backend/dist/harness/sources/awesome-opencode.d.ts +11 -0
- package/backend/dist/harness/sources/awesome-opencode.js +39 -0
- package/backend/dist/harness/sources/clawhub.d.ts +2 -0
- package/backend/dist/harness/sources/clawhub.js +83 -0
- package/backend/dist/harness/sources/github.d.ts +9 -0
- package/backend/dist/harness/sources/github.js +202 -0
- package/backend/dist/harness/sources/mcp-official.d.ts +2 -0
- package/backend/dist/harness/sources/mcp-official.js +110 -0
- package/backend/dist/harness/sources/npm.d.ts +2 -0
- package/backend/dist/harness/sources/npm.js +152 -0
- package/backend/dist/harness/sources/opencode-cafe.d.ts +11 -0
- package/backend/dist/harness/sources/opencode-cafe.js +41 -0
- package/backend/dist/harness/sources/smithery.d.ts +2 -0
- package/backend/dist/harness/sources/smithery.js +81 -0
- package/backend/dist/harness/spi.d.ts +98 -0
- package/backend/dist/harness/spi.js +8 -0
- package/backend/dist/harness/stars.d.ts +70 -0
- package/backend/dist/harness/stars.js +202 -0
- package/backend/dist/harness/translation.d.ts +142 -0
- package/backend/dist/harness/translation.js +567 -0
- package/backend/dist/harness/tree.d.ts +13 -0
- package/backend/dist/harness/tree.js +19 -0
- package/backend/dist/harness/types.d.ts +286 -0
- package/backend/dist/harness/types.js +8 -0
- package/backend/dist/harness/writers/extension.d.ts +116 -0
- package/backend/dist/harness/writers/extension.js +219 -0
- package/backend/dist/harness/writers/mcp.d.ts +72 -0
- package/backend/dist/harness/writers/mcp.js +195 -0
- package/backend/dist/harness/writers/skill.d.ts +60 -0
- package/backend/dist/harness/writers/skill.js +146 -0
- package/backend/dist/opencode/agents.d.ts +5 -0
- package/backend/dist/opencode/agents.js +10 -1
- package/backend/dist/opencode/catalog/cache.js +2 -1
- package/backend/dist/opencode/catalog/logos.js +2 -1
- package/backend/dist/opencode/catalog/ocr-store.js +2 -1
- package/backend/dist/opencode/catalog/overrides-store.js +2 -1
- package/backend/dist/opencode/credentials/factory.js +10 -27
- package/backend/dist/opencode/credentials/ocr-store.js +2 -1
- package/backend/dist/opencode/provider-defs.js +2 -1
- package/backend/dist/opencode/user-config.js +8 -16
- package/backend/dist/providers/registry.d.ts +15 -4
- package/backend/dist/providers/registry.js +29 -5
- package/backend/dist/providers/virtual-meta.d.ts +13 -0
- package/backend/dist/providers/virtual-meta.js +18 -0
- package/backend/dist/quota/store.js +2 -1
- package/backend/dist/resilience/breaker-state.js +2 -1
- package/backend/dist/resilience/credential-state.js +2 -1
- package/backend/dist/routes/console.js +137 -15
- package/backend/dist/routes/harness.d.ts +2 -0
- package/backend/dist/routes/harness.js +622 -0
- package/backend/dist/server.js +4 -0
- package/backend/dist/session/session-manager.js +2 -1
- package/backend/dist/surfaces/systemone-probe.d.ts +25 -0
- package/backend/dist/surfaces/systemone-probe.js +74 -0
- package/backend/dist/utils/atomic-write.d.ts +12 -0
- package/backend/dist/utils/atomic-write.js +29 -0
- package/bin/ocr.js +2 -2
- package/frontend/dist/assets/{index-DEo2iAT7.css → index-1o7qI-KJ.css} +1 -1
- package/frontend/dist/assets/index-DvXKvNxl.js +962 -0
- package/frontend/dist/index.html +2 -2
- package/package.json +87 -87
- package/backend/dist/budget/budget-manager.d.ts +0 -25
- package/backend/dist/budget/budget-manager.js +0 -54
- package/backend/dist/config/governance-limits.d.ts +0 -68
- package/backend/dist/config/governance-limits.js +0 -261
- package/backend/dist/flywheel/collector.d.ts +0 -74
- package/backend/dist/flywheel/collector.js +0 -235
- package/backend/dist/flywheel/dataset.d.ts +0 -130
- package/backend/dist/flywheel/dataset.js +0 -638
- package/backend/dist/flywheel/decision-capture.d.ts +0 -68
- package/backend/dist/flywheel/decision-capture.js +0 -85
- package/backend/dist/flywheel/prune.d.ts +0 -133
- package/backend/dist/flywheel/prune.js +0 -495
- package/backend/dist/flywheel/schema.d.ts +0 -108
- package/backend/dist/flywheel/schema.js +0 -117
- package/backend/dist/flywheel/trainer.d.ts +0 -84
- package/backend/dist/flywheel/trainer.js +0 -198
- package/backend/dist/opencode/catalog/custom-store.d.ts +0 -50
- package/backend/dist/opencode/catalog/custom-store.js +0 -144
- package/backend/dist/opencode/credentials/push.d.ts +0 -38
- package/backend/dist/opencode/credentials/push.js +0 -116
- package/backend/dist/opencode/credentials/reconcile.d.ts +0 -49
- package/backend/dist/opencode/credentials/reconcile.js +0 -216
- package/backend/dist/opencode/sync.d.ts +0 -29
- package/backend/dist/opencode/sync.js +0 -186
- package/backend/dist/pipeline/account-selection.d.ts +0 -101
- package/backend/dist/pipeline/account-selection.js +0 -112
- package/backend/dist/providers/systemone.d.ts +0 -29
- package/backend/dist/providers/systemone.js +0 -170
- package/backend/dist/ratelimit/duration.d.ts +0 -24
- package/backend/dist/ratelimit/duration.js +0 -43
- package/backend/dist/ratelimit/governance-runtime.d.ts +0 -121
- package/backend/dist/ratelimit/governance-runtime.js +0 -183
- package/backend/dist/ratelimit/index.d.ts +0 -4
- package/backend/dist/ratelimit/index.js +0 -4
- package/backend/dist/ratelimit/limiter.d.ts +0 -157
- package/backend/dist/ratelimit/limiter.js +0 -244
- package/backend/dist/ratelimit/sliding-window-counter.d.ts +0 -63
- package/backend/dist/ratelimit/sliding-window-counter.js +0 -103
- package/backend/dist/ratelimit/subject.d.ts +0 -26
- package/backend/dist/ratelimit/subject.js +0 -28
- package/backend/dist/resilience/account-state.d.ts +0 -84
- package/backend/dist/resilience/account-state.js +0 -228
- package/backend/dist/router/layer1-classifier.d.ts +0 -111
- package/backend/dist/router/layer1-classifier.js +0 -467
- package/backend/dist/router/layer2-judge.d.ts +0 -111
- package/backend/dist/router/layer2-judge.js +0 -373
- package/backend/dist/router/retry-escalation.d.ts +0 -89
- package/backend/dist/router/retry-escalation.js +0 -99
- package/backend/dist/routes/flywheel.d.ts +0 -3
- package/backend/dist/routes/flywheel.js +0 -268
- package/backend/dist/routes/systemone.d.ts +0 -3
- package/backend/dist/routes/systemone.js +0 -90
- package/backend/dist/surfaces/governance-envelope.d.ts +0 -34
- package/backend/dist/surfaces/governance-envelope.js +0 -47
- package/backend/dist/utils/token-estimator.d.ts +0 -7
- package/backend/dist/utils/token-estimator.js +0 -20
- package/frontend/dist/assets/index-nwgWkmU1.js +0 -840
|
@@ -897,6 +897,8 @@ const YAML_FIELD_COMMENTS = {
|
|
|
897
897
|
'modelProfiles.*.slots': '槽位表:槽位名 → modelRef(注册模型 id / 组合 id / auto / lite / plus / pro / ultra)',
|
|
898
898
|
'modelProfiles.*.note': '备注:仅控制台展示的自由文本,不参与路由',
|
|
899
899
|
clientProfileMemory: '控制台表单记忆(按环境保存):各客户端挂接表单上次选择的模型方案、槽位映射与模型列表模式(none=不设置(默认)/ custom=自定义 / follow=跟随所选 API Key 的权限),以及上次写入的 API Key id(apiKeyId;挂接总是写入所选 Key,不存明文),仅用于页面回填,不参与路由、也不影响实际接管配置',
|
|
900
|
+
defaultModels: '默认模型(网关自身内部调用花费的模型,不参与客户端路由)',
|
|
901
|
+
'defaultModels.translation': '控制台内部翻译(技能描述/README)使用的模型:填写网关可见的 modelRef(档位别名 lite/plus/pro/ultra 或已注册模型 id)。未设置 = lite;配置的模型失败降级到 lite,lite 也失败则如实报错——链条绝不自行升级到 auto(内部非关键调用不允许无上限花费;显式写 auto 视为运营者自担成本,照常生效)。可解析性在请求时校验(模型在启动时才注册);更换该值不使已缓存翻译失效(缓存按原文+语言键控,为派生数据)',
|
|
900
902
|
session: '会话粘性(棘轮:会话内模型不漂移)',
|
|
901
903
|
'session.strategy': '会话策略:monotonic 单调棘轮 / sticky 粘性 / stateless 无状态',
|
|
902
904
|
'session.ttlSeconds': '会话保持时长(秒)',
|
|
@@ -701,6 +701,27 @@ export interface RateLimitConfig {
|
|
|
701
701
|
/** Event-ledger persistence (see RateLimitPersistConfig). */
|
|
702
702
|
persist?: RateLimitPersistConfig;
|
|
703
703
|
}
|
|
704
|
+
/**
|
|
705
|
+
* Console-side default models — the picks the gateway itself spends on
|
|
706
|
+
* (internal calls, never client routing). One entry today: the translation
|
|
707
|
+
* model; the System One fallback stays on its own protocol-surface section
|
|
708
|
+
* (`systemone.defaultModel`).
|
|
709
|
+
*/
|
|
710
|
+
export interface DefaultModelsConfig {
|
|
711
|
+
/**
|
|
712
|
+
* ModelRef for the console's internal description/README translations
|
|
713
|
+
* (harness/translation.ts). Accepts any gateway-visible modelRef: a tier
|
|
714
|
+
* alias ('lite' | 'plus' | 'pro' | 'ultra') or a registered model id.
|
|
715
|
+
* Unset = the `lite` alias. The chain never escalates to `auto` ON ITS OWN
|
|
716
|
+
* (an internal, non-critical call must not have unbounded spend): a
|
|
717
|
+
* configured model that fails degrades to `lite`, and a failing `lite`
|
|
718
|
+
* errors honestly. Resolvability is checked at request time — models
|
|
719
|
+
* register at boot, so config load cannot validate the id. Cached
|
|
720
|
+
* translations are NOT invalidated by changing this (the store is derived
|
|
721
|
+
* data keyed by text+language; the serving model is recorded per entry).
|
|
722
|
+
*/
|
|
723
|
+
translation?: string;
|
|
724
|
+
}
|
|
704
725
|
export interface RouterConfig {
|
|
705
726
|
port: number;
|
|
706
727
|
host: string;
|
|
@@ -750,6 +771,8 @@ export interface RouterConfig {
|
|
|
750
771
|
credentials?: Record<string, CredentialLimitConfig[]>;
|
|
751
772
|
/** Per-client console form memory (see ClientProfileMemoryEntry) — UI-only, never routed. */
|
|
752
773
|
clientProfileMemory?: Record<string, ClientProfileMemoryEntry>;
|
|
774
|
+
/** Console-side default models (see DefaultModelsConfig) — gateway-internal spend picks. */
|
|
775
|
+
defaultModels?: DefaultModelsConfig;
|
|
753
776
|
/**
|
|
754
777
|
* Quota tracking: long-tail custom probe declarations keyed by
|
|
755
778
|
* provider id. Each entry carries a relative `url` (sanitized to stay inside
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineHost } from './declarative.js';
|
|
3
|
+
import { UNIVERSAL_SKILLS, xdgConfig } from './skills-paths.js';
|
|
4
|
+
/** Amp — own XDG skills directory (does not read `.agents`); no MCP or extension landing. */
|
|
5
|
+
export const ampAdapter = defineHost('amp', {
|
|
6
|
+
skills: { global: path.join(xdgConfig(), 'agents', 'skills'), project: UNIVERSAL_SKILLS.project },
|
|
7
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineHost } from './declarative.js';
|
|
3
|
+
import { home } from './skills-paths.js';
|
|
4
|
+
/** Claude Code — its own skills directory; no VERIFIED MCP or extension landing (§D2/§D8). */
|
|
5
|
+
export const claudeAdapter = defineHost('claude', {
|
|
6
|
+
skills: { global: path.join(home(), '.claude', 'skills'), project: path.join('.claude', 'skills') },
|
|
7
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { defineHost } from './declarative.js';
|
|
2
|
+
import { UNIVERSAL_SKILLS } from './skills-paths.js';
|
|
3
|
+
/** Cline — reads the shared cross-agent skills directory; no MCP or extension landing. */
|
|
4
|
+
export const clineAdapter = defineHost('cline', {
|
|
5
|
+
skills: { global: UNIVERSAL_SKILLS.global, project: UNIVERSAL_SKILLS.project, readsUniversal: true },
|
|
6
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { defineHost } from './declarative.js';
|
|
2
|
+
import { UNIVERSAL_SKILLS } from './skills-paths.js';
|
|
3
|
+
/** Codex — reads the shared cross-agent skills directory; no MCP or extension landing. */
|
|
4
|
+
export const codexAdapter = defineHost('codex', {
|
|
5
|
+
skills: { global: UNIVERSAL_SKILLS.global, project: UNIVERSAL_SKILLS.project, readsUniversal: true },
|
|
6
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor — skills in `.cursor/skills` plus the shared directory. Its extension model is owned by the
|
|
3
|
+
* editor's own marketplace, so no extension landing is declared until ADR-0015 §D8 verifies one.
|
|
4
|
+
*/
|
|
5
|
+
export declare const cursorAdapter: import("./declarative.js").DefinedHost;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineHost } from './declarative.js';
|
|
3
|
+
import { home, UNIVERSAL_SKILLS } from './skills-paths.js';
|
|
4
|
+
/**
|
|
5
|
+
* Cursor — skills in `.cursor/skills` plus the shared directory. Its extension model is owned by the
|
|
6
|
+
* editor's own marketplace, so no extension landing is declared until ADR-0015 §D8 verifies one.
|
|
7
|
+
*/
|
|
8
|
+
export const cursorAdapter = defineHost('cursor', {
|
|
9
|
+
skills: { global: path.join(home(), '.cursor', 'skills'), project: UNIVERSAL_SKILLS.project, readsUniversal: true },
|
|
10
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ExtensionHost, ExtensionSpec, HostAdapter, McpHost, SkillsHost, SkillsSpec } from './types.js';
|
|
2
|
+
import type { HarnessHostId } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The generic host implementations — every behaviour a host can have WITHOUT host-specific code
|
|
5
|
+
* (ADR-0015 §D3 R3, §D2, §D8.8).
|
|
6
|
+
*
|
|
7
|
+
* One `defineHost(id, spec)` per host file declares WHAT the runtime reads (skills dirs, an MCP
|
|
8
|
+
* config landing, an extension landing); the rules live here. That split keeps the two failure modes
|
|
9
|
+
* apart: a wrong PATH is a per-host data bug in one small file, a wrong RULE is a single
|
|
10
|
+
* implementation bug — they can never silently disagree with each other.
|
|
11
|
+
*
|
|
12
|
+
* Capabilities are separate interfaces (`SkillsHost` / `McpHost` / `ExtensionHost`), and `defineHost`
|
|
13
|
+
* only attaches the ones the spec asks for. Absence is therefore a TYPE fact: `cursor` cannot be
|
|
14
|
+
* handed to an MCP writer, and no host carries nine `unsupported` stubs.
|
|
15
|
+
*/
|
|
16
|
+
/** Normalize a `string | string[]` landing declaration; absent → empty. */
|
|
17
|
+
export declare function extPaths(value: string | string[] | undefined): string[];
|
|
18
|
+
/**
|
|
19
|
+
* The file a config landing WRITES.
|
|
20
|
+
*
|
|
21
|
+
* Reading may spread over the whole version ladder (v1 + v2 spellings), writing may not: the merge
|
|
22
|
+
* writer refuses a JSONC round-trip because it would drop the file's comments (§D8.2), so an existing
|
|
23
|
+
* plain-JSON candidate wins, then any existing candidate, then the first plain-JSON one, then the
|
|
24
|
+
* declared head. Resolution and default agree by construction — the historical defect this prevents
|
|
25
|
+
* is a writer landing in a file the next read would not prefer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function writeLanding(candidates: string[]): string;
|
|
28
|
+
/** What one host declares: the env root plus whichever capabilities it actually has. */
|
|
29
|
+
export interface HostSpec {
|
|
30
|
+
configRootEnv?: string;
|
|
31
|
+
skills?: SkillsSpec;
|
|
32
|
+
mcp?: {
|
|
33
|
+
configGlobal: string | string[];
|
|
34
|
+
configProject: string | string[];
|
|
35
|
+
container: string;
|
|
36
|
+
};
|
|
37
|
+
ext?: ExtensionSpec;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The composed host. `Partial<>` because a host genuinely lacks most capabilities: `dsh` has none of
|
|
41
|
+
* the three beyond identity, `cursor` has skills only. Callers narrow with the `is*Host` guards, so
|
|
42
|
+
* a capability can never be invoked without having been proved present.
|
|
43
|
+
*/
|
|
44
|
+
export type DefinedHost = HostAdapter & Partial<SkillsHost & McpHost & ExtensionHost>;
|
|
45
|
+
/**
|
|
46
|
+
* Build one host from its declarative spec. A spec naming a capability gets exactly those methods;
|
|
47
|
+
* naming none yields identity only (a measured "no landing", not a missing table row).
|
|
48
|
+
*/
|
|
49
|
+
export declare function defineHost(id: HarnessHostId, spec?: HostSpec): DefinedHost;
|
|
50
|
+
/**
|
|
51
|
+
* A host with ALL three capabilities (`opencode` today).
|
|
52
|
+
*
|
|
53
|
+
* The parameter type REQUIRES all three specs, so the widening cast below cannot claim a method the
|
|
54
|
+
* spec did not ask `defineHost` to build — the requirement is the proof, the cast only teaches the
|
|
55
|
+
* compiler what `Object.assign` already assembled at runtime.
|
|
56
|
+
*/
|
|
57
|
+
export declare function defineFullHost(id: HarnessHostId, spec: {
|
|
58
|
+
skills: SkillsSpec;
|
|
59
|
+
mcp: NonNullable<HostSpec['mcp']>;
|
|
60
|
+
ext: ExtensionSpec;
|
|
61
|
+
configRootEnv?: string;
|
|
62
|
+
}): SkillsHost & McpHost & ExtensionHost;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { UNIVERSAL_SKILLS } from './skills-paths.js';
|
|
4
|
+
/**
|
|
5
|
+
* The generic host implementations — every behaviour a host can have WITHOUT host-specific code
|
|
6
|
+
* (ADR-0015 §D3 R3, §D2, §D8.8).
|
|
7
|
+
*
|
|
8
|
+
* One `defineHost(id, spec)` per host file declares WHAT the runtime reads (skills dirs, an MCP
|
|
9
|
+
* config landing, an extension landing); the rules live here. That split keeps the two failure modes
|
|
10
|
+
* apart: a wrong PATH is a per-host data bug in one small file, a wrong RULE is a single
|
|
11
|
+
* implementation bug — they can never silently disagree with each other.
|
|
12
|
+
*
|
|
13
|
+
* Capabilities are separate interfaces (`SkillsHost` / `McpHost` / `ExtensionHost`), and `defineHost`
|
|
14
|
+
* only attaches the ones the spec asks for. Absence is therefore a TYPE fact: `cursor` cannot be
|
|
15
|
+
* handed to an MCP writer, and no host carries nine `unsupported` stubs.
|
|
16
|
+
*/
|
|
17
|
+
/** Normalize a `string | string[]` landing declaration; absent → empty. */
|
|
18
|
+
export function extPaths(value) {
|
|
19
|
+
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The file a config landing WRITES.
|
|
23
|
+
*
|
|
24
|
+
* Reading may spread over the whole version ladder (v1 + v2 spellings), writing may not: the merge
|
|
25
|
+
* writer refuses a JSONC round-trip because it would drop the file's comments (§D8.2), so an existing
|
|
26
|
+
* plain-JSON candidate wins, then any existing candidate, then the first plain-JSON one, then the
|
|
27
|
+
* declared head. Resolution and default agree by construction — the historical defect this prevents
|
|
28
|
+
* is a writer landing in a file the next read would not prefer.
|
|
29
|
+
*/
|
|
30
|
+
export function writeLanding(candidates) {
|
|
31
|
+
const plain = candidates.filter((p) => path.extname(p).toLowerCase() !== '.jsonc');
|
|
32
|
+
return (plain.find((p) => fs.existsSync(p)) ??
|
|
33
|
+
candidates.find((p) => fs.existsSync(p)) ??
|
|
34
|
+
plain[0] ??
|
|
35
|
+
candidates[0]);
|
|
36
|
+
}
|
|
37
|
+
/** Skill names are directory names: lowercase, dash-separated, no path segments. */
|
|
38
|
+
const SKILL_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
39
|
+
function buildSkills(id, spec, configRootEnv) {
|
|
40
|
+
const roots = (ctx, scope) => {
|
|
41
|
+
if (scope === 'project') {
|
|
42
|
+
return [{ root: path.resolve(ctx.projectRoot, spec.project), origin: 'default', precedence: 0 }];
|
|
43
|
+
}
|
|
44
|
+
const out = [];
|
|
45
|
+
const override = configRootEnv ? process.env[configRootEnv]?.trim() : undefined;
|
|
46
|
+
if (override) {
|
|
47
|
+
out.push({ root: path.join(path.resolve(override), 'skills'), origin: 'env-override', precedence: 0 });
|
|
48
|
+
}
|
|
49
|
+
out.push({ root: spec.global, origin: 'default', precedence: out.length });
|
|
50
|
+
// A runtime that reads `.agents` also sees a copy materialized there — the cross-agent directory
|
|
51
|
+
// is REFERENCED from its single declaration (skills-paths), never re-spelled per host.
|
|
52
|
+
if (spec.readsUniversal && !out.some((r) => r.root === UNIVERSAL_SKILLS.global)) {
|
|
53
|
+
out.push({ root: UNIVERSAL_SKILLS.global, origin: 'default', precedence: out.length });
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
...(configRootEnv ? { configRootEnv } : {}),
|
|
60
|
+
readsUniversalSkills: spec.readsUniversal === true,
|
|
61
|
+
skillRoots: roots,
|
|
62
|
+
skillTarget(ctx, scope, name) {
|
|
63
|
+
const candidates = roots(ctx, scope);
|
|
64
|
+
if (candidates.length === 0)
|
|
65
|
+
return { ok: false, reason: `host '${id}' has no skills location` };
|
|
66
|
+
if (!SKILL_NAME.test(name))
|
|
67
|
+
return { ok: false, reason: `invalid skill name '${name}'` };
|
|
68
|
+
const root = candidates[0];
|
|
69
|
+
const target = path.resolve(root.root, name);
|
|
70
|
+
const rel = path.relative(root.root, target);
|
|
71
|
+
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) {
|
|
72
|
+
return { ok: false, reason: 'target escapes its root' };
|
|
73
|
+
}
|
|
74
|
+
return { ok: true, root, path: target };
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function buildMcp(id, spec, configRootEnv) {
|
|
79
|
+
return {
|
|
80
|
+
id,
|
|
81
|
+
...(configRootEnv ? { configRootEnv } : {}),
|
|
82
|
+
container: spec.container,
|
|
83
|
+
configPath(ctx, scope) {
|
|
84
|
+
const declared = scope === 'project'
|
|
85
|
+
? extPaths(spec.configProject).map((p) => path.resolve(ctx.projectRoot, p))
|
|
86
|
+
: extPaths(spec.configGlobal);
|
|
87
|
+
if (declared.length === 0) {
|
|
88
|
+
return { ok: false, reason: `host '${id}' declares no MCP landing for ${scope} scope` };
|
|
89
|
+
}
|
|
90
|
+
// A ladder exists for the same reason extensions have one: a runtime may have moved its file.
|
|
91
|
+
return { ok: true, path: declared.find((p) => fs.existsSync(p)) ?? declared[0] };
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function buildExtension(id, spec, configRootEnv) {
|
|
96
|
+
const configCandidates = (ctx, scope) => {
|
|
97
|
+
if (!spec.container)
|
|
98
|
+
return [];
|
|
99
|
+
const declared = scope === 'project' ? extPaths(spec.configProject) : extPaths(spec.configGlobal);
|
|
100
|
+
// A global landing is already absolute; a project landing is declared relative to the project.
|
|
101
|
+
return scope === 'global' ? declared : declared.map((p) => path.resolve(ctx.projectRoot, p));
|
|
102
|
+
};
|
|
103
|
+
const looseDirs = (ctx, scope) => {
|
|
104
|
+
const declared = extPaths(scope === 'project' ? spec.looseDir?.project : spec.looseDir?.global);
|
|
105
|
+
return declared.map((p) => (path.isAbsolute(p) ? p : path.resolve(ctx.projectRoot, p)));
|
|
106
|
+
};
|
|
107
|
+
const declarations = () => {
|
|
108
|
+
if (!spec.declared)
|
|
109
|
+
return [];
|
|
110
|
+
return extPaths(spec.declared.global).map((file) => ({ file, key: spec.declared.key }));
|
|
111
|
+
};
|
|
112
|
+
const containers = () => spec.container ? [spec.container, ...(spec.containerAliases ?? [])] : [];
|
|
113
|
+
return {
|
|
114
|
+
id,
|
|
115
|
+
...(configRootEnv ? { configRootEnv } : {}),
|
|
116
|
+
containers,
|
|
117
|
+
declarations,
|
|
118
|
+
lock: () => spec.lock,
|
|
119
|
+
looseDirs,
|
|
120
|
+
readSources(ctx, scope) {
|
|
121
|
+
const out = [];
|
|
122
|
+
if (spec.subprocess) {
|
|
123
|
+
// A package-manager landing is a GLOBAL record (the runtime's own store has no project
|
|
124
|
+
// scope): the declaration file lists the specs, the lock file answers their versions.
|
|
125
|
+
for (const declaration of declarations()) {
|
|
126
|
+
out.push({
|
|
127
|
+
host: id,
|
|
128
|
+
scope: 'global',
|
|
129
|
+
origin: 'runtime-store',
|
|
130
|
+
kind: 'declared',
|
|
131
|
+
path: declaration.file,
|
|
132
|
+
key: declaration.key,
|
|
133
|
+
...(spec.lock ? { lockPath: spec.lock } : {}),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (containers().length > 0) {
|
|
138
|
+
// A config landing is discoverable by construction: the array the writer merges into IS the
|
|
139
|
+
// record. Every spelling in the version ladder is read, write landing first so the writer's
|
|
140
|
+
// preference wins the dedupe while the fallbacks still surface rows it would not have written.
|
|
141
|
+
const candidates = configCandidates(ctx, scope);
|
|
142
|
+
if (candidates.length > 0) {
|
|
143
|
+
const write = writeLanding(candidates);
|
|
144
|
+
const ordered = [write, ...candidates.filter((p) => p !== write)];
|
|
145
|
+
for (const file of ordered) {
|
|
146
|
+
out.push({
|
|
147
|
+
host: id,
|
|
148
|
+
scope,
|
|
149
|
+
origin: 'config-array',
|
|
150
|
+
kind: 'config-array',
|
|
151
|
+
path: file,
|
|
152
|
+
key: containers(),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Loose files are loaded from disk with no package at all — declared for every scope the host
|
|
158
|
+
// loads them from, config-array hosts included (`opencode` reads `plugins/*.ts` directly).
|
|
159
|
+
for (const dir of looseDirs(ctx, scope)) {
|
|
160
|
+
out.push({ host: id, scope, origin: 'local-file', kind: 'loose-dir', path: dir });
|
|
161
|
+
}
|
|
162
|
+
return out;
|
|
163
|
+
},
|
|
164
|
+
writeTarget(ctx, scope) {
|
|
165
|
+
if (spec.subprocess)
|
|
166
|
+
return { ok: true, op: 'subprocess', command: spec.subprocess };
|
|
167
|
+
const candidates = configCandidates(ctx, scope);
|
|
168
|
+
if (candidates.length === 0) {
|
|
169
|
+
return { ok: false, reason: `host '${id}' declares no extension config landing` };
|
|
170
|
+
}
|
|
171
|
+
return { ok: true, op: 'config', path: writeLanding(candidates), container: containers()[0] };
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Build one host from its declarative spec. A spec naming a capability gets exactly those methods;
|
|
177
|
+
* naming none yields identity only (a measured "no landing", not a missing table row).
|
|
178
|
+
*/
|
|
179
|
+
export function defineHost(id, spec = {}) {
|
|
180
|
+
const parts = [];
|
|
181
|
+
if (spec.skills)
|
|
182
|
+
parts.push(buildSkills(id, spec.skills, spec.configRootEnv));
|
|
183
|
+
if (spec.mcp)
|
|
184
|
+
parts.push(buildMcp(id, spec.mcp, spec.configRootEnv));
|
|
185
|
+
if (spec.ext)
|
|
186
|
+
parts.push(buildExtension(id, spec.ext, spec.configRootEnv));
|
|
187
|
+
const base = {
|
|
188
|
+
id,
|
|
189
|
+
...(spec.configRootEnv ? { configRootEnv: spec.configRootEnv } : {}),
|
|
190
|
+
};
|
|
191
|
+
return Object.assign(base, ...parts);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A host with ALL three capabilities (`opencode` today).
|
|
195
|
+
*
|
|
196
|
+
* The parameter type REQUIRES all three specs, so the widening cast below cannot claim a method the
|
|
197
|
+
* spec did not ask `defineHost` to build — the requirement is the proof, the cast only teaches the
|
|
198
|
+
* compiler what `Object.assign` already assembled at runtime.
|
|
199
|
+
*/
|
|
200
|
+
export function defineFullHost(id, spec) {
|
|
201
|
+
return defineHost(id, spec);
|
|
202
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH — relocated by `DSH_HOME`; NO skills location (`skills: null` in the old catalog) and no
|
|
3
|
+
* verified MCP or extension landing. Identity + env root only, which is the honest surface.
|
|
4
|
+
*/
|
|
5
|
+
export declare const dshAdapter: import("./declarative.js").DefinedHost;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { defineHost } from './declarative.js';
|
|
2
|
+
/**
|
|
3
|
+
* DSH — relocated by `DSH_HOME`; NO skills location (`skills: null` in the old catalog) and no
|
|
4
|
+
* verified MCP or extension landing. Identity + env root only, which is the honest surface.
|
|
5
|
+
*/
|
|
6
|
+
export const dshAdapter = defineHost('dsh', { configRootEnv: 'DSH_HOME' });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineHost } from './declarative.js';
|
|
3
|
+
import { home, UNIVERSAL_SKILLS } from './skills-paths.js';
|
|
4
|
+
/** Gemini CLI — own skills directory plus the shared one; no MCP or extension landing. */
|
|
5
|
+
export const geminiCliAdapter = defineHost('gemini-cli', {
|
|
6
|
+
skills: { global: path.join(home(), '.gemini', 'skills'), project: UNIVERSAL_SKILLS.project, readsUniversal: true },
|
|
7
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { defineHost } from './declarative.js';
|
|
3
|
+
import { home, UNIVERSAL_SKILLS } from './skills-paths.js';
|
|
4
|
+
/**
|
|
5
|
+
* GitHub Copilot / VS Code — skills only: the VS Code extension model is vendor-owned and no MCP
|
|
6
|
+
* landing is verified for this host.
|
|
7
|
+
*/
|
|
8
|
+
export const githubCopilotAdapter = defineHost('github-copilot', {
|
|
9
|
+
skills: { global: path.join(home(), '.copilot', 'skills'), project: UNIVERSAL_SKILLS.project, readsUniversal: true },
|
|
10
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { HarnessHostId, HarnessScope } from '../types.js';
|
|
2
|
+
import type { HostAdapter } from './types.js';
|
|
3
|
+
export { isExtensionHost, isMcpHost, isSkillsHost } from './types.js';
|
|
4
|
+
export type { AdapterContext, ExtensionHost, ExtensionSpec, ExtensionWriteTarget, ExtSource, HostAdapter, McpHost, SkillsHost, SkillsSpec, } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* The adapter registry — one entry per host in `HOSTS`, SAME ORDER (a test asserts the parity, so a
|
|
7
|
+
* new host cannot be added to the catalog without an adapter, nor removed unnoticed).
|
|
8
|
+
*
|
|
9
|
+
* Order is semantic: it decides (a) which host OWNS a shared skills directory (`skillOwner`) and
|
|
10
|
+
* (b) which adapter answers first for a discovered `(host, canonicalKey)` pair.
|
|
11
|
+
*/
|
|
12
|
+
export declare const HOST_ADAPTERS: readonly HostAdapter[];
|
|
13
|
+
/** The adapter for one host, or `undefined` for an id the catalog does not know. */
|
|
14
|
+
export declare function adapterFor(id: HarnessHostId | string): HostAdapter | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Every physical skills directory the adapters resolve, deduplicated.
|
|
17
|
+
*
|
|
18
|
+
* One directory is ONE copy: nine hosts share `.agents/skills`, so the FIRST adapter in registry
|
|
19
|
+
* order is the owner and every other host is an alias — installation, the inventory scan and the
|
|
20
|
+
* console all use this rule, otherwise the same directory gets labeled two different ways.
|
|
21
|
+
*/
|
|
22
|
+
export declare function skillLocationRoots(projectRoot?: string): {
|
|
23
|
+
host: HarnessHostId;
|
|
24
|
+
scope: HarnessScope;
|
|
25
|
+
root: string;
|
|
26
|
+
}[];
|
|
27
|
+
/** The skills roots one host resolves for a scope; empty for a host with no skills capability. */
|
|
28
|
+
export declare function skillRootsFor(host: HarnessHostId, scope: HarnessScope, projectRoot?: string): {
|
|
29
|
+
root: string;
|
|
30
|
+
origin: string;
|
|
31
|
+
precedence: number;
|
|
32
|
+
}[];
|
|
33
|
+
/** The host that OWNS a physical skills directory (first adapter in registry order). */
|
|
34
|
+
export declare function skillOwner(root: string, scope: HarnessScope, projectRoot?: string): HarnessHostId | null;
|
|
35
|
+
/**
|
|
36
|
+
* Every host that READS a physical skills directory — the inverse of `skillOwner`.
|
|
37
|
+
*
|
|
38
|
+
* One directory can be read by several runtimes without being written twice: the cross-agent
|
|
39
|
+
* `.agents/skills` root is materialized once and every `readsUniversal` host sees it. Ownership
|
|
40
|
+
* answers "who owns this copy" (install, claims, removal); reading answers "who can USE it" (the
|
|
41
|
+
* console's harness rail on the skills page). Collapsing the two is what makes a shared directory
|
|
42
|
+
* look empty for the eight runtimes that read it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function skillReaders(root: string, scope: HarnessScope, projectRoot?: string): HarnessHostId[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { ampAdapter } from './amp.js';
|
|
3
|
+
import { claudeAdapter } from './claude.js';
|
|
4
|
+
import { clineAdapter } from './cline.js';
|
|
5
|
+
import { codexAdapter } from './codex.js';
|
|
6
|
+
import { cursorAdapter } from './cursor.js';
|
|
7
|
+
import { dshAdapter } from './dsh.js';
|
|
8
|
+
import { geminiCliAdapter } from './gemini-cli.js';
|
|
9
|
+
import { githubCopilotAdapter } from './github-copilot.js';
|
|
10
|
+
import { opencodeAdapter } from './opencode.js';
|
|
11
|
+
import { piAdapter } from './pi.js';
|
|
12
|
+
import { universalAdapter } from './universal.js';
|
|
13
|
+
import { windsurfAdapter } from './windsurf.js';
|
|
14
|
+
import { zedAdapter } from './zed.js';
|
|
15
|
+
import { isSkillsHost } from './types.js';
|
|
16
|
+
export { isExtensionHost, isMcpHost, isSkillsHost } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* The adapter registry — one entry per host in `HOSTS`, SAME ORDER (a test asserts the parity, so a
|
|
19
|
+
* new host cannot be added to the catalog without an adapter, nor removed unnoticed).
|
|
20
|
+
*
|
|
21
|
+
* Order is semantic: it decides (a) which host OWNS a shared skills directory (`skillOwner`) and
|
|
22
|
+
* (b) which adapter answers first for a discovered `(host, canonicalKey)` pair.
|
|
23
|
+
*/
|
|
24
|
+
export const HOST_ADAPTERS = [
|
|
25
|
+
universalAdapter,
|
|
26
|
+
opencodeAdapter,
|
|
27
|
+
claudeAdapter,
|
|
28
|
+
codexAdapter,
|
|
29
|
+
piAdapter,
|
|
30
|
+
dshAdapter,
|
|
31
|
+
cursorAdapter,
|
|
32
|
+
githubCopilotAdapter,
|
|
33
|
+
geminiCliAdapter,
|
|
34
|
+
clineAdapter,
|
|
35
|
+
ampAdapter,
|
|
36
|
+
windsurfAdapter,
|
|
37
|
+
zedAdapter,
|
|
38
|
+
];
|
|
39
|
+
const BY_ID = new Map(HOST_ADAPTERS.map((adapter) => [adapter.id, adapter]));
|
|
40
|
+
/** The adapter for one host, or `undefined` for an id the catalog does not know. */
|
|
41
|
+
export function adapterFor(id) {
|
|
42
|
+
return BY_ID.get(id);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Every physical skills directory the adapters resolve, deduplicated.
|
|
46
|
+
*
|
|
47
|
+
* One directory is ONE copy: nine hosts share `.agents/skills`, so the FIRST adapter in registry
|
|
48
|
+
* order is the owner and every other host is an alias — installation, the inventory scan and the
|
|
49
|
+
* console all use this rule, otherwise the same directory gets labeled two different ways.
|
|
50
|
+
*/
|
|
51
|
+
export function skillLocationRoots(projectRoot = process.cwd()) {
|
|
52
|
+
const ctx = { projectRoot };
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
const out = [];
|
|
55
|
+
for (const adapter of HOST_ADAPTERS) {
|
|
56
|
+
if (!isSkillsHost(adapter))
|
|
57
|
+
continue;
|
|
58
|
+
for (const scope of ['global', 'project']) {
|
|
59
|
+
for (const resolved of adapter.skillRoots(ctx, scope)) {
|
|
60
|
+
if (seen.has(resolved.root))
|
|
61
|
+
continue;
|
|
62
|
+
seen.add(resolved.root);
|
|
63
|
+
out.push({ host: adapter.id, scope, root: resolved.root });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
/** The skills roots one host resolves for a scope; empty for a host with no skills capability. */
|
|
70
|
+
export function skillRootsFor(host, scope, projectRoot = process.cwd()) {
|
|
71
|
+
const adapter = adapterFor(host);
|
|
72
|
+
return isSkillsHost(adapter) ? adapter.skillRoots({ projectRoot }, scope) : [];
|
|
73
|
+
}
|
|
74
|
+
/** The host that OWNS a physical skills directory (first adapter in registry order). */
|
|
75
|
+
export function skillOwner(root, scope, projectRoot = process.cwd()) {
|
|
76
|
+
return skillReaders(root, scope, projectRoot)[0] ?? null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Every host that READS a physical skills directory — the inverse of `skillOwner`.
|
|
80
|
+
*
|
|
81
|
+
* One directory can be read by several runtimes without being written twice: the cross-agent
|
|
82
|
+
* `.agents/skills` root is materialized once and every `readsUniversal` host sees it. Ownership
|
|
83
|
+
* answers "who owns this copy" (install, claims, removal); reading answers "who can USE it" (the
|
|
84
|
+
* console's harness rail on the skills page). Collapsing the two is what makes a shared directory
|
|
85
|
+
* look empty for the eight runtimes that read it.
|
|
86
|
+
*/
|
|
87
|
+
export function skillReaders(root, scope, projectRoot = process.cwd()) {
|
|
88
|
+
const abs = path.resolve(root);
|
|
89
|
+
const ctx = { projectRoot };
|
|
90
|
+
const out = [];
|
|
91
|
+
for (const adapter of HOST_ADAPTERS) {
|
|
92
|
+
if (!isSkillsHost(adapter))
|
|
93
|
+
continue;
|
|
94
|
+
if (adapter.skillRoots(ctx, scope).some((resolved) => path.resolve(resolved.root) === abs)) {
|
|
95
|
+
out.push(adapter.id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { opencodeConfigCandidates, resolveDefaultPaths } from '../../opencode/credentials/paths.js';
|
|
3
|
+
import { defineFullHost } from './declarative.js';
|
|
4
|
+
import { UNIVERSAL_SKILLS, xdgConfig } from './skills-paths.js';
|
|
5
|
+
/**
|
|
6
|
+
* OpenCode — the only host with all three capabilities (ADR-0015 §D2, §D8.8).
|
|
7
|
+
*
|
|
8
|
+
* SKILLS: `<configRoot>/skills`, plus the shared `.agents/skills` directory (project scope IS
|
|
9
|
+
* `.agents/skills`). `OPENCODE_CONFIG_DIR` relocates the config root.
|
|
10
|
+
*
|
|
11
|
+
* MCP: servers merge into `opencode.json`. v2 also reads `opencode.jsonc`, but moving the MCP write
|
|
12
|
+
* target is an ADR-0010/§D2 decision with its own blast radius, not an adapter refactor.
|
|
13
|
+
*
|
|
14
|
+
* EXTENSIONS: two majors disagree about BOTH spellings, and a gateway has to serve either install:
|
|
15
|
+
*
|
|
16
|
+
* | | config file | plugin key | loose plugin dir |
|
|
17
|
+
* | :--- | :--- | :--- | :--- |
|
|
18
|
+
* | v2 | `opencode.jsonc` | `plugins` | `plugins/` |
|
|
19
|
+
* | v1 | `opencode.json` | `plugin` | `plugin/` |
|
|
20
|
+
*
|
|
21
|
+
* So the read ladder carries all three config candidates (v2 jsonc, v1 json, legacy `~/.opencode`),
|
|
22
|
+
* the container list carries both keys, and the loose-dir ladder carries both directories. The write
|
|
23
|
+
* landing stays plain JSON: the merge writer refuses a JSONC round-trip (§D8.2), so an install can
|
|
24
|
+
* never silently eat the operator's comments.
|
|
25
|
+
*
|
|
26
|
+
* The config ladder is NOT restated here — `opencodeConfigCandidates` is the credential layer's
|
|
27
|
+
* single candidate table (ADR-0006/0010) and already honours `OPENCODE_CONFIG_DIR`.
|
|
28
|
+
*/
|
|
29
|
+
const CONFIG_CANDIDATES = opencodeConfigCandidates(resolveDefaultPaths());
|
|
30
|
+
const CONFIG_DIR = path.dirname(CONFIG_CANDIDATES[0]);
|
|
31
|
+
// The spec declares all three capabilities; `defineFullHost`'s parameter type makes that a compile-
|
|
32
|
+
// time requirement rather than a comment.
|
|
33
|
+
export const opencodeAdapter = defineFullHost('opencode', {
|
|
34
|
+
configRootEnv: 'OPENCODE_CONFIG_DIR',
|
|
35
|
+
skills: {
|
|
36
|
+
global: path.join(xdgConfig(), 'opencode', 'skills'),
|
|
37
|
+
project: UNIVERSAL_SKILLS.project,
|
|
38
|
+
readsUniversal: true,
|
|
39
|
+
},
|
|
40
|
+
mcp: {
|
|
41
|
+
configGlobal: [path.join(CONFIG_DIR, 'opencode.json')],
|
|
42
|
+
configProject: ['opencode.json'],
|
|
43
|
+
container: 'mcp',
|
|
44
|
+
},
|
|
45
|
+
ext: {
|
|
46
|
+
configGlobal: CONFIG_CANDIDATES,
|
|
47
|
+
configProject: ['opencode.json', 'opencode.jsonc'],
|
|
48
|
+
container: 'plugin',
|
|
49
|
+
containerAliases: ['plugins'],
|
|
50
|
+
looseDir: {
|
|
51
|
+
global: [path.join(CONFIG_DIR, 'plugins'), path.join(CONFIG_DIR, 'plugin')],
|
|
52
|
+
project: ['.opencode/plugin', '.opencode/plugins'],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const piAdapter: import("./declarative.js").DefinedHost;
|