dsh-hiss-plugins 1.3.0 → 1.3.1
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 +5 -2
- package/lib/colgrep/index.js +55 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,10 +102,12 @@ colgrep command:"init" / command:"status" / command:"clear"
|
|
|
102
102
|
| `include` | string | 只检索匹配 glob 的文件(`--include`,如 `"*.rs"`) |
|
|
103
103
|
| `code_only` | boolean | 只检索代码文件,跳过 md/txt/yaml/json 等 |
|
|
104
104
|
| `no_update` | boolean | 跳过自动重建索引,直接检索现有索引 |
|
|
105
|
+
| `agent` | boolean | 使用 colgrep 本地 sub-agent 搜索(`--agent --json`),返回 `file:start-end` 位置;需要 colgrep ≥1.8.5 与 agent 模型 |
|
|
105
106
|
|
|
106
107
|
行为要点:
|
|
107
108
|
|
|
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 下使用。
|
|
109
111
|
- **索引留在工作区内**:DSH 文件沙箱禁止写工作区之外,而 colgrep 检索需要写索引锁文件。插件把索引目录重定位到 `<工作区>/.colgrep-data`(通过 `COLGREP_DATA_DIR`),使全部写入落在沙箱允许范围内。ColBERT 模型与 ONNX runtime 从 `~/.cache` 只读加载,无需联网。
|
|
110
112
|
- **显式根目录**:`root` 只改变检索**运行的位置**(`workdir`),不改变索引位置 —— 索引数据始终留在当前工作区的 `.colgrep-data`,因为 colgrep 的索引是**按项目注册的**(`<data_dir>/indices/<项目名>-<hash>`),一个数据目录可以同时容纳多个项目的索引,跨项目检索不会把数据写到别人的仓库里。**真正限制结果范围的是 `root`**(换项目);`path` 相对 `root` 解析(无 `root` 时相对工作区),只做聚焦、不保证排他。
|
|
111
113
|
- 首次检索会自动建立索引(CPU 上大仓库可能需数分钟);可用 `command:"init"` 显式建索引,`no_update:true` 走现有索引。
|
|
@@ -114,6 +116,7 @@ colgrep command:"init" / command:"status" / command:"clear"
|
|
|
114
116
|
前置要求:
|
|
115
117
|
|
|
116
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` 调用时下载)。
|
|
117
120
|
- 首次使用前,colgrep 需已下载默认模型 `lightonai/LateOn-Code-edge`(`colgrep "任意查询"` 会自动下载;私有模型需 `HF_TOKEN`,可用 `colgrep set-model` 切换)。
|
|
118
121
|
|
|
119
122
|
验证:重启后让模型调用 `colgrep`(例如“用 colgrep 搜索 error handling 相关代码”),或执行 `colgrep command:"status"` 看当前工作区的索引状态。
|
|
@@ -375,8 +378,8 @@ test/ node:test:<feature>/ 八个目录 + manifest / patch / c
|
|
|
375
378
|
## 发布(给维护者)
|
|
376
379
|
|
|
377
380
|
```powershell
|
|
378
|
-
git tag dsh-hiss-plugins@1.3.
|
|
379
|
-
git push origin dsh-hiss-plugins@1.3.
|
|
381
|
+
git tag dsh-hiss-plugins@1.3.1 # 必须与本目录 package.json 的 version 逐字一致
|
|
382
|
+
git push origin dsh-hiss-plugins@1.3.1
|
|
380
383
|
```
|
|
381
384
|
|
|
382
385
|
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`。
|
package/lib/colgrep/index.js
CHANGED
|
@@ -6,12 +6,13 @@ export const inject = ["tools", "shell", "sandboxPolicy", "systemPrompt"];
|
|
|
6
6
|
|
|
7
7
|
const LONG_PATH_PREFIX = String.fromCharCode(92, 92, 63, 92); // "\\?\"
|
|
8
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.`;
|
|
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
10
|
|
|
11
11
|
const GUIDANCE = [
|
|
12
12
|
"Semantic code search is available through the `colgrep` tool. ",
|
|
13
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
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. ",
|
|
15
16
|
"Pass `root` to search a project other than the workspace. ",
|
|
16
17
|
].join("");
|
|
17
18
|
|
|
@@ -42,7 +43,9 @@ export function buildArgs(args) {
|
|
|
42
43
|
if (typeof args.query !== "string" || args.query.trim() === "") {
|
|
43
44
|
throw new Error("query must be a non-empty string");
|
|
44
45
|
}
|
|
45
|
-
argv.push("--
|
|
46
|
+
if (args.agent) argv.push("--agent", "--json");
|
|
47
|
+
else argv.push("--json");
|
|
48
|
+
argv.push("--color", "never", "-y");
|
|
46
49
|
if (args.no_update) argv.push("--no-update");
|
|
47
50
|
argv.push("-k", String(args.top_k ? Number(args.top_k) : 15));
|
|
48
51
|
if (args.pattern) argv.push("-e", args.pattern);
|
|
@@ -85,7 +88,27 @@ export function normalizeResults(parsed) {
|
|
|
85
88
|
export function renderOutput(value) {
|
|
86
89
|
if (!value || typeof value !== "object") return String(value);
|
|
87
90
|
const lines = [];
|
|
88
|
-
if (value.command === "search" &&
|
|
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)) {
|
|
89
112
|
lines.push(`colgrep: ${value.results.length} result(s) for ${JSON.stringify(value.query)}`);
|
|
90
113
|
value.results.forEach((result, index) => {
|
|
91
114
|
const file = result.file || result.qualified_name || "?";
|
|
@@ -134,6 +157,7 @@ export function apply(ctx) {
|
|
|
134
157
|
include: { type: "string", description: "Only search files matching this glob (--include), e.g. \"*.rs\"." },
|
|
135
158
|
code_only: { type: "boolean", description: "Only search code files; skip text/config files such as md/txt/yaml/json (--code-only)." },
|
|
136
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)." },
|
|
137
161
|
},
|
|
138
162
|
output: {
|
|
139
163
|
schema: { type: "json" },
|
|
@@ -153,7 +177,7 @@ export function apply(ctx) {
|
|
|
153
177
|
const command = buildArgs(args).map((part, index) => (index === 0 ? part : quoteArg(part))).join(" ");
|
|
154
178
|
const spec = ctx.shell.resolve({
|
|
155
179
|
command,
|
|
156
|
-
timeoutMs: 300000,
|
|
180
|
+
timeoutMs: args.agent ? 600000 : 300000,
|
|
157
181
|
stdoutMaxBytes: 2 * 1024 * 1024,
|
|
158
182
|
signal: exec.signal,
|
|
159
183
|
sandboxPolicy: policy,
|
|
@@ -175,6 +199,33 @@ export function apply(ctx) {
|
|
|
175
199
|
if (commandName !== "search") {
|
|
176
200
|
return { ...common, stdout, stderr };
|
|
177
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
|
+
}
|
|
178
229
|
let parsed = null;
|
|
179
230
|
try {
|
|
180
231
|
parsed = JSON.parse(stdout);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hiss-plugins",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "dsh-hiss-plugins — one DeepSeek Harness bundle carrying eight independently switchable plugins (colgrep, codegraph, project-mcp, git-bash, superpowers, ponytail, init, fix) plus a management tab in the Plugins page.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|