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,245 @@
|
|
|
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/plan/plan-fact-anchors.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
import { stat, readFile } from "fs/promises";
|
|
10
|
+
import { readdirSync } from "fs";
|
|
11
|
+
import { resolve, relative, isAbsolute, join, dirname, basename } from "path";
|
|
12
|
+
var EXTENSIONS = [
|
|
13
|
+
"ts",
|
|
14
|
+
"tsx",
|
|
15
|
+
"js",
|
|
16
|
+
"jsx",
|
|
17
|
+
"mjs",
|
|
18
|
+
"cjs",
|
|
19
|
+
"mts",
|
|
20
|
+
"cts",
|
|
21
|
+
"json",
|
|
22
|
+
"jsonc",
|
|
23
|
+
"md",
|
|
24
|
+
"mdx",
|
|
25
|
+
"txt",
|
|
26
|
+
"css",
|
|
27
|
+
"scss",
|
|
28
|
+
"less",
|
|
29
|
+
"html",
|
|
30
|
+
"vue",
|
|
31
|
+
"svelte",
|
|
32
|
+
"py",
|
|
33
|
+
"rs",
|
|
34
|
+
"go",
|
|
35
|
+
"java",
|
|
36
|
+
"kt",
|
|
37
|
+
"rb",
|
|
38
|
+
"php",
|
|
39
|
+
"c",
|
|
40
|
+
"h",
|
|
41
|
+
"cpp",
|
|
42
|
+
"hpp",
|
|
43
|
+
"cs",
|
|
44
|
+
"swift",
|
|
45
|
+
"sh",
|
|
46
|
+
"bash",
|
|
47
|
+
"zsh",
|
|
48
|
+
"ps1",
|
|
49
|
+
"bat",
|
|
50
|
+
"yml",
|
|
51
|
+
"yaml",
|
|
52
|
+
"toml",
|
|
53
|
+
"ini",
|
|
54
|
+
"env.example",
|
|
55
|
+
"sql",
|
|
56
|
+
"graphql",
|
|
57
|
+
"proto"
|
|
58
|
+
];
|
|
59
|
+
var EXT_ALTERNATION = [...EXTENSIONS].sort((a, b) => b.length - a.length).map((ext) => ext.replace(/\./g, String.raw`\.`)).join("|");
|
|
60
|
+
var PATH_TOKEN_RE = new RegExp(
|
|
61
|
+
String.raw`(?<![\w./\\-])((?:[\w.@-]+/)+[\w.@-]+\.(?:${EXT_ALTERNATION}))(?!\w)(?::(\d+)(?:-\d+)?)?`,
|
|
62
|
+
"g"
|
|
63
|
+
);
|
|
64
|
+
var KNOWN_EXT_TAIL_RE = new RegExp(String.raw`\.(?:${EXT_ALTERNATION})$`, "i");
|
|
65
|
+
function hasFileShapedIntermediateSegment(path) {
|
|
66
|
+
const segments = path.split("/");
|
|
67
|
+
return segments.slice(0, -1).some((s) => KNOWN_EXT_TAIL_RE.test(s));
|
|
68
|
+
}
|
|
69
|
+
var PLACEHOLDER_BASENAMES = /* @__PURE__ */ new Set(["foo", "bar", "baz", "qux", "quux", "example", "sample", "demo", "dummy", "placeholder"]);
|
|
70
|
+
function isPlaceholderShaped(path) {
|
|
71
|
+
const base = (path.split("/").pop() ?? path).replace(/\.[^.]*$/, "").toLowerCase();
|
|
72
|
+
return PLACEHOLDER_BASENAMES.has(base) || /^[a-z]$/.test(base);
|
|
73
|
+
}
|
|
74
|
+
var NEW_FILE_MARKER_RE = /新增|新建|创建|\bnew file\b|\bcreate[ds]?\b/i;
|
|
75
|
+
var CHECKABLE_FENCE_LANGS = /* @__PURE__ */ new Set(["bash", "sh", "shell", "zsh", "console", ""]);
|
|
76
|
+
var LINE_CHECK_MAX_BYTES = 2 * 1024 * 1024;
|
|
77
|
+
var MAX_ANCHORS = 200;
|
|
78
|
+
function extractPlanAnchors(content) {
|
|
79
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
80
|
+
let inFence = false;
|
|
81
|
+
let fenceLang = "";
|
|
82
|
+
for (const line of content.split("\n")) {
|
|
83
|
+
const fenceMatch = line.match(/^\s*```([\w-]*)/);
|
|
84
|
+
if (fenceMatch) {
|
|
85
|
+
inFence = !inFence;
|
|
86
|
+
fenceLang = inFence ? (fenceMatch[1] ?? "").toLowerCase() : "";
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (inFence && !CHECKABLE_FENCE_LANGS.has(fenceLang)) continue;
|
|
90
|
+
const declaredNew = NEW_FILE_MARKER_RE.test(line);
|
|
91
|
+
for (const match of line.matchAll(PATH_TOKEN_RE)) {
|
|
92
|
+
const rawPath = match[1];
|
|
93
|
+
if (rawPath.startsWith("./") || rawPath.includes("..")) continue;
|
|
94
|
+
if (rawPath.includes("node_modules/")) continue;
|
|
95
|
+
if (hasFileShapedIntermediateSegment(rawPath)) continue;
|
|
96
|
+
const lineNo = match[2] ? Number.parseInt(match[2], 10) : void 0;
|
|
97
|
+
const key = `${rawPath}:${lineNo ?? ""}`;
|
|
98
|
+
const existing = anchors.get(key);
|
|
99
|
+
if (existing) {
|
|
100
|
+
if (declaredNew && !existing.declaredNew) existing.declaredNew = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
anchors.set(key, { raw: match[0], path: rawPath, line: lineNo, declaredNew, placeholderShaped: isPlaceholderShaped(rawPath) });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return [...anchors.values()];
|
|
107
|
+
}
|
|
108
|
+
function isInsideProject(cwd, inputPath) {
|
|
109
|
+
const rel = relative(resolve(cwd), resolve(cwd, inputPath));
|
|
110
|
+
return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
|
|
111
|
+
}
|
|
112
|
+
var REROOT_EXCLUDE_DIRS = /* @__PURE__ */ new Set(["node_modules", "dist"]);
|
|
113
|
+
var REROOT_PROBE_BUDGET = 128;
|
|
114
|
+
var MAX_ROOT_ENUM = 512;
|
|
115
|
+
function listSubdirs(dir) {
|
|
116
|
+
try {
|
|
117
|
+
return readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".") && !REROOT_EXCLUDE_DIRS.has(e.name)).map((e) => e.name);
|
|
118
|
+
} catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function createRerootProbe(cwd) {
|
|
123
|
+
return {
|
|
124
|
+
cwd,
|
|
125
|
+
parent: dirname(cwd),
|
|
126
|
+
selfName: basename(cwd),
|
|
127
|
+
probes: 0,
|
|
128
|
+
roots: null,
|
|
129
|
+
firstLevel: /* @__PURE__ */ new Map()
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function probeSpend(p) {
|
|
133
|
+
if (p.probes >= REROOT_PROBE_BUDGET) return false;
|
|
134
|
+
p.probes += 1;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
function ensureRerootRoots(p) {
|
|
138
|
+
if (p.roots) return p.roots;
|
|
139
|
+
if (!probeSpend(p)) return null;
|
|
140
|
+
const subs = listSubdirs(p.cwd).slice(0, MAX_ROOT_ENUM);
|
|
141
|
+
const roots = subs.map((n) => ({ label: `${n}/`, abs: join(p.cwd, n) }));
|
|
142
|
+
if (p.parent !== p.cwd) {
|
|
143
|
+
if (!probeSpend(p)) {
|
|
144
|
+
p.roots = roots;
|
|
145
|
+
return roots;
|
|
146
|
+
}
|
|
147
|
+
const siblings = listSubdirs(p.parent).filter((n) => n !== p.selfName).slice(0, MAX_ROOT_ENUM);
|
|
148
|
+
roots.push(...siblings.map((n) => ({ label: `../${n}/`, abs: join(p.parent, n) })));
|
|
149
|
+
}
|
|
150
|
+
p.roots = roots;
|
|
151
|
+
return roots;
|
|
152
|
+
}
|
|
153
|
+
function rootFirstLevel(p, rootAbs) {
|
|
154
|
+
const cached = p.firstLevel.get(rootAbs);
|
|
155
|
+
if (cached) return cached;
|
|
156
|
+
if (!probeSpend(p)) return null;
|
|
157
|
+
const set = new Set(listSubdirs(rootAbs));
|
|
158
|
+
p.firstLevel.set(rootAbs, set);
|
|
159
|
+
return set;
|
|
160
|
+
}
|
|
161
|
+
async function probeReroot(p, rel) {
|
|
162
|
+
if (!probeSpend(p)) return null;
|
|
163
|
+
const parentHit = await stat(join(p.parent, rel)).catch(() => null);
|
|
164
|
+
if (parentHit?.isFile()) return { label: "../", abs: p.parent };
|
|
165
|
+
const roots = ensureRerootRoots(p);
|
|
166
|
+
if (!roots) return null;
|
|
167
|
+
const s1 = rel.split("/")[0];
|
|
168
|
+
for (const root of roots) {
|
|
169
|
+
const first = rootFirstLevel(p, root.abs);
|
|
170
|
+
if (!first) return null;
|
|
171
|
+
if (!first.has(s1)) continue;
|
|
172
|
+
if (!probeSpend(p)) return null;
|
|
173
|
+
const hit = await stat(join(root.abs, rel)).catch(() => null);
|
|
174
|
+
if (hit?.isFile()) return root;
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
async function checkPlanFactAnchors(content, cwd) {
|
|
179
|
+
const anchors = extractPlanAnchors(content).slice(0, MAX_ANCHORS);
|
|
180
|
+
const drifts = [];
|
|
181
|
+
let checked = 0;
|
|
182
|
+
const pendingReroot = [];
|
|
183
|
+
let probe = null;
|
|
184
|
+
const declaredNewPaths = new Set(anchors.filter((a) => a.declaredNew).map((a) => a.path));
|
|
185
|
+
for (const anchor of anchors) {
|
|
186
|
+
if (!isInsideProject(cwd, anchor.path)) continue;
|
|
187
|
+
checked += 1;
|
|
188
|
+
const absolute = resolve(cwd, anchor.path);
|
|
189
|
+
if (anchor.declaredNew || declaredNewPaths.has(anchor.path)) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const fileStat = await stat(absolute).catch(() => null);
|
|
193
|
+
if (!fileStat || !fileStat.isFile()) {
|
|
194
|
+
pendingReroot.push(anchor);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (anchor.line !== void 0 && fileStat.size <= LINE_CHECK_MAX_BYTES) {
|
|
198
|
+
const text = await readFile(absolute, "utf-8").catch(() => null);
|
|
199
|
+
if (text !== null) {
|
|
200
|
+
const lineCount = text.split("\n").length;
|
|
201
|
+
if (anchor.line > lineCount) {
|
|
202
|
+
drifts.push({
|
|
203
|
+
anchor: anchor.raw,
|
|
204
|
+
path: anchor.path,
|
|
205
|
+
line: anchor.line,
|
|
206
|
+
kind: "line-out-of-range",
|
|
207
|
+
detail: `\u8BA1\u5212\u5F15\u7528 \`${anchor.raw}\`\uFF0C\u4F46\u8BE5\u6587\u4EF6\u5F53\u524D\u53EA\u6709 ${lineCount} \u884C\u2014\u2014\u884C\u53F7\u951A\u70B9\u5DF2\u6F02\u79FB\uFF0C\u91CD\u8BFB\u6587\u4EF6\u66F4\u65B0\u5F15\u7528\u3002`
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (pendingReroot.length > 0) {
|
|
214
|
+
probe ??= createRerootProbe(cwd);
|
|
215
|
+
for (const anchor of pendingReroot) {
|
|
216
|
+
const hit = await probeReroot(probe, anchor.path);
|
|
217
|
+
if (hit) {
|
|
218
|
+
drifts.push({
|
|
219
|
+
anchor: anchor.raw,
|
|
220
|
+
path: anchor.path,
|
|
221
|
+
kind: "root-mismatch",
|
|
222
|
+
detail: `\u8BA1\u5212\u5F15\u7528 \`${anchor.raw}\`\uFF0C\u76F8\u5BF9\u4F1A\u8BDD\u76EE\u5F55\u4E0D\u5B58\u5728\uFF0C\u4F46\u5B9E\u9645\u4F4D\u4E8E \`${hit.label}${anchor.path}\`\u2014\u2014\u628A\u5F15\u7528\u8865\u5168\u4E3A\u5E26\u6839\u524D\u7F00\u7684\u8DEF\u5F84\uFF0C\u6216\u786E\u8BA4\u6267\u884C\u76EE\u5F55\u540E\u518D\u52A8\u624B\u3002`
|
|
223
|
+
});
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (anchor.placeholderShaped) continue;
|
|
227
|
+
drifts.push({
|
|
228
|
+
anchor: anchor.raw,
|
|
229
|
+
path: anchor.path,
|
|
230
|
+
kind: "missing-file",
|
|
231
|
+
detail: `\u8BA1\u5212\u5F15\u7528 \`${anchor.raw}\`\uFF0C\u4F46\u8BE5\u6587\u4EF6\u5728\u5F53\u524D\u9879\u76EE\u4E2D\u4E0D\u5B58\u5728\u2014\u2014\u7528\u5DE5\u5177\u6838\u5B9E\u771F\u5B9E\u8DEF\u5F84\uFF0C\u6216\u5982\u679C\u662F\u6709\u610F\u65B0\u5EFA\u8BF7\u6807\u6CE8\u300C\u65B0\u589E\u300D\u3002`
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return { checked, drifts, rerootProbes: probe?.probes ?? 0 };
|
|
236
|
+
}
|
|
237
|
+
function formatAnchorDrifts(drifts) {
|
|
238
|
+
return drifts.map((d) => `- ${d.detail}`).join("\n");
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
extractPlanAnchors,
|
|
243
|
+
checkPlanFactAnchors,
|
|
244
|
+
formatAnchorDrifts
|
|
245
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
OFF_TOPIC_ERROR,
|
|
5
|
+
runBackendChain
|
|
6
|
+
} from "./chunk-EBJTVRQN.js";
|
|
7
|
+
import {
|
|
8
|
+
DuckDuckGoBackend,
|
|
9
|
+
createProxyAwareFetch
|
|
10
|
+
} from "./chunk-J4U4AW46.js";
|
|
11
|
+
import {
|
|
12
|
+
init_esm_shims
|
|
13
|
+
} from "./chunk-5GGOGLSN.js";
|
|
14
|
+
|
|
15
|
+
// src/tools/web-search.ts
|
|
16
|
+
init_esm_shims();
|
|
17
|
+
|
|
18
|
+
// src/tools/web-search/tool.ts
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
|
|
21
|
+
// src/tools/lenient.ts
|
|
22
|
+
init_esm_shims();
|
|
23
|
+
function lenientString(v) {
|
|
24
|
+
if (typeof v === "string") return v;
|
|
25
|
+
if (typeof v === "number" || typeof v === "boolean") return String(v);
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
function lenientNumber(v) {
|
|
29
|
+
if (typeof v === "number") {
|
|
30
|
+
return Number.isFinite(v) ? v : void 0;
|
|
31
|
+
}
|
|
32
|
+
if (typeof v === "string" && v.trim().length > 0) {
|
|
33
|
+
const n = Number(v);
|
|
34
|
+
return Number.isFinite(n) ? n : void 0;
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
function lenientPositiveNumber(v) {
|
|
39
|
+
const n = lenientNumber(v);
|
|
40
|
+
return n !== void 0 && n >= 1 ? n : void 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/tools/web-search/tool.ts
|
|
44
|
+
var MAX_RESULTS = 20;
|
|
45
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
46
|
+
function createWebSearchTool(deps = {}) {
|
|
47
|
+
const fetchImpl = deps.fetch ?? createProxyAwareFetch(deps.proxy);
|
|
48
|
+
const backends = deps.backends && deps.backends.length > 0 ? deps.backends : [new DuckDuckGoBackend(fetchImpl)];
|
|
49
|
+
const timeoutMs = deps.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
50
|
+
return {
|
|
51
|
+
definition: {
|
|
52
|
+
name: "web_search",
|
|
53
|
+
description: `\u641C\u7D22 Web \u83B7\u53D6\u5B9E\u65F6\u4FE1\u606F\u3002\u7ED3\u679C\u5305\u542B\u6807\u9898\u3001URL \u548C\u5185\u5BB9\u6458\u8981\u3002
|
|
54
|
+
|
|
55
|
+
### \u4F55\u65F6\u641C\u7D22
|
|
56
|
+
- \u5F53\u524D/\u65F6\u6548\u6027\u4E8B\u5B9E\uFF08\u6700\u65B0\u53D1\u5E03\u3001breaking changes\u3001\u4ECA\u65E5\u72B6\u6001\uFF09
|
|
57
|
+
- \u4F60\u4E0D\u8BA4\u8BC6\u6216\u8BB0\u4E0D\u51C6\u7684\u7279\u5B9A\u5E93/\u7248\u672C/API/\u62A5\u9519
|
|
58
|
+
- \u4EFB\u4F55\u53EF\u80FD\u5728\u4F60\u8BAD\u7EC3\u622A\u6B62\u540E\u53D1\u751F\u53D8\u5316\u7684\u5185\u5BB9
|
|
59
|
+
- \u4E0D\u8BA4\u8BC6\u7684\u9996\u5B57\u6BCD\u5927\u5199\u540D\u79F0\uFF08\u4EA7\u54C1\u3001\u5DE5\u5177\u3001\u5305\uFF09\uFF1A\u964C\u751F\u540D\u5B57\u66F4\u53EF\u80FD\u662F\u8BAD\u7EC3\u4E4B\u540E\u624D\u51FA\u73B0\u7684\u771F\u5B9E\u4E8B\u7269\uFF0C\u800C\u4E0D\u662F\u53EF\u4EE5\u81C6\u6D4B\u7684\u5BF9\u8C61\u2014\u2014\u641C\u7D22\uFF0C\u4E0D\u8981\u7F16\u9020
|
|
60
|
+
|
|
61
|
+
### \u4F55\u65F6\u4E0D\u8981\u641C\u7D22
|
|
62
|
+
- \u7A33\u5B9A\u4E8B\u5B9E\u3001\u8BED\u8A00\u8BED\u6CD5\uFF0C\u6216\u4F60\u5DF2\u638C\u63E1\u7684\u6210\u719F\u6982\u5FF5
|
|
63
|
+
- \u672C\u4ED3\u5E93\u5DF2\u6709\u7684\u4EE3\u7801\u2014\u2014\u6539\u7528 grep/read_file/semantic_search
|
|
64
|
+
|
|
65
|
+
### \u4F7F\u7528\u7ED3\u679C\uFF08\u7F72\u540D\u4E0E\u7248\u6743\uFF09
|
|
66
|
+
- \u7528\u81EA\u5DF1\u7684\u8BDD\u7EFC\u5408\u8F6C\u8FF0\uFF1B\u975E\u663E\u800C\u6613\u89C1\u7684\u8BBA\u65AD\u8981\u6CE8\u660E\u6765\u6E90 URL
|
|
67
|
+
- \u76F4\u63A5\u5F15\u7528\u4FDD\u6301\u7B80\u77ED\uFF08\u7EA6 15 \u8BCD\u4EE5\u5185\uFF09\uFF0C\u6BCF\u4E2A\u6765\u6E90\u6700\u591A\u5F15\u7528\u4E00\u5904
|
|
68
|
+
- \u7EDD\u4E0D\u8981\u9010\u5B57\u590D\u5236\u6587\u7AE0\u6BB5\u843D\u3001\u6B4C\u8BCD\u6216\u8BD7\u6B4C
|
|
69
|
+
- \u6458\u8981\u4E0D\u591F\u7528\u65F6\uFF0C\u7528 web_fetch \u8BFB\u53D6\u5B8C\u6574\u9875\u9762`,
|
|
70
|
+
input_schema: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
query: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "\u641C\u7D22\u67E5\u8BE2\u5B57\u7B26\u4E32"
|
|
76
|
+
},
|
|
77
|
+
count: {
|
|
78
|
+
type: "number",
|
|
79
|
+
description: "\u8FD4\u56DE\u7ED3\u679C\u6570\u91CF\uFF08\u9ED8\u8BA4\uFF1A10\uFF0C\u6700\u5927\uFF1A20\uFF09\u3002\u4F20 0 \u6216\u8D1F\u6570\u6309\u9ED8\u8BA4 10 \u5904\u7406\u3002"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
required: ["query"]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
async execute(params) {
|
|
86
|
+
const queryCandidate = lenientString(params.input.query);
|
|
87
|
+
if (queryCandidate === void 0 || queryCandidate.trim().length === 0) {
|
|
88
|
+
return { content: "\u9519\u8BEF\uFF1Aquery \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002", isError: true };
|
|
89
|
+
}
|
|
90
|
+
const query = queryCandidate.trim();
|
|
91
|
+
const count = Math.min(
|
|
92
|
+
Math.max(1, lenientPositiveNumber(params.input.count) ?? 10),
|
|
93
|
+
MAX_RESULTS
|
|
94
|
+
);
|
|
95
|
+
const { backend, results, errors } = await runBackendChain(backends, query, count, timeoutMs);
|
|
96
|
+
if (results.length === 0) {
|
|
97
|
+
const hardErrors = errors.filter((e) => e.message !== "no results" && e.message !== OFF_TOPIC_ERROR);
|
|
98
|
+
if (hardErrors.length > 0) {
|
|
99
|
+
const detail = hardErrors.map((e) => `${e.backend}: ${e.message}`).join("; ");
|
|
100
|
+
return { content: `\u641C\u7D22\u5931\u8D25\uFF08${detail}\uFF09`, isError: true };
|
|
101
|
+
}
|
|
102
|
+
return { content: `\u672A\u627E\u5230\u4E0E\u300C${query}\u300D\u76F8\u5173\u7684\u641C\u7D22\u7ED3\u679C` };
|
|
103
|
+
}
|
|
104
|
+
const formatted = results.map((r, i) => {
|
|
105
|
+
const meta = [r.siteName, r.publishedAt].filter(Boolean).join(" \xB7 ");
|
|
106
|
+
const snippet = r.snippet + (meta ? `\uFF08${meta}\uFF09` : "");
|
|
107
|
+
return `${i + 1}. [${r.title}](${r.url})
|
|
108
|
+
${snippet}`;
|
|
109
|
+
}).join("\n\n");
|
|
110
|
+
const via = backend ? `\uFF08\u7ECF ${backend}\uFF09` : "";
|
|
111
|
+
return { content: `\u300C${query}\u300D\u7684\u7F51\u9875\u641C\u7D22\u7ED3\u679C${via}\uFF1A
|
|
112
|
+
|
|
113
|
+
${formatted}` };
|
|
114
|
+
},
|
|
115
|
+
requiresApproval() {
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
isConcurrencySafe() {
|
|
119
|
+
return true;
|
|
120
|
+
},
|
|
121
|
+
isEnabled() {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
var WEB_SEARCH_TOOL = createWebSearchTool();
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
createWebSearchTool,
|
|
130
|
+
WEB_SEARCH_TOOL
|
|
131
|
+
};
|