dsh-vscode-mode 0.1.29 → 0.1.30
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/lib/client.js +32 -3
- package/lib/client.js.map +1 -1
- package/lib/index.js +72 -14
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/monaco/diffRender.ts +7 -0
- package/src/client/rpc.ts +13 -2
- package/src/client/ui/EditorView.ts +11 -3
- package/src/rpc.ts +79 -19
package/lib/index.js
CHANGED
|
@@ -2927,10 +2927,73 @@ async function revealInExplorer(ctx, absPath, isDir) {
|
|
|
2927
2927
|
}
|
|
2928
2928
|
//#endregion
|
|
2929
2929
|
//#region src/rpc.ts
|
|
2930
|
-
/** cwd →
|
|
2930
|
+
/** cwd → 内存缓冲:行数组 + 累计字节数 + 待触发 flush 定时器(攒批落盘,避免每条日志全文件读改写)。 */
|
|
2931
|
+
const debugBuffers = /* @__PURE__ */ new Map();
|
|
2932
|
+
/** cwd → Promise 链:串行化 debug 日志落盘(fs read+write 非原子,避免并发丢行)。 */
|
|
2931
2933
|
const debugWriteQueues = /* @__PURE__ */ new Map();
|
|
2932
2934
|
/** debug 日志单文件上限:超限截断保留尾部,防文件无限增长拖慢每次追加。 */
|
|
2933
2935
|
const DEBUG_LOG_CAP = 524288;
|
|
2936
|
+
/** debug 日志批量缓冲上限:攒满即落盘(一次读改写),上限内不逐条写文件。 */
|
|
2937
|
+
const DEBUG_BUF_CAP = 32768;
|
|
2938
|
+
/** debug 日志空闲 flush 延迟:缓冲未满时,静默一段时间后落盘一次。 */
|
|
2939
|
+
const DEBUG_FLUSH_IDLE_MS = 1e3;
|
|
2940
|
+
/** cwd → 上次 stale 自动清理时间:全量轮询(EditorView/DiffBadge/Dock 各自 5s)节流,避免每轮都读文件算指纹。 */
|
|
2941
|
+
const staleCheckedAt = /* @__PURE__ */ new Map();
|
|
2942
|
+
/** stale 自动清理最小间隔。 */
|
|
2943
|
+
const STALE_CHECK_MIN_MS = 1e4;
|
|
2944
|
+
/**
|
|
2945
|
+
* 调试日志入队:先攒内存缓冲(行 + 字节数),满 DEBUG_BUF_CAP 立即落盘,
|
|
2946
|
+
* 否则空闲 DEBUG_FLUSH_IDLE_MS 后落盘;落盘 = 读旧文件 + 追加整批 + 超限截断 + 一次写入。
|
|
2947
|
+
* @author ddj 2026年08月26号
|
|
2948
|
+
* @param ctx DSH 上下文
|
|
2949
|
+
* @param cwd 工作区(日志文件按工作区旁车存放)
|
|
2950
|
+
* @param policy 会话沙箱策略(入队时刻捕获)
|
|
2951
|
+
* @param line 单条日志文本(不含换行)
|
|
2952
|
+
*/
|
|
2953
|
+
function enqueueDebug(ctx, cwd, policy, line) {
|
|
2954
|
+
const st = debugBuffers.get(cwd) ?? {
|
|
2955
|
+
lines: [],
|
|
2956
|
+
len: 0,
|
|
2957
|
+
timer: null
|
|
2958
|
+
};
|
|
2959
|
+
st.lines.push(line);
|
|
2960
|
+
st.len += line.length;
|
|
2961
|
+
const flush = () => {
|
|
2962
|
+
st.timer = null;
|
|
2963
|
+
const batch = st.lines;
|
|
2964
|
+
st.lines = [];
|
|
2965
|
+
st.len = 0;
|
|
2966
|
+
flushDebug(ctx, cwd, policy, batch);
|
|
2967
|
+
};
|
|
2968
|
+
if (st.len >= DEBUG_BUF_CAP) {
|
|
2969
|
+
if (st.timer) clearTimeout(st.timer);
|
|
2970
|
+
flush();
|
|
2971
|
+
} else if (!st.timer) st.timer = setTimeout(flush, DEBUG_FLUSH_IDLE_MS);
|
|
2972
|
+
debugBuffers.set(cwd, st);
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* 批量落盘一条 debug 日志缓冲:读旧文件 → 追加 → 超上限截断保留尾部 → 一次写回。
|
|
2976
|
+
* 串行链保证同一 cwd 的读改写不交错丢行;写失败静默忽略(调试日志不阻塞业务)。
|
|
2977
|
+
* @author ddj 2026年08月26号
|
|
2978
|
+
* @param ctx DSH 上下文
|
|
2979
|
+
* @param cwd 工作区
|
|
2980
|
+
* @param policy 会话沙箱策略(enqueue 时刻捕获)
|
|
2981
|
+
* @param batch 本批日志行
|
|
2982
|
+
*/
|
|
2983
|
+
function flushDebug(ctx, cwd, policy, batch) {
|
|
2984
|
+
const task = (debugWriteQueues.get(cwd) ?? Promise.resolve()).then(async () => {
|
|
2985
|
+
try {
|
|
2986
|
+
const fs = ctx.get("fs");
|
|
2987
|
+
if (!fs) return;
|
|
2988
|
+
const target = await fs.resolve(".dsh-edit-review-debug.log", { cwd });
|
|
2989
|
+
const appended = await fs.readText(target).catch(() => "") + batch.map((l) => (/* @__PURE__ */ new Date()).toISOString() + " " + l + "\n").join("");
|
|
2990
|
+
const next = appended.length > DEBUG_LOG_CAP ? appended.slice(-Math.floor(DEBUG_LOG_CAP / 2)) : appended;
|
|
2991
|
+
await fs.writeText(target, next, void 0, void 0, policy);
|
|
2992
|
+
} catch (e) {}
|
|
2993
|
+
});
|
|
2994
|
+
debugWriteQueues.set(cwd, task);
|
|
2995
|
+
return task;
|
|
2996
|
+
}
|
|
2934
2997
|
/** 记录 → 客户端视图(不含 before 全文,仅长度)。 */
|
|
2935
2998
|
function recView(record) {
|
|
2936
2999
|
return {
|
|
@@ -3021,7 +3084,13 @@ function buildHandlers(ctx, registry, searcher = newSearcher(ctx), contentSearch
|
|
|
3021
3084
|
};
|
|
3022
3085
|
const bucket = await bucketOf(registry, ctx, sc.cwd);
|
|
3023
3086
|
const want = Array.isArray(args.callIds) ? new Set(args.callIds) : null;
|
|
3024
|
-
if (!want && args.skipStale !== true)
|
|
3087
|
+
if (!want && args.skipStale !== true) {
|
|
3088
|
+
const now = Date.now();
|
|
3089
|
+
if (now - (staleCheckedAt.get(sc.cwd) ?? 0) > STALE_CHECK_MIN_MS) {
|
|
3090
|
+
staleCheckedAt.set(sc.cwd, now);
|
|
3091
|
+
await autoArchiveStale(ctx, sc.session, sc.cwd, bucket);
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3025
3094
|
const out = [];
|
|
3026
3095
|
for (const rec of bucket.values()) {
|
|
3027
3096
|
if (!want && rec.archived) continue;
|
|
@@ -3327,19 +3396,8 @@ function buildHandlers(ctx, registry, searcher = newSearcher(ctx), contentSearch
|
|
|
3327
3396
|
ok: false,
|
|
3328
3397
|
error: sc.err
|
|
3329
3398
|
};
|
|
3330
|
-
const fs = ctx.get("fs");
|
|
3331
3399
|
const text = String(args.text ?? "");
|
|
3332
|
-
|
|
3333
|
-
try {
|
|
3334
|
-
const target = await fs.resolve(".dsh-edit-review-debug.log", { cwd: sc.cwd });
|
|
3335
|
-
const old = await fs.readText(target).catch(() => "");
|
|
3336
|
-
const line = (/* @__PURE__ */ new Date()).toISOString() + " " + text + "\n";
|
|
3337
|
-
const next = old.length + line.length > DEBUG_LOG_CAP ? old.slice(-Math.floor(DEBUG_LOG_CAP / 2)) + line : old + line;
|
|
3338
|
-
await fs.writeText(target, next, void 0, void 0, policyOf(ctx, sc.session));
|
|
3339
|
-
} catch (e) {}
|
|
3340
|
-
});
|
|
3341
|
-
debugWriteQueues.set(sc.cwd, task);
|
|
3342
|
-
await task;
|
|
3400
|
+
enqueueDebug(ctx, sc.cwd, policyOf(ctx, sc.session), text);
|
|
3343
3401
|
console.error("[edrv-debug] " + text);
|
|
3344
3402
|
return { ok: true };
|
|
3345
3403
|
},
|