@kirkchinese/harness-forge 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/README.md +46 -2
- package/assets/icon.svg +12 -0
- package/cordis.patch.yml +28 -0
- package/docs/DETAIL.zh.md +47 -0
- package/lib/agents/presets.d.ts +98 -0
- package/lib/agents/presets.js +292 -0
- package/lib/agents/profiles.d.ts +58 -0
- package/lib/agents/profiles.js +279 -0
- package/lib/agents/row.d.ts +17 -0
- package/lib/agents/row.js +148 -0
- package/lib/client/paths.d.ts +12 -0
- package/lib/client/paths.js +68 -0
- package/lib/client/styles.d.ts +8 -0
- package/lib/client/styles.js +89 -0
- package/lib/client/typert.d.ts +25 -0
- package/lib/client/typert.js +158 -0
- package/lib/client.js +23823 -0
- package/lib/commands/definition.d.ts +40 -0
- package/lib/commands/definition.js +113 -0
- package/lib/commands/output-styles.d.ts +42 -0
- package/lib/commands/output-styles.js +152 -0
- package/lib/commands/row.d.ts +9 -0
- package/lib/commands/row.js +157 -0
- package/lib/context/instructions.d.ts +32 -0
- package/lib/context/instructions.js +88 -0
- package/lib/context/row.d.ts +16 -0
- package/lib/context/row.js +17 -0
- package/lib/dsh/commands.d.ts +30 -0
- package/lib/dsh/commands.js +61 -0
- package/lib/dsh/host.d.ts +110 -0
- package/lib/dsh/host.js +217 -0
- package/lib/dsh/model-route.d.ts +21 -0
- package/lib/dsh/model-route.js +37 -0
- package/lib/dsh/session-records.d.ts +78 -0
- package/lib/dsh/session-records.js +36 -0
- package/lib/dsh/subagents.d.ts +46 -0
- package/lib/dsh/subagents.js +14 -0
- package/lib/forge/contract.d.ts +271 -0
- package/lib/forge/contract.js +45 -0
- package/lib/forge/follow.d.ts +30 -0
- package/lib/forge/follow.js +73 -0
- package/lib/forge/ledger.d.ts +206 -0
- package/lib/forge/ledger.js +1005 -0
- package/lib/forge/live-mounts.d.ts +45 -0
- package/lib/forge/live-mounts.js +78 -0
- package/lib/forge/npm.d.ts +31 -0
- package/lib/forge/npm.js +60 -0
- package/lib/forge/projects.d.ts +97 -0
- package/lib/forge/projects.js +343 -0
- package/lib/forge/receipts.d.ts +5 -0
- package/lib/forge/receipts.js +31 -0
- package/lib/forge/remote/archive.d.ts +65 -0
- package/lib/forge/remote/archive.js +565 -0
- package/lib/forge/remote/code-parts.d.ts +18 -0
- package/lib/forge/remote/code-parts.js +76 -0
- package/lib/forge/remote/fetch.d.ts +265 -0
- package/lib/forge/remote/fetch.js +1133 -0
- package/lib/forge/remote/service.d.ts +256 -0
- package/lib/forge/remote/service.js +868 -0
- package/lib/forge/row.d.ts +32 -0
- package/lib/forge/row.js +59 -0
- package/lib/forge/service.d.ts +115 -0
- package/lib/forge/service.js +290 -0
- package/lib/forge/settings.d.ts +43 -0
- package/lib/forge/settings.js +122 -0
- package/lib/forge/state.d.ts +129 -0
- package/lib/forge/state.js +266 -0
- package/lib/forge/trust.d.ts +48 -0
- package/lib/forge/trust.js +107 -0
- package/lib/forge/turns.d.ts +13 -0
- package/lib/forge/turns.js +56 -0
- package/lib/hooks/broker/engine.d.ts +112 -0
- package/lib/hooks/broker/engine.js +722 -0
- package/lib/hooks/broker/helpers.d.ts +10 -0
- package/lib/hooks/broker/helpers.js +22 -0
- package/lib/hooks/broker/lifecycle.d.ts +65 -0
- package/lib/hooks/broker/lifecycle.js +342 -0
- package/lib/hooks/broker/session-events.d.ts +27 -0
- package/lib/hooks/broker/session-events.js +205 -0
- package/lib/hooks/broker/tools.d.ts +52 -0
- package/lib/hooks/broker/tools.js +424 -0
- package/lib/hooks/broker/types.d.ts +264 -0
- package/lib/hooks/broker/types.js +1 -0
- package/lib/hooks/broker.d.ts +80 -0
- package/lib/hooks/broker.js +95 -0
- package/lib/hooks/codex-user.d.ts +5 -0
- package/lib/hooks/codex-user.js +109 -0
- package/lib/hooks/condition.d.ts +87 -0
- package/lib/hooks/condition.js +602 -0
- package/lib/hooks/config.d.ts +85 -0
- package/lib/hooks/config.js +154 -0
- package/lib/hooks/glob.d.ts +41 -0
- package/lib/hooks/glob.js +114 -0
- package/lib/hooks/matcher.d.ts +20 -0
- package/lib/hooks/matcher.js +39 -0
- package/lib/hooks/notice.d.ts +17 -0
- package/lib/hooks/notice.js +39 -0
- package/lib/hooks/output.d.ts +56 -0
- package/lib/hooks/output.js +214 -0
- package/lib/hooks/permissions.d.ts +19 -0
- package/lib/hooks/permissions.js +202 -0
- package/lib/hooks/powershell-aliases.d.ts +19 -0
- package/lib/hooks/powershell-aliases.js +58 -0
- package/lib/hooks/process.d.ts +64 -0
- package/lib/hooks/process.js +289 -0
- package/lib/hooks/row.d.ts +17 -0
- package/lib/hooks/row.js +96 -0
- package/lib/hooks/runner.d.ts +98 -0
- package/lib/hooks/runner.js +322 -0
- package/lib/hooks/shell-commands.d.ts +28 -0
- package/lib/hooks/shell-commands.js +241 -0
- package/lib/hooks/shell.d.ts +44 -0
- package/lib/hooks/shell.js +129 -0
- package/lib/hooks/transcript.d.ts +28 -0
- package/lib/hooks/transcript.js +141 -0
- package/lib/hooks/vocabulary.d.ts +57 -0
- package/lib/hooks/vocabulary.js +366 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +287 -0
- package/lib/mcp/auth.d.ts +35 -0
- package/lib/mcp/auth.js +178 -0
- package/lib/mcp/catalog.d.ts +39 -0
- package/lib/mcp/catalog.js +69 -0
- package/lib/mcp/mount.d.ts +113 -0
- package/lib/mcp/mount.js +317 -0
- package/lib/mcp/policy.d.ts +42 -0
- package/lib/mcp/policy.js +43 -0
- package/lib/mcp/remote.d.ts +45 -0
- package/lib/mcp/remote.js +133 -0
- package/lib/mcp/row.d.ts +9 -0
- package/lib/mcp/row.js +225 -0
- package/lib/mods/bundler.d.ts +38 -0
- package/lib/mods/bundler.js +157 -0
- package/lib/mods/chain.d.ts +103 -0
- package/lib/mods/chain.js +436 -0
- package/lib/mods/claude.d.ts +27 -0
- package/lib/mods/claude.js +56 -0
- package/lib/mods/engine.d.ts +160 -0
- package/lib/mods/engine.js +701 -0
- package/lib/mods/expect.d.ts +8 -0
- package/lib/mods/expect.js +248 -0
- package/lib/mods/host.d.ts +105 -0
- package/lib/mods/host.js +462 -0
- package/lib/mods/loader.d.ts +53 -0
- package/lib/mods/loader.js +231 -0
- package/lib/mods/ops.d.ts +13 -0
- package/lib/mods/ops.js +117 -0
- package/lib/mods/row.d.ts +9 -0
- package/lib/mods/row.js +77 -0
- package/lib/mods/runtime.d.ts +60 -0
- package/lib/mods/runtime.js +133 -0
- package/lib/mods/service/commands.d.ts +17 -0
- package/lib/mods/service/commands.js +121 -0
- package/lib/mods/service/drawings.d.ts +36 -0
- package/lib/mods/service/drawings.js +64 -0
- package/lib/mods/service/sessions.d.ts +63 -0
- package/lib/mods/service/sessions.js +345 -0
- package/lib/mods/service/tools.d.ts +32 -0
- package/lib/mods/service/tools.js +253 -0
- package/lib/mods/service/turns.d.ts +33 -0
- package/lib/mods/service/turns.js +136 -0
- package/lib/mods/service/types.d.ts +151 -0
- package/lib/mods/service/types.js +1 -0
- package/lib/mods/service.d.ts +72 -0
- package/lib/mods/service.js +104 -0
- package/lib/mods/surfaces.d.ts +93 -0
- package/lib/mods/surfaces.js +309 -0
- package/lib/mods/values.d.ts +30 -0
- package/lib/mods/values.js +95 -0
- package/lib/opencode/bun.d.ts +40 -0
- package/lib/opencode/bun.js +168 -0
- package/lib/opencode/convert.d.ts +53 -0
- package/lib/opencode/convert.js +255 -0
- package/lib/opencode/row.d.ts +22 -0
- package/lib/opencode/row.js +104 -0
- package/lib/opencode/runtime/core.d.ts +74 -0
- package/lib/opencode/runtime/core.js +249 -0
- package/lib/opencode/runtime/events.d.ts +80 -0
- package/lib/opencode/runtime/events.js +281 -0
- package/lib/opencode/runtime/mount.d.ts +27 -0
- package/lib/opencode/runtime/mount.js +283 -0
- package/lib/opencode/runtime/server.d.ts +27 -0
- package/lib/opencode/runtime/server.js +354 -0
- package/lib/opencode/runtime/types.d.ts +109 -0
- package/lib/opencode/runtime/types.js +1 -0
- package/lib/opencode/runtime.d.ts +55 -0
- package/lib/opencode/runtime.js +79 -0
- package/lib/porting/adapter-paths.d.ts +13 -0
- package/lib/porting/adapter-paths.js +120 -0
- package/lib/porting/port-gap.d.ts +36 -0
- package/lib/porting/port-gap.js +158 -0
- package/lib/porting/port-sessions.d.ts +41 -0
- package/lib/porting/port-sessions.js +98 -0
- package/lib/porting/prompt.d.ts +23 -0
- package/lib/porting/prompt.js +51 -0
- package/lib/porting/row.d.ts +16 -0
- package/lib/porting/row.js +27 -0
- package/lib/porting/verify-port.d.ts +46 -0
- package/lib/porting/verify-port.js +82 -0
- package/lib/presets/fs-search.d.ts +25 -0
- package/lib/presets/fs-search.js +17 -0
- package/lib/presets/tool-filter.d.ts +35 -0
- package/lib/presets/tool-filter.js +91 -0
- package/lib/sessions/chat-import.d.ts +48 -0
- package/lib/sessions/chat-import.js +44 -0
- package/lib/sessions/claude.d.ts +35 -0
- package/lib/sessions/claude.js +104 -0
- package/lib/sessions/codex-discover.d.ts +34 -0
- package/lib/sessions/codex-discover.js +205 -0
- package/lib/sessions/codex-meta.d.ts +63 -0
- package/lib/sessions/codex-meta.js +148 -0
- package/lib/sessions/codex-text.d.ts +9 -0
- package/lib/sessions/codex-text.js +44 -0
- package/lib/sessions/codex.d.ts +42 -0
- package/lib/sessions/codex.js +270 -0
- package/lib/sessions/opencode.d.ts +38 -0
- package/lib/sessions/opencode.js +339 -0
- package/lib/sessions/persist.d.ts +162 -0
- package/lib/sessions/persist.js +377 -0
- package/lib/sessions/row.d.ts +15 -0
- package/lib/sessions/row.js +101 -0
- package/lib/sessions/turns.d.ts +31 -0
- package/lib/sessions/turns.js +63 -0
- package/lib/sessions/zstd.d.ts +15 -0
- package/lib/sessions/zstd.js +152 -0
- package/lib/shared/invocation.d.ts +169 -0
- package/lib/shared/invocation.js +325 -0
- package/lib/shared/render.d.ts +101 -0
- package/lib/shared/render.js +1353 -0
- package/lib/shared/util.d.ts +21 -0
- package/lib/shared/util.js +32 -0
- package/lib/skills/bundled.d.ts +3 -0
- package/lib/skills/bundled.js +42 -0
- package/lib/skills/provider.d.ts +74 -0
- package/lib/skills/provider.js +346 -0
- package/lib/skills/row.d.ts +22 -0
- package/lib/skills/row.js +204 -0
- package/lib/workbench/adapter-coverage.d.ts +65 -0
- package/lib/workbench/adapter-coverage.js +141 -0
- package/lib/workbench/model-tools.d.ts +10 -0
- package/lib/workbench/model-tools.js +122 -0
- package/lib/workbench/overview.d.ts +153 -0
- package/lib/workbench/overview.js +246 -0
- package/lib/workbench/remote.d.ts +161 -0
- package/lib/workbench/remote.js +561 -0
- package/lib/workbench/row.d.ts +15 -0
- package/lib/workbench/row.js +16 -0
- package/lib/workbench/settings.d.ts +19 -0
- package/lib/workbench/settings.js +60 -0
- package/lib/workbench/workbench.d.ts +130 -0
- package/lib/workbench/workbench.js +361 -0
- package/locale/agents/en.json +6 -0
- package/locale/agents/zh.json +6 -0
- package/locale/commands/en.json +6 -0
- package/locale/commands/zh.json +6 -0
- package/locale/context/en.json +6 -0
- package/locale/context/zh.json +6 -0
- package/locale/en.json +6 -0
- package/locale/hooks/en.json +6 -0
- package/locale/hooks/zh.json +6 -0
- package/locale/mcp/en.json +6 -0
- package/locale/mcp/zh.json +6 -0
- package/locale/mods/en.json +6 -0
- package/locale/mods/zh.json +6 -0
- package/locale/opencode/en.json +6 -0
- package/locale/opencode/zh.json +6 -0
- package/locale/porter/en.json +6 -0
- package/locale/porter/zh.json +6 -0
- package/locale/sessions/en.json +6 -0
- package/locale/sessions/zh.json +6 -0
- package/locale/skills/en.json +6 -0
- package/locale/skills/zh.json +6 -0
- package/locale/workbench/en.json +6 -0
- package/locale/workbench/zh.json +6 -0
- package/locale/zh.json +7 -0
- package/package.json +247 -3
- package/runtime/opencode-host.mjs +270 -0
- package/skills/harness-forge/SKILL.md +47 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The skills row: imported `SKILL.md` bundles served zero-copy through one
|
|
3
|
+
* DSH skill provider, their frontmatter taking effect when a skill is invoked
|
|
4
|
+
* (`allowed-tools`, `model`, `context: fork`, arguments of a typed `/skill`),
|
|
5
|
+
* and the hooks a skill's frontmatter declares, which the hooks row runs.
|
|
6
|
+
* @module @kirkchinese/harness-forge/skills
|
|
7
|
+
*/
|
|
8
|
+
import { isAbsolute, join, dirname } from 'node:path';
|
|
9
|
+
import z from '@deepseek-ai/schemastery';
|
|
10
|
+
import { renderSkillContent } from '@deepseek-ai/dsh-skill';
|
|
11
|
+
import { HarnessError } from '@kirkchinese/harness-forge-core';
|
|
12
|
+
import { onDsh } from '../dsh/host.js';
|
|
13
|
+
import { skillRootOf } from '../forge/ledger.js';
|
|
14
|
+
import { FORGE_SERVICE } from '../forge/service.js';
|
|
15
|
+
import { hookSource, parseHookTable } from '../hooks/config.js';
|
|
16
|
+
import { appendNotice } from '../hooks/notice.js';
|
|
17
|
+
import { isOwnAssets, projectRootOf, templateScope } from '../mcp/mount.js';
|
|
18
|
+
import { ForeignSkillProvider } from './provider.js';
|
|
19
|
+
import { messageOf } from '../shared/util.js';
|
|
20
|
+
import { mounted, Parts, rowEffect } from '../forge/row.js';
|
|
21
|
+
export const Config = z.object({
|
|
22
|
+
skillRoots: z.array(z.string()),
|
|
23
|
+
});
|
|
24
|
+
export const name = 'harness-forge-skills';
|
|
25
|
+
export const inject = [FORGE_SERVICE, 'skills'];
|
|
26
|
+
/** The skills row. */
|
|
27
|
+
export function apply(ctx, config = {}) {
|
|
28
|
+
rowEffect(ctx, 'skills', forge => startSkills(ctx, forge, config));
|
|
29
|
+
}
|
|
30
|
+
function textOf(message) {
|
|
31
|
+
return message.content.map(block => block.type === 'text' ? block.text ?? '' : '').join('');
|
|
32
|
+
}
|
|
33
|
+
/** The arguments after a `/name` gesture in what the user typed. */
|
|
34
|
+
export function gestureArguments(typed, name) {
|
|
35
|
+
const match = new RegExp(`(?:^|\\s)/${name.replace(/[.*+?^${}()|[\]\\/]/gu, '\\$&')}(?=\\s|$)([^\\n]*)`, 'u').exec(typed);
|
|
36
|
+
return match?.[1]?.trim() ?? '';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Put a body rendered with the gesture's arguments in place of the one the
|
|
40
|
+
* host rendered without them, keeping the host's header lines.
|
|
41
|
+
*/
|
|
42
|
+
function replaceBody(injected, body) {
|
|
43
|
+
const headerEnd = injected.indexOf('\n\n');
|
|
44
|
+
return headerEnd === -1 ? body : `${injected.slice(0, headerEnd)}\n\n${body}`;
|
|
45
|
+
}
|
|
46
|
+
/** Start the skills row on the shared service. Returns its teardown. */
|
|
47
|
+
export function startSkills(ctx, forge, config) {
|
|
48
|
+
/** Files each session has worked with, for skills with `paths`. */
|
|
49
|
+
const worked = new Map();
|
|
50
|
+
/** The component of each skill body, for its load evidence. */
|
|
51
|
+
const bodies = new Map();
|
|
52
|
+
const skillHooks = new Map();
|
|
53
|
+
const provider = new ForeignSkillProvider(forge.shell, (bodyPath) => {
|
|
54
|
+
const componentId = bodies.get(bodyPath);
|
|
55
|
+
if (componentId !== undefined)
|
|
56
|
+
forge.observe(componentId, 'skill-load', true, 'loaded by the model');
|
|
57
|
+
}, sessionId => worked.get(sessionId) ?? new Set(), dir => forge.projects.trust.state(dir));
|
|
58
|
+
const invocations = forge.invocations;
|
|
59
|
+
const directory = (agent, signal) => forge.directory(agent, signal);
|
|
60
|
+
/**
|
|
61
|
+
* A skill the user invoked with `/name args` is rendered with its arguments
|
|
62
|
+
* and takes effect (a `context: fork` skill runs in a forked agent instead of
|
|
63
|
+
* entering the conversation). Prepended so it sees the skill tool's own injection.
|
|
64
|
+
*/
|
|
65
|
+
const preStep = async (payload, next) => {
|
|
66
|
+
const { agent, messages, signal } = payload;
|
|
67
|
+
const sessionId = agent.session.header.id;
|
|
68
|
+
const decision = await next();
|
|
69
|
+
if (decision.kind === 'reject' || decision.messages === undefined)
|
|
70
|
+
return decision;
|
|
71
|
+
const typed = messages.filter(message => message.source?.kind === 'user').map(textOf).join('\n');
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const message of decision.messages) {
|
|
74
|
+
const name = message.source?.kind === 'skill-invocation' ? message.source.name : undefined;
|
|
75
|
+
const spec = typeof name === 'string' ? invocations.skill(name) : undefined;
|
|
76
|
+
if (typeof name === 'string') {
|
|
77
|
+
// `UserPromptExpansion` sees every skill the user typed, ours or DSH's own.
|
|
78
|
+
const expansion = await forge.lookup('hooks')?.expandSkill(agent, {
|
|
79
|
+
name,
|
|
80
|
+
foreignName: spec?.foreignName ?? name,
|
|
81
|
+
args: gestureArguments(typed, name),
|
|
82
|
+
source: spec?.source ?? 'user',
|
|
83
|
+
}, signal);
|
|
84
|
+
if (expansion?.blocked !== undefined) {
|
|
85
|
+
appendNotice(agent.session, { kind: 'blocked', event: 'UserPromptExpansion', subject: name, plugin: spec?.pluginId ?? 'harness-forge', text: expansion.blocked });
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
for (const text of expansion?.context ?? [])
|
|
89
|
+
out.push({ source: { kind: 'user' }, content: [{ type: 'text', text }] });
|
|
90
|
+
}
|
|
91
|
+
if (spec === undefined || spec.places.skillDir === undefined) {
|
|
92
|
+
out.push(message);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const rawArguments = gestureArguments(typed, spec.name);
|
|
97
|
+
const cwd = await directory(agent, signal).catch(() => agent.session.header.cwd ?? process.cwd());
|
|
98
|
+
const body = await provider.renderFor(join(spec.places.skillDir, 'SKILL.md'), rawArguments, cwd, sessionId, signal).catch(() => undefined);
|
|
99
|
+
const directives = await invocations.activate(agent, spec, signal);
|
|
100
|
+
const rendered = body ?? textOf(message);
|
|
101
|
+
if (directives.fork !== undefined) {
|
|
102
|
+
const result = await invocations.fork(agent, spec, directives, rendered, signal).catch((error) => `Skill ${spec.name} could not start its forked agent: ${messageOf(error)}`);
|
|
103
|
+
out.push({ ...message, content: [{ type: 'text', text: `<skill-result name="${spec.name}">\n${result}\n</skill-result>` }] });
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
out.push(body === undefined ? message : { ...message, content: [{ type: 'text', text: replaceBody(textOf(message), body) }] });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
// The skill still reaches the model as the host injected it.
|
|
111
|
+
out.push(message);
|
|
112
|
+
appendNotice(agent.session, { kind: 'hook-error', event: 'SkillInvocation', subject: spec.name, plugin: spec.pluginId, text: `frontmatter of ${spec.name} not applied: ${messageOf(error)}` });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { ...decision, messages: out };
|
|
116
|
+
};
|
|
117
|
+
/** A model-invoked skill takes effect; a `context: fork` skill answers with its forked agent's result. */
|
|
118
|
+
const executeSkill = async (exec, next) => {
|
|
119
|
+
const result = await next();
|
|
120
|
+
const name = exec.arguments?.name;
|
|
121
|
+
const spec = typeof name === 'string' ? invocations.skill(name) : undefined;
|
|
122
|
+
if (exec.name !== 'skill' || result.isError || exec.agent === undefined || spec === undefined)
|
|
123
|
+
return result;
|
|
124
|
+
const directives = await invocations.activate(exec.agent, spec, exec.signal);
|
|
125
|
+
if (directives.fork === undefined || result.value === undefined)
|
|
126
|
+
return result;
|
|
127
|
+
const output = await invocations.fork(exec.agent, spec, directives, result.value.content, exec.signal);
|
|
128
|
+
const value = { ...result.value, content: output };
|
|
129
|
+
return { isError: false, value, content: [{ type: 'text', text: renderSkillContent(value) }] };
|
|
130
|
+
};
|
|
131
|
+
/** Remember the files a session reads or writes. */
|
|
132
|
+
const noteFile = (exec) => {
|
|
133
|
+
if (exec.agent === undefined || !['read', 'read_image', 'write', 'edit'].includes(exec.name))
|
|
134
|
+
return;
|
|
135
|
+
const path = exec.arguments?.file_path ?? exec.arguments?.path;
|
|
136
|
+
if (typeof path !== 'string')
|
|
137
|
+
return;
|
|
138
|
+
const id = exec.agent.session.header.id;
|
|
139
|
+
const files = worked.get(id) ?? new Set();
|
|
140
|
+
const absolute = isAbsolute(path) ? path : join(exec.agent.session.header.cwd ?? process.cwd(), path);
|
|
141
|
+
if (files.has(absolute))
|
|
142
|
+
return;
|
|
143
|
+
files.add(absolute);
|
|
144
|
+
worked.set(id, files);
|
|
145
|
+
provider.refresh();
|
|
146
|
+
};
|
|
147
|
+
const api = {
|
|
148
|
+
skillHooks: name => skillHooks.get(name),
|
|
149
|
+
reload: () => { provider.refresh(); },
|
|
150
|
+
// The configured roots, and the directories of the skills mounted one by one.
|
|
151
|
+
roots: () => [...new Set([...provider.listRoots(), ...provider.listSkills().map(skillRootOf)])].sort((a, b) => a.localeCompare(b, 'en')),
|
|
152
|
+
};
|
|
153
|
+
const parts = new Parts(ctx, forge, 'skills');
|
|
154
|
+
parts.add('skill provider', () => ctx.skills.registerProvider((control) => {
|
|
155
|
+
provider.attach(control);
|
|
156
|
+
provider.addRoots(config.skillRoots ?? []);
|
|
157
|
+
return provider;
|
|
158
|
+
}));
|
|
159
|
+
parts.add('typed skills', () => onDsh(ctx, 'agent/pre-step', preStep, { prepend: true, owner: 'skills' }));
|
|
160
|
+
parts.add('skill tool', () => onDsh(ctx, 'tools/execute', ((exec, next) => exec.name === 'skill' ? executeSkill(exec, next) : next()), { owner: 'skills' }));
|
|
161
|
+
parts.add('worked files', () => onDsh(ctx, 'tools/post-execute', ((exec, result, next) => {
|
|
162
|
+
if (!result.isError)
|
|
163
|
+
noteFile(exec);
|
|
164
|
+
return next();
|
|
165
|
+
}), { owner: 'skills' }));
|
|
166
|
+
parts.add('skill mounter', () => forge.registerMounter('skill', {
|
|
167
|
+
mount: async ({ component, plugin, dataDir }) => {
|
|
168
|
+
if (component.kind !== 'skill')
|
|
169
|
+
throw new HarnessError('component-failed', `action expects a skill: ${component.id}`);
|
|
170
|
+
const projectRoot = projectRootOf(plugin);
|
|
171
|
+
const releaseSkill = provider.addSkill(component.bodyPath, { pluginRoot: plugin.root, pluginName: plugin.name, ...(plugin.displayName !== undefined ? { pluginVariant: plugin.name.slice(plugin.displayName.length + 1) } : {}), dataDir, scope: templateScope(plugin), ...(projectRoot !== undefined ? { projectRoot } : {}) });
|
|
172
|
+
bodies.set(component.bodyPath, component.id);
|
|
173
|
+
const hooks = component.frontmatter.raw['hooks'];
|
|
174
|
+
const name = component.frontmatter.name;
|
|
175
|
+
const source = hooks === undefined ? undefined : hookSource(component.id, plugin, dataDir, parseHookTable(hooks), 'skill');
|
|
176
|
+
if (source !== undefined)
|
|
177
|
+
skillHooks.set(name, source);
|
|
178
|
+
// `allowed-tools`, `model`, `effort`, `context: fork` take effect when the skill is invoked.
|
|
179
|
+
const withdrawInvocation = invocations.registerSkill({
|
|
180
|
+
name,
|
|
181
|
+
kind: 'skill',
|
|
182
|
+
foreignName: isOwnAssets(plugin) ? name : `${plugin.name}:${name}`,
|
|
183
|
+
source: isOwnAssets(plugin) ? String(plugin.manifest['scope']) : 'plugin',
|
|
184
|
+
pluginId: plugin.id,
|
|
185
|
+
componentId: component.id,
|
|
186
|
+
frontmatter: component.frontmatter.raw,
|
|
187
|
+
places: { skillDir: dirname(component.bodyPath), ...(isOwnAssets(plugin) ? {} : { pluginRoot: plugin.root, dataDir }) },
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
outcome: mounted(component, 'L1a', name),
|
|
191
|
+
disposer: async () => {
|
|
192
|
+
if (bodies.get(component.bodyPath) === component.id)
|
|
193
|
+
bodies.delete(component.bodyPath);
|
|
194
|
+
if (source !== undefined && skillHooks.get(name) === source)
|
|
195
|
+
skillHooks.delete(name);
|
|
196
|
+
withdrawInvocation();
|
|
197
|
+
releaseSkill();
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
}));
|
|
202
|
+
parts.add('api', () => forge.provide('skills', api));
|
|
203
|
+
return () => parts.dispose();
|
|
204
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AdapterCoverage } from './overview.js';
|
|
2
|
+
/**
|
|
3
|
+
* The adapters installed in this DSH profile.
|
|
4
|
+
* @param profileDir - the DSH profile directory; its packages and its parent's shared ones are read.
|
|
5
|
+
*/
|
|
6
|
+
export declare function adapterCoverage(profileDir: string | undefined): AdapterCoverage[];
|
|
7
|
+
/** The part of `pluginManager` (`@deepseek-ai/dsh-plugin-manager`) adapter checks read. */
|
|
8
|
+
export interface PluginManagerLike {
|
|
9
|
+
listBundles(): Promise<ReadonlyArray<{
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly enabled: boolean;
|
|
12
|
+
readonly error?: {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
readonly diagnostic?: string;
|
|
15
|
+
};
|
|
16
|
+
readonly rows: ReadonlyArray<{
|
|
17
|
+
readonly rowId: string;
|
|
18
|
+
readonly entryId?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}>>;
|
|
21
|
+
listPlugins(): Promise<ReadonlyArray<{
|
|
22
|
+
readonly entryId: string;
|
|
23
|
+
readonly enabled: boolean;
|
|
24
|
+
readonly fiberPhase: string | null;
|
|
25
|
+
readonly diagnostic?: string;
|
|
26
|
+
}>>;
|
|
27
|
+
}
|
|
28
|
+
export type ListedBundle = Awaited<ReturnType<PluginManagerLike['listBundles']>>[number];
|
|
29
|
+
/** Where an adapter package stands with DSH: installed and enabled as a bundle that loads, or why not. */
|
|
30
|
+
export type BundleState = {
|
|
31
|
+
readonly state: 'enabled';
|
|
32
|
+
readonly bundle: ListedBundle;
|
|
33
|
+
} | {
|
|
34
|
+
readonly state: 'unlisted';
|
|
35
|
+
} | {
|
|
36
|
+
readonly state: 'off';
|
|
37
|
+
} | {
|
|
38
|
+
readonly state: 'broken';
|
|
39
|
+
readonly error: NonNullable<ListedBundle['error']>;
|
|
40
|
+
};
|
|
41
|
+
/** The state of the bundle named `name` among the plugin manager's bundles. */
|
|
42
|
+
export declare function bundleState(name: string, bundles: readonly ListedBundle[]): BundleState;
|
|
43
|
+
/** One step of an adapter's readiness, as `harness_verify_port` reports it. */
|
|
44
|
+
export interface ReadinessCheck {
|
|
45
|
+
readonly check: 'declared' | 'enabled' | 'loaded';
|
|
46
|
+
readonly ok: boolean;
|
|
47
|
+
readonly detail: string;
|
|
48
|
+
}
|
|
49
|
+
/** What the plugin manager says now, read once for any number of adapters. */
|
|
50
|
+
export interface ManagerSnapshot {
|
|
51
|
+
readonly bundles: readonly ListedBundle[];
|
|
52
|
+
readonly plugins: Awaited<ReturnType<PluginManagerLike['listPlugins']>>;
|
|
53
|
+
}
|
|
54
|
+
export declare function managerSnapshot(manager: PluginManagerLike): Promise<ManagerSnapshot>;
|
|
55
|
+
/**
|
|
56
|
+
* Whether an adapter package found on disk is ready: DSH lists it as an enabled bundle that loads, and every
|
|
57
|
+
* plugin row it declares runs, active, without a startup fault. The one decision the overview counts an adapter
|
|
58
|
+
* by and `harness_verify_port` reports step by step; the last check returned is the first that failed.
|
|
59
|
+
*/
|
|
60
|
+
export declare function adapterReadiness(name: string, snapshot: ManagerSnapshot): ReadinessCheck[];
|
|
61
|
+
/**
|
|
62
|
+
* The adapters on disk that are ready (see `adapterReadiness`). Without a plugin manager none is confirmed, so
|
|
63
|
+
* none counts.
|
|
64
|
+
*/
|
|
65
|
+
export declare function enabledAdapters(adapters: readonly AdapterCoverage[], manager: PluginManagerLike | undefined): Promise<AdapterCoverage[]>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which plugin parts installed adapters bring: an adapter package (a local
|
|
3
|
+
* `dsh-adapter-*` bundle written in DSH's creation mode from a porting brief,
|
|
4
|
+
* or one installed from npm) declares `harnessForge.ports`
|
|
5
|
+
* (`[{ plugin, component }]`, the original's names) in its package.json.
|
|
6
|
+
* A package found on disk only counts once DSH's plugin manager lists it as an
|
|
7
|
+
* enabled bundle whose plugin rows started without a fault (`adapterReadiness`):
|
|
8
|
+
* a failed install can leave a `node_modules` link behind that DSH never runs.
|
|
9
|
+
* The workbench overview and `harness_verify_port` apply that one decision.
|
|
10
|
+
* @module @kirkchinese/harness-forge
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
|
|
13
|
+
import { dirname, join } from 'node:path';
|
|
14
|
+
function readJson(path) {
|
|
15
|
+
try {
|
|
16
|
+
const value = JSON.parse(readFileSync(path, 'utf8'));
|
|
17
|
+
return typeof value === 'object' && value !== null ? value : undefined;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function portsOf(manifest) {
|
|
24
|
+
const ports = manifest['harnessForge']?.ports;
|
|
25
|
+
if (!Array.isArray(ports))
|
|
26
|
+
return [];
|
|
27
|
+
return ports.flatMap((port) => {
|
|
28
|
+
const plugin = port.plugin;
|
|
29
|
+
const component = port.component;
|
|
30
|
+
return typeof plugin === 'string' && typeof component === 'string' ? [{ plugin, component }] : [];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Where a package's files are: a local install is a link to its source directory. */
|
|
34
|
+
function realDir(dir) {
|
|
35
|
+
try {
|
|
36
|
+
return realpathSync(dir);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return dir;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Package manifests directly under a node_modules directory (scoped ones included). */
|
|
43
|
+
function manifestsUnder(modules) {
|
|
44
|
+
if (!existsSync(modules))
|
|
45
|
+
return [];
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const entry of readdirSync(modules, { withFileTypes: true })) {
|
|
48
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
49
|
+
continue;
|
|
50
|
+
const dirs = entry.name.startsWith('@')
|
|
51
|
+
? readdirSync(join(modules, entry.name), { withFileTypes: true }).map(inner => join(modules, entry.name, inner.name))
|
|
52
|
+
: [join(modules, entry.name)];
|
|
53
|
+
for (const dir of dirs) {
|
|
54
|
+
const manifest = readJson(join(dir, 'package.json'));
|
|
55
|
+
if (manifest !== undefined)
|
|
56
|
+
out.push({ manifest, dir });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The adapters installed in this DSH profile.
|
|
63
|
+
* @param profileDir - the DSH profile directory; its packages and its parent's shared ones are read.
|
|
64
|
+
*/
|
|
65
|
+
export function adapterCoverage(profileDir) {
|
|
66
|
+
const out = [];
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
const roots = profileDir === undefined ? [] : [join(profileDir, 'node_modules'), join(dirname(profileDir), 'node_modules')];
|
|
69
|
+
for (const modules of roots) {
|
|
70
|
+
for (const { manifest, dir } of manifestsUnder(modules)) {
|
|
71
|
+
const name = typeof manifest['name'] === 'string' ? manifest['name'] : undefined;
|
|
72
|
+
const ports = portsOf(manifest);
|
|
73
|
+
// A `dsh-adapter-*` package without ports still covers the part its name was given for (see `adapterPackageName`).
|
|
74
|
+
if (name === undefined || (ports.length === 0 && !name.startsWith('dsh-adapter-')) || seen.has(name))
|
|
75
|
+
continue;
|
|
76
|
+
seen.add(name);
|
|
77
|
+
out.push({ name, ports, dir: realDir(dir) });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
/** The state of the bundle named `name` among the plugin manager's bundles. */
|
|
83
|
+
export function bundleState(name, bundles) {
|
|
84
|
+
const bundle = bundles.find(item => item.name === name);
|
|
85
|
+
if (bundle === undefined)
|
|
86
|
+
return { state: 'unlisted' };
|
|
87
|
+
if (!bundle.enabled)
|
|
88
|
+
return { state: 'off' };
|
|
89
|
+
if (bundle.error !== undefined)
|
|
90
|
+
return { state: 'broken', error: bundle.error };
|
|
91
|
+
return { state: 'enabled', bundle };
|
|
92
|
+
}
|
|
93
|
+
const step = (name, ok, detail) => ({ check: name, ok, detail });
|
|
94
|
+
export async function managerSnapshot(manager) {
|
|
95
|
+
const [bundles, plugins] = await Promise.all([manager.listBundles(), manager.listPlugins()]);
|
|
96
|
+
return { bundles, plugins };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether an adapter package found on disk is ready: DSH lists it as an enabled bundle that loads, and every
|
|
100
|
+
* plugin row it declares runs, active, without a startup fault. The one decision the overview counts an adapter
|
|
101
|
+
* by and `harness_verify_port` reports step by step; the last check returned is the first that failed.
|
|
102
|
+
*/
|
|
103
|
+
export function adapterReadiness(name, snapshot) {
|
|
104
|
+
const status = bundleState(name, snapshot.bundles);
|
|
105
|
+
if (status.state === 'unlisted')
|
|
106
|
+
return [step('enabled', false, `${name} is on disk but DSH does not list it as an installed bundle: install it with plugin_manager install_bundle (a link left by a failed install does not count), and check that its package.json declares a bundle (dsh-doc references/host-plugin.md)`)];
|
|
107
|
+
if (status.state === 'off')
|
|
108
|
+
return [step('enabled', false, `${name} is installed but switched off: enable it with plugin_manager set_bundle`)];
|
|
109
|
+
if (status.state === 'broken')
|
|
110
|
+
return [step('enabled', false, `${name} is enabled but its bundle cannot load: ${status.error.code}${status.error.diagnostic !== undefined ? ` — ${status.error.diagnostic}` : ''}`)];
|
|
111
|
+
const enabled = step('enabled', true, `${name} is enabled`);
|
|
112
|
+
const rows = status.bundle.rows;
|
|
113
|
+
if (rows.length === 0)
|
|
114
|
+
return [enabled, step('loaded', true, 'its bundle declares no plugin rows, so nothing has to start')];
|
|
115
|
+
const entries = new Map(snapshot.plugins.map(entry => [entry.entryId, entry]));
|
|
116
|
+
const problems = [];
|
|
117
|
+
for (const row of rows) {
|
|
118
|
+
const entry = row.entryId === undefined ? undefined : entries.get(row.entryId);
|
|
119
|
+
if (entry === undefined)
|
|
120
|
+
problems.push(`row "${row.rowId}" has no running entry`);
|
|
121
|
+
else if (entry.diagnostic !== undefined)
|
|
122
|
+
problems.push(`row "${row.rowId}" failed to start: ${entry.diagnostic}`);
|
|
123
|
+
else if (!entry.enabled)
|
|
124
|
+
problems.push(`row "${row.rowId}" is disabled`);
|
|
125
|
+
else if (entry.fiberPhase !== 'active')
|
|
126
|
+
problems.push(`row "${row.rowId}" is ${entry.fiberPhase ?? 'not running'}`);
|
|
127
|
+
}
|
|
128
|
+
return [enabled, problems.length === 0
|
|
129
|
+
? step('loaded', true, `all ${String(rows.length)} plugin row(s) of its bundle are active, without startup failures`)
|
|
130
|
+
: step('loaded', false, problems.join('; '))];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The adapters on disk that are ready (see `adapterReadiness`). Without a plugin manager none is confirmed, so
|
|
134
|
+
* none counts.
|
|
135
|
+
*/
|
|
136
|
+
export async function enabledAdapters(adapters, manager) {
|
|
137
|
+
if (manager === undefined || adapters.length === 0)
|
|
138
|
+
return [];
|
|
139
|
+
const snapshot = await managerSnapshot(manager);
|
|
140
|
+
return adapters.filter(adapter => adapterReadiness(adapter.name, snapshot).every(item => item.ok));
|
|
141
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing Harness Forge tools. They are thin adapters over the same
|
|
3
|
+
* service the workbench uses, so a model can discover, inspect and install a
|
|
4
|
+
* plugin without inventing a second code path.
|
|
5
|
+
* @module @kirkchinese/harness-forge
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
import type { HarnessForge } from '../forge/service.js';
|
|
9
|
+
/** Register the `harness_*` tool family; returns one disposer. */
|
|
10
|
+
export declare function registerModelTools(ctx: Context, forge: HarnessForge): () => void;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { dialectIds } from '@kirkchinese/harness-forge-core';
|
|
2
|
+
import { Workbench } from './workbench.js';
|
|
3
|
+
import { dshService } from '../dsh/host.js';
|
|
4
|
+
import { forgeVerifyDeps, verifyPort } from '../porting/verify-port.js';
|
|
5
|
+
import { VERIFY_TOOL } from '../porting/prompt.js';
|
|
6
|
+
const inputSchema = (properties, required = []) => ({
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties,
|
|
9
|
+
...(required.length > 0 ? { required } : {}),
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
});
|
|
12
|
+
function textOutput() {
|
|
13
|
+
return {
|
|
14
|
+
schema: { type: 'object', additionalProperties: true },
|
|
15
|
+
render: (_args, value) => [{ type: 'text', text: JSON.stringify(value, null, 2) }],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Register the `harness_*` tool family; returns one disposer. */
|
|
19
|
+
export function registerModelTools(ctx, forge) {
|
|
20
|
+
const tools = dshService(ctx, 'tools');
|
|
21
|
+
if (tools === undefined)
|
|
22
|
+
return () => { };
|
|
23
|
+
const workbench = new Workbench(forge);
|
|
24
|
+
const disposers = [
|
|
25
|
+
tools.register({
|
|
26
|
+
name: 'harness_status',
|
|
27
|
+
description: 'List installed Harness Forge plugins, component mounts, compatibility vectors and gaps.',
|
|
28
|
+
parameters: inputSchema({}),
|
|
29
|
+
output: textOutput(),
|
|
30
|
+
execute: async () => ({ plugins: forge.list(), host: workbench.hostCapabilities() }),
|
|
31
|
+
}),
|
|
32
|
+
tools.register({
|
|
33
|
+
name: 'harness_discover',
|
|
34
|
+
description: 'Discover plugin roots under the configured Claude, Codex and OpenCode directories.',
|
|
35
|
+
parameters: inputSchema({}),
|
|
36
|
+
output: textOutput(),
|
|
37
|
+
execute: async () => workbench.discover(),
|
|
38
|
+
}),
|
|
39
|
+
tools.register({
|
|
40
|
+
name: 'harness_capabilities',
|
|
41
|
+
description: 'Return the installed capability catalog, per-plugin compatibility and context-budget usage.',
|
|
42
|
+
parameters: inputSchema({}),
|
|
43
|
+
output: textOutput(),
|
|
44
|
+
execute: async () => workbench.capabilities(),
|
|
45
|
+
}),
|
|
46
|
+
tools.register({
|
|
47
|
+
name: 'harness_scan',
|
|
48
|
+
description: 'Scan one foreign plugin root without installing it.',
|
|
49
|
+
parameters: inputSchema({
|
|
50
|
+
path: { type: 'string', description: 'Absolute plugin root' },
|
|
51
|
+
source: { type: 'string', enum: dialectIds() },
|
|
52
|
+
}, ['path']),
|
|
53
|
+
output: textOutput(),
|
|
54
|
+
execute: async (args) => {
|
|
55
|
+
const input = args;
|
|
56
|
+
const path = typeof input.path === 'string' ? input.path : '';
|
|
57
|
+
const source = typeof input.source === 'string' ? input.source : 'claude-code';
|
|
58
|
+
return forge.scan(path, source);
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
tools.register({
|
|
62
|
+
name: 'harness_plan',
|
|
63
|
+
description: 'Build the reversible action plan for one foreign plugin root.',
|
|
64
|
+
parameters: inputSchema({
|
|
65
|
+
path: { type: 'string', description: 'Absolute plugin root' },
|
|
66
|
+
source: { type: 'string', enum: dialectIds() },
|
|
67
|
+
}, ['path']),
|
|
68
|
+
output: textOutput(),
|
|
69
|
+
execute: async (args) => {
|
|
70
|
+
const input = args;
|
|
71
|
+
const path = typeof input.path === 'string' ? input.path : '';
|
|
72
|
+
const source = typeof input.source === 'string' ? input.source : 'claude-code';
|
|
73
|
+
return forge.plan(path, source);
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
tools.register({
|
|
77
|
+
name: 'harness_mcp_login',
|
|
78
|
+
description: 'Open the browser sign-in page of an imported remote MCP server that requires OAuth (its status shows "sign-in required"). The server connects when the user finishes; tell the user to complete the sign-in in the browser.',
|
|
79
|
+
parameters: inputSchema({ server: { type: 'string', description: 'MCP server name, e.g. plugin_context7_context7' } }, ['server']),
|
|
80
|
+
output: textOutput(),
|
|
81
|
+
execute: async (args, exec) => {
|
|
82
|
+
const server = String(args.server ?? '');
|
|
83
|
+
const mcp = forge.lookup('mcp');
|
|
84
|
+
if (mcp === undefined)
|
|
85
|
+
throw new Error('the Harness Forge mcp row is off');
|
|
86
|
+
const sessionId = exec?.agent?.session?.header?.id;
|
|
87
|
+
return { server, signInUrl: mcp.startSignIn(server, sessionId), waiting: mcp.pendingSignIns(sessionId) };
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
tools.register({
|
|
91
|
+
name: 'harness_install',
|
|
92
|
+
description: 'Install one foreign plugin root and execute its hooks, MCP servers and code shims.',
|
|
93
|
+
parameters: inputSchema({
|
|
94
|
+
path: { type: 'string', description: 'Absolute plugin root' },
|
|
95
|
+
source: { type: 'string', enum: dialectIds() },
|
|
96
|
+
}, ['path']),
|
|
97
|
+
output: textOutput(),
|
|
98
|
+
execute: async (args) => {
|
|
99
|
+
const input = args;
|
|
100
|
+
const path = typeof input.path === 'string' ? input.path : '';
|
|
101
|
+
const source = typeof input.source === 'string' ? input.source : 'claude-code';
|
|
102
|
+
return forge.install(path, source);
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
105
|
+
tools.register({
|
|
106
|
+
name: VERIFY_TOOL,
|
|
107
|
+
description: 'Check that an installed adapter now covers a plugin part Harness Forge could not run: an installed package declares it in package.json "harnessForge.ports", its DSH bundle is enabled, and its plugins started without a fault. Answers { covered, checks[] } and records the result in Harness Forge\'s Gaps screen. Call it after installing an adapter, before reporting the port done; when covered is false, fix what the failing check says and call it again.',
|
|
108
|
+
parameters: inputSchema({
|
|
109
|
+
pluginId: { type: 'string', description: 'The original plugin\'s id, as the porting brief gives it (e.g. claude-code:claude-hud)' },
|
|
110
|
+
componentId: { type: 'string', description: 'The part\'s component id, as the porting brief gives it' },
|
|
111
|
+
}, ['pluginId', 'componentId']),
|
|
112
|
+
output: textOutput(),
|
|
113
|
+
execute: async (args, exec) => {
|
|
114
|
+
const input = args;
|
|
115
|
+
const sessionId = exec?.agent?.session?.header?.id;
|
|
116
|
+
return verifyPort(forgeVerifyDeps(forge, workbench), String(input.pluginId ?? ''), String(input.componentId ?? ''), sessionId);
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
];
|
|
120
|
+
return () => { for (const dispose of disposers)
|
|
121
|
+
dispose(); };
|
|
122
|
+
}
|