@tech-leads-club/harness-toolkit 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/README.md +44 -8
  2. package/bin/tlc-cli.ts +40 -1
  3. package/bin/tlc-exec.d.mts +1 -0
  4. package/bin/tlc-exec.mjs +47 -2
  5. package/capabilities/catalog.json +47 -30
  6. package/dist/compact-before.mjs +84 -78
  7. package/dist/doctor.mjs +87 -81
  8. package/dist/help-topic.mjs +6 -5
  9. package/dist/init-project.mjs +147 -9
  10. package/dist/install-runtime.mjs +85 -79
  11. package/dist/lessons-cli.mjs +87 -81
  12. package/dist/obs-cli.mjs +83 -77
  13. package/dist/price-lookup.mjs +2 -2
  14. package/dist/prompt-submit.mjs +84 -78
  15. package/dist/refresh-model-prices.mjs +85 -79
  16. package/dist/response-after.mjs +84 -78
  17. package/dist/run.mjs +84 -78
  18. package/dist/session-end.mjs +90 -84
  19. package/dist/session-start.mjs +92 -86
  20. package/dist/shim.mjs +82 -76
  21. package/dist/stop.mjs +90 -84
  22. package/dist/subagent-start.mjs +84 -78
  23. package/dist/subagent-stop.mjs +85 -79
  24. package/dist/support.mjs +88 -82
  25. package/dist/tlc-cli.mjs +104 -98
  26. package/dist/tool-after.mjs +84 -78
  27. package/dist/tool-before.mjs +84 -78
  28. package/dist/tool-failure.mjs +84 -78
  29. package/dist/uninstall-runtime.mjs +4 -4
  30. package/docs/architecture.md +1 -0
  31. package/docs/concepts.md +86 -0
  32. package/docs/diagnose.md +20 -0
  33. package/docs/init.md +10 -2
  34. package/docs/lessons.md +12 -0
  35. package/docs/log.md +5 -0
  36. package/package.json +1 -1
  37. package/skills/harness-init/references/capabilities.md +54 -0
  38. package/src/core/core.facade.ts +54 -0
  39. package/src/core/floor/floor.paths.ts +2 -2
  40. package/src/core/floor/floor.policy-surface.ts +6 -1
  41. package/src/core/lesson/lesson.select.ts +30 -7
  42. package/src/core/policy/policy.defaults.ts +3 -0
  43. package/src/core/policy/policy.integrity.ts +2 -2
  44. package/src/core/policy/policy.loader.ts +14 -3
  45. package/src/core/policy/policy.shadow.ts +97 -0
  46. package/src/core/policy/policy.types.ts +8 -0
  47. package/src/core/release/release.decisions.ts +3 -13
  48. package/src/core/rules/rules.decide.ts +123 -0
  49. package/src/core/rules/rules.observe.ts +76 -0
  50. package/src/core/rules/rules.parse.ts +142 -0
  51. package/src/core/rules/rules.proof.ts +130 -0
  52. package/src/core/rules/rules.service.ts +141 -0
  53. package/src/core/rules/rules.store.ts +77 -0
  54. package/src/core/rules/rules.trigger.ts +101 -0
  55. package/src/core/rules/rules.types.ts +64 -0
  56. package/src/entrypoints/shim.ts +9 -1
  57. package/src/entrypoints/stop.ts +75 -1
  58. package/src/entrypoints/subagent-stop.ts +9 -1
  59. package/src/entrypoints/support.ts +32 -0
  60. package/src/entrypoints/tool-after.ts +7 -2
  61. package/src/entrypoints/tool-before.ts +44 -3
  62. package/src/platform/frontmatter.ts +142 -0
  63. package/src/platform/links.ts +32 -0
  64. package/src/platform/paths.ts +58 -4
  65. package/src/platform/pricing.ts +3 -3
  66. package/src/platform/screen.ts +62 -3
  67. package/tools/doctor.ts +162 -2
  68. package/tools/help-topic.ts +39 -23
  69. package/tools/init-project.ts +51 -6
  70. package/tools/install-runtime.ts +23 -2
  71. package/tools/lessons-cli.ts +4 -1
  72. package/tools/refresh-model-prices.ts +2 -2
  73. package/tools/uninstall-runtime.ts +11 -3
@@ -1,2 +1,2 @@
1
- import{createRequire as E}from"node:module";var H=E(import.meta.url);function M(P){let x=[],J=!1;for(let G of P){if(G==="--json"){J=!0;continue}x.push(G)}return{json:J,rest:x}}function _(P,x=N){x(`${JSON.stringify(P)}
2
- `)}function N(P){process.stdout.write(P)}import{existsSync as D,readFileSync as z}from"node:fs";import{join as k}from"node:path";import{homedir as S}from"node:os";import{join as T}from"node:path";function b(){return T(S(),".tlc","harness")}function L(P=process.env){return P.TLC_HOME??b()}var f="litellm",j={"cursor-grok-4.5":"grok-4.5",auto:"auto-cost"};function F(P){if(!P)return{};let{_meta:x,...J}=P;return J}function A(P){return P.trim().toLowerCase().replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[[\]]/g,"").replace(/[^a-z0-9.+]+/g,"-").replace(/^-+|-+$/g,"")}function p(P,x){let J=P.trim(),G=[],Q=($)=>{if($&&!G.includes($))G.push($)};if(Q(J),Q(x[J]),Q(A(J)),Q(x[A(J)]),J.includes("/"))Q(J.slice(J.lastIndexOf("/")+1));let Z=J.replace(/-(high|medium|low|max|fast|thinking)$/i,"");if(Z!==J)Q(Z),Q(x[Z]),Q(A(Z));return G}function U(P,x){let J=P[x];if(J)return{key:x,entry:J};for(let[G,Q]of Object.entries(P))if(x.startsWith(G)||G.startsWith(x))return{key:G,entry:Q};return}function v(){return k(L(),"model-prices.json")}function g(){return k(L(),"model-prices.local.json")}var R=new Map;function O(P){if(!D(P))return R.delete(P),null;let x;try{x=z(P,"utf8")}catch{return R.delete(P),null}let J=R.get(P);if(J&&J.text===x)return J.value;let G;try{G=JSON.parse(x)}catch{return R.delete(P),null}return R.set(P,{text:x,value:G}),G}function y(){return O(v())??{}}function C(P,x){return F(P.planes?.[x]??null)}function W(P,x){let J=x.trim();if(!J)return;let G=y(),Q=F(O(g())),Z=P?C(G,P):{},$=C(G,f),B=p(J,j);for(let Y of B){let q=Q[Y];if(q)return{entry:q,key:Y,source:"override"}}for(let Y of B){let q=Z[Y];if(q)return{entry:q,key:Y,source:"provider"}}for(let Y of B){let q=$[Y];if(q)return{entry:q,key:Y,source:"litellm"}}let X=A(J),I=U(Q,X);if(I)return{...I,source:"override"};let K=U(Z,X);if(K)return{...K,source:"provider"};let V=U($,X);if(V)return{...V,source:"litellm"};return}function w(P,x,J){let G=J.inputTokens??0,Q=J.outputTokens??0,Z=J.cacheReadTokens??0,$=J.cacheWriteTokens??0;if(!x||G<=0&&Q<=0&&Z<=0&&$<=0)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let B=W(P,x);if(!B)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let{entry:X,key:I,source:K}=B,V=X.pool??"unknown";if(X.billing==="included")return{costUsd:null,billing:"included",pool:V,source:K,catalogKey:I};if(typeof X.promptPer1M!=="number"||typeof X.completionPer1M!=="number")return{costUsd:null,billing:X.billing??"unknown",pool:V,source:K,catalogKey:I};let Y=G/1e6*X.promptPer1M+Q/1e6*X.completionPer1M;if(typeof X.cacheReadPer1M==="number"&&Z>0)Y+=Z/1e6*X.cacheReadPer1M;if(typeof X.cacheWritePer1M==="number"&&$>0)Y+=$/1e6*X.cacheWritePer1M;return{costUsd:Y,billing:"metered",pool:V,source:K,catalogKey:I}}function c(P){let x=P[0];if(!x)return null;return{model:x,provider:P[1]??""}}function m(P){let x=W(P.provider,P.model),J=w(P.provider,P.model,{inputTokens:1e6,outputTokens:1e6});return{model:P.model,provider:P.provider,resolved:x,per1M:J}}function u(){let{json:P,rest:x}=M(process.argv.slice(2)),J=c(x);if(!J)console.error("usage: tlc harness prices lookup <model-id> [provider]"),console.error(" or: node --experimental-strip-types tools/price-lookup.ts <model-id> [provider] (dev)"),process.exit(1);let G=m(J);if(P)_(G);else console.log(JSON.stringify(G,null,2));if(!G.resolved)process.exit(2)}if(H.main==H.module)u();export{c as parsePriceLookupArgs,m as lookupPrice};
1
+ import{createRequire as T}from"node:module";var k=T(import.meta.url);function M(P){let G=[],J=!1;for(let Q of P){if(Q==="--json"){J=!0;continue}G.push(Q)}return{json:J,rest:G}}function _(P,G=w){G(`${JSON.stringify(P)}
2
+ `)}function w(P){process.stdout.write(P)}import{existsSync as z,readFileSync as f}from"node:fs";import{join as E}from"node:path";import{homedir as S}from"node:os";import{delimiter as o,join as b,resolve as n}from"node:path";function C(){return b(S(),".tlc","harness")}function D(P=process.env){return P.TLC_HOME??C()}function R(P=process.env){return P.TLC_HOME_FROM_ENV==="0"?C():D(P)}var p="litellm",j={"cursor-grok-4.5":"grok-4.5",auto:"auto-cost"};function F(P){if(!P)return{};let{_meta:G,...J}=P;return J}function L(P){return P.trim().toLowerCase().replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/[[\]]/g,"").replace(/[^a-z0-9.+]+/g,"-").replace(/^-+|-+$/g,"")}function v(P,G){let J=P.trim(),Q=[],X=(q)=>{if(q&&!Q.includes(q))Q.push(q)};if(X(J),X(G[J]),X(L(J)),X(G[L(J)]),J.includes("/"))X(J.slice(J.lastIndexOf("/")+1));let $=J.replace(/-(high|medium|low|max|fast|thinking)$/i,"");if($!==J)X($),X(G[$]),X(L($));return Q}function U(P,G){let J=P[G];if(J)return{key:G,entry:J};for(let[Q,X]of Object.entries(P))if(G.startsWith(Q)||Q.startsWith(G))return{key:Q,entry:X};return}function g(){return E(R(),"model-prices.json")}function y(){return E(R(),"model-prices.local.json")}var A=new Map;function O(P){if(!z(P))return A.delete(P),null;let G;try{G=f(P,"utf8")}catch{return A.delete(P),null}let J=A.get(P);if(J&&J.text===G)return J.value;let Q;try{Q=JSON.parse(G)}catch{return A.delete(P),null}return A.set(P,{text:G,value:Q}),Q}function c(){return O(g())??{}}function H(P,G){return F(P.planes?.[G]??null)}function W(P,G){let J=G.trim();if(!J)return;let Q=c(),X=F(O(y())),$=P?H(Q,P):{},q=H(Q,p),B=v(J,j);for(let Z of B){let x=X[Z];if(x)return{entry:x,key:Z,source:"override"}}for(let Z of B){let x=$[Z];if(x)return{entry:x,key:Z,source:"provider"}}for(let Z of B){let x=q[Z];if(x)return{entry:x,key:Z,source:"litellm"}}let Y=L(J),I=U(X,Y);if(I)return{...I,source:"override"};let K=U($,Y);if(K)return{...K,source:"provider"};let V=U(q,Y);if(V)return{...V,source:"litellm"};return}function N(P,G,J){let Q=J.inputTokens??0,X=J.outputTokens??0,$=J.cacheReadTokens??0,q=J.cacheWriteTokens??0;if(!G||Q<=0&&X<=0&&$<=0&&q<=0)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let B=W(P,G);if(!B)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let{entry:Y,key:I,source:K}=B,V=Y.pool??"unknown";if(Y.billing==="included")return{costUsd:null,billing:"included",pool:V,source:K,catalogKey:I};if(typeof Y.promptPer1M!=="number"||typeof Y.completionPer1M!=="number")return{costUsd:null,billing:Y.billing??"unknown",pool:V,source:K,catalogKey:I};let Z=Q/1e6*Y.promptPer1M+X/1e6*Y.completionPer1M;if(typeof Y.cacheReadPer1M==="number"&&$>0)Z+=$/1e6*Y.cacheReadPer1M;if(typeof Y.cacheWritePer1M==="number"&&q>0)Z+=q/1e6*Y.cacheWritePer1M;return{costUsd:Z,billing:"metered",pool:V,source:K,catalogKey:I}}function m(P){let G=P[0];if(!G)return null;return{model:G,provider:P[1]??""}}function u(P){let G=W(P.provider,P.model),J=N(P.provider,P.model,{inputTokens:1e6,outputTokens:1e6});return{model:P.model,provider:P.provider,resolved:G,per1M:J}}function l(){let{json:P,rest:G}=M(process.argv.slice(2)),J=m(G);if(!J)console.error("usage: tlc harness prices lookup <model-id> [provider]"),console.error(" or: node --experimental-strip-types tools/price-lookup.ts <model-id> [provider] (dev)"),process.exit(1);let Q=u(J);if(P)_(Q);else console.log(JSON.stringify(Q,null,2));if(!Q.resolved)process.exit(2)}if(k.main==k.module)l();export{m as parsePriceLookupArgs,u as lookupPrice};