@tech-leads-club/harness-toolkit 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +46 -11
  2. package/bin/tlc-build.mjs +35 -6
  3. package/config.example.json +1 -1
  4. package/dist/chunks/compact-before-1e4qg1qt.mjs +1185 -0
  5. package/dist/chunks/compact-before-2hpbfxm5.mjs +5782 -0
  6. package/dist/chunks/compact-before-49j320yp.mjs +1283 -0
  7. package/dist/chunks/compact-before-4jrq0sqs.mjs +61 -0
  8. package/dist/chunks/compact-before-6w8n1vh1.mjs +186 -0
  9. package/dist/chunks/compact-before-7sdmwswh.mjs +52 -0
  10. package/dist/chunks/compact-before-beqpmqrm.mjs +187 -0
  11. package/dist/chunks/compact-before-j9y4jgn4.mjs +845 -0
  12. package/dist/chunks/compact-before-pk86tqx2.mjs +118 -0
  13. package/dist/chunks/compact-before-pkqk5v29.mjs +137 -0
  14. package/dist/chunks/compact-before-w1293m4n.mjs +315 -0
  15. package/dist/chunks/compact-before-wnnds45y.mjs +26 -0
  16. package/dist/chunks/compact-before-wt2c3nh4.mjs +551 -0
  17. package/dist/compact-before.mjs +13 -7961
  18. package/dist/doctor.mjs +33 -8480
  19. package/dist/help-topic.mjs +6 -14
  20. package/dist/init-project.mjs +36 -793
  21. package/dist/install-runtime.mjs +18 -1039
  22. package/dist/lessons-cli.mjs +25 -7043
  23. package/dist/obs-cli.mjs +27 -7037
  24. package/dist/price-lookup.mjs +11 -201
  25. package/dist/prompt-submit.mjs +14 -7974
  26. package/dist/refresh-model-prices.mjs +26 -7061
  27. package/dist/response-after.mjs +11 -7961
  28. package/dist/run.mjs +10 -7960
  29. package/dist/session-end.mjs +14 -8029
  30. package/dist/session-start.mjs +20 -8075
  31. package/dist/shim.mjs +18 -7024
  32. package/dist/stop.mjs +29 -8042
  33. package/dist/subagent-start.mjs +13 -7983
  34. package/dist/subagent-stop.mjs +11 -7961
  35. package/dist/support.mjs +21 -7168
  36. package/dist/tlc-cli.mjs +65 -8200
  37. package/dist/tool-after.mjs +20 -8176
  38. package/dist/tool-before.mjs +15 -7990
  39. package/dist/tool-failure.mjs +14 -7961
  40. package/dist/uninstall-runtime.mjs +61 -1008
  41. package/docs/log.md +4 -0
  42. package/package.json +2 -2
  43. package/src/core/release/release.version.ts +10 -4
  44. package/tools/install-runtime.ts +21 -1
@@ -1,1042 +1,21 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // tools/install-runtime.ts
5
- import { spawnSync } from "node:child_process";
6
- import { cpSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, rmSync as rmSync2, writeFileSync } from "node:fs";
7
- import { join as join3, relative, resolve, sep } from "node:path";
8
-
9
- // src/platform/paths.ts
10
- import { homedir } from "node:os";
11
- import { join } from "node:path";
12
- function conventionalRuntimeHome() {
13
- return join(homedir(), ".tlc", "harness");
14
- }
15
- function runtimeHome(env = process.env) {
16
- return env.TLC_HOME ?? conventionalRuntimeHome();
17
- }
18
- function runtimeHomeWasChosen(env = process.env) {
19
- return env.TLC_HOME_FROM_ENV === "1";
20
- }
21
-
22
- // src/platform/fs-atomic.ts
23
- var RETRYABLE_CODES = new Set(["EPERM", "EBUSY", "EACCES"]);
24
-
25
- // src/core/comment-policy/comment-syntax.catalog.ts
26
- var COMMENT_SYNTAX = [
27
- {
28
- id: "typescript",
29
- extensions: [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"],
30
- line: ["//"],
31
- block: [["/*", "*/"]],
32
- middle: ["*"]
33
- },
34
- {
35
- id: "python",
36
- extensions: [".py", ".pyi", ".pyw"],
37
- line: ["#"],
38
- block: [
39
- ['"""', '"""'],
40
- ["'''", "'''"]
41
- ],
42
- middle: []
43
- },
44
- {
45
- id: "ruby",
46
- extensions: [".rb", ".rake", ".gemspec"],
47
- line: ["#"],
48
- block: [["=begin", "=end"]],
49
- middle: []
50
- },
51
- {
52
- id: "shell",
53
- extensions: [".sh", ".bash", ".zsh", ".ksh", ".fish"],
54
- line: ["#"],
55
- block: [],
56
- middle: []
57
- },
58
- {
59
- id: "go",
60
- extensions: [".go"],
61
- line: ["//"],
62
- block: [["/*", "*/"]],
63
- middle: ["*"]
64
- },
65
- {
66
- id: "rust",
67
- extensions: [".rs"],
68
- line: ["//"],
69
- block: [["/*", "*/"]],
70
- middle: ["*"]
71
- },
72
- {
73
- id: "java",
74
- extensions: [".java"],
75
- line: ["//"],
76
- block: [["/*", "*/"]],
77
- middle: ["*"]
78
- },
79
- {
80
- id: "kotlin",
81
- extensions: [".kt", ".kts"],
82
- line: ["//"],
83
- block: [["/*", "*/"]],
84
- middle: ["*"]
85
- },
86
- {
87
- id: "swift",
88
- extensions: [".swift"],
89
- line: ["//"],
90
- block: [["/*", "*/"]],
91
- middle: ["*"]
92
- },
93
- {
94
- id: "c",
95
- extensions: [".c", ".h"],
96
- line: ["//"],
97
- block: [["/*", "*/"]],
98
- middle: ["*"]
99
- },
100
- {
101
- id: "cpp",
102
- extensions: [".cc", ".cpp", ".cxx", ".hpp", ".hh", ".hxx"],
103
- line: ["//"],
104
- block: [["/*", "*/"]],
105
- middle: ["*"]
106
- },
107
- {
108
- id: "csharp",
109
- extensions: [".cs"],
110
- line: ["//"],
111
- block: [["/*", "*/"]],
112
- middle: ["*"]
113
- },
114
- {
115
- id: "php",
116
- extensions: [".php"],
117
- line: ["//", "#"],
118
- block: [["/*", "*/"]],
119
- middle: ["*"]
120
- },
121
- {
122
- id: "scala",
123
- extensions: [".scala", ".sc"],
124
- line: ["//"],
125
- block: [["/*", "*/"]],
126
- middle: ["*"]
127
- },
128
- {
129
- id: "dart",
130
- extensions: [".dart"],
131
- line: ["//"],
132
- block: [["/*", "*/"]],
133
- middle: ["*"]
134
- },
135
- {
136
- id: "elixir",
137
- extensions: [".ex", ".exs"],
138
- line: ["#"],
139
- block: [],
140
- middle: []
141
- },
142
- {
143
- id: "erlang",
144
- extensions: [".erl", ".hrl"],
145
- line: ["%"],
146
- block: [],
147
- middle: []
148
- },
149
- {
150
- id: "haskell",
151
- extensions: [".hs"],
152
- line: ["--"],
153
- block: [["{-", "-}"]],
154
- middle: []
155
- },
156
- {
157
- id: "lua",
158
- extensions: [".lua"],
159
- line: ["--"],
160
- block: [["--[[", "]]"]],
161
- middle: []
162
- },
163
- {
164
- id: "sql",
165
- extensions: [".sql"],
166
- line: ["--"],
167
- block: [["/*", "*/"]],
168
- middle: ["*"]
169
- },
170
- {
171
- id: "css",
172
- extensions: [".css", ".scss", ".sass", ".less"],
173
- line: ["//"],
174
- block: [["/*", "*/"]],
175
- middle: ["*"]
176
- },
177
- {
178
- id: "yaml",
179
- extensions: [".yaml", ".yml"],
180
- line: ["#"],
181
- block: [],
182
- middle: []
183
- },
184
- {
185
- id: "toml",
186
- extensions: [".toml"],
187
- line: ["#"],
188
- block: [],
189
- middle: []
190
- },
191
- {
192
- id: "ini",
193
- extensions: [".ini", ".cfg", ".conf", ".properties"],
194
- line: [";", "#"],
195
- block: [],
196
- middle: []
197
- },
198
- {
199
- id: "dockerfile",
200
- extensions: [".dockerfile", "dockerfile"],
201
- line: ["#"],
202
- block: [],
203
- middle: []
204
- },
205
- {
206
- id: "makefile",
207
- extensions: [".mk", "makefile"],
208
- line: ["#"],
209
- block: [],
210
- middle: []
211
- },
212
- {
213
- id: "terraform",
214
- extensions: [".tf", ".tfvars"],
215
- line: ["#", "//"],
216
- block: [["/*", "*/"]],
217
- middle: ["*"]
218
- },
219
- {
220
- id: "powershell",
221
- extensions: [".ps1", ".psm1", ".psd1"],
222
- line: ["#"],
223
- block: [["<#", "#>"]],
224
- middle: []
225
- },
226
- {
227
- id: "perl",
228
- extensions: [".pl", ".pm"],
229
- line: ["#"],
230
- block: [],
231
- middle: []
232
- },
233
- {
234
- id: "r",
235
- extensions: [".r"],
236
- line: ["#"],
237
- block: [],
238
- middle: []
239
- },
240
- {
241
- id: "julia",
242
- extensions: [".jl"],
243
- line: ["#"],
244
- block: [["#=", "=#"]],
245
- middle: []
246
- },
247
- {
248
- id: "vue",
249
- extensions: [".vue", ".svelte"],
250
- line: ["//"],
251
- block: [
252
- ["/*", "*/"],
253
- ["<!--", "-->"]
254
- ],
255
- middle: ["*"]
256
- },
257
- {
258
- id: "html",
259
- extensions: [".html", ".htm", ".xml", ".xhtml"],
260
- line: [],
261
- block: [["<!--", "-->"]],
262
- middle: []
263
- },
264
- {
265
- id: "graphql",
266
- extensions: [".graphql", ".gql"],
267
- line: ["#"],
268
- block: [],
269
- middle: []
270
- },
271
- {
272
- id: "protobuf",
273
- extensions: [".proto"],
274
- line: ["//"],
275
- block: [["/*", "*/"]],
276
- middle: ["*"]
277
- },
278
- {
279
- id: "zig",
280
- extensions: [".zig"],
281
- line: ["//"],
282
- block: [],
283
- middle: []
284
- },
285
- {
286
- id: "clojure",
287
- extensions: [".clj", ".cljs", ".cljc", ".edn"],
288
- line: [";"],
289
- block: [],
290
- middle: []
291
- },
292
- {
293
- id: "ocaml",
294
- extensions: [".ml", ".mli"],
295
- line: [],
296
- block: [["(*", "*)"]],
297
- middle: ["*"]
298
- },
299
- {
300
- id: "fsharp",
301
- extensions: [".fs", ".fsi", ".fsx"],
302
- line: ["//"],
303
- block: [["(*", "*)"]],
304
- middle: ["*"]
305
- },
306
- {
307
- id: "vim",
308
- extensions: [".vim"],
309
- line: ['"'],
310
- block: [],
311
- middle: []
312
- },
313
- {
314
- id: "tex",
315
- extensions: [".tex", ".sty", ".cls"],
316
- line: ["%"],
317
- block: [],
318
- middle: []
319
- }
320
- ];
321
-
322
- // src/core/comment-policy/comment-syntax.store.ts
323
- function buildIndex(entries) {
324
- const byKey = new Map;
325
- for (const entry of entries) {
326
- const syntax = { line: entry.line, block: entry.block, middle: entry.middle };
327
- for (const extension of entry.extensions) {
328
- byKey.set(extension.toLowerCase(), syntax);
329
- }
330
- }
331
- return byKey;
332
- }
333
- var INDEX = buildIndex(COMMENT_SYNTAX);
334
- var KNOWN_EXTENSION_COUNT = INDEX.size;
335
-
336
- // src/core/comment-policy/comment-policy.service.ts
337
- var STOPWORDS = new Set([
338
- "a",
339
- "an",
340
- "and",
341
- "are",
342
- "as",
343
- "at",
344
- "be",
345
- "by",
346
- "for",
347
- "from",
348
- "get",
349
- "gets",
350
- "has",
351
- "in",
352
- "into",
353
- "is",
354
- "it",
355
- "its",
356
- "of",
357
- "on",
358
- "or",
359
- "return",
360
- "returns",
361
- "set",
362
- "sets",
363
- "that",
364
- "the",
365
- "then",
366
- "this",
367
- "to",
368
- "true",
369
- "when",
370
- "which",
371
- "with"
372
- ]);
373
-
374
- // src/core/duplication/duplication.service.ts
375
- var MIN_RUN = 6;
376
-
377
- // src/core/floor/floor.paths.ts
378
- var SECRET_BASENAMES = new Set([
379
- ".git-credentials",
380
- ".netrc",
381
- ".npmrc",
382
- ".pgpass",
383
- "credentials",
384
- "id_dsa",
385
- "id_ecdsa",
386
- "id_ed25519",
387
- "id_rsa"
388
- ]);
389
-
390
- // src/core/floor/floor.tokenize.ts
391
- var SEPARATORS = new Set([";", "|", "&", `
392
- `]);
393
- var ESCAPABLE = new Set([" ", "\t", '"', "'", "$", "`", "\\", ";", "|", "&", "(", ")"]);
394
-
395
- // src/core/floor/floor.verb.ts
396
- var WRAPPERS = new Set(["command", "doas", "env", "nice", "nohup", "sudo", "time", "xargs"]);
397
-
398
- // src/core/floor/floor.policy-surface.ts
399
- var PROVEN_READERS = new Set([
400
- "cat",
401
- "cmp",
402
- "diff",
403
- "echo",
404
- "file",
405
- "grep",
406
- "head",
407
- "jq",
408
- "less",
409
- "ls",
410
- "md5sum",
411
- "more",
412
- "od",
413
- "printf",
414
- "rg",
415
- "sha256sum",
416
- "stat",
417
- "strings",
418
- "tail",
419
- "test",
420
- "[",
421
- "wc",
422
- "xxd"
423
- ]);
424
- var GIT_READERS = new Set(["show", "diff", "log", "status", "ls-files", "cat-file", "blame"]);
425
- var EXECUTES_STDIN = new Set([
426
- "ash",
427
- "awk",
428
- "bash",
429
- "bun",
430
- "dash",
431
- "deno",
432
- "ed",
433
- "ex",
434
- "fish",
435
- "gawk",
436
- "ksh",
437
- "lua",
438
- "node",
439
- "perl",
440
- "php",
441
- "python",
442
- "python2",
443
- "python3",
444
- "ruby",
445
- "sed",
446
- "sh",
447
- "tclsh",
448
- "zsh"
449
- ]);
450
- var HARNESS_BINS = new Set(["tlc", "tlc.cmd"]);
451
- var MUTATING_SUBCOMMANDS = new Set(["pause", "resume", "grind", "mode", "init", "gate", "policy"]);
452
-
453
- // src/core/floor/floor.service.ts
454
- var DESTRUCTIVE_VERBS = new Set(["dd", "rm", "rmdir", "shred", "truncate"]);
455
- var MACHINE_VERBS = new Set(["halt", "poweroff", "reboot", "shutdown"]);
456
- var READER_VERBS = new Set(["base64", "cat", "head", "less", "more", "od", "strings", "tail", "xxd"]);
457
- var READING_TOOLS = new Set(["Read", "Edit", "MultiEdit", "NotebookEdit"]);
458
- var EXPANDING_VERBS = new Set([".", "eval", "source"]);
459
- var SHELLS = new Set(["ash", "bash", "dash", "fish", "ksh", "sh", "zsh"]);
460
- var FETCH_VERBS = new Set(["aria2c", "curl", "fetch", "http", "httpie", "https", "wget"]);
461
- var NETWORK_VERBS = new Set([...FETCH_VERBS, "nc", "ncat", "socat", "telnet", "lwp-request"]);
462
-
463
- // src/core/gate/gate.findings.ts
464
- var SOURCE_EXT = "ts|tsx|mts|cts|js|jsx|mjs|cjs|py|go|rb|rs|java|kt|swift|php|sh|sql";
465
- var PATH_IN_OUTPUT = new RegExp(`(?:file://)?((?:[A-Za-z]:)?[\\w./~@+-]*[\\w-]\\.(?:${SOURCE_EXT}))(?=[:)\\s,'"\`]|$)`, "g");
466
-
467
- // src/core/gate/gate.command.ts
468
- var RECIPE_RUNNERS = new Set(["just", "make", "task", "mise", "rake"]);
469
- var SCRIPT_RUNNERS = new Set(["npm", "yarn", "pnpm"]);
470
- var TRANSPARENT_PREFIXES = new Set(["npx", "bunx", "dlx", "exec"]);
471
-
472
- // src/core/gate/gate.lock.ts
473
- var GATE_LOCK_STALE_MS = 30 * 60 * 1000;
474
-
475
- // src/core/lesson/lesson.store.ts
476
- var EPOCH = "1970-01-01T00:00:00.000Z";
477
- function coreLesson(input) {
478
- return {
479
- ...input,
480
- scope: "gate-execution",
481
- source: "core",
482
- tier: "core",
483
- status: "active",
484
- confidence: 1,
485
- hitCount: 1,
486
- pinned: false,
487
- refs: [],
488
- sessionKeys: [],
489
- injectedCount: 0,
490
- gradeableCount: 0,
491
- helpedCount: 0,
492
- neutralCount: 0,
493
- firstSeenAt: EPOCH,
494
- lastSeenAt: EPOCH,
495
- lastAccessedAt: EPOCH,
496
- updatedAt: EPOCH
497
- };
498
- }
499
- var CORE_LESSONS = [
500
- coreLesson({
501
- id: "core:gate:lint",
502
- failedGate: "lint",
503
- category: "verification",
504
- triggerTokens: ["lint", "biome", "eslint", "ruff", "format"],
505
- instruction: "A lint gate failure means changed files still violate the project lint command. Fix the reported findings without suppressions.",
506
- avoid: "Do not add lint suppressions, disable comments, or delete failing files to silence the gate.",
507
- prefer: "Apply the smallest fix that clears each finding, then let the stop hook re-check.",
508
- preRetryCheck: "Confirm the lint command targets only the intended changed files and still fails for the same codes.",
509
- priority: 90
510
- }),
511
- coreLesson({
512
- id: "core:gate:test",
513
- failedGate: "test",
514
- category: "verification",
515
- triggerTokens: ["test", "vitest", "jest", "pytest", "failing"],
516
- 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.",
517
- avoid: "Do not delete failing tests, mark them skipped, or weaken assertions to force green.",
518
- prefer: "Reproduce the failure, fix root cause, re-run the same test target.",
519
- preRetryCheck: "Identify the failing test name/file from the gate output before editing.",
520
- priority: 90
521
- }),
522
- coreLesson({
523
- id: "core:gate:comments",
524
- failedGate: "comments",
525
- category: "verification",
526
- triggerTokens: ["junk comment", "TODO", "FIXME", "banner"],
527
- instruction: "Junk-comment policy failed. Delete narrating comments, banners, TODO/FIXME, and commented-out code.",
528
- avoid: "Do not keep TODO markers or section banners 'for clarity'.",
529
- prefer: "Keep only comments that explain a non-obvious why (invariant, hazard, external constraint).",
530
- preRetryCheck: "Scan the listed file:line hits and remove each one.",
531
- priority: 80
532
- }),
533
- coreLesson({
534
- id: "core:gate:ship",
535
- failedGate: "ship",
536
- category: "ship-evidence",
537
- triggerTokens: ["ship", "evidence", "90-verdict", "PASS"],
538
- instruction: "Ship claim without recent production PASS evidence. Produce real evidence before claiming done.",
539
- avoid: "Do not claim shipped based on unit tests alone when runtime paths changed.",
540
- prefer: "Run production E2E, write 90-verdict.txt PASS, cite the evidence path.",
541
- preRetryCheck: "Confirm evidenceDir and a recent PASS verdict exist for this change.",
542
- priority: 95
543
- }),
544
- coreLesson({
545
- id: "core:gate:empty-diff",
546
- failedGate: "empty-diff",
547
- category: "ship-evidence",
548
- triggerTokens: ["empty", "diff", "no changes", "shipped"],
549
- 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.",
550
- avoid: "Do not restate 'done' without a real diff or an explicit zero-change justification.",
551
- prefer: "Make the missing change, or clearly document why no files should change.",
552
- preRetryCheck: "Inspect git status / changed files before the next stop.",
553
- priority: 92
554
- }),
555
- coreLesson({
556
- id: "core:gate:stagnation",
557
- failedGate: "stagnation",
558
- category: "stagnation",
559
- triggerTokens: ["stagnation", "identical", "fingerprint", "same fail"],
560
- instruction: "Identical validation fingerprint repeated. Change approach — do not re-apply the same failing edit.",
561
- avoid: "Do not retry the exact same patch, command, or suppression.",
562
- prefer: "Diagnose root cause with a different path, or escalate with BLOCKED / TRIED / NEED.",
563
- preRetryCheck: "Diff your last edit against the gate output; ensure the next action is different.",
564
- priority: 100
565
- })
566
- ];
567
-
568
- // src/platform/style.ts
569
- var COLORS = {
570
- structure: "#3d3a4a",
571
- accent: "#a78bfa",
572
- success: "#6ee7b7",
573
- warning: "#d4a574",
574
- error: "#f87171",
575
- info: "#93c5fd",
576
- textMain: "#f5f5f7",
577
- textMuted: "#9ca3af",
578
- textDim: "#6b7280"
579
- };
580
- var SYMBOLS = {
581
- check: "✔",
582
- cross: "✖",
583
- warning: "⚠",
584
- arrow: "→",
585
- arrowRight: "▸",
586
- dot: "•",
587
- bar: "│",
588
- rule: "══",
589
- dash: "──"
590
- };
591
- function rgb(hex) {
592
- const match = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex.trim());
593
- if (!match) {
594
- return "255;255;255";
595
- }
596
- return [match[1], match[2], match[3]].map((part) => Number.parseInt(part, 16)).join(";");
597
- }
598
- var ESC = String.fromCharCode(27);
599
- var RESET = `${ESC}[0m`;
600
- function colorEnabled(env = process.env, argv = process.argv, isTty = process.stdout.isTTY === true) {
601
- if ("NO_COLOR" in env) {
602
- return false;
603
- }
604
- if (argv.includes("--no-color")) {
605
- return false;
606
- }
607
- return isTty;
608
- }
609
- var STATUS_COLOR = {
610
- ok: "success",
611
- warn: "warning",
612
- fail: "error",
613
- info: "info"
614
- };
615
- var STATUS_MARK = {
616
- ok: SYMBOLS.check,
617
- warn: SYMBOLS.warning,
618
- fail: SYMBOLS.cross,
619
- info: SYMBOLS.arrowRight
620
- };
621
- var KV_WIDTH = 16;
622
- function createStyle(enabled = colorEnabled()) {
623
- const wrap = (code, text) => enabled ? `${ESC}[${code}m${text}${RESET}` : text;
624
- const paint = (name, text) => wrap(`38;2;${rgb(COLORS[name])}`, text);
625
- return {
626
- enabled,
627
- paint,
628
- bold: (text) => wrap("1", text),
629
- dim: (text) => paint("textDim", text),
630
- heading: (text) => paint("accent", `${SYMBOLS.rule} ${text} ${SYMBOLS.rule}`),
631
- footer: (text) => paint("textDim", `${SYMBOLS.dash} ${text} ${SYMBOLS.dash}`),
632
- kv: (label, value, width = KV_WIDTH) => ` ${paint("textMuted", `${label}:`.padEnd(width))} ${value}`,
633
- status: (level, text) => `${paint(STATUS_COLOR[level], STATUS_MARK[level])} ${text}`
634
- };
635
- }
636
- var PLAIN = createStyle(false);
637
-
638
- // src/platform/screen.ts
639
- function render(screen, style) {
640
- const out = [style.heading(screen.title.toUpperCase())];
641
- if (screen.summary && screen.summary.length > 0) {
642
- out.push(` ${screen.summary.join(style.dim(` ${SYMBOLS.bar} `))}`);
643
- }
644
- const width = Math.max(KV_WIDTH, ...screen.sections.flatMap((section) => (section.rows ?? []).map((row) => row.label.length + 1)));
645
- for (const section of screen.sections) {
646
- out.push("");
647
- if (section.title) {
648
- out.push(style.paint("accent", section.title));
649
- }
650
- for (const row of section.rows ?? []) {
651
- const value = row.level ? style.status(row.level, row.value) : row.value;
652
- out.push(style.kv(row.label, value, width));
653
- }
654
- for (const line of section.lines ?? []) {
655
- out.push(line === "" ? "" : ` ${line}`);
656
- }
657
- }
658
- if (screen.footer) {
659
- out.push("", style.footer(screen.footer));
660
- }
661
- return out.join(`
662
- `);
663
- }
664
-
665
- // src/core/observability/observability.report.ts
666
- var SHELL_TOOLS = new Set(["Bash", "run_terminal_cmd", "terminal"]);
667
-
668
- // src/core/observability/observability.types.ts
669
- var DEFAULT_OBS = {
670
- enabled: true,
671
- signalPath: "obs.jsonl",
672
- debugPath: "debug.jsonl",
673
- debugEnabled: false,
674
- includePayloads: false,
675
- maxAttrChars: 500,
676
- sessionCostAlertUsd: 5,
677
- retentionDays: 14,
678
- maxSignalEvents: 50000,
679
- globalSpool: false
680
- };
681
- var SIGNAL_KINDS = new Set([
682
- "session.start",
683
- "session.end",
684
- "generation.end",
685
- "tool.fail",
686
- "subagent.start",
687
- "subagent.end",
688
- "prompt.submit",
689
- "compact",
690
- "gate.outcome",
691
- "cost.turn",
692
- "cost.session_alert",
693
- "ship.claim",
694
- "policy.deny",
695
- "policy.observe"
696
- ]);
697
- var LIVE_ALLOWLIST = new Set([
698
- "session.start",
699
- "session.end",
700
- "generation.end",
701
- "tool.fail",
702
- "shell.end",
703
- "subagent.start",
704
- "subagent.end",
705
- "gate.outcome",
706
- "cost.turn",
707
- "cost.session_alert",
708
- "ship.claim",
709
- "policy.deny",
710
- "compact",
711
- "prompt.submit"
712
- ]);
713
-
714
- // src/core/observability/observability.service.ts
715
- var PAYLOAD_KEYS = new Set(["tool_input", "tool_output", "prompt", "text", "content", "output"]);
716
-
717
- // src/core/observability/observability.why.ts
718
- var NONE = new Set(["none", "", "undefined"]);
719
- var NOTHING_WAS_THE_HARNESS = [
720
- "No harness decision in this window.",
721
- "Whatever you just saw was the model, not a rail — the harness allowed everything it was asked about."
722
- ].join(`
723
- `);
724
-
725
- // src/core/policy/policy.defaults.ts
726
- var DEFAULT_LESSONS_POLICY = {
727
- enabled: false,
728
- maxInjectSession: 5,
729
- maxInjectRetry: 8,
730
- maxCharsSession: 900,
731
- maxCharsRetry: 1400,
732
- promoteHitCount: 2,
733
- decayLambda: 0.02,
734
- projectBoost: 1.5,
735
- syncRulesFile: "auto",
736
- gardenOnSessionEnd: true
737
- };
738
- var DEFAULTS = {
739
- version: 1,
740
- mode: "solo",
741
- codePaths: ["src", "apps", "libs", "packages"],
742
- grind: {
743
- enabled: false,
744
- maxLoops: 5,
745
- lintCommand: null,
746
- testCommand: null,
747
- appendFiles: "auto"
748
- },
749
- shipGate: {
750
- enabled: false,
751
- runtimePathPrefixes: ["src", "apps", "libs", "packages", "deploy", "scripts"],
752
- runtimePathExcludes: [".tlc/", "**/node_modules/", "**/.git/"],
753
- evidenceDir: null,
754
- evidenceMaxAgeHours: 48,
755
- emptyDiffAntiShip: false,
756
- claimWindowMinutes: 10
757
- },
758
- subagents: {
759
- enforceAllowlist: false,
760
- requireModel: false,
761
- allowedModels: [],
762
- blockedPatterns: ["-fast(?:$|[^a-z0-9])", "/fast(?:$|[^a-z0-9])"],
763
- minEffort: null,
764
- blockParentFast: false,
765
- blockMode: "deny",
766
- readOnlyTypes: ["explore"]
767
- },
768
- docs: {
769
- command: null,
770
- severity: "warn"
771
- },
772
- observe: {
773
- enabled: false,
774
- rails: []
775
- },
776
- comments: {
777
- enabled: false,
778
- onViolation: "followup",
779
- mode: "declared"
780
- },
781
- supplyChain: {
782
- enabled: false
783
- },
784
- duplication: {
785
- enabled: false,
786
- minRun: MIN_RUN
787
- },
788
- obs: {
789
- globalSpool: false,
790
- includePayloads: DEFAULT_OBS.includePayloads,
791
- maxAttrChars: DEFAULT_OBS.maxAttrChars,
792
- sessionCostAlertUsd: DEFAULT_OBS.sessionCostAlertUsd,
793
- retentionDays: DEFAULT_OBS.retentionDays
794
- },
795
- untrustedContent: {
796
- mode: "frame",
797
- enabled: false,
798
- extraTools: [],
799
- extraCommandPatterns: []
800
- },
801
- planGate: {
802
- enabled: false,
803
- windowMinutes: 120
804
- },
805
- shell: {
806
- catastrophicAsk: true,
807
- stallDetection: false,
808
- stallRepeatThreshold: 3
809
- },
810
- intelligence: {
811
- gapFeedback: true,
812
- failureClassification: true,
813
- progressiveHandoff: true,
814
- progressiveContext: true,
815
- autopilot: true,
816
- idleTurnGate: false,
817
- budgetContinue: false,
818
- budgetContinueAfterLoops: 3,
819
- lessons: { ...DEFAULT_LESSONS_POLICY }
820
- },
821
- mcpPrime: [],
822
- bootstrapExtra: []
823
- };
824
-
825
- // src/core/policy/policy.guard.ts
826
- var WRITE_TOOLS = new Set(["Edit", "Write", "Delete", "MultiEdit", "NotebookEdit"]);
827
-
828
- // src/core/presence/presence.service.ts
829
- var STALE_MS = 10 * 60 * 1000;
830
-
831
- // src/core/shell-policy/shell-policy.service.ts
832
- var WRAPPERS2 = new Set(["command", "doas", "env", "nice", "nohup", "sudo", "time", "xargs"]);
833
- var MACHINE = new Set(["halt", "poweroff", "reboot", "shutdown"]);
834
- var NETWORK = new Set(["curl", "ftp", "gh", "nc", "ncat", "rsync", "scp", "sftp", "ssh", "telnet", "wget"]);
835
- var WRITE = new Set(["cp", "mv", "rm", "rmdir", "tee", "truncate"]);
836
- var PRIVILEGE = new Set(["chmod", "chown"]);
837
- var PAIRED_ASK = new Set(["write", "privilege", "network"]);
838
- // src/core/supply-chain/supply-chain.service.ts
839
- var UNPINNED_SPECS = new Set(["latest", "*", "x", "X", "", "main", "master", "HEAD"]);
840
-
841
- // src/core/turn/turn.activity.ts
842
- var TOOL_KINDS = new Set([
843
- "tool.start",
844
- "tool.end",
845
- "tool.fail",
846
- "shell.start",
847
- "shell.end",
848
- "mcp.start",
849
- "mcp.end",
850
- "file.edit",
851
- "file.read"
852
- ]);
853
- // src/platform/links.ts
854
- import { copyFileSync, existsSync, lstatSync, mkdirSync, rmSync, symlinkSync } from "node:fs";
855
- import { dirname, join as join2 } from "node:path";
856
- var LINK_TYPE = "junction";
857
- function linkDir(source, target) {
858
- let replaced = false;
859
- if (isLink(target)) {
860
- rmSync(target, { recursive: true, force: true });
861
- replaced = true;
862
- } else if (existsSync(target)) {
863
- return {
864
- kind: "refused",
865
- target,
866
- reason: `${target} exists and is not a link — move it aside and re-run`
867
- };
868
- }
869
- mkdirSync(dirname(target), { recursive: true });
870
- symlinkSync(source, target, LINK_TYPE);
871
- return { kind: replaced ? "relinked" : "linked", target, source };
872
- }
873
- function isLink(path) {
874
- try {
875
- return lstatSync(path).isSymbolicLink();
876
- } catch {
877
- return false;
878
- }
879
- }
880
-
881
- // bin/tlc-cli.ts
882
- var NPM_PACKAGE = "@tech-leads-club/harness-toolkit";
883
- var NPM_MARKER = "installed-from-npm";
884
- if (false) {}
885
-
886
- // tools/install-runtime.ts
887
- var RUNTIME_PAYLOAD = [
888
- "bin",
889
- "capabilities",
890
- "dist",
891
- "docs",
892
- "skills",
893
- "src",
894
- "tools",
895
- "config.example.json",
896
- "package.json"
897
- ];
898
- var OPERATOR_OWNED = ["config.json", "state", "flags"];
899
- var NOT_SHIPPED = [join3("tools", "dev"), join3("tools", "__test__")];
900
- function isShipped(relativePath) {
901
- const normalised = relativePath.split(sep).join("/");
902
- return !NOT_SHIPPED.some((excluded) => {
903
- const prefix = excluded.split(sep).join("/");
904
- return normalised === prefix || normalised.startsWith(`${prefix}/`);
905
- });
906
- }
907
- function originRoot(env = process.env) {
908
- const declared = env.TLC_ORIGIN?.trim();
909
- if (declared && declared.length > 0) {
910
- return resolve(declared);
911
- }
912
- const home = env.TLC_HOME?.trim();
913
- return home && home.length > 0 ? resolve(home) : conventionalRuntimeHome();
914
- }
915
- function installRuntime(source, dest) {
916
- if (resolve(source) === resolve(dest)) {
917
- return { kind: "in-place", source, dest, entries: [], missing: [] };
918
- }
919
- mkdirSync2(dest, { recursive: true });
920
- const entries = [];
921
- const missing = [];
922
- for (const entry of RUNTIME_PAYLOAD) {
923
- const from = join3(source, entry);
924
- if (!existsSync2(from)) {
925
- missing.push(entry);
926
- continue;
927
- }
928
- const to = join3(dest, entry);
929
- rmSync2(to, { recursive: true, force: true });
930
- cpSync(from, to, {
931
- recursive: true,
932
- filter: (src) => isShipped(relative(source, src))
933
- });
934
- entries.push(entry);
935
- }
936
- writeFileSync(join3(dest, NPM_MARKER), `Installed by \`tlc harness install\` from ${source}.
937
- Update with: npm i -g ${NPM_PACKAGE}@latest && tlc harness install
938
- `, "utf8");
939
- const config = join3(dest, "config.json");
940
- const example = join3(dest, "config.example.json");
941
- if (!existsSync2(config) && existsSync2(example)) {
942
- writeFileSync(config, readFileSync(example, "utf8"), "utf8");
943
- }
944
- return { kind: "copied", source, dest, entries, missing };
945
- }
946
- function linkRuntime(source, dest) {
947
- if (resolve(source) === resolve(dest)) {
948
- return { kind: "in-place", source, dest, entries: [], missing: [] };
949
- }
950
- const outcome = linkDir(resolve(source), dest);
951
- if (outcome.kind === "refused") {
952
- return { kind: "refused", source, dest, entries: [], missing: [], reason: outcome.reason };
953
- }
954
- const missing = RUNTIME_PAYLOAD.filter((entry) => !existsSync2(join3(dest, entry)));
955
- return { kind: outcome.kind === "relinked" ? "relinked" : "linked", source, dest, entries: [], missing };
956
- }
957
- function installScreen(report) {
958
- if (report.kind === "refused") {
959
- return {
960
- title: "harness install",
961
- sections: [{ rows: [{ label: "refused", value: report.reason ?? "", level: "fail" }] }]
962
- };
963
- }
964
- if (report.kind === "linked" || report.kind === "relinked") {
965
- return {
966
- title: "harness install",
967
- sections: [
968
- {
969
- rows: [
970
- {
971
- label: report.kind === "linked" ? "linked" : "relinked",
972
- value: `${report.dest} → ${report.source}`,
973
- level: "ok"
974
- },
975
- ...report.missing.length > 0 ? [
976
- {
977
- label: "incomplete",
978
- value: `the checkout has no ${report.missing.join(", ")} — run the build`,
979
- level: "fail"
980
- }
981
- ] : []
982
- ]
983
- }
984
- ],
985
- footer: "an edit in the checkout is live in the next hook · `npm link` puts `tlc` on PATH"
986
- };
987
- }
988
- if (report.kind === "in-place") {
989
- return {
990
- title: "harness install",
991
- sections: [
992
- { rows: [{ label: "runtime", value: `already at ${report.dest} — nothing to copy`, level: "ok" }] }
993
- ]
994
- };
995
- }
996
- const rows = [
997
- { label: "installed", value: `${report.entries.length} path(s) → ${report.dest}`, level: "ok" },
998
- { label: "from", value: report.source }
999
- ];
1000
- if (report.missing.length > 0) {
1001
- rows.push({
1002
- label: "packaging",
1003
- value: `MISSING from the source: ${report.missing.join(", ")}`,
1004
- level: "fail"
1005
- });
1006
- }
1007
- return { title: "harness install", sections: [{ rows }] };
1008
- }
1009
- function installReportText(report, style = PLAIN) {
1010
- return render(installScreen(report), style);
1011
- }
1012
- function installDest(env = process.env) {
1013
- const explicit = env.TLC_INSTALL_DEST?.trim();
1014
- if (explicit && explicit.length > 0) {
1015
- return resolve(explicit);
1016
- }
1017
- return runtimeHomeWasChosen(env) ? runtimeHome(env) : conventionalRuntimeHome();
1018
- }
1019
- function fetchPrices(dest, spawn = spawnSync) {
1020
- const result = spawn(process.execPath, [join3(dest, "bin", "tlc-exec.mjs"), "refresh-model-prices"], {
1021
- stdio: "inherit",
1022
- env: { ...process.env, TLC_HOME: dest }
1023
- });
1024
- if ((result.status ?? 1) !== 0) {
1025
- console.log("install: prices not fetched — cost estimates stay empty until `tlc harness prices refresh`");
1026
- }
1027
- }
1028
- if (__require.main == __require.module) {
1029
- const link = process.argv.includes("--link");
1030
- const source = link ? process.cwd() : originRoot();
1031
- const dest = installDest();
1032
- const report = link ? linkRuntime(source, dest) : installRuntime(source, dest);
1033
- console.log(installReportText(report, createStyle()));
1034
- if (report.kind === "refused") {
1035
- process.exit(1);
1036
- }
1037
- fetchPrices(dest);
1038
- process.exit(report.missing.length > 0 ? 1 : 0);
1039
- }
1
+ import {
2
+ NOT_SHIPPED,
3
+ OPERATOR_OWNED,
4
+ RUNTIME_PAYLOAD,
5
+ fetchPrices,
6
+ installDest,
7
+ installReportText,
8
+ installRuntime,
9
+ installScreen,
10
+ isShipped,
11
+ linkRuntime,
12
+ originRoot
13
+ } from "./chunks/compact-before-6w8n1vh1.mjs";
14
+ import"./chunks/compact-before-1e4qg1qt.mjs";
15
+ import"./chunks/compact-before-wnnds45y.mjs";
16
+ import"./chunks/compact-before-2hpbfxm5.mjs";
17
+ import"./chunks/compact-before-49j320yp.mjs";
18
+ import"./chunks/compact-before-4jrq0sqs.mjs";
1040
19
  export {
1041
20
  originRoot,
1042
21
  linkRuntime,