dsh-multigameassistant 2.0.4 → 2.1.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/cordis.patch.yml +178 -4
- package/lib/analyzer.js +135 -26
- package/lib/browser.js +279 -0
- package/lib/{chunk-XHP3SLMO.js → chunk-77ZYHRN7.js} +292 -6
- package/lib/{chunk-UOVFYP7C.js → chunk-EOWM56PA.js} +398 -58
- package/lib/chunk-FH64SAZU.js +605 -0
- package/lib/{chunk-IZENRXQ6.js → chunk-MEKSHT6V.js} +1797 -575
- package/lib/chunk-RESS7WVY.js +157 -0
- package/lib/{chunk-SA72K6M2.js → chunk-SHTX4AGU.js} +1 -3572
- package/lib/{chunk-4PNYIZVU.js → chunk-TWUATN5X.js} +13 -9
- package/lib/chunk-V2X4PLF5.js +3730 -0
- package/lib/emulator.js +5 -3
- package/lib/feishu.js +8 -5
- package/lib/game-intel.js +91 -8
- package/lib/gateway.js +9 -5
- package/lib/guard.js +5 -3
- package/lib/intervene.js +62 -17
- package/lib/low-context.js +71 -87
- package/lib/monitor.js +90 -10
- package/lib/notify.js +6 -4
- package/lib/orchestrator.js +97 -27
- package/lib/packs/maa/adg.script.yaml +119 -1
- package/lib/packs/maaend/adg.script.yaml +74 -4
- package/lib/packs/march7th/adg.script.yaml +116 -0
- package/lib/qqbot.js +8 -5
- package/lib/runner.js +18 -5
- package/lib/scheduler.js +4 -2
- package/lib/script-registry.js +203 -214
- package/package.json +5 -4
- package/skills/pipeline-planning.md +8 -5
- package/skills/script-analysis.md +70 -10
- package/skills/web-reading.md +2 -0
- package/web/assets/index-C-csjWiw.js +244 -0
- package/web/assets/index-C-csjWiw.js.map +1 -0
- package/web/assets/index-CjtVfcDS.css +1 -0
- package/web/index.html +2 -2
- package/lib/chunk-CCAB6XXZ.js +0 -34
- package/web/assets/index-BqeCz6LB.css +0 -1
- package/web/assets/index-CCaVm9ks.js +0 -242
- package/web/assets/index-CCaVm9ks.js.map +0 -1
package/cordis.patch.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# dsh-multigameassistant 2.0
|
|
1
|
+
# dsh-multigameassistant 2.1.0
|
|
2
2
|
# dsh-multigameassistant: the app's plugins (packages/bundle/cordis.patch.yml, each @adg/<plugin> as dsh-multigameassistant/<plugin>)
|
|
3
3
|
# sharing the dsh with the person's other chats, and the app's agent preset (dsh's standard one with the app's
|
|
4
4
|
# tools and prompts, and compaction as 设置 → 对话压缩 says). No row of dsh is restated.
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
name: 'dsh-multigameassistant/script-registry'
|
|
26
26
|
config:
|
|
27
27
|
toolsDir: !!js "process.env.ADG_TOOLS_DIR || dshHomePath('adg/tools')"
|
|
28
|
+
# Scripts installed before ADG_TOOLS_DIR was set stay where they are until their next update.
|
|
29
|
+
formerToolsDirs: !!js "process.env.ADG_TOOLS_DIR ? [dshHomePath('adg/tools')] : []"
|
|
28
30
|
dataDir: !!js "process.env.ADG_DATA_DIR || dshHomePath('adg/data')"
|
|
29
31
|
defaults:
|
|
30
32
|
downloadMirror: !!js "process.env.ADG_GITHUB_MIRROR || ''"
|
|
@@ -68,6 +70,18 @@
|
|
|
68
70
|
config:
|
|
69
71
|
dataDir: !!js "process.env.ADG_DATA_DIR || dshHomePath('adg/data')"
|
|
70
72
|
|
|
73
|
+
# The built-in browser's `browser_*` tools: web pages the agent operates and
|
|
74
|
+
# the user watches in the browser panel. The browser itself is the desktop
|
|
75
|
+
# app's (apps/desktop/browser.mjs), which hands dsh its bridge:
|
|
76
|
+
# ADG_BROWSER_URL the bridge's loopback address
|
|
77
|
+
# ADG_BROWSER_TOKEN its token
|
|
78
|
+
# Neither set (dsh started another way, or dsh's own app): no browser tools.
|
|
79
|
+
- id: adg-browser
|
|
80
|
+
name: 'dsh-multigameassistant/browser'
|
|
81
|
+
config:
|
|
82
|
+
endpoint: !!js "process.env.ADG_BROWSER_URL || undefined"
|
|
83
|
+
token: !!js "process.env.ADG_BROWSER_TOKEN || undefined"
|
|
84
|
+
|
|
71
85
|
# M3: the chat layer — notices with buttons, replies, conversations with
|
|
72
86
|
# the agent, approval cards; the `notify` capability.
|
|
73
87
|
- id: adg-notify
|
|
@@ -154,6 +168,159 @@
|
|
|
154
168
|
disabled: !!js process.platform !== 'win32'
|
|
155
169
|
- id: tool-fs
|
|
156
170
|
name: '@deepseek-ai/dsh-tool-fs'
|
|
171
|
+
config:
|
|
172
|
+
# Set false to drop the apply_patch tool beside edit.
|
|
173
|
+
applyPatch: false
|
|
174
|
+
- id: tool-fs-search
|
|
175
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
176
|
+
config:
|
|
177
|
+
sampleOverCapGlobResults: false
|
|
178
|
+
- id: tool-jobs
|
|
179
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
180
|
+
- id: tool-schedule
|
|
181
|
+
name: '@deepseek-ai/dsh-tool-schedule'
|
|
182
|
+
- id: skill-filesystem
|
|
183
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
184
|
+
config:
|
|
185
|
+
customSkillDirs:
|
|
186
|
+
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
187
|
+
- id: tool-skill
|
|
188
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
189
|
+
- id: command-goal
|
|
190
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
191
|
+
- id: tool-goal
|
|
192
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
193
|
+
- id: planning
|
|
194
|
+
name: cordis:group
|
|
195
|
+
group: true
|
|
196
|
+
isolate:
|
|
197
|
+
planMode: true
|
|
198
|
+
config:
|
|
199
|
+
- id: plan-mode
|
|
200
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
201
|
+
config:
|
|
202
|
+
section: |
|
|
203
|
+
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or 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.
|
|
204
|
+
|
|
205
|
+
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.
|
|
206
|
+
|
|
207
|
+
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.
|
|
208
|
+
|
|
209
|
+
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.
|
|
210
|
+
|
|
211
|
+
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.
|
|
212
|
+
|
|
213
|
+
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.
|
|
214
|
+
- id: compaction
|
|
215
|
+
name: cordis:group
|
|
216
|
+
group: true
|
|
217
|
+
isolate:
|
|
218
|
+
compaction: true
|
|
219
|
+
toolResultPruner: true
|
|
220
|
+
config:
|
|
221
|
+
- id: compaction-basic
|
|
222
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
223
|
+
config:
|
|
224
|
+
# 设置 → 对话压缩 (compaction.json in the app's data); read when the agent service starts.
|
|
225
|
+
auto: !!js "(() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().auto !== false"
|
|
226
|
+
thresholdRatio: !!js "(Math.min(100, Math.max(5, Number((() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().threshold) || 80)) / 100)"
|
|
227
|
+
retainRatio: !!js "Math.min(0.16, (Math.min(100, Math.max(5, Number((() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().threshold) || 80)) / 100) / 2)"
|
|
228
|
+
- id: adg-low-context
|
|
229
|
+
name: 'dsh-multigameassistant/low-context'
|
|
230
|
+
config:
|
|
231
|
+
file: !!js "(process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json'"
|
|
232
|
+
- id: command-compact
|
|
233
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
234
|
+
- id: tool-result-pruner
|
|
235
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
236
|
+
config:
|
|
237
|
+
thresholdChars: 8192
|
|
238
|
+
headChars: 4096
|
|
239
|
+
tailChars: 1024
|
|
240
|
+
- id: delegation
|
|
241
|
+
name: cordis:group
|
|
242
|
+
group: true
|
|
243
|
+
isolate:
|
|
244
|
+
workflowEngine: true
|
|
245
|
+
config:
|
|
246
|
+
- id: tool-subagent-control
|
|
247
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
248
|
+
config:
|
|
249
|
+
interrupt: false
|
|
250
|
+
- id: tool-subagent
|
|
251
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
252
|
+
config:
|
|
253
|
+
# Sub-agents call their tools from a program (run_code); read when the agent service starts.
|
|
254
|
+
agentPreset: !!js "(() => { try { return JSON.parse(process.getBuiltinModule('node:fs').readFileSync((process.env.ADG_DATA_DIR || dshHomePath('adg/data')) + '/compaction.json', 'utf8')) } catch { return {} } })().ptcSubagents === false ? undefined : 'mga-ptc'"
|
|
255
|
+
provider: spawn
|
|
256
|
+
toolName: subagent
|
|
257
|
+
modelSelection: true
|
|
258
|
+
modelDiscovery: true
|
|
259
|
+
- id: tool-subagent-fork
|
|
260
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
261
|
+
config:
|
|
262
|
+
provider: fork
|
|
263
|
+
toolName: subagent_fork
|
|
264
|
+
- id: workflow-ptc
|
|
265
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
266
|
+
config:
|
|
267
|
+
provider: spawn
|
|
268
|
+
- id: tool-workflow
|
|
269
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
270
|
+
- id: tool-ask-user
|
|
271
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
272
|
+
- id: tool-todo
|
|
273
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
274
|
+
config:
|
|
275
|
+
allowParallelInProgress: true
|
|
276
|
+
- id: tool-web
|
|
277
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
278
|
+
config:
|
|
279
|
+
fetch: true
|
|
280
|
+
searchTimeoutMs: 60000
|
|
281
|
+
- id: present
|
|
282
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
283
|
+
- id: tool-office
|
|
284
|
+
name: '@deepseek-ai/dsh-tool-office'
|
|
285
|
+
- id: tool-plugin-manager
|
|
286
|
+
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
287
|
+
disabled: !!js "!ctx.get('profileContext')"
|
|
288
|
+
- id: tool-plugin-market
|
|
289
|
+
name: '@deepseek-ai/dsh-plugin-market/tools'
|
|
290
|
+
disabled: true
|
|
291
|
+
- id: adg-agent
|
|
292
|
+
name: 'dsh-multigameassistant/agent'
|
|
293
|
+
|
|
294
|
+
# What the app's sub-agents run: dsh's ptc preset with the app's tools (设置 → 对话压缩 can turn it off).
|
|
295
|
+
- id: preset-mga-ptc
|
|
296
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
297
|
+
config:
|
|
298
|
+
id: mga-ptc
|
|
299
|
+
name: 多游戏助手 · 子 agent
|
|
300
|
+
description: 多游戏助手的子 agent 自动用的(用代码调用工具),不用自己选
|
|
301
|
+
order: 51
|
|
302
|
+
plugins:
|
|
303
|
+
- id: persona
|
|
304
|
+
name: '@deepseek-ai/dsh-persona'
|
|
305
|
+
config:
|
|
306
|
+
prefix: You are a coding agent powered by the {{model}} model.
|
|
307
|
+
- id: agent-instructions
|
|
308
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
309
|
+
config:
|
|
310
|
+
maxBytes: 65536
|
|
311
|
+
- id: time-context
|
|
312
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
313
|
+
- id: tool-bash
|
|
314
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
315
|
+
disabled: !!js process.platform === 'win32'
|
|
316
|
+
- id: tool-pwsh
|
|
317
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
318
|
+
disabled: !!js process.platform !== 'win32'
|
|
319
|
+
- id: tool-fs
|
|
320
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
321
|
+
config:
|
|
322
|
+
# Set true to add the apply_patch tool beside edit.
|
|
323
|
+
applyPatch: false
|
|
157
324
|
- id: tool-fs-search
|
|
158
325
|
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
159
326
|
config:
|
|
@@ -225,14 +392,15 @@
|
|
|
225
392
|
config:
|
|
226
393
|
- id: tool-subagent-control
|
|
227
394
|
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
228
|
-
|
|
229
|
-
|
|
395
|
+
config:
|
|
396
|
+
interrupt: false
|
|
230
397
|
- id: tool-subagent
|
|
231
398
|
name: '@deepseek-ai/dsh-tool-subagent'
|
|
232
399
|
config:
|
|
233
400
|
provider: spawn
|
|
234
401
|
toolName: subagent
|
|
235
|
-
|
|
402
|
+
modelSelection: true
|
|
403
|
+
modelDiscovery: true
|
|
236
404
|
- id: tool-subagent-fork
|
|
237
405
|
name: '@deepseek-ai/dsh-tool-subagent'
|
|
238
406
|
config:
|
|
@@ -240,10 +408,12 @@
|
|
|
240
408
|
toolName: subagent_fork
|
|
241
409
|
- id: workflow-ptc
|
|
242
410
|
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
411
|
+
disabled: true
|
|
243
412
|
config:
|
|
244
413
|
provider: spawn
|
|
245
414
|
- id: tool-workflow
|
|
246
415
|
name: '@deepseek-ai/dsh-tool-workflow'
|
|
416
|
+
disabled: true
|
|
247
417
|
- id: tool-ask-user
|
|
248
418
|
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
249
419
|
- id: tool-todo
|
|
@@ -255,8 +425,12 @@
|
|
|
255
425
|
config:
|
|
256
426
|
fetch: true
|
|
257
427
|
searchTimeoutMs: 60000
|
|
428
|
+
- id: tool-executor-ptc
|
|
429
|
+
name: '@deepseek-ai/dsh-tool-executor-ptc'
|
|
258
430
|
- id: present
|
|
259
431
|
name: '@deepseek-ai/dsh-tool-present'
|
|
432
|
+
- id: tool-office
|
|
433
|
+
name: '@deepseek-ai/dsh-tool-office'
|
|
260
434
|
- id: tool-plugin-manager
|
|
261
435
|
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
262
436
|
disabled: true
|
package/lib/analyzer.js
CHANGED
|
@@ -5,14 +5,18 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
MANIFEST_FILE,
|
|
7
7
|
SKILL_FILE,
|
|
8
|
+
guideIssues,
|
|
8
9
|
parseManifest,
|
|
9
10
|
require_dist
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-77ZYHRN7.js";
|
|
11
12
|
import {
|
|
13
|
+
BUILTIN_PACK_VERSION,
|
|
12
14
|
PACKS_CAPABILITY,
|
|
13
|
-
ScriptId
|
|
15
|
+
ScriptId
|
|
16
|
+
} from "./chunk-V2X4PLF5.js";
|
|
17
|
+
import {
|
|
14
18
|
external_exports
|
|
15
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-SHTX4AGU.js";
|
|
16
20
|
import {
|
|
17
21
|
__toESM
|
|
18
22
|
} from "./chunk-2UFLGPDY.js";
|
|
@@ -360,6 +364,7 @@ async function isFile(path) {
|
|
|
360
364
|
// packages/analyzer/lib/drafts.js
|
|
361
365
|
import { cp, mkdir, readdir as readdir2, readFile as readFile3, rename, rm, writeFile } from "node:fs/promises";
|
|
362
366
|
import { join as join3 } from "node:path";
|
|
367
|
+
var WHEN = /^(\d{4}-\d{2}-\d{2}T\d{2})-(\d{2})-(\d{2})-(\d{3})Z$/;
|
|
363
368
|
var DraftStore = class {
|
|
364
369
|
#root;
|
|
365
370
|
#packs;
|
|
@@ -391,6 +396,16 @@ var DraftStore = class {
|
|
|
391
396
|
`);
|
|
392
397
|
return { tasks: parsed.tasks.map((t) => ({ id: t.id, title: t.title })) };
|
|
393
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Validate a pack and put it in use: the user's pack from now on, with no draft left waiting.
|
|
401
|
+
* @returns `replaced`: a user pack of this id was there before (now in the history).
|
|
402
|
+
* @throws PackError naming every problem; the pack in use is then untouched.
|
|
403
|
+
*/
|
|
404
|
+
async save(meta, manifest, skill, now = Date.now()) {
|
|
405
|
+
const { tasks } = await this.propose(meta, manifest, skill);
|
|
406
|
+
const { dir, replaced } = await this.accept(meta.packId, now);
|
|
407
|
+
return { dir, tasks, replaced };
|
|
408
|
+
}
|
|
394
409
|
async list() {
|
|
395
410
|
const out = [];
|
|
396
411
|
for (const id of await readdir2(this.#root).catch(() => [])) {
|
|
@@ -405,22 +420,64 @@ var DraftStore = class {
|
|
|
405
420
|
const meta = JSON.parse(await readFile3(join3(dir, "draft.json"), "utf8"));
|
|
406
421
|
return { ...meta, manifest: await readFile3(join3(dir, MANIFEST_FILE), "utf8"), skill: await readFile3(join3(dir, SKILL_FILE), "utf8").catch(() => "") };
|
|
407
422
|
}
|
|
408
|
-
/** Install the draft as the user's pack. @returns the pack directory. */
|
|
423
|
+
/** Install the draft as the user's pack. @returns the pack directory, and whether a user pack was there before. */
|
|
409
424
|
async accept(packId, now = Date.now()) {
|
|
410
425
|
const draft = await this.get(packId);
|
|
411
426
|
parseManifest(draft.manifest);
|
|
412
427
|
const target = join3(this.#packs, packId);
|
|
413
|
-
const previous = await
|
|
414
|
-
if (previous) {
|
|
415
|
-
const aside = join3(this.#history, packId, new Date(now).toISOString().replace(/[:.]/g, "-"));
|
|
416
|
-
await mkdir(join3(this.#history, packId), { recursive: true });
|
|
417
|
-
await cp(target, aside, { recursive: true });
|
|
418
|
-
await rm(target, { recursive: true, force: true });
|
|
419
|
-
}
|
|
428
|
+
const previous = await this.#aside(packId, now);
|
|
420
429
|
await mkdir(this.#packs, { recursive: true });
|
|
421
430
|
await rename(join3(this.#root, packId), target);
|
|
422
431
|
await rm(join3(target, "draft.json"), { force: true });
|
|
423
|
-
return { dir: target, meta: draft };
|
|
432
|
+
return { dir: target, meta: draft, replaced: previous };
|
|
433
|
+
}
|
|
434
|
+
/** Move the user pack in use, if there is one, into the history. @returns whether there was one. */
|
|
435
|
+
async #aside(packId, now) {
|
|
436
|
+
const target = join3(this.#packs, packId);
|
|
437
|
+
if (!await readdir2(target).then(() => true, () => false))
|
|
438
|
+
return false;
|
|
439
|
+
const aside = join3(this.#history, packId, new Date(now).toISOString().replace(/[:.]/g, "-"));
|
|
440
|
+
await mkdir(join3(this.#history, packId), { recursive: true });
|
|
441
|
+
await cp(target, aside, { recursive: true });
|
|
442
|
+
await rm(target, { recursive: true, force: true });
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
/** The versions of a user pack that were replaced, the last replaced first. */
|
|
446
|
+
async history(packId) {
|
|
447
|
+
const out = [];
|
|
448
|
+
for (const id of await readdir2(join3(this.#history, packId)).catch(() => [])) {
|
|
449
|
+
const when = WHEN.exec(id);
|
|
450
|
+
const manifest = when === null ? void 0 : await readFile3(join3(this.#history, packId, id, MANIFEST_FILE), "utf8").catch(() => void 0);
|
|
451
|
+
if (when !== null && manifest !== void 0)
|
|
452
|
+
out.push({ id, at: Date.parse(`${when[1]}:${when[2]}:${when[3]}.${when[4]}Z`), manifest });
|
|
453
|
+
}
|
|
454
|
+
return out.sort((a, b) => b.at - a.at);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Put a replaced version back in use. The pack in use now goes into the
|
|
458
|
+
* history in its place, so this can be undone the same way.
|
|
459
|
+
* @throws Error when there is no such version, or it no longer fits the schema (nothing is changed then).
|
|
460
|
+
*/
|
|
461
|
+
async restore(packId, versionId, now = Date.now()) {
|
|
462
|
+
const from = join3(this.#history, packId, versionId);
|
|
463
|
+
const manifest = WHEN.test(versionId) ? await readFile3(join3(from, MANIFEST_FILE), "utf8").catch(() => void 0) : void 0;
|
|
464
|
+
if (manifest === void 0)
|
|
465
|
+
throw new Error(`\u5386\u53F2\u91CC\u6CA1\u6709\u811A\u672C\u5305 ${packId} \u7684\u8FD9\u4E2A\u7248\u672C\uFF1A${versionId}`);
|
|
466
|
+
parseManifest(manifest, `\u5386\u53F2\u7248\u672C ${packId}/${MANIFEST_FILE}`);
|
|
467
|
+
const target = join3(this.#packs, packId);
|
|
468
|
+
await this.#aside(packId, now);
|
|
469
|
+
await mkdir(this.#packs, { recursive: true });
|
|
470
|
+
await rename(from, target);
|
|
471
|
+
return { dir: target };
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Stop using the user pack: it goes into the history, and the built-in pack
|
|
475
|
+
* of the same id (when there is one) is the pack again.
|
|
476
|
+
* @throws Error when there is no user pack of this id.
|
|
477
|
+
*/
|
|
478
|
+
async discard(packId, now = Date.now()) {
|
|
479
|
+
if (!await this.#aside(packId, now))
|
|
480
|
+
throw new Error(`\u6CA1\u6709\u81EA\u5DF1\u5199\u7684\u811A\u672C\u5305 ${packId}`);
|
|
424
481
|
}
|
|
425
482
|
async reject(packId) {
|
|
426
483
|
await rm(join3(this.#root, packId), { recursive: true, force: true });
|
|
@@ -467,6 +524,17 @@ var AdgAnalyzer = class extends Service {
|
|
|
467
524
|
this.drafts = new DraftStore(library.dataDir);
|
|
468
525
|
const drafts = this.drafts;
|
|
469
526
|
const changed = (packId) => ctx.get("adgGateway")?.broadcast("packs/changed", packId === void 0 ? {} : { packId });
|
|
527
|
+
const use = async (packId, scriptId) => {
|
|
528
|
+
await library.reloadPacks();
|
|
529
|
+
try {
|
|
530
|
+
await library.attachPack(scriptId, packId);
|
|
531
|
+
return void 0;
|
|
532
|
+
} catch (error) {
|
|
533
|
+
const problem = error instanceof Error ? error.message : String(error);
|
|
534
|
+
log.warn(`pack ${packId} saved but could not attach it to ${scriptId}: ${problem}`);
|
|
535
|
+
return problem;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
470
538
|
ctx.inject(["skills", "adgGateway"], (scoped) => {
|
|
471
539
|
let disposers = [];
|
|
472
540
|
const register = async () => {
|
|
@@ -513,7 +581,7 @@ var AdgAnalyzer = class extends Service {
|
|
|
513
581
|
};
|
|
514
582
|
ctx.inject(["adgGateway"], (gateway) => gateway.adgGateway.agentPart("adg-analyzer tools", (agent) => {
|
|
515
583
|
const registered = [];
|
|
516
|
-
for (const tool of analyzerTools({ library, drafts, approve, ready: scripts.ready, changed }))
|
|
584
|
+
for (const tool of analyzerTools({ library, drafts, approve, ready: scripts.ready, changed, use }))
|
|
517
585
|
registered.push(agent.tools.register({ ...tool, execute: async (args, exec) => {
|
|
518
586
|
await ctx.get("adgGateway")?.guardTool(exec);
|
|
519
587
|
return tool.execute(args, exec);
|
|
@@ -538,12 +606,7 @@ var AdgAnalyzer = class extends Service {
|
|
|
538
606
|
await scripts.ready;
|
|
539
607
|
const { packId } = params;
|
|
540
608
|
const { dir, meta } = await drafts.accept(packId);
|
|
541
|
-
await
|
|
542
|
-
try {
|
|
543
|
-
await library.attachPack(meta.scriptId, packId);
|
|
544
|
-
} catch (error) {
|
|
545
|
-
log.warn(`accepted pack ${packId} but could not attach it to ${meta.scriptId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
546
|
-
}
|
|
609
|
+
await use(packId, meta.scriptId);
|
|
547
610
|
changed(packId);
|
|
548
611
|
return { packId, dir };
|
|
549
612
|
},
|
|
@@ -552,6 +615,39 @@ var AdgAnalyzer = class extends Service {
|
|
|
552
615
|
await drafts.reject(packId);
|
|
553
616
|
changed(packId);
|
|
554
617
|
return {};
|
|
618
|
+
},
|
|
619
|
+
"packs/history": async (params) => {
|
|
620
|
+
await scripts.ready;
|
|
621
|
+
const { packId } = params;
|
|
622
|
+
const tasksOf = (manifest) => {
|
|
623
|
+
try {
|
|
624
|
+
return parseManifest(manifest).tasks.map((t) => ({ id: t.id, title: t.title }));
|
|
625
|
+
} catch {
|
|
626
|
+
return [];
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
const items = (await drafts.history(packId)).map((v) => ({ id: v.id, at: v.at, tasks: tasksOf(v.manifest) }));
|
|
630
|
+
const over = library.pack(packId)?.over;
|
|
631
|
+
if (over !== void 0)
|
|
632
|
+
items.push({ id: BUILTIN_PACK_VERSION, builtin: true, tasks: over.manifest.tasks.map((t) => ({ id: t.id, title: t.title })) });
|
|
633
|
+
return { items };
|
|
634
|
+
},
|
|
635
|
+
"packs/restore": async (params) => {
|
|
636
|
+
await scripts.ready;
|
|
637
|
+
const { packId, version } = params;
|
|
638
|
+
if (version === BUILTIN_PACK_VERSION) {
|
|
639
|
+
if (library.pack(packId)?.over === void 0)
|
|
640
|
+
throw new Error(`${packId} \u6CA1\u6709\u5185\u7F6E\u7684\u811A\u672C\u5305\u53EF\u4EE5\u6062\u590D`);
|
|
641
|
+
await drafts.discard(packId);
|
|
642
|
+
} else {
|
|
643
|
+
await drafts.restore(packId, version);
|
|
644
|
+
}
|
|
645
|
+
await library.reloadPacks();
|
|
646
|
+
for (const script of library.list().scripts)
|
|
647
|
+
if (script.packId === packId)
|
|
648
|
+
await use(packId, script.id);
|
|
649
|
+
changed(packId);
|
|
650
|
+
return {};
|
|
555
651
|
}
|
|
556
652
|
}
|
|
557
653
|
});
|
|
@@ -676,7 +772,7 @@ function analyzerTools(deps) {
|
|
|
676
772
|
}),
|
|
677
773
|
tool({
|
|
678
774
|
name: "pack_reviewed",
|
|
679
|
-
description: "\u811A\u672C\u66F4\u65B0\u540E\u68C0\u67E5\u8FC7\u811A\u672C\u5305\u3001\u786E\u8BA4\u4E0D\u7528\u6539\u65F6\u8C03\u7528\uFF1A\u8BB0\u4E0B\u811A\u672C\u5305\u5DF2\u7ECF\u5BF9\u7167\u73B0\u5728\u7684\u7248\u672C\u68C0\u67E5\u8FC7\uFF0C\u4E0D\u518D\u63D0\u9192\u3002\u8981\u6539\u5C31\u7528 pack_propose \
|
|
775
|
+
description: "\u811A\u672C\u66F4\u65B0\u540E\u68C0\u67E5\u8FC7\u811A\u672C\u5305\u3001\u786E\u8BA4\u4E0D\u7528\u6539\u65F6\u8C03\u7528\uFF1A\u8BB0\u4E0B\u811A\u672C\u5305\u5DF2\u7ECF\u5BF9\u7167\u73B0\u5728\u7684\u7248\u672C\u68C0\u67E5\u8FC7\uFF0C\u4E0D\u518D\u63D0\u9192\u3002\u8981\u6539\u5C31\u7528 pack_propose \u4FDD\u5B58\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u81EA\u52A8\u8BB0\u4E0B\uFF0C\u4E0D\u7528\u8C03\u7528\u8FD9\u4E2A\u3002",
|
|
680
776
|
properties: {
|
|
681
777
|
id,
|
|
682
778
|
reason: { type: "string", description: "\u4E3A\u4EC0\u4E48\u4E0D\u7528\u6539\uFF08\u4F1A\u544A\u8BC9\u7528\u6237\uFF09\uFF0C\u4F8B\u5982\u300C\u8FD9\u51E0\u4E2A\u7248\u672C\u53EA\u4FEE\u4E86\u8BC6\u522B\u95EE\u9898\uFF0C\u4EFB\u52A1\u3001\u914D\u7F6E\u548C\u65E5\u5FD7\u90FD\u6CA1\u53D8\u300D\u3002" }
|
|
@@ -692,12 +788,12 @@ function analyzerTools(deps) {
|
|
|
692
788
|
}),
|
|
693
789
|
tool({
|
|
694
790
|
name: "pack_propose",
|
|
695
|
-
description: "\
|
|
791
|
+
description: "\u4FDD\u5B58\u811A\u672C\u5305\uFF08adg.script.yaml \u548C SKILL.md\uFF09\uFF0C\u76F4\u63A5\u751F\u6548\uFF0C\u4E0D\u7528\u7528\u6237\u518D\u786E\u8BA4\uFF1A\u65B0\u5199\u4E00\u4EFD\uFF0C\u6216\u8005\u7528\u539F\u6765\u7684 id \u6539\u5DF2\u6709\u7684\u4E00\u4EFD\uFF08\u5185\u7F6E\u7684\u3001\u7528\u6237\u786E\u8BA4\u8FC7\u7684\u90FD\u53EF\u4EE5\uFF1B\u88AB\u66FF\u6362\u7684\u90A3\u4E00\u7248\u7559\u5728\u5386\u53F2\u91CC\uFF09\u3002\u4F1A\u6309 schema \u6821\u9A8C\uFF0C\u5E76\u68C0\u67E5 manifest \u91CC\u7ED9\u7528\u6237\u770B\u7684\u4F7F\u7528\u8BF4\u660E\uFF08guide\u3001\u4EFB\u52A1\u548C\u53C2\u6570\u7684 description\u3001\u4E34\u65F6\u4FEE\u6539\u7684 note\uFF09\uFF1A\u7F3A\u4E86\u6216\u6DF7\u8FDB\u4E86\u7ED9 agent \u7684\u5185\u5BB9\uFF08\u5DE5\u5177\u540D\u3001\u811A\u672C\u5305\u5B57\u6BB5\u3001\u5360\u4F4D\u7B26\u3001\u6838\u9A8C\u4F9D\u636E\u3001\u5F85\u786E\u8BA4\uFF09\u90FD\u4F1A\u5931\u8D25\u5E76\u8FD4\u56DE\u5177\u4F53\u4F4D\u7F6E\uFF0C\u811A\u672C\u5305\u4FDD\u6301\u539F\u6837\uFF0C\u4FEE\u6B63\u540E\u91CD\u65B0\u63D0\u4EA4\uFF1B\u901A\u8FC7\u540E\u8FD9\u4E2A\u811A\u672C\u9A6C\u4E0A\u7528\u65B0\u7684\u811A\u672C\u5305\uFF0C\u4E4B\u540E\u7684 script_run\u3001script_tasks \u90FD\u6309\u5B83\u6765\u3002\u4E0D\u4F1A\u4FEE\u6539\u811A\u672C\u672C\u8EAB\u3002",
|
|
696
792
|
properties: {
|
|
697
793
|
pack_id: { type: "string", description: "\u811A\u672C\u5305 id\uFF08\u4E0E manifest \u91CC\u7684 id \u76F8\u540C\uFF1B\u6539\u8FDB\u5DF2\u6709\u811A\u672C\u5305\u65F6\u7528\u539F id\uFF09\u3002" },
|
|
698
794
|
script_id: { type: "string", description: "\u8FD9\u4E2A\u5305\u63CF\u8FF0\u7684\u811A\u672C\u5E93\u91CC\u7684\u811A\u672C id\u3002" },
|
|
699
|
-
manifest: { type: "string", description: "adg.script.yaml \u7684\u5B8C\u6574\u5185\u5BB9\u3002" },
|
|
700
|
-
skill: { type: "string", description: "SKILL.md \u7684\u5B8C\u6574\u5185\u5BB9\uFF08\u4EE5 name / description frontmatter \u5F00\u5934\uFF09\u3002" },
|
|
795
|
+
manifest: { type: "string", description: "adg.script.yaml \u7684\u5B8C\u6574\u5185\u5BB9\uFF0C\u5305\u62EC guide\uFF08\u7ED9\u7528\u6237\u770B\u7684\u4F7F\u7528\u8BF4\u660E\uFF0C\u811A\u672C\u9875\u663E\u793A\uFF09\u3002" },
|
|
796
|
+
skill: { type: "string", description: "SKILL.md \u7684\u5B8C\u6574\u5185\u5BB9\uFF08\u4EE5 name / description frontmatter \u5F00\u5934\uFF09\uFF1A\u53EA\u7ED9 agent \u770B\u7684\u5907\u6CE8\u2014\u2014\u7528\u6237\u8BF4\u6CD5\u600E\u4E48\u5BF9\u5E94\u4EFB\u52A1\u3001\u64CD\u4F5C\u8981\u70B9\u3001\u6838\u9A8C\u4F9D\u636E\u3001\u9650\u5236\u3001\u5F85\u786E\u8BA4\u3002" },
|
|
701
797
|
summary: { type: "string", description: "\u7ED9\u7528\u6237\u770B\u7684\u4E00\u6BB5\u8BDD\uFF1A\u505A\u4E86\u4EC0\u4E48\u3001\u4F9D\u636E\u662F\u4EC0\u4E48\u3001\u54EA\u4E9B\u8FD8\u5F85\u786E\u8BA4\u3002" },
|
|
702
798
|
docs: {
|
|
703
799
|
type: "array",
|
|
@@ -708,7 +804,7 @@ function analyzerTools(deps) {
|
|
|
708
804
|
},
|
|
709
805
|
required: ["pack_id", "script_id", "manifest", "skill", "summary", "docs"],
|
|
710
806
|
kind: "edit",
|
|
711
|
-
title: (a) => `\
|
|
807
|
+
title: (a) => `\u4FDD\u5B58\u811A\u672C\u5305\uFF1A${String(a["pack_id"] ?? "")}`,
|
|
712
808
|
execute: async (args, exec) => {
|
|
713
809
|
const a = parse(external_exports.object({
|
|
714
810
|
pack_id: ScriptId,
|
|
@@ -724,7 +820,11 @@ function analyzerTools(deps) {
|
|
|
724
820
|
throw new Error("\u5148\u8BFB\u9879\u76EE\u7684\u6587\u6863\u518D\u5199\u811A\u672C\u5305\uFF1Adocs \u91CC\u5199\u51FA\u8BFB\u8FC7\u7684\u6587\u6863\uFF08\u51FA\u5904\u548C\u5F97\u5230\u4E86\u4EC0\u4E48\uFF09\uFF1B\u786E\u5B9E\u627E\u4E0D\u5230\u6587\u6863\u65F6\u7528 no_docs \u8BF4\u660E\u627E\u8FC7\u54EA\u4E9B\u5730\u65B9\uFF08\u811A\u672C\u76EE\u5F55\u3001\u4ED3\u5E93 README\u3001Wiki\u3001\u6587\u6863\u7AD9\uFF09");
|
|
725
821
|
}
|
|
726
822
|
deps.library.get(a.script_id);
|
|
727
|
-
const
|
|
823
|
+
const issues = guideIssues(parseManifest(a.manifest, `${a.pack_id}/${MANIFEST_FILE}`));
|
|
824
|
+
if (issues.length > 0)
|
|
825
|
+
throw new Error(`\u4F7F\u7528\u8BF4\u660E\u8FD8\u8981\u6539\uFF08\u6309 script-analysis \u6280\u80FD\u300C\u4F7F\u7528\u8BF4\u660E\u300D\u4E00\u8282\uFF09\uFF1A
|
|
826
|
+
- ${issues.join("\n- ")}`);
|
|
827
|
+
const saved = await deps.drafts.save({
|
|
728
828
|
packId: a.pack_id,
|
|
729
829
|
scriptId: a.script_id,
|
|
730
830
|
proposedAt: Date.now(),
|
|
@@ -733,8 +833,17 @@ function analyzerTools(deps) {
|
|
|
733
833
|
...docs.length > 0 || a.no_docs == null ? {} : { noDocs: a.no_docs.trim() },
|
|
734
834
|
...exec.agent === void 0 ? {} : { sessionId: exec.agent.session.id }
|
|
735
835
|
}, a.manifest, a.skill);
|
|
836
|
+
const problem = await deps.use(a.pack_id, a.script_id);
|
|
736
837
|
deps.changed(a.pack_id);
|
|
737
|
-
return {
|
|
838
|
+
return {
|
|
839
|
+
ok: true,
|
|
840
|
+
pack_id: a.pack_id,
|
|
841
|
+
tasks: saved.tasks,
|
|
842
|
+
in_use: problem === void 0,
|
|
843
|
+
replaced: saved.replaced,
|
|
844
|
+
...problem === void 0 ? {} : { problem },
|
|
845
|
+
next: problem === void 0 ? `\u811A\u672C\u5305\u5DF2\u7ECF\u4FDD\u5B58\u5E76\u751F\u6548${saved.replaced ? "\uFF08\u4E4B\u524D\u7684\u7248\u672C\u7559\u5728\u5386\u53F2\u91CC\uFF09" : ""}\uFF0C\u4E0D\u7528\u7528\u6237\u786E\u8BA4\u3002\u56DE\u590D\u91CC\u544A\u8BC9\u7528\u6237\u6539\u4E86\u4EC0\u4E48\u3001\u4F9D\u636E\u4E86\u54EA\u4E9B\u6587\u6863\u3001\u54EA\u4E9B\u8FD8\u5F85\u786E\u8BA4\u3002` : `\u811A\u672C\u5305\u5DF2\u7ECF\u4FDD\u5B58\uFF0C\u4F46\u6CA1\u80FD\u63A5\u5230\u811A\u672C ${a.script_id} \u4E0A\uFF1A${problem}\u3002\u628A\u8FD9\u4E2A\u539F\u56E0\u544A\u8BC9\u7528\u6237\u3002`
|
|
846
|
+
};
|
|
738
847
|
}
|
|
739
848
|
})
|
|
740
849
|
];
|