dsh-hiss-plugins 2.0.0 → 3.0.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 +14 -90
- package/cordis.patch.yml +2 -8
- package/lib/client.js +4 -7
- package/lib/project-mcp/index.js +2 -2
- package/locale/en.json +3 -5
- package/locale/zh.json +3 -5
- package/package.json +12 -19
- package/lib/codegraph/index.js +0 -62
- package/lib/colgrep/index.js +0 -247
package/README.md
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
# dsh-hiss-plugins
|
|
2
2
|
|
|
3
|
-
一个 DeepSeek Harness **bundle
|
|
3
|
+
一个 DeepSeek Harness **bundle 插件**,把六个功能装在一个包里:**project-mcp**(项目 `.mcp.json`)、**git-bash**(Windows 上的 Git Bash shell)、**superpowers**(superpowers 技能常驻引导)、**ponytail**(ponytail 采纳提示与 `/ponytail` 等级切换)、**init**(读项目生成 `AGENTS.md`)、**fix**(先查根因、确认后再修)。六个功能各占一条顶层行,可以在 **Plugins 页**里单独开关;包还带一个管理标签,就挂在那个页面上。
|
|
4
4
|
|
|
5
5
|
安装后对 `web`、`headless` 等任意 profile 的**所有 preset、所有会话**生效。
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 七条行与六个开关
|
|
8
8
|
|
|
9
|
-
`cordis.patch.yml` 只做一件事:`insert`
|
|
9
|
+
`cordis.patch.yml` 只做一件事:`insert` 七条**顶层行**。宿主用 `name`(模块说明符)解析模块,用 `id` 记住开关状态。
|
|
10
10
|
|
|
11
11
|
| 行 id | 模块 | 作用 | 默认 |
|
|
12
12
|
|---|---|---|---|
|
|
13
13
|
| `dsh-hiss-plugins` | `dsh-hiss-plugins` | 载体行:空的 host 半,只为让浏览器半(`lib/client.js`,即管理标签)被送出 | 开 |
|
|
14
|
-
| `dsh-hiss-plugins-colgrep` | `dsh-hiss-plugins/colgrep` | `colgrep` 模型工具(语义检索,`root` 可指定项目) | 开 |
|
|
15
|
-
| `dsh-hiss-plugins-codegraph` | `dsh-hiss-plugins/codegraph` | 经 MCP 注册 `mcp__codegraph__*` 工具 + 使用引导 | 开 |
|
|
16
14
|
| `dsh-hiss-plugins-project-mcp` | `dsh-hiss-plugins/project-mcp` | 读会话项目根的 `.mcp.json`,把其中的 MCP server 挂进该 agent 自己的 scope | 开 |
|
|
17
15
|
| `dsh-hiss-plugins-gitbash` | `dsh-hiss-plugins/gitbash` | Windows 上接入 Git Bash:提供 `ctx.shell` + 宿主 `bash` 工具 | 非 Windows 关 |
|
|
18
16
|
| `dsh-hiss-plugins-superpowers` | `dsh-hiss-plugins/superpowers` | superpowers 技能常驻引导:任何回复前先检查有没有适用的技能,有就先加载(技能集本身由 DSH 原生发现) | 开 |
|
|
@@ -20,7 +18,7 @@
|
|
|
20
18
|
| `dsh-hiss-plugins-init` | `dsh-hiss-plugins/init` | 宿主 `/init` 命令:读项目、生成/更新 `AGENTS.md` | 开 |
|
|
21
19
|
| `dsh-hiss-plugins-fix` | `dsh-hiss-plugins/fix` | 宿主 `/fix` 命令:先查根因并报告,确认后才修复 | 开 |
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
**六条功能行就是 Plugins 页里那六个开关。** 载体行不在标签的开关列表里 —— 它是空的 host 半,但只有它在,浏览器半才会被送进页面;关掉它,管理标签本身就没了。
|
|
24
22
|
|
|
25
23
|
为什么必须是顶层行:插件管理器只为「组合后的 patch 里存在同 `id`、同 `name`,且挂载后父 entry 就是 profile 的 `include`」的行持久化开关。包在 `cordis:group` 里的子行在 `listPlugins()` 里被判为 `unaddressable`,**永远不会有开关**。所以这里没有组:git-bash 行把 realm 隔离写在自己身上(见下)。
|
|
26
24
|
|
|
@@ -79,78 +77,6 @@ Plugins 页(侧边栏 **插件**)里多出一个 `dsh-hiss-plugins` 标签
|
|
|
79
77
|
- **为什么是一个顶层行而不是一个 realm 组**:组里的子行对插件管理器不可寻址,永远拿不到开关(见上)。所以隔离写在这一行自己的 `isolate` 上。
|
|
80
78
|
- 行上的 `disabled: !!js process.platform !== 'win32'` 只在非 Windows 上默认禁用;它是 `!!js` 值,宿主写开关覆盖时不会与它比较,所以用户在 Windows 上的显式开关照样持久化。
|
|
81
79
|
|
|
82
|
-
## 功能:colgrep
|
|
83
|
-
|
|
84
|
-
以 DSH **bundle 插件**形式提供一个宿主侧模型工具 `colgrep`,把 [colgrep](https://github.com/lightonai/next-plaid/tree/main/colgrep)(LightOn 的语义代码检索工具:ColBERT 多向量搜索,按“含义”而非“精确文本”找代码)接进来。
|
|
85
|
-
|
|
86
|
-
```text
|
|
87
|
-
colgrep "error handling for database connections"
|
|
88
|
-
colgrep "auth" -e "async fn" --include "*.rs"
|
|
89
|
-
colgrep command:"init" / command:"status" / command:"clear"
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
工具参数:
|
|
93
|
-
|
|
94
|
-
| 参数 | 类型 | 说明 |
|
|
95
|
-
|---|---|---|
|
|
96
|
-
| `query` | string(必填) | 自然语言查询 |
|
|
97
|
-
| `command` | enum `search`(默认)/`init`/`status`/`clear` | 检索 / 建索引 / 查状态 / 清索引 |
|
|
98
|
-
| `root` | string | 检索/索引哪个项目(默认工作区根;可绝对路径或相对工作区解析) |
|
|
99
|
-
| `path` | string | `root` 内的检索目标(默认整个 `root`)。注意:colgrep 会回落到项目索引,所以它是「聚焦」而非硬过滤 —— 要硬收窄请用 `include` / `pattern` |
|
|
100
|
-
| `top_k` | integer | 结果数(`-k`,默认 15) |
|
|
101
|
-
| `pattern` | string | 正则预筛(`-e`,hybrid:先 grep 再语义排序) |
|
|
102
|
-
| `include` | string | 只检索匹配 glob 的文件(`--include`,如 `"*.rs"`) |
|
|
103
|
-
| `code_only` | boolean | 只检索代码文件,跳过 md/txt/yaml/json 等 |
|
|
104
|
-
| `no_update` | boolean | 跳过自动重建索引,直接检索现有索引 |
|
|
105
|
-
| `agent` | boolean | 使用 colgrep 本地 sub-agent 搜索(`--agent --json`),返回 `file:start-end` 位置;需要 colgrep ≥1.8.5 与 agent 模型 |
|
|
106
|
-
|
|
107
|
-
行为要点:
|
|
108
|
-
|
|
109
|
-
- 结果以 `--json` 解析后折叠为紧凑可读文本(`文件:行-行 [语言, 类型, 名称] (score)` + 首行签名),不倾倒整段代码;模型可再 `read` 具体文件。解析兼容顶层数组与 `{results:[...]}` 两种 JSON 形状;`query` 为空或纯空白时返回明确错误。
|
|
110
|
-
- **agent 模式**:`agent:true` 时改用 `--agent --json`,解析 `locations`(`file/start_line/end_line`)折叠为位置列表;`submitted:false` 表示模型没有提交最终答案,列出的是它 inspect 过的位置。首次使用前在普通终端跑 `colgrep --install-agent` 下载约 2.5GB 模型;CPU 上约 75–90 秒/问题,工具超时放宽到 10 分钟。模型/缓存位于用户目录,workspace-write/read-only 沙箱可能拒绝写入,先在工作区外安装模型或在 full-access 下使用。
|
|
111
|
-
- **索引留在工作区内**:DSH 文件沙箱禁止写工作区之外,而 colgrep 检索需要写索引锁文件。插件把索引目录重定位到 `<工作区>/.colgrep-data`(通过 `COLGREP_DATA_DIR`),使全部写入落在沙箱允许范围内。ColBERT 模型与 ONNX runtime 从 `~/.cache` 只读加载,无需联网。
|
|
112
|
-
- **显式根目录**:`root` 只改变检索**运行的位置**(`workdir`),不改变索引位置 —— 索引数据始终留在当前工作区的 `.colgrep-data`,因为 colgrep 的索引是**按项目注册的**(`<data_dir>/indices/<项目名>-<hash>`),一个数据目录可以同时容纳多个项目的索引,跨项目检索不会把数据写到别人的仓库里。**真正限制结果范围的是 `root`**(换项目);`path` 相对 `root` 解析(无 `root` 时相对工作区),只做聚焦、不保证排他。
|
|
113
|
-
- 首次检索会自动建立索引(CPU 上大仓库可能需数分钟);可用 `command:"init"` 显式建索引,`no_update:true` 走现有索引。
|
|
114
|
-
- **主动使用**:注册 `colgrep:guidance` 提示词段(每回合重算,带上当前会话工作区路径),让模型在「按含义找代码、但说不出确切标识符」时优先用 `colgrep` 而不是 grep。
|
|
115
|
-
|
|
116
|
-
前置要求:
|
|
117
|
-
|
|
118
|
-
- 已安装 [colgrep](https://github.com/lightonai/next-plaid/tree/main/colgrep) CLI(`cargo install colgrep` 或官方预编译二进制),且 `colgrep` 在宿主进程的 PATH 上。
|
|
119
|
-
- agent 模式需要 **colgrep ≥1.8.5**;先在普通终端跑 `colgrep --install-agent` 下载 agent 模型(约 2.5GB,或在首次 `agent:true` 调用时下载)。
|
|
120
|
-
- 首次使用前,colgrep 需已下载默认模型 `lightonai/LateOn-Code-edge`(`colgrep "任意查询"` 会自动下载;私有模型需 `HF_TOKEN`,可用 `colgrep set-model` 切换)。
|
|
121
|
-
|
|
122
|
-
验证:重启后让模型调用 `colgrep`(例如“用 colgrep 搜索 error handling 相关代码”),或执行 `colgrep command:"status"` 看当前工作区的索引状态。
|
|
123
|
-
|
|
124
|
-
## 功能:codegraph
|
|
125
|
-
|
|
126
|
-
把 [codegraph](https://github.com/colbymchenry/codegraph)(本地优先的代码图 / 知识图谱)接进来:插件用宿主内置的 MCP 客户端桥(`@deepseek-ai/dsh-mcp-client`)加载 CodeGraph 的 MCP server(`codegraph serve --mcp`,serverName `codegraph`),注册 **`mcp__codegraph__codegraph_explore`** 工具 —— 一次调用返回相关符号的逐字源码(按文件分组)、符号间调用链(含动态分派跳转)与影响范围(blast radius)。
|
|
127
|
-
|
|
128
|
-
- 注入 `codegraph:guidance` 提示词段(每回合重算),让智能体对结构性问题(「X 如何工作」「X 如何到达 Y」「改某处会影响什么」)**优先直接调 `codegraph_explore`**,而不是 grep/逐文件读,并**传 `projectPath`** 指向当前工作区(引导文本里带当前会话工作区的绝对路径)。
|
|
129
|
-
- 引导段每回合检查当前工作区是否已有 `.codegraph/`:**没有**时多注入一句,带上可直接执行的 `codegraph init -y`,让智能体先建图再检索,而不是撞一次「无索引」错误。
|
|
130
|
-
- MCP server 以 `failOnStartupError: false` 加载:`codegraph` CLI 不在 PATH 上时,这一行的其它注册照常,工具缺席而不是把插件树拖垮。
|
|
131
|
-
|
|
132
|
-
前置要求:
|
|
133
|
-
|
|
134
|
-
1. 全局安装 CodeGraph CLI(`codegraph` 需在 DSH 宿主进程的 PATH 上):
|
|
135
|
-
|
|
136
|
-
```powershell
|
|
137
|
-
npm i -g @colbymchenry/codegraph
|
|
138
|
-
# 或:irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
2. 每个项目首次建图(生成 `.codegraph/` 索引;之后 MCP server 的 watcher 自动增量同步):
|
|
142
|
-
|
|
143
|
-
```powershell
|
|
144
|
-
cd <your-project>
|
|
145
|
-
codegraph init
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
已知问题与限制:
|
|
149
|
-
|
|
150
|
-
1. **模型仍需手动传 `projectPath`(部分缓解)**:DSH 宿主是单实例、多会话(多工作区),而 mcp-client 的 `cwd` 是宿主面静态配置(`process.cwd()`)。`codegraph_explore` 无法默认指向「当前会话工作区」,模型每次调用仍要自己填 `projectPath`;引导文本已动态注入当前会话工作区的绝对路径来降低漏填/填错概率,但工具本身仍未自动注入。理想做法是包装一个能自动注入会话 `cwd` 的工具,或让 server 按会话定位项目。
|
|
151
|
-
2. **自动同步只覆盖 MCP server 默认目录的项目**:codegraph 的文件 watcher 只持续监视 MCP server 启动 `cwd` 对应的项目(在 DSH 里即 `dsh` 进程的工作目录);经 `projectPath` 查询的其它项目没有持续 watcher,索引不会随编辑自动刷新,需手动 `codegraph sync`。因此当**会话工作区 ≠ dsh 启动目录**时,该仓库的索引不会自动跟进。对策:在目标仓库目录里启动 `dsh`,或手动 `codegraph sync`。
|
|
152
|
-
3. **不代建索引**:插件不后台跑 `codegraph init`。项目完全没建过图时,由**引导段提示模型自己执行** `codegraph init -y`(一行提示,零后台进程;`.codegraph/` 存在后该提示自动消失)。
|
|
153
|
-
|
|
154
80
|
## 功能:project-mcp
|
|
155
81
|
|
|
156
82
|
让 DSH 自动加载**项目目录下的 `.mcp.json`**(Claude Code 用的那个格式),把它声明的 MCP server 挂到**当前会话**上。在 `<项目根>/.mcp.json` 里写一次,之后在该项目里开的每个会话都自带这些 MCP 工具(`mcp__<server>__<tool>`),换个项目就换一套,互不干扰。
|
|
@@ -161,7 +87,7 @@ colgrep command:"init" / command:"status" / command:"clear"
|
|
|
161
87
|
- **首轮即生效**:挂载发生在 `agent/created`(宿主会 await 这个监听器)里,会话第一次对话就能看到工具;插件 reload 时也会给已经活着的 agent 补挂一次。
|
|
162
88
|
- **${VAR} 展开**:`${TOKEN}` / `${TOKEN:-默认值}` 在挂载时用宿主进程环境求值,`.mcp.json` 里不必写明文密钥。
|
|
163
89
|
- **失败不致命**:坏 JSON、不支持的 transport、起不来的 server 都只影响它自己,打一条 warn,会话照常开。
|
|
164
|
-
- **`/mcp` 看状态(文本报告)**:在本项目的会话里执行 `/mcp`,逐条列出 `.mcp.json` 声明的 server 与其实时状态 —— `connected, N tools`(MCP 桥连上并同步工具后才注册工具)、`no tools`(没连上,或 server 本身不暴露工具)、`skipped`(条目映射不了)、`unusable`(宿主 MCP 桥的 schema 拒绝);另外报告本会话里来自项目外配置的 MCP 工具总数。状态读的是当前 agent
|
|
90
|
+
- **`/mcp` 看状态(文本报告)**:在本项目的会话里执行 `/mcp`,逐条列出 `.mcp.json` 声明的 server 与其实时状态 —— `connected, N tools`(MCP 桥连上并同步工具后才注册工具)、`no tools`(没连上,或 server 本身不暴露工具)、`skipped`(条目映射不了)、`unusable`(宿主 MCP 桥的 schema 拒绝);另外报告本会话里来自项目外配置的 MCP 工具总数。状态读的是当前 agent 自己的工具表(0.2.3 起的 `ctx.tools.getAll(agent)`;旧的 `schemas()` 已移除),所以列的是**此刻真正可用**的工具;命令不接受参数。
|
|
165
91
|
- **新会话里立即显示**:DSH 的 Web 客户端在会话还没有任何 turn 时把整段对话当 blank 隐藏(只有 `turn/start` 会清 `sessionListMetadata.blank`),而 `/mcp` 只写 `command/run`/`command/done`。浏览器半因此给 `/mcp` 注册了一个非 `command` 的**伴随节点**(`hiss-mcp-command`,零尺寸),chat 视图立即激活——不必再先发一条消息。
|
|
166
92
|
- **`/mcp` 弹窗(Web GUI)**:输入框里敲 `/mcp`(不带参数)打开对话框,而不是发消息。布局是**左右两栏**:左边「全局 MCP」、右边「当前工作区 MCP」。每台服务器默认**折叠**,点「N 个工具」展开列表;展开后全局那栏每个工具一个开关(关掉后模型这一轮就看不到它),工作区那栏工具只读。两种服务器都带**整台开关**:全局那台写 mcp-manager 的 `enabled`(对所有会话生效),工作区那台即时挂载/卸载。工作区服务器旁的「注册到全局」把它的配置写进全局后,它**立刻同时出现在两栏**:全局那份对所有会话生效,工作区那份保持原样、继续给本会话用(想只留全局那份,就把工作区那栏的开关关掉)。右下「添加 MCP」按钮展开新增表单(选全局或工作区),标题栏「刷新」重新读取状态。开关状态按**工作区路径**记在 `~/.dsh/hiss-mcp.json`,换项目互不影响。带参数的 `/mcp` 仍走上面的文本报告(headless / ACP 也用它)。
|
|
167
93
|
- **为什么工作区服务器不能逐工具关**:DSH 只允许在 agent scope 屏蔽**全局层**注册的工具(`tools.restrict`),项目 MCP 工具挂在 agent 自己的 scope 里,只能整台挂载/卸载。要逐工具控制,点该服务器的「注册到全局」把它写进全局配置(mcp-manager),它随后出现在全局区、可逐工具开关。
|
|
@@ -257,7 +183,7 @@ colgrep command:"init" / command:"status" / command:"clear"
|
|
|
257
183
|
| `DSH_GIT_BASH` | 直接指定要执行的 `bash.exe`(最高优先级) |
|
|
258
184
|
| `GIT_ROOT` / `GIT_INSTALL_ROOT` | 指定 Git for Windows 安装根目录 |
|
|
259
185
|
|
|
260
|
-
**工作原理**(细节见 `cordis.patch.yml` 与该行的模块):`lib/gitbash/index.js` 是一个组合根 —— 它把执行器(`createGitBashExecutor(SandboxBashExecutor)`,注册 `ctx.shell`)与宿主 `bash` 工具(`@deepseek-ai/dsh-tool-bash`,消费 `ctx.shell`)一起挂进这一行自己的 realm。执行器继承 `dsh-bash-sandbox` 的 `SandboxBashExecutor`(复用 DSH 自己的沙箱分类、后台进程事实、超时/溢出/清理机制),只覆写三处(接缝名自 0.1.7 起为 `execute` / `executeArgv`,`confine` 为异步三参;`test/gitbash/` 打到真实基类,把这三个接缝钉在当前运行时代次 `0.2.
|
|
186
|
+
**工作原理**(细节见 `cordis.patch.yml` 与该行的模块):`lib/gitbash/index.js` 是一个组合根 —— 它把执行器(`createGitBashExecutor(SandboxBashExecutor)`,注册 `ctx.shell`)与宿主 `bash` 工具(`@deepseek-ai/dsh-tool-bash`,消费 `ctx.shell`)一起挂进这一行自己的 realm。执行器继承 `dsh-bash-sandbox` 的 `SandboxBashExecutor`(复用 DSH 自己的沙箱分类、后台进程事实、超时/溢出/清理机制),只覆写三处(接缝名自 0.1.7 起为 `execute` / `executeArgv`,`confine` 为异步三参;`test/gitbash/` 打到真实基类,把这三个接缝钉在当前运行时代次 `0.2.3-alpha.3` 上):
|
|
261
187
|
|
|
262
188
|
- `confine()`:把继承来的 `bash` 换成解析出的绝对路径,并把 MSYS2 启动失败追加进 `denialSignatures`。提供方的 `ctx.sandbox.confine` 是**异步**的且接受取消信号,所以这里必须 `await` 并把信号透传(把 Promise 当对象展开会丢掉整个 argv);前台与后台都经这条路径分类,判定一致。
|
|
263
189
|
- `executeArgv()`:`danger-full-access` 下父类**不走** `confine()`,而是自己拼一个字面量 `bash -c` 的 argv —— Windows 上那正是 WSL 启动器,所以在这个 argv 接缝上把裸 `bash` 换成解析出的路径(只重写数组形状的 `["bash","-c",cmd]`;受限路径交给 `confine()` 的是准备回调,原样通过)。
|
|
@@ -363,12 +289,10 @@ pnpm test # 在包目录内也可:node --test-isolation=none --test
|
|
|
363
289
|
结构:
|
|
364
290
|
|
|
365
291
|
```text
|
|
366
|
-
package.json
|
|
367
|
-
cordis.patch.yml
|
|
292
|
+
package.json 七条行的 bundle 声明(dsh.bundle.patch)+ 浏览器半声明(dsh.client)+ exports/files
|
|
293
|
+
cordis.patch.yml 七条顶层行(载体 + 六个功能)
|
|
368
294
|
lib/index.js 载体行:空 host 半
|
|
369
295
|
lib/client.js 浏览器半:Plugins 页管理标签(手写 lazy-CJS,无构建步骤)
|
|
370
|
-
lib/colgrep/ colgrep 工具
|
|
371
|
-
lib/codegraph/ codegraph MCP 桥 + 引导
|
|
372
296
|
lib/project-mcp/ lib/config.js 纯逻辑(无宿主依赖)+ lib/index.js 接线
|
|
373
297
|
lib/gitbash/ lib/resolve.js 纯逻辑 + lib/gitbash-executor.js 执行器 + lib/index.js 组合根
|
|
374
298
|
lib/superpowers/ 常驻引导提示词段(只注册 systemPrompt 段,不导入宿主包)
|
|
@@ -376,22 +300,22 @@ lib/ponytail/ lib/mode.js 纯逻辑(等级解析与默认值)+ lib/i
|
|
|
376
300
|
lib/init/ lib/prompt.js 纯逻辑(/init 指令正文)+ lib/index.js 命令接缝
|
|
377
301
|
lib/fix/ lib/prompt.js 纯逻辑(/fix 诊断工作流正文)+ lib/index.js 命令接缝
|
|
378
302
|
locale/*.json 管理标签的文案字典
|
|
379
|
-
test/ node:test:<feature>/
|
|
303
|
+
test/ node:test:<feature>/ 六个目录 + manifest / patch / client 三个契约测试
|
|
380
304
|
```
|
|
381
305
|
|
|
382
|
-
`lib/project-mcp/config.js`、`lib/gitbash/resolve.js`、`lib/ponytail/mode.js`、`lib/init/prompt.js` 与 `lib/fix/prompt.js` 刻意不导入任何宿主包,所以这些纯逻辑分支可以在没有 dsh 安装的环境里完整跑测试;宿主接缝由各功能的 `index.js` 承担。浏览器半用 fake `window.__ModuleLoader__` + fake `ctx`
|
|
306
|
+
`lib/project-mcp/config.js`、`lib/gitbash/resolve.js`、`lib/ponytail/mode.js`、`lib/init/prompt.js` 与 `lib/fix/prompt.js` 刻意不导入任何宿主包,所以这些纯逻辑分支可以在没有 dsh 安装的环境里完整跑测试;宿主接缝由各功能的 `index.js` 承担。浏览器半用 fake `window.__ModuleLoader__` + fake `ctx` 测注册与远程调用,不启动浏览器。测试全部离线,不联网、不依赖外部 CLI。
|
|
383
307
|
|
|
384
308
|
## 发布(给维护者)
|
|
385
309
|
|
|
386
310
|
```powershell
|
|
387
|
-
git tag dsh-hiss-plugins@
|
|
388
|
-
git push origin dsh-hiss-plugins@
|
|
311
|
+
git tag dsh-hiss-plugins@3.0.0 # 必须与本目录 package.json 的 version 逐字一致
|
|
312
|
+
git push origin dsh-hiss-plugins@3.0.0
|
|
389
313
|
```
|
|
390
314
|
|
|
391
315
|
CI(`.github/workflows/publish.yml`,Windows runner)解析 tag、跑全量测试,再用 **npm trusted publishing(OIDC,无需任何 token)** 发布;包内 `prepublishOnly` 会再跑一次 `npm test`。手工发布:`npm publish`(`publishConfig.access` 已设为 public),发版前先 `node ../scripts/smoke-profile.mjs` 走一遍真实安装 + 真启动。发布新版本前记得递增 `package.json` 的 `version`。
|
|
392
316
|
|
|
393
317
|
## 许可与来源
|
|
394
318
|
|
|
395
|
-
MIT,见 [LICENSE](LICENSE)
|
|
319
|
+
MIT,见 [LICENSE](LICENSE)。本包通过宿主 MCP 桥读取项目 `.mcp.json`,不内置任何外部工具。沙箱行为、拒绝方言与升级流程均来自 DSH 自身(`@deepseek-ai/dsh-shell` / `dsh-bash-sandbox` / `dsh-sandbox-*`),git-bash 功能只提供执行器接线与 Git Bash 解析。
|
|
396
320
|
|
|
397
|
-
> `@deepseek-ai/dsh-
|
|
321
|
+
> `@deepseek-ai/dsh-mcp-client`、`@deepseek-ai/dsh-bash-sandbox`、`@deepseek-ai/dsh-tool-bash`、`@deepseek-ai/dsh-llm`、`@deepseek-ai/dsh-skill` 由**正在运行的 dsh 安装**提供,本包只在 `peerDependencies` 里声明(`devDependencies` 供本仓安装与测试)。**不要**把它们写进 `dependencies` —— 那会让 pnpm 往 profile 里塞一份自己的副本,遮蔽安装目录里的同名包,两代混装会让整棵插件树启动失败。升级 dsh 后先跑 `node ../scripts/smoke-profile.mjs` 再发版。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# dsh-hiss-plugins bundle patch: one package,
|
|
1
|
+
# dsh-hiss-plugins bundle patch: one package, seven top-level rows.
|
|
2
2
|
#
|
|
3
3
|
# The carrier row (`dsh-hiss-plugins`) is an empty host half: it exists so the package
|
|
4
4
|
# holds a Loader row, which is what the client module system serves the browser half
|
|
5
5
|
# (`lib/client.js`, the Plugins-page management tab) for.
|
|
6
6
|
#
|
|
7
|
-
# The
|
|
7
|
+
# The six feature rows are deliberate TOP-LEVEL rows, never a `cordis:group` with
|
|
8
8
|
# children: the plugin manager can only persist enablement for an entry whose parent
|
|
9
9
|
# tree is the profile's include and that it can address by row id (see
|
|
10
10
|
# `dsh-plugin-manager`'s `listPlugins()`), so a nested row can never be switched from
|
|
@@ -16,12 +16,6 @@
|
|
|
16
16
|
- id: dsh-hiss-plugins
|
|
17
17
|
name: 'dsh-hiss-plugins'
|
|
18
18
|
|
|
19
|
-
- id: dsh-hiss-plugins-colgrep
|
|
20
|
-
name: 'dsh-hiss-plugins/colgrep'
|
|
21
|
-
|
|
22
|
-
- id: dsh-hiss-plugins-codegraph
|
|
23
|
-
name: 'dsh-hiss-plugins/codegraph'
|
|
24
|
-
|
|
25
19
|
- id: dsh-hiss-plugins-project-mcp
|
|
26
20
|
name: 'dsh-hiss-plugins/project-mcp'
|
|
27
21
|
|
package/lib/client.js
CHANGED
|
@@ -28,8 +28,6 @@ window.__ModuleLoader__.load({
|
|
|
28
28
|
* Each row is a top-level Loader row, which is what makes its switch addressable at all.
|
|
29
29
|
*/
|
|
30
30
|
const FEATURES = [
|
|
31
|
-
{ key: "colgrep", moduleName: `${PACKAGE_ID}/colgrep`, description: "featureColgrepDescription" },
|
|
32
|
-
{ key: "codegraph", moduleName: `${PACKAGE_ID}/codegraph`, description: "featureCodegraphDescription" },
|
|
33
31
|
{ key: "project-mcp", moduleName: `${PACKAGE_ID}/project-mcp`, description: "featureProjectMcpDescription" },
|
|
34
32
|
{ key: "gitbash", moduleName: `${PACKAGE_ID}/gitbash`, description: "featureGitbashDescription" },
|
|
35
33
|
{ key: "superpowers", moduleName: `${PACKAGE_ID}/superpowers`, description: "featureSuperpowersDescription" },
|
|
@@ -88,8 +86,6 @@ window.__ModuleLoader__.load({
|
|
|
88
86
|
reasonManagementRequired: "该插件由 DSH 自身管理,无法在这个页面切换。",
|
|
89
87
|
reasonUnaddressable: "无法在 profile 中定位该插件的行,请手动修改 cordis.patch.yml。",
|
|
90
88
|
reasonUnknown: "该插件无法在这个页面切换({code})。",
|
|
91
|
-
featureColgrepDescription: "语义代码检索工具",
|
|
92
|
-
featureCodegraphDescription: "代码图 MCP 工具",
|
|
93
89
|
featureProjectMcpDescription: "按会话挂载项目 .mcp.json",
|
|
94
90
|
featureGitbashDescription: "Windows 上的 Git Bash shell",
|
|
95
91
|
featureSuperpowersDescription: "superpowers 技能常驻引导(任何回复前先检查并加载技能)",
|
|
@@ -143,8 +139,6 @@ window.__ModuleLoader__.load({
|
|
|
143
139
|
reasonManagementRequired: "DSH manages this plugin itself, so it cannot be switched from this page.",
|
|
144
140
|
reasonUnaddressable: "This plugin's row cannot be addressed in the profile; edit cordis.patch.yml by hand.",
|
|
145
141
|
reasonUnknown: "This plugin cannot be switched from this page ({code}).",
|
|
146
|
-
featureColgrepDescription: "semantic code search tool",
|
|
147
|
-
featureCodegraphDescription: "CodeGraph MCP tools",
|
|
148
142
|
featureProjectMcpDescription: "mounts the project's .mcp.json per session",
|
|
149
143
|
featureGitbashDescription: "Git Bash shell on Windows",
|
|
150
144
|
featureSuperpowersDescription: "always-on superpowers skill mandate",
|
|
@@ -676,6 +670,9 @@ window.__ModuleLoader__.load({
|
|
|
676
670
|
? { id: String(event.data.commandId), role: "start" }
|
|
677
671
|
: null,
|
|
678
672
|
start: (_context, match) => ({ seq: match.event.seq, commandId: match.event.data.commandId }),
|
|
673
|
+
// The contract requires update; each run's commandId is its own context, so later
|
|
674
|
+
// matches never arrive — keep the state unchanged if the harness ever sends one.
|
|
675
|
+
update: (context) => context.state,
|
|
679
676
|
buildViewNode: (context) => ({
|
|
680
677
|
key: context.key,
|
|
681
678
|
kind: MCP_NODE_KIND,
|
|
@@ -801,4 +798,4 @@ window.__ModuleLoader__.load({
|
|
|
801
798
|
exports.inject = inject;
|
|
802
799
|
return module.exports;
|
|
803
800
|
},
|
|
804
|
-
});
|
|
801
|
+
});
|
package/lib/project-mcp/index.js
CHANGED
|
@@ -56,7 +56,7 @@ function switchesOf(state, cwd) {
|
|
|
56
56
|
|
|
57
57
|
/** The public tool names a scope sees, or the global view when no scope is given. */
|
|
58
58
|
function toolNamesOf(ctx, scope) {
|
|
59
|
-
return ctx.tools.
|
|
59
|
+
return ctx.tools.getAll(scope).map((tool) => tool.name);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -565,4 +565,4 @@ export function apply(ctx) {
|
|
|
565
565
|
// A reload mid-session must reach agents that are already live.
|
|
566
566
|
for (const agent of ctx.agents.list()) void wire(agent);
|
|
567
567
|
registerStatusCommand(ctx);
|
|
568
|
-
}
|
|
568
|
+
}
|
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "dsh-hiss-plugins",
|
|
4
|
-
"description": "One DeepSeek Harness bundle carrying
|
|
4
|
+
"description": "One DeepSeek Harness bundle carrying six switchable plugins — project-mcp, git-bash, superpowers, ponytail, init and fix — managed from a tab in the Plugins page."
|
|
5
5
|
},
|
|
6
6
|
"loading": "Reading plugins…",
|
|
7
7
|
"error": "Plugins are unavailable: {error}",
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
"reasonManagementRequired": "DSH manages this plugin itself, so it cannot be switched from this page.",
|
|
16
16
|
"reasonUnaddressable": "This plugin's row cannot be addressed in the profile; edit cordis.patch.yml by hand.",
|
|
17
17
|
"reasonUnknown": "This plugin cannot be switched from this page ({code}).",
|
|
18
|
-
|
|
19
|
-
"featureCodegraphDescription": "CodeGraph MCP tools",
|
|
20
|
-
"featureProjectMcpDescription": "mounts the project's .mcp.json per session",
|
|
18
|
+
"featureProjectMcpDescription": "mounts the project's .mcp.json per session",
|
|
21
19
|
"featureGitbashDescription": "Git Bash shell on Windows",
|
|
22
20
|
"featureSuperpowersDescription": "always-on superpowers skill mandate",
|
|
23
21
|
"featurePonytailDescription": "ponytail adoption hint and /ponytail level switching",
|
|
@@ -55,4 +53,4 @@
|
|
|
55
53
|
"mcpCollapse": "Collapse",
|
|
56
54
|
"mcpExpandAria": "Expand the tools of {name}",
|
|
57
55
|
"mcpCollapseAria": "Collapse the tools of {name}"
|
|
58
|
-
}
|
|
56
|
+
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "dsh-hiss-plugins",
|
|
4
|
-
"description": "一个 DeepSeek Harness 组合包,携带
|
|
4
|
+
"description": "一个 DeepSeek Harness 组合包,携带 project-mcp、git-bash、superpowers、ponytail、init、fix 六个可独立开关的插件,并在插件页提供管理标签。"
|
|
5
5
|
},
|
|
6
6
|
"loading": "正在读取插件…",
|
|
7
7
|
"error": "暂时无法读取插件:{error}",
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
"reasonManagementRequired": "该插件由 DSH 自身管理,无法在这个页面切换。",
|
|
16
16
|
"reasonUnaddressable": "无法在 profile 中定位该插件的行,请手动修改 cordis.patch.yml。",
|
|
17
17
|
"reasonUnknown": "该插件无法在这个页面切换({code})。",
|
|
18
|
-
|
|
19
|
-
"featureCodegraphDescription": "代码图 MCP 工具",
|
|
20
|
-
"featureProjectMcpDescription": "按会话挂载项目 .mcp.json",
|
|
18
|
+
"featureProjectMcpDescription": "按会话挂载项目 .mcp.json",
|
|
21
19
|
"featureGitbashDescription": "Windows 上的 Git Bash shell",
|
|
22
20
|
"featureSuperpowersDescription": "superpowers 技能常驻引导(任何回复前先检查并加载技能)",
|
|
23
21
|
"featurePonytailDescription": "ponytail 采纳提示与 /ponytail 等级切换",
|
|
@@ -55,4 +53,4 @@
|
|
|
55
53
|
"mcpCollapse": "收起",
|
|
56
54
|
"mcpExpandAria": "展开 {name} 的工具",
|
|
57
55
|
"mcpCollapseAria": "收起 {name} 的工具"
|
|
58
|
-
}
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hiss-plugins",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "dsh-hiss-plugins — one DeepSeek Harness bundle carrying
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "dsh-hiss-plugins — one DeepSeek Harness bundle carrying six independently switchable plugins (project-mcp, git-bash, superpowers, ponytail, init, fix) plus a management tab in the Plugins page.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
7
7
|
"deepseek-harness",
|
|
8
8
|
"dsh-plugin",
|
|
9
|
-
"colgrep",
|
|
10
|
-
"codegraph",
|
|
11
9
|
"mcp",
|
|
12
10
|
"git-bash",
|
|
13
|
-
"semantic-search",
|
|
14
11
|
"superpowers",
|
|
15
12
|
"ponytail",
|
|
16
13
|
"agents-md",
|
|
@@ -34,8 +31,6 @@
|
|
|
34
31
|
"main": "./lib/index.js",
|
|
35
32
|
"exports": {
|
|
36
33
|
".": "./lib/index.js",
|
|
37
|
-
"./colgrep": "./lib/colgrep/index.js",
|
|
38
|
-
"./codegraph": "./lib/codegraph/index.js",
|
|
39
34
|
"./project-mcp": "./lib/project-mcp/index.js",
|
|
40
35
|
"./gitbash": "./lib/gitbash/index.js",
|
|
41
36
|
"./superpowers": "./lib/superpowers/index.js",
|
|
@@ -54,20 +49,18 @@
|
|
|
54
49
|
"LICENSE"
|
|
55
50
|
],
|
|
56
51
|
"peerDependencies": {
|
|
57
|
-
"@deepseek-ai/dsh-bash-sandbox": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-llm": "^0.2.
|
|
59
|
-
"@deepseek-ai/dsh-mcp-client": "^0.2.
|
|
60
|
-
"@deepseek-ai/dsh-skill": "^0.2.
|
|
61
|
-
"@deepseek-ai/dsh-tool-bash": "^0.2.
|
|
62
|
-
"@deepseek-ai/dsh-tools": "^0.2.1-alpha.4"
|
|
52
|
+
"@deepseek-ai/dsh-bash-sandbox": "^0.2.3-alpha.3",
|
|
53
|
+
"@deepseek-ai/dsh-llm": "^0.2.3-alpha.3",
|
|
54
|
+
"@deepseek-ai/dsh-mcp-client": "^0.2.3-alpha.3",
|
|
55
|
+
"@deepseek-ai/dsh-skill": "^0.2.3-alpha.3",
|
|
56
|
+
"@deepseek-ai/dsh-tool-bash": "^0.2.3-alpha.3"
|
|
63
57
|
},
|
|
64
58
|
"devDependencies": {
|
|
65
|
-
"@deepseek-ai/dsh-bash-sandbox": "0.2.
|
|
66
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
67
|
-
"@deepseek-ai/dsh-mcp-client": "0.2.
|
|
68
|
-
"@deepseek-ai/dsh-skill": "0.2.
|
|
69
|
-
"@deepseek-ai/dsh-tool-bash": "0.2.
|
|
70
|
-
"@deepseek-ai/dsh-tools": "0.2.1-alpha.4"
|
|
59
|
+
"@deepseek-ai/dsh-bash-sandbox": "0.2.3-alpha.3",
|
|
60
|
+
"@deepseek-ai/dsh-llm": "0.2.3-alpha.3",
|
|
61
|
+
"@deepseek-ai/dsh-mcp-client": "0.2.3-alpha.3",
|
|
62
|
+
"@deepseek-ai/dsh-skill": "0.2.3-alpha.3",
|
|
63
|
+
"@deepseek-ai/dsh-tool-bash": "0.2.3-alpha.3"
|
|
71
64
|
},
|
|
72
65
|
"dsh": {
|
|
73
66
|
"bundle": {
|
package/lib/codegraph/index.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { apply as mcpClientApply, inject as mcpClientInject } from "@deepseek-ai/dsh-mcp-client";
|
|
4
|
-
|
|
5
|
-
export const name = "codegraph";
|
|
6
|
-
export const inject = ["systemPrompt"];
|
|
7
|
-
|
|
8
|
-
const GUIDANCE = [
|
|
9
|
-
"CodeGraph (semantic code intelligence) is available through the `mcp__codegraph__codegraph_explore` tool. ",
|
|
10
|
-
"For structural questions about the codebase — how a component works, how X reaches Y, the blast radius of a change — ",
|
|
11
|
-
"call `mcp__codegraph__codegraph_explore` directly instead of grepping or reading files one by one; ",
|
|
12
|
-
"it returns the relevant symbols' source, call paths, and impact in one call. ",
|
|
13
|
-
"Always pass `projectPath` as the workspace directory you are working in (or a subdirectory that has a `.codegraph/` index). ",
|
|
14
|
-
"If the tool reports no index, tell the user to run `codegraph init` in that project first. ",
|
|
15
|
-
"If the `mcp__codegraph__*` tool is not listed, the codegraph CLI is not installed or failed to start — check the DSH host logs.",
|
|
16
|
-
].join("");
|
|
17
|
-
|
|
18
|
-
// This workspace has no index. The MCP server exposes only `codegraph_explore`,
|
|
19
|
-
// so nothing can build the index but the agent itself.
|
|
20
|
-
const MISSING_INDEX = " This workspace has no index yet — run `codegraph init -y` here once before exploring, then retry.";
|
|
21
|
-
|
|
22
|
-
export function guidanceFor(cwd) {
|
|
23
|
-
const hint = cwd && !existsSync(join(cwd, ".codegraph")) ? MISSING_INDEX : "";
|
|
24
|
-
return `${GUIDANCE} Current workspace: ${cwd}; pass it as \`projectPath\`.${hint}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Stdio config for the CodeGraph MCP server. `command` resolves `codegraph`
|
|
29
|
-
* from the DSH host process's PATH (installed globally), and `cwd` is only the
|
|
30
|
-
* server's default project — the model always passes `projectPath` to target
|
|
31
|
-
* the actual workspace.
|
|
32
|
-
*
|
|
33
|
-
* @param {string} [cwd] default project directory for the spawned server.
|
|
34
|
-
* @returns {import("@deepseek-ai/dsh-mcp-client").StdioConfig}
|
|
35
|
-
*/
|
|
36
|
-
export function codegraphConfig(cwd = process.cwd()) {
|
|
37
|
-
return {
|
|
38
|
-
transport: "stdio",
|
|
39
|
-
serverName: "codegraph",
|
|
40
|
-
command: "codegraph",
|
|
41
|
-
args: ["serve", "--mcp"],
|
|
42
|
-
env: {},
|
|
43
|
-
cwd,
|
|
44
|
-
toolCallTimeoutMs: 120000,
|
|
45
|
-
failOnStartupError: false,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* DSH plugin entry point. Loads the DSH MCP client bridge for the CodeGraph
|
|
51
|
-
* server (registering `mcp__codegraph__*` tools globally) and injects usage
|
|
52
|
-
* guidance whose text carries the current session's workspace path, so agents
|
|
53
|
-
* prefer it and pass the right `projectPath`.
|
|
54
|
-
*/
|
|
55
|
-
export function apply(ctx) {
|
|
56
|
-
ctx.plugin({ inject: mcpClientInject, apply: mcpClientApply }, codegraphConfig());
|
|
57
|
-
ctx.systemPrompt.section({
|
|
58
|
-
name: "codegraph:guidance",
|
|
59
|
-
order: 100,
|
|
60
|
-
text: (context) => guidanceFor(context.scope?.session?.header?.cwd ?? process.cwd()),
|
|
61
|
-
});
|
|
62
|
-
}
|
package/lib/colgrep/index.js
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
|
-
|
|
4
|
-
export const name = "colgrep";
|
|
5
|
-
export const inject = ["tools", "shell", "sandboxPolicy", "systemPrompt"];
|
|
6
|
-
|
|
7
|
-
const LONG_PATH_PREFIX = String.fromCharCode(92, 92, 63, 92); // "\\?\"
|
|
8
|
-
|
|
9
|
-
const TOOL_DESCRIPTION = `Semantic code search over the workspace using the local colgrep CLI (ColBERT multi-vector search). Finds code by meaning, not exact text. Use a natural-language \`query\` such as "error handling for database connections". Defaults to \`search\`; search auto-indexes, so the first run in a project builds the index and is slower. Use \`command:"status"\` to inspect the index, \`command:"init"\` to (re)build it explicitly, and \`no_update:true\` for a fast search over an existing index. Pass \`root\` to search a project other than the workspace, and \`path\` to narrow the search within it. Use \`pattern\` to pre-filter by regex, \`include\` to limit file types (e.g. "*.rs"), and \`code_only\` to skip text/config files. Use \`agent:true\` for open-ended "where is X handled?" questions: colgrep's local sub-agent explores the repository and returns code locations (slower; requires the agent model).`;
|
|
10
|
-
|
|
11
|
-
const GUIDANCE = [
|
|
12
|
-
"Semantic code search is available through the `colgrep` tool. ",
|
|
13
|
-
"Reach for it when you want code by meaning and cannot name the exact identifier — grep is for text you can already spell out. ",
|
|
14
|
-
"It auto-indexes on demand, so the first search in a project is slower; use `pattern` for a regex pre-filter that ranks semantically after. ",
|
|
15
|
-
"For open-ended \"where is X handled?\" questions, pass `agent:true` to run colgrep's local sub-agent search; it returns code locations and is slower than a normal search. ",
|
|
16
|
-
"Pass `root` to search a project other than the workspace. ",
|
|
17
|
-
].join("");
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Usage guidance carrying the current workspace, so the agent passes the right
|
|
21
|
-
* default root.
|
|
22
|
-
*
|
|
23
|
-
* @param {string} cwd the session workspace path.
|
|
24
|
-
* @returns {string} prompt text for the colgrep guidance section.
|
|
25
|
-
*/
|
|
26
|
-
export function guidanceFor(cwd) {
|
|
27
|
-
return `${GUIDANCE} Current workspace: ${cwd}; the default root.`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function stripPathPrefix(path) {
|
|
31
|
-
const value = String(path);
|
|
32
|
-
return value.startsWith(LONG_PATH_PREFIX) ? value.slice(4) : value;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function quoteArg(value) {
|
|
36
|
-
return "'" + String(value).replace(/'/g, "''") + "'";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function buildArgs(args) {
|
|
40
|
-
const command = args.command || "search";
|
|
41
|
-
const argv = ["colgrep"];
|
|
42
|
-
if (command === "search") {
|
|
43
|
-
if (typeof args.query !== "string" || args.query.trim() === "") {
|
|
44
|
-
throw new Error("query must be a non-empty string");
|
|
45
|
-
}
|
|
46
|
-
if (args.agent) argv.push("--agent", "--json");
|
|
47
|
-
else argv.push("--json");
|
|
48
|
-
argv.push("--color", "never", "-y");
|
|
49
|
-
if (args.no_update) argv.push("--no-update");
|
|
50
|
-
argv.push("-k", String(args.top_k ? Number(args.top_k) : 15));
|
|
51
|
-
if (args.pattern) argv.push("-e", args.pattern);
|
|
52
|
-
if (args.include) argv.push("--include", args.include);
|
|
53
|
-
if (args.code_only) argv.push("--code-only");
|
|
54
|
-
argv.push(String(args.query || ""));
|
|
55
|
-
if (args.root) argv.push(String(args.root));
|
|
56
|
-
if (args.path) argv.push(args.path);
|
|
57
|
-
} else if (command === "init") {
|
|
58
|
-
argv.push("init", "-y");
|
|
59
|
-
if (args.root) argv.push(String(args.root));
|
|
60
|
-
if (args.path) argv.push(args.path);
|
|
61
|
-
} else if (command === "status") {
|
|
62
|
-
argv.push("status");
|
|
63
|
-
} else if (command === "clear") {
|
|
64
|
-
argv.push("clear");
|
|
65
|
-
} else {
|
|
66
|
-
throw new Error("command must be one of: search, init, status, clear");
|
|
67
|
-
}
|
|
68
|
-
return argv;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function normalizeResults(parsed) {
|
|
72
|
-
return parsed.map((item) => {
|
|
73
|
-
const unit = item && item.unit ? item.unit : {};
|
|
74
|
-
return {
|
|
75
|
-
file: stripPathPrefix(unit.file),
|
|
76
|
-
name: unit.name || "",
|
|
77
|
-
qualified_name: unit.qualified_name || "",
|
|
78
|
-
line: unit.line,
|
|
79
|
-
end_line: unit.end_line,
|
|
80
|
-
language: unit.language || "",
|
|
81
|
-
unit_type: unit.unit_type || "",
|
|
82
|
-
signature: unit.signature || "",
|
|
83
|
-
score: item ? item.score : null,
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function renderOutput(value) {
|
|
89
|
-
if (!value || typeof value !== "object") return String(value);
|
|
90
|
-
const lines = [];
|
|
91
|
-
if (value.command === "search" && value.agent) {
|
|
92
|
-
if (Array.isArray(value.locations)) {
|
|
93
|
-
const label = value.submitted === false ? "inspected location(s)" : "location(s)";
|
|
94
|
-
lines.push(`colgrep (agent): ${value.locations.length} ${label} for ${JSON.stringify(value.query)}`);
|
|
95
|
-
if (value.submitted === false) lines.push("(the agent did not submit a final answer; showing the locations it inspected)");
|
|
96
|
-
if (value.locations.length > 0) {
|
|
97
|
-
lines.push("");
|
|
98
|
-
for (const location of value.locations) {
|
|
99
|
-
const start = location.line === undefined ? "?" : location.line;
|
|
100
|
-
const end = location.end_line === undefined ? "?" : location.end_line;
|
|
101
|
-
lines.push(`${location.file}:${start}-${end}`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (value.error) lines.push(`[agent error] ${value.error}`);
|
|
105
|
-
} else {
|
|
106
|
-
lines.push("colgrep agent search failed");
|
|
107
|
-
if (value.error) lines.push(`[agent error] ${value.error}`);
|
|
108
|
-
if (value.stderr) lines.push(`[stderr]\n${value.stderr}`);
|
|
109
|
-
else if (value.stdout) lines.push(`[stdout]\n${value.stdout}`);
|
|
110
|
-
}
|
|
111
|
-
} else if (value.command === "search" && Array.isArray(value.results)) {
|
|
112
|
-
lines.push(`colgrep: ${value.results.length} result(s) for ${JSON.stringify(value.query)}`);
|
|
113
|
-
value.results.forEach((result, index) => {
|
|
114
|
-
const file = result.file || result.qualified_name || "?";
|
|
115
|
-
const location = typeof result.line === "number" && typeof result.end_line === "number"
|
|
116
|
-
? `:${result.line}-${result.end_line}`
|
|
117
|
-
: "";
|
|
118
|
-
const meta = [result.language, result.unit_type, result.name].filter(Boolean).join(", ");
|
|
119
|
-
const score = typeof result.score === "number" ? `score ${result.score.toFixed(2)}` : "";
|
|
120
|
-
lines.push("");
|
|
121
|
-
lines.push(`${index + 1}. ${file}${location}${meta ? ` [${meta}]` : ""}${score ? ` (${score})` : ""}`);
|
|
122
|
-
if (result.signature) {
|
|
123
|
-
lines.push(` ${String(result.signature).split("\n")[0].slice(0, 200)}`);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
} else if (value.command === "search") {
|
|
127
|
-
lines.push(value.ok ? "colgrep search returned unparseable output (ok=true)" : "colgrep search failed (ok=false)");
|
|
128
|
-
if (value.stderr) lines.push(`[stderr]\n${value.stderr}`);
|
|
129
|
-
else if (value.stdout) lines.push(`[stdout]\n${value.stdout}`);
|
|
130
|
-
} else {
|
|
131
|
-
lines.push(`colgrep ${value.command} (exit ${value.exitCode})`);
|
|
132
|
-
if (value.stdout) lines.push(value.stdout);
|
|
133
|
-
if (!value.ok && value.stderr) lines.push(`[stderr]\n${value.stderr}`);
|
|
134
|
-
}
|
|
135
|
-
if (value.timedOut) lines.push("[timed out]");
|
|
136
|
-
if (value.aborted) lines.push("[aborted]");
|
|
137
|
-
return lines.join("\n");
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function apply(ctx) {
|
|
141
|
-
ctx.systemPrompt.section({
|
|
142
|
-
name: "colgrep:guidance",
|
|
143
|
-
order: 100,
|
|
144
|
-
text: (context) => guidanceFor(context.scope?.session?.header?.cwd ?? process.cwd()),
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
ctx.tools.register(defineTool({
|
|
148
|
-
name: "colgrep",
|
|
149
|
-
description: TOOL_DESCRIPTION,
|
|
150
|
-
parameters: {
|
|
151
|
-
query: { type: "string", description: "Natural-language query (used by search).", required: true },
|
|
152
|
-
command: { type: "string", enum: ["search", "init", "status", "clear"], description: "Operation. search (default) finds code; init builds/updates the index; status reports index state; clear removes the index." },
|
|
153
|
-
root: { type: "string", description: "Project directory to search or index (default: the workspace root). Absolute or relative to the workspace." },
|
|
154
|
-
path: { type: "string", description: "File or directory of `root` to search (default: the whole root). colgrep searches this target and falls back to the project index, so it is a focus, not a hard filter — narrow with `include` or `pattern` instead." },
|
|
155
|
-
top_k: { type: "integer", description: "Number of results to return (-k). Default 15." },
|
|
156
|
-
pattern: { type: "string", description: "Regex pre-filter (-e): grep first, then rank semantically (hybrid)." },
|
|
157
|
-
include: { type: "string", description: "Only search files matching this glob (--include), e.g. \"*.rs\"." },
|
|
158
|
-
code_only: { type: "boolean", description: "Only search code files; skip text/config files such as md/txt/yaml/json (--code-only)." },
|
|
159
|
-
no_update: { type: "boolean", description: "Skip automatic index update and search the existing index as-is (--no-update)." },
|
|
160
|
-
agent: { type: "boolean", description: "Run colgrep's local sub-agent search (--agent --json); returns file:start-end locations. Requires colgrep >= 1.8.5 and the agent model (colgrep --install-agent)." },
|
|
161
|
-
},
|
|
162
|
-
output: {
|
|
163
|
-
schema: { type: "json" },
|
|
164
|
-
render(_args, value) {
|
|
165
|
-
return [{ type: "text", text: renderOutput(value) }];
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
async execute(args, exec) {
|
|
169
|
-
const policy = ctx.sandboxPolicy.resolve({ session: exec.agent && exec.agent.session });
|
|
170
|
-
const root = policy && typeof policy.workspaceRoot === "string" ? policy.workspaceRoot : "";
|
|
171
|
-
const base = root.replace(/[\\/]+$/, "");
|
|
172
|
-
const dataDir = base + "/.colgrep-data";
|
|
173
|
-
// `root` moves the run, never the index: index data stays inside the
|
|
174
|
-
// workspace so it remains under the sandbox policy and the same
|
|
175
|
-
// registry serves every root.
|
|
176
|
-
const workdir = args.root && base ? resolve(base, args.root) : base;
|
|
177
|
-
const command = buildArgs(args).map((part, index) => (index === 0 ? part : quoteArg(part))).join(" ");
|
|
178
|
-
const spec = ctx.shell.resolve({
|
|
179
|
-
command,
|
|
180
|
-
timeoutMs: args.agent ? 600000 : 300000,
|
|
181
|
-
stdoutMaxBytes: 2 * 1024 * 1024,
|
|
182
|
-
signal: exec.signal,
|
|
183
|
-
sandboxPolicy: policy,
|
|
184
|
-
...(workdir ? { workdir, env: { COLGREP_DATA_DIR: dataDir } } : {}),
|
|
185
|
-
});
|
|
186
|
-
// The shell seam is `execute()` → handle → `result()` since 0.1.7; the
|
|
187
|
-
// older `run()` that settled the outcome directly no longer exists.
|
|
188
|
-
const run = await (await ctx.shell.execute(spec)).result();
|
|
189
|
-
const stdout = run.stdout && run.stdout.text ? run.stdout.text : "";
|
|
190
|
-
const stderr = run.stderr && run.stderr.text ? run.stderr.text : "";
|
|
191
|
-
const commandName = args.command || "search";
|
|
192
|
-
const common = {
|
|
193
|
-
ok: run.exitCode === 0,
|
|
194
|
-
command: commandName,
|
|
195
|
-
exitCode: run.exitCode,
|
|
196
|
-
...(run.timedOut ? { timedOut: true } : {}),
|
|
197
|
-
...(run.aborted ? { aborted: true } : {}),
|
|
198
|
-
};
|
|
199
|
-
if (commandName !== "search") {
|
|
200
|
-
return { ...common, stdout, stderr };
|
|
201
|
-
}
|
|
202
|
-
if (args.agent) {
|
|
203
|
-
let parsed = null;
|
|
204
|
-
try {
|
|
205
|
-
parsed = JSON.parse(stdout);
|
|
206
|
-
} catch {
|
|
207
|
-
parsed = null;
|
|
208
|
-
}
|
|
209
|
-
if (parsed !== null && Array.isArray(parsed.locations)) {
|
|
210
|
-
const locations = parsed.locations.map((entry) => ({
|
|
211
|
-
file: stripPathPrefix(entry.file),
|
|
212
|
-
line: entry.start_line,
|
|
213
|
-
end_line: entry.end_line,
|
|
214
|
-
}));
|
|
215
|
-
const agentError = typeof parsed.error === "string" && parsed.error !== "" ? parsed.error : undefined;
|
|
216
|
-
return {
|
|
217
|
-
...common,
|
|
218
|
-
ok: common.ok && agentError === undefined,
|
|
219
|
-
query: args.query,
|
|
220
|
-
agent: true,
|
|
221
|
-
submitted: parsed.submitted !== false,
|
|
222
|
-
count: locations.length,
|
|
223
|
-
locations,
|
|
224
|
-
...(agentError === undefined ? {} : { error: agentError, stderr }),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
return { ...common, query: args.query, agent: true, locations: null, stdout, stderr };
|
|
228
|
-
}
|
|
229
|
-
let parsed = null;
|
|
230
|
-
try {
|
|
231
|
-
parsed = JSON.parse(stdout);
|
|
232
|
-
} catch {
|
|
233
|
-
parsed = null;
|
|
234
|
-
}
|
|
235
|
-
let results = null;
|
|
236
|
-
if (Array.isArray(parsed)) {
|
|
237
|
-
results = normalizeResults(parsed);
|
|
238
|
-
} else if (parsed && typeof parsed === "object" && Array.isArray(parsed.results)) {
|
|
239
|
-
results = normalizeResults(parsed.results);
|
|
240
|
-
}
|
|
241
|
-
if (results === null) {
|
|
242
|
-
return { ...common, query: args.query, results: null, stdout, stderr };
|
|
243
|
-
}
|
|
244
|
-
return { ...common, query: args.query, count: results.length, results };
|
|
245
|
-
},
|
|
246
|
-
}));
|
|
247
|
-
}
|