dsh-js-reverse-plugin 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +43 -5
- package/package.json +4 -3
- package/preset/agent.cordis.yml +263 -0
- package/preset/preset.yml +3 -0
package/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// dsh-js-reverse-plugin — one DeepSeek Harness bundle that mounts the
|
|
2
2
|
// js-reverse skills (AST deobfuscation / iv8 / JSVMP) as runtime skills.
|
|
3
|
-
// The js-reverse-mcp server is mounted by the cordis.patch.yml layer,
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
// The js-reverse-mcp server is mounted by the cordis.patch.yml layer, and the
|
|
4
|
+
// bundled `preset/` directory is installed into the harness home as the
|
|
5
|
+
// `reverse` agent preset, so a single `dsh plugin add` installs skills + MCP
|
|
6
|
+
// tools + the reverse agent mode together.
|
|
7
|
+
import { copyFileSync, mkdirSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
8
|
+
import { homedir } from 'node:os'
|
|
9
|
+
import { dirname, join } from 'node:path'
|
|
7
10
|
import { fileURLToPath } from 'node:url'
|
|
8
11
|
import { parse } from 'yaml'
|
|
9
12
|
|
|
@@ -13,6 +16,33 @@ export const name = 'js-reverse-plugin'
|
|
|
13
16
|
export const inject = ['skills']
|
|
14
17
|
|
|
15
18
|
const SKILLS_DIR = fileURLToPath(new URL('./skills/', import.meta.url))
|
|
19
|
+
const PRESET_DIR = fileURLToPath(new URL('./preset/', import.meta.url))
|
|
20
|
+
|
|
21
|
+
/** Preset id the bundled composition installs under. */
|
|
22
|
+
export const PRESET_ID = 'reverse'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The user agent-presets root. Honors DSH_HOME; falls back to `~/.dsh`.
|
|
26
|
+
* @returns the `.agent-presets` directory under the harness home.
|
|
27
|
+
*/
|
|
28
|
+
export function presetUserRoot() {
|
|
29
|
+
return join(process.env.DSH_HOME ?? join(homedir(), '.dsh'), '.agent-presets')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Install the bundled preset into the user preset root. Idempotent: an
|
|
34
|
+
* existing composition file is never overwritten, so a user's edits survive
|
|
35
|
+
* reinstalls. Discovered immediately by `dsh-agent-presets` (unmemoized roots).
|
|
36
|
+
* @param destDir - the target `<name>` preset directory, derived from {@link PRESET_ID}.
|
|
37
|
+
*/
|
|
38
|
+
export function installPreset(destDir) {
|
|
39
|
+
mkdirSync(destDir, { recursive: true })
|
|
40
|
+
for (const file of readdirSync(PRESET_DIR)) {
|
|
41
|
+
const dest = join(destDir, file)
|
|
42
|
+
if (statSync(dest, { throwIfNoEntry: false })?.isFile()) continue
|
|
43
|
+
copyFileSync(join(PRESET_DIR, file), dest)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
16
46
|
|
|
17
47
|
/**
|
|
18
48
|
* Split one SKILL.md into its YAML frontmatter and the markdown body.
|
|
@@ -53,9 +83,17 @@ export function collectSkills() {
|
|
|
53
83
|
return registrations
|
|
54
84
|
}
|
|
55
85
|
|
|
56
|
-
/** Register every bundled skill
|
|
86
|
+
/** Register every bundled skill and install the bundled preset. */
|
|
57
87
|
export function apply(ctx) {
|
|
58
88
|
for (const skill of collectSkills()) {
|
|
59
89
|
ctx.skills.register(skill)
|
|
60
90
|
}
|
|
91
|
+
try {
|
|
92
|
+
installPreset(join(presetUserRoot(), PRESET_ID))
|
|
93
|
+
} catch (error) {
|
|
94
|
+
// Preset installation is additive and idempotent; skills and MCP remain
|
|
95
|
+
// usable when the user preset root is not writable, so this fails soft
|
|
96
|
+
// with a diagnostic instead of taking the whole bundle down.
|
|
97
|
+
ctx.logger.warn(`[${name}] could not install the "${PRESET_ID}" agent preset: ${String(error)}`)
|
|
98
|
+
}
|
|
61
99
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-js-reverse-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "JavaScript reverse-engineering bundle for DeepSeek Harness: AST deobfuscation / iv8 / JSVMP skills
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "JavaScript reverse-engineering bundle for DeepSeek Harness: AST deobfuscation / iv8 / JSVMP skills, the js-reverse-mcp server tools, and the reverse agent preset.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.js",
|
|
9
9
|
"cordis.patch.yml",
|
|
10
|
-
"skills"
|
|
10
|
+
"skills",
|
|
11
|
+
"preset"
|
|
11
12
|
],
|
|
12
13
|
"dependencies": {
|
|
13
14
|
"yaml": "^2.4.0"
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# The `reverse` agent preset: a JS reverse-engineering agent. A copy of
|
|
2
|
+
# `standard` whose persona states the reverse-engineering work rules —
|
|
3
|
+
# evidence-driven, stepwise user decisions, iv8 as the only controlled
|
|
4
|
+
# runtime, equivalence acceptance. The capability set is unchanged.
|
|
5
|
+
#
|
|
6
|
+
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
|
|
7
|
+
# standing scope; every session naming it joins by scope parentage, so the
|
|
8
|
+
# tools and prompt sections registered here cover each joined agent while a
|
|
9
|
+
# session's own state stays keyed per Session/Agent inside the plugins. The
|
|
10
|
+
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
|
|
11
|
+
# preset must not own: the registries themselves, the sandbox and approval
|
|
12
|
+
# stack, persistence, and the model route.
|
|
13
|
+
#
|
|
14
|
+
# A service row here MUST sit inside a group carrying an `isolate` realm.
|
|
15
|
+
# Without one it publishes into the root realm, where it is process-global —
|
|
16
|
+
# another preset publishing the same name collides, and a host reader would
|
|
17
|
+
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
|
|
18
|
+
# that at mount. `true` means an entry-local realm: this standing mount's own
|
|
19
|
+
# private instance, apart from every other preset's. (A shared label does NOT
|
|
20
|
+
# pool instances — `provide()` throws on the second registration under the
|
|
21
|
+
# same realm symbol; labels join REALMS, and are not what this file needs.)
|
|
22
|
+
|
|
23
|
+
# ── identity ────────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
# The preset's own persona, shadowing the deployment default for this agent.
|
|
26
|
+
# `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
|
|
27
|
+
- id: persona
|
|
28
|
+
name: '@deepseek-ai/dsh-persona'
|
|
29
|
+
config:
|
|
30
|
+
text: >-
|
|
31
|
+
You are a JS reverse-engineering agent powered by the {{model}} model. Your working directory is {{cwd}}.
|
|
32
|
+
|
|
33
|
+
工作准则:
|
|
34
|
+
- 证据驱动:每个结论必须可溯源——静态证据(源码、字节码、AST)或动态证据(受控执行、浏览器观测)。区分"事实"与"推断",不无证猜测。
|
|
35
|
+
- 逐步决策:关键选择先说明依据与代价,等用户决定——解混淆路线、是否补环境、静态还是动态、继续还是交接。
|
|
36
|
+
- 保护原始输入:目标文件一律只读;分析前先做格式化派生副本,一切修改只落在副本。
|
|
37
|
+
- 解混淆服务于分析:产出是方便阅读、搜索、定位、动态观测的派生视图;不以"清理干净"或还原作者原名、原始工程为目标。
|
|
38
|
+
- 受控执行:动态证据通过 iv8(C++ V8 + 浏览器环境)或 js-reverse MCP 取得;Node.js 仅作静态工程工具。
|
|
39
|
+
- 等价验收:恢复的算法、签名、映射以与原始实现精确等价为验收标准;"服务器恰好接受"不是证明。
|
|
40
|
+
- 长线任务用 todo 和 goal 跟踪;多路独立分析(静态/动态/资料)可用 subagent 并行;关键证据和推导过程记录在案,保持可审计。
|
|
41
|
+
|
|
42
|
+
- id: agent-instructions
|
|
43
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
44
|
+
config:
|
|
45
|
+
maxBytes: 65536
|
|
46
|
+
|
|
47
|
+
# ── shell ───────────────────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
# `shell-env` stays in the HOST composition: `apps/cli/src/web.ts` injects it to
|
|
50
|
+
# publish `DSH_WEB_URL`/`DSH_WEB_MODE`, and a host row that injects a service is
|
|
51
|
+
# the criterion for host-plane ownership — injection resolves before any session
|
|
52
|
+
# exists, so there is no agent to key by. Behind a preset realm those variables
|
|
53
|
+
# never reached the model's shell at all. Both shell tools consume the host
|
|
54
|
+
# registry from here; their executors (`bash-sandbox`/`pwsh-sandbox`) are
|
|
55
|
+
# host-plane too.
|
|
56
|
+
- id: tool-bash
|
|
57
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
58
|
+
disabled: !!js process.platform === 'win32'
|
|
59
|
+
|
|
60
|
+
- id: tool-pwsh
|
|
61
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
62
|
+
disabled: !!js process.platform !== 'win32'
|
|
63
|
+
|
|
64
|
+
# ── filesystem ──────────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
# Both register into the host `tools` registry and provide nothing, so
|
|
67
|
+
# they need no realm. The `fs` service and its policy stay in the host.
|
|
68
|
+
- id: tool-fs
|
|
69
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
70
|
+
|
|
71
|
+
- id: tool-fs-search
|
|
72
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
73
|
+
config:
|
|
74
|
+
sampleOverCapGlobResults: false
|
|
75
|
+
|
|
76
|
+
# ── background jobs ────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
# Only the model-facing controls. The task REGISTRY stays on the host plane:
|
|
79
|
+
# its producers sit outside any realm this file could put it in — `tool-bash`
|
|
80
|
+
# above resolves it with `ctx.get`, and an entry-local realm here is invisible
|
|
81
|
+
# to every sibling row, so `run_in_background` would answer "background jobs
|
|
82
|
+
# unavailable" while these controls sat in the catalog. The registry is keyed by
|
|
83
|
+
# owning agent anyway, so one host instance serves every session. What a preset
|
|
84
|
+
# chooses is whether its agent can collect and stop background work at all.
|
|
85
|
+
- id: tool-jobs
|
|
86
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
87
|
+
|
|
88
|
+
# ── skills ──────────────────────────────────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
# The skill REGISTRY lives in the host composition and is layered per scope:
|
|
91
|
+
# these rows register into THIS preset's layer of it, so they need no realm.
|
|
92
|
+
# `skill-filesystem` contributes local-root discovery for agents on this preset, and
|
|
93
|
+
# `tool-skill` gives them the catalog and loader; the merged catalog also
|
|
94
|
+
# carries whatever the deployment registered globally (repository plugins).
|
|
95
|
+
- id: skill-filesystem
|
|
96
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
97
|
+
|
|
98
|
+
- id: tool-skill
|
|
99
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
100
|
+
|
|
101
|
+
# ── goals ───────────────────────────────────────────────────────────────────
|
|
102
|
+
|
|
103
|
+
# Only the model-facing tool. The goal SERVICE, its session driver, and the
|
|
104
|
+
# `/goal` command stay on the host plane: the Gateway serves the goal domain as
|
|
105
|
+
# Remote endpoints whose receiver comes from a generated descriptor, so it
|
|
106
|
+
# resolves `goals` on the host and an entry-local realm here would hide it. The
|
|
107
|
+
# registry is keyed by session anyway, so one host instance serves every
|
|
108
|
+
# session. What a preset chooses is whether its agent can call the goal tool.
|
|
109
|
+
- id: tool-goal
|
|
110
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
111
|
+
|
|
112
|
+
# ── plan mode ───────────────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
# Plan state is per-agent by nature, so an entry-local realm is not a
|
|
115
|
+
# workaround here — it is the correct lifetime.
|
|
116
|
+
- id: planning
|
|
117
|
+
name: cordis:group
|
|
118
|
+
group: true
|
|
119
|
+
isolate:
|
|
120
|
+
planMode: true
|
|
121
|
+
config:
|
|
122
|
+
- id: plan-mode
|
|
123
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
124
|
+
config:
|
|
125
|
+
section: |
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
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.
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
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.
|
|
133
|
+
|
|
134
|
+
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.
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
# ── compaction ──────────────────────────────────────────────────────────────
|
|
139
|
+
|
|
140
|
+
# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
|
|
141
|
+
# share this realm rather than sit outside it.
|
|
142
|
+
#
|
|
143
|
+
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
|
|
144
|
+
# plane, and the rows here resolve that one instance. It takes no configuration,
|
|
145
|
+
# keys every fold by Session, and owns the context-meter projection units the
|
|
146
|
+
# browser reads for every session — behind a realm those units would come and go
|
|
147
|
+
# with whichever presets happen to be mounted. What a preset chooses is whether
|
|
148
|
+
# its agent compacts at all, which is `compaction-basic` below.
|
|
149
|
+
- id: compaction
|
|
150
|
+
name: cordis:group
|
|
151
|
+
group: true
|
|
152
|
+
isolate:
|
|
153
|
+
compaction: true
|
|
154
|
+
toolResultPruner: true
|
|
155
|
+
config:
|
|
156
|
+
- id: compaction-basic
|
|
157
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
158
|
+
|
|
159
|
+
- id: command-compact
|
|
160
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
161
|
+
|
|
162
|
+
- id: tool-result-pruner
|
|
163
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
164
|
+
config:
|
|
165
|
+
thresholdChars: 8192
|
|
166
|
+
headChars: 4096
|
|
167
|
+
tailChars: 1024
|
|
168
|
+
|
|
169
|
+
# ── delegation and workflows ────────────────────────────────────────────────
|
|
170
|
+
|
|
171
|
+
# The `subagents` registry and its spawn/fork backends live in the HOST
|
|
172
|
+
# composition: the registry is a process singleton whose cross-session queries
|
|
173
|
+
# the api-proxy serves to the browser, and a provider name may only be
|
|
174
|
+
# registered once. This preset contributes the delegation TOOLS, which resolve
|
|
175
|
+
# that host registry.
|
|
176
|
+
#
|
|
177
|
+
# `workflows` is different — nothing outside an agent reads it — so every row
|
|
178
|
+
# that reaches it shares one entry-local realm here, and a consumer left
|
|
179
|
+
# outside would resolve a host registry this preset does not populate.
|
|
180
|
+
#
|
|
181
|
+
# `tool-subagent-report` is host-plane for the same reason as the registry,
|
|
182
|
+
# not because a preset may not want it: it registers a CONTINUABLE SETUP on
|
|
183
|
+
# that singleton rather than a tool this agent calls, and the setup list is
|
|
184
|
+
# not scope-aware — one copy per mounted preset means every child gets
|
|
185
|
+
# `report` registered once per live session, which throws on the second.
|
|
186
|
+
- id: delegation
|
|
187
|
+
name: cordis:group
|
|
188
|
+
group: true
|
|
189
|
+
isolate:
|
|
190
|
+
workflowEngine: true
|
|
191
|
+
config:
|
|
192
|
+
- id: tool-subagent-control
|
|
193
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
194
|
+
|
|
195
|
+
- id: tool-subagent-list-agents
|
|
196
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
197
|
+
|
|
198
|
+
- id: tool-subagent
|
|
199
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
200
|
+
config:
|
|
201
|
+
provider: spawn
|
|
202
|
+
toolName: subagent
|
|
203
|
+
backgroundMode: continuable
|
|
204
|
+
|
|
205
|
+
- id: tool-subagent-fork
|
|
206
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
207
|
+
config:
|
|
208
|
+
provider: fork
|
|
209
|
+
toolName: subagent_fork
|
|
210
|
+
backgroundMode: continuable
|
|
211
|
+
|
|
212
|
+
# Product providers are host-plane singletons. Copy this preset, then
|
|
213
|
+
# remove `disabled` from either ordinary tool row to expose that product
|
|
214
|
+
# only to agents composed from the copy.
|
|
215
|
+
- id: tool-subagent-codex
|
|
216
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
217
|
+
disabled: true
|
|
218
|
+
config:
|
|
219
|
+
provider: codex
|
|
220
|
+
toolName: subagent_codex
|
|
221
|
+
enableRunInBackground: false
|
|
222
|
+
maxDepth: provider-managed
|
|
223
|
+
|
|
224
|
+
- id: tool-subagent-claude-code
|
|
225
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
226
|
+
disabled: true
|
|
227
|
+
config:
|
|
228
|
+
provider: claude-code
|
|
229
|
+
toolName: subagent_claude_code
|
|
230
|
+
enableRunInBackground: false
|
|
231
|
+
maxDepth: provider-managed
|
|
232
|
+
|
|
233
|
+
- id: workflow-worker-thread
|
|
234
|
+
name: '@deepseek-ai/dsh-workflow-worker-thread'
|
|
235
|
+
config:
|
|
236
|
+
provider: spawn
|
|
237
|
+
|
|
238
|
+
- id: tool-workflow
|
|
239
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
240
|
+
|
|
241
|
+
- id: tool-ralph
|
|
242
|
+
name: '@deepseek-ai/dsh-tool-ralph'
|
|
243
|
+
config:
|
|
244
|
+
subagentProvider: spawn
|
|
245
|
+
maxRounds: 64
|
|
246
|
+
|
|
247
|
+
# ── remaining model-facing rows ─────────────────────────────────────────────
|
|
248
|
+
|
|
249
|
+
- id: tool-ask-user
|
|
250
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
251
|
+
|
|
252
|
+
- id: tool-todo
|
|
253
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
254
|
+
config:
|
|
255
|
+
allowParallelInProgress: true
|
|
256
|
+
|
|
257
|
+
# The `web` service and its search provider stay in the host composition; only
|
|
258
|
+
# the model-facing tool is per-session.
|
|
259
|
+
- id: tool-web
|
|
260
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
261
|
+
config:
|
|
262
|
+
fetch: false
|
|
263
|
+
searchTimeoutMs: 60000
|