@jayyuen66/dsh-zvec-grep 0.1.14 → 0.1.16
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/CHANGELOG.md +23 -0
- package/README.md +26 -25
- package/README.zh-CN.md +4 -4
- package/client.js +195 -159
- package/host.js +227 -163
- package/package.json +45 -44
package/host.js
CHANGED
|
@@ -5,7 +5,7 @@ import { accessSync, constants, existsSync, readFileSync, statSync } from "node:
|
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
6
6
|
import nodePath from "node:path";
|
|
7
7
|
import { scopeOf } from "@deepseek-ai/dsh-scope";
|
|
8
|
-
import { isRecord } from "@jayyuen66/dsh-plugin-shared/lib/record";
|
|
8
|
+
import { isRecord as isRecord$1 } from "@jayyuen66/dsh-plugin-shared/lib/record";
|
|
9
9
|
import { errorText } from "@jayyuen66/dsh-plugin-shared/lib/errors";
|
|
10
10
|
import { LOCALE_SETTINGS_NAMESPACE, messagesFor, resolveLocalePreference } from "@jayyuen66/dsh-plugin-shared/lib/locale";
|
|
11
11
|
import { truncateEnd, truncateStart } from "@jayyuen66/dsh-plugin-shared/lib/text";
|
|
@@ -1995,7 +1995,7 @@ function zgToolProblem(name, args, execution, messages, platform) {
|
|
|
1995
1995
|
*/
|
|
1996
1996
|
function zgGuard(execution, messages, platform = "posix") {
|
|
1997
1997
|
const { name } = execution;
|
|
1998
|
-
const args = isRecord(execution.arguments) ? execution.arguments : {};
|
|
1998
|
+
const args = isRecord$1(execution.arguments) ? execution.arguments : {};
|
|
1999
1999
|
let reason;
|
|
2000
2000
|
if (isZgToolName(name)) reason = zgToolProblem(name, args, execution, messages, platform);
|
|
2001
2001
|
return reason;
|
|
@@ -2182,7 +2182,7 @@ function nativeGrepProblem(args, cwd, deps, messages) {
|
|
|
2182
2182
|
*/
|
|
2183
2183
|
function searchFirstGuard(execution, deps, messages) {
|
|
2184
2184
|
const { name } = execution;
|
|
2185
|
-
const args = isRecord(execution.arguments) ? execution.arguments : {};
|
|
2185
|
+
const args = isRecord$1(execution.arguments) ? execution.arguments : {};
|
|
2186
2186
|
const cwd = sessionHeaderCwd$1(execution);
|
|
2187
2187
|
let reason;
|
|
2188
2188
|
if (deps.enabled && cwd !== void 0 && searchAdmitted(execution)) {
|
|
@@ -2665,6 +2665,46 @@ function readClientMode(config, messages) {
|
|
|
2665
2665
|
return clientModeOf(config.clientMode, messages);
|
|
2666
2666
|
}
|
|
2667
2667
|
// lib/rebuild-remote.ts
|
|
2668
|
+
var __runInitializers = function(thisArg, initializers, value) {
|
|
2669
|
+
var useValue = arguments.length > 2;
|
|
2670
|
+
for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
2671
|
+
return useValue ? value : void 0;
|
|
2672
|
+
};
|
|
2673
|
+
var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2674
|
+
function accept(f) {
|
|
2675
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
2676
|
+
return f;
|
|
2677
|
+
}
|
|
2678
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
2679
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
2680
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
2681
|
+
var _, done = false;
|
|
2682
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2683
|
+
var context = {};
|
|
2684
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
2685
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
2686
|
+
context.addInitializer = function(f) {
|
|
2687
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
2688
|
+
extraInitializers.push(accept(f || null));
|
|
2689
|
+
};
|
|
2690
|
+
var result = (0, decorators[i])(kind === "accessor" ? {
|
|
2691
|
+
get: descriptor.get,
|
|
2692
|
+
set: descriptor.set
|
|
2693
|
+
} : descriptor[key], context);
|
|
2694
|
+
if (kind === "accessor") {
|
|
2695
|
+
if (result === void 0) continue;
|
|
2696
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
2697
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
2698
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
2699
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
2700
|
+
} else if (_ = accept(result)) {
|
|
2701
|
+
if (kind === "field") initializers.unshift(_);
|
|
2702
|
+
else descriptor[key] = _;
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
2706
|
+
done = true;
|
|
2707
|
+
};
|
|
2668
2708
|
/** 本包作业的 kind(宿主据此发出的 id 形如 `zvec-grep-rebuild-<hex>`)。 */
|
|
2669
2709
|
const REBUILD_JOB_KIND = "zvec-grep-rebuild";
|
|
2670
2710
|
/** 卡片视图的尾部长度(打标文案在 lib/messages.ts,随语言走)。 */
|
|
@@ -3096,159 +3136,183 @@ function releaseRebuildRecords(deps) {
|
|
|
3096
3136
|
* 本包也不把 `jobs` 列进 `inject` 名单:那会让缺席的整条 client 入口都不激活,而缺席只该让
|
|
3097
3137
|
* 「启动/轮询」这一档不可用。
|
|
3098
3138
|
*/
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3139
|
+
let ZvecRebuildService = (() => {
|
|
3140
|
+
let _classSuper = TypertRemoteService;
|
|
3141
|
+
let _instanceExtraInitializers = [];
|
|
3142
|
+
let _roots_decorators;
|
|
3143
|
+
let _rebuild_decorators;
|
|
3144
|
+
let _status_decorators;
|
|
3145
|
+
return class ZvecRebuildService extends _classSuper {
|
|
3146
|
+
static {
|
|
3147
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
3148
|
+
_roots_decorators = [Remote("roots")];
|
|
3149
|
+
_rebuild_decorators = [Remote("rebuild")];
|
|
3150
|
+
_status_decorators = [Remote("status")];
|
|
3151
|
+
__esDecorate(this, null, _roots_decorators, {
|
|
3152
|
+
kind: "method",
|
|
3153
|
+
name: "roots",
|
|
3154
|
+
static: false,
|
|
3155
|
+
private: false,
|
|
3156
|
+
access: {
|
|
3157
|
+
has: (obj) => "roots" in obj,
|
|
3158
|
+
get: (obj) => obj.roots
|
|
3159
|
+
},
|
|
3160
|
+
metadata: _metadata
|
|
3161
|
+
}, null, _instanceExtraInitializers);
|
|
3162
|
+
__esDecorate(this, null, _rebuild_decorators, {
|
|
3163
|
+
kind: "method",
|
|
3164
|
+
name: "rebuild",
|
|
3165
|
+
static: false,
|
|
3166
|
+
private: false,
|
|
3167
|
+
access: {
|
|
3168
|
+
has: (obj) => "rebuild" in obj,
|
|
3169
|
+
get: (obj) => obj.rebuild
|
|
3170
|
+
},
|
|
3171
|
+
metadata: _metadata
|
|
3172
|
+
}, null, _instanceExtraInitializers);
|
|
3173
|
+
__esDecorate(this, null, _status_decorators, {
|
|
3174
|
+
kind: "method",
|
|
3175
|
+
name: "status",
|
|
3176
|
+
static: false,
|
|
3177
|
+
private: false,
|
|
3178
|
+
access: {
|
|
3179
|
+
has: (obj) => "status" in obj,
|
|
3180
|
+
get: (obj) => obj.status
|
|
3181
|
+
},
|
|
3182
|
+
metadata: _metadata
|
|
3183
|
+
}, null, _instanceExtraInitializers);
|
|
3184
|
+
}
|
|
3185
|
+
constructor(ctx, deps) {
|
|
3186
|
+
super(ctx, REBUILD_REMOTE_NAMESPACE);
|
|
3187
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
3188
|
+
this.deps = deps;
|
|
3189
|
+
}
|
|
3190
|
+
/** 引导读取接口:白名单里的工作区 + 守护进程就绪态(都是本插件自己的数据)。 */
|
|
3191
|
+
async roots() {
|
|
3192
|
+
let serverReady = false;
|
|
3193
|
+
try {
|
|
3194
|
+
serverReady = await this.deps.serverGate.ready();
|
|
3195
|
+
} catch {}
|
|
3196
|
+
return {
|
|
3197
|
+
roots: this.deps.ledger.list(),
|
|
3198
|
+
serverReady
|
|
3199
|
+
};
|
|
3200
|
+
}
|
|
3201
|
+
/**
|
|
3202
|
+
* 起一条重建(或跟随同根已在跑的那条)。
|
|
3203
|
+
*
|
|
3204
|
+
* 占位是**互斥的唯一依据**,必须落在第一个 await 之前。先「查在不在跑」再占位,
|
|
3205
|
+
* 两次并发点击会同时通过那次查询、各自 spawn——两个进程在同一份索引上互相啃,
|
|
3206
|
+
* 后一条被 zg 的写锁直接顶掉并报成「启动失败」。改成「先占位、抢不到就跟随」,
|
|
3207
|
+
* 这条竞态就没有窗口了。
|
|
3208
|
+
*/
|
|
3209
|
+
async rebuild(request) {
|
|
3210
|
+
const started = this.deps.messages();
|
|
3211
|
+
const accepted = acceptableRoot(isRecord$1(request) ? request.root : void 0, this.deps.ledger, started, this.deps.platform);
|
|
3212
|
+
if ("error" in accepted) return {
|
|
3143
3213
|
ok: false,
|
|
3144
|
-
error:
|
|
3145
|
-
status:
|
|
3146
|
-
}
|
|
3214
|
+
error: accepted.error.value,
|
|
3215
|
+
status: accepted.error.status
|
|
3216
|
+
};
|
|
3217
|
+
const { root } = accepted;
|
|
3218
|
+
const jobs = this.deps.jobsOf();
|
|
3219
|
+
if (jobs === void 0) return {
|
|
3220
|
+
ok: false,
|
|
3221
|
+
error: started.endpointJobsUnavailable,
|
|
3222
|
+
status: 503
|
|
3223
|
+
};
|
|
3224
|
+
const claimed = this.deps.rebuilds.claim(root, "card");
|
|
3225
|
+
if (claimed === null) {
|
|
3226
|
+
const following = followRunningRebuild(jobs, this.deps.records, root);
|
|
3227
|
+
return following === void 0 ? {
|
|
3228
|
+
ok: false,
|
|
3229
|
+
error: started.endpointRebuildInFlight,
|
|
3230
|
+
status: 409
|
|
3231
|
+
} : {
|
|
3232
|
+
ok: true,
|
|
3233
|
+
jobId: following,
|
|
3234
|
+
reused: true
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
const embedding = readDefaultEmbedding(this.deps.config);
|
|
3238
|
+
const spawned = await spawnIndexWrite(this.deps, started, {
|
|
3239
|
+
root,
|
|
3240
|
+
embedding,
|
|
3241
|
+
rebuild: true
|
|
3242
|
+
}, embedding);
|
|
3243
|
+
if ("error" in spawned) {
|
|
3244
|
+
this.deps.rebuilds.release(root, claimed);
|
|
3245
|
+
return {
|
|
3246
|
+
ok: false,
|
|
3247
|
+
error: spawned.error,
|
|
3248
|
+
status: spawned.status
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3251
|
+
const attached = attachIndexWrite(this.deps, root, started, spawned, claimed);
|
|
3252
|
+
if ("error" in attached) {
|
|
3253
|
+
this.deps.rebuilds.release(root, claimed);
|
|
3254
|
+
return {
|
|
3255
|
+
ok: false,
|
|
3256
|
+
error: attached.error,
|
|
3257
|
+
status: attached.status
|
|
3258
|
+
};
|
|
3259
|
+
}
|
|
3260
|
+
this.deps.rebuilds.attach(root, attached.jobId, claimed);
|
|
3261
|
+
return {
|
|
3147
3262
|
ok: true,
|
|
3148
|
-
jobId:
|
|
3149
|
-
reused: true
|
|
3263
|
+
jobId: attached.jobId
|
|
3150
3264
|
};
|
|
3151
3265
|
}
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
this.deps.
|
|
3160
|
-
|
|
3266
|
+
/**
|
|
3267
|
+
* 轮询读取接口:官方状态投影 + 退出码/沙箱事实 + 打标后的输出尾窗(卡片每 2s 敲一次)。
|
|
3268
|
+
*
|
|
3269
|
+
* 侧表就是这条投影的授权边界:官方 id 是可预测的 `<kind>-<hex>`(宿主 bash 工具的
|
|
3270
|
+
* `bash-1` 同样猜得到),而它不在本包表里 ⇒ 一律拒绝,绝不代读别人的作业。
|
|
3271
|
+
*/
|
|
3272
|
+
status(request) {
|
|
3273
|
+
const marks = this.deps.messages();
|
|
3274
|
+
const raw = isRecord$1(request) ? request.jobId : void 0;
|
|
3275
|
+
const record = typeof raw === "string" && raw.length > 0 ? this.deps.records.get(raw) : void 0;
|
|
3276
|
+
if (record === void 0) return {
|
|
3161
3277
|
ok: false,
|
|
3162
|
-
error:
|
|
3163
|
-
status:
|
|
3278
|
+
error: fill(marks.unknownJobId, { maxJobs: 10 }),
|
|
3279
|
+
status: 404
|
|
3164
3280
|
};
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
if ("error" in attached) {
|
|
3168
|
-
this.deps.rebuilds.release(root, claimed);
|
|
3169
|
-
return {
|
|
3281
|
+
const jobs = this.deps.jobsOf();
|
|
3282
|
+
if (jobs === void 0) return {
|
|
3170
3283
|
ok: false,
|
|
3171
|
-
error:
|
|
3172
|
-
status:
|
|
3284
|
+
error: marks.endpointJobsUnavailable,
|
|
3285
|
+
status: 503
|
|
3286
|
+
};
|
|
3287
|
+
const output = readRebuildOutput(jobs, record.id);
|
|
3288
|
+
if (output === null) return {
|
|
3289
|
+
ok: false,
|
|
3290
|
+
error: fill(marks.unknownJobId, { maxJobs: 10 }),
|
|
3291
|
+
status: 404
|
|
3292
|
+
};
|
|
3293
|
+
if (!sameJob(record.state, output.view)) return {
|
|
3294
|
+
ok: false,
|
|
3295
|
+
error: fill(marks.unknownJobId, { maxJobs: 10 }),
|
|
3296
|
+
status: 404
|
|
3297
|
+
};
|
|
3298
|
+
const { view, retained } = output;
|
|
3299
|
+
const text = retained.chunks.map((chunk) => chunk.text).join("");
|
|
3300
|
+
const shown = truncateStart(text, JOB_OUT_VIEW_CHARS);
|
|
3301
|
+
const viewMark = text.length > JOB_OUT_VIEW_CHARS ? fill(marks.jobOutputView, {
|
|
3302
|
+
shown: JOB_OUT_VIEW_CHARS,
|
|
3303
|
+
total: text.length
|
|
3304
|
+
}) : "";
|
|
3305
|
+
return {
|
|
3306
|
+
ok: true,
|
|
3307
|
+
status: view.status,
|
|
3308
|
+
exitCode: record.proc.exitCode,
|
|
3309
|
+
root: record.root,
|
|
3310
|
+
...record.proc.sandbox === void 0 ? {} : { sandbox: record.proc.sandbox },
|
|
3311
|
+
output: (view.output.earliest > 0 ? marks.jobOutputTruncated : "") + (record.state.lost ? marks.jobOutputLost : "") + (record.state.timeoutNote ?? "") + (procSandboxNote(record.proc, marks) ?? "") + viewMark + shown
|
|
3173
3312
|
};
|
|
3174
|
-
}
|
|
3175
|
-
this.deps.rebuilds.attach(root, attached.jobId, claimed);
|
|
3176
|
-
return {
|
|
3177
|
-
ok: true,
|
|
3178
|
-
jobId: attached.jobId
|
|
3179
|
-
};
|
|
3180
|
-
}
|
|
3181
|
-
/**
|
|
3182
|
-
* 轮询读取接口:官方状态投影 + 退出码/沙箱事实 + 打标后的输出尾窗(卡片每 2s 敲一次)。
|
|
3183
|
-
*
|
|
3184
|
-
* 侧表就是这条投影的授权边界:官方 id 是可预测的 `<kind>-<hex>`(宿主 bash 工具的
|
|
3185
|
-
* `bash-1` 同样猜得到),而它不在本包表里 ⇒ 一律拒绝,绝不代读别人的作业。
|
|
3186
|
-
*/
|
|
3187
|
-
status(request) {
|
|
3188
|
-
const marks = this.deps.messages();
|
|
3189
|
-
const raw = isRecord(request) ? request.jobId : void 0;
|
|
3190
|
-
const record = typeof raw === "string" && raw.length > 0 ? this.deps.records.get(raw) : void 0;
|
|
3191
|
-
if (record === void 0) return {
|
|
3192
|
-
ok: false,
|
|
3193
|
-
error: fill(marks.unknownJobId, { maxJobs: 10 }),
|
|
3194
|
-
status: 404
|
|
3195
|
-
};
|
|
3196
|
-
const jobs = this.deps.jobsOf();
|
|
3197
|
-
if (jobs === void 0) return {
|
|
3198
|
-
ok: false,
|
|
3199
|
-
error: marks.endpointJobsUnavailable,
|
|
3200
|
-
status: 503
|
|
3201
|
-
};
|
|
3202
|
-
const output = readRebuildOutput(jobs, record.id);
|
|
3203
|
-
if (output === null) return {
|
|
3204
|
-
ok: false,
|
|
3205
|
-
error: fill(marks.unknownJobId, { maxJobs: 10 }),
|
|
3206
|
-
status: 404
|
|
3207
|
-
};
|
|
3208
|
-
if (!sameJob(record.state, output.view)) return {
|
|
3209
|
-
ok: false,
|
|
3210
|
-
error: fill(marks.unknownJobId, { maxJobs: 10 }),
|
|
3211
|
-
status: 404
|
|
3212
|
-
};
|
|
3213
|
-
const { view, retained } = output;
|
|
3214
|
-
const text = retained.chunks.map((chunk) => chunk.text).join("");
|
|
3215
|
-
const shown = truncateStart(text, JOB_OUT_VIEW_CHARS);
|
|
3216
|
-
const viewMark = text.length > JOB_OUT_VIEW_CHARS ? fill(marks.jobOutputView, {
|
|
3217
|
-
shown: JOB_OUT_VIEW_CHARS,
|
|
3218
|
-
total: text.length
|
|
3219
|
-
}) : "";
|
|
3220
|
-
return {
|
|
3221
|
-
ok: true,
|
|
3222
|
-
status: view.status,
|
|
3223
|
-
exitCode: record.proc.exitCode,
|
|
3224
|
-
root: record.root,
|
|
3225
|
-
...record.proc.sandbox === void 0 ? {} : { sandbox: record.proc.sandbox },
|
|
3226
|
-
output: (view.output.earliest > 0 ? marks.jobOutputTruncated : "") + (record.state.lost ? marks.jobOutputLost : "") + (record.state.timeoutNote ?? "") + (procSandboxNote(record.proc, marks) ?? "") + viewMark + shown
|
|
3227
|
-
};
|
|
3228
|
-
}
|
|
3229
|
-
};
|
|
3230
|
-
/**
|
|
3231
|
-
* 标准装饰器的**程序化调用**:`@Remote` 的全部作用就是往类原型写一枚描述符,而标准装饰器
|
|
3232
|
-
* 语法需要走一条 tsc 降级流水线(本仓的测试/构建解析器都不降级它)。这里直接按 TC39 的
|
|
3233
|
-
* `ClassMethodDecoratorContext` 形状调同一个 decorator 函数,把标记落到真正的原型上,
|
|
3234
|
-
* 于是源码里不再需要装饰器语法,构建与测试都不必再挂那枚预转换插件。
|
|
3235
|
-
*/
|
|
3236
|
-
function markRemote(prototype, methodName) {
|
|
3237
|
-
const context = {
|
|
3238
|
-
kind: "method",
|
|
3239
|
-
name: methodName,
|
|
3240
|
-
static: false,
|
|
3241
|
-
private: false,
|
|
3242
|
-
addInitializer: (initializer) => {
|
|
3243
|
-
Reflect.apply(initializer, Object.create(prototype), []);
|
|
3244
3313
|
}
|
|
3245
3314
|
};
|
|
3246
|
-
|
|
3247
|
-
Reflect.apply(decorate, void 0, [Reflect.get(prototype, methodName), context]);
|
|
3248
|
-
}
|
|
3249
|
-
markRemote(ZvecRebuildService.prototype, "roots");
|
|
3250
|
-
markRemote(ZvecRebuildService.prototype, "rebuild");
|
|
3251
|
-
markRemote(ZvecRebuildService.prototype, "status");
|
|
3315
|
+
})();
|
|
3252
3316
|
/**
|
|
3253
3317
|
*
|
|
3254
3318
|
* 为什么是一枚函数而不是让调用方直接 `new`:这枚 `new` 的**全部意义在构造期的注册副作用**
|
|
@@ -3260,7 +3324,7 @@ markRemote(ZvecRebuildService.prototype, "status");
|
|
|
3260
3324
|
* @param deps - 重建读取接口的全部依赖(见 ZvecRebuildDeps)
|
|
3261
3325
|
*/
|
|
3262
3326
|
function installRebuildRemote(ctx, deps) {
|
|
3263
|
-
if (!isRecord(ctx) || !isRecord(ctx.reflect) || typeof ctx.reflect.provide !== "function") return false;
|
|
3327
|
+
if (!isRecord$1(ctx) || !isRecord$1(ctx.reflect) || typeof ctx.reflect.provide !== "function") return false;
|
|
3264
3328
|
new ZvecRebuildService(ctx, deps);
|
|
3265
3329
|
ctx.effect(() => () => {
|
|
3266
3330
|
releaseRebuildRecords(deps);
|
|
@@ -3403,7 +3467,7 @@ const SESSION_LOST_STATUS = /* @__PURE__ */ new Set([
|
|
|
3403
3467
|
]);
|
|
3404
3468
|
/** 握手与工具调用的 JSON-RPC 常量。 */
|
|
3405
3469
|
const JSONRPC = "2.0";
|
|
3406
|
-
function isRecord
|
|
3470
|
+
function isRecord(value) {
|
|
3407
3471
|
return typeof value === "object" && value !== null;
|
|
3408
3472
|
}
|
|
3409
3473
|
/** 从 SSE 正文收集全部 `data:` 行的 JSON 载荷;解析不了的行(心跳/注释)跳过。 */
|
|
@@ -3429,12 +3493,12 @@ function responsePayloads(contentType, body) {
|
|
|
3429
3493
|
}
|
|
3430
3494
|
/** tools/call 的 JSON-RPC 应答块:错误对象或结果对象二者之一。 */
|
|
3431
3495
|
function replyOf(payloads, requestId) {
|
|
3432
|
-
const found = payloads.find((payload) => isRecord
|
|
3433
|
-
return isRecord
|
|
3496
|
+
const found = payloads.find((payload) => isRecord(payload) && payload["id"] === requestId);
|
|
3497
|
+
return isRecord(found) ? found : void 0;
|
|
3434
3498
|
}
|
|
3435
3499
|
/** 把 MCP result 的 content 拼成文本(只收 text 块)。 */
|
|
3436
3500
|
function resultText(result) {
|
|
3437
|
-
return (isRecord
|
|
3501
|
+
return (isRecord(result) && Array.isArray(result["content"]) ? result["content"] : []).map((block) => isRecord(block) && block["type"] === "text" ? block["text"] : void 0).filter((piece) => typeof piece === "string").join("\n");
|
|
3438
3502
|
}
|
|
3439
3503
|
/**
|
|
3440
3504
|
* 协议层失败:daemon **已经应答**(JSON-RPC error / 应答形状不符)。这类失败是确定性的,
|
|
@@ -3575,11 +3639,11 @@ async function callOnce(state, session, callOptions, requestId, deadline) {
|
|
|
3575
3639
|
if (status !== 200) throw new DaemonProtocolError(`tools/call failed with HTTP ${status}`);
|
|
3576
3640
|
const reply = replyOf(payloads, requestId);
|
|
3577
3641
|
if (reply === void 0) throw new DaemonProtocolError("tools/call reply missing from response");
|
|
3578
|
-
if (isRecord
|
|
3642
|
+
if (isRecord(reply["error"])) throw new DaemonProtocolError(JSON.stringify(reply["error"]));
|
|
3579
3643
|
const { result } = reply;
|
|
3580
3644
|
return {
|
|
3581
3645
|
text: resultText(result),
|
|
3582
|
-
isError: isRecord
|
|
3646
|
+
isError: isRecord(result) && result["isError"] === true
|
|
3583
3647
|
};
|
|
3584
3648
|
}
|
|
3585
3649
|
function createDaemonClient(options) {
|
|
@@ -3598,7 +3662,7 @@ function createDaemonClient(options) {
|
|
|
3598
3662
|
releaseSession(state, first, true);
|
|
3599
3663
|
return result;
|
|
3600
3664
|
} catch (error) {
|
|
3601
|
-
if (isRecord
|
|
3665
|
+
if (isRecord(error) && error["name"] === "AbortError") {
|
|
3602
3666
|
releaseSession(state, first, false);
|
|
3603
3667
|
throw error;
|
|
3604
3668
|
}
|
|
@@ -3704,7 +3768,7 @@ const STDERR_NOTE_CHARS = 400;
|
|
|
3704
3768
|
* 也会放过「是个对象但没注册方法」的错注入。 */
|
|
3705
3769
|
function hasMethod(value, name, keys) {
|
|
3706
3770
|
const member = value[name];
|
|
3707
|
-
return isRecord(member) && keys.every((key) => typeof member[key] === "function");
|
|
3771
|
+
return isRecord$1(member) && keys.every((key) => typeof member[key] === "function");
|
|
3708
3772
|
}
|
|
3709
3773
|
/**
|
|
3710
3774
|
* host 是否为本插件所需宿主服务:五个注入都必须是**带相应方法的对象**,
|
|
@@ -3717,7 +3781,7 @@ function hasMethod(value, name, keys) {
|
|
|
3717
3781
|
* 探它们等于断言一条没有测试撑着的能力。
|
|
3718
3782
|
*/
|
|
3719
3783
|
function isZvecGrepHost(value) {
|
|
3720
|
-
if (!isRecord(value)) return false;
|
|
3784
|
+
if (!isRecord$1(value)) return false;
|
|
3721
3785
|
return hasMethod(value, "settings", ["describe"]) && hasMethod(value, "shell", ["resolve", "execute"]) && hasMethod(value, "tools", ["register", "guard"]) && hasMethod(value, "systemPrompt", ["section"]) && hasMethod(value, "timer", ["timeout"]) && typeof value["get"] === "function";
|
|
3722
3786
|
}
|
|
3723
3787
|
/** 当前会话工作区(root 缺省回退源);非字符串视为缺(读取方式见 lib/routing.ts 的 SessionFace)。 */
|
|
@@ -3735,7 +3799,7 @@ function stringifyJson(value) {
|
|
|
3735
3799
|
return JSON.stringify(value, null, 2);
|
|
3736
3800
|
}
|
|
3737
3801
|
function textBlock(value) {
|
|
3738
|
-
const { text: textValue } = isRecord(value) ? value : {};
|
|
3802
|
+
const { text: textValue } = isRecord$1(value) ? value : {};
|
|
3739
3803
|
if (typeof textValue === "string") return [{
|
|
3740
3804
|
type: "text",
|
|
3741
3805
|
text: textValue
|
|
@@ -4332,11 +4396,11 @@ function manifestCoversRoot(manifestPath, dir, platform) {
|
|
|
4332
4396
|
} catch {
|
|
4333
4397
|
return false;
|
|
4334
4398
|
}
|
|
4335
|
-
if (!isRecord(parsed)) return false;
|
|
4399
|
+
if (!isRecord$1(parsed)) return false;
|
|
4336
4400
|
const version = parsed["indexVersion"];
|
|
4337
4401
|
if (typeof version !== "number" || !Number.isSafeInteger(version) || version < MINIMUM_INDEX_VERSION) return false;
|
|
4338
4402
|
const { sourceRoot } = parsed;
|
|
4339
|
-
if (!isRecord(sourceRoot)) return false;
|
|
4403
|
+
if (!isRecord$1(sourceRoot)) return false;
|
|
4340
4404
|
const recorded = sourceRoot["recordedPath"];
|
|
4341
4405
|
return typeof recorded === "string" && recorded.length > 0 && comparablePath(normalizeRoot(recorded, platform), process.platform) === comparablePath(normalizeRoot(dir, platform), process.platform);
|
|
4342
4406
|
}
|
|
@@ -4405,7 +4469,7 @@ function define(host, spec) {
|
|
|
4405
4469
|
},
|
|
4406
4470
|
execute: async (rawArgs, exec) => {
|
|
4407
4471
|
const messages = spec.messages();
|
|
4408
|
-
if (!isRecord(rawArgs)) throw new Error(fill(messages.argsMustBeObject, {
|
|
4472
|
+
if (!isRecord$1(rawArgs)) throw new Error(fill(messages.argsMustBeObject, {
|
|
4409
4473
|
name: spec.name,
|
|
4410
4474
|
received: rawArgs === null ? "null" : typeof rawArgs
|
|
4411
4475
|
}));
|
|
@@ -4872,7 +4936,7 @@ function daemonFailure(text, messages) {
|
|
|
4872
4936
|
}
|
|
4873
4937
|
/** daemon 调用的传输层失败(fetch 层):取消/超时与 CLI lane 同一套归因。 */
|
|
4874
4938
|
function daemonTransportFailure(error, exec, messages, token) {
|
|
4875
|
-
if (!(isRecord(error) && error["name"] === "AbortError")) {
|
|
4939
|
+
if (!(isRecord$1(error) && error["name"] === "AbortError")) {
|
|
4876
4940
|
const detail = redactToken(errorText(error), token);
|
|
4877
4941
|
return new Error(fill(messages.mcpCallFailed, { detail }), { cause: error });
|
|
4878
4942
|
}
|
|
@@ -4906,7 +4970,7 @@ async function runSearchViaDaemon(runtime, searchArgs, messages, exec, wait) {
|
|
|
4906
4970
|
signal: exec.signal
|
|
4907
4971
|
}));
|
|
4908
4972
|
} catch (error) {
|
|
4909
|
-
const aborted = isRecord(error) && error["name"] === "AbortError";
|
|
4973
|
+
const aborted = isRecord$1(error) && error["name"] === "AbortError";
|
|
4910
4974
|
if (!aborted) runtime.serverGate.invalidate();
|
|
4911
4975
|
throw new DaemonCallFailureError(daemonTransportFailure(error, exec, messages, runtime.daemon.tokenOf()).message, aborted);
|
|
4912
4976
|
}
|
|
@@ -5283,7 +5347,7 @@ function registerRoutingSection(host, registered) {
|
|
|
5283
5347
|
*/
|
|
5284
5348
|
/** 该不该为这次调用问一句;不该问就交回 undefined(调用方转交 next())。 */
|
|
5285
5349
|
function explicitRootAsk(execution, ledger, messages, platform) {
|
|
5286
|
-
const raw = (isRecord(execution.arguments) ? execution.arguments : void 0)?.["root"];
|
|
5350
|
+
const raw = (isRecord$1(execution.arguments) ? execution.arguments : void 0)?.["root"];
|
|
5287
5351
|
let question;
|
|
5288
5352
|
if (typeof raw === "string" && raw.trim().length > 0) {
|
|
5289
5353
|
const decision = judgeRoot(raw, sessionHeaderCwd(execution), messages, ledger, platform);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayyuen66/dsh-zvec-grep",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "dsh 工作区语义检索插件(zg):zg_search / zg_index / zg_status + 本地 embedding 设置卡片 + systemPrompt 路由规则 + guard 安全兜底。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cordis",
|
|
@@ -51,44 +51,45 @@
|
|
|
51
51
|
"registry": "https://registry.npmjs.org"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@jayyuen66/dsh-plugin-shared": "^0.2.
|
|
54
|
+
"@jayyuen66/dsh-plugin-shared": "^0.2.8",
|
|
55
55
|
"zod": "4.6.7"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@deepseek-ai/cordis": "4.1.0",
|
|
59
59
|
"@deepseek-ai/cordis-plugin-group": "1.1.0",
|
|
60
60
|
"@deepseek-ai/cordis-plugin-timer": "1.2.0",
|
|
61
|
-
"@deepseek-ai/dsh-agent": "0.2.2-rc.
|
|
62
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.
|
|
63
|
-
"@deepseek-ai/dsh-bash-local": "0.2.2-rc.
|
|
64
|
-
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.
|
|
65
|
-
"@deepseek-ai/dsh-client-store": "0.2.2-rc.
|
|
66
|
-
"@deepseek-ai/dsh-client-ui-layout": "0.2.2-rc.
|
|
67
|
-
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.2-rc.
|
|
68
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.
|
|
70
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.
|
|
71
|
-
"@deepseek-ai/dsh-
|
|
72
|
-
"@deepseek-ai/dsh-
|
|
73
|
-
"@deepseek-ai/dsh-
|
|
74
|
-
"@deepseek-ai/dsh-jobs
|
|
75
|
-
"@deepseek-ai/dsh-
|
|
76
|
-
"@deepseek-ai/dsh-
|
|
77
|
-
"@deepseek-ai/dsh-
|
|
78
|
-
"@deepseek-ai/dsh-
|
|
79
|
-
"@deepseek-ai/dsh-
|
|
80
|
-
"@deepseek-ai/dsh-
|
|
81
|
-
"@deepseek-ai/dsh-session
|
|
82
|
-
"@deepseek-ai/dsh-
|
|
83
|
-
"@deepseek-ai/dsh-
|
|
84
|
-
"@deepseek-ai/dsh-
|
|
85
|
-
"@deepseek-ai/dsh-subprocess
|
|
86
|
-
"@deepseek-ai/dsh-
|
|
87
|
-
"@deepseek-ai/dsh-
|
|
88
|
-
"@deepseek-ai/dsh-
|
|
89
|
-
"@deepseek-ai/dsh-
|
|
90
|
-
"@deepseek-ai/dsh-
|
|
91
|
-
"@deepseek-ai/dsh-
|
|
61
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.2",
|
|
62
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.2-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-bash-local": "0.2.2-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-client-store": "0.2.2-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.2.2-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.2-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.2",
|
|
70
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.2",
|
|
71
|
+
"@deepseek-ai/dsh-error": "0.2.2-rc.2",
|
|
72
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.2",
|
|
73
|
+
"@deepseek-ai/dsh-http-proxy": "0.2.2-rc.2",
|
|
74
|
+
"@deepseek-ai/dsh-jobs": "0.2.2-rc.2",
|
|
75
|
+
"@deepseek-ai/dsh-jobs-local": "0.2.2-rc.2",
|
|
76
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.2",
|
|
77
|
+
"@deepseek-ai/dsh-output-retention": "0.2.2-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-package-manifest": "0.2.2-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
|
|
80
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.2",
|
|
81
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.2",
|
|
82
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
|
|
83
|
+
"@deepseek-ai/dsh-settings": "0.2.2-rc.2",
|
|
84
|
+
"@deepseek-ai/dsh-shell": "0.2.2-rc.2",
|
|
85
|
+
"@deepseek-ai/dsh-subprocess": "0.2.2-rc.2",
|
|
86
|
+
"@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.2",
|
|
87
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.2",
|
|
88
|
+
"@deepseek-ai/dsh-timeout": "0.2.2-rc.2",
|
|
89
|
+
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.2",
|
|
90
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.2",
|
|
91
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.2",
|
|
92
|
+
"@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
|
|
92
93
|
"@deepseek-ai/schemastery": "3.19.0",
|
|
93
94
|
"@e18e/eslint-plugin": "0.8.1",
|
|
94
95
|
"@types/node": "26.6.6",
|
|
@@ -98,21 +99,21 @@
|
|
|
98
99
|
"eslint-plugin-sonarjs": "4.2.2",
|
|
99
100
|
"eslint-plugin-zod": "5.2.2",
|
|
100
101
|
"fast-check": "4.10.2",
|
|
101
|
-
"oxfmt": "0.
|
|
102
|
-
"oxlint": "1.
|
|
103
|
-
"oxlint-tsgolint": "7.0.
|
|
102
|
+
"oxfmt": "0.78.0",
|
|
103
|
+
"oxlint": "1.93.0",
|
|
104
|
+
"oxlint-tsgolint": "7.0.2006",
|
|
104
105
|
"react": "^19.3.0",
|
|
105
|
-
"rolldown": "1.2
|
|
106
|
+
"rolldown": "1.3.2",
|
|
106
107
|
"typescript": "7.0.2",
|
|
107
|
-
"vite": "8.3.
|
|
108
|
+
"vite": "8.3.8",
|
|
108
109
|
"vitest": "5.1.0"
|
|
109
110
|
},
|
|
110
111
|
"peerDependencies": {
|
|
111
|
-
"@deepseek-ai/dsh": "^0.2.
|
|
112
|
-
"@deepseek-ai/dsh-output-retention": "^0.2.
|
|
113
|
-
"@deepseek-ai/dsh-scope": "^0.2.
|
|
114
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.2.
|
|
115
|
-
"@deepseek-ai/schemastery": "^3.
|
|
112
|
+
"@deepseek-ai/dsh": "^0.2.2-rc.1",
|
|
113
|
+
"@deepseek-ai/dsh-output-retention": "^0.2.2-rc.1",
|
|
114
|
+
"@deepseek-ai/dsh-scope": "^0.2.2-rc.1",
|
|
115
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.1",
|
|
116
|
+
"@deepseek-ai/schemastery": "^3.19.0"
|
|
116
117
|
},
|
|
117
118
|
"peerDependenciesMeta": {
|
|
118
119
|
"@deepseek-ai/dsh": {
|
|
@@ -121,7 +122,7 @@
|
|
|
121
122
|
},
|
|
122
123
|
"icon": "icon.svg",
|
|
123
124
|
"engines": {
|
|
124
|
-
"dsh": "^0.2.
|
|
125
|
+
"dsh": "^0.2.2-rc.1",
|
|
125
126
|
"node": ">=24.9.0"
|
|
126
127
|
},
|
|
127
128
|
"dsh": {
|