@tech-leads-club/harness-toolkit 0.16.0 → 0.16.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.
- package/dist/compact-before.mjs +1 -1
- package/dist/doctor.mjs +1 -1
- package/dist/prompt-submit.mjs +33 -33
- package/dist/response-after.mjs +1 -1
- package/dist/run.mjs +1 -1
- package/dist/session-end.mjs +1 -1
- package/dist/session-start.mjs +1 -1
- package/dist/ship-gate.mjs +75 -75
- package/dist/stop.mjs +80 -80
- package/dist/subagent-start.mjs +1 -1
- package/dist/subagent-stop.mjs +1 -1
- package/dist/support.mjs +10 -10
- package/dist/tool-after.mjs +71 -71
- package/dist/tool-before.mjs +80 -80
- package/dist/tool-failure.mjs +1 -1
- package/docs/log.md +4 -0
- package/package.json +1 -1
- package/src/core/handoff/handoff.types.ts +7 -0
- package/src/entrypoints/prompt-submit.ts +8 -3
- package/src/entrypoints/stop.ts +4 -2
- package/src/entrypoints/support.ts +25 -3
- package/src/entrypoints/tool-after.ts +2 -2
- package/src/providers/cursor/cursor.wiring.ts +1 -1
package/dist/compact-before.mjs
CHANGED
|
@@ -157,6 +157,6 @@ description: Harness-learned lessons (auto-synced from gate failures)
|
|
|
157
157
|
alwaysApply: true
|
|
158
158
|
---
|
|
159
159
|
|
|
160
|
-
${J}`;return XV(Q,q,"utf8"),Q}function u3($,Z){let J={permission:$};if(Z.userNote!==void 0)J.user_message=Z.userNote;return J.agent_message=Z.reason,JSON.stringify(J)}function h3($,Z){switch($.kind){case"abstain":return{stdout:"{}",exitCode:0};case"allow":return{stdout:JSON.stringify({permission:"allow"}),exitCode:0};case"deny":return{stdout:u3("deny",$),exitCode:0};case"ask":return{stdout:u3("ask",$),exitCode:0};case"context":{let J={};if($.env!==void 0)J.env=$.env;return J.additional_context=$.text,{stdout:JSON.stringify(J),exitCode:0}}case"continue":return{stdout:JSON.stringify({followup_message:$.text}),exitCode:0};case"rewriteInput":return{stdout:JSON.stringify({updated_input:$.input}),exitCode:0};case"rewriteOutput":return{stdout:JSON.stringify({updated_mcp_tool_output:{result_json:$.output}}),exitCode:0};default:throw Error(`unreachable decision kind: ${JSON.stringify($)}`)}}function p3(){return{blockedPatterns:["-fast(?:$|[^a-z0-9])","/fast(?:$|[^a-z0-9])","composer-2\\.5-fast"],minEffort:null,untrustedTools:["Fetch","WebSearch"]}}import{join as zV}from"node:path";function c3(){return zV(J9(),"hooks.json")}function d3(){return[c3()]}var VV=[{hookEvent:"sessionStart",handler:"session-start",timeoutSeconds:10},{hookEvent:"sessionEnd",handler:"session-end",timeoutSeconds:10},{hookEvent:"beforeSubmitPrompt",handler:"prompt-submit",timeoutSeconds:5},{hookEvent:"afterAgentThought",handler:"tool-after",timeoutSeconds:5},{hookEvent:"preCompact",handler:"compact-before",timeoutSeconds:5},{hookEvent:"subagentStart",handler:"subagent-start",timeoutSeconds:5,failClosed:!0},{hookEvent:"subagentStop",handler:"subagent-stop",timeoutSeconds:5},{hookEvent:"preToolUse",handler:"tool-before",timeoutSeconds:
|
|
160
|
+
${J}`;return XV(Q,q,"utf8"),Q}function u3($,Z){let J={permission:$};if(Z.userNote!==void 0)J.user_message=Z.userNote;return J.agent_message=Z.reason,JSON.stringify(J)}function h3($,Z){switch($.kind){case"abstain":return{stdout:"{}",exitCode:0};case"allow":return{stdout:JSON.stringify({permission:"allow"}),exitCode:0};case"deny":return{stdout:u3("deny",$),exitCode:0};case"ask":return{stdout:u3("ask",$),exitCode:0};case"context":{let J={};if($.env!==void 0)J.env=$.env;return J.additional_context=$.text,{stdout:JSON.stringify(J),exitCode:0}}case"continue":return{stdout:JSON.stringify({followup_message:$.text}),exitCode:0};case"rewriteInput":return{stdout:JSON.stringify({updated_input:$.input}),exitCode:0};case"rewriteOutput":return{stdout:JSON.stringify({updated_mcp_tool_output:{result_json:$.output}}),exitCode:0};default:throw Error(`unreachable decision kind: ${JSON.stringify($)}`)}}function p3(){return{blockedPatterns:["-fast(?:$|[^a-z0-9])","/fast(?:$|[^a-z0-9])","composer-2\\.5-fast"],minEffort:null,untrustedTools:["Fetch","WebSearch"]}}import{join as zV}from"node:path";function c3(){return zV(J9(),"hooks.json")}function d3(){return[c3()]}var VV=[{hookEvent:"sessionStart",handler:"session-start",timeoutSeconds:10},{hookEvent:"sessionEnd",handler:"session-end",timeoutSeconds:10},{hookEvent:"beforeSubmitPrompt",handler:"prompt-submit",timeoutSeconds:5},{hookEvent:"afterAgentThought",handler:"tool-after",timeoutSeconds:5},{hookEvent:"preCompact",handler:"compact-before",timeoutSeconds:5},{hookEvent:"subagentStart",handler:"subagent-start",timeoutSeconds:5,failClosed:!0},{hookEvent:"subagentStop",handler:"subagent-stop",timeoutSeconds:5},{hookEvent:"preToolUse",handler:"tool-before",timeoutSeconds:10,failClosed:!0},{hookEvent:"postToolUse",handler:"tool-after",timeoutSeconds:5},{hookEvent:"postToolUseFailure",handler:"tool-failure",timeoutSeconds:5},{hookEvent:"beforeShellExecution",handler:"tool-before",timeoutSeconds:10,failClosed:!0},{hookEvent:"afterShellExecution",handler:"tool-after",timeoutSeconds:10},{hookEvent:"beforeMCPExecution",handler:"tool-before",timeoutSeconds:10},{hookEvent:"afterMCPExecution",handler:"tool-after",timeoutSeconds:5},{hookEvent:"beforeReadFile",handler:"tool-before",timeoutSeconds:5},{hookEvent:"afterFileEdit",handler:"tool-after",timeoutSeconds:30,matcher:"Write"},{hookEvent:"stop",handler:"stop",timeoutSeconds:120,loopLimit:5},{hookEvent:"afterAgentResponse",handler:"response-after",timeoutSeconds:5,matcher:"AgentResponse"}];function l3($){let J=[$.launcherPath],Q=VV.map((q)=>({hookEvent:q.hookEvent,handler:q.handler,command:"node",args:[...J,q.handler],timeoutSeconds:q.timeoutSeconds,...q.failClosed!==void 0?{failClosed:q.failClosed}:{},...q.matcher!==void 0?{matcher:q.matcher}:{},...q.loopLimit!==void 0?{loopLimit:q.loopLimit}:{}}));return{target:c3(),strategy:"replace",entries:Q}}var i3={name:"cursor",detect:f3,capabilities:b3,policyDefaults:p3,toEvent:w3,render:h3,wiring:l3,wiringTargets:d3,lessonsView:g3};var y$=[i3,S3];function s5($,Z){let J=Z.filter((Q)=>Q.detect($));if(J.length===0)return{provider:null,ambiguous:!1,matchedNames:[]};return{provider:J[0]??null,ambiguous:J.length>1,matchedNames:J.map((Q)=>Q.name)}}var n3=P.observability.DEFAULT_OBS,WO={...n3,debugEnabled:!0};function l8($,Z=n3){return{...Z,globalSpool:$.obs.globalSpool,includePayloads:$.obs.includePayloads,maxAttrChars:$.obs.maxAttrChars,sessionCostAlertUsd:$.obs.sessionCostAlertUsd,retentionDays:$.obs.retentionDays}}function a3($){let Z=`${$.provider}-`;return $.sessionKey.startsWith(Z)?$.sessionKey.slice(Z.length):$.sessionKey}function r3($,Z){return[...P.policy.forProvider($,Z.name)??[],...Z.policyDefaults().blockedPatterns]}var BV=6000;function UV($){if($.filePath===void 0)return!1;if($.event==="edit.after")return!0;return _8($.toolName)}function HV($){return $ instanceof Error?$.message:String($)}function r($,Z,J,Q="unknown",q={}){try{L(GV(H($),"obs.jsonl"),{schema:"harness.observability.v1",provider:Q,kind:Z,level:"signal",ts:new Date().toISOString(),...q,attrs:J})}catch{}}function MV($){return $.event==="shell.before"||$.event==="mcp.before"}function KV($){if(!MV($))return;r($.projectDir,"hook.enter",{event:$.event,toolName:$.toolName??"none",sessionKey:$.sessionKey},$.provider,{trace_id:P.observability.deriveTraceId($.sessionKey),session_id:$.sessionKey})}function FV($,Z,J){if(J.kind!=="deny"&&J.kind!=="ask")return;if($.event==="shell.before")return;P.observability.recordObs($.projectDir,l8(Z),{provider:$.provider,kind:"policy.deny",sessionKey:$.sessionKey,attrs:{event:$.event,tool_name:$.toolName,permission:J.kind,rule:J.rule??"none",diagnostic:J.diagnostic??"none"}})}function CV($){return $!==null&&typeof $==="object"&&!Array.isArray($)?$:{}}async function OV($,Z={}){let J=Z.readStdin??R9,Q=Z.now?Z.now():new Date,q={stdout:null,exitCode:0},W=(await J()).trim();if(!W)return r(process.cwd(),"adapter.unrecognized",{reason:"empty-stdin"}),{event:null,decision:{kind:"abstain"},rendered:q};let Y;try{Y=JSON.parse(W)}catch{return r(process.cwd(),"adapter.unrecognized",{reason:"invalid-json"}),{event:null,decision:{kind:"abstain"},rendered:q}}let z=s5(Y,y$);if(!z.provider)return r(process.cwd(),"adapter.unrecognized",{reason:"no-provider-match"}),{event:null,decision:{kind:"abstain"},rendered:q};if(z.ambiguous)r(process.cwd(),"adapter.ambiguous",{matched:z.matchedNames});let V=z.provider,G=V.toEvent(CV(Y));if(!G)return r(process.cwd(),"adapter.unrecognized",{reason:"unrecognized-event",provider:V.name}),{event:null,decision:{kind:"abstain"},rendered:q};let U=V.capabilities();KV(G);try{let M=P.policy.loadPolicy(G.projectDir);if(G.model)P.subagentPolicy.upsertParentModelState(G.projectDir,G.sessionKey,{model:G.model},r3(M.subagents.blockedPatterns,V));P.presence.heartbeat(G.projectDir,{provider:G.provider,session:a3(G),...UV(G)?{file:G.filePath}:{},now:Q});let B=y$.flatMap((E)=>E.wiringTargets()),T=await $(G,{policy:M,capabilities:U,provider:V,now:Q,protectedPaths:B}),S=d8(T,G,U,{contextBudgetChars:BV});FV(G,M,S);let d=V.render(S,G);return{event:G,decision:S,rendered:d}}catch(M){r(G.projectDir,"adapter.error",{provider:G.provider,event:G.event,message:HV(M)});let B={kind:"abstain"};return{event:G,decision:B,rendered:V.render(B,G)}}}async function s3($){let Z=await OV($);if(Z.rendered.stdout!==null){let J=Z.rendered.stdout;process.stdout.write(J.endsWith(`
|
|
161
161
|
`)?J:`${J}
|
|
162
162
|
`)}process.exit(Z.rendered.exitCode)}var _V=($,Z)=>{return P.observability.recordFromEvent($.projectDir,l8(Z.policy),$),{kind:"abstain"}};if(t5.main==t5.module)await s3(_V);export{_V as compactBeforeHandler};
|
package/dist/doctor.mjs
CHANGED
|
@@ -157,5 +157,5 @@ description: Harness-learned lessons (auto-synced from gate failures)
|
|
|
157
157
|
alwaysApply: true
|
|
158
158
|
---
|
|
159
159
|
|
|
160
|
-
${Q}`;return iV(q,J,"utf8"),q}function Qq($,Z){let Q={permission:$};if(Z.userNote!==void 0)Q.user_message=Z.userNote;return Q.agent_message=Z.reason,JSON.stringify(Q)}function qq($,Z){switch($.kind){case"abstain":return{stdout:"{}",exitCode:0};case"allow":return{stdout:JSON.stringify({permission:"allow"}),exitCode:0};case"deny":return{stdout:Qq("deny",$),exitCode:0};case"ask":return{stdout:Qq("ask",$),exitCode:0};case"context":{let Q={};if($.env!==void 0)Q.env=$.env;return Q.additional_context=$.text,{stdout:JSON.stringify(Q),exitCode:0}}case"continue":return{stdout:JSON.stringify({followup_message:$.text}),exitCode:0};case"rewriteInput":return{stdout:JSON.stringify({updated_input:$.input}),exitCode:0};case"rewriteOutput":return{stdout:JSON.stringify({updated_mcp_tool_output:{result_json:$.output}}),exitCode:0};default:throw Error(`unreachable decision kind: ${JSON.stringify($)}`)}}function Jq(){return{blockedPatterns:["-fast(?:$|[^a-z0-9])","/fast(?:$|[^a-z0-9])","composer-2\\.5-fast"],minEffort:null,untrustedTools:["Fetch","WebSearch"]}}import{join as sV}from"node:path";function Xq(){return sV(QZ(),"hooks.json")}function Yq(){return[Xq()]}var Wq=[{hookEvent:"sessionStart",handler:"session-start",timeoutSeconds:10},{hookEvent:"sessionEnd",handler:"session-end",timeoutSeconds:10},{hookEvent:"beforeSubmitPrompt",handler:"prompt-submit",timeoutSeconds:5},{hookEvent:"afterAgentThought",handler:"tool-after",timeoutSeconds:5},{hookEvent:"preCompact",handler:"compact-before",timeoutSeconds:5},{hookEvent:"subagentStart",handler:"subagent-start",timeoutSeconds:5,failClosed:!0},{hookEvent:"subagentStop",handler:"subagent-stop",timeoutSeconds:5},{hookEvent:"preToolUse",handler:"tool-before",timeoutSeconds:5,failClosed:!0},{hookEvent:"postToolUse",handler:"tool-after",timeoutSeconds:5},{hookEvent:"postToolUseFailure",handler:"tool-failure",timeoutSeconds:5},{hookEvent:"beforeShellExecution",handler:"tool-before",timeoutSeconds:10,failClosed:!0},{hookEvent:"afterShellExecution",handler:"tool-after",timeoutSeconds:10},{hookEvent:"beforeMCPExecution",handler:"tool-before",timeoutSeconds:10},{hookEvent:"afterMCPExecution",handler:"tool-after",timeoutSeconds:5},{hookEvent:"beforeReadFile",handler:"tool-before",timeoutSeconds:5},{hookEvent:"afterFileEdit",handler:"tool-after",timeoutSeconds:30,matcher:"Write"},{hookEvent:"stop",handler:"stop",timeoutSeconds:120,loopLimit:5},{hookEvent:"afterAgentResponse",handler:"response-after",timeoutSeconds:5,matcher:"AgentResponse"}];function zq($){let Q=[$.launcherPath],q=Wq.map((J)=>({hookEvent:J.hookEvent,handler:J.handler,command:"node",args:[...Q,J.handler],timeoutSeconds:J.timeoutSeconds,...J.failClosed!==void 0?{failClosed:J.failClosed}:{},...J.matcher!==void 0?{matcher:J.matcher}:{},...J.loopLimit!==void 0?{loopLimit:J.loopLimit}:{}}));return{target:Xq(),strategy:"replace",entries:q}}function rV($){return[...$.matchAll(/"([^"]*)"|(\S+)/g)].map((Z)=>Z[1]??Z[2]??"")}function Vq($,Z,Q){if($===null)return[{hookEvent:"(file)",reason:"no hooks file at the expected path"}];let q;try{q=JSON.parse($)}catch{return[{hookEvent:"(file)",reason:"the hooks file is not valid JSON"}]}let J=q!==null&&typeof q==="object"?q.hooks??{}:{},X=[];for(let Y of Wq){let z=(Array.isArray(J[Y.hookEvent])?J[Y.hookEvent]:[]).map((V)=>V!==null&&typeof V==="object"?String(V.command??""):"").filter((V)=>V.includes(Z.launcherPath));if(z.length===0){X.push({hookEvent:Y.hookEvent,reason:"no harness entry — run: tlc harness update"});continue}for(let V of z){let G=rV(V),B=G.indexOf(Z.launcherPath);if(B<1){X.push({hookEvent:Y.hookEvent,reason:`no executable before the script: \`${V}\``});continue}if(!Q(Z.launcherPath)){X.push({hookEvent:Y.hookEvent,reason:`the script does not exist: ${Z.launcherPath}`});continue}if(G[B+1]===void 0||G[B+1]==="")X.push({hookEvent:Y.hookEvent,reason:`no handler after the script: \`${V}\``})}}return X}function Gq($,Z=3){let Q=$.slice(0,Z).map((J)=>`${J.hookEvent}: ${J.reason}`).join("; "),q=$.length-Math.min($.length,Z);return q>0?`${Q}; and ${q} more`:Q}var Bq={name:"cursor",detect:r1,capabilities:s1,policyDefaults:Jq,toEvent:t1,render:qq,wiring:zq,wiringTargets:Yq,lessonsView:Zq};var r8=[Bq,a1];var eV="tlc-exec.mjs";function Uq($){return oV($)&&tV($,"utf8").includes(eV)}import{existsSync as $G,readFileSync as ZG}from"node:fs";import{join as QG}from"node:path";function Kq(){return QG(n(),"model-prices.json")}var g$=new Map;function Hq($){if(!$G($))return g$.delete($),null;let Z;try{Z=ZG($,"utf8")}catch{return g$.delete($),null}let Q=g$.get($);if(Q&&Q.text===Z)return Q.value;let q;try{q=JSON.parse(Z)}catch{return g$.delete($),null}return g$.set($,{text:Z,value:q}),q}function qG(){return Hq(Kq())??{}}function Mq(){return qG()._meta?.planes??{}}function Cq(){let $=Hq(Kq());return $===null?null:$._meta??{}}function P($,Z){return`${$} ${Z}${$===1?"":"s"}`}var u$=24;function GG($){if($.length===0)return null;let Z=[...$].sort((q,J)=>q-J),Q=Math.floor(Z.length/2);return Z.length%2===1?Z[Q]:(Z[Q-1]+Z[Q])/2}function BG($){let Z=$.spawn??((J,X)=>({ok:(JG(J,X,{stdio:"ignore"}).status??1)===0})),Q=$.now??(()=>Date.now()),q=[];for(let J=0;J<($.samples??3);J+=1){let X=Q();if(!Z($.command,$.args).ok)return null;q.push(Q()-X)}return GG(q)}function UG($,Z=null){let Q=Number.parseInt($.replace(/^v/,"").split(".")[0]??"0",10),q=[{level:Q>=u$||Z!==null?"ok":"fail",name:"Node.js runtime",detail:Q>=u$?`${$} (>= ${u$})`:Z!==null?`${$} — below ${u$}, covered by Bun at ${Z}`:`${$} — no runtime for hooks. Install Bun (curl -fsSL https://bun.sh/install | bash) or Node ${u$}+ (nodejs.org), then reload the editor.`}];if(Q===25)q.push({level:"warn",name:"Node.js line",detail:"Node 25 is EOL — prefer 24 LTS or 26 Current"});return q}function KG($){let Z=R1($);return{level:Z==="managed"||Z==="linked"||Z==="npm"?"ok":"fail",name:"runtime ownership",detail:{managed:"managed checkout — `tlc harness update` moves it to upstream and owns its contents",linked:"link to a working clone — update never writes here; pull that clone yourself",npm:"installed from npm — `tlc harness update` bumps the package and re-materialises this directory",unmanaged:"not a git checkout — update cannot pull; install the package and run `tlc harness install`",absent:"missing — install the package, then run `tlc harness install`"}[Z]}}function HG($,Z=qZ(),Q={linkTarget:(q)=>{try{return Iq(q)}catch{try{return _q(q)}catch{return null}}},exists:j,realpath:(q)=>{try{return Iq(q)}catch{return q}}}){return Z.filter((q)=>j(q)).map((q)=>{let J=H.skill.linkHealth(w(q,"skills","harness-init"),$,Q);return{level:J.state==="ok"?"ok":"fail",name:`init skill (${zG(q)})`,detail:H.skill.linkHealthMessage(J)}})}function MG($=new Date,Z={meta:Cq,planes:Mq}){let Q=H.pricing.freshness(Z.meta(),$),q=Z.planes(),J=Object.entries(q).map(([X,Y])=>`${X} ${Y.count??0}`).join(", ");return[{level:Q.state==="fresh"?"ok":"warn",name:"prices",detail:Q.state==="fresh"?`${H.pricing.freshnessMessage(Q,"catalogue")}${J?` (${J})`:""}`:H.pricing.freshnessMessage(Q,"catalogue")}]}function CG($){let Z=H.policy.loadPolicy($),Q=H.rules.load($,Z.rules);if(Q.rules.length===0&&Q.disabled.length===0&&Q.errors.length===0)return Z.rules.enabled?[{level:"warn",name:"operator rules",detail:`enabled, and no rule file was found — nothing is enforced. A rule is one markdown file in ${H.rules.projectDir($)} (this repository) or ${H.rules.globalDir()} (every repository here); tlc harness help rules has the frontmatter`}]:[];let q=[];if(Q.rules.length>0)q.push({level:"ok",name:"operator rules",detail:Q.rules.map((J)=>`${J.name} (${J.tier}) on ${J.on.kind} → ${J.otherwise}`).join("; ")});if(Q.disabled.length>0)q.push({level:"ok",name:"operator rules (off here)",detail:Q.disabled.map((J)=>J.name).join(", ")});for(let J of Q.errors)q.push({level:"fail",name:`operator rule (${J.name})`,detail:`${J.error} — the other rules still apply`});for(let J of H.rules.unobservedKinds(Q.rules,H.rules.observations($)))q.push({level:"warn",name:`operator rule (${J.rule})`,detail:`needs ${J.kinds.join(", ")}, and no observation of that kind has been recorded in this project yet`});return q}function IG($,Z){let Q=P1($),q=w($,"bin","tlc-exec.mjs"),J=w($,"dist","stop.mjs"),X=XZ("tlc");return[{level:Q===null?"warn":"ok",name:"harness version",detail:Q??`unknown — no readable package.json at ${$}`},{level:"ok",name:"platform",detail:Z},{level:j(q)?"ok":"fail",name:"global runtime",detail:$},KG($),{level:j(J)?"ok":"fail",name:"dist bundles",detail:j(J)?w($,"dist"):"missing — run: tlc harness build"},{level:j(q)?"ok":"fail",name:"portable launcher",detail:q},{level:X===null?"fail":"ok",name:"CLI on PATH",detail:X??`no \`tlc\` on PATH — link it: ln -s ${w($,"bin","tlc")} ${w(JZ(),"tlc")} (or re-run \`tlc harness install\`, which does it)`}]}function OG($,Z,Q=BG){let q=Z??process.execPath,J=Z?`Bun (${Z})`:`Node + dist/ (${process.version})`,X=Q({command:q,args:["-e",""]}),Y=X===null?" — interpreter start could not be measured on this machine":` — interpreter start measured at ${X} ms here, paid once per hook`;return Z?{level:"ok",name:"hook runtime",detail:`${J}${Y}`}:{level:"warn",name:"hook runtime",detail:`${J}${Y}. Bun runs the source directly and starts faster — install: https://bun.sh`}}function Fq($){if($.strategy!=="replace")return[];let Z=j($.target)?Oq($.target,"utf8"):null;return Vq(Z,{launcherPath:_G($)},j)}function _G($){return $.entries[0]?.args.find((Q)=>Q.endsWith(".mjs"))??""}function FG($){if(!j(VG($.target)))return"not-installed";if($.strategy==="replace"){if(!Uq($.target))return"detected-but-unwired";return Fq($).length===0?"wired":"detected-but-unwired"}let Z=j($.target)?Oq($.target,"utf8"):null,Q=X5(Z,$.entries);return Q.ok&&!Q.changed?"wired":"detected-but-unwired"}function LG($,Z){let Q=w(Z,"bin","tlc-exec.mjs");return $.map((q)=>{let J=q.wiring({launcherPath:Q}),X=FG(J);if(X==="not-installed")return{level:"ok",name:`${q.name} wiring`,detail:"not installed"};if(X==="wired")return{level:"ok",name:`${q.name} wiring`,detail:`wired (${J.target})`};let Y=Fq(J),W=Y.length>0?` — ${Gq(Y)}`:"";return{level:"warn",name:`${q.name} wiring`,detail:`detected but not wired${W} — run: tlc harness update (${J.target})`}})}function NG($,Z){let Q=H.capability.loadCatalog(Z),q=H.capability.readProjectPolicyRaw($);if(!Q||!q)return[];let J=H.capability.listAvailableNotEnabled(H.policy.loadPolicy($),Q);if(J.length===0)return[];return[{level:"ok",name:"capabilities",detail:H.capability.formatAvailableInventory(J)}]}function DG($){let Z=H.policy.resolveProjectPosture($);if(Z.origin!=="fallback")return{level:"ok",name:"operator posture",detail:`${Z.mode} (from ${Z.origin})`};return{level:"warn",name:"operator posture",detail:`\`${Z.invalid}\` is not a posture — running as ${Z.mode}. Accepted: ${H.policy.OPERATOR_MODES.join(" | ")}. Fix \`mode\` in ${O($)}, or run: tlc harness mode <${H.policy.OPERATOR_MODES.join("|")}>`}}function jG($){let Z=H.policy.loadPolicy($);if(!Z.observe.enabled)return[];let Q=H.observe.unobservableRails(Z.observe.rails),q=H.observe.OBSERVABLE_RAILS.join(" | ");if(Z.observe.rails.length===0)return[{level:"warn",name:"observed rails",detail:`observation is on with no rails listed, so nothing is measured. Set \`observe.rails\` to one or more of: ${q}`}];if(Q.length===0)return[{level:"ok",name:"observed rails",detail:Z.observe.rails.join(", ")}];return[{level:"warn",name:"observed rails",detail:`no checker exists for ${Q.map((J)=>`\`${J}\``).join(", ")}, so nothing is recorded for them. Observable today: ${q}`}]}function TG($){let{subagents:Z}=H.policy.loadPolicy($);if(!Z.enforceAllowlist)return[];let Q=Z.allowedModels;if((Array.isArray(Q)?Q.length:Object.values(Q??{}).reduce((J,X)=>J+X.length,0))>0)return[];return[{level:"fail",name:"subagent allowlist",detail:"enforceAllowlist is on and subagents.allowedModels is empty, so it permits every model. The harness ships no list — add the model slugs you allow, or set enforceAllowlist to false."}]}function AG($){let Z=H.capability.readProjectPolicyRaw($);if(!Z)return[];let Q=H.policy.shadowedKeys(Z,H.policy.resolvedWithoutProjectTier());if(Q.length===0)return[];let q=Q.slice(0,6).map((X)=>X.path),J=Q.length-q.length;return[{level:"warn",name:"project policy restates lower tiers",detail:`${P(Q.length,"key")} in this project's config name the value ${Q.length===1?"it":"they"} would already have: ${q.join(", ")}${J>0?`, and ${J} more`:""}. Each one stops tracking ${w(v(),"config.json")}, so a machine-wide change will not reach this repository. Delete what this project did not decide.`}]}function RG($){let Z=H.capability.readProjectPolicyStatus($);if(Z.status==="absent")return[];if(Z.status==="malformed")return[{level:"warn",name:"project policy parses",detail:`${O($)} failed to parse: ${Z.error}. Until fixed, this tier silently falls back to defaults.`}];let Q=H.policy.DEFAULTS,q=H.policy.unknownKeys(Z.value,Q),J=H.policy.typeMismatches(Z.value,Q),X=[];if(q.length>0){let Y=q.slice(0,6).map((z)=>z.path),W=q.length-Y.length;X.push({level:"warn",name:"project policy has an unknown key",detail:`${P(q.length,"key")} in this project's config ${q.length===1?"matches":"match"} nothing the harness reads: ${Y.join(", ")}${W>0?`, and ${W} more`:""}. Delete ${q.length===1?"it":"them"}, or check for a typo.`})}if(J.length>0){let Y=J.slice(0,6).map((z)=>`${z.path} (expected ${z.expected}, got ${z.actual})`),W=J.length-Y.length;X.push({level:"warn",name:"project policy has a type mismatch",detail:`${P(J.length,"key")} in this project's config ${J.length===1?"does":"do"} not match the type the harness expects: ${Y.join(", ")}${W>0?`, and ${W} more`:""}.`})}return X}function PG($){let Q=H.policy.loadPolicy($).intelligence.lessons;if(!Q.enabled)return[];let q=H.lesson.previewLessonSelection({projectDir:$,config:Q,mode:"session"}),J=q.lessons.length;if(q.omitted===0)return J===0?[]:[{level:"ok",name:"lesson budget",detail:`every eligible lesson reaches the model at session start (${P(J,"lesson")}, maxCharsSession ${Q.maxCharsSession})`}];let X=q.lessons.reduce((W,z)=>W+H.lesson.renderLessonBlock(z).length,0),Y=q.lessons.filter((W)=>W.pinned).map((W)=>`${W.id} (pinned, ${H.lesson.renderLessonBlock(W).length} chars)`);return[{level:"warn",name:"lesson budget",detail:[`${P(q.omitted,"eligible lesson")} ${q.omitted===1?"never reaches":"never reach"} the model at session start:`,`${J} of ${J+q.omitted} fit in maxCharsSession ${Q.maxCharsSession} (${X} used).`,Y.length>0?`Pinned lessons go first and take the room: ${Y.join(", ")}.`:"","Raise intelligence.lessons.maxCharsSession, shorten a lesson, or unpin one. Run: tlc harness lessons list"].filter(Boolean).join(" ")}]}function EG($){if(!H.policy.loadPolicy($).intelligence.lessons.enabled)return[];let Q=new Date,q=[...H.lesson.readProjectLessons($),...H.lesson.readGlobalLessons()];if(q.length===0)return[];let J=q.filter((z)=>H.lesson.isStaleLesson(z)),X=q.filter((z)=>H.lesson.validityReason(z,Q)!=="active"),Y=q.filter((z)=>H.lesson.lessonEffectiveness(z)==="unproven"),W=[];if(J.length>0)W.push({level:"warn",name:"stale lessons",detail:`${P(J.length,"lesson")} name a path or symbol that no longer resolves, so ${J.length===1?"it is":"they are"} withheld: ${J.map((z)=>z.id).join(", ")}. Run: tlc harness lessons list`});if(X.length>0)W.push({level:"warn",name:"lessons out of window",detail:`${P(X.length,"lesson")} fall outside their validity window: ${X.map((z)=>z.id).join(", ")}. Run: tlc harness lessons garden`});if(Y.length>0)W.push({level:"warn",name:"unproven lessons",detail:Y.length===1?"1 lesson has been injected for a gate and never graded, so nothing shows it helped":`${Y.length} lessons have been injected for a gate and never graded, so nothing shows they helped`});if(W.length===0)return[{level:"ok",name:"lesson health",detail:`${P(q.length,"lesson")} across the writable tiers, none stale, none out of window`}];return W}function kG($){let Z=H.policy.allDivergedPaths($);if(Z.length===0)return[];return[{level:"warn",name:"policy baseline",detail:`changed out of band during a live session: ${Z.join(", ")}. If that was you: tlc harness policy accept ${Z.join(" ")}`}]}function xG($){let Z=H.policy.loadPolicy($);if(!Z.grind.enabled)return[];let Q=[];for(let[q,J]of[["lintCommand",Z.grind.lintCommand],["testCommand",Z.grind.testCommand]]){if(!J||J.length===0)continue;let X=H.gate.appendFilesVerdict(J,Z.grind.appendFiles);if(X.appends||Z.grind.appendFiles==="never")continue;Q.push({level:"warn",name:`gate scope (${q})`,detail:`runs in full on every attempt, up to maxLoops ${Z.grind.maxLoops}, because ${X.reason}. Scope the command itself, or accept the cost knowingly.`})}return Q}function SG($){let Z=O($),Q=K($);return[{level:"ok",name:"project policy",detail:j(Z)?Z:"missing — run: tlc harness init"},{level:"ok",name:"state dir",detail:j(Q)?Q:`${Q} (created on first session)`},DG($),...jG($),...EG($),...PG($),...AG($),...RG($),...TG($),...kG($),...xG($)]}function bG($){let Z=w($,".cursor","commands");if(!j(Z))return{level:"ok",name:"global commands dir",detail:"optional — ~/.cursor/commands for slash commands"};try{return{level:"ok",name:"global commands dir",detail:XG(Z).isSymbolicLink()?`${Z} → ${_q(Z)}`:Z}}catch{return{level:"ok",name:"global commands dir",detail:Z}}}function fG($){return[...UG($.nodeVersion,$.bunPath),...IG($.runtimeHome,$.platform),...HG($.runtimeHome),OG($.runtimeHome,$.bunPath),...LG($.registry,$.runtimeHome),...SG($.root),...NG($.root,$.runtimeHome),...MG(),...CG($.root),bG($.home)]}function Lq($){return $.some((Z)=>Z.level==="fail")?1:0}function wG($){return $.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function yG($){let Z={ok:"OK",warn:"WARN",fail:"FAIL"};return{ok:Lq($)===0,failed:$.filter((Q)=>Q.level==="fail").length,warned:$.filter((Q)=>Q.level==="warn").length,checks:$.map((Q)=>({id:wG(Q.name),name:Q.name,status:Z[Q.level],detail:Q.detail}))}}function vG($,Z=o){let Q={ok:"OK ",warn:"WARN",fail:"FAIL"},q={ok:"success",warn:"warning",fail:"error"},J=$.map((W)=>`${Z.paint(q[W.level],Q[W.level])} ${Z.paint("textMuted",W.name)} ${Z.dim("—")} ${W.detail}`),X=$.filter((W)=>W.level==="fail").length,Y=$.filter((W)=>W.level==="warn").length;if(J.push(""),X>0)J.push(Z.paint("error",`${N.cross} doctor: ${P(X,"failure")}${Y>0?`, ${P(Y,"warning")}`:""}`));else if(Y>0)J.push(Z.paint("warning",`${N.warning} doctor: no failures, ${P(Y,"warning")} to read above`));else J.push(Z.paint("success",`${N.check} doctor: all checks passed`));return J.join(`
|
|
160
|
+
${Q}`;return iV(q,J,"utf8"),q}function Qq($,Z){let Q={permission:$};if(Z.userNote!==void 0)Q.user_message=Z.userNote;return Q.agent_message=Z.reason,JSON.stringify(Q)}function qq($,Z){switch($.kind){case"abstain":return{stdout:"{}",exitCode:0};case"allow":return{stdout:JSON.stringify({permission:"allow"}),exitCode:0};case"deny":return{stdout:Qq("deny",$),exitCode:0};case"ask":return{stdout:Qq("ask",$),exitCode:0};case"context":{let Q={};if($.env!==void 0)Q.env=$.env;return Q.additional_context=$.text,{stdout:JSON.stringify(Q),exitCode:0}}case"continue":return{stdout:JSON.stringify({followup_message:$.text}),exitCode:0};case"rewriteInput":return{stdout:JSON.stringify({updated_input:$.input}),exitCode:0};case"rewriteOutput":return{stdout:JSON.stringify({updated_mcp_tool_output:{result_json:$.output}}),exitCode:0};default:throw Error(`unreachable decision kind: ${JSON.stringify($)}`)}}function Jq(){return{blockedPatterns:["-fast(?:$|[^a-z0-9])","/fast(?:$|[^a-z0-9])","composer-2\\.5-fast"],minEffort:null,untrustedTools:["Fetch","WebSearch"]}}import{join as sV}from"node:path";function Xq(){return sV(QZ(),"hooks.json")}function Yq(){return[Xq()]}var Wq=[{hookEvent:"sessionStart",handler:"session-start",timeoutSeconds:10},{hookEvent:"sessionEnd",handler:"session-end",timeoutSeconds:10},{hookEvent:"beforeSubmitPrompt",handler:"prompt-submit",timeoutSeconds:5},{hookEvent:"afterAgentThought",handler:"tool-after",timeoutSeconds:5},{hookEvent:"preCompact",handler:"compact-before",timeoutSeconds:5},{hookEvent:"subagentStart",handler:"subagent-start",timeoutSeconds:5,failClosed:!0},{hookEvent:"subagentStop",handler:"subagent-stop",timeoutSeconds:5},{hookEvent:"preToolUse",handler:"tool-before",timeoutSeconds:10,failClosed:!0},{hookEvent:"postToolUse",handler:"tool-after",timeoutSeconds:5},{hookEvent:"postToolUseFailure",handler:"tool-failure",timeoutSeconds:5},{hookEvent:"beforeShellExecution",handler:"tool-before",timeoutSeconds:10,failClosed:!0},{hookEvent:"afterShellExecution",handler:"tool-after",timeoutSeconds:10},{hookEvent:"beforeMCPExecution",handler:"tool-before",timeoutSeconds:10},{hookEvent:"afterMCPExecution",handler:"tool-after",timeoutSeconds:5},{hookEvent:"beforeReadFile",handler:"tool-before",timeoutSeconds:5},{hookEvent:"afterFileEdit",handler:"tool-after",timeoutSeconds:30,matcher:"Write"},{hookEvent:"stop",handler:"stop",timeoutSeconds:120,loopLimit:5},{hookEvent:"afterAgentResponse",handler:"response-after",timeoutSeconds:5,matcher:"AgentResponse"}];function zq($){let Q=[$.launcherPath],q=Wq.map((J)=>({hookEvent:J.hookEvent,handler:J.handler,command:"node",args:[...Q,J.handler],timeoutSeconds:J.timeoutSeconds,...J.failClosed!==void 0?{failClosed:J.failClosed}:{},...J.matcher!==void 0?{matcher:J.matcher}:{},...J.loopLimit!==void 0?{loopLimit:J.loopLimit}:{}}));return{target:Xq(),strategy:"replace",entries:q}}function rV($){return[...$.matchAll(/"([^"]*)"|(\S+)/g)].map((Z)=>Z[1]??Z[2]??"")}function Vq($,Z,Q){if($===null)return[{hookEvent:"(file)",reason:"no hooks file at the expected path"}];let q;try{q=JSON.parse($)}catch{return[{hookEvent:"(file)",reason:"the hooks file is not valid JSON"}]}let J=q!==null&&typeof q==="object"?q.hooks??{}:{},X=[];for(let Y of Wq){let z=(Array.isArray(J[Y.hookEvent])?J[Y.hookEvent]:[]).map((V)=>V!==null&&typeof V==="object"?String(V.command??""):"").filter((V)=>V.includes(Z.launcherPath));if(z.length===0){X.push({hookEvent:Y.hookEvent,reason:"no harness entry — run: tlc harness update"});continue}for(let V of z){let G=rV(V),B=G.indexOf(Z.launcherPath);if(B<1){X.push({hookEvent:Y.hookEvent,reason:`no executable before the script: \`${V}\``});continue}if(!Q(Z.launcherPath)){X.push({hookEvent:Y.hookEvent,reason:`the script does not exist: ${Z.launcherPath}`});continue}if(G[B+1]===void 0||G[B+1]==="")X.push({hookEvent:Y.hookEvent,reason:`no handler after the script: \`${V}\``})}}return X}function Gq($,Z=3){let Q=$.slice(0,Z).map((J)=>`${J.hookEvent}: ${J.reason}`).join("; "),q=$.length-Math.min($.length,Z);return q>0?`${Q}; and ${q} more`:Q}var Bq={name:"cursor",detect:r1,capabilities:s1,policyDefaults:Jq,toEvent:t1,render:qq,wiring:zq,wiringTargets:Yq,lessonsView:Zq};var r8=[Bq,a1];var eV="tlc-exec.mjs";function Uq($){return oV($)&&tV($,"utf8").includes(eV)}import{existsSync as $G,readFileSync as ZG}from"node:fs";import{join as QG}from"node:path";function Kq(){return QG(n(),"model-prices.json")}var g$=new Map;function Hq($){if(!$G($))return g$.delete($),null;let Z;try{Z=ZG($,"utf8")}catch{return g$.delete($),null}let Q=g$.get($);if(Q&&Q.text===Z)return Q.value;let q;try{q=JSON.parse(Z)}catch{return g$.delete($),null}return g$.set($,{text:Z,value:q}),q}function qG(){return Hq(Kq())??{}}function Mq(){return qG()._meta?.planes??{}}function Cq(){let $=Hq(Kq());return $===null?null:$._meta??{}}function P($,Z){return`${$} ${Z}${$===1?"":"s"}`}var u$=24;function GG($){if($.length===0)return null;let Z=[...$].sort((q,J)=>q-J),Q=Math.floor(Z.length/2);return Z.length%2===1?Z[Q]:(Z[Q-1]+Z[Q])/2}function BG($){let Z=$.spawn??((J,X)=>({ok:(JG(J,X,{stdio:"ignore"}).status??1)===0})),Q=$.now??(()=>Date.now()),q=[];for(let J=0;J<($.samples??3);J+=1){let X=Q();if(!Z($.command,$.args).ok)return null;q.push(Q()-X)}return GG(q)}function UG($,Z=null){let Q=Number.parseInt($.replace(/^v/,"").split(".")[0]??"0",10),q=[{level:Q>=u$||Z!==null?"ok":"fail",name:"Node.js runtime",detail:Q>=u$?`${$} (>= ${u$})`:Z!==null?`${$} — below ${u$}, covered by Bun at ${Z}`:`${$} — no runtime for hooks. Install Bun (curl -fsSL https://bun.sh/install | bash) or Node ${u$}+ (nodejs.org), then reload the editor.`}];if(Q===25)q.push({level:"warn",name:"Node.js line",detail:"Node 25 is EOL — prefer 24 LTS or 26 Current"});return q}function KG($){let Z=R1($);return{level:Z==="managed"||Z==="linked"||Z==="npm"?"ok":"fail",name:"runtime ownership",detail:{managed:"managed checkout — `tlc harness update` moves it to upstream and owns its contents",linked:"link to a working clone — update never writes here; pull that clone yourself",npm:"installed from npm — `tlc harness update` bumps the package and re-materialises this directory",unmanaged:"not a git checkout — update cannot pull; install the package and run `tlc harness install`",absent:"missing — install the package, then run `tlc harness install`"}[Z]}}function HG($,Z=qZ(),Q={linkTarget:(q)=>{try{return Iq(q)}catch{try{return _q(q)}catch{return null}}},exists:j,realpath:(q)=>{try{return Iq(q)}catch{return q}}}){return Z.filter((q)=>j(q)).map((q)=>{let J=H.skill.linkHealth(w(q,"skills","harness-init"),$,Q);return{level:J.state==="ok"?"ok":"fail",name:`init skill (${zG(q)})`,detail:H.skill.linkHealthMessage(J)}})}function MG($=new Date,Z={meta:Cq,planes:Mq}){let Q=H.pricing.freshness(Z.meta(),$),q=Z.planes(),J=Object.entries(q).map(([X,Y])=>`${X} ${Y.count??0}`).join(", ");return[{level:Q.state==="fresh"?"ok":"warn",name:"prices",detail:Q.state==="fresh"?`${H.pricing.freshnessMessage(Q,"catalogue")}${J?` (${J})`:""}`:H.pricing.freshnessMessage(Q,"catalogue")}]}function CG($){let Z=H.policy.loadPolicy($),Q=H.rules.load($,Z.rules);if(Q.rules.length===0&&Q.disabled.length===0&&Q.errors.length===0)return Z.rules.enabled?[{level:"warn",name:"operator rules",detail:`enabled, and no rule file was found — nothing is enforced. A rule is one markdown file in ${H.rules.projectDir($)} (this repository) or ${H.rules.globalDir()} (every repository here); tlc harness help rules has the frontmatter`}]:[];let q=[];if(Q.rules.length>0)q.push({level:"ok",name:"operator rules",detail:Q.rules.map((J)=>`${J.name} (${J.tier}) on ${J.on.kind} → ${J.otherwise}`).join("; ")});if(Q.disabled.length>0)q.push({level:"ok",name:"operator rules (off here)",detail:Q.disabled.map((J)=>J.name).join(", ")});for(let J of Q.errors)q.push({level:"fail",name:`operator rule (${J.name})`,detail:`${J.error} — the other rules still apply`});for(let J of H.rules.unobservedKinds(Q.rules,H.rules.observations($)))q.push({level:"warn",name:`operator rule (${J.rule})`,detail:`needs ${J.kinds.join(", ")}, and no observation of that kind has been recorded in this project yet`});return q}function IG($,Z){let Q=P1($),q=w($,"bin","tlc-exec.mjs"),J=w($,"dist","stop.mjs"),X=XZ("tlc");return[{level:Q===null?"warn":"ok",name:"harness version",detail:Q??`unknown — no readable package.json at ${$}`},{level:"ok",name:"platform",detail:Z},{level:j(q)?"ok":"fail",name:"global runtime",detail:$},KG($),{level:j(J)?"ok":"fail",name:"dist bundles",detail:j(J)?w($,"dist"):"missing — run: tlc harness build"},{level:j(q)?"ok":"fail",name:"portable launcher",detail:q},{level:X===null?"fail":"ok",name:"CLI on PATH",detail:X??`no \`tlc\` on PATH — link it: ln -s ${w($,"bin","tlc")} ${w(JZ(),"tlc")} (or re-run \`tlc harness install\`, which does it)`}]}function OG($,Z,Q=BG){let q=Z??process.execPath,J=Z?`Bun (${Z})`:`Node + dist/ (${process.version})`,X=Q({command:q,args:["-e",""]}),Y=X===null?" — interpreter start could not be measured on this machine":` — interpreter start measured at ${X} ms here, paid once per hook`;return Z?{level:"ok",name:"hook runtime",detail:`${J}${Y}`}:{level:"warn",name:"hook runtime",detail:`${J}${Y}. Bun runs the source directly and starts faster — install: https://bun.sh`}}function Fq($){if($.strategy!=="replace")return[];let Z=j($.target)?Oq($.target,"utf8"):null;return Vq(Z,{launcherPath:_G($)},j)}function _G($){return $.entries[0]?.args.find((Q)=>Q.endsWith(".mjs"))??""}function FG($){if(!j(VG($.target)))return"not-installed";if($.strategy==="replace"){if(!Uq($.target))return"detected-but-unwired";return Fq($).length===0?"wired":"detected-but-unwired"}let Z=j($.target)?Oq($.target,"utf8"):null,Q=X5(Z,$.entries);return Q.ok&&!Q.changed?"wired":"detected-but-unwired"}function LG($,Z){let Q=w(Z,"bin","tlc-exec.mjs");return $.map((q)=>{let J=q.wiring({launcherPath:Q}),X=FG(J);if(X==="not-installed")return{level:"ok",name:`${q.name} wiring`,detail:"not installed"};if(X==="wired")return{level:"ok",name:`${q.name} wiring`,detail:`wired (${J.target})`};let Y=Fq(J),W=Y.length>0?` — ${Gq(Y)}`:"";return{level:"warn",name:`${q.name} wiring`,detail:`detected but not wired${W} — run: tlc harness update (${J.target})`}})}function NG($,Z){let Q=H.capability.loadCatalog(Z),q=H.capability.readProjectPolicyRaw($);if(!Q||!q)return[];let J=H.capability.listAvailableNotEnabled(H.policy.loadPolicy($),Q);if(J.length===0)return[];return[{level:"ok",name:"capabilities",detail:H.capability.formatAvailableInventory(J)}]}function DG($){let Z=H.policy.resolveProjectPosture($);if(Z.origin!=="fallback")return{level:"ok",name:"operator posture",detail:`${Z.mode} (from ${Z.origin})`};return{level:"warn",name:"operator posture",detail:`\`${Z.invalid}\` is not a posture — running as ${Z.mode}. Accepted: ${H.policy.OPERATOR_MODES.join(" | ")}. Fix \`mode\` in ${O($)}, or run: tlc harness mode <${H.policy.OPERATOR_MODES.join("|")}>`}}function jG($){let Z=H.policy.loadPolicy($);if(!Z.observe.enabled)return[];let Q=H.observe.unobservableRails(Z.observe.rails),q=H.observe.OBSERVABLE_RAILS.join(" | ");if(Z.observe.rails.length===0)return[{level:"warn",name:"observed rails",detail:`observation is on with no rails listed, so nothing is measured. Set \`observe.rails\` to one or more of: ${q}`}];if(Q.length===0)return[{level:"ok",name:"observed rails",detail:Z.observe.rails.join(", ")}];return[{level:"warn",name:"observed rails",detail:`no checker exists for ${Q.map((J)=>`\`${J}\``).join(", ")}, so nothing is recorded for them. Observable today: ${q}`}]}function TG($){let{subagents:Z}=H.policy.loadPolicy($);if(!Z.enforceAllowlist)return[];let Q=Z.allowedModels;if((Array.isArray(Q)?Q.length:Object.values(Q??{}).reduce((J,X)=>J+X.length,0))>0)return[];return[{level:"fail",name:"subagent allowlist",detail:"enforceAllowlist is on and subagents.allowedModels is empty, so it permits every model. The harness ships no list — add the model slugs you allow, or set enforceAllowlist to false."}]}function AG($){let Z=H.capability.readProjectPolicyRaw($);if(!Z)return[];let Q=H.policy.shadowedKeys(Z,H.policy.resolvedWithoutProjectTier());if(Q.length===0)return[];let q=Q.slice(0,6).map((X)=>X.path),J=Q.length-q.length;return[{level:"warn",name:"project policy restates lower tiers",detail:`${P(Q.length,"key")} in this project's config name the value ${Q.length===1?"it":"they"} would already have: ${q.join(", ")}${J>0?`, and ${J} more`:""}. Each one stops tracking ${w(v(),"config.json")}, so a machine-wide change will not reach this repository. Delete what this project did not decide.`}]}function RG($){let Z=H.capability.readProjectPolicyStatus($);if(Z.status==="absent")return[];if(Z.status==="malformed")return[{level:"warn",name:"project policy parses",detail:`${O($)} failed to parse: ${Z.error}. Until fixed, this tier silently falls back to defaults.`}];let Q=H.policy.DEFAULTS,q=H.policy.unknownKeys(Z.value,Q),J=H.policy.typeMismatches(Z.value,Q),X=[];if(q.length>0){let Y=q.slice(0,6).map((z)=>z.path),W=q.length-Y.length;X.push({level:"warn",name:"project policy has an unknown key",detail:`${P(q.length,"key")} in this project's config ${q.length===1?"matches":"match"} nothing the harness reads: ${Y.join(", ")}${W>0?`, and ${W} more`:""}. Delete ${q.length===1?"it":"them"}, or check for a typo.`})}if(J.length>0){let Y=J.slice(0,6).map((z)=>`${z.path} (expected ${z.expected}, got ${z.actual})`),W=J.length-Y.length;X.push({level:"warn",name:"project policy has a type mismatch",detail:`${P(J.length,"key")} in this project's config ${J.length===1?"does":"do"} not match the type the harness expects: ${Y.join(", ")}${W>0?`, and ${W} more`:""}.`})}return X}function PG($){let Q=H.policy.loadPolicy($).intelligence.lessons;if(!Q.enabled)return[];let q=H.lesson.previewLessonSelection({projectDir:$,config:Q,mode:"session"}),J=q.lessons.length;if(q.omitted===0)return J===0?[]:[{level:"ok",name:"lesson budget",detail:`every eligible lesson reaches the model at session start (${P(J,"lesson")}, maxCharsSession ${Q.maxCharsSession})`}];let X=q.lessons.reduce((W,z)=>W+H.lesson.renderLessonBlock(z).length,0),Y=q.lessons.filter((W)=>W.pinned).map((W)=>`${W.id} (pinned, ${H.lesson.renderLessonBlock(W).length} chars)`);return[{level:"warn",name:"lesson budget",detail:[`${P(q.omitted,"eligible lesson")} ${q.omitted===1?"never reaches":"never reach"} the model at session start:`,`${J} of ${J+q.omitted} fit in maxCharsSession ${Q.maxCharsSession} (${X} used).`,Y.length>0?`Pinned lessons go first and take the room: ${Y.join(", ")}.`:"","Raise intelligence.lessons.maxCharsSession, shorten a lesson, or unpin one. Run: tlc harness lessons list"].filter(Boolean).join(" ")}]}function EG($){if(!H.policy.loadPolicy($).intelligence.lessons.enabled)return[];let Q=new Date,q=[...H.lesson.readProjectLessons($),...H.lesson.readGlobalLessons()];if(q.length===0)return[];let J=q.filter((z)=>H.lesson.isStaleLesson(z)),X=q.filter((z)=>H.lesson.validityReason(z,Q)!=="active"),Y=q.filter((z)=>H.lesson.lessonEffectiveness(z)==="unproven"),W=[];if(J.length>0)W.push({level:"warn",name:"stale lessons",detail:`${P(J.length,"lesson")} name a path or symbol that no longer resolves, so ${J.length===1?"it is":"they are"} withheld: ${J.map((z)=>z.id).join(", ")}. Run: tlc harness lessons list`});if(X.length>0)W.push({level:"warn",name:"lessons out of window",detail:`${P(X.length,"lesson")} fall outside their validity window: ${X.map((z)=>z.id).join(", ")}. Run: tlc harness lessons garden`});if(Y.length>0)W.push({level:"warn",name:"unproven lessons",detail:Y.length===1?"1 lesson has been injected for a gate and never graded, so nothing shows it helped":`${Y.length} lessons have been injected for a gate and never graded, so nothing shows they helped`});if(W.length===0)return[{level:"ok",name:"lesson health",detail:`${P(q.length,"lesson")} across the writable tiers, none stale, none out of window`}];return W}function kG($){let Z=H.policy.allDivergedPaths($);if(Z.length===0)return[];return[{level:"warn",name:"policy baseline",detail:`changed out of band during a live session: ${Z.join(", ")}. If that was you: tlc harness policy accept ${Z.join(" ")}`}]}function xG($){let Z=H.policy.loadPolicy($);if(!Z.grind.enabled)return[];let Q=[];for(let[q,J]of[["lintCommand",Z.grind.lintCommand],["testCommand",Z.grind.testCommand]]){if(!J||J.length===0)continue;let X=H.gate.appendFilesVerdict(J,Z.grind.appendFiles);if(X.appends||Z.grind.appendFiles==="never")continue;Q.push({level:"warn",name:`gate scope (${q})`,detail:`runs in full on every attempt, up to maxLoops ${Z.grind.maxLoops}, because ${X.reason}. Scope the command itself, or accept the cost knowingly.`})}return Q}function SG($){let Z=O($),Q=K($);return[{level:"ok",name:"project policy",detail:j(Z)?Z:"missing — run: tlc harness init"},{level:"ok",name:"state dir",detail:j(Q)?Q:`${Q} (created on first session)`},DG($),...jG($),...EG($),...PG($),...AG($),...RG($),...TG($),...kG($),...xG($)]}function bG($){let Z=w($,".cursor","commands");if(!j(Z))return{level:"ok",name:"global commands dir",detail:"optional — ~/.cursor/commands for slash commands"};try{return{level:"ok",name:"global commands dir",detail:XG(Z).isSymbolicLink()?`${Z} → ${_q(Z)}`:Z}}catch{return{level:"ok",name:"global commands dir",detail:Z}}}function fG($){return[...UG($.nodeVersion,$.bunPath),...IG($.runtimeHome,$.platform),...HG($.runtimeHome),OG($.runtimeHome,$.bunPath),...LG($.registry,$.runtimeHome),...SG($.root),...NG($.root,$.runtimeHome),...MG(),...CG($.root),bG($.home)]}function Lq($){return $.some((Z)=>Z.level==="fail")?1:0}function wG($){return $.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function yG($){let Z={ok:"OK",warn:"WARN",fail:"FAIL"};return{ok:Lq($)===0,failed:$.filter((Q)=>Q.level==="fail").length,warned:$.filter((Q)=>Q.level==="warn").length,checks:$.map((Q)=>({id:wG(Q.name),name:Q.name,status:Z[Q.level],detail:Q.detail}))}}function vG($,Z=o){let Q={ok:"OK ",warn:"WARN",fail:"FAIL"},q={ok:"success",warn:"warning",fail:"error"},J=$.map((W)=>`${Z.paint(q[W.level],Q[W.level])} ${Z.paint("textMuted",W.name)} ${Z.dim("—")} ${W.detail}`),X=$.filter((W)=>W.level==="fail").length,Y=$.filter((W)=>W.level==="warn").length;if(J.push(""),X>0)J.push(Z.paint("error",`${N.cross} doctor: ${P(X,"failure")}${Y>0?`, ${P(Y,"warning")}`:""}`));else if(Y>0)J.push(Z.paint("warning",`${N.warning} doctor: no failures, ${P(Y,"warning")} to read above`));else J.push(Z.paint("success",`${N.check} doctor: all checks passed`));return J.join(`
|
|
161
161
|
`)}function mG(){let $=v(),Z=k1();return x1($,Z),{root:process.env.TLC_PROJECT_DIR??process.cwd(),home:YG(),runtimeHome:$,platform:WG(),nodeVersion:process.version,bunPath:Z,registry:r8}}if(G5.main==G5.module){let{json:$}=$5(process.argv.slice(2)),Z=fG(mG());if($)Z5(yG(Z));else console.log(vG(Z,H8()));process.exit(Lq(Z))}export{Fq as wiringProblems,yG as toReport,KG as runtimeOwnershipCheck,fG as runChecks,FG as providerWiringStatus,P as plural,GG as medianMs,BG as measureRuntimeStart,vG as formatReport,Lq as exitCodeFor,TG as checkSubagentAllowlist,HG as checkSkillLinks,AG as checkShadowedPolicy,IG as checkRuntimePaths,CG as checkRules,LG as checkProviders,SG as checkProjectPolicy,MG as checkPrices,UG as checkNodeVersion,EG as checkLessonHealth,PG as checkLessonBudget,wG as checkId,OG as checkHookRuntime,bG as checkGlobalCommands,RG as checkConfigKeys,NG as checkCapabilities};
|