tianshu-harness 3.23.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/LICENSE +189 -0
- package/README.en.md +1066 -0
- package/README.ja.md +1214 -0
- package/README.ko.md +1216 -0
- package/README.md +309 -0
- package/completions/rivet.bash +118 -0
- package/completions/rivet.fish +110 -0
- package/completions/rivet.ps1 +230 -0
- package/completions/rivet.zsh +187 -0
- package/dist/account-OAEKORZE.js +47 -0
- package/dist/account-login-V6FOLHJR.js +65 -0
- package/dist/account-status-KHNPPAFL.js +23 -0
- package/dist/agent/worker-process/child.js +407 -0
- package/dist/browser-cli-FLNY5ZHI.js +19 -0
- package/dist/browser-readiness-LWVGSBD5.js +12 -0
- package/dist/build-backends-5KXKR2S4.js +13 -0
- package/dist/build-options-66Y4ZE7C.js +9 -0
- package/dist/bundled-skills/brainstorming/SKILL.md +139 -0
- package/dist/bundled-skills/visual-acceptance/SKILL.md +64 -0
- package/dist/chain-7MAMFXZ3.js +10 -0
- package/dist/checkpoint-MND4DUIX.js +33 -0
- package/dist/chunk-2E6CK2RC.js +392 -0
- package/dist/chunk-2EBWGAXD.js +51 -0
- package/dist/chunk-2HDP7RMR.js +119 -0
- package/dist/chunk-2HKD2UFM.js +1000 -0
- package/dist/chunk-2VYRLULP.js +51 -0
- package/dist/chunk-2XN7PM4N.js +125 -0
- package/dist/chunk-35H7GVNR.js +66 -0
- package/dist/chunk-3C3R7JXY.js +77 -0
- package/dist/chunk-3VGD2FXB.js +118 -0
- package/dist/chunk-424AP7FM.js +534 -0
- package/dist/chunk-4J5TZGOE.js +3707 -0
- package/dist/chunk-4QJ3Y5JM.js +898 -0
- package/dist/chunk-4U2ET7ZY.js +1326 -0
- package/dist/chunk-4XPFLICE.js +876 -0
- package/dist/chunk-5B2OCU5P.js +31707 -0
- package/dist/chunk-5GGOGLSN.js +73 -0
- package/dist/chunk-5JRZPLI6.js +251 -0
- package/dist/chunk-5TQ3JYBU.js +397 -0
- package/dist/chunk-66JPZSGX.js +55 -0
- package/dist/chunk-6HSVXHCZ.js +764 -0
- package/dist/chunk-6S5FPUS7.js +21 -0
- package/dist/chunk-722LQO64.js +131 -0
- package/dist/chunk-73NJ7IT7.js +354 -0
- package/dist/chunk-7FW3I7WC.js +95 -0
- package/dist/chunk-7KUCBNLB.js +173 -0
- package/dist/chunk-7RDOV3DF.js +201 -0
- package/dist/chunk-A5MNH4ER.js +79 -0
- package/dist/chunk-ADIVZ2D5.js +15 -0
- package/dist/chunk-AE3P3F6W.js +366 -0
- package/dist/chunk-AERM3VGP.js +280 -0
- package/dist/chunk-AEWHC4WM.js +246 -0
- package/dist/chunk-AOVQ7VIF.js +169 -0
- package/dist/chunk-AOYHP3WI.js +12411 -0
- package/dist/chunk-B3YEBABJ.js +7160 -0
- package/dist/chunk-BCQXEZPJ.js +154 -0
- package/dist/chunk-BKTQAYO2.js +418 -0
- package/dist/chunk-BSECIPAQ.js +80 -0
- package/dist/chunk-BUIMGNDD.js +52 -0
- package/dist/chunk-BXHV3GSB.js +10320 -0
- package/dist/chunk-C6ZVZCPP.js +139 -0
- package/dist/chunk-CEZNQVWM.js +82 -0
- package/dist/chunk-CGFZGR7G.js +1492 -0
- package/dist/chunk-CGOADM2X.js +337 -0
- package/dist/chunk-CI4R6P2B.js +24 -0
- package/dist/chunk-D2TCGRSX.js +73 -0
- package/dist/chunk-D4PTYFOG.js +154 -0
- package/dist/chunk-D54ZWG4T.js +717 -0
- package/dist/chunk-DEBI37QB.js +145 -0
- package/dist/chunk-DWROHPXP.js +1051 -0
- package/dist/chunk-DZ6UOJ5D.js +92 -0
- package/dist/chunk-EBJTVRQN.js +81 -0
- package/dist/chunk-EGEI2RQA.js +1167 -0
- package/dist/chunk-EHHUASO5.js +1305 -0
- package/dist/chunk-EPKTIOED.js +41 -0
- package/dist/chunk-ER5JW2QZ.js +5681 -0
- package/dist/chunk-ETHFACAB.js +315 -0
- package/dist/chunk-EXUE5W2F.js +112 -0
- package/dist/chunk-EXXICUIW.js +73 -0
- package/dist/chunk-FFQSZJOO.js +169 -0
- package/dist/chunk-FHFKPGDO.js +85 -0
- package/dist/chunk-FW3QKMFX.js +158 -0
- package/dist/chunk-GD4ZNZ7W.js +30 -0
- package/dist/chunk-GHVMWF2I.js +581 -0
- package/dist/chunk-GMKAXSYQ.js +297 -0
- package/dist/chunk-HBVF6BWO.js +325 -0
- package/dist/chunk-HV4YGVMS.js +379 -0
- package/dist/chunk-ILBCKAV6.js +89 -0
- package/dist/chunk-J4U4AW46.js +440 -0
- package/dist/chunk-J6ESSM47.js +1791 -0
- package/dist/chunk-JBZHIC6T.js +2309 -0
- package/dist/chunk-JCFWOULR.js +245 -0
- package/dist/chunk-JRF5L6OD.js +131 -0
- package/dist/chunk-JSS75KCG.js +2014 -0
- package/dist/chunk-JSXWIWWJ.js +225 -0
- package/dist/chunk-JYV7I2QH.js +98 -0
- package/dist/chunk-KIOXTQQL.js +1596 -0
- package/dist/chunk-KWVTXT5B.js +89 -0
- package/dist/chunk-KX22RD6R.js +33 -0
- package/dist/chunk-LA6IPTGH.js +709 -0
- package/dist/chunk-LH5VCGLB.js +1796 -0
- package/dist/chunk-LQQ6XJ2Y.js +269 -0
- package/dist/chunk-MJQ55WZZ.js +65 -0
- package/dist/chunk-ML3UKMH3.js +40 -0
- package/dist/chunk-MOZPLHSU.js +5526 -0
- package/dist/chunk-NGEWJ4DF.js +89 -0
- package/dist/chunk-NH6VIOAR.js +211 -0
- package/dist/chunk-O5VZQKCB.js +26106 -0
- package/dist/chunk-OHSV42QB.js +748 -0
- package/dist/chunk-OO3TAHO5.js +4070 -0
- package/dist/chunk-OTNHSAGN.js +38282 -0
- package/dist/chunk-OUWAC7AQ.js +442 -0
- package/dist/chunk-OXMIV4WE.js +270 -0
- package/dist/chunk-P5KJURUR.js +229 -0
- package/dist/chunk-P6GJOVO6.js +307 -0
- package/dist/chunk-QARAGUXX.js +23 -0
- package/dist/chunk-R43HJCDX.js +2711 -0
- package/dist/chunk-RAXBAWRN.js +210 -0
- package/dist/chunk-RK3JHWPT.js +39 -0
- package/dist/chunk-RWA23GMM.js +24 -0
- package/dist/chunk-S4K4L6IM.js +179 -0
- package/dist/chunk-SAXK6LVF.js +124 -0
- package/dist/chunk-SEPGEJNK.js +1607 -0
- package/dist/chunk-SUJERP5I.js +285 -0
- package/dist/chunk-T3ED6BY2.js +913 -0
- package/dist/chunk-THKDVSEC.js +90 -0
- package/dist/chunk-TI4GSEL5.js +52 -0
- package/dist/chunk-TPI73L57.js +164 -0
- package/dist/chunk-TVHW77C7.js +338 -0
- package/dist/chunk-TWNHOSDT.js +1073 -0
- package/dist/chunk-UFMN76QD.js +347 -0
- package/dist/chunk-UHGLFRZE.js +205 -0
- package/dist/chunk-UTZYPKBF.js +15231 -0
- package/dist/chunk-UXNLELW6.js +25 -0
- package/dist/chunk-UXXS53EA.js +166 -0
- package/dist/chunk-V5DHFGI7.js +171 -0
- package/dist/chunk-V5YIPMHV.js +2353 -0
- package/dist/chunk-WMUWEO2C.js +754 -0
- package/dist/chunk-WOE3D7JM.js +945 -0
- package/dist/chunk-X2IK5LVR.js +2592 -0
- package/dist/chunk-XU2YXCDL.js +459 -0
- package/dist/chunk-YJG5HIX5.js +203 -0
- package/dist/chunk-Z3QE7TZM.js +72 -0
- package/dist/chunk-Z5Z3JHJY.js +64 -0
- package/dist/chunk-ZDIFBJFT.js +168 -0
- package/dist/chunk-ZGGCEXDC.js +176 -0
- package/dist/chunk-ZMZCZNKU.js +263 -0
- package/dist/chunk-ZNC5T65N.js +17 -0
- package/dist/chunk-ZO3I3A7O.js +308 -0
- package/dist/chunk-ZQKXBUB7.js +217 -0
- package/dist/chunk-ZTRINFM2.js +78 -0
- package/dist/chunk-ZU7JZCVP.js +193 -0
- package/dist/chunk-ZZAWNALS.js +350 -0
- package/dist/cli/entry.js +54 -0
- package/dist/connector-L5QQTR6Y.js +26 -0
- package/dist/context-62DC6EC3.js +31 -0
- package/dist/council-convene-NJWPNBDU.js +46 -0
- package/dist/create-agent-config-ODSQWNVC.js +55 -0
- package/dist/default-registry-2PU3BTAU.js +68 -0
- package/dist/deliver-task-KONV4C4M.js +57 -0
- package/dist/delivery-gate-v2-F2YVMVGK.js +27 -0
- package/dist/domain-knowledge-store-DDZ3F4J7.js +11 -0
- package/dist/fetch-core-ZPPYDSZH.js +14 -0
- package/dist/galaxy-K72BBDQN.js +91 -0
- package/dist/goal-criteria-SCALAU2D.js +141 -0
- package/dist/goal-persist-XWY2GDQX.js +19 -0
- package/dist/goal-tracker-FXMJ2GVK.js +11 -0
- package/dist/headless-LSB6I7PT.js +162 -0
- package/dist/headless-coordinator-VDPDMVUT.js +90 -0
- package/dist/inject-U55SMB6A.js +39 -0
- package/dist/login-flow-CD4ZGXOC.js +59 -0
- package/dist/logs-cli-SQVYFMMN.js +283 -0
- package/dist/loop-ULZYBDA3.js +76 -0
- package/dist/main.js +4064 -0
- package/dist/manager-ROZBCWPA.js +171 -0
- package/dist/manager-Z7XFFUOM.js +10670 -0
- package/dist/meridian-indexer-ZIW363L7.js +21 -0
- package/dist/native-resolver-PN34UIVV.js +13 -0
- package/dist/node_modules/better-sqlite3/lib/database.js +90 -0
- package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/node_modules/better-sqlite3/package.json +59 -0
- package/dist/ownership-ledger-E3WIEKPL.js +9 -0
- package/dist/package.json +3 -0
- package/dist/path-grants-XRRXHXG7.js +40 -0
- package/dist/paths-LVV5IMQN.js +49 -0
- package/dist/plan-fact-anchors-LMVQZCW5.js +13 -0
- package/dist/plan-store-ODLTTPFB.js +17 -0
- package/dist/plan-templates-5FPFBOL6.js +109 -0
- package/dist/plugin-loader-ZZKX7ZE6.js +22 -0
- package/dist/prefix-budget-62OV5HQC.js +13 -0
- package/dist/project-trust-5WS5MOMU.js +31 -0
- package/dist/provider-cli-ALDQXIT7.js +37 -0
- package/dist/providers-XQYTAVPK.js +11 -0
- package/dist/proxy-resolver-V2Y6534D.js +15 -0
- package/dist/recovery-cli-KPGY6FY3.js +106 -0
- package/dist/review-discipline-MNSYCST5.js +55 -0
- package/dist/review-router-BVQZW3MX.js +18 -0
- package/dist/seed-capsules/seed-capsule-attack-methodology.md +62 -0
- package/dist/seed-capsules/seed-capsule-changgeng.md +31 -0
- package/dist/seed-capsules/seed-capsule-design-aesthetics.md +38 -0
- package/dist/seed-capsules/seed-capsule-diagnostic-ladder.md +54 -0
- package/dist/seed-capsules/seed-capsule-fu.md +39 -0
- package/dist/seed-capsules/seed-capsule-huagai.md +73 -0
- package/dist/seed-capsules/seed-capsule-kaiyang.md +65 -0
- package/dist/seed-capsules/seed-capsule-knowledge-work.md +40 -0
- package/dist/seed-capsules/seed-capsule-tanlang.md +47 -0
- package/dist/seed-capsules/seed-capsule-tianfu.md +23 -0
- package/dist/seed-capsules/seed-capsule-tianliang.md +63 -0
- package/dist/seed-capsules/seed-capsule-tianquan.md +32 -0
- package/dist/seed-capsules/seed-capsule-tianxuan-ccr.md +22 -0
- package/dist/seed-capsules/seed-capsule-tianxuan.md +64 -0
- package/dist/seed-capsules/seed-capsule-yaoguang.md +87 -0
- package/dist/serve-X2R2UTLF.js +170 -0
- package/dist/serve-agent-KHSU6RVV.js +965 -0
- package/dist/session-persist-HUUC772H.js +37 -0
- package/dist/session-registry-6XUD5C4Y.js +15 -0
- package/dist/skill-loader-CK3RMO47.js +48 -0
- package/dist/skills/cli-harness-sop.md +207 -0
- package/dist/spawn-git-4HFU65AH.js +29 -0
- package/dist/sse-EYUTBWUK.js +512 -0
- package/dist/starflow-NOFBMPFU.js +30 -0
- package/dist/streamableHttp-V67CNJMO.js +447 -0
- package/dist/task-contract-6XHBNJQK.js +32 -0
- package/dist/task-ledger-3K4TJIER.js +9 -0
- package/dist/team-orchestrate-S6NHZP7X.js +64 -0
- package/dist/title-extract-QX4XGCYN.js +50 -0
- package/dist/todo-QDXGRZZP.js +31 -0
- package/dist/todo-store-V3TTO5AH.js +12 -0
- package/dist/tool-preset-LU5BYEDZ.js +23 -0
- package/dist/tool-tiers-GD742YBN.js +23 -0
- package/dist/turndown.es-OI55K6C3.js +17373 -0
- package/dist/verification-attribution-EKG4CNUV.js +13 -0
- package/dist/volatile-git-MBTST7RA.js +15 -0
- package/dist/wave-checkpoint-XLIIHXQA.js +30 -0
- package/dist/web-cli-DUG4I35O.js +233 -0
- package/dist/web-search-3IK542AA.js +34 -0
- package/dist/workers/cpu-worker.js +45 -0
- package/dist/workflow-runner-HX7UBAYG.js +297 -0
- package/dist/worktree-baseline-O5NCU6M2.js +9 -0
- package/package.json +122 -0
- package/scripts/check-mobile-env.mjs +76 -0
- package/scripts/fetch-native-sqlite.js +392 -0
- package/scripts/prune-installed-wasms.js +45 -0
- package/scripts/tree-sitter-wasm-keep.js +40 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-5GGOGLSN.js";
|
|
6
|
+
|
|
7
|
+
// src/server/workspace.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
import { homedir } from "os";
|
|
10
|
+
import { mkdirSync, statSync } from "fs";
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
function expandTilde(raw, home) {
|
|
13
|
+
if (raw === "~") return home;
|
|
14
|
+
if (raw.startsWith("~/") || raw.startsWith("~\\")) return join(home, raw.slice(2));
|
|
15
|
+
return raw;
|
|
16
|
+
}
|
|
17
|
+
function clean(value) {
|
|
18
|
+
return typeof value === "string" ? value.trim() : "";
|
|
19
|
+
}
|
|
20
|
+
function resolveSessionWorkspace(input) {
|
|
21
|
+
const home = input.homeDir ?? homedir();
|
|
22
|
+
const requested = clean(input.requested);
|
|
23
|
+
if (requested) {
|
|
24
|
+
return { path: expandTilde(requested, home), source: "explicit", managed: false };
|
|
25
|
+
}
|
|
26
|
+
const mode = input.mode ?? "explicit";
|
|
27
|
+
if (mode === "scratch") {
|
|
28
|
+
const key = clean(input.sessionId).slice(0, 8) || "session";
|
|
29
|
+
return { path: join(input.scratchRoot, key), source: "scratch", managed: true };
|
|
30
|
+
}
|
|
31
|
+
if (mode === "default") {
|
|
32
|
+
const configured = clean(input.configDefaultDir);
|
|
33
|
+
if (configured) {
|
|
34
|
+
return { path: expandTilde(configured, home), source: "config-default", managed: false };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { path: input.processCwd, source: "runtime-default", managed: false };
|
|
38
|
+
}
|
|
39
|
+
function sessionScratchRoot(rivetHome) {
|
|
40
|
+
return join(rivetHome, "workspace");
|
|
41
|
+
}
|
|
42
|
+
var SESSION_WORKSPACE_MODES = ["explicit", "default", "scratch"];
|
|
43
|
+
function isSessionWorkspaceMode(value) {
|
|
44
|
+
return typeof value === "string" && SESSION_WORKSPACE_MODES.includes(value);
|
|
45
|
+
}
|
|
46
|
+
function resolveSessionWorkspaceForSession(input) {
|
|
47
|
+
let wsConfig = {};
|
|
48
|
+
try {
|
|
49
|
+
wsConfig = input.readConfig().workspace ?? {};
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
const resolved = resolveSessionWorkspace({
|
|
53
|
+
requested: input.requested,
|
|
54
|
+
mode: input.mode,
|
|
55
|
+
configDefaultDir: wsConfig.defaultDir,
|
|
56
|
+
processCwd: input.processCwd,
|
|
57
|
+
scratchRoot: wsConfig.scratchDir ?? sessionScratchRoot(input.rivetHome),
|
|
58
|
+
sessionId: input.sessionId
|
|
59
|
+
});
|
|
60
|
+
if (!resolved.managed) {
|
|
61
|
+
if (resolved.source === "config-default" && !isUsableDirectory(resolved.path)) {
|
|
62
|
+
return { path: input.processCwd, source: "runtime-default", managed: false };
|
|
63
|
+
}
|
|
64
|
+
return resolved;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
mkdirSync(resolved.path, { recursive: true });
|
|
68
|
+
return resolved;
|
|
69
|
+
} catch {
|
|
70
|
+
return { path: input.processCwd, source: "runtime-default", managed: false };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function isUsableDirectory(path) {
|
|
74
|
+
try {
|
|
75
|
+
return statSync(path).isDirectory();
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
sessionScratchRoot,
|
|
83
|
+
isSessionWorkspaceMode,
|
|
84
|
+
resolveSessionWorkspaceForSession
|
|
85
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
expandHome
|
|
5
|
+
} from "./chunk-ETHFACAB.js";
|
|
6
|
+
import {
|
|
7
|
+
init_esm_shims
|
|
8
|
+
} from "./chunk-5GGOGLSN.js";
|
|
9
|
+
|
|
10
|
+
// src/tools/open-path.ts
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
import { execFileSync, spawn } from "child_process";
|
|
13
|
+
import { existsSync, statSync } from "fs";
|
|
14
|
+
import { dirname, extname, resolve } from "path";
|
|
15
|
+
function normalizeOpenTarget(path, platform) {
|
|
16
|
+
const expanded = expandHome(path);
|
|
17
|
+
if (platform === "win32" && /^(?:[a-zA-Z]:[\\/]|\\\\)/.test(expanded)) {
|
|
18
|
+
return expanded;
|
|
19
|
+
}
|
|
20
|
+
return resolve(expanded);
|
|
21
|
+
}
|
|
22
|
+
function buildOpenPathCommand(path, platform = process.platform) {
|
|
23
|
+
const target = normalizeOpenTarget(path, platform);
|
|
24
|
+
if (platform === "win32") {
|
|
25
|
+
const winTarget = target.replace(/\//g, "\\");
|
|
26
|
+
const literal = `'${winTarget.replace(/'/g, "''")}'`;
|
|
27
|
+
return {
|
|
28
|
+
cmd: "powershell.exe",
|
|
29
|
+
args: ["-NoProfile", "-NonInteractive", "-Command", `Start-Process -FilePath ${literal}`]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (platform === "darwin") {
|
|
33
|
+
return { cmd: "open", args: [target] };
|
|
34
|
+
}
|
|
35
|
+
return { cmd: "xdg-open", args: [target] };
|
|
36
|
+
}
|
|
37
|
+
function buildRevealCommand(path, platform = process.platform) {
|
|
38
|
+
const target = normalizeOpenTarget(path, platform);
|
|
39
|
+
if (platform === "win32") {
|
|
40
|
+
const winTarget = target.replace(/\//g, "\\");
|
|
41
|
+
const literal = `'${winTarget.replace(/'/g, "''")}'`;
|
|
42
|
+
return {
|
|
43
|
+
cmd: "powershell.exe",
|
|
44
|
+
args: ["-NoProfile", "-NonInteractive", "-Command", `explorer /select,${literal}`]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (platform === "darwin") {
|
|
48
|
+
return { cmd: "open", args: ["-R", target] };
|
|
49
|
+
}
|
|
50
|
+
return { cmd: "xdg-open", args: [dirname(target)] };
|
|
51
|
+
}
|
|
52
|
+
function defaultRegQuery(key, value) {
|
|
53
|
+
const reg = process.env.SystemRoot ? `${process.env.SystemRoot}\\System32\\reg.exe` : "reg.exe";
|
|
54
|
+
return execFileSync(reg, ["query", key, value === "" ? "/ve" : "/v", ...value === "" ? [] : [value]], {
|
|
55
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
56
|
+
windowsHide: true
|
|
57
|
+
}).toString();
|
|
58
|
+
}
|
|
59
|
+
function windowsFileHasHandler(filePath, platform = process.platform, query = defaultRegQuery) {
|
|
60
|
+
if (platform !== "win32") return void 0;
|
|
61
|
+
const ext = extname(filePath);
|
|
62
|
+
if (!ext || !/^\.[A-Za-z0-9_+-]+$/.test(ext)) return void 0;
|
|
63
|
+
try {
|
|
64
|
+
if (/ProgId\s+REG_SZ\s+\S+/.test(query(
|
|
65
|
+
`HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\${ext}\\UserChoice`,
|
|
66
|
+
"ProgId"
|
|
67
|
+
))) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
let progId;
|
|
73
|
+
try {
|
|
74
|
+
const out = query(`HKEY_CLASSES_ROOT\\${ext}`, "");
|
|
75
|
+
progId = out.match(/REG_SZ\s+(\S+)/)?.[1];
|
|
76
|
+
} catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (!progId) return void 0;
|
|
80
|
+
try {
|
|
81
|
+
query(`HKEY_CLASSES_ROOT\\${progId}\\shell\\open\\command`, "");
|
|
82
|
+
return true;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function decideOpenAction(input) {
|
|
88
|
+
if (input.platform !== "win32") return "open";
|
|
89
|
+
if (input.isDirectory) return "open";
|
|
90
|
+
return input.hasHandler === false ? "reveal" : "open";
|
|
91
|
+
}
|
|
92
|
+
function isDirectoryPath(path) {
|
|
93
|
+
try {
|
|
94
|
+
return statSync(path).isDirectory();
|
|
95
|
+
} catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var OPEN_PATH_TOOL = {
|
|
100
|
+
definition: {
|
|
101
|
+
name: "open_path",
|
|
102
|
+
description: `\u5728\u7528\u6237\u64CD\u4F5C\u7CFB\u7EDF\u4E2D\u6253\u5F00\u6587\u4EF6\u6216\u76EE\u5F55\u3002
|
|
103
|
+
|
|
104
|
+
\u7528\u4E8E\u7528\u6237\u53EF\u89C1\u6587\u4EF6\uFF0C\u5982\u751F\u6210\u7684\u56FE\u7247\u3001SVG\u3001PDF \u6216\u6587\u4EF6\u5939\u3002\u63A5\u53D7\u5916\u90E8\u8DEF\u5F84\uFF08\u684C\u9762\u3001\u4E0B\u8F7D\u3001\u6302\u8F7D\u76D8\u3001Windows \u8DEF\u5F84\uFF09\uFF0C\u901A\u8FC7\u76F4\u63A5\u542F\u52A8 OS \u6253\u5F00\u5668\u907F\u514D shell \u5F15\u7528\u95EE\u9898\u3002
|
|
105
|
+
|
|
106
|
+
\u793A\u4F8B\uFF1A
|
|
107
|
+
Good: open_path(path="~/Desktop/tianshu-logo.svg")
|
|
108
|
+
Good: open_path(path="H:\\zhuomian\\\u767D\u5AD6gpt")
|
|
109
|
+
Bad: \u7528 bash explorer/open/start \u547D\u4EE4\u52A0\u624B\u5199 shell \u5F15\u53F7`,
|
|
110
|
+
input_schema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
path: { type: "string", description: "\u7EDD\u5BF9\u8DEF\u5F84\u6216 ~ \u76F8\u5BF9\u8DEF\u5F84\uFF0C\u8981\u6253\u5F00\u7684\u6587\u4EF6/\u76EE\u5F55\u3002\u53EF\u5728\u9879\u76EE\u4E4B\u5916\u3002" }
|
|
114
|
+
},
|
|
115
|
+
required: ["path"]
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
async execute(params) {
|
|
119
|
+
const raw = params.input.path;
|
|
120
|
+
if (typeof raw !== "string" || raw.trim().length === 0) {
|
|
121
|
+
return { content: "\u9519\u8BEF\uFF1Apath \u4E3A\u5FC5\u586B\u9879", isError: true };
|
|
122
|
+
}
|
|
123
|
+
const target = resolve(expandHome(raw.trim()));
|
|
124
|
+
if (!existsSync(target)) {
|
|
125
|
+
return { content: `\u9519\u8BEF\uFF1A\u8DEF\u5F84\u4E0D\u5B58\u5728\uFF1A${target}`, isError: true };
|
|
126
|
+
}
|
|
127
|
+
const isDir = isDirectoryPath(target);
|
|
128
|
+
const action = decideOpenAction({
|
|
129
|
+
platform: process.platform,
|
|
130
|
+
isDirectory: isDir,
|
|
131
|
+
hasHandler: isDir ? void 0 : windowsFileHasHandler(target)
|
|
132
|
+
});
|
|
133
|
+
const command = action === "reveal" ? buildRevealCommand(target) : buildOpenPathCommand(target);
|
|
134
|
+
const verb = action === "reveal" ? "\u5DF2\u5728\u8D44\u6E90\u7BA1\u7406\u5668\u4E2D\u5B9A\u4F4D" : "\u5DF2\u6253\u5F00";
|
|
135
|
+
return new Promise((resolveResult) => {
|
|
136
|
+
const child = spawn(command.cmd, command.args, { detached: true, stdio: "ignore", windowsHide: true });
|
|
137
|
+
child.on("error", (err) => {
|
|
138
|
+
resolveResult({ content: `${action === "reveal" ? "\u5B9A\u4F4D" : "\u6253\u5F00"} ${target} \u65F6\u51FA\u9519\uFF1A${err.message}`, isError: true });
|
|
139
|
+
});
|
|
140
|
+
child.on("spawn", () => {
|
|
141
|
+
child.unref();
|
|
142
|
+
resolveResult({ content: `${verb}\uFF1A${target}` });
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
requiresApproval: () => true,
|
|
147
|
+
isConcurrencySafe: () => true,
|
|
148
|
+
isEnabled: () => true
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
buildOpenPathCommand,
|
|
153
|
+
buildRevealCommand,
|
|
154
|
+
windowsFileHasHandler,
|
|
155
|
+
decideOpenAction,
|
|
156
|
+
isDirectoryPath,
|
|
157
|
+
OPEN_PATH_TOOL
|
|
158
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --expose-gc --max-old-space-size=4096
|
|
2
|
+
import { createRequire as __rivetCreateRequire } from 'node:module'; const require = __rivetCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
init_esm_shims
|
|
5
|
+
} from "./chunk-5GGOGLSN.js";
|
|
6
|
+
|
|
7
|
+
// src/path-format.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
import { relative } from "path";
|
|
10
|
+
function toPosixPath(filePath) {
|
|
11
|
+
return filePath.replaceAll("\\", "/");
|
|
12
|
+
}
|
|
13
|
+
function relativePosix(from, to) {
|
|
14
|
+
return toPosixPath(relative(from, to));
|
|
15
|
+
}
|
|
16
|
+
function canonicalPathKey(filePath, platform = process.platform) {
|
|
17
|
+
if (platform !== "win32") return filePath;
|
|
18
|
+
return toPosixPath(filePath).toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
function translateWindowsShellPath(inputPath, platform = process.platform) {
|
|
21
|
+
if (platform !== "win32") return inputPath;
|
|
22
|
+
return inputPath.replace(/^\/([a-zA-Z]):(?=[\\/]|$)/, (_, d) => `${d.toUpperCase()}:`).replace(/^\/(?:cygdrive|mnt)\/([a-zA-Z])(?=\/|$)/, (_, d) => `${d.toUpperCase()}:`).replace(/^\/([a-zA-Z])(?=\/|$)/, (_, d) => `${d.toUpperCase()}:`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
toPosixPath,
|
|
27
|
+
relativePosix,
|
|
28
|
+
canonicalPathKey,
|
|
29
|
+
translateWindowsShellPath
|
|
30
|
+
};
|