@kirkchinese/harness-forge 0.0.0-stage → 0.4.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 +42 -2
- package/assets/icon.svg +12 -0
- package/cordis.patch.yml +28 -0
- package/lib/agents/presets.d.ts +91 -0
- package/lib/agents/presets.js +282 -0
- package/lib/agents/profiles.d.ts +58 -0
- package/lib/agents/profiles.js +278 -0
- package/lib/agents/row.d.ts +17 -0
- package/lib/agents/row.js +146 -0
- package/lib/client/styles.d.ts +8 -0
- package/lib/client/styles.js +89 -0
- package/lib/client/typert.d.ts +14 -0
- package/lib/client/typert.js +110 -0
- package/lib/client.js +22500 -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 +107 -0
- package/lib/dsh/host.js +214 -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 +231 -0
- package/lib/forge/contract.js +43 -0
- package/lib/forge/ledger.d.ts +143 -0
- package/lib/forge/ledger.js +733 -0
- package/lib/forge/live-mounts.d.ts +45 -0
- package/lib/forge/live-mounts.js +78 -0
- package/lib/forge/marketplace-install.d.ts +3 -0
- package/lib/forge/marketplace-install.js +64 -0
- package/lib/forge/npm.d.ts +31 -0
- package/lib/forge/npm.js +60 -0
- package/lib/forge/projects.d.ts +94 -0
- package/lib/forge/projects.js +336 -0
- package/lib/forge/receipts.d.ts +5 -0
- package/lib/forge/receipts.js +31 -0
- package/lib/forge/row.d.ts +32 -0
- package/lib/forge/row.js +59 -0
- package/lib/forge/service.d.ts +105 -0
- package/lib/forge/service.js +274 -0
- package/lib/forge/settings.d.ts +41 -0
- package/lib/forge/settings.js +115 -0
- package/lib/forge/state.d.ts +69 -0
- package/lib/forge/state.js +150 -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 +728 -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 +22 -0
- package/lib/hooks/broker/session-events.js +196 -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 +262 -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 +11 -0
- package/lib/hooks/condition.js +181 -0
- package/lib/hooks/config.d.ts +85 -0
- package/lib/hooks/config.js +150 -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 +14 -0
- package/lib/hooks/permissions.js +109 -0
- package/lib/hooks/process.d.ts +47 -0
- package/lib/hooks/process.js +134 -0
- package/lib/hooks/row.d.ts +17 -0
- package/lib/hooks/row.js +94 -0
- package/lib/hooks/runner.d.ts +85 -0
- package/lib/hooks/runner.js +293 -0
- package/lib/hooks/shell-commands.d.ts +19 -0
- package/lib/hooks/shell-commands.js +177 -0
- package/lib/hooks/shell.d.ts +43 -0
- package/lib/hooks/shell.js +126 -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 +364 -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 +36 -0
- package/lib/mcp/catalog.js +61 -0
- package/lib/mcp/mount.d.ts +75 -0
- package/lib/mcp/mount.js +217 -0
- package/lib/mcp/remote.d.ts +45 -0
- package/lib/mcp/remote.js +143 -0
- package/lib/mcp/row.d.ts +9 -0
- package/lib/mcp/row.js +131 -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 +227 -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 +32 -0
- package/lib/mods/service/turns.js +161 -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 +156 -0
- package/lib/opencode/convert.d.ts +53 -0
- package/lib/opencode/convert.js +255 -0
- package/lib/opencode/row.d.ts +9 -0
- package/lib/opencode/row.js +86 -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 +353 -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/port-gap.d.ts +30 -0
- package/lib/porting/port-gap.js +122 -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 +49 -0
- package/lib/porting/row.d.ts +16 -0
- package/lib/porting/row.js +25 -0
- package/lib/porting/verify-port.d.ts +53 -0
- package/lib/porting/verify-port.js +104 -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/claude.d.ts +29 -0
- package/lib/sessions/claude.js +83 -0
- package/lib/sessions/codex.d.ts +30 -0
- package/lib/sessions/codex.js +303 -0
- package/lib/sessions/opencode.d.ts +32 -0
- package/lib/sessions/opencode.js +320 -0
- package/lib/sessions/row.d.ts +14 -0
- package/lib/sessions/row.js +35 -0
- package/lib/shared/invocation.d.ts +169 -0
- package/lib/shared/invocation.js +325 -0
- package/lib/shared/render.d.ts +72 -0
- package/lib/shared/render.js +588 -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 +72 -0
- package/lib/skills/provider.js +340 -0
- package/lib/skills/row.d.ts +22 -0
- package/lib/skills/row.js +204 -0
- package/lib/workbench/adapter-coverage.d.ts +47 -0
- package/lib/workbench/adapter-coverage.js +102 -0
- package/lib/workbench/model-tools.d.ts +10 -0
- package/lib/workbench/model-tools.js +122 -0
- package/lib/workbench/overview.d.ts +103 -0
- package/lib/workbench/overview.js +159 -0
- package/lib/workbench/remote.d.ts +118 -0
- package/lib/workbench/remote.js +422 -0
- package/lib/workbench/row.d.ts +15 -0
- package/lib/workbench/row.js +16 -0
- package/lib/workbench/settings.d.ts +15 -0
- package/lib/workbench/settings.js +56 -0
- package/lib/workbench/workbench.d.ts +100 -0
- package/lib/workbench/workbench.js +260 -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 +6 -0
- package/package.json +246 -3
- package/runtime/opencode-host.mjs +270 -0
- package/skills/harness-forge/SKILL.md +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Harness Forge contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Harness Forge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use your Claude Code, Codex and OpenCode plugins and settings in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH): skills, slash commands, subagents, hooks, MCP servers (stdio, HTTP, SSE, OAuth), Claude Code mods and OpenCode code plugins, your `~/.claude` and `~/.codex` setup, instruction files DSH does not read itself, and session history you can continue. It converts at run time and leaves the original installation untouched.
|
|
4
|
+
|
|
5
|
+
In DSH: **Plugins › Add plugin** and enter `@kirkchinese/harness-forge`. From a terminal, for the main profile that `dsh web` runs:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
dsh plugin --profile web add @kirkchinese/harness-forge
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires DSH 0.2.2-rc.3 or later and Node.js 22.19+ or 24+; on Windows, hooks run in Git Bash.
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
Open **Harness Forge** in the DSH sidebar:
|
|
16
|
+
|
|
17
|
+
- **Discover & migrate** lists the plugins found on this computer and your own settings, marks each part as working, partly working or not possible with the reason, and migrates them (**Migrate all**). You can also browse a marketplace here.
|
|
18
|
+
- **Migrated** switches single parts off and undoes migrations.
|
|
19
|
+
- **Gaps** lists what cannot fully run and why. **Fill with AI** opens a session in DSH's creation mode that builds a local adapter plugin (`dsh-adapter-<plugin>-<part>`); publishing it is optional and under your own npm scope.
|
|
20
|
+
|
|
21
|
+
Also: **Import sessions**, **Settings**, **Diagnostics**. The model can use the `harness_*` tools, and you can type `/harness status | list | scan | plan | import | undo | remove | roots | login`.
|
|
22
|
+
|
|
23
|
+
## Rows
|
|
24
|
+
|
|
25
|
+
This package installs one DSH plugin row per capability: Harness Forge (required by the others), skills, commands, agents, hooks, MCP servers, Claude Code mods, OpenCode plugins, instructions, sessions, porting and workbench. Each can be switched off in DSH's **Plugins** page without affecting the rest.
|
|
26
|
+
|
|
27
|
+
## Safety
|
|
28
|
+
|
|
29
|
+
Migrated hooks, MCP servers and plugin code run with your permissions, as in their original harness. Migrate only plugins you trust.
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
- [Quick start](https://github.com/kirkchinese/harness-forge/blob/main/docs/user/quickstart.md)
|
|
34
|
+
- [Compatibility](https://github.com/kirkchinese/harness-forge/blob/main/docs/user/compatibility.md)
|
|
35
|
+
- [Porting (Fill with AI)](https://github.com/kirkchinese/harness-forge/blob/main/docs/user/porting.md)
|
|
36
|
+
- [Architecture](https://github.com/kirkchinese/harness-forge/blob/main/docs/architecture/overview.md)
|
|
37
|
+
- [Changelog](https://github.com/kirkchinese/harness-forge/blob/main/CHANGELOG.md)
|
|
38
|
+
|
|
39
|
+
Chinese documentation: [README](https://github.com/kirkchinese/harness-forge/blob/main/README.zh.md).
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/assets/icon.svg
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96" viewBox="0 0 96 96">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0" stop-color="#4f6bed"/>
|
|
5
|
+
<stop offset="1" stop-color="#2f3fa8"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect width="96" height="96" rx="22" fill="url(#bg)"/>
|
|
9
|
+
<path d="M22 36h40c0 7 6 12 14 12v4c-9 0-16 3-19 9H39c-3-6-9-9-17-9z" fill="#fff"/>
|
|
10
|
+
<path d="M38 64h20l4 10H34z" fill="#fff"/>
|
|
11
|
+
<path d="M66 20l3 7 7 3-7 3-3 7-3-7-7-3 7-3z" fill="#ffd66b"/>
|
|
12
|
+
</svg>
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
- insert:
|
|
2
|
+
- id: harness-forge
|
|
3
|
+
name: '@kirkchinese/harness-forge'
|
|
4
|
+
config: {}
|
|
5
|
+
- id: harness-forge-porter
|
|
6
|
+
name: '@kirkchinese/harness-forge/porter'
|
|
7
|
+
- id: harness-forge-sessions
|
|
8
|
+
name: '@kirkchinese/harness-forge/sessions'
|
|
9
|
+
- id: harness-forge-opencode
|
|
10
|
+
name: '@kirkchinese/harness-forge/opencode'
|
|
11
|
+
- id: harness-forge-mods
|
|
12
|
+
name: '@kirkchinese/harness-forge/mods'
|
|
13
|
+
- id: harness-forge-mcp
|
|
14
|
+
name: '@kirkchinese/harness-forge/mcp'
|
|
15
|
+
- id: harness-forge-hooks
|
|
16
|
+
name: '@kirkchinese/harness-forge/hooks'
|
|
17
|
+
- id: harness-forge-agents
|
|
18
|
+
name: '@kirkchinese/harness-forge/agents'
|
|
19
|
+
- id: harness-forge-commands
|
|
20
|
+
name: '@kirkchinese/harness-forge/commands'
|
|
21
|
+
- id: harness-forge-context
|
|
22
|
+
name: '@kirkchinese/harness-forge/context'
|
|
23
|
+
- id: harness-forge-skills
|
|
24
|
+
name: '@kirkchinese/harness-forge/skills'
|
|
25
|
+
config:
|
|
26
|
+
skillRoots: []
|
|
27
|
+
- id: harness-forge-workbench
|
|
28
|
+
name: '@kirkchinese/harness-forge/workbench'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreign agents as DSH agent presets, plus the delegation tool that offers
|
|
3
|
+
* them to the model.
|
|
4
|
+
*
|
|
5
|
+
* A DSH preset is a complete agent composition, so an imported agent starts
|
|
6
|
+
* from the host's default preset (the same tools, instructions and skills the
|
|
7
|
+
* main agent has), replaces its persona with the agent's prompt, and narrows
|
|
8
|
+
* its tools to the agent's `tools` / `disallowedTools`. The `agent` tool lists
|
|
9
|
+
* every imported agent with its description, as Claude Code's Task tool does.
|
|
10
|
+
* @module @kirkchinese/harness-forge
|
|
11
|
+
*/
|
|
12
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
+
import type { PresetDefinition } from '@deepseek-ai/dsh-agent-preset-registry';
|
|
14
|
+
import { type AgentComponent } from '@kirkchinese/harness-forge-core';
|
|
15
|
+
/** One mounted agent preset. */
|
|
16
|
+
export interface AgentMount {
|
|
17
|
+
readonly presetId: string;
|
|
18
|
+
readonly dispose: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
type PresetRow = PresetDefinition['plugins'][number];
|
|
21
|
+
/** The registry surface used here. */
|
|
22
|
+
export interface AgentPresetRegistry {
|
|
23
|
+
readonly defaultId: string;
|
|
24
|
+
register(definition: PresetDefinition): Promise<() => Promise<void>>;
|
|
25
|
+
readDocument(id: string): Promise<{
|
|
26
|
+
readonly content: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/** The model-facing delegation tool for imported agents. */
|
|
30
|
+
export declare const AGENT_TOOL_NAME = "agent";
|
|
31
|
+
/** The preset id an imported agent is registered under. */
|
|
32
|
+
export declare function agentPresetId(pluginName: string, agentName: string): string;
|
|
33
|
+
/** Map an agent's tool lists to DSH tool names; unknown names are reported. */
|
|
34
|
+
export declare function agentTools(component: AgentComponent): {
|
|
35
|
+
allow?: string[];
|
|
36
|
+
deny?: string[];
|
|
37
|
+
unknown: string[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Narrow the default preset's rows to an agent's tools: a row whose tools are
|
|
41
|
+
* all excluded is dropped, a row with per-tool switches keeps only the
|
|
42
|
+
* allowed ones. Tools a row cannot switch off individually are denied by the
|
|
43
|
+
* filter row.
|
|
44
|
+
*/
|
|
45
|
+
export declare function narrowRows(rows: readonly PresetRow[], allow: ReadonlySet<string> | undefined, deny: ReadonlySet<string>): PresetRow[];
|
|
46
|
+
/**
|
|
47
|
+
* Register one agent as a preset built on the host's default preset.
|
|
48
|
+
* @throws when the host composes no preset registry (headless and SDK profiles).
|
|
49
|
+
*/
|
|
50
|
+
export declare function mountAgentPreset(ctx: Context, component: AgentComponent, pluginName: string): Promise<AgentMount>;
|
|
51
|
+
/** The default preset's rows, the base every generated preset starts from. */
|
|
52
|
+
export declare function baseRows(registry: AgentPresetRegistry): Promise<PresetRow[]>;
|
|
53
|
+
/**
|
|
54
|
+
* The `agent` delegation tool: one `dsh-tool-subagent` instance whose
|
|
55
|
+
* selectable presets are exactly the imported agents.
|
|
56
|
+
*
|
|
57
|
+
* A session's project agents get a tool of their own, mounted in that
|
|
58
|
+
* agent's context: it shadows the global tool for the session and offers the
|
|
59
|
+
* global agents too.
|
|
60
|
+
*/
|
|
61
|
+
export declare class AgentTool {
|
|
62
|
+
private readonly ctx;
|
|
63
|
+
private readonly inherited?;
|
|
64
|
+
private readonly presets;
|
|
65
|
+
private readonly scoped;
|
|
66
|
+
private holding;
|
|
67
|
+
private fiber;
|
|
68
|
+
/**
|
|
69
|
+
* @param inherited - the global tool whose agents a session-scoped tool also offers.
|
|
70
|
+
*/
|
|
71
|
+
constructor(ctx: Context, inherited?: AgentTool | undefined);
|
|
72
|
+
/** Offer one preset under its foreign name; returns the withdrawal. */
|
|
73
|
+
add(presetId: string, foreignName: string): () => void;
|
|
74
|
+
/** The foreign agent name of a preset (`plugin:agent`), for hook payloads. */
|
|
75
|
+
foreignName(presetId: string): string | undefined;
|
|
76
|
+
/** The preset of a foreign agent name: `plugin:agent`, or the bare agent name when it is unique. */
|
|
77
|
+
presetOf(foreignName: string): string | undefined;
|
|
78
|
+
/** Wait until the tool offers its current agents (a config update restarts the tool). */
|
|
79
|
+
settled(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Collect several `add` calls into one tool start. A tool mounted in an
|
|
82
|
+
* agent's context does not take config updates (the preset owns its rows),
|
|
83
|
+
* so a session's project agents are offered all at once.
|
|
84
|
+
*/
|
|
85
|
+
hold(): void;
|
|
86
|
+
/** End a {@link hold}: the tool starts once with every agent added meanwhile. */
|
|
87
|
+
resume(): void;
|
|
88
|
+
dispose(): Promise<void>;
|
|
89
|
+
private refresh;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { entryListSchema } from '@deepseek-ai/cordis-plugin-include';
|
|
2
|
+
import * as subagentTool from '@deepseek-ai/dsh-tool-subagent';
|
|
3
|
+
import { load } from 'js-yaml';
|
|
4
|
+
import { kebabCase, toolList } from '@kirkchinese/harness-forge-core';
|
|
5
|
+
import { dshToolsFor } from '../hooks/vocabulary.js';
|
|
6
|
+
import { dshService } from '../dsh/host.js';
|
|
7
|
+
/** The persona row every built-in preset carries. */
|
|
8
|
+
const PERSONA = '@deepseek-ai/dsh-persona';
|
|
9
|
+
/** The row that loads AGENTS.md / CLAUDE.md into an agent's context. */
|
|
10
|
+
const INSTRUCTIONS = '@deepseek-ai/dsh-agent-instructions';
|
|
11
|
+
const TOOL_FILTER = '@kirkchinese/harness-forge/preset-tool-filter';
|
|
12
|
+
const FS_SEARCH = '@deepseek-ai/dsh-tool-fs-search';
|
|
13
|
+
const FS_SEARCH_STAND_IN = '@kirkchinese/harness-forge/preset-fs-search';
|
|
14
|
+
/** The model-facing delegation tool for imported agents. */
|
|
15
|
+
export const AGENT_TOOL_NAME = 'agent';
|
|
16
|
+
/** The preset id an imported agent is registered under. */
|
|
17
|
+
export function agentPresetId(pluginName, agentName) {
|
|
18
|
+
return kebabCase(`${pluginName}-${agentName}`);
|
|
19
|
+
}
|
|
20
|
+
/** Map an agent's tool lists to DSH tool names; unknown names are reported. */
|
|
21
|
+
export function agentTools(component) {
|
|
22
|
+
const unknown = [];
|
|
23
|
+
const map = (names) => {
|
|
24
|
+
if (names === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
const mapped = new Set();
|
|
27
|
+
for (const name of names) {
|
|
28
|
+
const tools = dshToolsFor(name, component.id.startsWith('codex:') ? 'codex' : 'claude-code');
|
|
29
|
+
if (tools.length === 0)
|
|
30
|
+
unknown.push(name);
|
|
31
|
+
for (const tool of tools)
|
|
32
|
+
mapped.add(tool);
|
|
33
|
+
}
|
|
34
|
+
return [...mapped];
|
|
35
|
+
};
|
|
36
|
+
const allow = map(toolList(component.frontmatter['tools']));
|
|
37
|
+
const deny = map(toolList(component.frontmatter['disallowedTools'] ?? component.frontmatter['disallowed-tools']));
|
|
38
|
+
return { ...(allow !== undefined ? { allow } : {}), ...(deny !== undefined ? { deny } : {}), unknown };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Which DSH tools each tool-providing preset row registers, and the row config
|
|
42
|
+
* switch for each tool when the row has one.
|
|
43
|
+
*/
|
|
44
|
+
const TOOL_ROWS = {
|
|
45
|
+
'@deepseek-ai/dsh-tool-bash': [{ tool: 'bash' }],
|
|
46
|
+
'@deepseek-ai/dsh-tool-pwsh': [{ tool: 'pwsh' }],
|
|
47
|
+
'@deepseek-ai/dsh-tool-fs': [{ tool: 'read', flag: 'read' }, { tool: 'read_image', flag: 'readImage' }, { tool: 'write', flag: 'write' }, { tool: 'edit', flag: 'edit' }],
|
|
48
|
+
'@deepseek-ai/dsh-tool-fs-search': [{ tool: 'glob' }, { tool: 'grep' }],
|
|
49
|
+
'@deepseek-ai/dsh-tool-jobs': [{ tool: 'job_output' }, { tool: 'job_kill' }],
|
|
50
|
+
'@deepseek-ai/dsh-tool-web': [{ tool: 'web_search', flag: 'search' }, { tool: 'web_fetch', flag: 'fetch' }],
|
|
51
|
+
'@deepseek-ai/dsh-tool-todo': [{ tool: 'todo_write' }],
|
|
52
|
+
'@deepseek-ai/dsh-tool-skill': [{ tool: 'skill' }],
|
|
53
|
+
'@deepseek-ai/dsh-tool-ask-user': [{ tool: 'ask_user_question' }],
|
|
54
|
+
'@deepseek-ai/dsh-plan-mode': [{ tool: 'exit_plan_mode' }],
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Rows that let an agent delegate. Claude Code subagents cannot start
|
|
58
|
+
* subagents unless their `tools` names the Agent tool.
|
|
59
|
+
*/
|
|
60
|
+
const DELEGATION_ROWS = new Set([
|
|
61
|
+
'@deepseek-ai/dsh-tool-subagent',
|
|
62
|
+
'@deepseek-ai/dsh-tool-subagent-control',
|
|
63
|
+
'@deepseek-ai/dsh-tool-subagent-control/list-agents',
|
|
64
|
+
'@deepseek-ai/dsh-workflow-ptc',
|
|
65
|
+
'@deepseek-ai/dsh-tool-workflow',
|
|
66
|
+
]);
|
|
67
|
+
/** Rows whose tools have no Claude Code counterpart; an explicit `tools` list leaves them out. */
|
|
68
|
+
const HOST_ONLY_ROWS = new Set([
|
|
69
|
+
'@deepseek-ai/dsh-tool-schedule',
|
|
70
|
+
'@deepseek-ai/dsh-tool-goal',
|
|
71
|
+
'@deepseek-ai/dsh-command-goal',
|
|
72
|
+
'@deepseek-ai/dsh-tool-present',
|
|
73
|
+
'@deepseek-ai/dsh-plugin-manager/tools',
|
|
74
|
+
'@deepseek-ai/dsh-plugin-market/tools',
|
|
75
|
+
]);
|
|
76
|
+
/**
|
|
77
|
+
* Narrow the default preset's rows to an agent's tools: a row whose tools are
|
|
78
|
+
* all excluded is dropped, a row with per-tool switches keeps only the
|
|
79
|
+
* allowed ones. Tools a row cannot switch off individually are denied by the
|
|
80
|
+
* filter row.
|
|
81
|
+
*/
|
|
82
|
+
export function narrowRows(rows, allow, deny) {
|
|
83
|
+
const allowed = (tool) => !deny.has(tool) && (allow === undefined || allow.has(tool));
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const row of rows) {
|
|
86
|
+
const name = row.name;
|
|
87
|
+
const nested = row.config;
|
|
88
|
+
if (name === 'cordis:group' && Array.isArray(nested)) {
|
|
89
|
+
const inner = narrowRows(nested, allow, deny);
|
|
90
|
+
if (inner.length > 0)
|
|
91
|
+
out.push({ ...row, config: inner });
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (typeof name !== 'string') {
|
|
95
|
+
out.push(row);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (DELEGATION_ROWS.has(name)) {
|
|
99
|
+
// Claude Code's Agent tool starts a subagent; DSH's control and workflow rows (send_message, list_agents,
|
|
100
|
+
// interrupt_agent, workflow) have no Claude Code counterpart, so a listed Agent keeps the spawn row only.
|
|
101
|
+
const spawn = name === '@deepseek-ai/dsh-tool-subagent';
|
|
102
|
+
if (spawn && allow !== undefined && (allow.has('agent') || allow.has('subagent')) && !deny.has('agent')) {
|
|
103
|
+
// Claude Code's Agent tool has no model discovery: DSH 0.2.2's row registers `list_subagent_models` with it on.
|
|
104
|
+
const config = row.config;
|
|
105
|
+
out.push(config?.['modelDiscovery'] === true ? { ...row, config: { ...config, modelDiscovery: false } } : row);
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (HOST_ONLY_ROWS.has(name)) {
|
|
110
|
+
if (allow === undefined)
|
|
111
|
+
out.push(row);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const tools = TOOL_ROWS[name];
|
|
115
|
+
if (tools === undefined) {
|
|
116
|
+
out.push(row);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const kept = tools.filter(item => allowed(item.tool));
|
|
120
|
+
if (kept.length === 0)
|
|
121
|
+
continue;
|
|
122
|
+
// DSH's search row registers glob and grep together, with no switch: one listed alone gets a stand-in row.
|
|
123
|
+
if (name === FS_SEARCH && kept.length < tools.length) {
|
|
124
|
+
out.push({ ...row, name: FS_SEARCH_STAND_IN, config: { ...row.config, tools: kept.map(item => item.tool) } });
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const flags = tools.filter(item => item.flag !== undefined);
|
|
128
|
+
if (flags.length === 0 || kept.length === tools.length) {
|
|
129
|
+
out.push(row);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const config = { ...row.config };
|
|
133
|
+
for (const item of flags)
|
|
134
|
+
config[item.flag] = allowed(item.tool);
|
|
135
|
+
out.push({ ...row, config });
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Register one agent as a preset built on the host's default preset.
|
|
141
|
+
* @throws when the host composes no preset registry (headless and SDK profiles).
|
|
142
|
+
*/
|
|
143
|
+
export async function mountAgentPreset(ctx, component, pluginName) {
|
|
144
|
+
const registry = dshService(ctx, 'agentPresets');
|
|
145
|
+
if (registry === undefined)
|
|
146
|
+
throw new Error('this DSH profile composes no agent presets; agents run in the Web and Desktop profiles');
|
|
147
|
+
if (component.body.trim().length === 0)
|
|
148
|
+
throw new Error(`agent "${component.name}" has an empty prompt`);
|
|
149
|
+
const base = await baseRows(registry);
|
|
150
|
+
const tools = agentTools(component);
|
|
151
|
+
// `memory` enables Read, Write and Edit for the memory files; `permissionMode: plan` is read-only.
|
|
152
|
+
const memory = ['user', 'project', 'local'].includes(String(component.frontmatter['memory']));
|
|
153
|
+
const planMode = component.frontmatter['permissionMode'] === 'plan';
|
|
154
|
+
const listed = tools.allow === undefined ? undefined : [...new Set([...tools.allow, ...(memory ? ['read', 'write', 'edit'] : [])])];
|
|
155
|
+
const denied = [...new Set([...tools.deny ?? [], ...(planMode ? ['write', 'edit'] : [])])];
|
|
156
|
+
const allow = listed === undefined ? undefined : new Set(listed);
|
|
157
|
+
const deny = new Set(denied);
|
|
158
|
+
// `omitClaudeMd` starts the agent without the project instruction files.
|
|
159
|
+
const rows = narrowRows(base, allow, deny).filter(row => !(component.frontmatter['omitClaudeMd'] === true && row.name === INSTRUCTIONS));
|
|
160
|
+
const filter = { ...(listed !== undefined ? { allow: listed } : {}), ...(denied.length > 0 ? { deny: denied } : {}) };
|
|
161
|
+
const plugins = [
|
|
162
|
+
...rows.map(row => row.name === PERSONA ? { ...row, config: { ...row.config, prefix: component.body.trim() } } : row),
|
|
163
|
+
...(Object.keys(filter).length > 0 ? [{ id: 'harness-forge-tool-filter', name: TOOL_FILTER, config: filter }] : []),
|
|
164
|
+
];
|
|
165
|
+
const presetId = agentPresetId(pluginName, component.name);
|
|
166
|
+
const dispose = await registry.register({
|
|
167
|
+
id: presetId,
|
|
168
|
+
name: `${pluginName}:${component.name}`,
|
|
169
|
+
description: component.description ?? `Agent ${component.name} from ${pluginName}`,
|
|
170
|
+
order: 100,
|
|
171
|
+
plugins,
|
|
172
|
+
});
|
|
173
|
+
return { presetId, dispose };
|
|
174
|
+
}
|
|
175
|
+
/** The default preset's rows, the base every generated preset starts from. */
|
|
176
|
+
export async function baseRows(registry) {
|
|
177
|
+
const document = await registry.readDocument(registry.defaultId);
|
|
178
|
+
const rows = load(document.content, { schema: entryListSchema });
|
|
179
|
+
if (!Array.isArray(rows) || !rows.some(row => row.name === PERSONA)) {
|
|
180
|
+
throw new Error(`default preset "${registry.defaultId}" has no persona row to replace`);
|
|
181
|
+
}
|
|
182
|
+
return rows;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The `agent` delegation tool: one `dsh-tool-subagent` instance whose
|
|
186
|
+
* selectable presets are exactly the imported agents.
|
|
187
|
+
*
|
|
188
|
+
* A session's project agents get a tool of their own, mounted in that
|
|
189
|
+
* agent's context: it shadows the global tool for the session and offers the
|
|
190
|
+
* global agents too.
|
|
191
|
+
*/
|
|
192
|
+
export class AgentTool {
|
|
193
|
+
ctx;
|
|
194
|
+
inherited;
|
|
195
|
+
presets = new Map();
|
|
196
|
+
scoped = new Set();
|
|
197
|
+
holding = false;
|
|
198
|
+
fiber;
|
|
199
|
+
/**
|
|
200
|
+
* @param inherited - the global tool whose agents a session-scoped tool also offers.
|
|
201
|
+
*/
|
|
202
|
+
constructor(ctx, inherited) {
|
|
203
|
+
this.ctx = ctx;
|
|
204
|
+
this.inherited = inherited;
|
|
205
|
+
inherited?.scoped.add(this);
|
|
206
|
+
}
|
|
207
|
+
/** Offer one preset under its foreign name; returns the withdrawal. */
|
|
208
|
+
add(presetId, foreignName) {
|
|
209
|
+
this.presets.set(presetId, foreignName);
|
|
210
|
+
this.refresh();
|
|
211
|
+
return () => {
|
|
212
|
+
this.presets.delete(presetId);
|
|
213
|
+
this.refresh();
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/** The foreign agent name of a preset (`plugin:agent`), for hook payloads. */
|
|
217
|
+
foreignName(presetId) {
|
|
218
|
+
const own = this.presets.get(presetId);
|
|
219
|
+
if (own !== undefined)
|
|
220
|
+
return own;
|
|
221
|
+
for (const tool of this.scoped) {
|
|
222
|
+
const name = tool.presets.get(presetId);
|
|
223
|
+
if (name !== undefined)
|
|
224
|
+
return name;
|
|
225
|
+
}
|
|
226
|
+
return this.inherited?.foreignName(presetId);
|
|
227
|
+
}
|
|
228
|
+
/** The preset of a foreign agent name: `plugin:agent`, or the bare agent name when it is unique. */
|
|
229
|
+
presetOf(foreignName) {
|
|
230
|
+
const all = [...this.presets, ...[...this.scoped].flatMap(tool => [...tool.presets])];
|
|
231
|
+
const matches = all.filter(([, name]) => name === foreignName || name.split(':').at(-1) === foreignName);
|
|
232
|
+
if (matches.length === 1)
|
|
233
|
+
return matches[0]?.[0];
|
|
234
|
+
return matches.find(([, name]) => name === foreignName)?.[0] ?? this.inherited?.presetOf(foreignName);
|
|
235
|
+
}
|
|
236
|
+
/** Wait until the tool offers its current agents (a config update restarts the tool). */
|
|
237
|
+
async settled() {
|
|
238
|
+
await this.fiber?.await();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Collect several `add` calls into one tool start. A tool mounted in an
|
|
242
|
+
* agent's context does not take config updates (the preset owns its rows),
|
|
243
|
+
* so a session's project agents are offered all at once.
|
|
244
|
+
*/
|
|
245
|
+
hold() {
|
|
246
|
+
this.holding = true;
|
|
247
|
+
}
|
|
248
|
+
/** End a {@link hold}: the tool starts once with every agent added meanwhile. */
|
|
249
|
+
resume() {
|
|
250
|
+
if (!this.holding)
|
|
251
|
+
return;
|
|
252
|
+
this.holding = false;
|
|
253
|
+
this.refresh();
|
|
254
|
+
}
|
|
255
|
+
async dispose() {
|
|
256
|
+
this.inherited?.scoped.delete(this);
|
|
257
|
+
const fiber = this.fiber;
|
|
258
|
+
this.fiber = undefined;
|
|
259
|
+
await fiber?.dispose();
|
|
260
|
+
}
|
|
261
|
+
refresh() {
|
|
262
|
+
if (this.holding)
|
|
263
|
+
return;
|
|
264
|
+
for (const tool of this.scoped)
|
|
265
|
+
tool.refresh();
|
|
266
|
+
// A session tool exists only while the session has agents of its own.
|
|
267
|
+
const ids = this.presets.size === 0
|
|
268
|
+
? []
|
|
269
|
+
: [...new Set([...this.inherited?.presets.keys() ?? [], ...this.presets.keys()])].sort((a, b) => a.localeCompare(b, 'en'));
|
|
270
|
+
if (ids.length === 0) {
|
|
271
|
+
const fiber = this.fiber;
|
|
272
|
+
this.fiber = undefined;
|
|
273
|
+
void fiber?.dispose();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const config = { provider: 'spawn', toolName: AGENT_TOOL_NAME, allowedAgentPresets: ids };
|
|
277
|
+
if (this.fiber === undefined)
|
|
278
|
+
this.fiber = this.ctx.plugin(subagentTool, config);
|
|
279
|
+
else
|
|
280
|
+
this.fiber.update(config);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ForeignShell } from '../hooks/shell.js';
|
|
3
|
+
import { type McpVariables, type RemoteMcpHost } from '../mcp/mount.js';
|
|
4
|
+
/** An imported agent's run-time frontmatter. */
|
|
5
|
+
export interface AgentProfile {
|
|
6
|
+
readonly presetId: string;
|
|
7
|
+
/** The agent's own name (memory directories use it). */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly pluginId: string;
|
|
10
|
+
readonly frontmatter: Readonly<Record<string, unknown>>;
|
|
11
|
+
readonly vars: McpVariables;
|
|
12
|
+
}
|
|
13
|
+
/** The parsed run-time fields of an agent's frontmatter. */
|
|
14
|
+
export interface AgentRuntimeFields {
|
|
15
|
+
readonly model?: string;
|
|
16
|
+
readonly effort?: string;
|
|
17
|
+
readonly skills: readonly string[];
|
|
18
|
+
readonly mcpServers: ReadonlyArray<{
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly config?: Readonly<Record<string, unknown>>;
|
|
21
|
+
}>;
|
|
22
|
+
readonly maxTurns?: number;
|
|
23
|
+
readonly memory?: 'user' | 'project' | 'local';
|
|
24
|
+
readonly isolation?: 'worktree';
|
|
25
|
+
readonly initialPrompt?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Read the run-time fields of an agent's frontmatter. */
|
|
28
|
+
export declare function agentRuntimeFields(frontmatter: Readonly<Record<string, unknown>>): AgentRuntimeFields;
|
|
29
|
+
/** The memory directory of an agent for a scope. */
|
|
30
|
+
export declare function agentMemoryDir(scope: 'user' | 'project' | 'local', name: string, projectDir: string, home?: string): string;
|
|
31
|
+
/** The memory instructions an agent starts with. */
|
|
32
|
+
export declare function memoryInstructions(dir: string): string;
|
|
33
|
+
/** Run-time effects of imported agents' frontmatter. */
|
|
34
|
+
export declare class AgentProfiles {
|
|
35
|
+
private readonly ctx;
|
|
36
|
+
private readonly shell;
|
|
37
|
+
private readonly dataRoot;
|
|
38
|
+
private readonly remoteHost;
|
|
39
|
+
private readonly profiles;
|
|
40
|
+
private readonly runs;
|
|
41
|
+
/** Worktrees created for isolated agents, by path. */
|
|
42
|
+
private readonly worktrees;
|
|
43
|
+
constructor(ctx: Context, shell: ForeignShell, dataRoot: string, remoteHost: (componentId: string) => RemoteMcpHost);
|
|
44
|
+
register(profile: AgentProfile): () => void;
|
|
45
|
+
/** The preset of an `agent` tool call that runs an isolated agent, for its worktree. */
|
|
46
|
+
isolated(presetId: unknown): boolean;
|
|
47
|
+
/** Listen on the host. Returns the disposer. */
|
|
48
|
+
install(): () => void;
|
|
49
|
+
private presetOf;
|
|
50
|
+
private created;
|
|
51
|
+
private disposed;
|
|
52
|
+
/**
|
|
53
|
+
* Create the worktree an isolated agent runs in, branched from the
|
|
54
|
+
* repository's current HEAD.
|
|
55
|
+
* @returns the worktree directory, or undefined outside a git repository.
|
|
56
|
+
*/
|
|
57
|
+
worktree(cwd: string): Promise<string | undefined>;
|
|
58
|
+
}
|