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.
Files changed (255) hide show
  1. package/LICENSE +189 -0
  2. package/README.en.md +1066 -0
  3. package/README.ja.md +1214 -0
  4. package/README.ko.md +1216 -0
  5. package/README.md +309 -0
  6. package/completions/rivet.bash +118 -0
  7. package/completions/rivet.fish +110 -0
  8. package/completions/rivet.ps1 +230 -0
  9. package/completions/rivet.zsh +187 -0
  10. package/dist/account-OAEKORZE.js +47 -0
  11. package/dist/account-login-V6FOLHJR.js +65 -0
  12. package/dist/account-status-KHNPPAFL.js +23 -0
  13. package/dist/agent/worker-process/child.js +407 -0
  14. package/dist/browser-cli-FLNY5ZHI.js +19 -0
  15. package/dist/browser-readiness-LWVGSBD5.js +12 -0
  16. package/dist/build-backends-5KXKR2S4.js +13 -0
  17. package/dist/build-options-66Y4ZE7C.js +9 -0
  18. package/dist/bundled-skills/brainstorming/SKILL.md +139 -0
  19. package/dist/bundled-skills/visual-acceptance/SKILL.md +64 -0
  20. package/dist/chain-7MAMFXZ3.js +10 -0
  21. package/dist/checkpoint-MND4DUIX.js +33 -0
  22. package/dist/chunk-2E6CK2RC.js +392 -0
  23. package/dist/chunk-2EBWGAXD.js +51 -0
  24. package/dist/chunk-2HDP7RMR.js +119 -0
  25. package/dist/chunk-2HKD2UFM.js +1000 -0
  26. package/dist/chunk-2VYRLULP.js +51 -0
  27. package/dist/chunk-2XN7PM4N.js +125 -0
  28. package/dist/chunk-35H7GVNR.js +66 -0
  29. package/dist/chunk-3C3R7JXY.js +77 -0
  30. package/dist/chunk-3VGD2FXB.js +118 -0
  31. package/dist/chunk-424AP7FM.js +534 -0
  32. package/dist/chunk-4J5TZGOE.js +3707 -0
  33. package/dist/chunk-4QJ3Y5JM.js +898 -0
  34. package/dist/chunk-4U2ET7ZY.js +1326 -0
  35. package/dist/chunk-4XPFLICE.js +876 -0
  36. package/dist/chunk-5B2OCU5P.js +31707 -0
  37. package/dist/chunk-5GGOGLSN.js +73 -0
  38. package/dist/chunk-5JRZPLI6.js +251 -0
  39. package/dist/chunk-5TQ3JYBU.js +397 -0
  40. package/dist/chunk-66JPZSGX.js +55 -0
  41. package/dist/chunk-6HSVXHCZ.js +764 -0
  42. package/dist/chunk-6S5FPUS7.js +21 -0
  43. package/dist/chunk-722LQO64.js +131 -0
  44. package/dist/chunk-73NJ7IT7.js +354 -0
  45. package/dist/chunk-7FW3I7WC.js +95 -0
  46. package/dist/chunk-7KUCBNLB.js +173 -0
  47. package/dist/chunk-7RDOV3DF.js +201 -0
  48. package/dist/chunk-A5MNH4ER.js +79 -0
  49. package/dist/chunk-ADIVZ2D5.js +15 -0
  50. package/dist/chunk-AE3P3F6W.js +366 -0
  51. package/dist/chunk-AERM3VGP.js +280 -0
  52. package/dist/chunk-AEWHC4WM.js +246 -0
  53. package/dist/chunk-AOVQ7VIF.js +169 -0
  54. package/dist/chunk-AOYHP3WI.js +12411 -0
  55. package/dist/chunk-B3YEBABJ.js +7160 -0
  56. package/dist/chunk-BCQXEZPJ.js +154 -0
  57. package/dist/chunk-BKTQAYO2.js +418 -0
  58. package/dist/chunk-BSECIPAQ.js +80 -0
  59. package/dist/chunk-BUIMGNDD.js +52 -0
  60. package/dist/chunk-BXHV3GSB.js +10320 -0
  61. package/dist/chunk-C6ZVZCPP.js +139 -0
  62. package/dist/chunk-CEZNQVWM.js +82 -0
  63. package/dist/chunk-CGFZGR7G.js +1492 -0
  64. package/dist/chunk-CGOADM2X.js +337 -0
  65. package/dist/chunk-CI4R6P2B.js +24 -0
  66. package/dist/chunk-D2TCGRSX.js +73 -0
  67. package/dist/chunk-D4PTYFOG.js +154 -0
  68. package/dist/chunk-D54ZWG4T.js +717 -0
  69. package/dist/chunk-DEBI37QB.js +145 -0
  70. package/dist/chunk-DWROHPXP.js +1051 -0
  71. package/dist/chunk-DZ6UOJ5D.js +92 -0
  72. package/dist/chunk-EBJTVRQN.js +81 -0
  73. package/dist/chunk-EGEI2RQA.js +1167 -0
  74. package/dist/chunk-EHHUASO5.js +1305 -0
  75. package/dist/chunk-EPKTIOED.js +41 -0
  76. package/dist/chunk-ER5JW2QZ.js +5681 -0
  77. package/dist/chunk-ETHFACAB.js +315 -0
  78. package/dist/chunk-EXUE5W2F.js +112 -0
  79. package/dist/chunk-EXXICUIW.js +73 -0
  80. package/dist/chunk-FFQSZJOO.js +169 -0
  81. package/dist/chunk-FHFKPGDO.js +85 -0
  82. package/dist/chunk-FW3QKMFX.js +158 -0
  83. package/dist/chunk-GD4ZNZ7W.js +30 -0
  84. package/dist/chunk-GHVMWF2I.js +581 -0
  85. package/dist/chunk-GMKAXSYQ.js +297 -0
  86. package/dist/chunk-HBVF6BWO.js +325 -0
  87. package/dist/chunk-HV4YGVMS.js +379 -0
  88. package/dist/chunk-ILBCKAV6.js +89 -0
  89. package/dist/chunk-J4U4AW46.js +440 -0
  90. package/dist/chunk-J6ESSM47.js +1791 -0
  91. package/dist/chunk-JBZHIC6T.js +2309 -0
  92. package/dist/chunk-JCFWOULR.js +245 -0
  93. package/dist/chunk-JRF5L6OD.js +131 -0
  94. package/dist/chunk-JSS75KCG.js +2014 -0
  95. package/dist/chunk-JSXWIWWJ.js +225 -0
  96. package/dist/chunk-JYV7I2QH.js +98 -0
  97. package/dist/chunk-KIOXTQQL.js +1596 -0
  98. package/dist/chunk-KWVTXT5B.js +89 -0
  99. package/dist/chunk-KX22RD6R.js +33 -0
  100. package/dist/chunk-LA6IPTGH.js +709 -0
  101. package/dist/chunk-LH5VCGLB.js +1796 -0
  102. package/dist/chunk-LQQ6XJ2Y.js +269 -0
  103. package/dist/chunk-MJQ55WZZ.js +65 -0
  104. package/dist/chunk-ML3UKMH3.js +40 -0
  105. package/dist/chunk-MOZPLHSU.js +5526 -0
  106. package/dist/chunk-NGEWJ4DF.js +89 -0
  107. package/dist/chunk-NH6VIOAR.js +211 -0
  108. package/dist/chunk-O5VZQKCB.js +26106 -0
  109. package/dist/chunk-OHSV42QB.js +748 -0
  110. package/dist/chunk-OO3TAHO5.js +4070 -0
  111. package/dist/chunk-OTNHSAGN.js +38282 -0
  112. package/dist/chunk-OUWAC7AQ.js +442 -0
  113. package/dist/chunk-OXMIV4WE.js +270 -0
  114. package/dist/chunk-P5KJURUR.js +229 -0
  115. package/dist/chunk-P6GJOVO6.js +307 -0
  116. package/dist/chunk-QARAGUXX.js +23 -0
  117. package/dist/chunk-R43HJCDX.js +2711 -0
  118. package/dist/chunk-RAXBAWRN.js +210 -0
  119. package/dist/chunk-RK3JHWPT.js +39 -0
  120. package/dist/chunk-RWA23GMM.js +24 -0
  121. package/dist/chunk-S4K4L6IM.js +179 -0
  122. package/dist/chunk-SAXK6LVF.js +124 -0
  123. package/dist/chunk-SEPGEJNK.js +1607 -0
  124. package/dist/chunk-SUJERP5I.js +285 -0
  125. package/dist/chunk-T3ED6BY2.js +913 -0
  126. package/dist/chunk-THKDVSEC.js +90 -0
  127. package/dist/chunk-TI4GSEL5.js +52 -0
  128. package/dist/chunk-TPI73L57.js +164 -0
  129. package/dist/chunk-TVHW77C7.js +338 -0
  130. package/dist/chunk-TWNHOSDT.js +1073 -0
  131. package/dist/chunk-UFMN76QD.js +347 -0
  132. package/dist/chunk-UHGLFRZE.js +205 -0
  133. package/dist/chunk-UTZYPKBF.js +15231 -0
  134. package/dist/chunk-UXNLELW6.js +25 -0
  135. package/dist/chunk-UXXS53EA.js +166 -0
  136. package/dist/chunk-V5DHFGI7.js +171 -0
  137. package/dist/chunk-V5YIPMHV.js +2353 -0
  138. package/dist/chunk-WMUWEO2C.js +754 -0
  139. package/dist/chunk-WOE3D7JM.js +945 -0
  140. package/dist/chunk-X2IK5LVR.js +2592 -0
  141. package/dist/chunk-XU2YXCDL.js +459 -0
  142. package/dist/chunk-YJG5HIX5.js +203 -0
  143. package/dist/chunk-Z3QE7TZM.js +72 -0
  144. package/dist/chunk-Z5Z3JHJY.js +64 -0
  145. package/dist/chunk-ZDIFBJFT.js +168 -0
  146. package/dist/chunk-ZGGCEXDC.js +176 -0
  147. package/dist/chunk-ZMZCZNKU.js +263 -0
  148. package/dist/chunk-ZNC5T65N.js +17 -0
  149. package/dist/chunk-ZO3I3A7O.js +308 -0
  150. package/dist/chunk-ZQKXBUB7.js +217 -0
  151. package/dist/chunk-ZTRINFM2.js +78 -0
  152. package/dist/chunk-ZU7JZCVP.js +193 -0
  153. package/dist/chunk-ZZAWNALS.js +350 -0
  154. package/dist/cli/entry.js +54 -0
  155. package/dist/connector-L5QQTR6Y.js +26 -0
  156. package/dist/context-62DC6EC3.js +31 -0
  157. package/dist/council-convene-NJWPNBDU.js +46 -0
  158. package/dist/create-agent-config-ODSQWNVC.js +55 -0
  159. package/dist/default-registry-2PU3BTAU.js +68 -0
  160. package/dist/deliver-task-KONV4C4M.js +57 -0
  161. package/dist/delivery-gate-v2-F2YVMVGK.js +27 -0
  162. package/dist/domain-knowledge-store-DDZ3F4J7.js +11 -0
  163. package/dist/fetch-core-ZPPYDSZH.js +14 -0
  164. package/dist/galaxy-K72BBDQN.js +91 -0
  165. package/dist/goal-criteria-SCALAU2D.js +141 -0
  166. package/dist/goal-persist-XWY2GDQX.js +19 -0
  167. package/dist/goal-tracker-FXMJ2GVK.js +11 -0
  168. package/dist/headless-LSB6I7PT.js +162 -0
  169. package/dist/headless-coordinator-VDPDMVUT.js +90 -0
  170. package/dist/inject-U55SMB6A.js +39 -0
  171. package/dist/login-flow-CD4ZGXOC.js +59 -0
  172. package/dist/logs-cli-SQVYFMMN.js +283 -0
  173. package/dist/loop-ULZYBDA3.js +76 -0
  174. package/dist/main.js +4064 -0
  175. package/dist/manager-ROZBCWPA.js +171 -0
  176. package/dist/manager-Z7XFFUOM.js +10670 -0
  177. package/dist/meridian-indexer-ZIW363L7.js +21 -0
  178. package/dist/native-resolver-PN34UIVV.js +13 -0
  179. package/dist/node_modules/better-sqlite3/lib/database.js +90 -0
  180. package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
  181. package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
  182. package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
  183. package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
  184. package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
  185. package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
  186. package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
  187. package/dist/node_modules/better-sqlite3/lib/methods/table.js +189 -0
  188. package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
  189. package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
  190. package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
  191. package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
  192. package/dist/node_modules/better-sqlite3/package.json +59 -0
  193. package/dist/ownership-ledger-E3WIEKPL.js +9 -0
  194. package/dist/package.json +3 -0
  195. package/dist/path-grants-XRRXHXG7.js +40 -0
  196. package/dist/paths-LVV5IMQN.js +49 -0
  197. package/dist/plan-fact-anchors-LMVQZCW5.js +13 -0
  198. package/dist/plan-store-ODLTTPFB.js +17 -0
  199. package/dist/plan-templates-5FPFBOL6.js +109 -0
  200. package/dist/plugin-loader-ZZKX7ZE6.js +22 -0
  201. package/dist/prefix-budget-62OV5HQC.js +13 -0
  202. package/dist/project-trust-5WS5MOMU.js +31 -0
  203. package/dist/provider-cli-ALDQXIT7.js +37 -0
  204. package/dist/providers-XQYTAVPK.js +11 -0
  205. package/dist/proxy-resolver-V2Y6534D.js +15 -0
  206. package/dist/recovery-cli-KPGY6FY3.js +106 -0
  207. package/dist/review-discipline-MNSYCST5.js +55 -0
  208. package/dist/review-router-BVQZW3MX.js +18 -0
  209. package/dist/seed-capsules/seed-capsule-attack-methodology.md +62 -0
  210. package/dist/seed-capsules/seed-capsule-changgeng.md +31 -0
  211. package/dist/seed-capsules/seed-capsule-design-aesthetics.md +38 -0
  212. package/dist/seed-capsules/seed-capsule-diagnostic-ladder.md +54 -0
  213. package/dist/seed-capsules/seed-capsule-fu.md +39 -0
  214. package/dist/seed-capsules/seed-capsule-huagai.md +73 -0
  215. package/dist/seed-capsules/seed-capsule-kaiyang.md +65 -0
  216. package/dist/seed-capsules/seed-capsule-knowledge-work.md +40 -0
  217. package/dist/seed-capsules/seed-capsule-tanlang.md +47 -0
  218. package/dist/seed-capsules/seed-capsule-tianfu.md +23 -0
  219. package/dist/seed-capsules/seed-capsule-tianliang.md +63 -0
  220. package/dist/seed-capsules/seed-capsule-tianquan.md +32 -0
  221. package/dist/seed-capsules/seed-capsule-tianxuan-ccr.md +22 -0
  222. package/dist/seed-capsules/seed-capsule-tianxuan.md +64 -0
  223. package/dist/seed-capsules/seed-capsule-yaoguang.md +87 -0
  224. package/dist/serve-X2R2UTLF.js +170 -0
  225. package/dist/serve-agent-KHSU6RVV.js +965 -0
  226. package/dist/session-persist-HUUC772H.js +37 -0
  227. package/dist/session-registry-6XUD5C4Y.js +15 -0
  228. package/dist/skill-loader-CK3RMO47.js +48 -0
  229. package/dist/skills/cli-harness-sop.md +207 -0
  230. package/dist/spawn-git-4HFU65AH.js +29 -0
  231. package/dist/sse-EYUTBWUK.js +512 -0
  232. package/dist/starflow-NOFBMPFU.js +30 -0
  233. package/dist/streamableHttp-V67CNJMO.js +447 -0
  234. package/dist/task-contract-6XHBNJQK.js +32 -0
  235. package/dist/task-ledger-3K4TJIER.js +9 -0
  236. package/dist/team-orchestrate-S6NHZP7X.js +64 -0
  237. package/dist/title-extract-QX4XGCYN.js +50 -0
  238. package/dist/todo-QDXGRZZP.js +31 -0
  239. package/dist/todo-store-V3TTO5AH.js +12 -0
  240. package/dist/tool-preset-LU5BYEDZ.js +23 -0
  241. package/dist/tool-tiers-GD742YBN.js +23 -0
  242. package/dist/turndown.es-OI55K6C3.js +17373 -0
  243. package/dist/verification-attribution-EKG4CNUV.js +13 -0
  244. package/dist/volatile-git-MBTST7RA.js +15 -0
  245. package/dist/wave-checkpoint-XLIIHXQA.js +30 -0
  246. package/dist/web-cli-DUG4I35O.js +233 -0
  247. package/dist/web-search-3IK542AA.js +34 -0
  248. package/dist/workers/cpu-worker.js +45 -0
  249. package/dist/workflow-runner-HX7UBAYG.js +297 -0
  250. package/dist/worktree-baseline-O5NCU6M2.js +9 -0
  251. package/package.json +122 -0
  252. package/scripts/check-mobile-env.mjs +76 -0
  253. package/scripts/fetch-native-sqlite.js +392 -0
  254. package/scripts/prune-installed-wasms.js +45 -0
  255. package/scripts/tree-sitter-wasm-keep.js +40 -0
@@ -0,0 +1,347 @@
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
+ loadConfig
5
+ } from "./chunk-ER5JW2QZ.js";
6
+ import {
7
+ init_esm_shims
8
+ } from "./chunk-5GGOGLSN.js";
9
+
10
+ // src/tools/resolved-env.ts
11
+ init_esm_shims();
12
+ import { execFile, spawnSync } from "child_process";
13
+ import { existsSync } from "fs";
14
+ import { win32 as winPath, posix as posixPath } from "path";
15
+ var TOOLCHAIN_VARS = [
16
+ "JAVA_HOME",
17
+ "JDK_HOME",
18
+ "JRE_HOME",
19
+ "MAVEN_HOME",
20
+ "M2_HOME",
21
+ "M2",
22
+ "GRADLE_HOME",
23
+ "GOROOT",
24
+ "GOPATH",
25
+ "GOBIN",
26
+ "ANDROID_HOME",
27
+ "ANDROID_SDK_ROOT",
28
+ "CARGO_HOME",
29
+ "RUSTUP_HOME",
30
+ "NVM_DIR",
31
+ "PYENV_ROOT",
32
+ "SDKMAN_DIR",
33
+ "PNPM_HOME",
34
+ "VOLTA_HOME",
35
+ "FNM_DIR"
36
+ ];
37
+ function findPathKey(env) {
38
+ for (const key of Object.keys(env)) {
39
+ if (key.toLowerCase() === "path") return key;
40
+ }
41
+ return "PATH";
42
+ }
43
+ function splitPath(value, sep) {
44
+ return value.split(sep).map((s) => s.trim()).filter(Boolean);
45
+ }
46
+ function expandWinVars(value, env) {
47
+ return value.replace(/%([^%]+)%/g, (whole, name) => {
48
+ const lower = name.toLowerCase();
49
+ for (const [k, v] of Object.entries(env)) {
50
+ if (k.toLowerCase() === lower && typeof v === "string") return v;
51
+ }
52
+ return whole;
53
+ });
54
+ }
55
+ function parseRegQuery(stdout) {
56
+ const out = {};
57
+ for (const line of stdout.split(/\r?\n/)) {
58
+ const m = line.match(/^\s+(\S+)\s+(REG_\w+)\s+(.*)$/);
59
+ if (m) out[m[1]] = m[3].trim();
60
+ }
61
+ return out;
62
+ }
63
+ function parseEnvDump(dump) {
64
+ const out = {};
65
+ for (const line of dump.split(/\r?\n/)) {
66
+ const m = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
67
+ if (m) out[m[1]] = m[2];
68
+ }
69
+ return out;
70
+ }
71
+ function looksShort(entries) {
72
+ const set = new Set(entries);
73
+ return !set.has("/usr/local/bin") && !set.has("/opt/homebrew/bin");
74
+ }
75
+ function unixProbeDirs(env) {
76
+ const home = env.HOME ?? "";
77
+ const dirs = ["/usr/local/bin", "/opt/homebrew/bin", "/usr/local/sbin"];
78
+ if (home) dirs.push(posixPath.join(home, ".local", "bin"), posixPath.join(home, "bin"));
79
+ return dirs;
80
+ }
81
+ function deriveBinDirs(vars, platform) {
82
+ const path = platform === "win32" ? winPath : posixPath;
83
+ const dirs = [];
84
+ const bin = (v) => {
85
+ if (v) dirs.push(path.join(v, "bin"));
86
+ };
87
+ bin(vars.JAVA_HOME);
88
+ bin(vars.JDK_HOME);
89
+ bin(vars.JRE_HOME);
90
+ bin(vars.MAVEN_HOME);
91
+ bin(vars.M2_HOME);
92
+ bin(vars.M2);
93
+ bin(vars.GRADLE_HOME);
94
+ bin(vars.GOROOT);
95
+ bin(vars.GOPATH);
96
+ bin(vars.CARGO_HOME);
97
+ if (vars.GOBIN) dirs.push(vars.GOBIN);
98
+ if (vars.PNPM_HOME) dirs.push(vars.PNPM_HOME);
99
+ bin(vars.VOLTA_HOME);
100
+ if (vars.ANDROID_HOME) {
101
+ dirs.push(path.join(vars.ANDROID_HOME, "platform-tools"), path.join(vars.ANDROID_HOME, "cmdline-tools", "latest", "bin"));
102
+ }
103
+ return dirs;
104
+ }
105
+ function resolveHostEnv(deps) {
106
+ const isWin = deps.platform === "win32";
107
+ const sep = isWin ? ";" : ":";
108
+ const pathKey = findPathKey(deps.baseEnv);
109
+ const basePath = deps.baseEnv[pathKey] ?? deps.baseEnv.PATH ?? "";
110
+ const pathEntries = splitPath(basePath, sep);
111
+ const seen = new Set(pathEntries.map((e) => isWin ? e.toLowerCase() : e));
112
+ const addPath = (p) => {
113
+ if (!p) return;
114
+ const key = isWin ? p.toLowerCase() : p;
115
+ if (seen.has(key)) return;
116
+ seen.add(key);
117
+ pathEntries.push(p);
118
+ };
119
+ const vars = {};
120
+ const baseHas = (k) => Object.keys(deps.baseEnv).some((bk) => bk.toLowerCase() === k.toLowerCase());
121
+ const addVar = (key, val) => {
122
+ if (!val || vars[key] || baseHas(key)) return;
123
+ vars[key] = val;
124
+ };
125
+ if (isWin) {
126
+ let regReadOk = false;
127
+ for (const scope of ["machine", "user"]) {
128
+ const reg = deps.readRegistryEnv(scope);
129
+ const regPath = reg.Path ?? reg.PATH ?? "";
130
+ if (regPath) regReadOk = true;
131
+ for (const e of splitPath(expandWinVars(regPath, deps.baseEnv), sep)) addPath(e);
132
+ for (const v of TOOLCHAIN_VARS) {
133
+ const val = reg[v];
134
+ if (val) addVar(v, expandWinVars(val, deps.baseEnv));
135
+ }
136
+ }
137
+ if (!regReadOk) {
138
+ const sysRoot = deps.baseEnv.SystemRoot || deps.baseEnv.windir || "C:\\Windows";
139
+ for (const dir of [`${sysRoot}\\System32`, `${sysRoot}`, `${sysRoot}\\System32\\Wbem`]) {
140
+ if (deps.exists(dir)) addPath(dir);
141
+ }
142
+ const localApp = deps.baseEnv.LOCALAPPDATA;
143
+ if (localApp) {
144
+ for (const sub of ["Programs\\Git\\bin", "Programs\\Git\\cmd", "Microsoft\\WindowsApps"]) {
145
+ if (deps.exists(`${localApp}\\${sub}`)) addPath(`${localApp}\\${sub}`);
146
+ }
147
+ }
148
+ }
149
+ } else if (looksShort(pathEntries)) {
150
+ const dump = deps.dumpLoginShellEnv();
151
+ if (dump) {
152
+ const parsed = parseEnvDump(dump);
153
+ for (const e of splitPath(parsed.PATH ?? "", sep)) addPath(e);
154
+ for (const v of TOOLCHAIN_VARS) {
155
+ if (parsed[v]) addVar(v, parsed[v]);
156
+ }
157
+ } else {
158
+ for (const dir of unixProbeDirs(deps.baseEnv)) {
159
+ if (deps.exists(dir)) addPath(dir);
160
+ }
161
+ }
162
+ }
163
+ const allToolchainVars = { ...vars };
164
+ for (const v of TOOLCHAIN_VARS) {
165
+ if (!allToolchainVars[v]) {
166
+ for (const [bk, bv] of Object.entries(deps.baseEnv)) {
167
+ if (bk.toLowerCase() === v.toLowerCase() && typeof bv === "string") {
168
+ allToolchainVars[v] = bv;
169
+ break;
170
+ }
171
+ }
172
+ }
173
+ }
174
+ for (const dir of deriveBinDirs(allToolchainVars, deps.platform)) {
175
+ if (deps.exists(dir)) addPath(dir);
176
+ }
177
+ return { pathKey, path: pathEntries.join(sep), vars };
178
+ }
179
+ function applyConfigEnv(base, config, platform) {
180
+ const sep = platform === "win32" ? ";" : ":";
181
+ const result = { ...base };
182
+ const pathKey = findPathKey(result);
183
+ const extraPath = (config.extraPath ?? []).filter(Boolean);
184
+ if (extraPath.length > 0) {
185
+ const current = result[pathKey] ?? "";
186
+ const existing = new Set(splitPath(current, sep).map((e) => platform === "win32" ? e.toLowerCase() : e));
187
+ const additions = extraPath.filter((p) => !existing.has(platform === "win32" ? p.toLowerCase() : p));
188
+ result[pathKey] = additions.length > 0 ? [current, ...additions].filter(Boolean).join(sep) : current;
189
+ }
190
+ for (const [k, v] of Object.entries(config.extraVars ?? {})) {
191
+ result[k] = v;
192
+ }
193
+ return result;
194
+ }
195
+ function readRegistryEnvReal(scope) {
196
+ const hive = scope === "machine" ? "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" : "HKCU\\Environment";
197
+ const systemRoot = process.env.SystemRoot || process.env.windir || "C:\\Windows";
198
+ const regExe = systemRoot + "\\System32\\reg.exe";
199
+ try {
200
+ const res = spawnSync(regExe, ["query", hive], {
201
+ stdio: ["ignore", "pipe", "ignore"],
202
+ timeout: 3e3,
203
+ encoding: "utf8",
204
+ windowsHide: true
205
+ });
206
+ if (res.status !== 0 || typeof res.stdout !== "string") return {};
207
+ return parseRegQuery(res.stdout);
208
+ } catch {
209
+ return {};
210
+ }
211
+ }
212
+ function dumpLoginShellEnvReal() {
213
+ try {
214
+ const shell = process.env.SHELL || "/bin/bash";
215
+ const res = spawnSync(shell, ["-lic", "command env"], {
216
+ stdio: ["ignore", "pipe", "ignore"],
217
+ timeout: 3e3,
218
+ encoding: "utf8",
219
+ windowsHide: true
220
+ });
221
+ if (res.status !== 0 || typeof res.stdout !== "string") return "";
222
+ return res.stdout;
223
+ } catch {
224
+ return "";
225
+ }
226
+ }
227
+ function realDeps() {
228
+ return {
229
+ platform: process.platform,
230
+ baseEnv: process.env,
231
+ readRegistryEnv: readRegistryEnvReal,
232
+ dumpLoginShellEnv: dumpLoginShellEnvReal,
233
+ exists: existsSync
234
+ };
235
+ }
236
+ var _cachedHost = null;
237
+ var _prewarm = null;
238
+ function readRegistryEnvAsync(scope) {
239
+ const hive = scope === "machine" ? "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" : "HKCU\\Environment";
240
+ const systemRoot = process.env.SystemRoot || process.env.windir || "C:\\Windows";
241
+ const regExe = systemRoot + "\\System32\\reg.exe";
242
+ return new Promise((resolve) => {
243
+ try {
244
+ execFile(
245
+ regExe,
246
+ ["query", hive],
247
+ { timeout: 3e3, encoding: "utf8", windowsHide: true, maxBuffer: 4 * 1024 * 1024 },
248
+ (err, stdout) => resolve(err || typeof stdout !== "string" ? {} : parseRegQuery(stdout))
249
+ );
250
+ } catch {
251
+ resolve({});
252
+ }
253
+ });
254
+ }
255
+ function dumpLoginShellEnvAsync() {
256
+ return new Promise((resolve) => {
257
+ try {
258
+ const shell = process.env.SHELL || "/bin/bash";
259
+ execFile(
260
+ shell,
261
+ ["-lic", "command env"],
262
+ { timeout: 3e3, encoding: "utf8", windowsHide: true, maxBuffer: 4 * 1024 * 1024 },
263
+ (err, stdout) => resolve(err || typeof stdout !== "string" ? "" : stdout)
264
+ );
265
+ } catch {
266
+ resolve("");
267
+ }
268
+ });
269
+ }
270
+ function prewarmResolvedEnv() {
271
+ if (_cachedHost) return Promise.resolve();
272
+ if (_prewarm) return _prewarm;
273
+ _prewarm = (async () => {
274
+ const platform = process.platform;
275
+ let reg = { machine: {}, user: {} };
276
+ let dump = "";
277
+ if (platform === "win32") {
278
+ const [machine, user] = await Promise.all([readRegistryEnvAsync("machine"), readRegistryEnvAsync("user")]);
279
+ reg = { machine, user };
280
+ } else {
281
+ const sep = ":";
282
+ const base = process.env[findPathKey(process.env)] ?? process.env.PATH ?? "";
283
+ if (looksShort(splitPath(base, sep))) dump = await dumpLoginShellEnvAsync();
284
+ }
285
+ if (_cachedHost) return;
286
+ _cachedHost = resolveHostEnv({
287
+ platform,
288
+ baseEnv: process.env,
289
+ readRegistryEnv: (scope) => reg[scope],
290
+ dumpLoginShellEnv: () => dump,
291
+ exists: existsSync
292
+ });
293
+ })().catch(() => {
294
+ }).finally(() => {
295
+ _prewarm = null;
296
+ });
297
+ return _prewarm;
298
+ }
299
+ var ANTI_INTERACTIVE_ENV = {
300
+ PAGER: "cat",
301
+ GIT_PAGER: "cat",
302
+ GH_PAGER: "cat",
303
+ MANPAGER: "cat",
304
+ GIT_TERMINAL_PROMPT: "0",
305
+ // git never prompts for credentials interactively
306
+ GIT_EDITOR: "true",
307
+ // git never launches an editor
308
+ GIT_SEQUENCE_EDITOR: "true",
309
+ GPG_TTY: ""
310
+ // empty = gpg/pinentry can't grab the tty, fails cleanly
311
+ };
312
+ function withAntiInteractive(env) {
313
+ return { ...env, ...ANTI_INTERACTIVE_ENV };
314
+ }
315
+ function getResolvedEnv(cwd) {
316
+ let envConfig;
317
+ try {
318
+ envConfig = loadConfig({ cwd }).env;
319
+ } catch {
320
+ envConfig = { resolve: true, extraPath: [], extraVars: {} };
321
+ }
322
+ if (envConfig.resolve === false) {
323
+ return withAntiInteractive(applyConfigEnv({ ...process.env }, envConfig, process.platform));
324
+ }
325
+ if (!_cachedHost) _cachedHost = resolveHostEnv(realDeps());
326
+ const merged = { ..._cachedHost.vars, ...process.env };
327
+ merged[_cachedHost.pathKey] = _cachedHost.path;
328
+ return withAntiInteractive(applyConfigEnv(merged, envConfig, process.platform));
329
+ }
330
+ function getResolvedPathDiff(cwd) {
331
+ const sep = process.platform === "win32" ? ";" : ":";
332
+ const rawKey = findPathKey(process.env);
333
+ const processPath = splitPath(process.env[rawKey] ?? process.env.PATH ?? "", sep);
334
+ const resolved = getResolvedEnv(cwd);
335
+ const resKey = findPathKey(resolved);
336
+ const resolvedPath = splitPath(resolved[resKey] ?? resolved.PATH ?? "", sep);
337
+ const existing = new Set(processPath.map((e) => process.platform === "win32" ? e.toLowerCase() : e));
338
+ const added = resolvedPath.filter((e) => !existing.has(process.platform === "win32" ? e.toLowerCase() : e));
339
+ return { processPath, resolvedPath, added };
340
+ }
341
+
342
+ export {
343
+ prewarmResolvedEnv,
344
+ ANTI_INTERACTIVE_ENV,
345
+ getResolvedEnv,
346
+ getResolvedPathDiff
347
+ };
@@ -0,0 +1,205 @@
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
+ MAX_TASK_CONSTRAINT_CHARS
5
+ } from "./chunk-4QJ3Y5JM.js";
6
+ import {
7
+ listPlansSync
8
+ } from "./chunk-ZMZCZNKU.js";
9
+ import {
10
+ validatePathSafe
11
+ } from "./chunk-7RDOV3DF.js";
12
+ import {
13
+ init_esm_shims
14
+ } from "./chunk-5GGOGLSN.js";
15
+
16
+ // src/agent/plan-constraints.ts
17
+ init_esm_shims();
18
+ import { readFileSync, statSync } from "fs";
19
+ import { join } from "path";
20
+ var HEADING_RE = /^(反目标|非目标|不做的事|待验证假设|anti-?goals?|non-?goals?|assumptions?)\s*(?:[((].*)?$/i;
21
+ var BOLD_RE = /^\*\*(反目标|非目标|不做的事|待验证假设|约束)[::]*\*\*\s*[::]?\s*(.*)$/;
22
+ var LIST_ITEM_RE = /^\s*(?:[-*]\s+(?:\[[ xX]\]\s*)?|\d+\.\s+)(.+)$/;
23
+ var THEMATIC_BREAK_RE = /^([-*_])(?:\s*\1){2,}$/;
24
+ var BOLD_LINE_RE = /^\*\*/;
25
+ var MD_TOKEN_RE = /([^\s<>"'`]+\.md)/g;
26
+ var MAX_PLAN_BYTES = 512 * 1024;
27
+ function kindForWord(word) {
28
+ const w = word.toLowerCase();
29
+ if (w === "\u5F85\u9A8C\u8BC1\u5047\u8BBE" || w === "assumption" || w === "assumptions") return "assumption";
30
+ return "anti-goal";
31
+ }
32
+ function kindForBoldWord(word) {
33
+ if (word === "\u5F85\u9A8C\u8BC1\u5047\u8BBE") return "assumption";
34
+ if (word === "\u7EA6\u675F") return "constraint";
35
+ return "anti-goal";
36
+ }
37
+ function extractPlanConstraints(markdown) {
38
+ if (!markdown) return [];
39
+ const items = [];
40
+ const push = (kind, text, section) => {
41
+ const trimmed = text.trim();
42
+ if (trimmed) items.push({ kind, text: trimmed, section });
43
+ };
44
+ let heading = null;
45
+ let bold = null;
46
+ for (const raw of markdown.split(/\r?\n/)) {
47
+ const line = raw.trim();
48
+ const headingMatch = line.match(/^(#{1,6})\s+(.*)$/);
49
+ if (headingMatch) {
50
+ bold = null;
51
+ const level = headingMatch[1].length;
52
+ const title = headingMatch[2].trim();
53
+ const hit = title.match(HEADING_RE);
54
+ if (hit) {
55
+ heading = { kind: kindForWord(hit[1]), level, section: title };
56
+ } else if (heading && level <= heading.level) {
57
+ heading = null;
58
+ }
59
+ continue;
60
+ }
61
+ if (THEMATIC_BREAK_RE.test(line)) {
62
+ bold = null;
63
+ continue;
64
+ }
65
+ const boldMatch = line.match(BOLD_RE);
66
+ if (boldMatch) {
67
+ const kind = kindForBoldWord(boldMatch[1]);
68
+ const rest = boldMatch[2].trim();
69
+ bold = rest ? null : { kind, section: boldMatch[1] };
70
+ if (rest) push(kind, rest, boldMatch[1]);
71
+ continue;
72
+ }
73
+ if (BOLD_LINE_RE.test(line)) {
74
+ bold = null;
75
+ continue;
76
+ }
77
+ const listMatch = line.match(LIST_ITEM_RE);
78
+ if (listMatch && listMatch[1].trim()) {
79
+ const text = listMatch[1].trim();
80
+ if (bold) push(bold.kind, text, bold.section);
81
+ else if (heading) push(heading.kind, text, heading.section);
82
+ }
83
+ }
84
+ return items;
85
+ }
86
+ var PLAN_CONSTRAINT_PREFIX = "[\u8BA1\u5212";
87
+ var PREFIX_BY_KIND = {
88
+ "anti-goal": `${PLAN_CONSTRAINT_PREFIX}\u53CD\u76EE\u6807] `,
89
+ constraint: `${PLAN_CONSTRAINT_PREFIX}\u7EA6\u675F] `,
90
+ assumption: `${PLAN_CONSTRAINT_PREFIX}\u5F85\u9A8C\u8BC1\u5047\u8BBE\xB7\u6267\u884C\u671F\u5148\u9A8C\u8BC1] `
91
+ };
92
+ var SENTENCE_END_RE = /[。..!!??]/g;
93
+ function truncateWithPointer(text, section, planRef, budget) {
94
+ const pointer = `\u2026\uFF08\u5168\u6587\u89C1 ${planRef ?? "\u8BA1\u5212"}\u300C${section}\u300D\uFF09`;
95
+ const textBudget = Math.max(8, budget - pointer.length);
96
+ if (text.length <= textBudget) return text;
97
+ let cut = -1;
98
+ for (const m of text.slice(0, textBudget).matchAll(SENTENCE_END_RE)) {
99
+ cut = m.index + 1;
100
+ }
101
+ if (cut < 0) cut = textBudget;
102
+ return text.slice(0, cut) + pointer;
103
+ }
104
+ function renderPlanConstraints(items, planRef) {
105
+ const rank = { "anti-goal": 0, constraint: 1, assumption: 2 };
106
+ const sorted = [...items].sort((a, b) => rank[a.kind] - rank[b.kind]);
107
+ return sorted.map((item) => {
108
+ const prefix = PREFIX_BY_KIND[item.kind];
109
+ return prefix + truncateWithPointer(item.text, item.section, planRef, MAX_TASK_CONSTRAINT_CHARS - prefix.length);
110
+ });
111
+ }
112
+ function readPlanAndRender(cwd, pathToken) {
113
+ const validated = validatePathSafe(cwd, pathToken);
114
+ if (!validated.ok) return [];
115
+ let stat;
116
+ try {
117
+ stat = statSync(validated.path);
118
+ } catch {
119
+ return [];
120
+ }
121
+ if (!stat.isFile() || stat.size > MAX_PLAN_BYTES) return [];
122
+ let content = "";
123
+ try {
124
+ content = readFileSync(validated.path, "utf-8");
125
+ } catch {
126
+ return [];
127
+ }
128
+ return renderPlanConstraints(extractPlanConstraints(content), pathToken);
129
+ }
130
+ function resolvePlanConstraints(cwd, src) {
131
+ if (process.env.RIVET_PLAN_CONSTRAINTS === "0") return [];
132
+ try {
133
+ if (src.markdown) {
134
+ const rendered = renderPlanConstraints(extractPlanConstraints(src.markdown));
135
+ if (rendered.length > 0) return rendered;
136
+ }
137
+ if (src.planPath) {
138
+ const rendered = readPlanAndRender(cwd, src.planPath);
139
+ if (rendered.length > 0) return rendered;
140
+ }
141
+ if (src.objective) {
142
+ const seen = /* @__PURE__ */ new Set();
143
+ for (const raw of src.objective.matchAll(MD_TOKEN_RE)) {
144
+ const token = raw[1].trim().replace(/[.,;:)\]}>]+$/, "");
145
+ if (!token || seen.has(token)) continue;
146
+ seen.add(token);
147
+ const rendered = readPlanAndRender(cwd, token);
148
+ if (rendered.length > 0) return rendered;
149
+ }
150
+ }
151
+ if (src.fromContract && src.fromContract.length > 0) return [...src.fromContract];
152
+ const approved = findApprovedPlanConstraints(cwd);
153
+ if (approved) return approved;
154
+ return [];
155
+ } catch {
156
+ return [];
157
+ }
158
+ }
159
+ var PLANS_DIR = ".rivet/plans";
160
+ var approvedPlanCache = /* @__PURE__ */ new Map();
161
+ var APPROVED_PLAN_CACHE_TTL_MS = 5e3;
162
+ function findApprovedPlanConstraints(cwd) {
163
+ try {
164
+ let dirMtimeMs = -1;
165
+ try {
166
+ dirMtimeMs = statSync(join(cwd, PLANS_DIR)).mtimeMs;
167
+ } catch {
168
+ }
169
+ const now = Date.now();
170
+ const cached = approvedPlanCache.get(cwd);
171
+ if (cached && now - cached.at < APPROVED_PLAN_CACHE_TTL_MS && cached.dirMtimeMs === dirMtimeMs) {
172
+ return cached.value;
173
+ }
174
+ const approved = listPlansSync(cwd).filter((p) => p.status === "approved");
175
+ const value = approved.length === 0 ? void 0 : (() => {
176
+ const rendered = renderPlanConstraints(extractPlanConstraints(approved[0].content));
177
+ return rendered.length > 0 ? rendered : void 0;
178
+ })();
179
+ approvedPlanCache.set(cwd, { value, at: now, dirMtimeMs });
180
+ return value;
181
+ } catch {
182
+ return void 0;
183
+ }
184
+ }
185
+ function constraintsFromUnifiedPlan(src) {
186
+ const items = [];
187
+ for (const raw of src.nonGoals ?? []) {
188
+ const text = raw.trim();
189
+ if (text) items.push({ kind: "anti-goal", text, section: "nonGoals" });
190
+ }
191
+ for (const ob of src.obligations ?? []) {
192
+ if (ob.kind === "advisory_gate") continue;
193
+ const text = ob.text.trim();
194
+ if (text) items.push({ kind: "constraint", text, section: `obligations.${ob.kind}` });
195
+ }
196
+ return renderPlanConstraints(items);
197
+ }
198
+
199
+ export {
200
+ extractPlanConstraints,
201
+ PLAN_CONSTRAINT_PREFIX,
202
+ renderPlanConstraints,
203
+ resolvePlanConstraints,
204
+ constraintsFromUnifiedPlan
205
+ };