@tech-leads-club/harness-toolkit 0.3.6 → 0.4.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 (74) hide show
  1. package/README.md +44 -8
  2. package/bin/tlc-cli.ts +90 -18
  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 +88 -82
  12. package/dist/obs-cli.mjs +84 -78
  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 +86 -80
  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 +61 -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 +93 -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 +113 -4
  65. package/src/platform/pricing.ts +3 -3
  66. package/src/platform/screen.ts +62 -3
  67. package/src/providers/index.ts +1 -0
  68. package/tools/doctor.ts +166 -27
  69. package/tools/help-topic.ts +39 -23
  70. package/tools/init-project.ts +51 -6
  71. package/tools/install-runtime.ts +17 -2
  72. package/tools/lessons-cli.ts +4 -1
  73. package/tools/refresh-model-prices.ts +2 -2
  74. 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 D}from"node:module";var _=D(import.meta.url);function H(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 x(P,G=T){G(`${JSON.stringify(P)}
2
+ `)}function T(P){process.stdout.write(P)}import{existsSync as z,readFileSync as f}from"node:fs";import{join as O}from"node:path";import{homedir as E}from"node:os";import{delimiter as i,join as S,resolve as n}from"node:path";function C(){return S(E(),".tlc","harness")}function b(P=process.env){return P.TLC_HOME??C()}function U(P=process.env){return P.TLC_HOME_FROM_ENV==="0"?C():b(P)}var j="litellm",p={"cursor-grok-4.5":"grok-4.5",auto:"auto-cost"};function k(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 g(P,G){let J=P.trim(),Q=[],Y=(V)=>{if(V&&!Q.includes(V))Q.push(V)};if(Y(J),Y(G[J]),Y(L(J)),Y(G[L(J)]),J.includes("/"))Y(J.slice(J.lastIndexOf("/")+1));let K=J.replace(/-(high|medium|low|max|fast|thinking)$/i,"");if(K!==J)Y(K),Y(G[K]),Y(L(K));return Q}function W(P,G){let J=P[G];if(J)return{key:G,entry:J};for(let[Q,Y]of Object.entries(P))if(G.startsWith(Q)||Q.startsWith(G))return{key:Q,entry:Y};return}function v(){return O(U(),"model-prices.json")}function y(){return O(U(),"model-prices.local.json")}var A=new Map;function N(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 N(v())??{}}function F(P,G){return k(P.planes?.[G]??null)}function M(P,G){let J=G.trim();if(!J)return;let Q=c(),Y=k(N(y())),K=P?F(Q,P):{},V=F(Q,j),B=g(J,p);for(let $ of B){let q=Y[$];if(q)return{entry:q,key:$,source:"override"}}for(let $ of B){let q=K[$];if(q)return{entry:q,key:$,source:"provider"}}for(let $ of B){let q=V[$];if(q)return{entry:q,key:$,source:"litellm"}}let Z=L(J),I=W(Y,Z);if(I)return{...I,source:"override"};let X=W(K,Z);if(X)return{...X,source:"provider"};let R=W(V,Z);if(R)return{...R,source:"litellm"};return}function w(P,G,J){let Q=J.inputTokens??0,Y=J.outputTokens??0,K=J.cacheReadTokens??0,V=J.cacheWriteTokens??0;if(!G||Q<=0&&Y<=0&&K<=0&&V<=0)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let B=M(P,G);if(!B)return{costUsd:null,billing:"unknown",pool:"unknown",source:"missing"};let{entry:Z,key:I,source:X}=B,R=Z.pool??"unknown";if(Z.billing==="included")return{costUsd:null,billing:"included",pool:R,source:X,catalogKey:I};if(typeof Z.promptPer1M!=="number"||typeof Z.completionPer1M!=="number")return{costUsd:null,billing:Z.billing??"unknown",pool:R,source:X,catalogKey:I};let $=Q/1e6*Z.promptPer1M+Y/1e6*Z.completionPer1M;if(typeof Z.cacheReadPer1M==="number"&&K>0)$+=K/1e6*Z.cacheReadPer1M;if(typeof Z.cacheWritePer1M==="number"&&V>0)$+=V/1e6*Z.cacheWritePer1M;return{costUsd:$,billing:"metered",pool:R,source:X,catalogKey:I}}function u(P){let G=P[0];if(!G)return null;return{model:G,provider:P[1]??""}}function m(P){let G=M(P.provider,P.model),J=w(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}=H(process.argv.slice(2)),J=u(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=m(J);if(P)x(Q);else console.log(JSON.stringify(Q,null,2));if(!Q.resolved)process.exit(2)}if(_.main==_.module)l();export{u as parsePriceLookupArgs,m as lookupPrice};