@tech-leads-club/harness-toolkit 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/tlc-build.mjs +10 -1
- package/bin/tlc-cli.ts +61 -14
- package/dist/compact-before.mjs +103 -7940
- package/dist/doctor.mjs +102 -8471
- package/dist/help-topic.mjs +4 -64
- package/dist/init-project.mjs +10 -990
- package/dist/install-runtime.mjs +101 -7247
- package/dist/lessons-cli.mjs +101 -7353
- package/dist/obs-cli.mjs +102 -7131
- package/dist/price-lookup.mjs +2 -243
- package/dist/prompt-submit.mjs +103 -7961
- package/dist/refresh-model-prices.mjs +101 -7266
- package/dist/response-after.mjs +103 -7980
- package/dist/run.mjs +103 -7931
- package/dist/session-end.mjs +110 -8034
- package/dist/session-start.mjs +112 -8153
- package/dist/shim.mjs +100 -7041
- package/dist/stop.mjs +109 -8595
- package/dist/subagent-start.mjs +103 -7962
- package/dist/subagent-stop.mjs +104 -7952
- package/dist/support.mjs +107 -7147
- package/dist/tlc-cli.mjs +121 -8219
- package/dist/tool-after.mjs +103 -8236
- package/dist/tool-before.mjs +103 -8086
- package/dist/tool-failure.mjs +103 -7951
- package/dist/uninstall-runtime.mjs +4 -1306
- package/package.json +1 -1
package/bin/tlc-build.mjs
CHANGED
|
@@ -49,10 +49,19 @@ function sourcesIn(dir) {
|
|
|
49
49
|
* one program that is allowed to run it. Splitting can come back when no library module carries that guard, and
|
|
50
50
|
* not before — the size win is real and it is not worth a CLI that cannot install.
|
|
51
51
|
*/
|
|
52
|
+
/**
|
|
53
|
+
* why `--minify`: one bundle per entry means the core is inlined 24 times, and minifying is the part of that cost
|
|
54
|
+
* that can be removed without touching module identity. Measured: `dist/` 5.0 MB → 3.0 MB, `stop.mjs` 281,400 →
|
|
55
|
+
* 164,937 bytes. Splitting would take it to 548 KB and cannot be done until no library module self-executes
|
|
56
|
+
* ([/decisions/ad-098.md](/decisions/ad-098.md)).
|
|
57
|
+
*
|
|
58
|
+
* invariant: safe because nothing here reads a function or class name at runtime, and no stack trace reaches an
|
|
59
|
+
* operator — both checked before turning it on. Renaming locals is all this does.
|
|
60
|
+
*/
|
|
52
61
|
function buildOne(source, out) {
|
|
53
62
|
const result = spawnSync(
|
|
54
63
|
"bun",
|
|
55
|
-
["build", "--target=node", "--format=esm", `--outfile=${out}`, source],
|
|
64
|
+
["build", "--target=node", "--format=esm", "--minify", `--outfile=${out}`, source],
|
|
56
65
|
{ stdio: "inherit" },
|
|
57
66
|
);
|
|
58
67
|
if (result.error?.code === "ENOENT") {
|
package/bin/tlc-cli.ts
CHANGED
|
@@ -936,18 +936,24 @@ export function globalPackageRoot(
|
|
|
936
936
|
* invariant: the *package's* launcher runs the materialisation, not the runtime home's. A release that fixes
|
|
937
937
|
* `install` has to be able to deliver that fix, and the old code cannot do it.
|
|
938
938
|
*
|
|
939
|
-
* invariant:
|
|
940
|
-
*
|
|
941
|
-
*
|
|
939
|
+
* invariant: only the **source** is named. `TLC_ORIGIN` is the one end this can know; the destination belongs to
|
|
940
|
+
* `installDest`, which exists because on a first npm run the *resolved* home is the package itself
|
|
941
|
+
* ([/decisions/ad-056.md](/decisions/ad-056.md)).
|
|
942
|
+
*
|
|
943
|
+
* hazard: the first version of this named the destination too, as `runtimeHome()`, and walked straight into that.
|
|
944
|
+
* On a clean machine it wrote `config.json` and the price catalogue into
|
|
945
|
+
* `node_modules/@tech-leads-club/harness-toolkit`, copied nothing, and then crashed writing hooks — Node refuses
|
|
946
|
+
* to strip types under `node_modules` ([/decisions/ad-098.md](/decisions/ad-098.md)).
|
|
942
947
|
*/
|
|
943
|
-
export function npmSyncPlan(
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
948
|
+
export function npmSyncPlan(packageRoot: string): {
|
|
949
|
+
command: string;
|
|
950
|
+
args: string[];
|
|
951
|
+
env: Record<string, string>;
|
|
952
|
+
} {
|
|
947
953
|
return {
|
|
948
954
|
command: process.execPath,
|
|
949
955
|
args: [join(packageRoot, "bin", "tlc-exec.mjs"), "install-runtime"],
|
|
950
|
-
env: { TLC_ORIGIN: packageRoot
|
|
956
|
+
env: { TLC_ORIGIN: packageRoot },
|
|
951
957
|
};
|
|
952
958
|
}
|
|
953
959
|
|
|
@@ -1042,8 +1048,9 @@ export type Action =
|
|
|
1042
1048
|
| { kind: "policy"; accept: string[] }
|
|
1043
1049
|
| { kind: "prices-help" }
|
|
1044
1050
|
| { kind: "prices-refresh"; scope: string }
|
|
1045
|
-
| { kind: "prices-lookup"; modelId: string }
|
|
1051
|
+
| { kind: "prices-lookup"; modelId: string; provider: string }
|
|
1046
1052
|
| { kind: "entry"; entry: string; args: string[] }
|
|
1053
|
+
| { kind: "install"; args: string[] }
|
|
1047
1054
|
| { kind: "unknown"; cmd: string };
|
|
1048
1055
|
|
|
1049
1056
|
export function route(args: string[]): Action {
|
|
@@ -1139,10 +1146,17 @@ export function route(args: string[]): Action {
|
|
|
1139
1146
|
const modelId = args[2];
|
|
1140
1147
|
if (!modelId) {
|
|
1141
1148
|
throw new UsageError(
|
|
1142
|
-
"usage: tlc harness prices lookup <model-id
|
|
1149
|
+
"usage: tlc harness prices lookup <model-id> [provider]\ndetail: tlc harness help prices",
|
|
1143
1150
|
);
|
|
1144
1151
|
}
|
|
1145
|
-
|
|
1152
|
+
/**
|
|
1153
|
+
* hazard: the provider was parsed by the tool and dropped by this route, so every lookup ran with an empty
|
|
1154
|
+
* provider — which is the one input that matches no provider plane. `prices lookup composer-2.5 cursor`
|
|
1155
|
+
* answered `source: missing` for a model priced `$0.5/$2.5`, while the same call straight to the tool
|
|
1156
|
+
* resolved it. The help and `docs/measure.md` had documented the argument all along
|
|
1157
|
+
* ([/decisions/ad-098.md](/decisions/ad-098.md)).
|
|
1158
|
+
*/
|
|
1159
|
+
return { kind: "prices-lookup", modelId, provider: args[3] ?? "" };
|
|
1146
1160
|
}
|
|
1147
1161
|
throw new UsageError(
|
|
1148
1162
|
"usage: tlc harness prices refresh [all|cursor|litellm] | tlc harness prices lookup <model>\ndetail: tlc harness help prices",
|
|
@@ -1162,7 +1176,7 @@ export function route(args: string[]): Action {
|
|
|
1162
1176
|
case "init":
|
|
1163
1177
|
return { kind: "entry", entry: "init-project", args: args.slice(1) };
|
|
1164
1178
|
case "install":
|
|
1165
|
-
return { kind: "
|
|
1179
|
+
return { kind: "install", args: args.slice(1) };
|
|
1166
1180
|
// why: the exit has to be as easy to find as the entrance. An operator who cannot get the harness off their
|
|
1167
1181
|
// machine without hand-editing settings.json will not try it on a second one
|
|
1168
1182
|
// ([/decisions/ad-066.md](/decisions/ad-066.md)).
|
|
@@ -1353,7 +1367,7 @@ function runUpdate(root: string): never {
|
|
|
1353
1367
|
console.error(npmRootFailureMessage(home));
|
|
1354
1368
|
process.exit(1);
|
|
1355
1369
|
}
|
|
1356
|
-
const plan = npmSyncPlan(packageRoot
|
|
1370
|
+
const plan = npmSyncPlan(packageRoot);
|
|
1357
1371
|
const sync = spawnSync(plan.command, plan.args, {
|
|
1358
1372
|
stdio: "inherit",
|
|
1359
1373
|
env: { ...process.env, ...plan.env },
|
|
@@ -1451,6 +1465,31 @@ function runEntry(entry: string, toolArgs: string[], root: string): never {
|
|
|
1451
1465
|
process.exit(r.status ?? 1);
|
|
1452
1466
|
}
|
|
1453
1467
|
|
|
1468
|
+
/**
|
|
1469
|
+
* `install`, which is the only entry that must run from the *package* rather than from the runtime it is about to
|
|
1470
|
+
* replace.
|
|
1471
|
+
*
|
|
1472
|
+
* hazard: it went through `runEntry`, so the runtime home's own launcher ran the runtime home's own
|
|
1473
|
+
* `install-runtime`, whose source and destination then resolved to the same directory. Measured: package at 0.3.3,
|
|
1474
|
+
* runtime left on 0.3.1, with the command reporting success — and this is the recovery route the README and every
|
|
1475
|
+
* failure message name ([/decisions/ad-098.md](/decisions/ad-098.md)).
|
|
1476
|
+
*
|
|
1477
|
+
* invariant: `--link` stays local. It points the runtime at the checkout the operator is standing in, so its
|
|
1478
|
+
* source is the working directory and never the package.
|
|
1479
|
+
*/
|
|
1480
|
+
function runInstall(toolArgs: string[], root: string): never {
|
|
1481
|
+
const packageRoot = toolArgs.includes("--link") ? null : globalPackageRoot();
|
|
1482
|
+
if (packageRoot === null) {
|
|
1483
|
+
runEntry("install-runtime", toolArgs, root);
|
|
1484
|
+
}
|
|
1485
|
+
const plan = npmSyncPlan(packageRoot);
|
|
1486
|
+
const r = spawnSync(plan.command, [...plan.args, ...toolArgs], {
|
|
1487
|
+
stdio: "inherit",
|
|
1488
|
+
env: { ...process.env, ...plan.env, TLC_PROJECT_DIR: root },
|
|
1489
|
+
});
|
|
1490
|
+
process.exit(r.status ?? 1);
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1454
1493
|
function main(argv: string[]): void {
|
|
1455
1494
|
const root = resolveProjectRoot();
|
|
1456
1495
|
const group = (argv[0] ?? "").toLowerCase();
|
|
@@ -1612,7 +1651,15 @@ function main(argv: string[]): void {
|
|
|
1612
1651
|
runEntry("refresh-model-prices", [action.scope], root);
|
|
1613
1652
|
break;
|
|
1614
1653
|
case "prices-lookup":
|
|
1615
|
-
runEntry(
|
|
1654
|
+
runEntry(
|
|
1655
|
+
"price-lookup",
|
|
1656
|
+
// invariant: the provider reaches the tool, or the lookup can only ever match the vendor plane.
|
|
1657
|
+
[action.modelId, ...(action.provider ? [action.provider] : []), ...(json ? [JSON_FLAG] : [])],
|
|
1658
|
+
root,
|
|
1659
|
+
);
|
|
1660
|
+
break;
|
|
1661
|
+
case "install":
|
|
1662
|
+
runInstall(action.args, root);
|
|
1616
1663
|
break;
|
|
1617
1664
|
case "entry":
|
|
1618
1665
|
runEntry(action.entry, json ? [...action.args, JSON_FLAG] : action.args, root);
|