@tech-leads-club/harness-toolkit 0.2.1

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 (300) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/LICENSE +84 -0
  3. package/NOTICE +9 -0
  4. package/README.md +480 -0
  5. package/bin/tlc +10 -0
  6. package/bin/tlc-build +80 -0
  7. package/bin/tlc-cli.ts +1509 -0
  8. package/bin/tlc-exec +10 -0
  9. package/bin/tlc-exec.cmd +4 -0
  10. package/bin/tlc-exec.d.mts +60 -0
  11. package/bin/tlc-exec.mjs +248 -0
  12. package/bin/tlc.cmd +4 -0
  13. package/bin/tlc.mjs +7 -0
  14. package/bin/write-user-hooks.d.mts +40 -0
  15. package/bin/write-user-hooks.mjs +123 -0
  16. package/capabilities/catalog.json +418 -0
  17. package/config.example.json +51 -0
  18. package/dist/compact-before.mjs +7839 -0
  19. package/dist/doctor.mjs +8263 -0
  20. package/dist/help-topic.mjs +82 -0
  21. package/dist/init-project.mjs +993 -0
  22. package/dist/install-runtime.mjs +969 -0
  23. package/dist/lessons-cli.mjs +7258 -0
  24. package/dist/obs-cli.mjs +7025 -0
  25. package/dist/price-lookup.mjs +221 -0
  26. package/dist/prompt-submit.mjs +7860 -0
  27. package/dist/refresh-model-prices.mjs +158 -0
  28. package/dist/response-after.mjs +7879 -0
  29. package/dist/run.mjs +7830 -0
  30. package/dist/session-end.mjs +7937 -0
  31. package/dist/session-start.mjs +8056 -0
  32. package/dist/shim.mjs +52 -0
  33. package/dist/stop.mjs +8494 -0
  34. package/dist/subagent-start.mjs +7861 -0
  35. package/dist/subagent-stop.mjs +7851 -0
  36. package/dist/support.mjs +7045 -0
  37. package/dist/tlc-cli.mjs +8063 -0
  38. package/dist/tool-after.mjs +8113 -0
  39. package/dist/tool-before.mjs +7985 -0
  40. package/dist/tool-failure.mjs +7850 -0
  41. package/dist/uninstall-runtime.mjs +1307 -0
  42. package/docs/architecture.md +270 -0
  43. package/docs/concepts.md +562 -0
  44. package/docs/coverage.md +55 -0
  45. package/docs/decisions/ad-001.md +32 -0
  46. package/docs/decisions/ad-002.md +51 -0
  47. package/docs/decisions/ad-003.md +30 -0
  48. package/docs/decisions/ad-004.md +37 -0
  49. package/docs/decisions/ad-005.md +36 -0
  50. package/docs/decisions/ad-006.md +49 -0
  51. package/docs/decisions/ad-007.md +36 -0
  52. package/docs/decisions/ad-008.md +54 -0
  53. package/docs/decisions/ad-009.md +61 -0
  54. package/docs/decisions/ad-010.md +45 -0
  55. package/docs/decisions/ad-011.md +59 -0
  56. package/docs/decisions/ad-012.md +71 -0
  57. package/docs/decisions/ad-013.md +87 -0
  58. package/docs/decisions/ad-014.md +56 -0
  59. package/docs/decisions/ad-015.md +33 -0
  60. package/docs/decisions/ad-016.md +98 -0
  61. package/docs/decisions/ad-017.md +65 -0
  62. package/docs/decisions/ad-018.md +77 -0
  63. package/docs/decisions/ad-019.md +75 -0
  64. package/docs/decisions/ad-020.md +88 -0
  65. package/docs/decisions/ad-021.md +57 -0
  66. package/docs/decisions/ad-022.md +120 -0
  67. package/docs/decisions/ad-023.md +87 -0
  68. package/docs/decisions/ad-024.md +85 -0
  69. package/docs/decisions/ad-025.md +92 -0
  70. package/docs/decisions/ad-026.md +131 -0
  71. package/docs/decisions/ad-027.md +90 -0
  72. package/docs/decisions/ad-028.md +90 -0
  73. package/docs/decisions/ad-029.md +73 -0
  74. package/docs/decisions/ad-030.md +97 -0
  75. package/docs/decisions/ad-031.md +94 -0
  76. package/docs/decisions/ad-032.md +83 -0
  77. package/docs/decisions/ad-033.md +89 -0
  78. package/docs/decisions/ad-034.md +86 -0
  79. package/docs/decisions/ad-035.md +86 -0
  80. package/docs/decisions/ad-036.md +68 -0
  81. package/docs/decisions/ad-037.md +47 -0
  82. package/docs/decisions/ad-038.md +52 -0
  83. package/docs/decisions/ad-039.md +69 -0
  84. package/docs/decisions/ad-040.md +89 -0
  85. package/docs/decisions/ad-041.md +98 -0
  86. package/docs/decisions/ad-042.md +82 -0
  87. package/docs/decisions/ad-043.md +79 -0
  88. package/docs/decisions/ad-044.md +61 -0
  89. package/docs/decisions/ad-045.md +94 -0
  90. package/docs/decisions/ad-046.md +111 -0
  91. package/docs/decisions/ad-047.md +96 -0
  92. package/docs/decisions/ad-048.md +85 -0
  93. package/docs/decisions/ad-049.md +66 -0
  94. package/docs/decisions/ad-050.md +94 -0
  95. package/docs/decisions/ad-051.md +69 -0
  96. package/docs/decisions/ad-052.md +69 -0
  97. package/docs/decisions/ad-053.md +78 -0
  98. package/docs/decisions/ad-054.md +98 -0
  99. package/docs/decisions/ad-055.md +74 -0
  100. package/docs/decisions/ad-056.md +85 -0
  101. package/docs/decisions/ad-057.md +68 -0
  102. package/docs/decisions/ad-058.md +97 -0
  103. package/docs/decisions/ad-059.md +82 -0
  104. package/docs/decisions/ad-060.md +75 -0
  105. package/docs/decisions/ad-061.md +68 -0
  106. package/docs/decisions/ad-062.md +72 -0
  107. package/docs/decisions/ad-063.md +84 -0
  108. package/docs/decisions/ad-064.md +79 -0
  109. package/docs/decisions/ad-065.md +81 -0
  110. package/docs/decisions/ad-066.md +111 -0
  111. package/docs/decisions/ad-067.md +64 -0
  112. package/docs/decisions/ad-068.md +79 -0
  113. package/docs/decisions/ad-069.md +74 -0
  114. package/docs/decisions/ad-070.md +86 -0
  115. package/docs/decisions/ad-071.md +93 -0
  116. package/docs/decisions/ad-072.md +82 -0
  117. package/docs/decisions/ad-073.md +102 -0
  118. package/docs/decisions/ad-074.md +91 -0
  119. package/docs/decisions/ad-075.md +79 -0
  120. package/docs/decisions/ad-076.md +102 -0
  121. package/docs/decisions/ad-077.md +94 -0
  122. package/docs/decisions/ad-078.md +84 -0
  123. package/docs/decisions/ad-079.md +73 -0
  124. package/docs/decisions/ad-080.md +86 -0
  125. package/docs/decisions/ad-081.md +70 -0
  126. package/docs/decisions/ad-082.md +79 -0
  127. package/docs/decisions/ad-083.md +88 -0
  128. package/docs/decisions/index.md +111 -0
  129. package/docs/diagnose.md +248 -0
  130. package/docs/index.md +52 -0
  131. package/docs/init.md +101 -0
  132. package/docs/lessons.md +294 -0
  133. package/docs/log.md +139 -0
  134. package/docs/measure.md +178 -0
  135. package/docs/providers/claude-code.md +118 -0
  136. package/docs/providers/cursor.md +110 -0
  137. package/docs/providers/index.md +71 -0
  138. package/docs/troubleshooting.md +138 -0
  139. package/model-aliases.json +12 -0
  140. package/model-prices.cursor.json +410 -0
  141. package/model-prices.json +1 -0
  142. package/package.json +57 -0
  143. package/skills/harness-init/SKILL.md +241 -0
  144. package/skills/harness-init/evals/trigger_evals.json +86 -0
  145. package/skills/harness-init/references/capabilities.md +113 -0
  146. package/src/contracts/capabilities.ts +30 -0
  147. package/src/contracts/decision.ts +21 -0
  148. package/src/contracts/effort.ts +15 -0
  149. package/src/contracts/harness-event.ts +87 -0
  150. package/src/contracts/index.ts +6 -0
  151. package/src/contracts/policy-defaults.ts +14 -0
  152. package/src/contracts/wiring.ts +20 -0
  153. package/src/core/attest/attest.service.ts +0 -0
  154. package/src/core/capability/capability.service.ts +62 -0
  155. package/src/core/capability/capability.store.ts +51 -0
  156. package/src/core/capability/capability.types.ts +56 -0
  157. package/src/core/comment-policy/comment-policy.service.ts +307 -0
  158. package/src/core/comment-policy/comment-policy.types.ts +6 -0
  159. package/src/core/comment-policy/comment-resolvability.ts +134 -0
  160. package/src/core/comment-policy/comment-syntax.catalog.ts +310 -0
  161. package/src/core/comment-policy/comment-syntax.store.ts +65 -0
  162. package/src/core/comment-policy/comment-syntax.types.ts +24 -0
  163. package/src/core/core.facade.ts +461 -0
  164. package/src/core/duplication/duplication.service.ts +219 -0
  165. package/src/core/floor/floor.catalog.ts +54 -0
  166. package/src/core/floor/floor.paths.ts +90 -0
  167. package/src/core/floor/floor.policy-surface.ts +311 -0
  168. package/src/core/floor/floor.service.ts +306 -0
  169. package/src/core/floor/floor.tokenize.ts +179 -0
  170. package/src/core/floor/floor.verb.ts +28 -0
  171. package/src/core/floor/index.ts +1 -0
  172. package/src/core/gate/gate.artifact.ts +157 -0
  173. package/src/core/gate/gate.command.ts +130 -0
  174. package/src/core/gate/gate.findings.ts +201 -0
  175. package/src/core/gate/gate.inputs.ts +0 -0
  176. package/src/core/gate/gate.lock.ts +283 -0
  177. package/src/core/gate/gate.service.ts +28 -0
  178. package/src/core/gate/gate.types.ts +67 -0
  179. package/src/core/handoff/handoff.service.ts +43 -0
  180. package/src/core/handoff/handoff.store.ts +59 -0
  181. package/src/core/handoff/handoff.types.ts +89 -0
  182. package/src/core/index.ts +52 -0
  183. package/src/core/integrity/state-seal.ts +81 -0
  184. package/src/core/lesson/lesson.authored.ts +96 -0
  185. package/src/core/lesson/lesson.credit.ts +51 -0
  186. package/src/core/lesson/lesson.garden.ts +283 -0
  187. package/src/core/lesson/lesson.link.ts +93 -0
  188. package/src/core/lesson/lesson.score.ts +61 -0
  189. package/src/core/lesson/lesson.select.ts +209 -0
  190. package/src/core/lesson/lesson.service.ts +110 -0
  191. package/src/core/lesson/lesson.store.ts +317 -0
  192. package/src/core/lesson/lesson.sync.ts +70 -0
  193. package/src/core/lesson/lesson.types.ts +92 -0
  194. package/src/core/lesson/lesson.validity.ts +44 -0
  195. package/src/core/observability/observability.report.ts +326 -0
  196. package/src/core/observability/observability.service.ts +328 -0
  197. package/src/core/observability/observability.store.ts +269 -0
  198. package/src/core/observability/observability.types.ts +193 -0
  199. package/src/core/observability/observability.why.ts +206 -0
  200. package/src/core/observe/observe.service.ts +76 -0
  201. package/src/core/plan/plan.detect.ts +47 -0
  202. package/src/core/plan/plan.service.ts +81 -0
  203. package/src/core/plan/plan.types.ts +25 -0
  204. package/src/core/policy/policy.defaults.ts +103 -0
  205. package/src/core/policy/policy.guard.ts +34 -0
  206. package/src/core/policy/policy.integrity.ts +238 -0
  207. package/src/core/policy/policy.loader.ts +118 -0
  208. package/src/core/policy/policy.operator.ts +82 -0
  209. package/src/core/policy/policy.posture.ts +79 -0
  210. package/src/core/policy/policy.rails.ts +45 -0
  211. package/src/core/policy/policy.types.ts +157 -0
  212. package/src/core/presence/presence.service.ts +111 -0
  213. package/src/core/presence/presence.store.ts +59 -0
  214. package/src/core/presence/presence.types.ts +9 -0
  215. package/src/core/release/release.decisions.ts +147 -0
  216. package/src/core/release/release.seen.ts +38 -0
  217. package/src/core/shell-policy/shell-policy.service.ts +215 -0
  218. package/src/core/shell-policy/shell-policy.stall.ts +57 -0
  219. package/src/core/shell-policy/shell-policy.types.ts +26 -0
  220. package/src/core/ship/ship.ledger.ts +76 -0
  221. package/src/core/ship/ship.service.ts +137 -0
  222. package/src/core/ship/ship.types.ts +19 -0
  223. package/src/core/stagnation/stagnation.resolution.ts +87 -0
  224. package/src/core/stagnation/stagnation.service.ts +20 -0
  225. package/src/core/stagnation/stagnation.store.ts +49 -0
  226. package/src/core/stagnation/stagnation.types.ts +12 -0
  227. package/src/core/subagent-policy/subagent-policy.parent-model.ts +202 -0
  228. package/src/core/subagent-policy/subagent-policy.service.ts +139 -0
  229. package/src/core/subagent-policy/subagent-policy.types.ts +22 -0
  230. package/src/core/supply-chain/supply-chain.catalog.ts +51 -0
  231. package/src/core/supply-chain/supply-chain.service.ts +217 -0
  232. package/src/core/turn/turn.activity.ts +94 -0
  233. package/src/core/turn/turn.autopilot.ts +131 -0
  234. package/src/core/turn/turn.failure-signals.ts +193 -0
  235. package/src/core/turn/turn.loop-counter.ts +71 -0
  236. package/src/core/turn/turn.types.ts +14 -0
  237. package/src/core/untrusted/untrusted.detect.ts +53 -0
  238. package/src/core/untrusted/untrusted.recall.ts +87 -0
  239. package/src/core/untrusted/untrusted.service.ts +129 -0
  240. package/src/core/untrusted/untrusted.store.ts +75 -0
  241. package/src/core/untrusted/untrusted.types.ts +42 -0
  242. package/src/entrypoints/compact-before.ts +14 -0
  243. package/src/entrypoints/prompt-submit.ts +25 -0
  244. package/src/entrypoints/response-after.ts +60 -0
  245. package/src/entrypoints/run.ts +179 -0
  246. package/src/entrypoints/session-end.ts +58 -0
  247. package/src/entrypoints/session-start.ts +172 -0
  248. package/src/entrypoints/shim.ts +46 -0
  249. package/src/entrypoints/stop.ts +876 -0
  250. package/src/entrypoints/subagent-start.ts +16 -0
  251. package/src/entrypoints/subagent-stop.ts +32 -0
  252. package/src/entrypoints/support.ts +182 -0
  253. package/src/entrypoints/tool-after.ts +111 -0
  254. package/src/entrypoints/tool-before.ts +186 -0
  255. package/src/entrypoints/tool-failure.ts +26 -0
  256. package/src/platform/backoff.ts +49 -0
  257. package/src/platform/cli-output.ts +30 -0
  258. package/src/platform/env-scope.ts +22 -0
  259. package/src/platform/fs-atomic.ts +142 -0
  260. package/src/platform/fs-jsonl.ts +24 -0
  261. package/src/platform/git.ts +187 -0
  262. package/src/platform/paths.ts +80 -0
  263. package/src/platform/pricing.ts +229 -0
  264. package/src/platform/process.ts +64 -0
  265. package/src/platform/sanitize.ts +23 -0
  266. package/src/platform/screen.ts +46 -0
  267. package/src/platform/style.ts +103 -0
  268. package/src/providers/claude/claude.capabilities.ts +25 -0
  269. package/src/providers/claude/claude.detect.ts +14 -0
  270. package/src/providers/claude/claude.inbound.ts +252 -0
  271. package/src/providers/claude/claude.lessons-view.ts +33 -0
  272. package/src/providers/claude/claude.outbound.ts +65 -0
  273. package/src/providers/claude/claude.policy-defaults.ts +9 -0
  274. package/src/providers/claude/claude.transcript.ts +62 -0
  275. package/src/providers/claude/claude.wiring.ts +245 -0
  276. package/src/providers/claude/index.ts +17 -0
  277. package/src/providers/cursor/cursor.capabilities.ts +28 -0
  278. package/src/providers/cursor/cursor.detect.ts +14 -0
  279. package/src/providers/cursor/cursor.inbound.ts +203 -0
  280. package/src/providers/cursor/cursor.lessons-view.ts +30 -0
  281. package/src/providers/cursor/cursor.outbound.ts +43 -0
  282. package/src/providers/cursor/cursor.policy-defaults.ts +9 -0
  283. package/src/providers/cursor/cursor.wiring.ts +214 -0
  284. package/src/providers/cursor/index.ts +17 -0
  285. package/src/providers/index.ts +9 -0
  286. package/src/providers/provider.degrade.ts +152 -0
  287. package/src/providers/provider.port.ts +20 -0
  288. package/src/providers/provider.registry.ts +28 -0
  289. package/tools/doctor.ts +631 -0
  290. package/tools/help-topic.ts +74 -0
  291. package/tools/init-project.ts +277 -0
  292. package/tools/install-runtime.ts +164 -0
  293. package/tools/lessons-cli.ts +474 -0
  294. package/tools/obs-cli.ts +175 -0
  295. package/tools/price-lookup.ts +57 -0
  296. package/tools/refresh-model-prices.ts +210 -0
  297. package/tools/test-env.mjs +28 -0
  298. package/tools/test-env.names.d.mts +1 -0
  299. package/tools/test-env.names.mjs +14 -0
  300. package/tools/uninstall-runtime.ts +463 -0
@@ -0,0 +1,1307 @@
1
+ import { createRequire } from "node:module";
2
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+
4
+ // tools/uninstall-runtime.ts
5
+ import {
6
+ existsSync as existsSync2,
7
+ lstatSync,
8
+ readFileSync as readFileSync2,
9
+ readlinkSync,
10
+ realpathSync as realpathSync2,
11
+ rmSync,
12
+ statSync,
13
+ unlinkSync,
14
+ writeFileSync as writeFileSync2
15
+ } from "node:fs";
16
+ import { homedir as homedir2 } from "node:os";
17
+ import { basename, dirname, isAbsolute, join as join3, relative as relative2, resolve as resolve2 } from "node:path";
18
+
19
+ // src/platform/paths.ts
20
+ import { homedir } from "node:os";
21
+ import { join } from "node:path";
22
+ function conventionalRuntimeHome() {
23
+ return join(homedir(), ".tlc", "harness");
24
+ }
25
+ function runtimeHome(env = process.env) {
26
+ return env.TLC_HOME ?? conventionalRuntimeHome();
27
+ }
28
+ function claudeConfigDir() {
29
+ const custom = process.env.CLAUDE_CONFIG_DIR?.trim();
30
+ return custom && custom.length > 0 ? custom : join(homedir(), ".claude");
31
+ }
32
+ function cursorConfigDir() {
33
+ const custom = process.env.CURSOR_CONFIG_DIR?.trim();
34
+ return custom && custom.length > 0 ? custom : join(homedir(), ".cursor");
35
+ }
36
+
37
+ // src/platform/fs-atomic.ts
38
+ var RETRYABLE_CODES = new Set(["EPERM", "EBUSY", "EACCES"]);
39
+
40
+ // src/core/comment-policy/comment-syntax.catalog.ts
41
+ var COMMENT_SYNTAX = [
42
+ {
43
+ id: "typescript",
44
+ extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"],
45
+ line: ["//"],
46
+ block: [["/*", "*/"]],
47
+ middle: ["*"]
48
+ },
49
+ {
50
+ id: "python",
51
+ extensions: [".py", ".pyi", ".pyw"],
52
+ line: ["#"],
53
+ block: [
54
+ ['"""', '"""'],
55
+ ["'''", "'''"]
56
+ ],
57
+ middle: []
58
+ },
59
+ {
60
+ id: "ruby",
61
+ extensions: [".rb", ".rake", ".gemspec"],
62
+ line: ["#"],
63
+ block: [["=begin", "=end"]],
64
+ middle: []
65
+ },
66
+ {
67
+ id: "shell",
68
+ extensions: [".sh", ".bash", ".zsh", ".ksh", ".fish"],
69
+ line: ["#"],
70
+ block: [],
71
+ middle: []
72
+ },
73
+ {
74
+ id: "go",
75
+ extensions: [".go"],
76
+ line: ["//"],
77
+ block: [["/*", "*/"]],
78
+ middle: ["*"]
79
+ },
80
+ {
81
+ id: "rust",
82
+ extensions: [".rs"],
83
+ line: ["//"],
84
+ block: [["/*", "*/"]],
85
+ middle: ["*"]
86
+ },
87
+ {
88
+ id: "java",
89
+ extensions: [".java"],
90
+ line: ["//"],
91
+ block: [["/*", "*/"]],
92
+ middle: ["*"]
93
+ },
94
+ {
95
+ id: "kotlin",
96
+ extensions: [".kt", ".kts"],
97
+ line: ["//"],
98
+ block: [["/*", "*/"]],
99
+ middle: ["*"]
100
+ },
101
+ {
102
+ id: "swift",
103
+ extensions: [".swift"],
104
+ line: ["//"],
105
+ block: [["/*", "*/"]],
106
+ middle: ["*"]
107
+ },
108
+ {
109
+ id: "c",
110
+ extensions: [".c", ".h"],
111
+ line: ["//"],
112
+ block: [["/*", "*/"]],
113
+ middle: ["*"]
114
+ },
115
+ {
116
+ id: "cpp",
117
+ extensions: [".cc", ".cpp", ".cxx", ".hpp", ".hh", ".hxx"],
118
+ line: ["//"],
119
+ block: [["/*", "*/"]],
120
+ middle: ["*"]
121
+ },
122
+ {
123
+ id: "csharp",
124
+ extensions: [".cs"],
125
+ line: ["//"],
126
+ block: [["/*", "*/"]],
127
+ middle: ["*"]
128
+ },
129
+ {
130
+ id: "php",
131
+ extensions: [".php"],
132
+ line: ["//", "#"],
133
+ block: [["/*", "*/"]],
134
+ middle: ["*"]
135
+ },
136
+ {
137
+ id: "scala",
138
+ extensions: [".scala", ".sc"],
139
+ line: ["//"],
140
+ block: [["/*", "*/"]],
141
+ middle: ["*"]
142
+ },
143
+ {
144
+ id: "dart",
145
+ extensions: [".dart"],
146
+ line: ["//"],
147
+ block: [["/*", "*/"]],
148
+ middle: ["*"]
149
+ },
150
+ {
151
+ id: "elixir",
152
+ extensions: [".ex", ".exs"],
153
+ line: ["#"],
154
+ block: [],
155
+ middle: []
156
+ },
157
+ {
158
+ id: "erlang",
159
+ extensions: [".erl", ".hrl"],
160
+ line: ["%"],
161
+ block: [],
162
+ middle: []
163
+ },
164
+ {
165
+ id: "haskell",
166
+ extensions: [".hs"],
167
+ line: ["--"],
168
+ block: [["{-", "-}"]],
169
+ middle: []
170
+ },
171
+ {
172
+ id: "lua",
173
+ extensions: [".lua"],
174
+ line: ["--"],
175
+ block: [["--[[", "]]"]],
176
+ middle: []
177
+ },
178
+ {
179
+ id: "sql",
180
+ extensions: [".sql"],
181
+ line: ["--"],
182
+ block: [["/*", "*/"]],
183
+ middle: ["*"]
184
+ },
185
+ {
186
+ id: "css",
187
+ extensions: [".css", ".scss", ".sass", ".less"],
188
+ line: ["//"],
189
+ block: [["/*", "*/"]],
190
+ middle: ["*"]
191
+ },
192
+ {
193
+ id: "yaml",
194
+ extensions: [".yaml", ".yml"],
195
+ line: ["#"],
196
+ block: [],
197
+ middle: []
198
+ },
199
+ {
200
+ id: "toml",
201
+ extensions: [".toml"],
202
+ line: ["#"],
203
+ block: [],
204
+ middle: []
205
+ },
206
+ {
207
+ id: "ini",
208
+ extensions: [".ini", ".cfg", ".conf", ".properties"],
209
+ line: [";", "#"],
210
+ block: [],
211
+ middle: []
212
+ },
213
+ {
214
+ id: "dockerfile",
215
+ extensions: [".dockerfile", "dockerfile"],
216
+ line: ["#"],
217
+ block: [],
218
+ middle: []
219
+ },
220
+ {
221
+ id: "makefile",
222
+ extensions: [".mk", "makefile"],
223
+ line: ["#"],
224
+ block: [],
225
+ middle: []
226
+ },
227
+ {
228
+ id: "terraform",
229
+ extensions: [".tf", ".tfvars"],
230
+ line: ["#", "//"],
231
+ block: [["/*", "*/"]],
232
+ middle: ["*"]
233
+ },
234
+ {
235
+ id: "powershell",
236
+ extensions: [".ps1", ".psm1", ".psd1"],
237
+ line: ["#"],
238
+ block: [["<#", "#>"]],
239
+ middle: []
240
+ },
241
+ {
242
+ id: "perl",
243
+ extensions: [".pl", ".pm"],
244
+ line: ["#"],
245
+ block: [],
246
+ middle: []
247
+ },
248
+ {
249
+ id: "r",
250
+ extensions: [".r"],
251
+ line: ["#"],
252
+ block: [],
253
+ middle: []
254
+ },
255
+ {
256
+ id: "julia",
257
+ extensions: [".jl"],
258
+ line: ["#"],
259
+ block: [["#=", "=#"]],
260
+ middle: []
261
+ },
262
+ {
263
+ id: "vue",
264
+ extensions: [".vue", ".svelte"],
265
+ line: ["//"],
266
+ block: [
267
+ ["/*", "*/"],
268
+ ["<!--", "-->"]
269
+ ],
270
+ middle: ["*"]
271
+ },
272
+ {
273
+ id: "html",
274
+ extensions: [".html", ".htm", ".xml", ".xhtml"],
275
+ line: [],
276
+ block: [["<!--", "-->"]],
277
+ middle: []
278
+ },
279
+ {
280
+ id: "graphql",
281
+ extensions: [".graphql", ".gql"],
282
+ line: ["#"],
283
+ block: [],
284
+ middle: []
285
+ },
286
+ {
287
+ id: "protobuf",
288
+ extensions: [".proto"],
289
+ line: ["//"],
290
+ block: [["/*", "*/"]],
291
+ middle: ["*"]
292
+ },
293
+ {
294
+ id: "zig",
295
+ extensions: [".zig"],
296
+ line: ["//"],
297
+ block: [],
298
+ middle: []
299
+ },
300
+ {
301
+ id: "clojure",
302
+ extensions: [".clj", ".cljs", ".cljc", ".edn"],
303
+ line: [";"],
304
+ block: [],
305
+ middle: []
306
+ },
307
+ {
308
+ id: "ocaml",
309
+ extensions: [".ml", ".mli"],
310
+ line: [],
311
+ block: [["(*", "*)"]],
312
+ middle: ["*"]
313
+ },
314
+ {
315
+ id: "fsharp",
316
+ extensions: [".fs", ".fsi", ".fsx"],
317
+ line: ["//"],
318
+ block: [["(*", "*)"]],
319
+ middle: ["*"]
320
+ },
321
+ {
322
+ id: "vim",
323
+ extensions: [".vim"],
324
+ line: ['"'],
325
+ block: [],
326
+ middle: []
327
+ },
328
+ {
329
+ id: "tex",
330
+ extensions: [".tex", ".sty", ".cls"],
331
+ line: ["%"],
332
+ block: [],
333
+ middle: []
334
+ }
335
+ ];
336
+
337
+ // src/core/comment-policy/comment-syntax.store.ts
338
+ function buildIndex(entries) {
339
+ const byKey = new Map;
340
+ for (const entry of entries) {
341
+ const syntax = { line: entry.line, block: entry.block, middle: entry.middle };
342
+ for (const extension of entry.extensions) {
343
+ byKey.set(extension.toLowerCase(), syntax);
344
+ }
345
+ }
346
+ return byKey;
347
+ }
348
+ var INDEX = buildIndex(COMMENT_SYNTAX);
349
+ var KNOWN_EXTENSION_COUNT = INDEX.size;
350
+
351
+ // src/core/comment-policy/comment-policy.service.ts
352
+ var STOPWORDS = new Set([
353
+ "a",
354
+ "an",
355
+ "and",
356
+ "are",
357
+ "as",
358
+ "at",
359
+ "be",
360
+ "by",
361
+ "for",
362
+ "from",
363
+ "get",
364
+ "gets",
365
+ "has",
366
+ "in",
367
+ "into",
368
+ "is",
369
+ "it",
370
+ "its",
371
+ "of",
372
+ "on",
373
+ "or",
374
+ "return",
375
+ "returns",
376
+ "set",
377
+ "sets",
378
+ "that",
379
+ "the",
380
+ "then",
381
+ "this",
382
+ "to",
383
+ "true",
384
+ "when",
385
+ "which",
386
+ "with"
387
+ ]);
388
+
389
+ // src/core/duplication/duplication.service.ts
390
+ var MIN_RUN = 6;
391
+
392
+ // src/core/floor/floor.paths.ts
393
+ var SECRET_BASENAMES = new Set([
394
+ ".git-credentials",
395
+ ".netrc",
396
+ ".npmrc",
397
+ ".pgpass",
398
+ "credentials",
399
+ "id_dsa",
400
+ "id_ecdsa",
401
+ "id_ed25519",
402
+ "id_rsa"
403
+ ]);
404
+
405
+ // src/core/floor/floor.tokenize.ts
406
+ var SEPARATORS = new Set([";", "|", "&", `
407
+ `]);
408
+ var ESCAPABLE = new Set([" ", "\t", '"', "'", "$", "`", "\\", ";", "|", "&", "(", ")"]);
409
+
410
+ // src/core/floor/floor.verb.ts
411
+ var WRAPPERS = new Set(["command", "doas", "env", "nice", "nohup", "sudo", "time", "xargs"]);
412
+
413
+ // src/core/floor/floor.policy-surface.ts
414
+ var PROVEN_READERS = new Set([
415
+ "cat",
416
+ "cmp",
417
+ "diff",
418
+ "echo",
419
+ "file",
420
+ "grep",
421
+ "head",
422
+ "jq",
423
+ "less",
424
+ "ls",
425
+ "md5sum",
426
+ "more",
427
+ "od",
428
+ "printf",
429
+ "rg",
430
+ "sha256sum",
431
+ "stat",
432
+ "strings",
433
+ "tail",
434
+ "test",
435
+ "[",
436
+ "wc",
437
+ "xxd"
438
+ ]);
439
+ var GIT_READERS = new Set(["show", "diff", "log", "status", "ls-files", "cat-file", "blame"]);
440
+ var EXECUTES_STDIN = new Set([
441
+ "ash",
442
+ "awk",
443
+ "bash",
444
+ "bun",
445
+ "dash",
446
+ "deno",
447
+ "ed",
448
+ "ex",
449
+ "fish",
450
+ "gawk",
451
+ "ksh",
452
+ "lua",
453
+ "node",
454
+ "perl",
455
+ "php",
456
+ "python",
457
+ "python2",
458
+ "python3",
459
+ "ruby",
460
+ "sed",
461
+ "sh",
462
+ "tclsh",
463
+ "zsh"
464
+ ]);
465
+ var HARNESS_BINS = new Set(["tlc", "tlc.cmd"]);
466
+ var MUTATING_SUBCOMMANDS = new Set(["pause", "resume", "grind", "mode", "init", "gate", "policy"]);
467
+
468
+ // src/core/floor/floor.service.ts
469
+ var DESTRUCTIVE_VERBS = new Set(["dd", "rm", "rmdir", "shred", "truncate"]);
470
+ var MACHINE_VERBS = new Set(["halt", "poweroff", "reboot", "shutdown"]);
471
+ var READER_VERBS = new Set(["base64", "cat", "head", "less", "more", "od", "strings", "tail", "xxd"]);
472
+ var READING_TOOLS = new Set(["Read", "Edit", "MultiEdit", "NotebookEdit"]);
473
+ var EXPANDING_VERBS = new Set([".", "eval", "source"]);
474
+ var SHELLS = new Set(["ash", "bash", "dash", "fish", "ksh", "sh", "zsh"]);
475
+ var FETCH_VERBS = new Set(["aria2c", "curl", "fetch", "http", "httpie", "https", "wget"]);
476
+ var NETWORK_VERBS = new Set([...FETCH_VERBS, "nc", "ncat", "socat", "telnet", "lwp-request"]);
477
+
478
+ // src/core/gate/gate.findings.ts
479
+ var SOURCE_EXT = "ts|tsx|mts|cts|js|jsx|mjs|cjs|py|go|rb|rs|java|kt|swift|php|sh|sql";
480
+ var PATH_IN_OUTPUT = new RegExp(`(?:file://)?((?:[A-Za-z]:)?[\\w./~@+-]*[\\w-]\\.(?:${SOURCE_EXT}))(?=[:)\\s,'"\`]|$)`, "g");
481
+
482
+ // src/core/gate/gate.command.ts
483
+ var RECIPE_RUNNERS = new Set(["just", "make", "task", "mise", "rake"]);
484
+ var SCRIPT_RUNNERS = new Set(["npm", "yarn", "pnpm"]);
485
+ var TRANSPARENT_PREFIXES = new Set(["npx", "bunx", "dlx", "exec"]);
486
+
487
+ // src/core/gate/gate.lock.ts
488
+ var GATE_LOCK_STALE_MS = 30 * 60 * 1000;
489
+
490
+ // src/core/lesson/lesson.store.ts
491
+ var EPOCH = "1970-01-01T00:00:00.000Z";
492
+ function coreLesson(input) {
493
+ return {
494
+ ...input,
495
+ scope: "gate-execution",
496
+ source: "core",
497
+ tier: "core",
498
+ status: "active",
499
+ confidence: 1,
500
+ hitCount: 1,
501
+ pinned: false,
502
+ refs: [],
503
+ sessionKeys: [],
504
+ injectedCount: 0,
505
+ gradeableCount: 0,
506
+ helpedCount: 0,
507
+ neutralCount: 0,
508
+ firstSeenAt: EPOCH,
509
+ lastSeenAt: EPOCH,
510
+ lastAccessedAt: EPOCH,
511
+ updatedAt: EPOCH
512
+ };
513
+ }
514
+ var CORE_LESSONS = [
515
+ coreLesson({
516
+ id: "core:gate:lint",
517
+ failedGate: "lint",
518
+ category: "verification",
519
+ triggerTokens: ["lint", "biome", "eslint", "ruff", "format"],
520
+ instruction: "A lint gate failure means changed files still violate the project lint command. Fix the reported findings without suppressions.",
521
+ avoid: "Do not add lint suppressions, disable comments, or delete failing files to silence the gate.",
522
+ prefer: "Apply the smallest fix that clears each finding, then let the stop hook re-check.",
523
+ preRetryCheck: "Confirm the lint command targets only the intended changed files and still fails for the same codes.",
524
+ priority: 90
525
+ }),
526
+ coreLesson({
527
+ id: "core:gate:test",
528
+ failedGate: "test",
529
+ category: "verification",
530
+ triggerTokens: ["test", "vitest", "jest", "pytest", "failing"],
531
+ instruction: "A test gate failure means assertions still fail. Fix the behavior or the test under the real contract — do not delete or skip tests.",
532
+ avoid: "Do not delete failing tests, mark them skipped, or weaken assertions to force green.",
533
+ prefer: "Reproduce the failure, fix root cause, re-run the same test target.",
534
+ preRetryCheck: "Identify the failing test name/file from the gate output before editing.",
535
+ priority: 90
536
+ }),
537
+ coreLesson({
538
+ id: "core:gate:comments",
539
+ failedGate: "comments",
540
+ category: "verification",
541
+ triggerTokens: ["junk comment", "TODO", "FIXME", "banner"],
542
+ instruction: "Junk-comment policy failed. Delete narrating comments, banners, TODO/FIXME, and commented-out code.",
543
+ avoid: "Do not keep TODO markers or section banners 'for clarity'.",
544
+ prefer: "Keep only comments that explain a non-obvious why (invariant, hazard, external constraint).",
545
+ preRetryCheck: "Scan the listed file:line hits and remove each one.",
546
+ priority: 80
547
+ }),
548
+ coreLesson({
549
+ id: "core:gate:ship",
550
+ failedGate: "ship",
551
+ category: "ship-evidence",
552
+ triggerTokens: ["ship", "evidence", "90-verdict", "PASS"],
553
+ instruction: "Ship claim without recent production PASS evidence. Produce real evidence before claiming done.",
554
+ avoid: "Do not claim shipped based on unit tests alone when runtime paths changed.",
555
+ prefer: "Run production E2E, write 90-verdict.txt PASS, cite the evidence path.",
556
+ preRetryCheck: "Confirm evidenceDir and a recent PASS verdict exist for this change.",
557
+ priority: 95
558
+ }),
559
+ coreLesson({
560
+ id: "core:gate:empty-diff",
561
+ failedGate: "empty-diff",
562
+ category: "ship-evidence",
563
+ triggerTokens: ["empty", "diff", "no changes", "shipped"],
564
+ instruction: "Done/shipped was claimed with zero file changes. Either implement the work or explain why zero-diff is correct — do not claim shipped on an empty tree.",
565
+ avoid: "Do not restate 'done' without a real diff or an explicit zero-change justification.",
566
+ prefer: "Make the missing change, or clearly document why no files should change.",
567
+ preRetryCheck: "Inspect git status / changed files before the next stop.",
568
+ priority: 92
569
+ }),
570
+ coreLesson({
571
+ id: "core:gate:stagnation",
572
+ failedGate: "stagnation",
573
+ category: "stagnation",
574
+ triggerTokens: ["stagnation", "identical", "fingerprint", "same fail"],
575
+ instruction: "Identical validation fingerprint repeated. Change approach — do not re-apply the same failing edit.",
576
+ avoid: "Do not retry the exact same patch, command, or suppression.",
577
+ prefer: "Diagnose root cause with a different path, or escalate with BLOCKED / TRIED / NEED.",
578
+ preRetryCheck: "Diff your last edit against the gate output; ensure the next action is different.",
579
+ priority: 100
580
+ })
581
+ ];
582
+
583
+ // src/platform/style.ts
584
+ var COLORS = {
585
+ structure: "#3d3a4a",
586
+ accent: "#a78bfa",
587
+ success: "#6ee7b7",
588
+ warning: "#d4a574",
589
+ error: "#f87171",
590
+ info: "#93c5fd",
591
+ textMain: "#f5f5f7",
592
+ textMuted: "#9ca3af",
593
+ textDim: "#6b7280"
594
+ };
595
+ var SYMBOLS = {
596
+ check: "✔",
597
+ cross: "✖",
598
+ warning: "⚠",
599
+ arrow: "→",
600
+ arrowRight: "▸",
601
+ dot: "•",
602
+ bar: "│",
603
+ rule: "══",
604
+ dash: "──"
605
+ };
606
+ function rgb(hex) {
607
+ const match = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex.trim());
608
+ if (!match) {
609
+ return "255;255;255";
610
+ }
611
+ return [match[1], match[2], match[3]].map((part) => Number.parseInt(part, 16)).join(";");
612
+ }
613
+ var ESC = String.fromCharCode(27);
614
+ var RESET = `${ESC}[0m`;
615
+ function colorEnabled(env = process.env, argv = process.argv, isTty = process.stdout.isTTY === true) {
616
+ if ("NO_COLOR" in env) {
617
+ return false;
618
+ }
619
+ if (argv.includes("--no-color")) {
620
+ return false;
621
+ }
622
+ return isTty;
623
+ }
624
+ var STATUS_COLOR = {
625
+ ok: "success",
626
+ warn: "warning",
627
+ fail: "error",
628
+ info: "info"
629
+ };
630
+ var STATUS_MARK = {
631
+ ok: SYMBOLS.check,
632
+ warn: SYMBOLS.warning,
633
+ fail: SYMBOLS.cross,
634
+ info: SYMBOLS.arrowRight
635
+ };
636
+ var KV_WIDTH = 16;
637
+ function createStyle(enabled = colorEnabled()) {
638
+ const wrap = (code, text) => enabled ? `${ESC}[${code}m${text}${RESET}` : text;
639
+ const paint = (name, text) => wrap(`38;2;${rgb(COLORS[name])}`, text);
640
+ return {
641
+ enabled,
642
+ paint,
643
+ bold: (text) => wrap("1", text),
644
+ dim: (text) => paint("textDim", text),
645
+ heading: (text) => paint("accent", `${SYMBOLS.rule} ${text} ${SYMBOLS.rule}`),
646
+ footer: (text) => paint("textDim", `${SYMBOLS.dash} ${text} ${SYMBOLS.dash}`),
647
+ kv: (label, value, width = KV_WIDTH) => ` ${paint("textMuted", `${label}:`.padEnd(width))} ${value}`,
648
+ status: (level, text) => `${paint(STATUS_COLOR[level], STATUS_MARK[level])} ${text}`
649
+ };
650
+ }
651
+ var PLAIN = createStyle(false);
652
+
653
+ // src/platform/screen.ts
654
+ function render(screen, style) {
655
+ const out = [style.heading(screen.title.toUpperCase())];
656
+ if (screen.summary && screen.summary.length > 0) {
657
+ out.push(` ${screen.summary.join(style.dim(` ${SYMBOLS.bar} `))}`);
658
+ }
659
+ const width = Math.max(KV_WIDTH, ...screen.sections.flatMap((section) => (section.rows ?? []).map((row) => row.label.length + 1)));
660
+ for (const section of screen.sections) {
661
+ out.push("");
662
+ if (section.title) {
663
+ out.push(style.paint("accent", section.title));
664
+ }
665
+ for (const row of section.rows ?? []) {
666
+ const value = row.level ? style.status(row.level, row.value) : row.value;
667
+ out.push(style.kv(row.label, value, width));
668
+ }
669
+ for (const line of section.lines ?? []) {
670
+ out.push(line === "" ? "" : ` ${line}`);
671
+ }
672
+ }
673
+ if (screen.footer) {
674
+ out.push("", style.footer(screen.footer));
675
+ }
676
+ return out.join(`
677
+ `);
678
+ }
679
+
680
+ // src/core/observability/observability.report.ts
681
+ var SHELL_TOOLS = new Set(["Bash", "run_terminal_cmd", "terminal"]);
682
+
683
+ // src/core/observability/observability.types.ts
684
+ var DEFAULT_OBS = {
685
+ enabled: true,
686
+ signalPath: "obs.jsonl",
687
+ debugPath: "debug.jsonl",
688
+ debugEnabled: false,
689
+ includePayloads: false,
690
+ maxAttrChars: 500,
691
+ sessionCostAlertUsd: 5,
692
+ retentionDays: 14,
693
+ maxSignalEvents: 50000,
694
+ globalSpool: false
695
+ };
696
+ var SIGNAL_KINDS = new Set([
697
+ "session.start",
698
+ "session.end",
699
+ "generation.end",
700
+ "tool.fail",
701
+ "subagent.start",
702
+ "subagent.end",
703
+ "prompt.submit",
704
+ "compact",
705
+ "gate.outcome",
706
+ "cost.turn",
707
+ "cost.session_alert",
708
+ "ship.claim",
709
+ "policy.deny",
710
+ "policy.observe"
711
+ ]);
712
+ var LIVE_ALLOWLIST = new Set([
713
+ "session.start",
714
+ "session.end",
715
+ "generation.end",
716
+ "tool.fail",
717
+ "shell.end",
718
+ "subagent.start",
719
+ "subagent.end",
720
+ "gate.outcome",
721
+ "cost.turn",
722
+ "cost.session_alert",
723
+ "ship.claim",
724
+ "policy.deny",
725
+ "compact",
726
+ "prompt.submit"
727
+ ]);
728
+
729
+ // src/core/observability/observability.service.ts
730
+ var PAYLOAD_KEYS = new Set(["tool_input", "tool_output", "prompt", "text", "content", "output"]);
731
+
732
+ // src/core/observability/observability.why.ts
733
+ var NONE = new Set(["none", "", "undefined"]);
734
+ var NOTHING_WAS_THE_HARNESS = [
735
+ "No harness decision in this window.",
736
+ "Whatever you just saw was the model, not a rail — the harness allowed everything it was asked about."
737
+ ].join(`
738
+ `);
739
+
740
+ // src/core/policy/policy.defaults.ts
741
+ var DEFAULT_LESSONS_POLICY = {
742
+ enabled: false,
743
+ maxInjectSession: 5,
744
+ maxInjectRetry: 8,
745
+ maxCharsSession: 900,
746
+ maxCharsRetry: 1400,
747
+ promoteHitCount: 2,
748
+ decayLambda: 0.02,
749
+ projectBoost: 1.5,
750
+ syncRulesFile: "auto",
751
+ gardenOnSessionEnd: true
752
+ };
753
+ var DEFAULTS = {
754
+ version: 1,
755
+ mode: "solo",
756
+ codePaths: ["src", "apps", "libs", "packages"],
757
+ grind: {
758
+ enabled: false,
759
+ maxLoops: 5,
760
+ lintCommand: null,
761
+ testCommand: null,
762
+ appendFiles: "auto"
763
+ },
764
+ shipGate: {
765
+ enabled: false,
766
+ runtimePathPrefixes: ["src", "apps", "libs", "packages", "deploy", "scripts"],
767
+ runtimePathExcludes: [".tlc/", "**/node_modules/", "**/.git/"],
768
+ evidenceDir: null,
769
+ evidenceMaxAgeHours: 48,
770
+ emptyDiffAntiShip: false,
771
+ claimWindowMinutes: 10
772
+ },
773
+ subagents: {
774
+ enforceAllowlist: false,
775
+ requireModel: false,
776
+ allowedModels: [],
777
+ blockedPatterns: ["-fast(?:$|[^a-z0-9])", "/fast(?:$|[^a-z0-9])"],
778
+ minEffort: null,
779
+ blockParentFast: false,
780
+ blockMode: "deny",
781
+ readOnlyTypes: ["explore"]
782
+ },
783
+ docs: {
784
+ command: null,
785
+ severity: "warn"
786
+ },
787
+ observe: {
788
+ enabled: false,
789
+ rails: []
790
+ },
791
+ comments: {
792
+ enabled: false,
793
+ onViolation: "followup",
794
+ mode: "declared"
795
+ },
796
+ supplyChain: {
797
+ enabled: false
798
+ },
799
+ duplication: {
800
+ enabled: false,
801
+ minRun: MIN_RUN
802
+ },
803
+ obs: {
804
+ globalSpool: false,
805
+ includePayloads: DEFAULT_OBS.includePayloads,
806
+ maxAttrChars: DEFAULT_OBS.maxAttrChars,
807
+ sessionCostAlertUsd: DEFAULT_OBS.sessionCostAlertUsd,
808
+ retentionDays: DEFAULT_OBS.retentionDays
809
+ },
810
+ untrustedContent: {
811
+ mode: "frame",
812
+ enabled: false,
813
+ extraTools: [],
814
+ extraCommandPatterns: []
815
+ },
816
+ planGate: {
817
+ enabled: false,
818
+ windowMinutes: 120
819
+ },
820
+ shell: {
821
+ catastrophicAsk: true,
822
+ stallDetection: false,
823
+ stallRepeatThreshold: 3
824
+ },
825
+ intelligence: {
826
+ gapFeedback: true,
827
+ failureClassification: true,
828
+ progressiveHandoff: true,
829
+ progressiveContext: true,
830
+ autopilot: true,
831
+ idleTurnGate: false,
832
+ budgetContinue: false,
833
+ budgetContinueAfterLoops: 3,
834
+ lessons: { ...DEFAULT_LESSONS_POLICY }
835
+ },
836
+ mcpPrime: [],
837
+ bootstrapExtra: []
838
+ };
839
+
840
+ // src/core/policy/policy.guard.ts
841
+ var WRITE_TOOLS = new Set(["Edit", "Write", "Delete", "MultiEdit", "NotebookEdit"]);
842
+
843
+ // src/core/presence/presence.service.ts
844
+ var STALE_MS = 10 * 60 * 1000;
845
+
846
+ // src/core/shell-policy/shell-policy.service.ts
847
+ var WRAPPERS2 = new Set(["command", "doas", "env", "nice", "nohup", "sudo", "time", "xargs"]);
848
+ var MACHINE = new Set(["halt", "poweroff", "reboot", "shutdown"]);
849
+ var NETWORK = new Set(["curl", "ftp", "gh", "nc", "ncat", "rsync", "scp", "sftp", "ssh", "telnet", "wget"]);
850
+ var WRITE = new Set(["cp", "mv", "rm", "rmdir", "tee", "truncate"]);
851
+ var PRIVILEGE = new Set(["chmod", "chown"]);
852
+ var PAIRED_ASK = new Set(["write", "privilege", "network"]);
853
+ // src/core/supply-chain/supply-chain.service.ts
854
+ var UNPINNED_SPECS = new Set(["latest", "*", "x", "X", "", "main", "master", "HEAD"]);
855
+
856
+ // src/core/turn/turn.activity.ts
857
+ var TOOL_KINDS = new Set([
858
+ "tool.start",
859
+ "tool.end",
860
+ "tool.fail",
861
+ "shell.start",
862
+ "shell.end",
863
+ "mcp.start",
864
+ "mcp.end",
865
+ "file.edit",
866
+ "file.read"
867
+ ]);
868
+ // bin/tlc-cli.ts
869
+ var NPM_PACKAGE = "@tech-leads-club/harness-toolkit";
870
+ var NPM_MARKER = "installed-from-npm";
871
+ if (false) {}
872
+
873
+ // src/providers/claude/claude.wiring.ts
874
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
875
+ function isPlainRecord(value) {
876
+ return value !== null && typeof value === "object" && !Array.isArray(value);
877
+ }
878
+ function isHooksRecord(value) {
879
+ return isPlainRecord(value);
880
+ }
881
+ var LAUNCHER_MARKER = "tlc-exec.mjs";
882
+ function isHarnessGroup(group) {
883
+ return JSON.stringify(group ?? null).includes(LAUNCHER_MARKER);
884
+ }
885
+ function unmergeClaudeSettings(existingText) {
886
+ if (existingText === null || existingText.trim() === "") {
887
+ return { ok: true, settingsText: "", changed: false };
888
+ }
889
+ let parsed;
890
+ try {
891
+ parsed = JSON.parse(existingText);
892
+ } catch (error) {
893
+ const message = error instanceof Error ? error.message : String(error);
894
+ return { ok: false, error: message, block: "" };
895
+ }
896
+ if (!isPlainRecord(parsed)) {
897
+ return { ok: false, error: "settings.json root is not a JSON object", block: "" };
898
+ }
899
+ const currentHooks = isHooksRecord(parsed.hooks) ? parsed.hooks : {};
900
+ const remainingHooks = {};
901
+ let changed = false;
902
+ for (const [hookEvent, groups] of Object.entries(currentHooks)) {
903
+ const foreign = groups.filter((group) => !isHarnessGroup(group));
904
+ if (foreign.length !== groups.length) {
905
+ changed = true;
906
+ }
907
+ if (foreign.length > 0) {
908
+ remainingHooks[hookEvent] = foreign;
909
+ }
910
+ }
911
+ const next = {};
912
+ for (const [key, value] of Object.entries(parsed)) {
913
+ if (key !== "hooks") {
914
+ next[key] = value;
915
+ } else if (Object.keys(remainingHooks).length > 0) {
916
+ next.hooks = remainingHooks;
917
+ }
918
+ }
919
+ return { ok: true, settingsText: JSON.stringify(next, null, 2), changed };
920
+ }
921
+ function removeClaudeWiring(settingsPath) {
922
+ if (!existsSync(settingsPath)) {
923
+ return { ok: true, settingsText: "", changed: false };
924
+ }
925
+ const result = unmergeClaudeSettings(readFileSync(settingsPath, "utf8"));
926
+ if (result.ok && result.changed) {
927
+ writeFileSync(settingsPath, result.settingsText, "utf8");
928
+ }
929
+ return result;
930
+ }
931
+
932
+ // src/providers/cursor/cursor.wiring.ts
933
+ function unwireCursorHooks(text, marker = "tlc-exec.mjs") {
934
+ if (text === null || text.trim() === "") {
935
+ return { kind: "absent" };
936
+ }
937
+ let parsed;
938
+ try {
939
+ parsed = JSON.parse(text);
940
+ } catch {
941
+ return { kind: "unparsed" };
942
+ }
943
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
944
+ return { kind: "unparsed" };
945
+ }
946
+ const document = parsed;
947
+ const hooks = document.hooks !== null && typeof document.hooks === "object" && !Array.isArray(document.hooks) ? document.hooks : {};
948
+ const remaining = {};
949
+ let removed = 0;
950
+ let kept = 0;
951
+ for (const [hookEvent, value] of Object.entries(hooks)) {
952
+ const list = Array.isArray(value) ? value : [];
953
+ const foreign = list.filter((row) => !JSON.stringify(row ?? null).includes(marker));
954
+ removed += list.length - foreign.length;
955
+ if (foreign.length > 0) {
956
+ remaining[hookEvent] = foreign;
957
+ kept += foreign.length;
958
+ }
959
+ }
960
+ if (kept === 0) {
961
+ return { kind: "empty", removed };
962
+ }
963
+ return {
964
+ kind: "rewritten",
965
+ removed,
966
+ text: `${JSON.stringify({ ...document, hooks: remaining }, null, 2)}
967
+ `
968
+ };
969
+ }
970
+
971
+ // tools/install-runtime.ts
972
+ import { join as join2, relative, resolve, sep } from "node:path";
973
+ var RUNTIME_PAYLOAD = [
974
+ "bin",
975
+ "capabilities",
976
+ "dist",
977
+ "docs",
978
+ "skills",
979
+ "src",
980
+ "tools",
981
+ "config.example.json",
982
+ "model-aliases.json",
983
+ "model-prices.cursor.json",
984
+ "model-prices.json",
985
+ "package.json"
986
+ ];
987
+ var OPERATOR_OWNED = ["config.json", "state", "flags"];
988
+ var NOT_SHIPPED = [join2("tools", "dev"), join2("tools", "__test__")];
989
+ if (false) {}
990
+
991
+ // tools/uninstall-runtime.ts
992
+ function uninstallTargets(env = process.env, platform = process.platform) {
993
+ const windows = platform === "win32";
994
+ const userHome = (windows ? env.USERPROFILE : env.HOME)?.trim() || homedir2();
995
+ const binDir = env.TLC_BIN_DIR?.trim() || join3(userHome, ".local", "bin");
996
+ return {
997
+ home: runtimeHome(env),
998
+ binLink: join3(binDir, windows ? "tlc.cmd" : "tlc"),
999
+ claudeSettings: join3(claudeConfigDir(), "settings.json"),
1000
+ cursorHooks: join3(cursorConfigDir(), "hooks.json"),
1001
+ skillLinks: windows ? [join3(userHome, ".tlc", "skills", "harness-init")] : [
1002
+ join3(claudeConfigDir(), "skills", "harness-init"),
1003
+ join3(cursorConfigDir(), "skills", "harness-init")
1004
+ ]
1005
+ };
1006
+ }
1007
+ function isSymlink(path) {
1008
+ try {
1009
+ return lstatSync(path).isSymbolicLink();
1010
+ } catch {
1011
+ return false;
1012
+ }
1013
+ }
1014
+ function canonicalise(path) {
1015
+ let head = resolve2(path);
1016
+ const tail = [];
1017
+ for (;; ) {
1018
+ try {
1019
+ return join3(realpathSync2(head), ...tail);
1020
+ } catch {
1021
+ const parent = dirname(head);
1022
+ if (parent === head) {
1023
+ return resolve2(path);
1024
+ }
1025
+ tail.unshift(basename(head));
1026
+ head = parent;
1027
+ }
1028
+ }
1029
+ }
1030
+ function resolveLink(path) {
1031
+ try {
1032
+ return realpathSync2(path);
1033
+ } catch {
1034
+ try {
1035
+ const target = readlinkSync(path);
1036
+ return canonicalise(isAbsolute(target) ? target : resolve2(dirname(path), target));
1037
+ } catch {
1038
+ return canonicalise(path);
1039
+ }
1040
+ }
1041
+ }
1042
+ function isInsideRoot(target, root, pathApi = { relative: relative2, isAbsolute }) {
1043
+ if (target === root) {
1044
+ return true;
1045
+ }
1046
+ const step = pathApi.relative(root, target);
1047
+ return step !== "" && !step.startsWith("..") && !pathApi.isAbsolute(step);
1048
+ }
1049
+ function pointsInto(link, home) {
1050
+ return isInsideRoot(resolveLink(link), canonicalise(home));
1051
+ }
1052
+ var LAUNCHER_MARKER2 = "tlc-exec.mjs";
1053
+ function carriesLauncherMarker(path) {
1054
+ try {
1055
+ return statSync(path).size < 4096 && readFileSync2(path, "utf8").includes(LAUNCHER_MARKER2);
1056
+ } catch {
1057
+ return false;
1058
+ }
1059
+ }
1060
+ function planLink(items, path, home, label, ownership) {
1061
+ if (!existsSync2(path) && !isSymlink(path)) {
1062
+ return;
1063
+ }
1064
+ if (!isSymlink(path)) {
1065
+ if (carriesLauncherMarker(path)) {
1066
+ items.push({ action: "remove", target: path, detail: `${label}, installed as a copy` });
1067
+ return;
1068
+ }
1069
+ items.push({
1070
+ action: "keep",
1071
+ target: path,
1072
+ detail: `${label} is a real file the installer did not write`
1073
+ });
1074
+ return;
1075
+ }
1076
+ if (ownership === "target" && !pointsInto(path, home)) {
1077
+ items.push({ action: "keep", target: path, detail: `points at ${resolveLink(path)} — not ours` });
1078
+ return;
1079
+ }
1080
+ const stale = ownership === "location" && !pointsInto(path, home);
1081
+ items.push({
1082
+ action: "unlink",
1083
+ target: path,
1084
+ detail: stale ? `${label}, stale — points at ${resolveLink(path)}` : label
1085
+ });
1086
+ }
1087
+ function planClaude(items, settingsPath) {
1088
+ if (!existsSync2(settingsPath)) {
1089
+ return;
1090
+ }
1091
+ const result = unmergeClaudeSettings(readFileSync2(settingsPath, "utf8"));
1092
+ if (!result.ok) {
1093
+ items.push({
1094
+ action: "keep",
1095
+ target: settingsPath,
1096
+ detail: `left untouched — it does not parse as JSON: ${result.error}`
1097
+ });
1098
+ return;
1099
+ }
1100
+ if (!result.changed) {
1101
+ return;
1102
+ }
1103
+ items.push({
1104
+ action: "unmerge",
1105
+ target: settingsPath,
1106
+ detail: "drop the harness hook groups, keep every other key and every foreign hook"
1107
+ });
1108
+ }
1109
+ function planCursor(items, hooksPath) {
1110
+ const text = existsSync2(hooksPath) ? readFileSync2(hooksPath, "utf8") : null;
1111
+ const result = unwireCursorHooks(text);
1112
+ switch (result.kind) {
1113
+ case "absent":
1114
+ return;
1115
+ case "unparsed":
1116
+ items.push({ action: "keep", target: hooksPath, detail: "left untouched — it does not parse as JSON" });
1117
+ return;
1118
+ case "empty":
1119
+ if (result.removed > 0) {
1120
+ items.push({ action: "remove", target: hooksPath, detail: `${result.removed} entries, all ours` });
1121
+ }
1122
+ return;
1123
+ default:
1124
+ items.push({
1125
+ action: "unmerge",
1126
+ target: hooksPath,
1127
+ detail: `drop ${result.removed} harness entries, keep the rest`
1128
+ });
1129
+ }
1130
+ }
1131
+ function planRuntime(items, home, purge) {
1132
+ const homeIsLink = isSymlink(home);
1133
+ if (homeIsLink) {
1134
+ items.push({
1135
+ action: "unlink",
1136
+ target: home,
1137
+ detail: `a link to ${resolveLink(home)} — the checkout it points at is left exactly as it is`
1138
+ });
1139
+ return true;
1140
+ }
1141
+ if (!existsSync2(home)) {
1142
+ return false;
1143
+ }
1144
+ for (const entry of RUNTIME_PAYLOAD) {
1145
+ const path = join3(home, entry);
1146
+ if (existsSync2(path)) {
1147
+ items.push({ action: "remove", target: path, detail: "runtime payload" });
1148
+ }
1149
+ }
1150
+ const marker = join3(home, NPM_MARKER);
1151
+ if (existsSync2(marker)) {
1152
+ items.push({ action: "remove", target: marker, detail: "install marker" });
1153
+ }
1154
+ for (const entry of OPERATOR_OWNED) {
1155
+ const path = join3(home, entry);
1156
+ if (!existsSync2(path)) {
1157
+ continue;
1158
+ }
1159
+ items.push(purge ? { action: "remove", target: path, detail: "--purge" } : { action: "keep", target: path, detail: "yours — add --purge to remove it" });
1160
+ }
1161
+ return false;
1162
+ }
1163
+ function planManual(items, home) {
1164
+ if (existsSync2(join3(home, NPM_MARKER))) {
1165
+ items.push({
1166
+ action: "manual",
1167
+ target: `npm uninstall -g ${NPM_PACKAGE}`,
1168
+ detail: "the global package is reported, never removed for you"
1169
+ });
1170
+ }
1171
+ items.push({
1172
+ action: "manual",
1173
+ target: "rm -rf .tlc/ in each repository",
1174
+ detail: "per-project config and state — this command does not search your disk for them"
1175
+ });
1176
+ }
1177
+ function planUninstall(targets, options = {}) {
1178
+ const purge = options.purge === true;
1179
+ const items = [];
1180
+ planClaude(items, targets.claudeSettings);
1181
+ planCursor(items, targets.cursorHooks);
1182
+ for (const link of targets.skillLinks) {
1183
+ planLink(items, link, targets.home, "skill link", "location");
1184
+ }
1185
+ planLink(items, targets.binLink, targets.home, "the tlc launcher on PATH", "target");
1186
+ const homeIsLink = planRuntime(items, targets.home, purge);
1187
+ planManual(items, targets.home);
1188
+ return { items, purge, homeIsLink };
1189
+ }
1190
+ function pendingItems(plan) {
1191
+ return plan.items.filter((item) => item.action === "unmerge" || item.action === "unlink" || item.action === "remove");
1192
+ }
1193
+ function applyUninstall(plan, targets) {
1194
+ const applied = [];
1195
+ const failed = [];
1196
+ for (const item of pendingItems(plan)) {
1197
+ try {
1198
+ if (item.action === "unmerge" && item.target === targets.claudeSettings) {
1199
+ removeClaudeWiring(item.target);
1200
+ } else if (item.action === "unmerge") {
1201
+ const result = unwireCursorHooks(readFileSync2(item.target, "utf8"));
1202
+ if (result.kind === "rewritten") {
1203
+ writeFileSync2(item.target, result.text, "utf8");
1204
+ }
1205
+ } else if (item.action === "unlink") {
1206
+ unlinkSync(item.target);
1207
+ } else {
1208
+ rmSync(item.target, { recursive: true, force: true });
1209
+ }
1210
+ applied.push(item);
1211
+ } catch (error) {
1212
+ failed.push({ item, reason: error instanceof Error ? error.message : String(error) });
1213
+ }
1214
+ }
1215
+ return { applied, failed };
1216
+ }
1217
+ var ACTION_LEVEL = {
1218
+ unmerge: "warn",
1219
+ unlink: "warn",
1220
+ remove: "warn",
1221
+ keep: "ok",
1222
+ manual: "info"
1223
+ };
1224
+ function uninstallScreen(plan, result) {
1225
+ const pending = pendingItems(plan);
1226
+ const applied = result !== null;
1227
+ if (pending.length === 0) {
1228
+ return {
1229
+ title: "harness uninstall",
1230
+ summary: ["nothing wired"],
1231
+ sections: [
1232
+ {
1233
+ rows: [{ label: "state", value: "no harness artefact found — nothing to undo", level: "ok" }]
1234
+ },
1235
+ { title: "STILL YOURS TO DO", rows: manualRows(plan) }
1236
+ ],
1237
+ footer: `already clean · reinstall with npm i -g ${NPM_PACKAGE}, then \`tlc harness install\``
1238
+ };
1239
+ }
1240
+ const changes = pending.map((item) => ({
1241
+ label: item.action,
1242
+ value: `${item.target} — ${item.detail}`,
1243
+ level: ACTION_LEVEL[item.action]
1244
+ }));
1245
+ const kept = plan.items.filter((item) => item.action === "keep");
1246
+ const sections = [
1247
+ { title: applied ? "REMOVED" : "WOULD REMOVE", rows: changes },
1248
+ ...kept.length > 0 ? [
1249
+ {
1250
+ title: "KEPT",
1251
+ rows: kept.map((item) => ({
1252
+ label: "keep",
1253
+ value: `${item.target} — ${item.detail}`,
1254
+ level: "ok"
1255
+ }))
1256
+ }
1257
+ ] : [],
1258
+ { title: "STILL YOURS TO DO", rows: manualRows(plan) },
1259
+ ...result !== null && result.failed.length > 0 ? [
1260
+ {
1261
+ title: "FAILED",
1262
+ rows: result.failed.map((entry) => ({
1263
+ label: "error",
1264
+ value: `${entry.item.target} — ${entry.reason}`,
1265
+ level: "fail"
1266
+ }))
1267
+ }
1268
+ ] : []
1269
+ ];
1270
+ return {
1271
+ title: "harness uninstall",
1272
+ summary: [
1273
+ applied ? `${result.applied.length} applied` : `${pending.length} pending`,
1274
+ plan.purge ? "purge: state included" : "purge: state kept",
1275
+ plan.homeIsLink ? "runtime: linked checkout, unlinked only" : "runtime: owned by the installer"
1276
+ ],
1277
+ sections,
1278
+ footer: applied ? `reinstall any time with npm i -g ${NPM_PACKAGE}, then \`tlc harness install\`` : "nothing was changed · re-run with --yes to apply this plan"
1279
+ };
1280
+ }
1281
+ function manualRows(plan) {
1282
+ return plan.items.filter((item) => item.action === "manual").map((item) => ({ label: "run", value: `${item.target} — ${item.detail}`, level: "info" }));
1283
+ }
1284
+ function uninstallReportText(plan, result, style = PLAIN) {
1285
+ return render(uninstallScreen(plan, result), style);
1286
+ }
1287
+ function main(argv = process.argv.slice(2)) {
1288
+ const targets = uninstallTargets();
1289
+ const plan = planUninstall(targets, { purge: argv.includes("--purge") });
1290
+ const result = argv.includes("--yes") ? applyUninstall(plan, targets) : null;
1291
+ console.log(uninstallReportText(plan, result, createStyle()));
1292
+ return result !== null && result.failed.length > 0 ? 1 : 0;
1293
+ }
1294
+ if (__require.main == __require.module) {
1295
+ process.exitCode = main();
1296
+ }
1297
+ export {
1298
+ uninstallTargets,
1299
+ uninstallScreen,
1300
+ uninstallReportText,
1301
+ planUninstall,
1302
+ pendingItems,
1303
+ main,
1304
+ isInsideRoot,
1305
+ canonicalise,
1306
+ applyUninstall
1307
+ };