@minidoll/agentkit-dsh-plugin 0.0.0-stage → 0.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/README.md +59 -2
- package/cordis.patch.yml +5 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +288 -0
- package/dist/execute.d.ts +27 -0
- package/dist/execute.js +51 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +667 -0
- package/dist/inject.d.ts +74 -0
- package/dist/inject.js +248 -0
- package/dist/install.d.ts +81 -0
- package/dist/install.js +213 -0
- package/dist/payload.d.ts +37 -0
- package/dist/payload.js +64 -0
- package/package.json +51 -4
package/dist/payload.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
export function buildPayload(input) {
|
|
4
|
+
return {
|
|
5
|
+
event: input.event,
|
|
6
|
+
hookId: input.hookId,
|
|
7
|
+
toolName: input.toolName,
|
|
8
|
+
args: input.args,
|
|
9
|
+
sessionId: input.sessionId,
|
|
10
|
+
cwd: input.cwd ?? null,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** payload 走 stdin:一行 JSON + 换行(与 DSH shell 服务的词汇表一致)。 */
|
|
14
|
+
export function payloadStdin(payload) {
|
|
15
|
+
return `${JSON.stringify(payload)}\n`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 环境变量。
|
|
19
|
+
*
|
|
20
|
+
* **必须显式带上 PATH**:harness 的执行器给命令的是**干净环境** ——
|
|
21
|
+
* `env: { ...ENV_OVERRIDES, ...spec.env, ...spec.dshEnv }`,**没有 process.env**。
|
|
22
|
+
* 于是 `node .agent/generated/dsh-hook-bridge.mjs Gx` 在里面找不到 node,
|
|
23
|
+
* 命令静默失败、不写台账 —— 这正是"真实 seam 有痕迹但台账不动"的根因
|
|
24
|
+
* (我自己的探针能跑通,是因为探针进程有 PATH)。
|
|
25
|
+
*/
|
|
26
|
+
export function hookEnv(cwd, hookId, sessionId) {
|
|
27
|
+
// **关键**:DSH 宿主进程的 PATH 里往往**没有 node**(桌面应用的 PATH 通常是
|
|
28
|
+
// /usr/bin:/bin),实测 exit=127(command not found)。插件跑在宿主的 Node
|
|
29
|
+
// 运行时里 —— `process.execPath` 就是 node 的绝对路径,把它所在目录加进 PATH,
|
|
30
|
+
// `node ...` 才解析得到。
|
|
31
|
+
const nodeDir = nodeBinDir() ?? dirname(process.execPath);
|
|
32
|
+
const hostPath = process.env.PATH;
|
|
33
|
+
return {
|
|
34
|
+
CLAUDE_PROJECT_DIR: cwd,
|
|
35
|
+
DSH_HOOK_ID: hookId,
|
|
36
|
+
DSH_SESSION_ID: sessionId ?? '',
|
|
37
|
+
// PATH = node 所在目录 + 宿主 PATH(node 目录放最前,保证 `node` 可解析)
|
|
38
|
+
PATH: [nodeDir, hostPath ?? '/usr/local/bin:/usr/bin:/bin'].filter((p) => p !== '').join(':'),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 找到能跑 `node` 的目录。
|
|
43
|
+
*
|
|
44
|
+
* `process.execPath` 在插件跑在 Node 里时就是 node 本身;但 DSH 桌面端
|
|
45
|
+
* 可能把它跑在 Electron 宿主里(execPath 是 dsh-desktop)—— 那样要另外探测。
|
|
46
|
+
* 顺序:execPath 目录(若含 node)→ PATH 里第一个含 node 的目录 → 常见安装位置。
|
|
47
|
+
*/
|
|
48
|
+
export function nodeBinDir() {
|
|
49
|
+
const candidates = [dirname(process.execPath)];
|
|
50
|
+
for (const dir of (process.env.PATH ?? '').split(':'))
|
|
51
|
+
if (dir !== '')
|
|
52
|
+
candidates.push(dir);
|
|
53
|
+
candidates.push('/usr/local/bin', '/usr/bin', '/bin');
|
|
54
|
+
for (const dir of candidates) {
|
|
55
|
+
try {
|
|
56
|
+
if (existsSync(join(dir, 'node')))
|
|
57
|
+
return dir;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
/* 探测失败继续 */
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minidoll/agentkit-dsh-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DeepSeek Harness 插件:项目自包含的 lifecycle hooks(配置随仓库走,per-session 发现)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"cordis.patch.yml",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "esbuild src/index.ts src/cli.ts --bundle --platform=node --format=esm --outdir=dist --target=node20",
|
|
20
|
+
"prepack": "npm run build",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
23
|
+
"dev:install": "node scripts/dev-install.mjs"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22",
|
|
27
|
+
"agentkit-plugin-core": "workspace:*"
|
|
28
|
+
},
|
|
29
|
+
"dsh": {
|
|
30
|
+
"bundle": {
|
|
31
|
+
"patch": "./cordis.patch.yml"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"dsh-landing": "dist/cli.js"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/agentkit/agentkit.git",
|
|
44
|
+
"directory": "packages/plugins/dsh"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"deepseek-harness",
|
|
48
|
+
"dsh",
|
|
49
|
+
"agent",
|
|
50
|
+
"hooks",
|
|
51
|
+
"agentkit"
|
|
52
|
+
]
|
|
53
|
+
}
|