tracetoon 1.0.0-rc.36 → 1.0.0-rc.37
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tracetoon",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.37",
|
|
4
4
|
"description": "Pull request descriptions written from your AI coding agent’s session logs, with every claim checked against the evidence. Better PRs at lower cost. Run: npx tracetoon@latest setup",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://tracetoon.ai",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"node": ">=18"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@tracetoon/cli-linux-x64": "1.0.0-rc.
|
|
34
|
-
"@tracetoon/cli-linux-arm64": "1.0.0-rc.
|
|
35
|
-
"@tracetoon/cli-darwin-x64": "1.0.0-rc.
|
|
36
|
-
"@tracetoon/cli-darwin-arm64": "1.0.0-rc.
|
|
37
|
-
"@tracetoon/cli-win32-x64": "1.0.0-rc.
|
|
33
|
+
"@tracetoon/cli-linux-x64": "1.0.0-rc.37",
|
|
34
|
+
"@tracetoon/cli-linux-arm64": "1.0.0-rc.37",
|
|
35
|
+
"@tracetoon/cli-darwin-x64": "1.0.0-rc.37",
|
|
36
|
+
"@tracetoon/cli-darwin-arm64": "1.0.0-rc.37",
|
|
37
|
+
"@tracetoon/cli-win32-x64": "1.0.0-rc.37"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/skill/tracetoon/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.0-rc.
|
|
1
|
+
1.0.0-rc.37
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.0-rc.
|
|
3
|
-
"buildId": "
|
|
4
|
-
"revision": "
|
|
2
|
+
"version": "1.0.0-rc.37",
|
|
3
|
+
"buildId": "060da6295acdf20495efada145899bce6c74a6c045f797b4544abc4b0596a645",
|
|
4
|
+
"revision": "a6320f5ab507e10d6bc1f8c0c15c00fc76a82883",
|
|
5
5
|
"protocol": 2,
|
|
6
6
|
"dependencies": [
|
|
7
7
|
{
|
|
@@ -326,7 +326,7 @@ export default function (amp: any) {
|
|
|
326
326
|
}
|
|
327
327
|
`}function cG(Q){let $=Q.split(/\r?\n/,1)[0]??"";return $.startsWith("// tracetoon:amp-plugin")?$.slice(23).trim():void 0}var dG=(Q,$)=>T6($.XDG_CONFIG_HOME||T6(Q,".config"),"amp"),lG=(Q,$)=>qI(dG(Q,$))||!!$0("amp",$),pG={id:"amp",label:"Amp",status:"partial",supportTier:"community",variants:"CLI",limits:["Amp keeps its threads on Amp's servers, so the PR is written from the diff and git history, not session logs.","Only PR commands run in the shell are redirected to Tracetoon."],traces:[],hook:{file:(Q,$)=>T6(dG(Q,$),"plugins","tracetoon.ts"),present:lG,apply:(Q)=>Q,installedCommand:()=>{return},text:{render:uG,command:cG},parse:(Q)=>x4(Q,"amp"),deny:w4,installNote:()=>'In Amp, run "plugins: reload" from the command palette, or start a new session.'},skill:(Q,$)=>({present:lG(Q,$),dir:T6(Q,".agents","skills","tracetoon")})};import{existsSync as EI}from"node:fs";import{join as SI}from"node:path";import{existsSync as oG}from"node:fs";import{createRequire as CI}from"node:module";import{homedir as PI}from"node:os";import{isAbsolute as _I,join as m4,resolve as nZ,sep as iG}from"node:path";var F3=(Q)=>typeof Q==="object"&&Q!==null&&!Array.isArray(Q),j5=(Q)=>typeof Q==="string"&&Q.length?Q:void 0;function O6(Q=process.env,$=PI()){if(Q.ZED_DATA_DIR)return Q.ZED_DATA_DIR;if(process.platform==="win32")return m4(Q.LOCALAPPDATA||m4($,"AppData","Local"),"Zed");if(process.platform==="darwin")return m4($,"Library","Application Support","Zed");return m4(Q.XDG_DATA_HOME||m4($,".local","share"),"zed")}var aZ=()=>m4(O6(),"threads","threads.db"),FI=new Set(["read_file","list_directory","grep","find_path","diagnostics","fetch","web_search","thinking","now","open","skill","project_notifications","copy_path","create_directory"]);function LI(){let Q=globalThis.Bun;if(typeof Q?.zstdDecompressSync==="function")return($)=>Q.zstdDecompressSync($);try{let $=CI(import.meta.url)("node:zlib");if(typeof $.zstdDecompressSync==="function")return(Z)=>$.zstdDecompressSync(Z)}catch{}return}function nG(Q,$,Z){try{let X=Q;if($==="zstd"){let z=LI();if(!z){Z.push("Zed threads are zstd-compressed and this runtime cannot read zstd.");return}X=z(Q)}let Y=typeof X==="string"?X:new TextDecoder().decode(X),J=JSON.parse(Y);return F3(J)?J:void 0}catch{Z.push("Skipped a Zed thread that could not be decoded.");return}}function AI(Q,$){let Z=new Map;for(let J of a(Q))Z.set(J,(Z.get(J)??0)+1);let X=[];for(let J of a($)){let z=Z.get(J)??0;if(z>0)Z.set(J,z-1);else X.push(J)}let Y=[];for(let[J,z]of Z)for(let K=0;K<z;K++)Y.push(J);return{added:X,removed:Y}}var jI=(Q)=>typeof Q.output==="string"?Q.output:Array.isArray(Q.content)?Q.content.map(($)=>F3($)&&typeof $.Text==="string"?$.Text:"").join(`
|
|
328
328
|
`):"";function II(Q){let $=/failed with exit code (-?\d+)/.exec(Q),Z=/```[^\n]*\n([\s\S]*?)\n?```/.exec(Q);return{exit:$?Number($[1]):void 0,output:(Z?Z[1]:"").trim()}}function TI(Q,$,Z,X){let Y=X??j5(Q.initial_project_snapshot?.timestamp)??j5(Q.updated_at),J=Array.isArray(Q.messages)?Q.messages.filter(F3):[],z={};for(let K of J)if(F3(K.Agent)&&F3(K.Agent.tool_results))Object.assign(z,K.Agent.tool_results);for(let K of J){let V=F3(K.User)?"user":F3(K.Agent)?"agent":void 0;if(!V){let W=Object.keys(K)[0]??"?";$.unknownTypes[W]=($.unknownTypes[W]??0)+1;continue}let G=Array.isArray(K[V==="user"?"User":"Agent"].content)?K[V==="user"?"User":"Agent"].content.filter(F3):[];for(let W of G){if(typeof W.Text==="string"){let N=W.Text.trim();if(!N)continue;if(V==="user"){if(!G0(N))$.records.push({kind:"prompt",text:N,ts:Y,cwd:Z})}else $.records.push({kind:"assistant",text:N,ts:Y,cwd:Z});continue}if(!F3(W.ToolUse))continue;let B=W.ToolUse,H=j5(B.name)??"";N0($);let U=F3(B.input?.value)?B.input.value:(()=>{try{let N=JSON.parse(B.raw_input??"");return F3(N)?N:{}}catch{return{}}})(),M=j5(B.id)?z[B.id]:void 0;if(H==="terminal"&&j5(U.command)){let N={kind:"command",cmd:U.command,ts:Y,cwd:j5(U.cd)??Z};if(!M)N.pending=!0;else{let{exit:D,output:C}=II(jI(M));if(M.is_error===!0||D!==void 0&&D!==0)N.isError=!0;if(C)N.output=C.slice(0,4000)}$.records.push(N)}else if((H==="edit_file"||H==="streaming_edit_file")&&F3(M?.output)&&typeof M.output.new_text==="string"){let N=M.output,D=j5(N.original_path)??j5(U.path)??"",C=_I(D)?D:nZ(Z??".",D),F=typeof N.old_text==="string"?N.old_text:"",{added:I,removed:_}=AI(F,N.new_text);$.records.push({kind:"edit",file:C,added:I,removed:_,...F===""&&U.mode==="create"?{created:!0}:{},ts:Y,cwd:Z})}else if(!FI.has(H))j0($,H)}}}function iZ(Q,...$){let Z=aZ();if(!oG(Z))return[];try{let X=K3(Z);if(!X)return[];try{return X.all(Q,...$)}finally{X.close()}}catch{return[]}}var aG=(Q,$)=>{let Z=nZ(Q).toLowerCase(),X=nZ($).toLowerCase();return Z===X||Z.startsWith(X.endsWith(iG)?X:X+iG)},OI=(Q)=>(Q.folder_paths??"").split(/\r?\n/).map(($)=>$.trim()).filter(Boolean);function RI(Q){let $=[];for(let Z of Array.isArray(Q.messages)?Q.messages:[])for(let X of F3(Z?.Agent)&&Array.isArray(Z.Agent.content)?Z.Agent.content:[])if(F3(X?.ToolUse)&&X.ToolUse.name==="terminal"){let Y=j5(X.ToolUse.input?.value?.cd);if(Y)$.push(Y)}return $}var sG={id:"zed",label:"Zed",home:()=>oG(aZ())?O6():void 0,count:()=>iZ("select id from threads").length,discover(Q){let $=[],Z=new Date(Q.sinceMs).toISOString();for(let X of iZ("select id, summary, updated_at, data_type, data, folder_paths, parent_id from threads where updated_at >= ?",Z)){let Y=OI(X),J=Y.find((z)=>Q.all||Q.roots.some((K)=>aG(z,K)));if(!J&&!Q.all){let z=nG(X.data,X.data_type,[]);J=z?RI(z).find((K)=>Q.roots.some((V)=>aG(K,V))):void 0}if(!J&&!Q.all)continue;$.push({agent:"zed",sessionId:X.id,path:`${aZ()}#${X.id}`,mtimeMs:Date.parse(X.updated_at)||0,cwd:J??Y[0]})}return $},read(Q){let $={agent:"zed",sessionId:Q.sessionId,source:Q.path,records:[],unknownTypes:{},warnings:[]},Z=iZ("select id, summary, updated_at, created_at, data_type, data, folder_paths, parent_id from threads where id = ?",Q.sessionId)[0];if(!Z)return $;if(Z.summary)$.title=Z.summary;if(Z.parent_id)$.parentSessionId=Z.parent_id;let X=nG(Z.data,Z.data_type,$.warnings);if(X)TI(X,$,Q.cwd,Z.created_at??void 0);return $}};var kI=(Q,$)=>EI(O6($,Q))||!!$0("zed",$),rG={id:"zed",label:"Zed",status:"partial",supportTier:"community",variants:"Zed Agent",limits:["Zed has no hook before its agent's tools, so a PR command run by the Zed Agent isn't redirected; the agent can still use the Tracetoon skill.","Claude Code, Codex and Copilot CLI run inside Zed are covered by their own integrations."],traces:[sG],skill:(Q,$)=>({present:kI(Q,$),dir:SI(Q,".agents","skills","tracetoon")})};import{existsSync as fI}from"node:fs";import{dirname as gI,join as hI}from"node:path";import{existsSync as QW}from"node:fs";import{homedir as yI}from"node:os";import{join as X8,resolve as oZ,sep as tG}from"node:path";var c2=(Q)=>typeof Q==="string"&&Q.length?Q:void 0;function u4(Q=process.env,$=yI()){if(Q.WARP_DB_PATH)return Q.WARP_DB_PATH;if(process.platform==="win32")return X8(Q.LOCALAPPDATA||X8($,"AppData","Local"),"warp","Warp","data","warp.sqlite");if(process.platform==="darwin")return X8($,"Library","Group Containers","2BBY89MBSN.dev.warp","Library","Application Support","dev.warp.Warp-Stable","warp.sqlite");return X8(Q.XDG_STATE_HOME||X8($,".local","state"),"warp-terminal","warp.sqlite")}var R6=(Q)=>{if(typeof Q!=="string")return;try{return JSON.parse(Q)}catch{return}};function sZ(Q){let $=/^(\d{4}-\d\d-\d\d)[ T](\d\d:\d\d:\d\d)(\.\d{1,3})?/.exec(String(Q??""));return $?`${$[1]}T${$[2]}${$[3]??""}Z`:void 0}function rZ(Q){return(typeof Q==="string"?Q:Q instanceof Uint8Array?new TextDecoder().decode(Q):"").replace(/\x1b\][^\x07\x1b]*(\x07|\x1b\\)/g,"").replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,"").replace(/\r\n?/g,`
|
|
329
|
-
`).trim()}function xI(Q){return c2(R6(Q.ai_metadata)?.conversation_id)??c2(R6(Q.agent_view_visibility)?.Agent?.origin_conversation_id)}function wI(Q,$,Z){for(let X of Q){let Y=R6(X.input);for(let J of Array.isArray(Y)?Y:[]){let z=c2(J?.Query?.text)?.trim();if(!z||G0(z))continue;Z.records.push({kind:"prompt",text:z,ts:sZ(X.start_ts),cwd:c2(X.working_directory)})}}for(let X of $){let Y=rZ(X.stylized_command);if(!Y)continue;N0(Z);let J=rZ(X.stylized_output);Z.records.push({kind:"command",cmd:Y,ts:sZ(X.start_ts),cwd:c2(X.pwd),...typeof X.exit_code==="number"&&X.exit_code!==0?{isError:!0}:{},...J?{output:J.slice(0,4000)}:{}})}Z.records.sort((X,Y)=>(X.ts??"").localeCompare(Y.ts??""))}function Y8(Q,...$){let Z=u4();if(!QW(Z))return[];try{let X=K3(Z);if(!X)return[];try{return X.all(Q,...$)}finally{X.close()}}catch{return[]}}var bI=(Q,$)=>{let Z=oZ(Q).toLowerCase(),X=oZ($).toLowerCase();return Z===X||Z.startsWith(X.endsWith(tG)?X:X+tG)},vI=`select pwd, exit_code, start_ts, ai_metadata, agent_view_visibility, stylized_command, stylized_output from blocks where ai_metadata is not null or agent_view_visibility like '%"Agent"%' order by start_ts`;function eG(){let Q=new Map;for(let $ of Y8(vI)){let Z=xI($);if(Z)Q.set(Z,[...Q.get(Z)??[],$])}return Q}var $W={id:"warp",label:"Warp",home:()=>QW(u4())?u4():void 0,count:()=>Number(Y8("select count(*) as n from agent_conversations")[0]?.n??0),discover(Q){let $=eG(),Z=[];for(let X of Y8("select conversation_id, last_modified_at from agent_conversations")){let Y=Date.parse(sZ(X.last_modified_at)??"")||0;if(Y<Q.sinceMs&&!Q.all)continue;let z=($.get(X.conversation_id)??[]).map((K)=>{let V=c2(K.pwd);if(V&&Q.roots.some((W)=>bI(V,W)))return V;let G=rZ(K.stylized_command).toLowerCase();return Q.roots.find((W)=>G.includes(oZ(W).toLowerCase()))}).find(Boolean);if(!z&&!Q.all)continue;Z.push({agent:"warp",sessionId:X.conversation_id,path:`${u4()}#${X.conversation_id}`,mtimeMs:Y,cwd:z})}return Z},read(Q){let $={agent:"warp",sessionId:Q.sessionId,source:Q.path,records:[],unknownTypes:{},warnings:[]},Z=R6(Y8("select summary from agent_conversations where conversation_id = ?",Q.sessionId)[0]?.summary);if(c2(Z?.title))$.title=Z.title;return wI(Y8("select input, start_ts, working_directory from ai_queries where conversation_id = ? order by start_ts",Q.sessionId),eG().get(Q.sessionId)??[],$),$}};var mI=(Q,$)=>fI(gI(u4($,Q)))||!!$0("warp",$),ZW={id:"warp",label:"Warp",status:"partial",supportTier:"community",variants:"Warp agent",limits:["Warp keeps its agent's replies and file edits on its servers; Tracetoon reads the prompts and the commands the agent ran, from Warp's local database.","Warp has no hook before its agent's tools, so a PR command run by Warp's agent isn't redirected; the agent can still use the Tracetoon skill."],traces:[$W],skill:(Q,$)=>({present:mI(Q,$),dir:hI(Q,".agents","skills","tracetoon")})};var p0=[gK,aK,YV,DV,OV,yV,gV,mV,nV,KG,MG,qG,IG,yG,mG,pG,rG,ZW,zV],XW=["codex","factory","copilot","cursor","kiro","claude"],c4=p0.flatMap((Q)=>Q.traces),t5=p0.filter((Q)=>Q.hook).map((Q)=>Q.id);function e5(Q){return p0.find(($)=>$.id===Q)}function E6(Q){return c4.find(($)=>$.id===Q)?.label??Q}function S6(Q=process.env){let $=[...XW.map(e5).filter((Z)=>!!Z),...p0.filter((Z)=>!XW.includes(Z.id))];for(let Z of $)for(let X of Z.sessionEnv??[])if(Q[X])return Q[X];return}function JW(Q){return Q==="AI_AGENT"||p0.some(($)=>$.hostEnv?.test(Q))}function k6(Q,$){let Z=e5(Q),X=[...Z?[Z]:[],...p0.filter((Y)=>Y!==Z)];for(let Y of X){let J=Y.hook?.parse($);if(J)return{host:Y,payload:J}}return}function l4(Q=YW(),$=process.env){let Z=[];for(let X of p0){let Y=X.skill?.(Q,$);if(!Y?.present)continue;let J=Z.find((z)=>z.dir===Y.dir);if(J)J.labels.push(X.label);else Z.push({labels:[X.label],dir:Y.dir})}return Z}function zW(Q=YW(),$=process.env){let Z=[];for(let X of p0){let Y=X.skill?.(Q,$);if(!Y)continue;if(!Z.find((z)=>z.dir===Y.dir))Z.push({label:X.label,dir:Y.dir})}return Z}var KW=[];function J8(Q=iI(),$=process.env){return p0.filter((Z)=>Z.hook).map((Z)=>({agent:Z.id,label:Z.label,file:Z.hook.file(Q,$),present:Z.hook.present(Q,$)}))}var l2=(Q)=>{let $=e5(Q.agent)?.hook;if(!$)throw Error(`no hook integration for ${Q.agent}`);return $};function nI(Q,$){return`${(Array.isArray($)?$:[$]).map((X)=>{let Y=X.replace(/\\/g,"/");return/\s/.test(Y)?`"${Y}"`:Y}).join(" ")} hook pre-pr --agent ${Q}`}function VW(Q,$){let Z=nI(Q,$),X=(Array.isArray($)?$:[$]).map((Y)=>Y.replace(/\\/g,"/"));return{prePr:Z,lifecycle:(Y)=>Z.replace(/hook pre-pr --agent/,"hook lifecycle --agent")+` --event ${Y}`,argv:{prePr:[...X,"hook","pre-pr","--agent",Q],lifecycle:(Y)=>[...X,"hook","lifecycle","--agent",Q,"--event",Y]}}}function y6(Q,$=J8()){return $.map((Z)=>{let X={agent:Z.agent,label:Z.label,file:Z.file};if(!Z.present)return{...X,result:"skipped",note:"not installed"};let Y=l2(Z).text;if(Y){let V=VW(Z.agent,Q),G=oI(Z.file,Y,V),W=G.map((B)=>eZ(B.path));if(G.every((B,H)=>W[H]===B.text))return{...X,result:"unchanged"};if(W.some((B)=>B!==void 0&&!Y.command(B)))return{...X,result:"skipped",note:"a file Tracetoon did not write is there; left untouched"};for(let B of G)if(cI(tZ(B.path),{recursive:!0}),pI(B.path,B.text,"utf8"),B.executable)uI(B.path,493);return{...X,result:"installed",note:l2(Z).installNote?.(Z.file,{})}}let J;try{J=x1(Z.file)}catch(V){return{...X,result:"skipped",note:`could not read it (${V.message}); left untouched`}}let z=l2(Z),K=z.apply(J,VW(Z.agent,Q));if(JSON.stringify(K)===JSON.stringify(J))return{...X,result:"unchanged"};return D$(Z.file,K),{...X,result:"installed",note:z.installNote?.(Z.file,K)}})}function BW(Q=J8()){return Q.map(($)=>{let Z={agent:$.agent,label:$.label,file:$.file},X=l2($).text;if(X){let z=!1;for(let K of[$.file,...aI($.file,X)]){let V=eZ(K);if(V===void 0||!X.command(V))continue;dI(K,{force:!0}),z=!0}return{...Z,result:z?"removed":"unchanged"}}let Y;try{Y=x1($.file)}catch{return{...Z,result:"skipped",note:"could not read it; left untouched"}}let J=l2($).apply(Y,void 0);if(JSON.stringify(J)===JSON.stringify(Y))return{...Z,result:"unchanged"};return D$($.file,J),{...Z,result:"removed"}})}var GW="PR creation through recognized shell commands and GitHub connectors; existing PR operations, pushes and read-only commands are left alone. Arbitrary network scripts are not intercepted.",aI=(Q,$)=>Object.keys($.siblings??{}).map((Z)=>WW(tZ(Q),Z));function oI(Q,$,Z){return[{path:Q,text:$.render(Z),executable:!1},...Object.entries($.siblings??{}).map(([X,Y])=>({path:WW(tZ(Q),X),text:Y(Z),executable:$.executable?.includes(X)??!1}))]}function eZ(Q){try{return lI(Q,"utf8")}catch{return}}function x6(Q=J8()){return Q.map(($)=>{let Z=l2($).text;if(Z){let G=(()=>{let W=eZ($.file);return W===void 0?void 0:Z.command(W)})();return{agent:$.agent,label:$.label,present:$.present,installed:!!G,file:$.file,completionInstalled:!1,command:G,coverage:GW}}let X={},Y=!1;try{X=x1($.file)}catch{Y=!0}let J=JSON.stringify(X),z=l2($),K=!Y&&(J.includes("hook pre-pr")&&/tracetoon/i.test(J)||!!z.installedCommand(X)),V={agent:$.agent,label:$.label,present:$.present,installed:K,file:$.file,completionInstalled:J.includes("hook lifecycle")&&J.includes("--event Stop"),command:z.installedCommand(X),coverage:GW};if(Y)V.problem=`${$.file} is not valid JSON`;else if(K)V.problem=z.problem?.($.file,X);if(V.problem===void 0)delete V.problem;return V})}import{existsSync as UT,readFileSync as MT}from"node:fs";import{join as DT}from"node:path";import{spawnSync as sI}from"node:child_process";function X3(Q,$,Z={}){let X=/(?:^|[\\/])git(?:\.exe)?$/i.test(Q)?"git":/(?:^|[\\/])gh(?:\.exe)?$/i.test(Q)?"github":"other";if(X!=="git"||MW($)==="write")$X();u0(`subprocess.${X}`);let Y=$5(`subprocess.${X}`,()=>sI(Q,$,{cwd:Z.cwd,input:Z.input,env:Z.env??process.env,encoding:"utf8",maxBuffer:268435456,windowsHide:!0,timeout:Z.timeoutMs}));if(Y.error)return{ok:!1,code:-1,stdout:"",stderr:String(Y.error.message)};return{ok:Y.status===0,code:Y.status??-1,stdout:Y.stdout??"",stderr:Y.stderr??""}}var QX=0,w6=new Map;function UW(Q){QX++;let $=!1;try{let Z=Q();if(Z instanceof Promise)return $=!0,Z.finally(HW);return Z}finally{if(!$)HW()}}function HW(){if(--QX===0)w6.clear()}function $X(){w6.clear()}var rI=new Set(["blame","cat-file","check-ignore","describe","diff","for-each-ref","grep","log","ls-files","ls-tree","merge-base","rev-list","rev-parse","show","show-ref","status"]);function tI(Q){let $=0;while($<Q.length&&Q[$].startsWith("-"))$+=Q[$]==="-c"||Q[$]==="-C"?2:1;return Q.slice($)}function MW(Q){let[$,...Z]=tI(Q);if($==="rev-parse")return"cache";if($==="remote")return Z[0]==="get-url"||Z[0]==="-v"&&Z.length===1?"cache":"write";if($==="config")return Z[0]==="--get"&&Z.length===2?"cache":"write";if($==="worktree")return Z[0]==="list"?"read":"write";if($==="notes")return Z.find((X)=>!X.startsWith("-"))==="list"?"read":"write";return $&&rI.has($)?"read":"write"}function p(Q,$,Z,X){let Y=QX>0&&Z===void 0&&!X&&MW($)==="cache",J=Y?JSON.stringify([Q,$]):"",z=Y?w6.get(J):void 0;if(z)return{...z};let K=X3("git",["-c","core.fsmonitor=false","-c","protocol.ext.allow=never","-c","core.quotepath=off",...$],{cwd:Q,input:Z,env:X?{...process.env,...X}:void 0});if(Y)w6.set(J,{...K});return K}function y0(Q,$){let Z=process.env.TRACETOON_GH_SCRIPT,[X,Y]=Z?[process.env.TRACETOON_TEST_RUNNER??process.execPath,[Z,...$]]:["gh",$];return X3(X,Y,{cwd:Q,env:{...process.env,GH_PROMPT_DISABLED:"1",NO_COLOR:"1"}})}import{join as $i,resolve as JX}from"node:path";var eI=/^[^/\s]+\/[^/\s]+$/;function d4(Q){let $=/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(Q.trim());return $?{owner:$[1],name:$[2]}:void 0}var DW=(Q)=>Q?`${Q.owner}/${Q.name}`:void 0;function d2(Q,$={}){let Z=DW(d4(p(Q,["remote","get-url","origin"]).stdout)),X;if(!$.offline){let J=y0(Q,["repo","view","--json","nameWithOwner","-q",".nameWithOwner"]),z=J.ok?J.stdout.trim():"";if(eI.test(z))X=z}let Y=Z;if(X){if(new Set(p(Q,["remote","-v"]).stdout.split(/\r?\n/).map((z)=>DW(d4(z.split(/\s+/)[1]??""))?.toLowerCase()).filter(Boolean)).has(X.toLowerCase())||!Z)Y=X}return Y?{repo:Y,origin:Z,ghDefault:X}:void 0}function Q2(Q){return Q?["--repo",Q]:[]}function z8(Q,$,Z){let X=Z?.split("/")[0];return $&&X&&$.toLowerCase()!==X.toLowerCase()?`${$}:${Q}`:Q}function b6(Q){if(!Q)return"PR target: unknown (no GitHub remote and no gh default repo).";let $=[];if(Q.origin&&Q.origin.toLowerCase()!==Q.repo.toLowerCase())$.push(`branch is pushed to ${Q.origin}, a different repository`);if(Q.ghDefault&&Q.ghDefault.toLowerCase()!==Q.repo.toLowerCase())$.push(`gh's default repo ${Q.ghDefault} is not a remote of this clone, ignored`);return`PR target: ${Q.repo}${$.length?` (${$.join("; ")})`:""}.`}import{lstatSync as QT,readFileSync as $T,readlinkSync as ZT,realpathSync as ZX}from"node:fs";import{dirname as XT,isAbsolute as YT,relative as JT,resolve as NW}from"node:path";function XX(Q){return Q.replace(/\\/g,"/").split("/").some(($)=>[".git",".showtail"].includes($.toLowerCase()))}function E0(Q){return!!Q&&!YT(Q)&&!Q.includes("\\")&&!/[:\x00-\x1f\x7f]/.test(Q)&&!XX(Q)&&!Q.split("/").some(($)=>!$||$===".."||$===".")}function qW(Q,$){let Z=JT(ZX.native(Q),$).replace(/\\/g,"/");if(Z!==""&&!E0(Z))throw Error("Path is outside the repository or private.")}function K8(Q,$){if(!E0($))throw Error(`Unsafe repository source: ${$}`);let Z=ZX.native(NW(Q,$));return qW(Q,Z),$T(Z)}function K5(Q,$){if(!E0($))throw Error(`Unsafe submitted path: ${$}`);let Z=NW(Q,$);qW(Q,ZX.native(XT(Z)));let X=QT(Z);if(X.isSymbolicLink())return Buffer.from(ZT(Z),"utf8");if(!X.isFile())throw Error("Submitted path is not a regular file.");return K8(Q,$)}function YX(Q,$){let Z=p(Q,$);if(!Z.ok)throw Error(`git ${$.join(" ")} failed: ${Z.stderr.trim()||Z.code}`);return Z.stdout.trim()}function zT(Q){let $=p(Q,["worktree","list","--porcelain"]);if(!$.ok)return[];return $.stdout.split(/\r?\n/).filter((Z)=>Z.startsWith("worktree ")).map((Z)=>JX(Z.slice(9)))}var zX=["rev-parse","--show-toplevel","--absolute-git-dir","HEAD","--abbrev-ref","HEAD"];function V8(Q){let $=p(Q,zX),[Z,X,Y,J]=$.stdout.split(/\r?\n/).map((z)=>z.trim());if(!Z||!X)return;return{toplevel:JX(Z),gitDir:JX(X),branch:J||"HEAD",.../^[a-f0-9]{40,64}$/.test(Y??"")?{headSha:Y}:{},ok:$.ok}}var CW=["main","master","trunk","develop"];function PW(Q,$=[]){let Z=["refs/remotes/origin/HEAD",...[...new Set([...CW,...$])].flatMap((J)=>[`refs/heads/${J}`,`refs/remotes/origin/${J}`])],X=p(Q,["for-each-ref","--format=%(refname)%09%(symref)",...Z]),Y=new Map;for(let J of X.stdout.split(/\r?\n/)){let[z,K]=J.split("\t");if(z)Y.set(z,K??"")}return Y}function _W(Q){let $=Q.get("refs/remotes/origin/HEAD");if($?.startsWith("refs/remotes/origin/"))return $.slice(20);return CW.find((Z)=>Q.has(`refs/heads/${Z}`))??"main"}function G8(Q){return _W(PW(Q))}function KT(Q,$){return Q.has(`refs/remotes/origin/${$}`)?`origin/${$}`:$}function KX(Q,$,Z){let X=new Map;for(let B of p(Q,["remote","-v"]).stdout.split(/\r?\n/)){let[H,U]=B.split(/\s+/);if(H&&!X.has(H)){let M=d4(U??"");X.set(H,M?`${M.owner}/${M.name}`.toLowerCase():void 0)}}let Y=new Set(p(Q,["for-each-ref","--format=%(refname)",`refs/remotes/${$}`,`refs/remotes/*/${$}`]).stdout.split(/\r?\n/).filter(Boolean)),J=[...X.keys()].sort((B,H)=>H.length-B.length).find((B)=>$.startsWith(`${B}/`)&&Y.has(`refs/remotes/${$}`));if(J)return{branch:$.slice(J.length+1),ref:$};let z=(B)=>Y.has(`refs/remotes/${B}/${$}`),K=Z?.toLowerCase(),V=K?[...X].find(([,B])=>B===K)?.[0]:void 0,G=[...X.keys()].filter(z),W=z("origin")?"origin":V&&z(V)?V:G.length===1?G[0]:void 0;return{branch:$,ref:W?`${W}/${$}`:$}}function VT(Q,$,Z,X){let Y=y0(Q,["pr","view",z8($,X,Z),...Q2(Z),"--json","number,url,title,body,baseRefName,headRefName,state"]);if(!Y.ok)return;try{let J=JSON.parse(Y.stdout);return J.state==="OPEN"||J.state==="DRAFT"?J:void 0}catch{return}}function GT(Q){let $={};for(let Z of Q.split(/\r?\n/)){let X=/^([A-Za-z][A-Za-z0-9-]*):\s*(.+)$/.exec(Z.trim());if(!X)continue;($[X[1]]??=[]).push(X[2].trim())}return $}function WT(Q,$,Z){let X=p(Q,["log","--reverse","--no-merges","--format=%H%x1f%s%x1f%at%x1f%ct%x1f%(trailers:unfold,only)%x1f%b%x1e",`${$}..${Z}`]);if(!X.ok)return[];return X.stdout.split("\x1E").map((Y)=>Y.replace(/^\s+/,"")).filter(Boolean).map((Y)=>{let[J,z,K,V,G,W]=Y.split("\x1F");return{sha:J,subject:z??"",...W?.trim()?{body:W.trim()}:{},authorTime:Number(K)*1000,commitTime:Number(V)*1000,trailers:GT(G??"")}})}function BT(Q){let $=[],Z,X,Y=!1,J=0,z=(K)=>Number(/\+(\d+)/.exec(K)?.[1]??0);for(let K of Q.split(/\r?\n/)){if(K.startsWith("diff --git ")){Z=void 0,X=void 0,Y=!1;continue}let V=/^Binary files (?:a\/(.+?)|\/dev\/null) and (?:b\/(.+?)|\/dev\/null) differ$/.exec(K);if(V){let G=V[2]??V[1];if(G)$.push({path:G,added:[],removed:[],addedAt:[]});continue}if(!Y){if(K.startsWith("--- ")){let G=K.slice(4).trim();X=G==="/dev/null"?void 0:G.replace(/^a\//,"")}else if(K.startsWith("+++ ")){let G=K.slice(4).trim(),W=G==="/dev/null"?X:G.replace(/^b\//,"");if(W)Z={path:W,added:[],removed:[],addedAt:[]},$.push(Z)}else if(K.startsWith("@@"))Y=!0,J=z(K);continue}if(K.startsWith("@@")){J=z(K);continue}if(!Z)continue;if(K.startsWith("+"))Z.added.push(K.slice(1)),Z.addedAt?.push(J++);else if(K.startsWith("-"))Z.removed.push(K.slice(1));else if(K.startsWith(" "))J++}return $}function HT(Q){let $=p(Q,["ls-files","--others","--exclude-standard","-z"]);if(!$.ok)return[];let Z=[];for(let X of $.stdout.split("\x00").filter(Boolean)){if(!E0(X))continue;try{let Y=K5(Q,X),J=Y.toString("utf8");Z.push({path:X,added:Y.includes(0)||!Buffer.from(J,"utf8").equals(Y)?[]:J.split(/\r?\n/),removed:[]})}catch{}}return Z}function i0(Q,$={}){let Z=V8(Q);if(!Z)YX(Q,["rev-parse","--show-toplevel"]);let{toplevel:X,gitDir:Y}=Z,J=$.head?YX(X,["rev-parse",$.head]):Z.headSha??"HEAD";if(!$.head&&!Z.ok)YX(X,["rev-parse","--abbrev-ref","HEAD"]);let z=$.head??Z.branch,K=$.noGh?void 0:d2(X),V=d4(p(X,["remote","get-url","origin"]).stdout)?.owner,G=$.noGh?void 0:VT(X,z,K?.repo,V),W=$.base??G?.baseRefName,B,H;if(W)({ref:H}=KX(X,B=W,K?.repo));else{let A=PW(X);B=_W(A),H=KT(A,B)}let U=p(X,["merge-base",H,J]).stdout.trim()||H,M=WT(X,U,J),N=p(X,["log","-n","200","--format=%H%x1f%ct%x1f%s",U]).stdout.split(/\r?\n/).filter(Boolean).map((A)=>{let[E,S,...x]=A.split("\x1F");return{sha:E,ct:Number(S),subject:x.join("\x1F")}}),D=N[0]?.ct??NaN,C=Number.isFinite(D)&&D>0?D*1000:void 0,F=N.map(({sha:A,subject:E})=>({sha:A,subject:E})),I=$.head?!1:p(X,["status","--porcelain","--untracked-files=no"]).stdout.trim().length>0,_=M.length===0&&!$.head,L=BT(p(X,_?["diff","-U0","--no-color","--no-ext-diff",U]:["diff","-U0","--no-color","--no-ext-diff",U,J]).stdout);if(_)L=L.concat(HT(X));L=L.filter((A)=>!XX(A.path));let T=[...new Set([X,...zT(X)])],O=p(X,["remote","get-url","origin"]).stdout.trim(),q=O?d4(O):void 0;return{toplevel:X,gitDir:Y,roots:T,head:z,headSha:J,base:B,mergeBase:U,mergeBaseTime:C,baseCommits:F,commits:M,files:L,usedWorkingTree:_,dirty:I,remote:q?{...q,url:O}:void 0,target:K,pr:G}}var FW=/^(0|false|off|no)$/i,LW=/^(1|true|on|yes)$/i;function AW(Q){try{if(!UT(Q))return;let $=JSON.parse(MT(Q,"utf8")).enabled;return typeof $==="boolean"?$:void 0}catch{return}}function p4(Q){return p(Q,zX).stdout.split(/\r?\n/)[0]?.trim()||void 0}function n3(Q,$=process.env){let Z=$.TRACETOON?.trim();if(Z&&FW.test(Z))return{enabled:!1,decidedBy:"env",why:"TRACETOON=0 is set"};let X=$.CI?.trim();if(X&&LW.test(X)&&!(Z&&LW.test(Z)))return{enabled:!1,decidedBy:"ci",why:"running in CI (set TRACETOON=1 to use it there)"};let Y=p4(Q);if(Y){if(AW(j4(Y))===!1)return{enabled:!1,decidedBy:"repo",why:`this repo turns it off in ${DT(".github","tracetoon.json")}`};let J=p(Y,["config","--get","tracetoon.enabled"]);if(J.ok&&FW.test(J.stdout.trim()))return{enabled:!1,decidedBy:"local",why:"turned off for this repo on this machine (git config tracetoon.enabled)"}}if(AW(O0())===!1)return{enabled:!1,decidedBy:"user",why:"turned off in your Tracetoon settings"};return{enabled:!0,decidedBy:"default",why:"default setting"}}var jW={name:"tracetoon",version:"1.0.0-rc.36",description:"Write pull request descriptions from the AI agent session logs already on your machine, plus a one-off comic.",private:!0,mcpName:"io.github.Tracetoon/tracetoon",type:"module",license:"Apache-2.0",homepage:"https://tracetoon.ai",repository:{type:"git",url:"git+https://github.com/Tracetoon/tracetoon.git"},bugs:"https://github.com/Tracetoon/tracetoon/issues",author:"Tracetoon",keywords:["pull-request","pull-request-description","pr-description-generator","ai-pull-request","github","code-review","ai-agents","agent-skills","claude-code","codex","antigravity","factory-droid","copilot","github-copilot","cursor","opencode","kilo","kilo-code","kiro","cline","junie","devin","goose","qwen-code","crush","amp","zed","warp","session-logs","agent-trace","provenance","ai-provenance","mcp","mcp-server","developer-tools","comic"],bin:{tracetoon:"./src/cli.ts"},scripts:{dev:"bun run src/cli.ts",test:"bun run scripts/test-source.ts","test:bundled":"bun run scripts/test-packaged.ts","test:compiled":"bun run scripts/test-packaged.ts --compiled",typecheck:"bun run scripts/typecheck.ts","dependencies:prepare":"bun run scripts/dependencies.ts",format:'bun x prettier --write "src/**/*.ts" "tests/**/*.ts"',bundle:"bun run scripts/bundle.ts",build:"bun run scripts/build.ts","build:check":"bun run scripts/build-info.ts --check","build:reproduce":"bun run scripts/reproduce.ts","agent-surfaces":"bun run scripts/agent-surfaces.ts","site-kit":"bun run scripts/site-kit.ts"},dependencies:{"@resvg/resvg-wasm":"2.6.2",commander:"^14.0.0",marked:"^16.0.0"},devDependencies:{"@types/node":"^22.0.0","bun-types":"^1.1.0",prettier:"^3.3.0",typescript:"^5.5.0","@expo-google-fonts/comic-neue":"^0.4.1"},engines:{bun:">=1.3.14"}};var qT="source",p2={version:"1.0.0-rc.36",buildId:"c0045bdb8cb1f52c58c604c7bd047ac4c859905d3aec5133bacde214faa8372e",revision:"c549db768d317db8dfdc3ee7bbec625428e7b35a",protocol:2,dependencies:[{name:"@showtail/agent-traces",revision:"dd0b6f40a09e206c1571a0440f2bdc2b78222c18",packageTree:"6eb00aad7a5c9aa7d54b6dbe3bdb1cd4cb17957e",sha256:"93ff323d6a1b62fe571a771facbbb17186c0530d7372b5b68b8763838fad78de"}],compiler:{name:"bun",version:"1.3.14"},recipe:{schema:"tracetoon.build-recipe/v1",bunVersion:"1.3.14",identity:"__TRACETOON_BUILD__",bundle:{target:"node",format:"esm",minify:!0,ascii:!0},native:{minify:!0,targets:["linux-x64","linux-arm64","darwin-x64","darwin-arm64","windows-x64"]}}},L0=jW.version,b0={version:L0,buildId:p2.buildId,revision:p2.revision,protocol:p2.protocol,...p2.dependencies?{dependencies:p2.dependencies}:{},...p2.compiler?{compiler:p2.compiler}:{},capabilities:["task-lifecycle","check-receipts","pr-creation-routing","shared-preparation","batch-evidence","claim-review-v2"]},i2=b0.buildId===qT;import{spawn as LT}from"node:child_process";import{existsSync as AT,mkdirSync as jT,readFileSync as RW,rmSync as IT,writeFileSync as TT}from"node:fs";import{basename as OT,dirname as EW,join as SW}from"node:path";import{existsSync as CT,realpathSync as PT}from"node:fs";import{homedir as _T}from"node:os";import{basename as FT,join as i4}from"node:path";function v6(Q=process.env,$=_T(),Z=process.platform,X=process.arch){let Y=Z==="win32",J=Y?"windows":Z==="darwin"?"darwin":"linux",z=X==="arm64"?"arm64":"x64",K=Y&&Q.LOCALAPPDATA?i4(Q.LOCALAPPDATA,"tracetoon"):i4(Q.XDG_DATA_HOME||i4($,".local","share"),"tracetoon"),V=Y?".exe":"";return{homeRoot:K,stable:i4(K,"bin",`tracetoon${V}`),assets:i4(K,"assets"),receipt:i4(K,"install.json"),asset:`tracetoon-${J}-${z}${V}`}}var IW=(Q)=>{try{return PT(Q)}catch{return Q}};function f6(Q,$=process.execPath,Z=process.env,X=i2){if(Z.TRACETOON_BIN)return{ok:!1,reason:"TRACETOON_BIN points at a runtime you manage yourself. Replace it, or unset it to use the installed one."};if(CT(Q.stable)&&IW($)===IW(Q.stable))return{ok:!0};if(!/^tracetoon(-[a-z]+-[a-z0-9]+)?(\.exe)?$/i.test(FT($)))return{ok:!1,reason:X?"This copy runs from a source checkout (bun src/cli.ts). Pull the checkout to update it, or install the binary: curl -fsSL https://raw.githubusercontent.com/Tracetoon/tracetoon/main/install.sh | sh":"This copy runs from a bundle (a Claude Code plugin). Update the plugin with /plugin marketplace update, or install the binary: curl -fsSL https://raw.githubusercontent.com/Tracetoon/tracetoon/main/install.sh | sh"};return{ok:!1,reason:`This binary (${$}) is not the installed one (${Q.stable}). Run the installed tracetoon, or re-run the installer.`}}function n2(Q){let $=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(Q.trim());if(!$)return;return{core:[Number($[1]),Number($[2]),Number($[3])],pre:$[4]?$[4].split(".").map((Z)=>/^\d+$/.test(Z)?Number(Z):Z):[]}}function $2(Q,$){let Z=n2(Q),X=n2($);if(!Z||!X)throw Error(`not a version: ${!Z?Q:$}`);for(let Y=0;Y<3;Y++){let J=Z.core[Y]-X.core[Y];if(J)return J}if(!Z.pre.length||!X.pre.length)return X.pre.length-Z.pre.length;for(let Y=0;Y<Math.max(Z.pre.length,X.pre.length);Y++){let J=Z.pre[Y],z=X.pre[Y];if(J===void 0)return-1;if(z===void 0)return 1;if(J===z)continue;if(typeof J==="number"&&typeof z==="number")return J-z;if(typeof J==="number")return-1;if(typeof z==="number")return 1;return J<z?-1:1}return 0}function TW(Q){return(n2(Q)?.pre.length??0)>0}var OW=86400000,RT=3600000,kW=900000,yW=(Q)=>EW(Q.TRACETOON_CONFIG??O0()),xW=(Q=process.env)=>SW(yW(Q),"update-state.json"),wW=(Q)=>SW(yW(Q),"update.lock"),h6=(Q=process.env)=>M0(xW(Q))??{};function g6(Q,$){A0(xW(Q),{...h6(Q),...$})}function ET(Q=process.env,$=Date.now()){try{return $-Number(RW(wW(Q),"utf8"))<kW}catch{return!1}}function bW(Q=process.env,$=Date.now()){let Z=wW(Q);try{if(AT(Z)&&$-Number(RW(Z,"utf8"))<kW)return}catch{}return jT(EW(Z),{recursive:!0}),TT(Z,String($)),()=>IT(Z,{force:!0})}function ST(Q,$){let X=/^tracetoon(-[a-z]+-[a-z0-9]+)?(\.exe)?$/i.test(OT(process.execPath))?Q:[process.argv[1],...Q],Y=LT(process.execPath,X,{detached:!0,stdio:"ignore",windowsHide:!0,env:$});Y.on("error",()=>{}),Y.unref()}function vW(Q,$=process.env,Z={}){if($.TRACETOON_NO_UPDATE_CHECK==="1"||$.TRACETOON_DISABLE_UPDATES==="1")return;let X=F0();if(X.autoUpdate==="off")return;if(!(Z.eligible??f6(v6($),process.execPath,$).ok))return;let J=Z.now??Date.now(),z=Z.spawn??((W)=>ST(W,$)),K=h6($);if((!K.checkedAt||K.channel!==X.updateChannel||J-Date.parse(K.checkedAt)>OW)&&(!K.spawnedAt||J-Date.parse(K.spawnedAt)>RT))g6($,{spawnedAt:new Date(J).toISOString()}),z(["update","--check","--quiet"]);if(!K.latest||K.channel!==X.updateChannel||$2(K.latest,L0)<=0)return;let G;if(X.autoUpdate==="install"){if(!ET($,J))z(["update","--auto","--quiet"]);G=`Tracetoon ${K.latest} is being installed in the background (you have ${L0}). Reload your agent when it finishes.`}else G=`Tracetoon ${K.latest} is available (you have ${L0}). Run: tracetoon update`;if(K.notifiedVersion===K.latest&&K.notifiedAt&&J-Date.parse(K.notifiedAt)<OW)return;if(g6($,{notifiedAt:new Date(J).toISOString(),notifiedVersion:K.latest}),Q!=="claude"&&Q!=="codex")return;return JSON.stringify({systemMessage:G,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:`${G} If the user asks to update, run \`tracetoon update --check --json\`, summarize what changed, confirm with them, then run \`tracetoon update\`. Do not update on your own.`}})}var kT=[{code:"ERROR",exit:1,meaning:"Any error without a more specific code"},{code:"USAGE",exit:2,meaning:"Unknown command or option, or a missing argument",fix:"tracetoon commands --json"},{code:"NOT_A_GIT_REPO",exit:1,meaning:"The command must run inside a git repository",fix:"cd into the repository, then rerun"},{code:"RUN_NOT_FOUND",exit:1,meaning:"No Tracetoon run, or not the one named by `--run`",fix:"tracetoon prepare --json"},{code:"RUN_OTHER_WORKTREE",exit:1,meaning:"The run belongs to another worktree or branch",fix:"Switch to that checkout, or pass another --run"},{code:"NOTHING_RENDERED",exit:1,meaning:"Publishing needs a render first",fix:"tracetoon render --json"},{code:"BRANCH_NOT_PUSHED",exit:1,meaning:"With `--no-push`: GitHub does not have the rendered revision",fix:"tracetoon publish --push"},{code:"PR_EXISTS",exit:1,meaning:"A PR Tracetoon did not render already exists for this branch and base",fix:"tracetoon context --json, then render and publish again (it updates that PR)"},{code:"GH_MISSING",exit:6,meaning:"The GitHub CLI (`gh`) is not installed",fix:"Install the GitHub CLI: https://cli.github.com",humanRequired:!0},{code:"GH_NOT_AUTHENTICATED",exit:6,meaning:"`gh` is not signed in, or its token was refused",fix:"gh auth login",humanRequired:!0},{code:"GH_FAILED",exit:1,meaning:"A `gh` call failed for another reason (the message has its output)"},{code:"GITHUB_UNREACHABLE",exit:7,meaning:"GitHub could not be reached, timed out or rate-limited the call",fix:"Rerun the same command in a minute",retryable:!0},{code:"CONSENT_REQUIRED",exit:4,meaning:"Sending comic prompts to this image route needs the user\u2019s agreement",fix:"Ask the user; rerun with --consent only after they agree",humanRequired:!0},{code:"NO_IMAGE_ROUTE",exit:5,meaning:"No approved image route can draw the comic",fix:"Offer the printed options, or skip the comic",humanRequired:!0},{code:"COMIC_UNEXPLAINED",exit:1,meaning:"A comic was expected and an image route could draw it, but none was drawn or skipped with a reason",fix:'Draw it (SKILL step 5), or `tracetoon comic skip --reason "<why>"`, then render again'},{code:"UPDATES_DISABLED",exit:1,meaning:"`TRACETOON_DISABLE_UPDATES=1` is set here"},{code:"UPDATE_LOOKUP_FAILED",exit:7,meaning:"The release list could not be fetched",fix:"Rerun the same command in a minute",retryable:!0},{code:"SKILL_SOURCE_NOT_FOUND",exit:1,meaning:"`setup` found no skill folder shipped with this runtime",fix:"Follow docs/agents/install.md"}];function W8(Q){return kT.find(($)=>$.code===Q)}var fW=1;function d(Q,$,Z){if(Q.json){let X=$&&typeof $==="object"&&!Array.isArray($)&&!("schemaVersion"in $)?{...$,schemaVersion:fW}:$;process.stdout.write(JSON.stringify(X,null,2)+`
|
|
329
|
+
`).trim()}function xI(Q){return c2(R6(Q.ai_metadata)?.conversation_id)??c2(R6(Q.agent_view_visibility)?.Agent?.origin_conversation_id)}function wI(Q,$,Z){for(let X of Q){let Y=R6(X.input);for(let J of Array.isArray(Y)?Y:[]){let z=c2(J?.Query?.text)?.trim();if(!z||G0(z))continue;Z.records.push({kind:"prompt",text:z,ts:sZ(X.start_ts),cwd:c2(X.working_directory)})}}for(let X of $){let Y=rZ(X.stylized_command);if(!Y)continue;N0(Z);let J=rZ(X.stylized_output);Z.records.push({kind:"command",cmd:Y,ts:sZ(X.start_ts),cwd:c2(X.pwd),...typeof X.exit_code==="number"&&X.exit_code!==0?{isError:!0}:{},...J?{output:J.slice(0,4000)}:{}})}Z.records.sort((X,Y)=>(X.ts??"").localeCompare(Y.ts??""))}function Y8(Q,...$){let Z=u4();if(!QW(Z))return[];try{let X=K3(Z);if(!X)return[];try{return X.all(Q,...$)}finally{X.close()}}catch{return[]}}var bI=(Q,$)=>{let Z=oZ(Q).toLowerCase(),X=oZ($).toLowerCase();return Z===X||Z.startsWith(X.endsWith(tG)?X:X+tG)},vI=`select pwd, exit_code, start_ts, ai_metadata, agent_view_visibility, stylized_command, stylized_output from blocks where ai_metadata is not null or agent_view_visibility like '%"Agent"%' order by start_ts`;function eG(){let Q=new Map;for(let $ of Y8(vI)){let Z=xI($);if(Z)Q.set(Z,[...Q.get(Z)??[],$])}return Q}var $W={id:"warp",label:"Warp",home:()=>QW(u4())?u4():void 0,count:()=>Number(Y8("select count(*) as n from agent_conversations")[0]?.n??0),discover(Q){let $=eG(),Z=[];for(let X of Y8("select conversation_id, last_modified_at from agent_conversations")){let Y=Date.parse(sZ(X.last_modified_at)??"")||0;if(Y<Q.sinceMs&&!Q.all)continue;let z=($.get(X.conversation_id)??[]).map((K)=>{let V=c2(K.pwd);if(V&&Q.roots.some((W)=>bI(V,W)))return V;let G=rZ(K.stylized_command).toLowerCase();return Q.roots.find((W)=>G.includes(oZ(W).toLowerCase()))}).find(Boolean);if(!z&&!Q.all)continue;Z.push({agent:"warp",sessionId:X.conversation_id,path:`${u4()}#${X.conversation_id}`,mtimeMs:Y,cwd:z})}return Z},read(Q){let $={agent:"warp",sessionId:Q.sessionId,source:Q.path,records:[],unknownTypes:{},warnings:[]},Z=R6(Y8("select summary from agent_conversations where conversation_id = ?",Q.sessionId)[0]?.summary);if(c2(Z?.title))$.title=Z.title;return wI(Y8("select input, start_ts, working_directory from ai_queries where conversation_id = ? order by start_ts",Q.sessionId),eG().get(Q.sessionId)??[],$),$}};var mI=(Q,$)=>fI(gI(u4($,Q)))||!!$0("warp",$),ZW={id:"warp",label:"Warp",status:"partial",supportTier:"community",variants:"Warp agent",limits:["Warp keeps its agent's replies and file edits on its servers; Tracetoon reads the prompts and the commands the agent ran, from Warp's local database.","Warp has no hook before its agent's tools, so a PR command run by Warp's agent isn't redirected; the agent can still use the Tracetoon skill."],traces:[$W],skill:(Q,$)=>({present:mI(Q,$),dir:hI(Q,".agents","skills","tracetoon")})};var p0=[gK,aK,YV,DV,OV,yV,gV,mV,nV,KG,MG,qG,IG,yG,mG,pG,rG,ZW,zV],XW=["codex","factory","copilot","cursor","kiro","claude"],c4=p0.flatMap((Q)=>Q.traces),t5=p0.filter((Q)=>Q.hook).map((Q)=>Q.id);function e5(Q){return p0.find(($)=>$.id===Q)}function E6(Q){return c4.find(($)=>$.id===Q)?.label??Q}function S6(Q=process.env){let $=[...XW.map(e5).filter((Z)=>!!Z),...p0.filter((Z)=>!XW.includes(Z.id))];for(let Z of $)for(let X of Z.sessionEnv??[])if(Q[X])return Q[X];return}function JW(Q){return Q==="AI_AGENT"||p0.some(($)=>$.hostEnv?.test(Q))}function k6(Q,$){let Z=e5(Q),X=[...Z?[Z]:[],...p0.filter((Y)=>Y!==Z)];for(let Y of X){let J=Y.hook?.parse($);if(J)return{host:Y,payload:J}}return}function l4(Q=YW(),$=process.env){let Z=[];for(let X of p0){let Y=X.skill?.(Q,$);if(!Y?.present)continue;let J=Z.find((z)=>z.dir===Y.dir);if(J)J.labels.push(X.label);else Z.push({labels:[X.label],dir:Y.dir})}return Z}function zW(Q=YW(),$=process.env){let Z=[];for(let X of p0){let Y=X.skill?.(Q,$);if(!Y)continue;if(!Z.find((z)=>z.dir===Y.dir))Z.push({label:X.label,dir:Y.dir})}return Z}var KW=[];function J8(Q=iI(),$=process.env){return p0.filter((Z)=>Z.hook).map((Z)=>({agent:Z.id,label:Z.label,file:Z.hook.file(Q,$),present:Z.hook.present(Q,$)}))}var l2=(Q)=>{let $=e5(Q.agent)?.hook;if(!$)throw Error(`no hook integration for ${Q.agent}`);return $};function nI(Q,$){return`${(Array.isArray($)?$:[$]).map((X)=>{let Y=X.replace(/\\/g,"/");return/\s/.test(Y)?`"${Y}"`:Y}).join(" ")} hook pre-pr --agent ${Q}`}function VW(Q,$){let Z=nI(Q,$),X=(Array.isArray($)?$:[$]).map((Y)=>Y.replace(/\\/g,"/"));return{prePr:Z,lifecycle:(Y)=>Z.replace(/hook pre-pr --agent/,"hook lifecycle --agent")+` --event ${Y}`,argv:{prePr:[...X,"hook","pre-pr","--agent",Q],lifecycle:(Y)=>[...X,"hook","lifecycle","--agent",Q,"--event",Y]}}}function y6(Q,$=J8()){return $.map((Z)=>{let X={agent:Z.agent,label:Z.label,file:Z.file};if(!Z.present)return{...X,result:"skipped",note:"not installed"};let Y=l2(Z).text;if(Y){let V=VW(Z.agent,Q),G=oI(Z.file,Y,V),W=G.map((B)=>eZ(B.path));if(G.every((B,H)=>W[H]===B.text))return{...X,result:"unchanged"};if(W.some((B)=>B!==void 0&&!Y.command(B)))return{...X,result:"skipped",note:"a file Tracetoon did not write is there; left untouched"};for(let B of G)if(cI(tZ(B.path),{recursive:!0}),pI(B.path,B.text,"utf8"),B.executable)uI(B.path,493);return{...X,result:"installed",note:l2(Z).installNote?.(Z.file,{})}}let J;try{J=x1(Z.file)}catch(V){return{...X,result:"skipped",note:`could not read it (${V.message}); left untouched`}}let z=l2(Z),K=z.apply(J,VW(Z.agent,Q));if(JSON.stringify(K)===JSON.stringify(J))return{...X,result:"unchanged"};return D$(Z.file,K),{...X,result:"installed",note:z.installNote?.(Z.file,K)}})}function BW(Q=J8()){return Q.map(($)=>{let Z={agent:$.agent,label:$.label,file:$.file},X=l2($).text;if(X){let z=!1;for(let K of[$.file,...aI($.file,X)]){let V=eZ(K);if(V===void 0||!X.command(V))continue;dI(K,{force:!0}),z=!0}return{...Z,result:z?"removed":"unchanged"}}let Y;try{Y=x1($.file)}catch{return{...Z,result:"skipped",note:"could not read it; left untouched"}}let J=l2($).apply(Y,void 0);if(JSON.stringify(J)===JSON.stringify(Y))return{...Z,result:"unchanged"};return D$($.file,J),{...Z,result:"removed"}})}var GW="PR creation through recognized shell commands and GitHub connectors; existing PR operations, pushes and read-only commands are left alone. Arbitrary network scripts are not intercepted.",aI=(Q,$)=>Object.keys($.siblings??{}).map((Z)=>WW(tZ(Q),Z));function oI(Q,$,Z){return[{path:Q,text:$.render(Z),executable:!1},...Object.entries($.siblings??{}).map(([X,Y])=>({path:WW(tZ(Q),X),text:Y(Z),executable:$.executable?.includes(X)??!1}))]}function eZ(Q){try{return lI(Q,"utf8")}catch{return}}function x6(Q=J8()){return Q.map(($)=>{let Z=l2($).text;if(Z){let G=(()=>{let W=eZ($.file);return W===void 0?void 0:Z.command(W)})();return{agent:$.agent,label:$.label,present:$.present,installed:!!G,file:$.file,completionInstalled:!1,command:G,coverage:GW}}let X={},Y=!1;try{X=x1($.file)}catch{Y=!0}let J=JSON.stringify(X),z=l2($),K=!Y&&(J.includes("hook pre-pr")&&/tracetoon/i.test(J)||!!z.installedCommand(X)),V={agent:$.agent,label:$.label,present:$.present,installed:K,file:$.file,completionInstalled:J.includes("hook lifecycle")&&J.includes("--event Stop"),command:z.installedCommand(X),coverage:GW};if(Y)V.problem=`${$.file} is not valid JSON`;else if(K)V.problem=z.problem?.($.file,X);if(V.problem===void 0)delete V.problem;return V})}import{existsSync as UT,readFileSync as MT}from"node:fs";import{join as DT}from"node:path";import{spawnSync as sI}from"node:child_process";function X3(Q,$,Z={}){let X=/(?:^|[\\/])git(?:\.exe)?$/i.test(Q)?"git":/(?:^|[\\/])gh(?:\.exe)?$/i.test(Q)?"github":"other";if(X!=="git"||MW($)==="write")$X();u0(`subprocess.${X}`);let Y=$5(`subprocess.${X}`,()=>sI(Q,$,{cwd:Z.cwd,input:Z.input,env:Z.env??process.env,encoding:"utf8",maxBuffer:268435456,windowsHide:!0,timeout:Z.timeoutMs}));if(Y.error)return{ok:!1,code:-1,stdout:"",stderr:String(Y.error.message)};return{ok:Y.status===0,code:Y.status??-1,stdout:Y.stdout??"",stderr:Y.stderr??""}}var QX=0,w6=new Map;function UW(Q){QX++;let $=!1;try{let Z=Q();if(Z instanceof Promise)return $=!0,Z.finally(HW);return Z}finally{if(!$)HW()}}function HW(){if(--QX===0)w6.clear()}function $X(){w6.clear()}var rI=new Set(["blame","cat-file","check-ignore","describe","diff","for-each-ref","grep","log","ls-files","ls-tree","merge-base","rev-list","rev-parse","show","show-ref","status"]);function tI(Q){let $=0;while($<Q.length&&Q[$].startsWith("-"))$+=Q[$]==="-c"||Q[$]==="-C"?2:1;return Q.slice($)}function MW(Q){let[$,...Z]=tI(Q);if($==="rev-parse")return"cache";if($==="remote")return Z[0]==="get-url"||Z[0]==="-v"&&Z.length===1?"cache":"write";if($==="config")return Z[0]==="--get"&&Z.length===2?"cache":"write";if($==="worktree")return Z[0]==="list"?"read":"write";if($==="notes")return Z.find((X)=>!X.startsWith("-"))==="list"?"read":"write";return $&&rI.has($)?"read":"write"}function p(Q,$,Z,X){let Y=QX>0&&Z===void 0&&!X&&MW($)==="cache",J=Y?JSON.stringify([Q,$]):"",z=Y?w6.get(J):void 0;if(z)return{...z};let K=X3("git",["-c","core.fsmonitor=false","-c","protocol.ext.allow=never","-c","core.quotepath=off",...$],{cwd:Q,input:Z,env:X?{...process.env,...X}:void 0});if(Y)w6.set(J,{...K});return K}function y0(Q,$){let Z=process.env.TRACETOON_GH_SCRIPT,[X,Y]=Z?[process.env.TRACETOON_TEST_RUNNER??process.execPath,[Z,...$]]:["gh",$];return X3(X,Y,{cwd:Q,env:{...process.env,GH_PROMPT_DISABLED:"1",NO_COLOR:"1"}})}import{join as $i,resolve as JX}from"node:path";var eI=/^[^/\s]+\/[^/\s]+$/;function d4(Q){let $=/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(Q.trim());return $?{owner:$[1],name:$[2]}:void 0}var DW=(Q)=>Q?`${Q.owner}/${Q.name}`:void 0;function d2(Q,$={}){let Z=DW(d4(p(Q,["remote","get-url","origin"]).stdout)),X;if(!$.offline){let J=y0(Q,["repo","view","--json","nameWithOwner","-q",".nameWithOwner"]),z=J.ok?J.stdout.trim():"";if(eI.test(z))X=z}let Y=Z;if(X){if(new Set(p(Q,["remote","-v"]).stdout.split(/\r?\n/).map((z)=>DW(d4(z.split(/\s+/)[1]??""))?.toLowerCase()).filter(Boolean)).has(X.toLowerCase())||!Z)Y=X}return Y?{repo:Y,origin:Z,ghDefault:X}:void 0}function Q2(Q){return Q?["--repo",Q]:[]}function z8(Q,$,Z){let X=Z?.split("/")[0];return $&&X&&$.toLowerCase()!==X.toLowerCase()?`${$}:${Q}`:Q}function b6(Q){if(!Q)return"PR target: unknown (no GitHub remote and no gh default repo).";let $=[];if(Q.origin&&Q.origin.toLowerCase()!==Q.repo.toLowerCase())$.push(`branch is pushed to ${Q.origin}, a different repository`);if(Q.ghDefault&&Q.ghDefault.toLowerCase()!==Q.repo.toLowerCase())$.push(`gh's default repo ${Q.ghDefault} is not a remote of this clone, ignored`);return`PR target: ${Q.repo}${$.length?` (${$.join("; ")})`:""}.`}import{lstatSync as QT,readFileSync as $T,readlinkSync as ZT,realpathSync as ZX}from"node:fs";import{dirname as XT,isAbsolute as YT,relative as JT,resolve as NW}from"node:path";function XX(Q){return Q.replace(/\\/g,"/").split("/").some(($)=>[".git",".showtail"].includes($.toLowerCase()))}function E0(Q){return!!Q&&!YT(Q)&&!Q.includes("\\")&&!/[:\x00-\x1f\x7f]/.test(Q)&&!XX(Q)&&!Q.split("/").some(($)=>!$||$===".."||$===".")}function qW(Q,$){let Z=JT(ZX.native(Q),$).replace(/\\/g,"/");if(Z!==""&&!E0(Z))throw Error("Path is outside the repository or private.")}function K8(Q,$){if(!E0($))throw Error(`Unsafe repository source: ${$}`);let Z=ZX.native(NW(Q,$));return qW(Q,Z),$T(Z)}function K5(Q,$){if(!E0($))throw Error(`Unsafe submitted path: ${$}`);let Z=NW(Q,$);qW(Q,ZX.native(XT(Z)));let X=QT(Z);if(X.isSymbolicLink())return Buffer.from(ZT(Z),"utf8");if(!X.isFile())throw Error("Submitted path is not a regular file.");return K8(Q,$)}function YX(Q,$){let Z=p(Q,$);if(!Z.ok)throw Error(`git ${$.join(" ")} failed: ${Z.stderr.trim()||Z.code}`);return Z.stdout.trim()}function zT(Q){let $=p(Q,["worktree","list","--porcelain"]);if(!$.ok)return[];return $.stdout.split(/\r?\n/).filter((Z)=>Z.startsWith("worktree ")).map((Z)=>JX(Z.slice(9)))}var zX=["rev-parse","--show-toplevel","--absolute-git-dir","HEAD","--abbrev-ref","HEAD"];function V8(Q){let $=p(Q,zX),[Z,X,Y,J]=$.stdout.split(/\r?\n/).map((z)=>z.trim());if(!Z||!X)return;return{toplevel:JX(Z),gitDir:JX(X),branch:J||"HEAD",.../^[a-f0-9]{40,64}$/.test(Y??"")?{headSha:Y}:{},ok:$.ok}}var CW=["main","master","trunk","develop"];function PW(Q,$=[]){let Z=["refs/remotes/origin/HEAD",...[...new Set([...CW,...$])].flatMap((J)=>[`refs/heads/${J}`,`refs/remotes/origin/${J}`])],X=p(Q,["for-each-ref","--format=%(refname)%09%(symref)",...Z]),Y=new Map;for(let J of X.stdout.split(/\r?\n/)){let[z,K]=J.split("\t");if(z)Y.set(z,K??"")}return Y}function _W(Q){let $=Q.get("refs/remotes/origin/HEAD");if($?.startsWith("refs/remotes/origin/"))return $.slice(20);return CW.find((Z)=>Q.has(`refs/heads/${Z}`))??"main"}function G8(Q){return _W(PW(Q))}function KT(Q,$){return Q.has(`refs/remotes/origin/${$}`)?`origin/${$}`:$}function KX(Q,$,Z){let X=new Map;for(let B of p(Q,["remote","-v"]).stdout.split(/\r?\n/)){let[H,U]=B.split(/\s+/);if(H&&!X.has(H)){let M=d4(U??"");X.set(H,M?`${M.owner}/${M.name}`.toLowerCase():void 0)}}let Y=new Set(p(Q,["for-each-ref","--format=%(refname)",`refs/remotes/${$}`,`refs/remotes/*/${$}`]).stdout.split(/\r?\n/).filter(Boolean)),J=[...X.keys()].sort((B,H)=>H.length-B.length).find((B)=>$.startsWith(`${B}/`)&&Y.has(`refs/remotes/${$}`));if(J)return{branch:$.slice(J.length+1),ref:$};let z=(B)=>Y.has(`refs/remotes/${B}/${$}`),K=Z?.toLowerCase(),V=K?[...X].find(([,B])=>B===K)?.[0]:void 0,G=[...X.keys()].filter(z),W=z("origin")?"origin":V&&z(V)?V:G.length===1?G[0]:void 0;return{branch:$,ref:W?`${W}/${$}`:$}}function VT(Q,$,Z,X){let Y=y0(Q,["pr","view",z8($,X,Z),...Q2(Z),"--json","number,url,title,body,baseRefName,headRefName,state"]);if(!Y.ok)return;try{let J=JSON.parse(Y.stdout);return J.state==="OPEN"||J.state==="DRAFT"?J:void 0}catch{return}}function GT(Q){let $={};for(let Z of Q.split(/\r?\n/)){let X=/^([A-Za-z][A-Za-z0-9-]*):\s*(.+)$/.exec(Z.trim());if(!X)continue;($[X[1]]??=[]).push(X[2].trim())}return $}function WT(Q,$,Z){let X=p(Q,["log","--reverse","--no-merges","--format=%H%x1f%s%x1f%at%x1f%ct%x1f%(trailers:unfold,only)%x1f%b%x1e",`${$}..${Z}`]);if(!X.ok)return[];return X.stdout.split("\x1E").map((Y)=>Y.replace(/^\s+/,"")).filter(Boolean).map((Y)=>{let[J,z,K,V,G,W]=Y.split("\x1F");return{sha:J,subject:z??"",...W?.trim()?{body:W.trim()}:{},authorTime:Number(K)*1000,commitTime:Number(V)*1000,trailers:GT(G??"")}})}function BT(Q){let $=[],Z,X,Y=!1,J=0,z=(K)=>Number(/\+(\d+)/.exec(K)?.[1]??0);for(let K of Q.split(/\r?\n/)){if(K.startsWith("diff --git ")){Z=void 0,X=void 0,Y=!1;continue}let V=/^Binary files (?:a\/(.+?)|\/dev\/null) and (?:b\/(.+?)|\/dev\/null) differ$/.exec(K);if(V){let G=V[2]??V[1];if(G)$.push({path:G,added:[],removed:[],addedAt:[]});continue}if(!Y){if(K.startsWith("--- ")){let G=K.slice(4).trim();X=G==="/dev/null"?void 0:G.replace(/^a\//,"")}else if(K.startsWith("+++ ")){let G=K.slice(4).trim(),W=G==="/dev/null"?X:G.replace(/^b\//,"");if(W)Z={path:W,added:[],removed:[],addedAt:[]},$.push(Z)}else if(K.startsWith("@@"))Y=!0,J=z(K);continue}if(K.startsWith("@@")){J=z(K);continue}if(!Z)continue;if(K.startsWith("+"))Z.added.push(K.slice(1)),Z.addedAt?.push(J++);else if(K.startsWith("-"))Z.removed.push(K.slice(1));else if(K.startsWith(" "))J++}return $}function HT(Q){let $=p(Q,["ls-files","--others","--exclude-standard","-z"]);if(!$.ok)return[];let Z=[];for(let X of $.stdout.split("\x00").filter(Boolean)){if(!E0(X))continue;try{let Y=K5(Q,X),J=Y.toString("utf8");Z.push({path:X,added:Y.includes(0)||!Buffer.from(J,"utf8").equals(Y)?[]:J.split(/\r?\n/),removed:[]})}catch{}}return Z}function i0(Q,$={}){let Z=V8(Q);if(!Z)YX(Q,["rev-parse","--show-toplevel"]);let{toplevel:X,gitDir:Y}=Z,J=$.head?YX(X,["rev-parse",$.head]):Z.headSha??"HEAD";if(!$.head&&!Z.ok)YX(X,["rev-parse","--abbrev-ref","HEAD"]);let z=$.head??Z.branch,K=$.noGh?void 0:d2(X),V=d4(p(X,["remote","get-url","origin"]).stdout)?.owner,G=$.noGh?void 0:VT(X,z,K?.repo,V),W=$.base??G?.baseRefName,B,H;if(W)({ref:H}=KX(X,B=W,K?.repo));else{let A=PW(X);B=_W(A),H=KT(A,B)}let U=p(X,["merge-base",H,J]).stdout.trim()||H,M=WT(X,U,J),N=p(X,["log","-n","200","--format=%H%x1f%ct%x1f%s",U]).stdout.split(/\r?\n/).filter(Boolean).map((A)=>{let[E,S,...x]=A.split("\x1F");return{sha:E,ct:Number(S),subject:x.join("\x1F")}}),D=N[0]?.ct??NaN,C=Number.isFinite(D)&&D>0?D*1000:void 0,F=N.map(({sha:A,subject:E})=>({sha:A,subject:E})),I=$.head?!1:p(X,["status","--porcelain","--untracked-files=no"]).stdout.trim().length>0,_=M.length===0&&!$.head,L=BT(p(X,_?["diff","-U0","--no-color","--no-ext-diff",U]:["diff","-U0","--no-color","--no-ext-diff",U,J]).stdout);if(_)L=L.concat(HT(X));L=L.filter((A)=>!XX(A.path));let T=[...new Set([X,...zT(X)])],O=p(X,["remote","get-url","origin"]).stdout.trim(),q=O?d4(O):void 0;return{toplevel:X,gitDir:Y,roots:T,head:z,headSha:J,base:B,mergeBase:U,mergeBaseTime:C,baseCommits:F,commits:M,files:L,usedWorkingTree:_,dirty:I,remote:q?{...q,url:O}:void 0,target:K,pr:G}}var FW=/^(0|false|off|no)$/i,LW=/^(1|true|on|yes)$/i;function AW(Q){try{if(!UT(Q))return;let $=JSON.parse(MT(Q,"utf8")).enabled;return typeof $==="boolean"?$:void 0}catch{return}}function p4(Q){return p(Q,zX).stdout.split(/\r?\n/)[0]?.trim()||void 0}function n3(Q,$=process.env){let Z=$.TRACETOON?.trim();if(Z&&FW.test(Z))return{enabled:!1,decidedBy:"env",why:"TRACETOON=0 is set"};let X=$.CI?.trim();if(X&&LW.test(X)&&!(Z&&LW.test(Z)))return{enabled:!1,decidedBy:"ci",why:"running in CI (set TRACETOON=1 to use it there)"};let Y=p4(Q);if(Y){if(AW(j4(Y))===!1)return{enabled:!1,decidedBy:"repo",why:`this repo turns it off in ${DT(".github","tracetoon.json")}`};let J=p(Y,["config","--get","tracetoon.enabled"]);if(J.ok&&FW.test(J.stdout.trim()))return{enabled:!1,decidedBy:"local",why:"turned off for this repo on this machine (git config tracetoon.enabled)"}}if(AW(O0())===!1)return{enabled:!1,decidedBy:"user",why:"turned off in your Tracetoon settings"};return{enabled:!0,decidedBy:"default",why:"default setting"}}var jW={name:"tracetoon",version:"1.0.0-rc.37",description:"Write pull request descriptions from the AI agent session logs already on your machine, plus a one-off comic.",private:!0,mcpName:"io.github.Tracetoon/tracetoon",type:"module",license:"Apache-2.0",homepage:"https://tracetoon.ai",repository:{type:"git",url:"git+https://github.com/Tracetoon/tracetoon.git"},bugs:"https://github.com/Tracetoon/tracetoon/issues",author:"Tracetoon",keywords:["pull-request","pull-request-description","pr-description-generator","ai-pull-request","github","code-review","ai-agents","agent-skills","claude-code","codex","antigravity","factory-droid","copilot","github-copilot","cursor","opencode","kilo","kilo-code","kiro","cline","junie","devin","goose","qwen-code","crush","amp","zed","warp","session-logs","agent-trace","provenance","ai-provenance","mcp","mcp-server","developer-tools","comic"],bin:{tracetoon:"./src/cli.ts"},scripts:{dev:"bun run src/cli.ts",test:"bun run scripts/test-source.ts","test:bundled":"bun run scripts/test-packaged.ts","test:compiled":"bun run scripts/test-packaged.ts --compiled",typecheck:"bun run scripts/typecheck.ts","dependencies:prepare":"bun run scripts/dependencies.ts",format:'bun x prettier --write "src/**/*.ts" "tests/**/*.ts"',bundle:"bun run scripts/bundle.ts",build:"bun run scripts/build.ts","build:check":"bun run scripts/build-info.ts --check","build:reproduce":"bun run scripts/reproduce.ts","agent-surfaces":"bun run scripts/agent-surfaces.ts","site-kit":"bun run scripts/site-kit.ts"},dependencies:{"@resvg/resvg-wasm":"2.6.2",commander:"^14.0.0",marked:"^16.0.0"},devDependencies:{"@types/node":"^22.0.0","bun-types":"^1.1.0",prettier:"^3.3.0",typescript:"^5.5.0","@expo-google-fonts/comic-neue":"^0.4.1"},engines:{bun:">=1.3.14"}};var qT="source",p2={version:"1.0.0-rc.37",buildId:"060da6295acdf20495efada145899bce6c74a6c045f797b4544abc4b0596a645",revision:"a6320f5ab507e10d6bc1f8c0c15c00fc76a82883",protocol:2,dependencies:[{name:"@showtail/agent-traces",revision:"dd0b6f40a09e206c1571a0440f2bdc2b78222c18",packageTree:"6eb00aad7a5c9aa7d54b6dbe3bdb1cd4cb17957e",sha256:"93ff323d6a1b62fe571a771facbbb17186c0530d7372b5b68b8763838fad78de"}],compiler:{name:"bun",version:"1.3.14"},recipe:{schema:"tracetoon.build-recipe/v1",bunVersion:"1.3.14",identity:"__TRACETOON_BUILD__",bundle:{target:"node",format:"esm",minify:!0,ascii:!0},native:{minify:!0,targets:["linux-x64","linux-arm64","darwin-x64","darwin-arm64","windows-x64"]}}},L0=jW.version,b0={version:L0,buildId:p2.buildId,revision:p2.revision,protocol:p2.protocol,...p2.dependencies?{dependencies:p2.dependencies}:{},...p2.compiler?{compiler:p2.compiler}:{},capabilities:["task-lifecycle","check-receipts","pr-creation-routing","shared-preparation","batch-evidence","claim-review-v2"]},i2=b0.buildId===qT;import{spawn as LT}from"node:child_process";import{existsSync as AT,mkdirSync as jT,readFileSync as RW,rmSync as IT,writeFileSync as TT}from"node:fs";import{basename as OT,dirname as EW,join as SW}from"node:path";import{existsSync as CT,realpathSync as PT}from"node:fs";import{homedir as _T}from"node:os";import{basename as FT,join as i4}from"node:path";function v6(Q=process.env,$=_T(),Z=process.platform,X=process.arch){let Y=Z==="win32",J=Y?"windows":Z==="darwin"?"darwin":"linux",z=X==="arm64"?"arm64":"x64",K=Y&&Q.LOCALAPPDATA?i4(Q.LOCALAPPDATA,"tracetoon"):i4(Q.XDG_DATA_HOME||i4($,".local","share"),"tracetoon"),V=Y?".exe":"";return{homeRoot:K,stable:i4(K,"bin",`tracetoon${V}`),assets:i4(K,"assets"),receipt:i4(K,"install.json"),asset:`tracetoon-${J}-${z}${V}`}}var IW=(Q)=>{try{return PT(Q)}catch{return Q}};function f6(Q,$=process.execPath,Z=process.env,X=i2){if(Z.TRACETOON_BIN)return{ok:!1,reason:"TRACETOON_BIN points at a runtime you manage yourself. Replace it, or unset it to use the installed one."};if(CT(Q.stable)&&IW($)===IW(Q.stable))return{ok:!0};if(!/^tracetoon(-[a-z]+-[a-z0-9]+)?(\.exe)?$/i.test(FT($)))return{ok:!1,reason:X?"This copy runs from a source checkout (bun src/cli.ts). Pull the checkout to update it, or install the binary: curl -fsSL https://raw.githubusercontent.com/Tracetoon/tracetoon/main/install.sh | sh":"This copy runs from a bundle (a Claude Code plugin). Update the plugin with /plugin marketplace update, or install the binary: curl -fsSL https://raw.githubusercontent.com/Tracetoon/tracetoon/main/install.sh | sh"};return{ok:!1,reason:`This binary (${$}) is not the installed one (${Q.stable}). Run the installed tracetoon, or re-run the installer.`}}function n2(Q){let $=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(Q.trim());if(!$)return;return{core:[Number($[1]),Number($[2]),Number($[3])],pre:$[4]?$[4].split(".").map((Z)=>/^\d+$/.test(Z)?Number(Z):Z):[]}}function $2(Q,$){let Z=n2(Q),X=n2($);if(!Z||!X)throw Error(`not a version: ${!Z?Q:$}`);for(let Y=0;Y<3;Y++){let J=Z.core[Y]-X.core[Y];if(J)return J}if(!Z.pre.length||!X.pre.length)return X.pre.length-Z.pre.length;for(let Y=0;Y<Math.max(Z.pre.length,X.pre.length);Y++){let J=Z.pre[Y],z=X.pre[Y];if(J===void 0)return-1;if(z===void 0)return 1;if(J===z)continue;if(typeof J==="number"&&typeof z==="number")return J-z;if(typeof J==="number")return-1;if(typeof z==="number")return 1;return J<z?-1:1}return 0}function TW(Q){return(n2(Q)?.pre.length??0)>0}var OW=86400000,RT=3600000,kW=900000,yW=(Q)=>EW(Q.TRACETOON_CONFIG??O0()),xW=(Q=process.env)=>SW(yW(Q),"update-state.json"),wW=(Q)=>SW(yW(Q),"update.lock"),h6=(Q=process.env)=>M0(xW(Q))??{};function g6(Q,$){A0(xW(Q),{...h6(Q),...$})}function ET(Q=process.env,$=Date.now()){try{return $-Number(RW(wW(Q),"utf8"))<kW}catch{return!1}}function bW(Q=process.env,$=Date.now()){let Z=wW(Q);try{if(AT(Z)&&$-Number(RW(Z,"utf8"))<kW)return}catch{}return jT(EW(Z),{recursive:!0}),TT(Z,String($)),()=>IT(Z,{force:!0})}function ST(Q,$){let X=/^tracetoon(-[a-z]+-[a-z0-9]+)?(\.exe)?$/i.test(OT(process.execPath))?Q:[process.argv[1],...Q],Y=LT(process.execPath,X,{detached:!0,stdio:"ignore",windowsHide:!0,env:$});Y.on("error",()=>{}),Y.unref()}function vW(Q,$=process.env,Z={}){if($.TRACETOON_NO_UPDATE_CHECK==="1"||$.TRACETOON_DISABLE_UPDATES==="1")return;let X=F0();if(X.autoUpdate==="off")return;if(!(Z.eligible??f6(v6($),process.execPath,$).ok))return;let J=Z.now??Date.now(),z=Z.spawn??((W)=>ST(W,$)),K=h6($);if((!K.checkedAt||K.channel!==X.updateChannel||J-Date.parse(K.checkedAt)>OW)&&(!K.spawnedAt||J-Date.parse(K.spawnedAt)>RT))g6($,{spawnedAt:new Date(J).toISOString()}),z(["update","--check","--quiet"]);if(!K.latest||K.channel!==X.updateChannel||$2(K.latest,L0)<=0)return;let G;if(X.autoUpdate==="install"){if(!ET($,J))z(["update","--auto","--quiet"]);G=`Tracetoon ${K.latest} is being installed in the background (you have ${L0}). Reload your agent when it finishes.`}else G=`Tracetoon ${K.latest} is available (you have ${L0}). Run: tracetoon update`;if(K.notifiedVersion===K.latest&&K.notifiedAt&&J-Date.parse(K.notifiedAt)<OW)return;if(g6($,{notifiedAt:new Date(J).toISOString(),notifiedVersion:K.latest}),Q!=="claude"&&Q!=="codex")return;return JSON.stringify({systemMessage:G,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:`${G} If the user asks to update, run \`tracetoon update --check --json\`, summarize what changed, confirm with them, then run \`tracetoon update\`. Do not update on your own.`}})}var kT=[{code:"ERROR",exit:1,meaning:"Any error without a more specific code"},{code:"USAGE",exit:2,meaning:"Unknown command or option, or a missing argument",fix:"tracetoon commands --json"},{code:"NOT_A_GIT_REPO",exit:1,meaning:"The command must run inside a git repository",fix:"cd into the repository, then rerun"},{code:"RUN_NOT_FOUND",exit:1,meaning:"No Tracetoon run, or not the one named by `--run`",fix:"tracetoon prepare --json"},{code:"RUN_OTHER_WORKTREE",exit:1,meaning:"The run belongs to another worktree or branch",fix:"Switch to that checkout, or pass another --run"},{code:"NOTHING_RENDERED",exit:1,meaning:"Publishing needs a render first",fix:"tracetoon render --json"},{code:"BRANCH_NOT_PUSHED",exit:1,meaning:"With `--no-push`: GitHub does not have the rendered revision",fix:"tracetoon publish --push"},{code:"PR_EXISTS",exit:1,meaning:"A PR Tracetoon did not render already exists for this branch and base",fix:"tracetoon context --json, then render and publish again (it updates that PR)"},{code:"GH_MISSING",exit:6,meaning:"The GitHub CLI (`gh`) is not installed",fix:"Install the GitHub CLI: https://cli.github.com",humanRequired:!0},{code:"GH_NOT_AUTHENTICATED",exit:6,meaning:"`gh` is not signed in, or its token was refused",fix:"gh auth login",humanRequired:!0},{code:"GH_FAILED",exit:1,meaning:"A `gh` call failed for another reason (the message has its output)"},{code:"GITHUB_UNREACHABLE",exit:7,meaning:"GitHub could not be reached, timed out or rate-limited the call",fix:"Rerun the same command in a minute",retryable:!0},{code:"CONSENT_REQUIRED",exit:4,meaning:"Sending comic prompts to this image route needs the user\u2019s agreement",fix:"Ask the user; rerun with --consent only after they agree",humanRequired:!0},{code:"NO_IMAGE_ROUTE",exit:5,meaning:"No approved image route can draw the comic",fix:"Offer the printed options, or skip the comic",humanRequired:!0},{code:"COMIC_UNEXPLAINED",exit:1,meaning:"A comic was expected and an image route could draw it, but none was drawn or skipped with a reason",fix:'Draw it (SKILL step 5), or `tracetoon comic skip --reason "<why>"`, then render again'},{code:"UPDATES_DISABLED",exit:1,meaning:"`TRACETOON_DISABLE_UPDATES=1` is set here"},{code:"UPDATE_LOOKUP_FAILED",exit:7,meaning:"The release list could not be fetched",fix:"Rerun the same command in a minute",retryable:!0},{code:"SKILL_SOURCE_NOT_FOUND",exit:1,meaning:"`setup` found no skill folder shipped with this runtime",fix:"Follow docs/agents/install.md"}];function W8(Q){return kT.find(($)=>$.code===Q)}var fW=1;function d(Q,$,Z){if(Q.json){let X=$&&typeof $==="object"&&!Array.isArray($)&&!("schemaVersion"in $)?{...$,schemaVersion:fW}:$;process.stdout.write(JSON.stringify(X,null,2)+`
|
|
330
330
|
`)}else process.stdout.write(Z().replace(/\s*$/,"")+`
|
|
331
331
|
`)}class g extends Error{exitCode;isUserError=!0;code;fix;retryable;humanRequired;constructor(Q,$=1,Z={}){super(Q);this.exitCode=$;this.code=Z.code,this.fix=Z.fix,this.retryable=Z.retryable,this.humanRequired=Z.humanRequired}}function P0(Q,$,Z){let X=W8(Q);return new g($,X?.exit??1,{code:Q,fix:Z??X?.fix,retryable:X?.retryable??!1,humanRequired:X?.humanRequired??!1})}function VX(Q,$){let Z=$.trim(),X=`${Q} failed: ${Z}`;if(/ENOENT|not recognized as|executable file not found|command not found/i.test(Z))return P0("GH_MISSING",X);if(/not logged in|gh auth login|authentication|HTTP 401|bad credentials/i.test(Z))return P0("GH_NOT_AUTHENTICATED",X);if(/rate limit|HTTP 5\d\d|timed? ?out|ECONNRESET|ETIMEDOUT|could not resolve host|connection (lost|refused|reset)|network/i.test(Z))return P0("GITHUB_UNREACHABLE",X);return P0("GH_FAILED",X)}var yT=[[/not (inside )?a git repository/i,"NOT_A_GIT_REPO"],[/No Tracetoon run found/,"RUN_NOT_FOUND"],[/Invalid Tracetoon run id/,"RUN_NOT_FOUND"],[/belongs to another worktree or branch/,"RUN_OTHER_WORKTREE"]];function GX(Q){let $=Q,Z=String($?.message??Q),X=$?.isUserError?$:void 0,Y=X?.code||yT.find(([K])=>K.test(Z))?.[1],J=Y?W8(Y):void 0,z=X?.fix||J?.fix;return{schemaVersion:fW,error:Z,errorCode:Y??"ERROR",...z?{fix:z}:{},retryable:X?.retryable??J?.retryable??!1,humanRequired:X?.humanRequired??J?.humanRequired??!1}}import{spawn as fT,spawnSync as gT}from"node:child_process";import{existsSync as LX,mkdirSync as hT,mkdtempSync as rW,readdirSync as mT,readFileSync as n6,statSync as PX,writeFileSync as tW}from"node:fs";import{homedir as eW,tmpdir as QB}from"node:os";import{join as g3}from"node:path";var B8=[{id:"strip",name:"Gag strip",useWhen:"a joke told in beats: setup, build, punchline",layout:"a horizontal row of panels read left to right; the last panel lands the punchline",panels:[3,4],aspect:"16:9"},{id:"tiered-strip",name:"Tiered page",useWhen:"a scene that needs establishing first, then quick beats to the punchline",layout:"a wide establishing panel across the top, then a row of 2 to 4 smaller panels below it; the last one lands the joke",panels:[3,5],aspect:"4:3"},{id:"manga-page",name:"Manga page",useWhen:"escalation or a dramatic overreaction: quick beats into one big reaction",layout:"a manga page with irregular, slanted panels of different sizes; small fast beats lead into one dominant reaction panel",panels:[3,6],aspect:"3:4"},{id:"webtoon",name:"Vertical webtoon",useWhen:"a slow reveal or a pause before the punchline: read top to bottom",layout:"a vertical scroll of 3 to 5 stacked wide panels with space between them for timing; the last panel is the payoff",panels:[3,5],aspect:"3:4"},{id:"4koma",name:"4-koma",useWhen:"a story with a clear twist: setup, development, twist, resolution",layout:"four panels: setup, development, twist, resolution",panels:[4,4],aspect:"4:3"},{id:"before-after",name:"Before / after",useWhen:"only when the contrast itself is the punchline; most changes make a better joke as a story",layout:"split page: BEFORE on the left, AFTER on the right, optionally a narrow FIX panel between them",panels:[2,3],aspect:"16:9"},{id:"splash",name:"Splash page",useWhen:"one big moment says it all: a launch, a rescue, a victory",layout:"one full-page scene with a huge headline; at most one small inset or caption box",panels:[1,2],aspect:"4:3"},{id:"mission-briefing",name:"Mission briefing",useWhen:"a tricky multi-part fix: objectives, obstacles, outcome",layout:"a briefing board: a large hero panel plus 2 to 4 numbered mission cards with short labels",panels:[3,5],aspect:"4:3"},{id:"movie-poster",name:"Movie poster",useWhen:"a big feature or a dramatic rescue that deserves a blockbuster",layout:"a movie poster: the cast posed heroically, a title treatment, a tagline, and a credits block of short labels",panels:[1,1],aspect:"3:4"},{id:"manual-page",name:"Instruction manual",useWhen:"a new workflow or setup: show the steps",layout:"a flat-pack instruction manual page: 3 to 6 numbered steps with simple pictures and tiny labels",panels:[3,6],aspect:"4:3"},{id:"newspaper-sunday",name:"Sunday funnies",useWhen:"an everyday, relatable story with a few beats",layout:"a Sunday comics page: a title banner, then panels of varied widths in two rows",panels:[4,6],aspect:"4:3"},{id:"trading-card",name:"Trading card",useWhen:"a new capability or tool: show its stats and powers",layout:"a collectible trading card: a framed character portrait, a name plate, 2 to 3 ability lines and a stats box",panels:[1,1],aspect:"3:4"},{id:"custom",name:"Custom",useWhen:"none of the above fits: describe the page in `layout`",layout:"",panels:[1,6],aspect:"4:3"}],Z2=(Q)=>B8.find(($)=>$.id===Q);var m6=[{id:"webcomic",name:"Modern webcomic",family:"webcomic",prompt:"modern webcomic, bold clean black ink outlines, bright cel-shaded color, very expressive cartoon faces and big reactions, simple readable backgrounds, crisp panel borders with white gutters",palettes:["full-color"],moods:["gag","relatable","everyday","any"],lettering:"bold hand-lettered comic font in white speech balloons, yellow caption boxes, punchy sound effects"},{id:"superhero",name:"American superhero",family:"american",prompt:"modern American superhero comic book, dynamic foreshortened poses, confident inking with feathered shadows, rich digital coloring, dramatic lighting",palettes:["full-color"],moods:["heroic","rescue","big win","showdown"],lettering:"uppercase comic-book lettering in oval balloons, bold caption boxes, big angular sound effects"},{id:"silver-age",name:"Silver Age comic",family:"american",prompt:"1960s American comic book page, Ben-Day halftone dots, bold primary colors, thick inked outlines, melodramatic poses, slightly yellowed newsprint",palettes:["full-color","limited"],moods:["heroic","melodrama","retro","big claim"],lettering:"classic uppercase comic lettering in white balloons, exclamation-heavy, narration boxes"},{id:"alt-comix",name:"Indie alt-comix",family:"indie",prompt:"indie alternative comic, loose expressive brush ink, slightly wobbly hand-drawn panel borders, flat muted colors, deadpan characters",palettes:["limited","bw-accent"],moods:["deadpan","awkward","dry humor","existential"],lettering:"uneven hand-lettered capitals in simple balloons"},{id:"shonen-action",name:"Shonen manga",family:"manga",prompt:"shonen manga page, energetic black ink, screentone shading, speed lines and impact frames, exaggerated reactions, dynamic camera angles",palettes:["bw-accent","full-color"],moods:["epic","battle","comeback","speed","rivalry"],lettering:"manga balloons with bold lettering, huge hand-drawn sound effects integrated into the art"},{id:"manga-ink",name:"Seinen manga",family:"manga",prompt:"seinen manga page, detailed black ink linework, crosshatching and screentone, cinematic paneling, restrained, tense expressions",palettes:["bw-accent","limited"],moods:["tense","mystery","debugging","serious-as-a-joke"],lettering:"clean manga lettering in balloons, sparse narration boxes"},{id:"shojo",name:"Shojo manga",family:"manga",prompt:"shojo manga page, delicate fine linework, sparkle and flower screentones, big emotive eyes, soft pastel tones, panels that break their borders for emotional beats",palettes:["limited","full-color"],moods:["dramatic feelings","romance parody","wholesome","devotion"],lettering:"elegant manga lettering, floating inner-monologue text, sparkly emphasis"},{id:"chibi-anime",name:"Chibi manga comedy",family:"manga",prompt:"comedic chibi manga, super-deformed characters with big heads, sweat drops, anger marks and comic tears, simple screentone backgrounds, bold ink outlines",palettes:["full-color","limited"],moods:["silly","panic","small fix","cute"],lettering:"rounded bubbly balloons, wobbly panic lettering"},{id:"yonkoma",name:"Yonkoma gag manga",family:"manga",prompt:"yonkoma gag manga, clean simple ink linework, cute deformed characters, flat light tones, tidy rectangular panels",palettes:["bw-accent","limited"],moods:["gag","twist","everyday","deadpan"],lettering:"small neat balloons, a quiet beat before the last-panel punchline"},{id:"ligne-claire",name:"Ligne claire",family:"euro",prompt:"ligne claire European comic, clean uniform ink outlines, flat bright colors, detailed tidy backgrounds, no hatching",palettes:["full-color"],moods:["adventure","investigation","clever","travel"],lettering:"neat hand lettering in clean rounded balloons"},{id:"euro-humor",name:"Franco-Belgian humor",family:"euro",prompt:"Franco-Belgian humor comic, round bouncy cartoon characters with big noses, lively brush ink, bright flat colors, busy funny background details",palettes:["full-color"],moods:["slapstick","chaos","escalation","ensemble"],lettering:"lively hand lettering in rounded balloons, onomatopoeia drawn into the scene"},{id:"sunday-strip",name:"Sunday funnies",family:"newspaper",prompt:"classic Sunday newspaper comic strip, simple expressive cartoon characters, warm flat colors, confident brush outlines, slight newsprint texture",palettes:["full-color","limited"],moods:["gag","everyday","relatable","small fix"],lettering:"friendly hand-lettered balloons"},{id:"editorial-cartoon",name:"Editorial cartoon",family:"newspaper",prompt:"newspaper editorial cartoon, scratchy pen-and-ink crosshatching, exaggerated original figures, words written on the objects that matter, single gray wash",palettes:["bw-accent"],moods:["commentary","irony","big picture","satire"],lettering:"hand-lettered words on objects in the scene, a short caption under the drawing"},{id:"magazine-cartoon",name:"Magazine gag cartoon",family:"newspaper",prompt:"sophisticated magazine gag cartoon, loose confident pen line, light gray wash, understated deadpan characters",palettes:["bw-accent"],moods:["dry wit","understatement","one-liner"],lettering:"a single typeset caption beneath the drawing, set in quotes when someone speaks"},{id:"webtoon",name:"Full-color webtoon",family:"webcomic",prompt:"full-color webtoon, clean digital lineart, soft gradient cel shading, glossy modern characters, big reaction close-ups, generous space between panels",palettes:["full-color"],moods:["drama","reaction","slow reveal","vertical"],lettering:"clean digital balloons, oversized reaction text"},{id:"saturday-cartoon",name:"90s Saturday-morning cartoon",family:"american",prompt:"1990s Saturday-morning TV cartoon look drawn as a comic, thick outlines, angular stylized characters, saturated flat colors, squash-and-stretch expressions",palettes:["full-color"],moods:["zany","chaos","slapstick","villain plan"],lettering:"chunky cartoon lettering in bold balloons, loud sound effects"},{id:"noir",name:"Noir graphic novel",family:"american",prompt:"noir graphic novel, heavy black ink shadows, venetian-blind light, rain, chiaroscuro, trench coats",palettes:["bw-accent","limited"],moods:["mystery","debugging","investigation","confession"],lettering:"typewriter caption boxes with hard-boiled narration, tight balloons"},{id:"pixel-16bit",name:"Pixel comic",family:"webcomic",prompt:"pixel-art comic, crisp 16-bit pixels, clear panel borders, chunky expressive sprites, video-game UI framing",palettes:["limited","full-color"],moods:["quest","level up","boss fight","retro"],lettering:"pixel-font RPG dialogue boxes"}],xT=[["mecha-anime","mecha anime style, detailed robots and cockpits, holographic HUD panels, cinematic lighting","HUD labels and readouts on screens, condensed sci-fi headline",["full-color","bw-accent"]],["rubber-hose","1930s rubber-hose cartoon, bendy limbs, pie-cut eyes, white gloves, sepia film grain, bouncy motion","vintage title card lettering, bouncy balloons",["limited","duotone"]],["storybook-watercolor","children's storybook watercolor illustration, soft washes, pencil linework, gentle light","handwritten storybook captions, whimsical headline",["full-color"]],["claymation","stop-motion claymation diorama, plasticine characters with fingerprints, miniature set, soft studio lighting","cut-paper signs and labels in the set, chunky headline",["full-color"]],["risograph","risograph-printed zine, two overprinted ink colors, grainy texture, slight misregistration, bold shapes","chunky grotesque type, stamped labels",["duotone"]],["pulp-scifi","1950s pulp science fiction magazine art, ray guns, rocket fins, painted gouache, dramatic sky","pulp magazine cover headline, starburst blurbs",["full-color","limited"]],["ukiyo-e","Japanese ukiyo-e woodblock print, flat color areas, carved outlines, stylized waves and clouds, washi paper texture","vertical cartouche labels, brush headline",["limited"]],["atomic-flat","mid-century modern illustration, atomic-age shapes, flat geometric characters, starbursts, cream background","retro display type, small caption labels",["limited","full-color"]],["blueprint","technical blueprint, white linework on cyan blueprint paper, callouts, dimension lines, exploded views","drafting stencil labels and callouts, title block headline",["duotone"]],["vaporwave","vaporwave aesthetic, neon pink and cyan, synthwave sun, chrome text, grid horizon, retro computer windows","chrome and neon headline, window-title labels",["full-color"]]].map(([Q,$,Z,X])=>({id:Q,name:Q,family:"custom",prompt:$,palettes:X,moods:[],lettering:Z})),X2=(Q)=>m6.find(($)=>$.id===Q)??xT.find(($)=>$.id===Q);function hW(Q=[],$){let Z=m6.filter((X)=>X.id!==$);return[...Z.filter((X)=>!Q.includes(X.id)),...Z.filter((X)=>Q.includes(X.id))]}function WX(Q){return X2(Q)?.prompt??Q.trim()}function BX(Q){return X2(Q)?.lettering??"hand-lettered comic text in speech balloons and caption boxes that suits the art, easy to read at phone size"}var gW=/\b(3d|cgi|render(ed)?|clay|claymation|plasticine|diorama|plush|toy|figurine|watercolou?r|gouache|oil paint|painted|picture[- ]book|storybook|photo(graph|real)?|stop[- ]motion|papercraft|paper[- ]cut)/i;function mW(Q,$){return gW.test(WX(Q))||gW.test($??"")}function uW(Q,$){switch(Q){case"bw-accent":return`black and white with a single accent color (${$??"red"}) used sparingly for emphasis`;case"duotone":return`two-color print (${$?`black and ${$}`:"two inks"})`;case"limited":return"limited palette of 3 to 4 colors";default:return"full color"}}import{createHash as iW}from"node:crypto";var HX=["ki","sho","ten","ketsu"],cW={ki:"setup",sho:"development",ten:"twist",ketsu:"resolution"},UX=["happy","excited","worried","surprised","determined","thinking","sleepy","proud","angry"],H8=["human","creature","object"],MX=["webcomic","american","manga","euro","newspaper","indie","custom"],wT=["ink","flat-color","painted","print","dimensional","pixel","technical"],u6=[...MX,...wT],U8=["single","comparison","sequence","vertical","asymmetric","hero-inset","diagonal","tiered","custom"],DX=["speech","thought","caption","sfx","sign","label"],NX=["4:3","1:1","16:9","3:4"],n4=["full-color","bw-accent","duotone","limited"];function Y2(Q){return Q.aspect??(Q.composition?.family==="vertical"?"3:4":Z2(Q.format)?.aspect??"4:3")}function a4(Q){let[$,Z]=Q.split(":").map(Number);return $/Z}function T5(Q){let $=Q.composition?.title?.mode==="none"?"":Q.headline??Q.title;return typeof $==="string"?$:""}function I5(Q){let $=Q.composition;if(!$)return;if($.frames)return{...$,frames:$.frames};let Z=Q.panels.length,X=$.title.mode==="heading"?0.14:0.025,Y=0.975-X,J=(V,G,W,B)=>({x:V,y:X+G*Y,w:W,h:B*Y}),z=0.025,K;switch($.family){case"single":K=[J(0.025,0,0.95,1)];break;case"comparison":case"sequence":{let V=(0.95-z*(Z-1))/Z;K=Array.from({length:Z},(G,W)=>J(0.025+W*(V+z),0,V,1));break}case"vertical":{let V=(1-z*(Z-1))/Z;K=Array.from({length:Z},(G,W)=>J(0.025,W*(V+z),0.95,V));break}case"asymmetric":{let V=Z-1,G=V<=2?V:2,W=Math.ceil(V/G),B=(0.95-z*(G-1))/G,H=(0.46-z*(W-1))/W;K=Array.from({length:V},(U,M)=>J(0.025+M%G*(B+z),Math.floor(M/G)*(H+z),B,H)),K.push(J(0.025,0.49,0.95,0.51));break}case"tiered":{let V=Z-1,G=(0.95-z*(V-1))/V;K=[J(0.025,0,0.95,0.44)];for(let W=0;W<V;W++)K.push(J(0.025+W*(G+z),0.47,G,0.53));break}case"hero-inset":{K=[{...J(0.025,0,0.95,1),textBox:{x:0.035,y:0.03,w:0.56,h:0.8}}];let V=(0.88-z*(Z-2))/(Z-1);for(let G=0;G<Z-1;G++)K.push(J(0.64,0.045+G*(V+z),0.305,V));break}case"diagonal":K=[{...J(0.025,0,0.95,1),clip:[[0,0],[0.98,0],[0,0.98]],textBox:{x:0.035,y:0.03,w:0.48,h:0.32}},{...J(0.025,0,0.95,1),clip:[[1,0.02],[1,1],[0.02,1]],textBox:{x:0.5,y:0.65,w:0.46,h:0.31}}];break;default:K=[]}return{...$,frames:K}}function i6(Q){let $=Q.composition?.title;if(!$||$.mode==="none")return;return $.box??($.mode==="heading"?{x:0.035,y:0.015,w:0.93,h:0.1}:{x:0.055,y:0.82,w:0.55,h:0.13})}function M8(Q,$){let Z=I5(Q)?.frames[$];if(!Z)return"1:1";let X=Z.w*a4(Y2(Q))/Z.h;return["1:1","4:3","16:9","3:4"].reduce((Y,J)=>Math.abs(Math.log(a4(Y)/X))<Math.abs(Math.log(a4(J)/X))?Y:J)}var c6=(Q)=>`${Math.round(Q*1000)/10}%`;function nW(Q){let $=I5(Q);if(!$)return"";return[`Composition: ${$.family}; exactly ${$.frames.length} scene(s), read left-to-right then top-to-bottom in the numbered story order. Preserve the specified hierarchy, unequal sizes and negative space.`,...$.frames.map((Z,X)=>`Frame ${X+1}: left ${c6(Z.x)}, top ${c6(Z.y)}, width ${c6(Z.w)}, height ${c6(Z.h)}; ${Z.clip?`polygon clipping points ${JSON.stringify(Z.clip)}`:"rectangular"}; ${Z.border==="none"?"borderless":"visible frame border"}.`),$.title.mode==="none"?"No visible title or headline. Start with the art; do not reserve a title banner.":`Title treatment: ${$.title.mode}; place "${T5(Q)}" inside this page area ${JSON.stringify(i6(Q))}. ${$.title.mode==="integrated"?"Integrate it into the scene; no separate top banner.":"Keep it inside that heading area, sized to the composition."}`].join(`
|
|
332
332
|
`)}function o4(Q,$){let{designReason:Z,anchor:X,altText:Y,synopsis:J,...z}=Q,K=z.panels.map(({drawn:V,...G})=>G);return iW("sha256").update(JSON.stringify({art:{...z,panels:K},lettering:$})).digest("hex")}function D8(Q,$,Z){if(!Q)return!1;if(Q===o4($,Z))return!0;let{designReason:X,anchor:Y,...J}=$;return Q===iW("sha256").update(JSON.stringify({art:J,lettering:Z})).digest("hex")}var bT=[["flat-color",["mecha-anime","rubber-hose","atomic-flat","vaporwave"]],["painted",["storybook-watercolor","pulp-scifi"]],["print",["risograph","ukiyo-e"]],["dimensional",["claymation"]],["technical",["blueprint"]]];function lW(Q){return m6.find(($)=>$.id===Q)?.family??bT.find(([,$])=>$.includes(Q))?.[0]}function s4(Q){let $=Array.isArray(Q.characters)&&Q.characters.every((Z)=>Z.kind);return{style:Q.style,...Q.styleFamily||lW(Q.style)?{styleFamily:Q.styleFamily??lW(Q.style)}:{},...Q.composition?{layoutFamily:Q.composition.family,titleTreatment:Q.composition.title.mode}:{},panelCount:Q.panels.length,...$?{castKinds:[...new Set(Q.characters.map((Z)=>Z.kind))].sort()}:{}}}var aW=(Q,$,Z)=>($[0]-Q[0])*(Z[1]-$[1])-($[1]-Q[1])*(Z[0]-$[0]);function qX(Q,$){let Z=$.map((X,Y)=>aW(X,$[(Y+1)%$.length],Q)).filter((X)=>Math.abs(X)>0.00000001);return Z.every((X)=>X>=0)||Z.every((X)=>X<=0)}function l6(Q){return(Q.clip??[[0,0],[1,0],[1,1],[0,1]]).map(([$,Z])=>[Q.x+$*Q.w,Q.y+Z*Q.h])}function dW(Q,$){for(let Z of[Q,$])for(let X=0;X<Z.length;X++){let Y=Z[X],J=Z[(X+1)%Z.length],z=[J[1]-Y[1],Y[0]-J[0]],K=Q.map(([G,W])=>G*z[0]+W*z[1]),V=$.map(([G,W])=>G*z[0]+W*z[1]);if(Math.min(...K)>=Math.max(...V)-0.00000001||Math.min(...V)>=Math.max(...K)-0.00000001)return!1}return!0}function d6(Q){let $=Q;return!!$&&[$.x,$.y,$.w,$.h].every((Z)=>typeof Z==="number"&&Number.isFinite(Z))&&$.x>=0&&$.y>=0&&$.w>0&&$.h>0&&$.x+$.w<=1.00000001&&$.y+$.h<=1.00000001}function CX(Q){let $=Q.composition;if(!$)return[];let Z=[],X=(V,G)=>Z.push({where:`composition.${V}`,problem:G});if(!U8.includes($.family))X("family",`must be ${U8.join(", ")}`);if(!$.title||!["none","integrated","heading"].includes($.title.mode))X("title.mode","must be none, integrated or heading");if($.title?.box!==void 0&&!d6($.title.box))X("title.box","must be positive bounds within the 0\u20131 page");let J={single:[1,1],comparison:[2,3],asymmetric:[3,6],"hero-inset":[2,6],diagonal:[2,2],tiered:[3,5]}[$.family];if(J&&(Q.panels.length<J[0]||Q.panels.length>J[1]))X("family",`${$.family} needs ${J[0]}\u2013${J[1]} panels; choose another family or explicit custom geometry`);if($.family==="custom"&&!Array.isArray($.frames))X("frames","custom composition requires explicit frames");if($.frames!==void 0&&(!Array.isArray($.frames)||$.frames.length!==Q.panels.length))X("frames","must contain one frame per story panel, in reading order");if(Z.length)return Z;let z=I5(Q);if(z.frames.forEach((V,G)=>{let W=`frames[${G}]`;if(!d6(V)){X(W,"must be positive bounds within the 0\u20131 page");return}if(V.border!==void 0&&!["line","none"].includes(V.border))X(`${W}.border`,"must be line or none");if(V.inset!==void 0&&typeof V.inset!=="boolean")X(`${W}.inset`,"must be boolean");if(V.textBox!==void 0&&!d6(V.textBox))X(`${W}.textBox`,"must be positive bounds within the 0\u20131 frame");if(V.clip!==void 0){if(!Array.isArray(V.clip)||V.clip.length<3||V.clip.length>8||V.clip.some((H)=>!Array.isArray(H)||H.length!==2||H.some((U)=>!Number.isFinite(U)||U<0||U>1))){X(`${W}.clip`,"use 3\u20138 polygon points in the frame\u2019s 0\u20131 space");return}let B=V.clip.map((H,U)=>aW(H,V.clip[(U+1)%V.clip.length],V.clip[(U+2)%V.clip.length]));if(B.every((H)=>Math.abs(H)<0.00000001)||!(B.every((H)=>H>=-0.00000001)||B.every((H)=>H<=0.00000001))||!V.clip.every((H)=>qX(H,V.clip)))X(`${W}.clip`,"must be a nonzero convex polygon, with points around its edge");if(Q.panels[G]?.dialogue?.length&&!V.textBox)X(`${W}.textBox`,"polygon panels with dialogue require a safe lettering box");if(V.textBox&&d6(V.textBox)&&l6(V.textBox).some((H)=>!qX(H,V.clip)))X(`${W}.textBox`,"must fit entirely inside the clipping polygon")}}),Z.length)return Z;let K=$.title.mode==="heading"?l6(i6(Q)):void 0;return z.frames.forEach((V,G)=>{let W=l6(V);if(K&&dW(W,K))X(`frames[${G}]`,"overlaps the separate heading; move it or use integrated title treatment");for(let B=0;B<G;B++){let H=l6(z.frames[B]);if(!dW(W,H))continue;if(!(($.family==="hero-inset"||V.inset)&&W.every((M)=>qX(M,H))))X(`frames[${G}]`,`overlaps frame ${B+1}; deliberate insets must be contained and marked inset: true`)}}),Z}var pW=360;function vT(Q){let $=I5(Q);if($)return $.frames;let Z=Q.format==="strip"||Q.format==="before-after"?"sequence":void 0;if(!Z)return;return I5({...Q,composition:{family:Z,title:{mode:"heading"}}})?.frames}function p6(Q){let $=vT(Q);if(!$)return[];let Z=pW/a4(Y2(Q));return $.map((X,Y)=>{let J=Math.round(X.w*pW),z=X.h*Z,K=Math.max(1,Math.floor(J*0.85/6.2)),V=Math.max(1,Math.floor(z*0.5/15)),G=Math.round((Q.panels[Y]?.dialogue??[]).reduce((H,U)=>H+U.text.length*(U.kind==="sign"||U.kind==="label"?1.5:1),0)),W=K*V,B=G<=W&&!(J<120&&G>0);return{panel:Y+1,widthPx:J,chars:G,capacity:W,fits:B}})}function r4(Q){let $=p6(Q);if(!$.length||$.every((J)=>J.fits))return;let X=Q.panels.length>=4?["asymmetric","vertical"]:["vertical","asymmetric"],Y;for(let J of X){if(J===Q.composition?.family)continue;let z={...Q,composition:{family:J,title:{mode:Q.composition?.title.mode??"heading"}},aspect:J==="vertical"?"3:4":"4:3"};if(delete z.layout,CX(z).length)continue;if(Y??=z,p6(z).every((K)=>K.fits))return z}return Y}var V5=["codex","antigravity","openai","gemini"],oW={"4:3":"1536x1024","16:9":"1536x1024","1:1":"1024x1024","3:4":"1024x1536"},uT="fictional characters only (human characters are welcome); original character designs that do not resemble existing cartoon, film or game characters; no identifiable real-person or celebrity likenesses, no logos or brand marks, no watermarks, no signatures",cT="no identifiable real-person or celebrity likenesses, no logos or brand marks, no watermarks, no signatures",lT="It must look like a drawn comic: inked line art with flat or cel coloring, real panel borders and gutters, lettering in balloons and caption boxes. Not a 3D render, CGI, clay, plastic toy, plush or diorama, and not a soft children's picture-book painting.";function $B(Q){return Q.request?.trim()?cT:uT}function ZB(Q){return Q.request?.trim()?`The user asked for this; honor it exactly: ${Q.request.trim()}.`:""}function dT(Q,$){let Z=Q.characters?.find((X)=>X.name.toLowerCase()===$.toLowerCase());return Z?`${Z.name}: ${Z.description}`:$}function pT(Q,$){return Q.characters.map((Z)=>`${dT($,Z.name)}, on the ${Z.position}${Z.expression?`, looking ${Z.expression}`:""}${Z.pose?`, ${Z.pose}`:""}`).join("; ")}function XB(Q){let $=Q.palette??X2(Q.style)?.palettes[0];return`${WX(Q.style)}${$?`; ${uW($,Q.accent)}`:""}`}function a6(Q,$,Z){let X=pT(Q,Z),Y=Z.panels.length,J=I5(Z)?.frames[$];return[`${XB(Z)}.`,Q.beat?`Panel ${$+1} of ${Y} (${cW[Q.beat]}) of a comic.`:`Panel ${$+1} of ${Y} of a comic.`,`Scene: ${Q.scene}.`,X?`Characters: ${X}.`:"",Q.camera?`Camera: ${Q.camera} shot.`:"",Q.artPrompt?`${Q.artPrompt}.`:"",Z.composition?`A ${YB[M8(Z,$)]} panel image. Keep this normalized area plain for later lettering: ${JSON.stringify(J?.textBox??{x:0,y:0,w:1,h:0.4})}. Compose the subject outside it. No text, no letters.`:"Square image. Keep the top third as plain, uncluttered background so speech bubbles can be added later. No text, no letters.","If a reference image is given, keep every character and the art style consistent with it.",ZB(Z),`Strictly: ${$B(Z)}.`].filter(Boolean).join(" ")}var YB={"4:3":"landscape 4:3","16:9":"wide landscape 16:9","1:1":"square","3:4":"portrait 3:4"};function iT(Q){let $=`"${Q.text}"`;switch(Q.kind){case"thought":return`${Q.speaker} thinks (thought bubble): ${$}`;case"caption":return`caption box: ${$}`;case"sfx":return`big sound-effect lettering: ${$}`;case"sign":case"label":return`written on ${Q.points?.trim()||"a screen, sign or object in the scene"} as a natural part of the scene (no callout tag, no pointer line): ${$}`;default:return Q.speaker==="caption"?`caption box: ${$}`:`${Q.speaker} says (speech balloon): ${$}`}}function o6(Q){let $=Z2(Q.format),Z=Y2(Q),X=T5(Q),Y=(Q.characters??[]).map((z)=>`${z.name}: ${z.description}`),J=Q.panels.map((z,K)=>{let V=z.characters.map((W)=>`${W.name} on the ${W.position}${W.expression?`, looking ${W.expression}`:""}${W.pose?`, ${W.pose}`:""}`),G=(z.dialogue??[]).map(iT);return[`Panel ${K+1}: ${z.scene}.`,V.length?`Characters: ${V.join("; ")}.`:"",z.camera?`${z.camera} shot.`:"",z.artPrompt?`${z.artPrompt}.`:"",G.length?`Text: ${G.join("; ")}.`:"No text in this panel."].filter(Boolean).join(" ")});return[`A finished comic page, ${YB[Z]} image.`,`Art style: ${XB(Q)}.`,ZB(Q),mW(Q.style,Q.request)?"":lT,!Q.composition&&$&&$.id!=="custom"?`Format: ${$.name}. ${$.layout}.`:"",Q.layout?`Layout: ${Q.layout}.`:"",nW(Q),Y.length?`Characters (draw each one the same way in every panel): ${Y.join("; ")}.`:"",!Q.composition?`Headline, lettered big and bold as part of the design: "${X}".`:"",`${Q.panels.length===1?"The scene":`The ${Q.panels.length} panels, in reading order`}:`,...J,`Lettering: ${Q.composition?BX(Q.style).split(",").filter((z)=>!/headline|title/i.test(z)).join(",")||"clear comic lettering suited to this art":BX(Q.style)}. Letter every quoted text exactly as written, spelled correctly. It must stay readable when the whole page is shown only 360 pixels wide on a phone: balloon and caption letters at least 1/30 of the page width tall, signs and labels in the scene just as large (draw the object bigger rather than the words smaller), short lines, no tiny print anywhere. Words on screens, signs and objects are part of the drawing, never floating tags or arrows. No words other than the quoted text above: no invented labels, no signatures, no watermarks, no made-up text.`,`Strictly: ${$B(Q)}.`].filter(Boolean).join(`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "tracetoon.build-output/v1",
|
|
3
|
-
"buildId": "
|
|
3
|
+
"buildId": "060da6295acdf20495efada145899bce6c74a6c045f797b4544abc4b0596a645",
|
|
4
4
|
"target": "node-esm",
|
|
5
|
-
"inputManifestSha256": "
|
|
6
|
-
"sha256": "
|
|
5
|
+
"inputManifestSha256": "ac9e74077e27ba4ae0ef49c59f959969bb8165f4a51090b2cb0dce070f8014dc",
|
|
6
|
+
"sha256": "b4bd6da06066d429f51ba9911f4207c5c132f29b1ce30cbb7aaae957011a911c",
|
|
7
7
|
"compiler": {
|
|
8
8
|
"version": "1.3.14",
|
|
9
9
|
"sha256": "9fd36f87e4b90b07632b987a2e4ec81ca15a62c81bf983190cea6d715be2ad74",
|