@crazx/dsh 0.1.0-rc.7.zw.2
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.i18n.yaml +6 -0
- package/README.md +47 -0
- package/README.zh.md +47 -0
- package/config/agent-presets/code/agent.cordis.yml +262 -0
- package/config/agent-presets/code/preset.yml +3 -0
- package/config/agent-presets/cordis/agent.cordis.yml +262 -0
- package/config/agent-presets/cordis/preset.yml +3 -0
- package/config/agent-presets/cordis/skills/cordis-plugin-development/SKILL.md +420 -0
- package/config/agent-presets/cordis/skills/editing-cordis-compositions/SKILL.md +154 -0
- package/config/agent-presets/minimal/agent.cordis.yml +62 -0
- package/config/agent-presets/minimal/preset.yml +3 -0
- package/config/agent-presets/standard/agent.cordis.yml +251 -0
- package/config/agent-presets/standard/preset.yml +3 -0
- package/lib/bin.js +185 -0
- package/lib/dump-config-D-jtgwY3.js +52 -0
- package/lib/plugin-9h8shc4d.js +129 -0
- package/lib/profile-boot-BnJoK_kl.js +2 -0
- package/lib/profile-boot-DG5t9aNs.js +283 -0
- package/lib/web-log-CKn_UFWp.js +83 -0
- package/lib/web-log-DZLBFfre.js +96 -0
- package/package.json +101 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# The `standard` agent preset: the full coding agent, mounted once per process.
|
|
2
|
+
#
|
|
3
|
+
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
|
|
4
|
+
# standing scope; every session naming it joins by scope parentage, so the
|
|
5
|
+
# tools and prompt sections registered here cover each joined agent while a
|
|
6
|
+
# session's own state stays keyed per Session/Agent inside the plugins. The
|
|
7
|
+
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
|
|
8
|
+
# preset must not own: the registries themselves, the sandbox and approval
|
|
9
|
+
# stack, persistence, and the model route.
|
|
10
|
+
#
|
|
11
|
+
# A service row here MUST sit inside a group carrying an `isolate` realm.
|
|
12
|
+
# Without one it publishes into the root realm, where it is process-global —
|
|
13
|
+
# another preset publishing the same name collides, and a host reader would
|
|
14
|
+
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
|
|
15
|
+
# that at mount. `true` means an entry-local realm: this standing mount's own
|
|
16
|
+
# private instance, apart from every other preset's. (A shared label does NOT
|
|
17
|
+
# pool instances — `provide()` throws on the second registration under the
|
|
18
|
+
# same realm symbol; labels join REALMS, and are not what this file needs.)
|
|
19
|
+
|
|
20
|
+
# ── identity ────────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
# The preset's own persona, shadowing the deployment default for this agent.
|
|
23
|
+
# `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
|
|
24
|
+
- id: persona
|
|
25
|
+
name: '@deepseek-ai/dsh-persona'
|
|
26
|
+
config:
|
|
27
|
+
text: >-
|
|
28
|
+
You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}.
|
|
29
|
+
|
|
30
|
+
- id: agent-instructions
|
|
31
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
32
|
+
config:
|
|
33
|
+
maxBytes: 65536
|
|
34
|
+
|
|
35
|
+
# ── shell ───────────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
# `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
|
|
38
|
+
# publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
|
|
39
|
+
# the criterion for host-plane ownership — injection resolves before any session
|
|
40
|
+
# exists, so there is no agent to key by. Behind a preset realm those variables
|
|
41
|
+
# never reached the model's shell at all. Both shell tools consume the host
|
|
42
|
+
# registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
|
|
43
|
+
# host-plane too.
|
|
44
|
+
- id: tool-bash
|
|
45
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
46
|
+
disabled: !!js process.platform === 'win32'
|
|
47
|
+
|
|
48
|
+
- id: tool-pwsh
|
|
49
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
50
|
+
disabled: !!js process.platform !== 'win32'
|
|
51
|
+
|
|
52
|
+
# ── filesystem ──────────────────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
# Both register into the host `tools` registry and provide nothing, so
|
|
55
|
+
# they need no realm. The `fs` service and its policy stay in the host.
|
|
56
|
+
- id: tool-fs
|
|
57
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
58
|
+
|
|
59
|
+
- id: tool-fs-search
|
|
60
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
61
|
+
config:
|
|
62
|
+
sampleOverCapGlobResults: false
|
|
63
|
+
|
|
64
|
+
# ── background jobs ────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
# Only the model-facing controls. The task REGISTRY stays on the host plane:
|
|
67
|
+
# its producers sit outside any realm this file could put it in — `tool-bash`
|
|
68
|
+
# above resolves it with `ctx.get`, and an entry-local realm here is invisible
|
|
69
|
+
# to every sibling row, so `run_in_background` would answer "background jobs
|
|
70
|
+
# unavailable" while these controls sat in the catalog. The registry is keyed by
|
|
71
|
+
# owning agent anyway, so one host instance serves every session. What a preset
|
|
72
|
+
# chooses is whether its agent can collect and stop background work at all.
|
|
73
|
+
- id: tool-jobs
|
|
74
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
75
|
+
|
|
76
|
+
# ── skills ──────────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
# The skill REGISTRY lives in the host composition and is layered per scope:
|
|
79
|
+
# these rows register into THIS preset's layer of it, so they need no realm.
|
|
80
|
+
# `skill-filesystem` contributes local-root discovery for agents on this preset, and
|
|
81
|
+
# `tool-skill` gives them the catalog and loader; the merged catalog also
|
|
82
|
+
# carries whatever the deployment registered globally (repository plugins).
|
|
83
|
+
- id: skill-filesystem
|
|
84
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
85
|
+
|
|
86
|
+
- id: tool-skill
|
|
87
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
88
|
+
|
|
89
|
+
# ── goals ───────────────────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
# Only the model-facing tool. The goal SERVICE, its session driver, and the
|
|
92
|
+
# `/goal` command stay on the host plane: the Gateway serves the goal domain as
|
|
93
|
+
# Remote endpoints whose receiver comes from a generated descriptor, so it
|
|
94
|
+
# resolves `goals` on the host and an entry-local realm here would hide it. The
|
|
95
|
+
# registry is keyed by session anyway, so one host instance serves every
|
|
96
|
+
# session. What a preset chooses is whether its agent can call the goal tool.
|
|
97
|
+
- id: tool-goal
|
|
98
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
99
|
+
|
|
100
|
+
# ── plan mode ───────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
# Plan state is per-agent by nature, so an entry-local realm is not a
|
|
103
|
+
# workaround here — it is the correct lifetime.
|
|
104
|
+
- id: planning
|
|
105
|
+
name: cordis:group
|
|
106
|
+
group: true
|
|
107
|
+
isolate:
|
|
108
|
+
planMode: true
|
|
109
|
+
config:
|
|
110
|
+
- id: plan-mode
|
|
111
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
112
|
+
config:
|
|
113
|
+
section: |
|
|
114
|
+
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
115
|
+
|
|
116
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
117
|
+
|
|
118
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
119
|
+
|
|
120
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
121
|
+
|
|
122
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
123
|
+
|
|
124
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
125
|
+
|
|
126
|
+
# ── compaction ──────────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
|
|
129
|
+
# share this realm rather than sit outside it.
|
|
130
|
+
#
|
|
131
|
+
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
|
|
132
|
+
# plane, and the rows here resolve that one instance. It takes no configuration,
|
|
133
|
+
# keys every fold by Session, and owns the context-meter projection units the
|
|
134
|
+
# browser reads for every session — behind a realm those units would come and go
|
|
135
|
+
# with whichever presets happen to be mounted. What a preset chooses is whether
|
|
136
|
+
# its agent compacts at all, which is `compaction-basic` below.
|
|
137
|
+
- id: compaction
|
|
138
|
+
name: cordis:group
|
|
139
|
+
group: true
|
|
140
|
+
isolate:
|
|
141
|
+
compaction: true
|
|
142
|
+
toolResultPruner: true
|
|
143
|
+
config:
|
|
144
|
+
- id: compaction-basic
|
|
145
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
146
|
+
|
|
147
|
+
- id: command-compact
|
|
148
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
149
|
+
|
|
150
|
+
- id: tool-result-pruner
|
|
151
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
152
|
+
config:
|
|
153
|
+
thresholdChars: 8192
|
|
154
|
+
headChars: 4096
|
|
155
|
+
tailChars: 1024
|
|
156
|
+
|
|
157
|
+
# ── delegation and workflows ────────────────────────────────────────────────
|
|
158
|
+
|
|
159
|
+
# The `subagents` registry and its spawn/fork backends live in the HOST
|
|
160
|
+
# composition: the registry is a process singleton whose cross-session queries
|
|
161
|
+
# the api-proxy serves to the browser, and a provider name may only be
|
|
162
|
+
# registered once. This preset contributes the delegation TOOLS, which resolve
|
|
163
|
+
# that host registry.
|
|
164
|
+
#
|
|
165
|
+
# `workflows` is different — nothing outside an agent reads it — so every row
|
|
166
|
+
# that reaches it shares one entry-local realm here, and a consumer left
|
|
167
|
+
# outside would resolve a host registry this preset does not populate.
|
|
168
|
+
#
|
|
169
|
+
# `tool-subagent-report` is host-plane for the same reason as the registry,
|
|
170
|
+
# not because a preset may not want it: it registers a CONTINUABLE SETUP on
|
|
171
|
+
# that singleton rather than a tool this agent calls, and the setup list is
|
|
172
|
+
# not scope-aware — one copy per mounted preset means every child gets
|
|
173
|
+
# `report` registered once per live session, which throws on the second.
|
|
174
|
+
- id: delegation
|
|
175
|
+
name: cordis:group
|
|
176
|
+
group: true
|
|
177
|
+
isolate:
|
|
178
|
+
workflowEngine: true
|
|
179
|
+
config:
|
|
180
|
+
- id: tool-subagent-control
|
|
181
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
182
|
+
|
|
183
|
+
- id: tool-subagent-list-agents
|
|
184
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
185
|
+
|
|
186
|
+
- id: tool-subagent
|
|
187
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
188
|
+
config:
|
|
189
|
+
provider: spawn
|
|
190
|
+
toolName: subagent
|
|
191
|
+
backgroundMode: continuable
|
|
192
|
+
|
|
193
|
+
- id: tool-subagent-fork
|
|
194
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
195
|
+
config:
|
|
196
|
+
provider: fork
|
|
197
|
+
toolName: subagent_fork
|
|
198
|
+
backgroundMode: continuable
|
|
199
|
+
|
|
200
|
+
# Production dsh does not install these optional providers. An opting-in
|
|
201
|
+
# Profile mounts each provider once on the host plane; copy this preset,
|
|
202
|
+
# then remove `disabled` from the matching tool row.
|
|
203
|
+
- id: tool-subagent-codex
|
|
204
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
205
|
+
disabled: true
|
|
206
|
+
config:
|
|
207
|
+
provider: codex
|
|
208
|
+
toolName: subagent_codex
|
|
209
|
+
backgroundMode: one-shot
|
|
210
|
+
maxDepth: provider-managed
|
|
211
|
+
|
|
212
|
+
- id: tool-subagent-claude-code
|
|
213
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
214
|
+
disabled: true
|
|
215
|
+
config:
|
|
216
|
+
provider: claude-code
|
|
217
|
+
toolName: subagent_claude_code
|
|
218
|
+
backgroundMode: one-shot
|
|
219
|
+
maxDepth: provider-managed
|
|
220
|
+
|
|
221
|
+
- id: workflow-worker-thread
|
|
222
|
+
name: '@deepseek-ai/dsh-workflow-worker-thread'
|
|
223
|
+
config:
|
|
224
|
+
provider: spawn
|
|
225
|
+
|
|
226
|
+
- id: tool-workflow
|
|
227
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
228
|
+
|
|
229
|
+
- id: tool-ralph
|
|
230
|
+
name: '@deepseek-ai/dsh-tool-ralph'
|
|
231
|
+
config:
|
|
232
|
+
subagentProvider: spawn
|
|
233
|
+
maxRounds: 64
|
|
234
|
+
|
|
235
|
+
# ── remaining model-facing rows ─────────────────────────────────────────────
|
|
236
|
+
|
|
237
|
+
- id: tool-ask-user
|
|
238
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
239
|
+
|
|
240
|
+
- id: tool-todo
|
|
241
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
242
|
+
config:
|
|
243
|
+
allowParallelInProgress: true
|
|
244
|
+
|
|
245
|
+
# The `web` service and its search provider stay in the host composition; only
|
|
246
|
+
# the model-facing tool is per-session.
|
|
247
|
+
- id: tool-web
|
|
248
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
249
|
+
config:
|
|
250
|
+
fetch: false
|
|
251
|
+
searchTimeoutMs: 60000
|
package/lib/bin.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { loadLayeredEnv } from "@deepseek-ai/dsh-app-boot";
|
|
5
|
+
import { Command, CommanderError } from "commander";
|
|
6
|
+
//#region lib/types/args.js
|
|
7
|
+
/**
|
|
8
|
+
* Commander adapter for the `dsh` command line.
|
|
9
|
+
*
|
|
10
|
+
* The launcher parses only what it owns — which profile to boot, which extra
|
|
11
|
+
* patch overlays to apply, and the config dumps — and hands **everything after
|
|
12
|
+
* its own flags** to the booted tree verbatim, where injected app plugins parse
|
|
13
|
+
* their own flag families and print their own `--help` (see
|
|
14
|
+
* `@deepseek-ai/dsh-cmdline`). Launcher flags therefore come first: the first
|
|
15
|
+
* token this parser does not recognize starts the inner arguments, so
|
|
16
|
+
* `dsh --profile tui --resume abc` boots the tui profile with `--resume abc`,
|
|
17
|
+
* and `dsh --profile web -h` prints the web app's help, not this one's.
|
|
18
|
+
*
|
|
19
|
+
* `web` is a hardcoded alias for `--profile web`; `plugin` manages a profile's
|
|
20
|
+
* plugin dependencies by forwarding to pnpm. The fork adds `web:log` /
|
|
21
|
+
* `web:log:tmp`, which boot the web profile while teeing output to a log file.
|
|
22
|
+
* @module @deepseek-ai/dsh/args
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Repeatable single-value collector: `--patch a.yml --patch b.yml`. Never
|
|
26
|
+
* variadic — a variadic `--patch` would swallow the inner arguments.
|
|
27
|
+
*/
|
|
28
|
+
const collect = (value, previous = []) => [...previous, value];
|
|
29
|
+
/** The launcher's own help text; each app prints its own. */
|
|
30
|
+
const HELP_EXAMPLES = `
|
|
31
|
+
Examples:
|
|
32
|
+
dsh --profile web boot the web profile (same as: dsh web)
|
|
33
|
+
dsh --profile headless "run the tests" answer one task, print the result, and exit
|
|
34
|
+
dsh --profile tui --patch ./extra.yml boot a custom profile with one extra overlay
|
|
35
|
+
dsh --profile tui --resume <session> arguments after the launcher flags reach the app
|
|
36
|
+
dsh --profile web --help the web app's own flags and help
|
|
37
|
+
dsh plugin --profile tui add <package> install a plugin into the tui profile
|
|
38
|
+
dsh web:log --port 0 boot web with output teed to a timestamped log file (fork-local)
|
|
39
|
+
`;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a boot or dump invocation from the launcher flags and the leftover
|
|
42
|
+
* inner arguments.
|
|
43
|
+
* @param program - the command whose options were parsed (the root, or the `web` alias).
|
|
44
|
+
* @param profile - the profile these flags boot.
|
|
45
|
+
* @param options - the launcher flags commander collected.
|
|
46
|
+
* @param args - the leftover arguments, in argv order.
|
|
47
|
+
* @returns the resolved invocation.
|
|
48
|
+
*/
|
|
49
|
+
function resolveBoot(program, profile, options, args) {
|
|
50
|
+
const patches = options.patch ?? [];
|
|
51
|
+
if (patches.includes("")) program.error("error: --patch needs a path");
|
|
52
|
+
if (options.dumpConfig !== true && options.dumpDefaultConfig !== true) return {
|
|
53
|
+
mode: "profile",
|
|
54
|
+
profile,
|
|
55
|
+
patches,
|
|
56
|
+
args
|
|
57
|
+
};
|
|
58
|
+
if (options.dumpConfig === true && options.dumpDefaultConfig === true) program.error("error: --dump-config and --dump-default-config are mutually exclusive");
|
|
59
|
+
if (args.length > 0) program.error(`error: config dumps take no app arguments, got ${args.map((argument) => JSON.stringify(argument)).join(" ")}`);
|
|
60
|
+
const defaultOnly = options.dumpDefaultConfig === true;
|
|
61
|
+
if (defaultOnly && patches.length > 0) program.error("error: --dump-default-config prints the bundle layers and takes no --patch");
|
|
62
|
+
return {
|
|
63
|
+
mode: "dump-config",
|
|
64
|
+
profile,
|
|
65
|
+
defaultOnly,
|
|
66
|
+
patches
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Resolve argv into one invocation, or print and exit for help, version, or an
|
|
71
|
+
* error.
|
|
72
|
+
* @param argv - arguments after the Node binary and script.
|
|
73
|
+
* @param version - version string printed by `--version`.
|
|
74
|
+
* @returns the resolved invocation.
|
|
75
|
+
*/
|
|
76
|
+
function parseDshArgs(argv, version) {
|
|
77
|
+
let resolved;
|
|
78
|
+
const program = new Command();
|
|
79
|
+
program.name("dsh").version(version, "-V, --version", "output the version number").description("dsh: boot a DeepSeek Harness profile — an ordered stack of plugin-bundle patch layers under your own overrides.").addHelpText("after", HELP_EXAMPLES).exitOverride().helpOption(false).allowUnknownOption().passThroughOptions().enablePositionalOptions().argument("[args...]", "arguments for the booted profile's app (see: dsh --profile <name> --help)").option("--profile <name>", "the profile under $DSH_HOME/profiles to boot").option("--patch <path>", "extra patch-list overlay applied after the profile layer (repeatable)", collect).option("--dump-config", "print the composed profile tree and exit").option("--dump-default-config", "print the profile tree without its user layer or --patch overlays and exit").action((args, options) => {
|
|
80
|
+
if (options.profile === void 0) {
|
|
81
|
+
if (args.some((argument) => argument === "-h" || argument === "--help")) program.help();
|
|
82
|
+
program.error("error: --profile <name> is required");
|
|
83
|
+
}
|
|
84
|
+
const profile = options.profile;
|
|
85
|
+
if (profile === "") program.error("error: --profile needs a name");
|
|
86
|
+
resolved = resolveBoot(program, profile, options, args);
|
|
87
|
+
});
|
|
88
|
+
/** Reject parent options supplied before a subcommand. */
|
|
89
|
+
const rejectParentOptions = (command) => {
|
|
90
|
+
const parent = program.opts();
|
|
91
|
+
if (parent.profile !== void 0 || parent.patch !== void 0 || parent.dumpConfig !== void 0 || parent.dumpDefaultConfig !== void 0) program.error(`error: ${command} takes none of parent --profile, --patch, --dump-config, or --dump-default-config`);
|
|
92
|
+
};
|
|
93
|
+
const web = program.command("web").description("boot the web profile (alias of --profile web); the web app's own flags follow");
|
|
94
|
+
web.helpOption(false).allowUnknownOption().passThroughOptions().enablePositionalOptions().argument("[args...]", "arguments for the web app (see: dsh web --help)").option("--patch <path>", "extra patch-list overlay applied after the profile layer (repeatable)", collect).option("--dump-config", "print the composed web-profile tree (with the user layer and any --patch) and exit").option("--dump-default-config", "print the web profile's bundle layers (no user layer) and exit").action((args, options) => {
|
|
95
|
+
rejectParentOptions("web");
|
|
96
|
+
resolved = resolveBoot(web, "web", options, args);
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Fork-local logged web boots: `dsh web:log` tees the web app's output to a
|
|
100
|
+
* timestamped file under $DSH_HOME/logs, `dsh web:log:tmp` under the OS temp
|
|
101
|
+
* dir. Flag shape mirrors the `web` alias minus the boot-free dumps.
|
|
102
|
+
*/
|
|
103
|
+
const registerWebLog = (name, tmp) => {
|
|
104
|
+
program.command(name).description(tmp ? "boot the web profile, teeing its output to a log file under the OS temp dir (fork-local)" : "boot the web profile, teeing its output to a log file under $DSH_HOME/logs (fork-local)").helpOption(false).allowUnknownOption().passThroughOptions().enablePositionalOptions().argument("[args...]", "arguments for the web app (see: dsh web --help)").option("--patch <path>", "extra patch-list overlay applied after the profile layer (repeatable)", collect).action((args, options) => {
|
|
105
|
+
rejectParentOptions(name);
|
|
106
|
+
const patches = options.patch ?? [];
|
|
107
|
+
if (patches.includes("")) program.error("error: --patch needs a path");
|
|
108
|
+
resolved = {
|
|
109
|
+
mode: "web-log",
|
|
110
|
+
tmp,
|
|
111
|
+
patches,
|
|
112
|
+
args
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
registerWebLog("web:log", false);
|
|
117
|
+
registerWebLog("web:log:tmp", true);
|
|
118
|
+
program.command("plugin").description("manage a profile's plugins by forwarding the remaining arguments to pnpm in the profile directory").requiredOption("--profile <name>", "the profile whose plugins to manage (initialized on first use)").allowUnknownOption().argument("[args...]", "pnpm arguments, forwarded verbatim (add <pkg>, remove <pkg>, why <pkg>, ...)").action((args, options) => {
|
|
119
|
+
rejectParentOptions("plugin");
|
|
120
|
+
if (options.profile === "") program.error("error: --profile needs a name");
|
|
121
|
+
if (args.length === 0) program.error("error: plugin needs pnpm arguments to forward (e.g. add <package>)");
|
|
122
|
+
resolved = {
|
|
123
|
+
mode: "plugin",
|
|
124
|
+
profile: options.profile,
|
|
125
|
+
args
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
try {
|
|
129
|
+
program.parse(argv, { from: "user" });
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return process.exit(error instanceof CommanderError ? error.exitCode : 1);
|
|
132
|
+
}
|
|
133
|
+
/* v8 ignore next -- an action resolves or Commander throws */
|
|
134
|
+
if (resolved === void 0) throw new Error("dsh: no invocation resolved");
|
|
135
|
+
return resolved;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region lib/types/bin.js
|
|
139
|
+
/**
|
|
140
|
+
* dsh — command-line entry. Dynamic imports per mode keep unrelated modes out
|
|
141
|
+
* of each dispatch path; the adapter prints and exits for
|
|
142
|
+
* `--help`/`--version`/a parse error, so only a valid mode reaches the switch.
|
|
143
|
+
* @module @deepseek-ai/dsh/bin
|
|
144
|
+
*/
|
|
145
|
+
/* v8 ignore file -- built-bin acceptance exercises this self-executing dispatch. */
|
|
146
|
+
/** This app's version, read from its checked-in package.json. */
|
|
147
|
+
function readVersion() {
|
|
148
|
+
const manifest = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
|
|
149
|
+
return typeof manifest.version === "string" ? manifest.version : "0.0.0";
|
|
150
|
+
}
|
|
151
|
+
const invocation = parseDshArgs(process.argv.slice(2), readVersion());
|
|
152
|
+
switch (invocation.mode) {
|
|
153
|
+
case "profile": {
|
|
154
|
+
const { runProfile } = await import("./profile-boot-BnJoK_kl.js");
|
|
155
|
+
await runProfile({
|
|
156
|
+
environment: loadLayeredEnv("dsh"),
|
|
157
|
+
profile: invocation.profile,
|
|
158
|
+
patchFiles: invocation.patches,
|
|
159
|
+
args: invocation.args
|
|
160
|
+
});
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case "plugin": {
|
|
164
|
+
const { runPlugin } = await import("./plugin-9h8shc4d.js");
|
|
165
|
+
process.exit(runPlugin(invocation.profile, invocation.args));
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
case "web-log": {
|
|
169
|
+
const { runWebLog } = await import("./web-log-DZLBFfre.js");
|
|
170
|
+
runWebLog({
|
|
171
|
+
tmp: invocation.tmp,
|
|
172
|
+
patches: invocation.patches,
|
|
173
|
+
args: invocation.args
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case "dump-config": {
|
|
178
|
+
const { runDumpConfig } = await import("./dump-config-D-jtgwY3.js");
|
|
179
|
+
runDumpConfig(invocation.profile, invocation.defaultOnly, invocation.patches);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
default: throw new Error(`dsh: unhandled invocation mode ${JSON.stringify(invocation)}`);
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { i as prepareProfile, n as PROFILE_ROOT_FILENAME, r as homePatchPath } from "./profile-boot-DG5t9aNs.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { loadOptionalPatches, loadOverlayPatches, renderConfigDump } from "@deepseek-ai/dsh-app-boot";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
//#region lib/types/dump-config.js
|
|
6
|
+
/**
|
|
7
|
+
* Config-dump entry for `dsh --profile <name> --dump-config`: compose the
|
|
8
|
+
* profile's patch layers through the include plugin's patch algorithm without
|
|
9
|
+
* booting or evaluating `!!js`, with one source layer per bundle, the
|
|
10
|
+
* profile's own patch file, and each `--patch` overlay.
|
|
11
|
+
* @module @deepseek-ai/dsh/dump-config
|
|
12
|
+
*/
|
|
13
|
+
const NAME = "dsh";
|
|
14
|
+
/* v8 ignore start -- built-bin acceptance drives this boot-free dispatch */
|
|
15
|
+
/**
|
|
16
|
+
* Print a profile composition with comments naming each source file and patch layer.
|
|
17
|
+
* @param profile - the profile name.
|
|
18
|
+
* @param defaultOnly - omit the profile's user layer and `--patch` overlays
|
|
19
|
+
* (the recovery diagnostic for a broken `cordis.patch.yml`, which is then
|
|
20
|
+
* never parsed).
|
|
21
|
+
* @param patches - `--patch` overlay paths, in argv order.
|
|
22
|
+
*/
|
|
23
|
+
function runDumpConfig(profile, defaultOnly, patches) {
|
|
24
|
+
const loaded = prepareProfile(profile, !defaultOnly);
|
|
25
|
+
const layers = loaded.layers.map((layer) => ({
|
|
26
|
+
label: layer.packageName,
|
|
27
|
+
patches: layer.patches
|
|
28
|
+
}));
|
|
29
|
+
if (!defaultOnly) {
|
|
30
|
+
if (existsSync(loaded.patchPath)) layers.push({
|
|
31
|
+
label: loaded.patchPath,
|
|
32
|
+
patches: loaded.patches
|
|
33
|
+
});
|
|
34
|
+
const homePatchFile = homePatchPath();
|
|
35
|
+
const homePatches = loadOptionalPatches(NAME, homePatchFile);
|
|
36
|
+
if (homePatches !== void 0) layers.push({
|
|
37
|
+
label: homePatchFile,
|
|
38
|
+
patches: homePatches
|
|
39
|
+
});
|
|
40
|
+
for (const file of patches) {
|
|
41
|
+
const absolute = resolve(file);
|
|
42
|
+
layers.push({
|
|
43
|
+
label: absolute,
|
|
44
|
+
patches: loadOverlayPatches(NAME, absolute)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
process.stdout.write(renderConfigDump(NAME, join(loaded.dir, PROFILE_ROOT_FILENAME), layers));
|
|
49
|
+
}
|
|
50
|
+
/* v8 ignore stop */
|
|
51
|
+
//#endregion
|
|
52
|
+
export { runDumpConfig };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { t as INSTALL_ANCHOR } from "./profile-boot-DG5t9aNs.js";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { DEFAULT_PROFILE_BUNDLES, PROFILE_TEMPLATES, initProfile, readProfileManifest, resolveBundleDir, resolveProfileDir, writeProfileManifest } from "@deepseek-ai/dsh-app-boot";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
//#region lib/types/plugin.js
|
|
7
|
+
/**
|
|
8
|
+
* `dsh plugin --profile <name> <args...>` — profile plugin management as a
|
|
9
|
+
* thin pnpm forwarder: initialize the profile on first use, run
|
|
10
|
+
* `pnpm <args...>` in the profile directory, then reconcile the
|
|
11
|
+
* `dsh.profile.bundles` layer list against the installed state (a dependency
|
|
12
|
+
* resolving to a package that declares `dsh.bundle` joins the layer stack; a
|
|
13
|
+
* removed or bundle-less dependency leaves it). Reconciling by installed
|
|
14
|
+
* state, not by dependency diff, means `update` activates a package that
|
|
15
|
+
* gained its `dsh.bundle` declaration in a newer version.
|
|
16
|
+
* @module @deepseek-ai/dsh/plugin
|
|
17
|
+
*/
|
|
18
|
+
const NAME = "dsh";
|
|
19
|
+
/**
|
|
20
|
+
* Whether a resolved dependency exports a profile patch, i.e. is a bundle.
|
|
21
|
+
* @param packageName - the dependency's package name.
|
|
22
|
+
* @param profileDir - the profile directory (resolution anchor).
|
|
23
|
+
* @returns true when the package manifest declares `dsh.bundle`.
|
|
24
|
+
*/
|
|
25
|
+
function exportsPatch(packageName, profileDir) {
|
|
26
|
+
let dir;
|
|
27
|
+
try {
|
|
28
|
+
dir = resolveBundleDir(NAME, packageName, INSTALL_ANCHOR, profileDir);
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return readProfileManifest(NAME, dir).dsh?.bundle?.patch !== void 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reconcile `dsh.profile.bundles` against the installed state: pnpm has
|
|
36
|
+
* already written the real installed names (so a git/path/tarball/alias spec
|
|
37
|
+
* on the command line reconciles by its true package name) and materialized
|
|
38
|
+
* the packages. A dependency that resolves to a `dsh.bundle`-declaring
|
|
39
|
+
* package joins the layer stack (appended in dependency order); a
|
|
40
|
+
* dependency-listed name that no longer does — removed, or the installed
|
|
41
|
+
* version dropped the declaration — leaves it. In-box bundles from the
|
|
42
|
+
* profile template are not dependencies and are never touched. Warns once
|
|
43
|
+
* per newly-added bundle-less dependency (a plain library is fine; the
|
|
44
|
+
* warning is orientation).
|
|
45
|
+
*/
|
|
46
|
+
function reconcilePlugins(before, profileDir) {
|
|
47
|
+
const after = readProfileManifest(NAME, profileDir);
|
|
48
|
+
const beforeDeps = new Set(Object.keys(before.dependencies ?? {}));
|
|
49
|
+
const dependencies = Object.keys(after.dependencies ?? {});
|
|
50
|
+
const plugins = after.dsh?.profile?.bundles ?? [];
|
|
51
|
+
let changed = false;
|
|
52
|
+
for (const packageName of dependencies) {
|
|
53
|
+
const isBundle = exportsPatch(packageName, profileDir);
|
|
54
|
+
if (isBundle && !plugins.includes(packageName)) {
|
|
55
|
+
plugins.push(packageName);
|
|
56
|
+
changed = true;
|
|
57
|
+
} else if (!isBundle && !beforeDeps.has(packageName)) process.stderr.write(`${NAME}: warning: ${packageName} declares no dsh.bundle — installed as a plain dependency, not a profile layer (a later update that gains one activates it automatically)
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
const dependencySet = new Set(dependencies);
|
|
61
|
+
for (const packageName of [...plugins]) {
|
|
62
|
+
const wasDependency = beforeDeps.has(packageName) || dependencySet.has(packageName);
|
|
63
|
+
const stillBundle = dependencySet.has(packageName) && exportsPatch(packageName, profileDir);
|
|
64
|
+
if (wasDependency && !stillBundle) {
|
|
65
|
+
plugins.splice(plugins.indexOf(packageName), 1);
|
|
66
|
+
changed = true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!changed) return;
|
|
70
|
+
after.dsh = {
|
|
71
|
+
...after.dsh,
|
|
72
|
+
profile: {
|
|
73
|
+
...after.dsh?.profile,
|
|
74
|
+
bundles: plugins
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
writeProfileManifest(profileDir, after);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Rewrite relative filesystem specs against the user's invoking directory.
|
|
81
|
+
* pnpm runs with cwd = the profile directory, so a bare `.` or `../plugin`
|
|
82
|
+
* (or their `file:`/`link:` forms) would silently resolve inside the profile
|
|
83
|
+
* — `add .` from a plugin checkout would self-link the profile. Absolute
|
|
84
|
+
* specs, registry names, and every other pnpm argument pass through
|
|
85
|
+
* untouched.
|
|
86
|
+
* @param argument - one pnpm argument, verbatim from argv.
|
|
87
|
+
* @param cwd - the directory `dsh` was invoked from.
|
|
88
|
+
* @returns the argument with a relative path spec anchored to `cwd`.
|
|
89
|
+
*/
|
|
90
|
+
function anchorPathSpec(argument, cwd) {
|
|
91
|
+
const match = /^(?<prefix>(?:file|link):)?(?<path>\.{1,2}(?:[/\\].*)?)$/.exec(argument);
|
|
92
|
+
if (match?.groups?.path === void 0) return argument;
|
|
93
|
+
return `${match.groups.prefix ?? ""}${resolve(cwd, match.groups.path)}`;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Run one `dsh plugin` invocation: init if needed, forward to pnpm, reconcile.
|
|
97
|
+
* @param profile - the profile name.
|
|
98
|
+
* @param args - pnpm arguments with relative path specs anchored to the invoking directory.
|
|
99
|
+
* @returns the pnpm exit code.
|
|
100
|
+
*/
|
|
101
|
+
function runPlugin(profile, args) {
|
|
102
|
+
const dir = resolveProfileDir(profile);
|
|
103
|
+
if (!existsSync(join(dir, "package.json"))) {
|
|
104
|
+
initProfile(dir, PROFILE_TEMPLATES[profile] ?? DEFAULT_PROFILE_BUNDLES);
|
|
105
|
+
process.stderr.write(`${NAME}: initialized profile ${profile} at ${dir}\n`);
|
|
106
|
+
}
|
|
107
|
+
const before = readProfileManifest(NAME, dir);
|
|
108
|
+
const result = spawnSync("pnpm", args.map((argument) => anchorPathSpec(argument, process.cwd())), {
|
|
109
|
+
cwd: dir,
|
|
110
|
+
stdio: "inherit",
|
|
111
|
+
shell: process.platform === "win32"
|
|
112
|
+
});
|
|
113
|
+
if (result.error !== void 0) {
|
|
114
|
+
if (result.error.code === "ENOENT") {
|
|
115
|
+
process.stderr.write(`${NAME}: pnpm not found on PATH — install pnpm to manage profile plugins\n`);
|
|
116
|
+
return 127;
|
|
117
|
+
}
|
|
118
|
+
throw result.error;
|
|
119
|
+
}
|
|
120
|
+
const exitCode = result.status ?? 1;
|
|
121
|
+
if (exitCode === 0) reconcilePlugins(before, dir);
|
|
122
|
+
else {
|
|
123
|
+
process.stderr.write(`${NAME}: pnpm failed in profile directory ${dir}\n`);
|
|
124
|
+
if (args.some((argument) => /^git\+|^github:|\.git(?:#|$)/.test(argument))) process.stderr.write(`${NAME}: git-hosted plugins build on install via their prepare script, which pnpm blocks until allowed — add the exact key pnpm printed above under allowBuilds in ${join(dir, "pnpm-workspace.yaml")}, then re-run\n`);
|
|
125
|
+
}
|
|
126
|
+
return exitCode;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { runPlugin };
|