@xiaoso/dsh-tool-plus 0.1.2-beta.0 → 0.1.2

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 CHANGED
@@ -2077,7 +2077,6 @@ window.__ModuleLoader__.load({
2077
2077
  switch (reason) {
2078
2078
  case "snapshot-unavailable": return "rmSafeReasonSnapshotUnavailable";
2079
2079
  case "cli-missing": return "rmSafeReasonCliMissing";
2080
- case "script-write-failed": return "rmSafeReasonScriptWriteFailed";
2081
2080
  case "snapshot-write-failed": return "rmSafeReasonSnapshotWriteFailed";
2082
2081
  case "runtime-not-effective": return "rmSafeReasonRuntimeNotEffective";
2083
2082
  }
@@ -2714,11 +2713,11 @@ window.__ModuleLoader__.load({
2714
2713
  editFuzzyThreshold: "模糊匹配阈值",
2715
2714
  editFuzzyThresholdHint: "相似度阈值,低于该值不视为命中。",
2716
2715
  editEnforceSeenLines: "已见行守卫",
2717
- editEnforceSeenLinesHint: "拒绝锚定在先前 read/search 从未完整展示过的行上的编辑。",
2716
+ editEnforceSeenLinesHint: "禁止修改此前读取或搜索从未完整展示过的行。",
2718
2717
  grepContextBefore: "匹配前上下文行数",
2719
- grepContextBeforeHint: "每个匹配前展示的上下文行数。",
2718
+ grepContextBeforeHint: "每个匹配结果上方连带显示几行,方便对照命中处的前后文。",
2720
2719
  grepContextAfter: "匹配后上下文行数",
2721
- grepContextAfterHint: "每个匹配后展示的上下文行数。",
2720
+ grepContextAfterHint: "每个匹配结果下方连带显示几行,方便对照命中处的前后文。",
2722
2721
  grepCaseDefault: "大小写敏感(默认)",
2723
2722
  grepCaseDefaultHint: "开启(默认)时按大小写严格匹配;关闭后忽略大小写。调用时显式传 case 参数会覆盖此默认。",
2724
2723
  grepGitignoreDefault: "跳过被忽略的文件(默认)",
@@ -2771,12 +2770,11 @@ window.__ModuleLoader__.load({
2771
2770
  rmSafeStatusFailed: "安全 rm 注入失败:{reason},rm 将永久删除",
2772
2771
  rmSafeReasonSnapshotUnavailable: "快照不可用",
2773
2772
  rmSafeReasonCliMissing: "trash-cli 产物缺失",
2774
- rmSafeReasonScriptWriteFailed: "脚本写入失败",
2775
2773
  rmSafeReasonSnapshotWriteFailed: "快照不可写",
2776
2774
  rmSafeReasonRuntimeNotEffective: "运行时未生效",
2777
2775
  useShellCommandWrapper: "用 bash -c 包裹命令",
2778
2776
  useShellCommandWrapperHint: "把每条命令用 bash -c 包裹,以获得完整的 bash 环境。",
2779
- outputTruncateStrategy: "截断按",
2777
+ outputTruncateStrategy: "截断单位",
2780
2778
  outputTruncateStrategyHint: "后台任务完成消息达到阈值时的截断单位:按字节或按行。切换后下方显示对应单位的配置。",
2781
2779
  outputTruncateTriggerBytes: "字节触发阈值",
2782
2780
  outputTruncateTriggerBytesHint: "完成文本超过该字节数才截断(按字节策略时生效)。",
@@ -2905,11 +2903,11 @@ window.__ModuleLoader__.load({
2905
2903
  editFuzzyThreshold: "Fuzzy threshold",
2906
2904
  editFuzzyThresholdHint: "Similarity threshold below which a match is not accepted.",
2907
2905
  editEnforceSeenLines: "Seen-line guard",
2908
- editEnforceSeenLinesHint: "Reject edits anchored on lines a prior read/search never displayed in full.",
2906
+ editEnforceSeenLinesHint: "Reject edits on lines a previous read or search never displayed in full.",
2909
2907
  grepContextBefore: "Context lines before match",
2910
- grepContextBeforeHint: "Context lines shown before each match.",
2908
+ grepContextBeforeHint: "Lines shown above each match so you can see the context around a hit.",
2911
2909
  grepContextAfter: "Context lines after match",
2912
- grepContextAfterHint: "Context lines shown after each match.",
2910
+ grepContextAfterHint: "Lines shown below each match so you can see the context around a hit.",
2913
2911
  grepCaseDefault: "Case-sensitive (default)",
2914
2912
  grepCaseDefaultHint: "When on (default), matches strictly by case; when off, case is ignored. An explicit case argument on the call overrides this default.",
2915
2913
  grepGitignoreDefault: "Skip ignored files (default)",
@@ -2962,12 +2960,11 @@ window.__ModuleLoader__.load({
2962
2960
  rmSafeStatusFailed: "Safe rm injection failed: {reason}, rm deletes permanently",
2963
2961
  rmSafeReasonSnapshotUnavailable: "snapshot unavailable",
2964
2962
  rmSafeReasonCliMissing: "trash-cli binary missing",
2965
- rmSafeReasonScriptWriteFailed: "script write failed",
2966
2963
  rmSafeReasonSnapshotWriteFailed: "snapshot not writable",
2967
2964
  rmSafeReasonRuntimeNotEffective: "not effective at runtime",
2968
2965
  useShellCommandWrapper: "Wrap commands in bash -c",
2969
2966
  useShellCommandWrapperHint: "Wrap every command in bash -c for a full bash environment.",
2970
- outputTruncateStrategy: "Truncate by",
2967
+ outputTruncateStrategy: "Truncate unit",
2971
2968
  outputTruncateStrategyHint: "Unit used when a background completion message crosses its threshold: bytes or lines. Switching shows the matching unit's settings below.",
2972
2969
  outputTruncateTriggerBytes: "Byte trigger threshold",
2973
2970
  outputTruncateTriggerBytesHint: "Truncate only when the completion text exceeds this many bytes (byte strategy).",
package/lib/index.mjs CHANGED
@@ -3,7 +3,7 @@ __installBunShim();
3
3
  import { n as fs_promises_shim_exports, t as exists } from "./fs-promises-shim-Bx0fpxuk.mjs";
4
4
  import { i as setRuntimeLogger, n as systemChromiumCandidatesForTest, r as runtimeLogger } from "./launch-DwpE70Pv.mjs";
5
5
  import { $ as peekFile, A as formatAge, C as error, F as $envpos, I as $flag, M as formatCount, P as $env, Q as isProbablyBinary, S as debug, T as warn, U as getAutoQaDbPath, V as VERSION, X as getRemoteDir, Y as getPuppeteerDir, b as isEnotdir, c as combineSignals, d as $which, j as formatBytes$1, k as installBunShim, l as exec, p as readImageMetadata, q as getInstallId, tt as untilAborted, u as render, v as hasFsCode, y as isEnoent } from "./src-D_e1qMwi.mjs";
6
- import { C as truncateToWidth$1, S as replaceTabs, _ as formatCodeFrameLine, a as fetchBinary, b as LRUCache, c as getParallelExtractContent, d as convertFileWithMarkit, f as Settings, g as capParseErrors, h as OMP_DEFAULTS, i as convertWithMarkit, l as ensureTool, m as settings, o as extractWithParallel, p as isSettingsInitialized, s as findParallelApiKey, u as CONVERTIBLE_EXTENSIONS, v as formatParseErrors, x as padding, y as shortenPath } from "./utils-DvRrWOyM.mjs";
6
+ import { C as truncateToWidth$1, S as replaceTabs, _ as formatCodeFrameLine, a as fetchBinary, b as LRUCache, c as getParallelExtractContent, d as convertFileWithMarkit, f as Settings, g as capParseErrors, h as OMP_DEFAULTS, i as convertWithMarkit, l as ensureTool, m as settings, o as extractWithParallel, p as isSettingsInitialized, s as findParallelApiKey, u as CONVERTIBLE_EXTENSIONS, v as formatParseErrors, x as padding, y as shortenPath } from "./utils-NmfqUq33.mjs";
7
7
  import { t as sanitizeText } from "./sanitize-text-CfcXzw5X.mjs";
8
8
  import { n as isRecord$2 } from "./type-guards-B9VVjRDK.mjs";
9
9
  import { n as ToolError, r as throwIfAborted, t as ToolAbortError } from "./tool-errors-DoyxivAR.mjs";
@@ -811,20 +811,21 @@ function cleanupSnapshots() {
811
811
  /**
812
812
  * rmSafe: rm 重定义脚本的生成与快照注入。
813
813
  *
814
- * 生成一个 bash 函数定义脚本(rm → `node <trash-cli.mjs> "$@"`),
815
- * 通过快照文件(会话 shell 创建时 source 一次)注入:
814
+ * 生成 bash 函数定义(rm → `node <trash-cli.mjs> "$@"`),直接内联进
815
+ * 快照文件(会话 shell 创建时 source 一次):
816
816
  * - POSIX:追加到用户环境快照末尾(幂等,带标记行);
817
817
  * - Windows:getOrCreateSnapshot 生成"仅注入"快照文件后同样追加。
818
818
  *
819
+ * 内联而非独立脚本文件:快照随进程重建(重启后重新生成),node/trash-cli
820
+ * 路径在进程内是常量,不存在"路径漂移";独立脚本文件反而引入跨进程共享
821
+ * 缓存(不同安装路径的实例、测试进程互相覆盖,测试进程的 import.meta.url
822
+ * 指向 src 会把共享缓存重写成不存在的路径)。
823
+ *
819
824
  * rmSafe 关闭时调用方不注入,快照保持原样,系统 rm 生效。
820
825
  * @module @xiaoso/dsh-tool-plus/bash/rm-safe
821
826
  */
822
827
  /** 注入标记行:injectRmSafe 以此判断是否已注入(幂等)。 */
823
828
  const RM_SAFE_MARKER = "# dsh-tool-plus rmSafe";
824
- /** rm-safe 脚本缓存目录(tmpdir 下,跨会话复用)。 */
825
- function rmSafeScriptDir() {
826
- return path.join(os.tmpdir(), "dsh-bash-plus");
827
- }
828
829
  /** trash-cli 构建产物路径(lib/trash-cli.mjs,与主 bundle 同目录)。 */
829
830
  function rmSafeCliPath() {
830
831
  return fileURLToPath(new URL("./trash-cli.mjs", import.meta.url));
@@ -849,28 +850,10 @@ function rmSafeScript(nodePath, cliPath) {
849
850
  ].join("\n");
850
851
  }
851
852
  /**
852
- * 确保 rm-safe 脚本存在(内容不变时幂等,不重写文件)。
853
- * 返回脚本路径;目录/写入失败时返回 null(不抛异常,调用方降级并告警)。
854
- */
855
- function ensureRmSafeScript(dir, nodePath, cliPath) {
856
- const target = path.join(dir, "rm-safe.sh");
857
- const content = rmSafeScript(nodePath, cliPath);
858
- try {
859
- if (fs.readFileSync(target, "utf8") === content) return target;
860
- } catch {}
861
- try {
862
- fs.mkdirSync(dir, { recursive: true });
863
- fs.writeFileSync(target, content, { mode: 384 });
864
- return target;
865
- } catch {
866
- return null;
867
- }
868
- }
869
- /**
870
- * 向快照文件追加 `source <rm-safe.sh>`(幂等:已有标记则跳过)。
853
+ * 向快照文件内联追加 rm 重定义(幂等:已有标记则跳过)。
871
854
  * 返回是否注入成功;快照文件不可读/不可写时返回 false(不抛异常)。
872
855
  */
873
- function injectRmSafe(snapshotPath, scriptPath) {
856
+ function injectRmSafe(snapshotPath, nodePath, cliPath) {
874
857
  let content;
875
858
  try {
876
859
  content = fs.readFileSync(snapshotPath, "utf8");
@@ -879,7 +862,7 @@ function injectRmSafe(snapshotPath, scriptPath) {
879
862
  }
880
863
  if (content.includes("# dsh-tool-plus rmSafe")) return true;
881
864
  try {
882
- fs.appendFileSync(snapshotPath, `\n${RM_SAFE_MARKER}\nsource ${quote(scriptPath)}\n`);
865
+ fs.appendFileSync(snapshotPath, `\n${rmSafeScript(nodePath, cliPath)}`);
883
866
  return true;
884
867
  } catch {
885
868
  return false;
@@ -2426,13 +2409,9 @@ async function executeBash(command, options) {
2426
2409
  let snapshotPath = bashShell && options?.snapshotEnabled !== false ? await getOrCreateSnapshot(shell, shellEnv) : null;
2427
2410
  let rmSafeInjectionFailed = false;
2428
2411
  if (snapshotPath !== null && options?.rmSafe === true) {
2429
- const scriptPath = ensureRmSafeScript(rmSafeScriptDir(), process.execPath, rmSafeCliPath());
2430
- if (scriptPath === null || !injectRmSafe(snapshotPath, scriptPath)) {
2412
+ if (!injectRmSafe(snapshotPath, process.execPath, rmSafeCliPath())) {
2431
2413
  rmSafeInjectionFailed = true;
2432
- runtimeLogger().warn("rmSafe: injection failed, rm will delete permanently", {
2433
- scriptPath: scriptPath ?? null,
2434
- snapshotPath
2435
- });
2414
+ runtimeLogger().warn("rmSafe: injection failed, rm will delete permanently", { snapshotPath });
2436
2415
  }
2437
2416
  }
2438
2417
  const injectionFailedMarker = rmSafeInjectionFailed ? { rmSafeInjectionFailed: true } : {};
@@ -4458,12 +4437,7 @@ async function queryRmSafeStatus(deps) {
4458
4437
  status: "failed",
4459
4438
  reason: "cli-missing"
4460
4439
  };
4461
- const scriptPath = deps.ensureScript();
4462
- if (scriptPath === null) return {
4463
- status: "failed",
4464
- reason: "script-write-failed"
4465
- };
4466
- if (!deps.inject(snapshotPath, scriptPath)) return {
4440
+ if (!deps.inject(snapshotPath, deps.nodePath(), deps.cliPath())) return {
4467
4441
  status: "failed",
4468
4442
  reason: "snapshot-write-failed"
4469
4443
  };
@@ -4533,8 +4507,9 @@ function installBrowserProbeRpc(ctx, deps) {
4533
4507
  value: await queryRmSafeStatus({
4534
4508
  getOrCreateSnapshot: () => getOrCreateSnapshot(shell, env),
4535
4509
  cliExists: () => fs.existsSync(rmSafeCliPath()),
4536
- ensureScript: () => ensureRmSafeScript(rmSafeScriptDir(), process.execPath, rmSafeCliPath()),
4537
- inject: (snapshotPath, scriptPath) => injectRmSafe(snapshotPath, scriptPath),
4510
+ nodePath: () => process.execPath,
4511
+ cliPath: () => rmSafeCliPath(),
4512
+ inject: (snapshotPath, nodePath, cliPath) => injectRmSafe(snapshotPath, nodePath, cliPath),
4538
4513
  probe: (snapshotPath) => probeRmSafeRuntime(shell, snapshotPath)
4539
4514
  })
4540
4515
  };
@@ -14881,7 +14856,7 @@ let specialHandlersPromise;
14881
14856
  * requires a special handler, so we keep them out of the cold-startup graph.
14882
14857
  */
14883
14858
  function loadSpecialHandlers() {
14884
- specialHandlersPromise ??= import("./scrapers-B3AO6nqq.mjs").then((m) => m.specialHandlers);
14859
+ specialHandlersPromise ??= import("./scrapers-kdFCThln.mjs").then((m) => m.specialHandlers);
14885
14860
  return specialHandlersPromise;
14886
14861
  }
14887
14862
  /**
@@ -3,7 +3,7 @@ __installBunShim();
3
3
  import { n as fs_promises_shim_exports } from "./fs-promises-shim-Bx0fpxuk.mjs";
4
4
  import { B as USER_AGENT, G as getDocsRsCacheDir, N as formatNumber, P as $env, T as warn, c as combineSignals, j as formatBytes, l as exec, s as Snowflake, x as parseFrontmatter, y as isEnoent } from "./src-D_e1qMwi.mjs";
5
5
  import { V as tryParseJson } from "./utils-fnV2zzp3.mjs";
6
- import { a as fetchBinary, c as getParallelExtractContent, i as convertWithMarkit, l as ensureTool, m as settings, n as asRecord, o as extractWithParallel, r as asString, s as findParallelApiKey, t as asNumber } from "./utils-DvRrWOyM.mjs";
6
+ import { a as fetchBinary, c as getParallelExtractContent, i as convertWithMarkit, l as ensureTool, m as settings, n as asRecord, o as extractWithParallel, r as asString, s as findParallelApiKey, t as asNumber } from "./utils-NmfqUq33.mjs";
7
7
  import { n as isRecord } from "./type-guards-B9VVjRDK.mjs";
8
8
  import { r as throwIfAborted, t as ToolAbortError } from "./tool-errors-DoyxivAR.mjs";
9
9
  import { c as getLocalizedText, d as looksLikeHtml, i as decodeHtmlEntities, l as htmlToBasicMarkdown, o as formatIsoDate, r as buildResult, s as formatMediaDuration, u as loadPage } from "./types-BUO0JXO-.mjs";
@@ -7202,7 +7202,7 @@ const settings = {
7202
7202
  };
7203
7203
  //#endregion
7204
7204
  //#region package.json
7205
- var version = "0.1.2-beta.0";
7205
+ var version = "0.1.2";
7206
7206
  /** `.tmp` files older than this are treated as orphaned writes and swept. */
7207
7207
  const TMP_ORPHAN_MAX_AGE_MS = 3e5;
7208
7208
  function markitConversionCacheKey(bytes, extension) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xiaoso/dsh-tool-plus",
3
3
  "description": "Oh My Pi bash runtime ported as a deepseek-harness tool plugin: persistent shell session, output minimizer, managed background jobs, command interception",
4
- "version": "0.1.2-beta.0",
4
+ "version": "0.1.2",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "deepseek-harness",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaoso/dsh-tool-plus-presets",
3
- "version": "0.1.2-beta.0",
3
+ "version": "0.1.2",
4
4
  "description": "Agent-preset installer for dsh-tool-plus: installs the standard / PTC enhanced preset templates into a DeepSeek Harness home.",
5
5
  "license": "MIT",
6
6
  "keywords": [