module.exports=[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])},818992,a=>{"use strict";var b=a.i(233405),c=a.i(522734),d=a.i(761469),e=a.i(897667);function f(a,c){return(0,b.execFileSync)("git",a,{cwd:c,timeout:1e4,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}function g(a){for(let b of["main","master","develop"])try{return f(["merge-base","HEAD",b],a)}catch{}return null}function h(a){if(!a)return null;let b=a.split("\n").filter(Boolean);if(0===b.length)return null;let c=b[0].replace(/^[a-f0-9]+\s+/,"");return 1===b.length?c:`${b.length} commits: ${c}`}async function i(a,b,i,j,k){try{let b;console.error(`[captureExecutionSummary] Starting: exec=${a.slice(0,8)} exit=${i} buffer=${j.length}chars worktree=${k}`);let l=null,m=null,n=null;if(k&&(0,c.existsSync)(k))try{if(f(["rev-parse","--git-dir"],k),l=function(a){try{let b=g(a);if(b){let c=f(["log","--oneline",`${b}..HEAD`],a);if(c)return c}return f(["log","--oneline","-3"],a)||null}catch{return null}}(k),(m=function(a){try{let b,c=g(a);if(!(b=c?f(["diff","--stat",`${c}..HEAD`],a):f(["diff","--stat","HEAD~20","HEAD"],a)))return null;return function(a){let b=a.split("\n"),c=b[b.length-1];if(!c)return null;let d=c.match(/(\d+)\s+files?\s+changed/),e=c.match(/(\d+)\s+insertions?\(\+\)/),f=c.match(/(\d+)\s+deletions?\(-\)/);return d||e||f?{commits:0,filesChanged:d?parseInt(d[1],10):0,insertions:e?parseInt(e[1],10):0,deletions:f?parseInt(f[1],10):0}:null}(b)}catch{return null}}(k))&&l){let a=l.split("\n").filter(Boolean).length;m={...m,commits:a}}n=h(l)}catch{}let o=(b=j.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/\x1b[^[\]()][^\x1b]*/g,"").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,"").replace(/\n{3,}/g,"\n\n").trim()).length<=10240?b:b.slice(b.length-10240);await d.db.taskExecution.update({where:{id:a},data:{summary:n??(l?h(l):null),gitLog:l??null,gitStats:m?JSON.stringify(m):null,exitCode:i,terminalLog:o||null}}),o&&k&&(console.error("[captureExecutionSummary] Starting background AI summary..."),(0,e.generateSummaryFromLog)(o,k).then(async b=>{b&&(console.error(`[captureExecutionSummary] AI summary ready: ${b.slice(0,80)}`),await d.db.taskExecution.update({where:{id:a},data:{summary:b}}))}).catch(a=>{console.error("[captureExecutionSummary] Background AI summary failed:",a)}))}catch(a){console.error("[captureExecutionSummary] Failed to capture summary:",a)}}async function j(a){try{let b=await d.db.task.findUnique({where:{id:a},select:{projectId:!0,executions:{orderBy:{createdAt:"desc"},select:{id:!0,terminalLog:!0,worktreePath:!0,summary:!0}}}});if(!b||0===b.executions.length)return;let c="",f=null,g=[];for(let a of b.executions)a.terminalLog&&(c+=a.terminalLog+"\n---\n"),a.summary&&g.push(a.summary),!f&&a.worktreePath&&(f=a.worktreePath);if(!(c=c.slice(-8e3)).trim())return;let h=g.join("\n"),i=f||process.cwd();console.error(`[captureTaskDreaming] Starting for task=${a.slice(0,8)}, ${b.executions.length} executions`);let j=await (0,e.generateDreamingInsight)(c,i,h);if(!j||!j.shouldCreateNote)return void console.error("[captureTaskDreaming] No note needed");let k=await d.db.projectNote.create({data:{title:j.noteTitle||j.summary.slice(0,50),content:function(a){let b=[];if(b.push("## Summary"),b.push(a.summary),b.push(""),a.insights.length>0)for(let c of(b.push("## Insights"),a.insights))b.push(`- **[${c.type}]**: ${c.content}`);return b.join("\n")}(j),category:"session-insight",projectId:b.projectId,taskId:a}}),l=b.executions[0].id;await d.db.taskExecution.update({where:{id:l},data:{insightNoteId:k.id}}),console.error(`[captureTaskDreaming] Note created: ${k.id}`)}catch(a){console.error("[captureTaskDreaming] Failed:",a)}}a.s(["captureExecutionSummary",0,i,"captureTaskDreaming",0,j])},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=_0qkxdkn._.js.map