module.exports=[103071,a=>{"use strict";a.s(["SESSION_INSIGHT_CATEGORY",0,"经验洞见","TASK_OVERVIEW_CATEGORY",0,"任务笔记","TOWER_LABEL_COLOR",0,"#8b5cf6","TOWER_LABEL_NAME",0,"Tower"])},897667,a=>{"use strict";let b=new(a.i(52350)).ClaudeCliAdapter;async function c(d,e,f={}){let g="";try{let{query:c}=await a.A(719041),h=b.resolveCommand();for await(let a of c({prompt:d,options:{tools:f.tools??[],allowedTools:f.allowedTools??[],maxTurns:f.maxTurns??1,cwd:e,pathToClaudeCodeExecutable:h,sessionPersistence:!1}}))if("assistant"===a.type){let b=a.message.content.filter(a=>"text"===a.type);g+=b.map(a=>a.text??"").join("")}else if("result"===a.type){let b="string"==typeof a.result?a.result:"";b&&!g&&(g=b)}return g.trim()||null}catch(a){if(a.message?.includes("maximum number of turns")&&g.trim())return g.trim();return console.error("[aiQuery] Failed:",a.message,a.stack?.slice(0,300)),null}}async function d(a,b){let d=`以下是一次AI编程助手的终端会话记录。请用一句简短的中文总结这次会话做了什么（不超过50字，只回答总结内容，不要加引号或前缀）：

\`\`\`
${a.slice(-5e3)}
\`\`\``,e=await c(d,b);return e&&e.replace(/^[#*\->"'\s]+/,"").trim()||null}async function e(a,b,d){let e=a.slice(-8e3),f=d?`
Session summary: ${d}`:"",g=`You are analyzing a completed AI coding session. Extract reusable insights.
${f}

Terminal log (last 8000 chars):
\`\`\`
${e}
\`\`\`

Respond ONLY with valid JSON matching this schema (no markdown, no explanation):
{
  "summary": "one-sentence summary of what was accomplished",
  "insights": [
    { "type": "pattern|pitfall|decision|tool|reference", "content": "description" }
  ],
  "shouldCreateNote": true/false,
  "noteTitle": "short title for the note (only if shouldCreateNote is true)"
}

Rules:
- Set shouldCreateNote=true ONLY if there are genuinely reusable insights (architectural decisions, non-obvious pitfalls, useful patterns, important tool discoveries)
- Trivial sessions (simple formatting, single-line edits, routine commits) should have shouldCreateNote=false
- insights array can be empty if nothing notable
- Keep each insight concise (1-2 sentences)`,h=await c(g,b);if(!h)return null;try{let a=h,b=a.match(/\{[\s\S]*\}/);b&&(a=b[0]);let c=JSON.parse(a);if("string"!=typeof c.summary||"boolean"!=typeof c.shouldCreateNote)return console.error("[generateDreamingInsight] Invalid response structure"),null;return c}catch(a){return console.error("[generateDreamingInsight] JSON parse failed:",a.message),null}}a.s(["aiQuery",0,c,"generateDreamingInsight",0,e,"generateSummaryFromLog",0,d])},941750,a=>{"use strict";var b=a.i(233405),c=a.i(522734),d=a.i(761469),e=a.i(835032),f=a.i(897667);async function g(a){let e=await d.db.task.findUnique({where:{id:a},include:{project:!0}});if(!e)return{kind:"error",status:404,message:"Task not found"};if(!e.project?.localPath)return{kind:"error",status:400,message:"Project has no local path"};let f=e.baseBranch||"main",g=e.project.localPath,h=await d.db.taskExecution.findFirst({where:{taskId:a},orderBy:{createdAt:"desc"}});if(!h)return{kind:"empty"};let{forkCommit:i,mergeCommit:j,branchTipCommit:k,worktreeBranch:l,worktreePath:m}=h;if(j&&i){let a=k||j;return{kind:"ok",data:{diffCwd:g,diffTarget:`${i}..${a}`,baseRef:i,endRef:a,worktreePath:null}}}if(i&&m&&(0,c.existsSync)(m))return{kind:"ok",data:{diffCwd:m,diffTarget:i,baseRef:i,endRef:null,worktreePath:m}};if(i&&!m)return{kind:"ok",data:{diffCwd:g,diffTarget:i,baseRef:i,endRef:null,worktreePath:null}};if(l)try{let a=(0,b.execFileSync)("git",["merge-base",f,l],{cwd:g,encoding:"utf-8",timeout:5e3}).trim(),d=m&&(0,c.existsSync)(m)?m:g;return{kind:"ok",data:{diffCwd:d,diffTarget:a,baseRef:a,endRef:null,worktreePath:m&&(0,c.existsSync)(m)?m:null}}}catch{return{kind:"branch-deleted"}}return{kind:"empty"}}var h=a.i(103071);function i(a,c,d=1048576){try{return(0,b.execFileSync)("git",a,{cwd:c,encoding:"utf-8",timeout:3e4,maxBuffer:d,stdio:["pipe","pipe","pipe"]}).trim()}catch{return null}}async function j(a){let b=await d.db.task.findUnique({where:{id:a},include:{project:!0}});if(!b||!b.project)return null;let e=b.project.localPath??null,f=[],h=null,j=0,k=null,l=e||process.cwd();if(e){let b=await g(a);if("ok"===b.kind){let{diffCwd:a,diffTarget:c}=b.data;l=a;let d=c.includes("..")?c:`${c}..HEAD`,e=i(["diff","--numstat",c],a,0x4000000);e&&(f=function(a){let b=[];for(let c of a.split("\n")){let a=c.trim();if(!a)continue;let d=a.split("	");if(d.length<3)continue;let[e,f,...g]=d,h=g.join("	");"-"===e&&"-"===f?b.push({filename:h,added:0,removed:0,isBinary:!0}):b.push({filename:h,added:parseInt(e,10)||0,removed:parseInt(f,10)||0,isBinary:!1})}let c=/^diff --git a\/(.+) b\/(.+)$/,d=new Map;if("".trim())for(let a of"".split(/(?=^diff --git )/m)){if(!a.trim())continue;let b=a.split("\n")[0],e=c.exec(b);if(!e)continue;let f=e[2],g=a;0;d.set(f,g)}let e=b.map(a=>({filename:a.filename,added:a.added,removed:a.removed,isBinary:a.isBinary,patch:d.get(a.filename)??""})),f=e.reduce((a,b)=>a+b.added,0),g=e.reduce((a,b)=>a+b.removed,0);return{files:e,totalAdded:f,totalRemoved:g}}(e).files),h=i(["log","--oneline",d],a)||null;let g=i(["rev-list","--count",d],a);j=g&&parseInt(g,10)||0;let m=i(["diff",c],a,0x4000000);m&&(k=m.length>12288?m.slice(0,12288)+"\n...(diff truncated)":m)}}if(0===f.length&&0===j){let b=await d.db.taskExecution.findFirst({where:{taskId:a},orderBy:{createdAt:"desc"},select:{gitLog:!0,worktreePath:!0}});b?.gitLog&&(h=b.gitLog,j=b.gitLog.split("\n").filter(Boolean).length),b?.worktreePath&&(0,c.existsSync)(b.worktreePath)&&(l=b.worktreePath)}if(0===f.length&&0===j)return null;let m=(await d.db.projectAsset.findMany({where:{taskId:a},orderBy:{createdAt:"asc"},select:{filename:!0,description:!0}})).map(a=>({filename:a.filename,description:a.description}));return{taskId:a,taskTitle:b.title,projectId:b.projectId,projectName:b.project.name,files:f,commitLog:h,commitCount:j,diffText:k,assets:m,cwd:l}}async function k(a){let b=a.files.slice(0,60).map(a=>a.isBinary?`${a.filename} (binary)`:`${a.filename} (+${a.added}/-${a.removed})`).join("\n")||"（无文件清单）",d=`你是资深工程师。下面是一个刚完成的开发任务的代码改动信息，请用简洁中文写一段「改动摘要」：说明这次改动做了什么、解决了什么问题、主要涉及哪些模块或逻辑。要求 3-6 句、纯文本，不要 markdown 标题，不要逐条罗列文件（文件清单会另外展示）。

任务标题：${a.taskTitle}

提交记录：
${a.commitLog??"（无提交记录）"}

变更文件（共 ${a.files.length} 个）：
${b}

diff（可能已截断）：
\`\`\`diff
${a.diffText??"（无 diff）"}
\`\`\``,e=(0,c.existsSync)(a.cwd)?a.cwd:process.cwd(),g=await (0,f.aiQuery)(d,e,{maxTurns:1});if(g){let a=g.replace(/^[#*\->"'\s]+/,"").trim();if(a)return a}var h=a.commitLog;if(!h)return null;let i=h.split("\n").filter(Boolean);if(0===i.length)return null;let j=i[0].replace(/^[a-f0-9]+\s+/,"");return 1===i.length?j:`${i.length} 个提交：${j}`}async function l(a,b={}){let c=b.kind??"done",f=null;try{f=await j(a)}catch(a){console.error("[captureTaskOverview] Failed to gather change data:",a);return}if(!f)return void console.error(`[captureTaskOverview] No changes for task=${a.slice(0,8)} — skip`);let g=f;(async()=>{try{let b=await k(g),f=new Date().toISOString(),i=function(a,b,c,d="done"){let e=[];if(e.push("cancelled"===d?"> 本笔记由任务取消时自动生成，记录已产生的改动，作为下次重启该任务的参考经验。":"> 本笔记由任务完成时自动生成，记录本次任务的改动概览，便于后续复盘与排查。"),e.push(""),e.push("## 改动摘要"),e.push(b??"（未能生成改动摘要）"),e.push(""),e.push("## 文件清单"),a.files.length>0){let b=a.files.slice(0,100);for(let a of b)e.push(a.isBinary?`- \`${a.filename}\`（二进制）`:`- \`${a.filename}\` (+${a.added} / -${a.removed})`);a.files.length>b.length&&e.push(`- …其余 ${a.files.length-b.length} 个文件`),e.push(""),e.push(`共 ${a.files.length} 个文件、${a.commitCount} 个提交。`)}else e.push(`（未能获取精确文件清单，本次约 ${a.commitCount} 个提交。）`);if(e.push(""),e.push("## 相关附件与参考资料"),a.assets.length>0)for(let b of a.assets)e.push(b.description?`- ${b.filename} — ${b.description}`:`- ${b.filename}`);else e.push("（无）");return e.push(""),e.push("---"),e.push(`> 关联任务：${a.taskTitle} (\`${a.taskId}\`)`),e.push(`> 项目：${a.projectName}`),e.push(`> 生成时间：${c}`),e.join("\n")}(g,b,f,c),j=function(a,b="done"){return`${"cancelled"===b?"任务概览（已取消）：":"任务概览："}${a}`.slice(0,200)}(g.taskTitle,c),l=await d.db.projectNote.create({data:{title:j,content:i,category:h.TASK_OVERVIEW_CATEGORY,projectId:g.projectId,taskId:g.taskId}});await (0,e.syncNoteToFts)(d.db,{id:l.id,title:l.title,content:l.content}),console.error(`[captureTaskOverview] Note created: ${l.id} for task=${a.slice(0,8)}`)}catch(a){console.error("[captureTaskOverview] Failed to create overview note:",a)}})()}a.s(["captureTaskOverview",0,l],941750)},719041,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[externals]__0ti8vng._.js","server/chunks/ssr/07-d_@anthropic-ai_claude-agent-sdk_sdk_mjs_0myippv._.js"].map(b=>a.l(b))).then(()=>b(845454)))}];

//# sourceMappingURL=_0l3l_d6._.js.map