module.exports=[287068,a=>{"use strict";var b=a.i(761469);function c(a,b){return{id:a.note_id,type:"note",title:a.title,subtitle:`${a.workspace_name} / ${a.project_name}`,navigateTo:`/workspaces/${a.workspaceId}/notes?projectId=${a.projectId}`,snippet:a.content?a.content.slice(0,b):void 0}}async function d(a,e="task",f){if(!a.trim())return[];let g=a.trim(),{resultLimit:h,allModeCap:i,snippetLength:j}=f;if("all"===e){let[a,b,c,e,h]=await Promise.allSettled([d(g,"task",f),d(g,"project",f),d(g,"repository",f),d(g,"note",f),d(g,"asset",f)]),j=a=>"fulfilled"===a.status?a.value.slice(0,i):[];return[...j(a),...j(b),...j(c),...j(e),...j(h)]}if("task"===e)return(await b.db.task.findMany({where:{OR:[{title:{contains:g}},{description:{contains:g}}]},include:{project:{include:{workspace:!0}}},take:h,orderBy:{updatedAt:"desc"}})).map(a=>{let b="DONE"===a.status||"CANCELLED"===a.status,c=a.project.workspaceId;return{id:a.id,type:"task",title:a.title,subtitle:`${a.project.workspace.name} / ${a.project.name}`,navigateTo:b?`/workspaces/${c}/archive?projectId=${a.projectId}`:`/workspaces/${c}?projectId=${a.projectId}`}});if("project"===e)return(await b.db.project.findMany({where:{OR:[{name:{contains:g}},{alias:{contains:g}},{description:{contains:g}}]},include:{workspace:!0},take:h,orderBy:{updatedAt:"desc"}})).map(a=>({id:a.id,type:"project",title:a.alias?`${a.name} (${a.alias})`:a.name,subtitle:a.workspace.name,navigateTo:`/workspaces/${a.workspaceId}?projectId=${a.id}`}));if("repository"===e)return(await b.db.repository.findMany({where:{OR:[{name:{contains:g}},{path:{contains:g}}]},include:{project:{include:{workspace:!0}}},take:h})).map(a=>({id:a.id,type:"repository",title:a.name,subtitle:`${a.project.workspace.name} / ${a.project.name} \xb7 ${a.branch}`,navigateTo:`/workspaces/${a.project.workspaceId}?projectId=${a.projectId}`}));if("note"===e){if(g.length<3)return(await b.db.$queryRawUnsafe(`SELECT n.id as note_id, n.title, n.content,
                n."projectId", p."workspaceId", p.name as project_name, w.name as workspace_name
         FROM "ProjectNote" n
         JOIN "Project" p ON p.id = n."projectId"
         JOIN "Workspace" w ON w.id = p."workspaceId"
         WHERE n.title LIKE ? OR n.content LIKE ?
         LIMIT ?`,`%${g}%`,`%${g}%`,h)).map(a=>c(a,j));try{return(await b.db.$queryRawUnsafe(`SELECT f.note_id, f.title, f.content,
                n."projectId", p."workspaceId", p.name as project_name, w.name as workspace_name
         FROM notes_fts f
         JOIN "ProjectNote" n ON n.id = f.note_id
         JOIN "Project" p ON p.id = n."projectId"
         JOIN "Workspace" w ON w.id = p."workspaceId"
         WHERE f.notes_fts MATCH ?
         ORDER BY rank
         LIMIT ?`,g,h)).map(a=>c(a,j))}catch{return(await b.db.$queryRawUnsafe(`SELECT n.id as note_id, n.title, n.content,
                n."projectId", p."workspaceId", p.name as project_name, w.name as workspace_name
         FROM "ProjectNote" n
         JOIN "Project" p ON p.id = n."projectId"
         JOIN "Workspace" w ON w.id = p."workspaceId"
         WHERE n.title LIKE ? OR n.content LIKE ?
         LIMIT ?`,`%${g}%`,`%${g}%`,h)).map(a=>c(a,j))}}return"asset"===e?(await b.db.projectAsset.findMany({where:{OR:[{filename:{contains:g}},{description:{contains:g}}]},include:{project:{include:{workspace:!0}}},take:h,orderBy:{createdAt:"desc"}})).map(a=>({id:a.id,type:"asset",title:a.filename,subtitle:`${a.project.workspace.name} / ${a.project.name}`,navigateTo:`/workspaces/${a.project.workspaceId}/assets?projectId=${a.projectId}`,snippet:a.description||void 0})):[]}a.s(["search",0,d])},396904,a=>a.a(async(b,c)=>{try{var d=a.i(815429),e=a.i(287068),f=a.i(980999),g=a.i(630048),h=b([f]);async function i(a,b="task"){let c=await (0,f.getConfigValues)(["search.resultLimit","search.allModeCap","search.snippetLength"]);return(0,e.search)(a,b,{resultLimit:c["search.resultLimit"]??20,allModeCap:c["search.allModeCap"]??5,snippetLength:c["search.snippetLength"]??80})}[f]=h.then?(await h)():h,(0,g.ensureServerEntryExports)([i]),(0,d.registerServerReference)(i,"605c2fc35fe8ffc8c86eea4b9b750a9ac5c7b745f6",null),a.s(["globalSearch",0,i]),c()}catch(a){c(a)}},!1),101844,a=>{"use strict";var b=a.i(815429),c=a.i(924868),d=a.i(522734),e=a.i(814747),f=a.i(761469),g=a.i(188139),h=a.i(630048);async function i(b){if(!b||"string"!=typeof b)return{safe:!1,reason:"无效的项目 ID"};let g=await f.db.project.findUnique({where:{id:b}});if(!g||!g.localPath)return{safe:!1,reason:"项目不存在或未设置本地路径"};if((await f.db.taskExecution.findMany({where:{task:{projectId:b},status:"RUNNING"},select:{id:!0}})).length>0)return{safe:!1,reason:"该项目有正在运行的任务执行，请先停止所有执行"};let h=await f.db.task.findMany({where:{projectId:b},select:{id:!0}}),{getSession:i}=await a.A(98813);for(let a of h)if(void 0!==i(a.id))return{safe:!1,reason:"该项目有活跃的终端会话，请先关闭"};let j=e.default.join(g.localPath,".worktrees");if((0,d.existsSync)(j))try{if((await (0,c.readdir)(j)).length>0)return{safe:!1,reason:"该项目有活跃的 Git Worktree，请先清理"}}catch{}return{safe:!0}}async function j(b,h){if(!b||"string"!=typeof b)return{success:!1,error:"无效的项目 ID"};if(!h||"string"!=typeof h||!e.default.isAbsolute(h))return{success:!1,error:"目标路径必须是非空的绝对路径"};let i=await f.db.project.findUnique({where:{id:b}});if(!i||!i.localPath)return{success:!1,error:"项目不存在或未设置本地路径"};let j=i.localPath;if(h===j)return{success:!1,error:"源路径和目标路径相同"};if((await f.db.taskExecution.findMany({where:{task:{projectId:b},status:"RUNNING"},select:{id:!0}})).length>0)return{success:!1,error:"该项目有正在运行的任务执行，请先停止所有执行"};let k=await f.db.task.findMany({where:{projectId:b},select:{id:!0}}),{getSession:l}=await a.A(98813);for(let a of k)if(void 0!==l(a.id))return{success:!1,error:"该项目有活跃的终端会话，请先关闭"};let m=e.default.join(j,".worktrees");if((0,d.existsSync)(m))try{if((await (0,c.readdir)(m)).length>0)return{success:!1,error:"该项目有活跃的 Git Worktree，请先清理"}}catch{}if((0,d.existsSync)(h))try{if((await (0,c.readdir)(h)).length>0)return{success:!1,error:"目标路径已存在且不为空"}}catch{return{success:!1,error:"目标路径已存在且不为空"}}let n=e.default.dirname(h);try{await (0,c.mkdir)(n,{recursive:!0})}catch(a){if("EACCES"===a.code||"EPERM"===a.code)return{success:!1,error:`无权限创建父目录 ${n} — 请检查 Git 路径映射规则的模板是否漏了 "~/" 前缀`};if("EROFS"===a.code)return{success:!1,error:`父目录所在文件系统只读：${n}`};return{success:!1,error:`创建父目录失败：${a.message||a.code||"未知错误"}`}}try{await (0,c.rename)(j,h)}catch(a){if("EXDEV"===a.code)return{success:!1,error:"源路径和目标路径不在同一文件系统，不支持跨设备迁移"};if("EACCES"===a.code||"EPERM"===a.code)return{success:!1,error:`无权限移动到 ${h}`};return{success:!1,error:a.message||"文件系统操作失败"}}return await f.db.project.update({where:{id:b},data:{localPath:h}}),(0,g.revalidatePath)("/workspaces"),{success:!0}}let k=`分析这个项目目录，生成一段简短的 Markdown 项目描述。

读取 package.json、README.md 等关键文件，然后概括：

**技术栈：** 一句话列出主要语言、框架、关键库
**定位：** 一句话说明项目是什么
**核心模块：** 2-3 个关键模块，每个一句话

要求：
- 总字数不超过 500 字
- 用简洁的 Markdown（加粗标签 + 短句），不要用 ## 大标题和表格
- 不要罗列每个文件/目录，只说关键信息
- 中文输出`,l=`Analyze this project directory and generate a brief Markdown project description.

Read package.json, README.md and other key files, then summarize:

**Tech Stack:** One sentence listing primary languages, frameworks, and key libraries
**Overview:** One sentence describing what this project is
**Core Modules:** 2-3 key modules, one sentence each

Requirements:
- Keep it under 1000 words
- Use concise Markdown (bold labels + short sentences), no ## headings or tables
- Don't list every file/directory, only key information
- Output in English`;async function m(b,c="zh"){if(!b||"string"!=typeof b)throw Error("无效的本地路径");if(b.startsWith("~"))throw Error("不支持 ~ 别名，请提供绝对路径");if(!e.default.isAbsolute(b))throw Error("本地路径必须为绝对路径");let{aiQuery:d}=await a.A(752453),f=await d("en"===c?l:k,b,{maxTurns:10,tools:["Read","Glob"],allowedTools:["Read","Glob"]});if(!f)throw Error("AI 分析未返回结果");return f.length>2e3?f.slice(0,2e3).trimEnd()+"\n\n...":f}(0,h.ensureServerEntryExports)([i,j,m]),(0,b.registerServerReference)(i,"40c7f324fe557fb80c37a1a32181503a0536257351",null),(0,b.registerServerReference)(j,"60c86ef167fca66c0b566738b7d16ce04945d66ce2",null),(0,b.registerServerReference)(m,"603afc0abc8a99c0d1556130213be4f1900ced3cf3",null),a.s(["analyzeProjectDirectory",0,m,"checkMigrationSafety",0,i,"migrateProjectPath",0,j])},52350,562278,a=>{"use strict";var b=a.i(902157),c=a.i(660526),d=a.i(750227),e=a.i(163812);function f(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}a.s(["getPackageRoot",0,f],562278);let g=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"];a.s(["ClaudeCliAdapter",0,class{buildSpawnArgs(a){let b=["--dangerously-skip-permissions"];a.extraArgs?.length&&b.push(...a.extraArgs),a.resumeSessionId?b.push("--resume",a.resumeSessionId):a.continueLatest?b.push("--continue"):a.prompt&&b.push(a.prompt);let c={...a.envOverrides??{}};return{command:this.resolveCommand(),args:b,env:c}}buildEnvOverrides(a){let b={TOWER_TASK_ID:a.taskId,TOWER_TASK_TITLE:a.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:a.apiUrl};return a.callbackUrl&&(b.CALLBACK_URL=a.callbackUrl),b}async installHooks(a){try{let a=this.readSettings(),b=a.hooks??{},c=f().replace(/\\/g,"/"),e=d.join(c,"scripts","session-start-hook.js").replace(/\\/g,"/"),g=d.join(c,"scripts","post-tool-hook.js").replace(/\\/g,"/"),h=d.join(c,"scripts","stop-hook.js").replace(/\\/g,"/"),i=!1;return i=this.upsertHook(b,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${e}"`,timeout:5,type:"command"}]})||i,i=this.upsertHook(b,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${g}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||i,(i=this.upsertHook(b,"Stop","stop-hook.js",{hooks:[{command:`node "${h}"`,timeout:5,type:"command"}]})||i)&&(a.hooks=b,this.writeSettings(a)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(a){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:a instanceof Error?a.message:String(a)}}}async repairHookPaths(){try{let a=this.readSettings(),b=a.hooks??{},c=f().replace(/\\/g,"/"),e=!1;for(let[a,f]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let g=this.getHookArray(b,a),h=g.findIndex(a=>a?.hooks?.some?.(a=>a.command?.includes(f)));if(h<0)continue;let i=d.join(c,"scripts",f).replace(/\\/g,"/"),j=`node "${i}"`,k=g[h]?.hooks?.[0];k&&k.command!==j&&(k.command=j,b[a]=g,e=!0)}e&&(a.hooks=b,this.writeSettings(a))}catch{}}upsertHook(a,b,c,d){let e=this.getHookArray(a,b),f=d?.hooks?.[0]?.command,g=e.findIndex(a=>a?.hooks?.some?.(a=>a.command?.includes(c)));if(g>=0){if(e[g]?.hooks?.[0]?.command===f)return!1;e.splice(g,1)}return e.push(d),a[b]=e,!0}async uninstallHooks(){try{let a=this.readSettings(),b=a.hooks??{},c=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let a of["SessionStart","PostToolUse","Stop"]){let d=this.getHookArray(b,a);b[a]=d.filter(a=>!a.hooks?.some(a=>c.some(b=>a.command?.includes(b))))}return a.hooks=b,this.writeSettings(a),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(a){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:a instanceof Error?a.message:String(a)}}}async isHooksInstalled(){let a=this.readSettings().hooks??{},b=this.getHookArray(a,"PostToolUse");return this.hasHook(b,"post-tool-hook.js")}async installMcp(a,b={}){let c=b.scope??"user",d={command:a.command,args:a.args};a.env&&Object.keys(a.env).length>0&&(d.env=a.env);let e=this.resolveCommand(),f=["mcp","add-json","-s",c,a.name,JSON.stringify(d)];try{return await this.runCli(e,["mcp","remove","-s",c,a.name],b.cwd).catch(()=>{}),await this.runCli(e,f,b.cwd),{ok:!0,method:"cli",detail:`${e} ${f.join(" ")}`}}catch(a){return{ok:!1,method:"cli",detail:`${e} ${f.join(" ")}`,error:a instanceof Error?a.message:String(a)}}}async uninstallMcp(a,b={}){let c=b.scope??"user",d=this.resolveCommand(),e=["mcp","remove","-s",c,a];try{return await this.runCli(d,e,b.cwd),{ok:!0,method:"cli",detail:`${d} ${e.join(" ")}`}}catch(a){return{ok:!1,method:"cli",detail:`${d} ${e.join(" ")}`,error:a instanceof Error?a.message:String(a)}}}async isMcpInstalled(a,b={}){let c=this.resolveCommand();try{return await this.runCli(c,["mcp","get",a],b.cwd,5e3),!0}catch{return!1}}async installSkill(a,c){let f=d.join(this.getConfigDir(),"skills",a);try{if(!b.existsSync(c))return{ok:!1,method:"symlink",detail:f,error:`Source skill dir does not exist: ${c}`};b.mkdirSync(d.dirname(f),{recursive:!0});let a=await b.promises.lstat(f).catch(()=>null);if(a)if(!(a.isSymbolicLink()||(0,e.isWindows)()&&a.isDirectory()))return{ok:!1,method:"symlink",detail:f,error:`Refusing to overwrite non-symlink at ${f}`};else try{let a=await b.promises.readlink(f);if(d.resolve(a)===d.resolve(c))return{ok:!0,method:"symlink",detail:`${f} → ${c} (already)`};await b.promises.unlink(f)}catch{if(!a.isSymbolicLink())return{ok:!1,method:"symlink",detail:f,error:`Refusing to overwrite non-symlink at ${f}`}}let g=(0,e.isWindows)()?"junction":"dir";return await b.promises.symlink(c,f,g),{ok:!0,method:"symlink",detail:`${f} → ${c}`}}catch(a){return{ok:!1,method:"symlink",detail:f,error:a instanceof Error?a.message:String(a)}}}async uninstallSkill(a){let c=d.join(this.getConfigDir(),"skills",a);try{let a=await b.promises.lstat(c).catch(()=>null);if(!a)return{ok:!0,method:"symlink",detail:`${c} (already absent)`};if(!a.isSymbolicLink())return{ok:!1,method:"symlink",detail:c,error:`Refusing to remove non-symlink at ${c}`};return await b.promises.unlink(c),{ok:!0,method:"symlink",detail:c}}catch(a){return{ok:!1,method:"symlink",detail:c,error:a instanceof Error?a.message:String(a)}}}async isSkillInstalled(a,c){let e=d.join(this.getConfigDir(),"skills",a);try{if(!(await b.promises.lstat(e)).isSymbolicLink())return!1;if(!c)return!0;let a=await b.promises.readlink(e),f=d.isAbsolute(a)?a:d.resolve(d.dirname(e),a);return d.resolve(f)===d.resolve(c)}catch{return!1}}async runCli(b,c,d,e=1e4){let{execFile:f}=await a.A(482848),{promisify:g}=await a.A(268548),h=g(f),{stdout:i}=await h(b,c,{cwd:d,timeout:e});return i}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:b}=await a.A(144264),{promisify:c}=await a.A(534777),{resolveSpawnTarget:d}=await a.A(889618),e=c(b),f=await d(this.resolveCommand(),["--version"]),{stdout:g}=await e(f.command,f.args,{timeout:5e3});return g.trim()||null}catch{return null}}async getModels(){return g}getConfigDir(){return d.join(c.homedir(),".claude")}getSettingsPath(){return d.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return d.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(a){return{command:this.resolveCommand(),args:["--print",a,"--output-format","stream-json","--verbose"]}}resolveCommand(){if(process.env.CLAUDE_CODE_PATH)return process.env.CLAUDE_CODE_PATH;if((0,e.isWindows)()){let a=(0,e.resolveCommandPathSync)("claude-code");if("claude-code"!==a)return a}return(0,e.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(b.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(a){let c=this.getConfigDir();b.existsSync(c)||b.mkdirSync(c,{recursive:!0}),b.writeFileSync(this.getSettingsPath(),JSON.stringify(a,null,2),"utf-8")}getHookArray(a,b){let c=a[b];return Array.isArray(c)?c:[]}hasHook(a,b){return a.some(a=>a.hooks?.some(a=>a.command?.includes(b)))}}],52350)},417219,a=>{"use strict";a.i(666680);var b=a.i(902157),c=a.i(750227),d=a.i(319997);a.s(["ensureAssetsDir",0,function(a){let e=function(a){let b=c.join((0,d.getStorageDir)(),"assets",a);if(!b.startsWith((0,d.getStorageDir)()+c.sep))throw Error("Path traversal detected");return b}(a);return b.mkdirSync(e,{recursive:!0}),e}])},97397,a=>a.a(async(b,c)=>{try{var d=a.i(815429),e=a.i(902157),f=a.i(750227),g=a.i(75681),h=a.i(761469),i=a.i(188139),j=a.i(417219),k=a.i(980999),l=a.i(630048),m=b([k]);[k]=m.then?(await m)():m;let t=g.z.object({filename:g.z.string().min(1).max(255),path:g.z.string().min(1),mimeType:g.z.string().max(100).optional(),size:g.z.number().int().nonnegative().optional(),projectId:g.z.string().min(1),description:g.z.string().max(500).optional(),taskId:g.z.string().optional()});async function n(a){let b=t.parse(a);(0,j.ensureAssetsDir)(b.projectId);let c=await h.db.projectAsset.create({data:{...b,taskId:b.taskId??null}});return(0,i.revalidatePath)("/workspaces"),c}async function o(a){let b=await h.db.projectAsset.findUnique({where:{id:a}});b?.path&&await e.promises.unlink(b.path).catch(()=>{}),await h.db.projectAsset.delete({where:{id:a}}),(0,i.revalidatePath)("/workspaces")}async function p(a){return h.db.projectAsset.findMany({where:{projectId:a},orderBy:{createdAt:"desc"},include:{task:{select:{id:!0,title:!0,status:!0,priority:!0,description:!0,createdAt:!0,labels:{include:{label:!0}},executions:{orderBy:{createdAt:"desc"},take:1,select:{summary:!0,status:!0,endedAt:!0}},_count:{select:{assets:!0}}}}}})}async function q(a){return h.db.projectAsset.findMany({where:{taskId:a},orderBy:{createdAt:"desc"}})}async function r(a){return h.db.projectAsset.findUnique({where:{id:a}})}async function s(a){let b=a.get("file"),c=a.get("projectId"),d=a.get("taskId")||void 0;if(!b||!c)throw Error("Missing file or projectId");let g=await (0,k.getConfigValue)("system.maxUploadBytes",0x3200000);if(b.size>g)throw Error(`File too large (max ${Math.round(g/1024/1024)} MB)`);let l=a.get("description")??"";if(!await h.db.project.findUnique({where:{id:c}}))throw Error("Invalid projectId");let m=Buffer.from(await b.arrayBuffer()),o=(0,j.ensureAssetsDir)(c),p=f.basename(b.name);p&&"."!==p&&".."!==p||(p=`upload-${Date.now()}`);let q=f.join(o,p);if(e.existsSync(q)){let a=f.extname(p),b=f.basename(p,a);p=`${b}-${Date.now()}${a}`}let r=f.join(o,p);if(!r.startsWith(o))throw Error("Invalid filename");await e.promises.writeFile(r,m);let s=await n({filename:p,path:r,mimeType:b.type||void 0,size:b.size,projectId:c,description:l||void 0,taskId:d});return(0,i.revalidatePath)("/workspaces"),s}(0,l.ensureServerEntryExports)([n,o,p,q,r,s]),(0,d.registerServerReference)(n,"40692d78f9f9856c4d731d0174d846843529ae4da6",null),(0,d.registerServerReference)(o,"40c0e84099b888ee15c70367c45cfde562ecbaf67f",null),(0,d.registerServerReference)(p,"405bfb0d8c83e6fd1f6fab5f7c1702ad27bee95412",null),(0,d.registerServerReference)(q,"4024c970ae8e22133b65e280b1f6790b6dcc9e8aab",null),(0,d.registerServerReference)(r,"40f8c6447656a06913790e85dc05a691c7aa8c4d5f",null),(0,d.registerServerReference)(s,"40f1890174662fd3e05a8ab2f28cc37679e3f35653",null),a.s(["createAsset",0,n,"deleteAsset",0,o,"getAssetById",0,r,"getProjectAssets",0,p,"getTaskAssets",0,q,"uploadAsset",0,s]),c()}catch(a){c(a)}},!1),835032,a=>{"use strict";async function b(a,b){await a.$executeRawUnsafe("DELETE FROM notes_fts WHERE note_id = ?",b.id),await a.$executeRawUnsafe("INSERT INTO notes_fts(note_id, title, content) VALUES (?, ?, ?)",b.id,b.title,b.content)}async function c(a,b){await a.$executeRawUnsafe("DELETE FROM notes_fts WHERE note_id = ?",b)}a.s(["deleteNoteFromFts",0,c,"syncNoteToFts",0,b])},392164,a=>{"use strict";var b=a.i(815429),c=a.i(75681),d=a.i(761469),e=a.i(188139),f=a.i(835032),g=a.i(630048);let h=c.z.object({title:c.z.string().min(1).max(200),content:c.z.string(),category:c.z.string().max(50).optional(),projectId:c.z.string().min(1),taskId:c.z.string().optional()}),i=c.z.object({title:c.z.string().min(1).max(200).optional(),content:c.z.string().optional(),category:c.z.string().max(50).optional()});async function j(a){let b=h.parse(a),c=await d.db.projectNote.create({data:{title:b.title,content:b.content,category:b.category??"备忘",projectId:b.projectId,taskId:b.taskId??null}});return await (0,f.syncNoteToFts)(d.db,{id:c.id,title:c.title,content:c.content}),(0,e.revalidatePath)("/workspace"),c}async function k(a,b){let c=i.parse(b),g=await d.db.projectNote.update({where:{id:a},data:c});return await (0,f.syncNoteToFts)(d.db,{id:g.id,title:g.title,content:g.content}),(0,e.revalidatePath)("/workspace"),g}async function l(a){await (0,f.deleteNoteFromFts)(d.db,a),await d.db.projectNote.delete({where:{id:a}}),(0,e.revalidatePath)("/workspace")}async function m(a){return d.db.projectNote.findUnique({where:{id:a}})}async function n(a,b){return d.db.projectNote.findMany({where:{projectId:a,...b?.category?{category:b.category}:{}},orderBy:[{updatedAt:"desc"},{id:"desc"}],include:{task:{select:{id:!0,title:!0}}}})}async function o(a){return d.db.projectNote.findMany({where:{taskId:a},orderBy:[{updatedAt:"desc"},{id:"desc"}]})}(0,g.ensureServerEntryExports)([j,k,l,m,n,o]),(0,b.registerServerReference)(j,"40359404df2000745963c2ef56b3ebd5920dd11881",null),(0,b.registerServerReference)(k,"60bc7620818cdef3c2044437e2a288b05c2cf29c96",null),(0,b.registerServerReference)(l,"402d235d3cadb13ac7f299a35a91a721ee40b76d4d",null),(0,b.registerServerReference)(m,"40447909230dc07a789f27d886e53db06667104982",null),(0,b.registerServerReference)(n,"60470084914533a1b0571ecba35d1ed99b679b18e8",null),(0,b.registerServerReference)(o,"40b9da4796cde7c3039167d8c9a106bd4eca5494bf",null),a.s(["createNote",0,j,"deleteNote",0,l,"getNoteById",0,m,"getProjectNotes",0,n,"getTaskNotes",0,o,"updateNote",0,k])},196195,a=>{"use strict";var b=a.i(815429),c=a.i(233405),d=a.i(814747),e=a.i(446786);function f(a){return a.startsWith("~/")||"~"===a?d.default.join(e.default.homedir(),a.slice(1)):a}async function g(a){if(!a?.trim())return null;let b=d.default.resolve(f(a));try{return(0,c.execSync)("git rev-parse --abbrev-ref HEAD",{cwd:b,encoding:"utf-8",timeout:5e3}).trim()}catch{return null}}async function h(a){if(!a?.trim())return[];let b=d.default.resolve(f(a));try{let a,d;return a=new Set((0,c.execSync)("git branch --format='%(refname:short)'",{cwd:b,encoding:"utf-8",timeout:5e3}).trim().split("\n").filter(Boolean).map(a=>a.replace(/'/g,""))),d=(0,c.execSync)("git branch -r --format='%(refname:short)'",{cwd:b,encoding:"utf-8",timeout:5e3}).trim().split("\n").filter(Boolean).map(a=>a.replace(/'/g,"").replace(/^origin\//,"")).filter(b=>"HEAD"!==b&&!a.has(b)),[...a,...d]}catch{return[]}}async function i(a){if(!a?.trim())return;let b=d.default.resolve(f(a));try{(0,c.spawn)("git",["fetch","--prune"],{cwd:b,stdio:"ignore",detached:!0}).unref()}catch{}}(0,a.i(630048).ensureServerEntryExports)([g,h,i]),(0,b.registerServerReference)(g,"400954e103ea703bf5fe6e03cc8c3f1a4a7b47a9a1",null),(0,b.registerServerReference)(h,"4005c134080c66bb8cabf390cf0ff11380f0e0b6db",null),(0,b.registerServerReference)(i,"4078d8e4a64f54b301edad3a8747029da86e985d81",null),a.s(["fetchRemoteBranches",0,i,"getCurrentBranch",0,g,"getProjectBranches",0,h])},925886,a=>{"use strict";var b=a.i(815429),c=a.i(761469),d=a.i(188139);async function e(a){return c.db.agentPrompt.findMany({where:a?{OR:[{workspaceId:a},{workspaceId:null}]}:{},orderBy:[{isDefault:"desc"},{name:"asc"}]})}async function f(a){return c.db.agentPrompt.findUnique({where:{id:a}})}async function g(a){if(a.content.length>1e5)throw Error("Prompt content exceeds maximum length of 100000 characters");let b=await c.db.agentPrompt.create({data:a});return(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings"),b}async function h(a,b){if(void 0!==b.content&&b.content.length>1e5)throw Error("Prompt content exceeds maximum length of 100000 characters");let e=await c.db.agentPrompt.update({where:{id:a},data:b});return(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings"),e}async function i(a){await c.db.agentPrompt.delete({where:{id:a}}),(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings")}async function j(a,b){let e=await c.db.$transaction(async c=>(await c.agentPrompt.updateMany({where:b?{workspaceId:b,isDefault:!0}:{isDefault:!0},data:{isDefault:!1}}),c.agentPrompt.update({where:{id:a},data:{isDefault:!0}})));return(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings"),e}(0,a.i(630048).ensureServerEntryExports)([e,f,g,h,i,j]),(0,b.registerServerReference)(e,"404ced5321cafdbb940385d492c4abe7763919765c",null),(0,b.registerServerReference)(f,"4093cdc5a5fae8c25d005b539114d5c077276aaa7a",null),(0,b.registerServerReference)(g,"40ed593f878bdb40633ace1e213cdd4a46659ed794",null),(0,b.registerServerReference)(h,"603b94f659983ece6c00b16fef05685ccb8ef6c65c",null),(0,b.registerServerReference)(i,"40c075d29e5bfede26a93e26cf145f2fccc603534f",null),(0,b.registerServerReference)(j,"60076279904b452893970a334bf7415e18d4f37849",null),a.s(["createPrompt",0,g,"deletePrompt",0,i,"getPrompts",0,e,"setDefaultPrompt",0,j,"updatePrompt",0,h])},748383,a=>{"use strict";var b=a.i(815429),c=a.i(761469),d=a.i(188139),e=a.i(496877),f=a.i(233405);function g(a,b){if(!b||b.startsWith("-"))return null;try{return(0,f.execFileSync)("git",["rev-parse",b],{cwd:a,encoding:"utf-8",timeout:5e3}).trim()||null}catch(a){return null}}async function h(a){return c.db.version.findMany({where:{projectId:a},orderBy:[{targetDate:"desc"},{order:"desc"},{createdAt:"desc"}],include:{type:!0,tasks:{orderBy:[{order:"asc"},{createdAt:"desc"}],include:{labels:{include:{label:!0}},assets:{select:{id:!0,filename:!0,mimeType:!0,size:!0}},notes:{select:{id:!0,title:!0,category:!0}}}}}})}async function i(a){let b=e.createVersionSchema.parse(a),f=null;if(b.baseBranch){let a=await c.db.project.findUnique({where:{id:b.projectId},select:{localPath:!0}});a?.localPath&&(f=g(a.localPath,b.baseBranch))}let h=await c.db.version.create({data:{projectId:b.projectId,number:b.number,name:b.name,typeId:b.typeId??null,status:"PLANNED",baseBranch:b.baseBranch??null,baseCommit:f,startDate:b.startDate??null,targetDate:b.targetDate??null,description:b.description??null}});return b.setCurrent&&await q(h.id),(0,d.revalidatePath)("/workspaces"),h}async function j(a,b){let f=e.updateVersionSchema.parse(b);try{let b=await c.db.version.update({where:{id:a},data:f});return(0,d.revalidatePath)("/workspaces"),b}catch(a){if("object"==typeof a&&a&&"code"in a&&"P2025"===a.code)throw Error("版本不存在");throw a}}async function k(a){try{await c.db.version.delete({where:{id:a}})}catch(a){if("object"==typeof a&&a&&"code"in a&&"P2025"===a.code)throw Error("版本不存在");throw a}(0,d.revalidatePath)("/workspaces")}async function l(a,b){await c.db.task.updateMany({where:{id:a},data:{versionId:b}}),(0,d.revalidatePath)("/workspaces")}async function m(a,b){let e=await c.db.version.findUnique({where:{id:a},select:{id:!0,projectId:!0,status:!0,baseBranch:!0,project:{select:{localPath:!0}}}});if(!e)throw Error("版本不存在");if("RELEASED"===e.status)throw Error("该版本已发布");let f=null;e.baseBranch&&e.project?.localPath&&(f=g(e.project.localPath,e.baseBranch));let h=await c.db.version.findUnique({where:{id:b},select:{id:!0,projectId:!0,status:!0}});if(!h)throw Error("目标版本不存在");if(h.projectId!==e.projectId)throw Error("目标版本必须属于同一项目");if(h.id===a)throw Error("目标版本不能是正在发布的版本本身");if("RELEASED"===h.status)throw Error("目标版本已发布，不能作为下一个当前版本");await c.db.$transaction(async c=>{await c.version.update({where:{id:a},data:{status:"RELEASED",releasedAt:new Date,releaseCommit:f,isCurrent:!1}}),await c.task.updateMany({where:{versionId:a,status:{notIn:["DONE","CANCELLED"]}},data:{versionId:b}}),await c.version.updateMany({where:{projectId:e.projectId,isCurrent:!0},data:{isCurrent:!1}}),await c.version.update({where:{id:b},data:{isCurrent:!0,status:"ACTIVE"}})}),(0,d.revalidatePath)("/workspaces")}async function n(a){return c.db.version.findMany({where:{projectId:a,status:{not:"RELEASED"}},select:{id:!0,number:!0,name:!0,isCurrent:!0,status:!0},orderBy:[{isCurrent:"desc"},{targetDate:"desc"},{createdAt:"desc"}]})}async function o(a){let b=await c.db.version.findUnique({where:{id:a},select:{baseCommit:!0,releaseCommit:!0,baseBranch:!0,project:{select:{localPath:!0}}}});if(!b?.baseCommit||!b.project?.localPath)return null;let d=b.releaseCommit??(b.baseBranch?g(b.project.localPath,b.baseBranch):null);return d?function(a,b,c){try{let d=(0,f.execFileSync)("git",["diff","--numstat",`${b}..${c}`],{cwd:a,encoding:"utf-8",timeout:5e3}),e=0,g=0,h=0;for(let a of d.split("\n")){let b=a.trim();if(!b)continue;let[c,d]=b.split("	");e+=Number.parseInt(c,10)||0,g+=Number.parseInt(d,10)||0,h+=1}return{additions:e,deletions:g,files:h}}catch(a){return{additions:0,deletions:0,files:0}}}(b.project.localPath,b.baseCommit,d):null}async function p(a){let b=await c.db.version.findUnique({where:{id:a},select:{baseCommit:!0,releaseCommit:!0,baseBranch:!0,project:{select:{localPath:!0}}}});if(!b?.baseCommit||!b.project?.localPath)return null;let d=b.releaseCommit??(b.baseBranch?g(b.project.localPath,b.baseBranch):null);return d?{patch:function(a,b,c){try{return(0,f.execFileSync)("git",["diff",`${b}..${c}`],{cwd:a,encoding:"utf-8",timeout:15e3,maxBuffer:0x1400000})}catch(a){return""}}(b.project.localPath,b.baseCommit,d)}:null}async function q(a){let b=await c.db.version.findUnique({where:{id:a},select:{id:!0,projectId:!0}});if(!b)throw Error("版本不存在");await c.db.$transaction(async c=>{await c.version.updateMany({where:{projectId:b.projectId,isCurrent:!0},data:{isCurrent:!1}}),await c.version.update({where:{id:a},data:{isCurrent:!0,status:"ACTIVE"}})}),(0,d.revalidatePath)("/workspaces")}(0,a.i(630048).ensureServerEntryExports)([h,i,j,k,l,m,n,o,p,q]),(0,b.registerServerReference)(h,"4079b9c580c6f80e34f3279853929ea454d98c356f",null),(0,b.registerServerReference)(i,"4019da742b0ec4b2f142aa6b032f694c735768b6c2",null),(0,b.registerServerReference)(j,"608ab6b30964217d51d8f016deb19becdf63758ff6",null),(0,b.registerServerReference)(k,"40858d48e0f2abf74612cdbe337d68e0abe5aa0da3",null),(0,b.registerServerReference)(l,"6054ec2dd3dcaa33b023aaf62fb57d4dd0cd24fd7c",null),(0,b.registerServerReference)(m,"609bb4cb1eb37f5fcc9f9753c5cb5fdbbbf7adde71",null),(0,b.registerServerReference)(n,"4032ae7d74eb777aa91dcbffe35d7f9f37e86aebdb",null),(0,b.registerServerReference)(o,"40d053a0c0001deadf83a93f4b80762895f2b50a0f",null),(0,b.registerServerReference)(p,"4019331231d7a31d8f2d3e48967fbfe856229b9e4c",null),(0,b.registerServerReference)(q,"402beeeaad30b138405b95e2ca98c3bc9be2357dd7",null),a.s(["assignTaskVersion",0,l,"createVersion",0,i,"deleteVersion",0,k,"getProjectVersions",0,h,"getVersionDiff",0,p,"getVersionDiffStat",0,o,"getVersionsForPicker",0,n,"releaseVersion",0,m,"setCurrentVersion",0,q,"updateVersion",0,j],748383)},408835,a=>a.a(async(b,c)=>{try{a.i(244256),a.i(495370);var d=a.i(396904),e=a.i(980999);a.i(101844),a.i(563736),a.i(4634),a.i(196195),a.i(536960),a.i(347427);var f=a.i(689171);a.i(925886),a.i(392164);var g=a.i(97397);a.i(748383);var h=b([d,e,f,g]);[d,e,f,g]=h.then?(await h)():h,a.s([]),c()}catch(a){c(a)}},!1),590656,a=>a.a(async(b,c)=>{try{var d=a.i(408835),e=a.i(244256),f=a.i(495370),g=a.i(396904),h=a.i(980999),i=a.i(101844),j=a.i(563736),k=a.i(4634),l=a.i(196195),m=a.i(536960),n=a.i(347427),o=a.i(689171),p=a.i(925886),q=a.i(392164),r=a.i(97397),s=a.i(748383),t=b([d,g,h,o,r]);[d,g,h,o,r]=t.then?(await t)():t,a.s(["003a751a093cb8d33cb84837de53ed55bb831808f0",()=>h.getAvailableEditors,"003ef32d24bc4b29c342acf4c816cf95fa4fe3f598",()=>h.getActualWsPort,"003f1dfdc13dd3928867e8ca32a72ccaefc2e0573d",()=>k.getOnboardingStatus,"006aab408acb61a0962235f55a3de594983b7dd5bf",()=>j.listAllExtensionStatus,"007299bb439e8bd78f44c5943e259c3c64826d2322",()=>h.getArchiveDelayDays,"00787d644bb3e50af7d1fc14f1f2ef93c8e1b718dd",()=>h.getAvailableShells,"0096dda894769b63f7db321229f2e29c5eb63910eb",()=>h.getAvailableTerminalApps,"009dc12578d21ac356f7a520046a766fd241cb1a2e",()=>h.getPlatformInfo,"4005c134080c66bb8cabf390cf0ff11380f0e0b6db",()=>l.getProjectBranches,"400954e103ea703bf5fe6e03cc8c3f1a4a7b47a9a1",()=>l.getCurrentBranch,"400e2fda1bae5acb01074e51d080a2be2a77bc34cd",()=>h.getConfigValues,"4012b5a73e0f56276592ab3dffbfb4a5886b44ad1f",()=>h.resolveGitLocalPath,"401b19ed1de78cc49e951594c328f146e9f3b16d23",()=>n.continueLatestPtyExecution,"4020a59af9c321427f702c3c13f21ccd90a0734683",()=>o.createTask,"4024c970ae8e22133b65e280b1f6790b6dcc9e8aab",()=>r.getTaskAssets,"4028b5499c3e11f3aa6261beeb4e14566a4403030f",()=>f.getTaskLabels,"402d235d3cadb13ac7f299a35a91a721ee40b76d4d",()=>q.deleteNote,"4030983d0916967d1b45111b1f8932995e322ac168",()=>f.getLabelsForWorkspace,"4032ae7d74eb777aa91dcbffe35d7f9f37e86aebdb",()=>s.getVersionsForPicker,"40359404df2000745963c2ef56b3ebd5920dd11881",()=>q.createNote,"40396fea8de05006bf9af23d47754c92e20099807a",()=>o.deleteTask,"403b928263920b2aa0280c225175ff9d208fda0109",()=>o.toggleTaskPinned,"404c560cd8f5726f68215bdda66da5b48b80ba8dca",()=>m.openInFileManager,"404ced5321cafdbb940385d492c4abe7763919765c",()=>p.getPrompts,"405365149185a3f1aa7bf7b74cf5fd91f66a6c9d5b",()=>e.deleteWorkspace,"4054c3d2ea9f6bcddfa7d33d42dc7ae43c5d3bc071",()=>j.installExtension,"4054f9623c07304a83a2f85e6b3b6fae81dc47f655",()=>e.reorderWorkspaces,"40769e3e7c790732374614ca824e004ce8291d79f2",()=>e.createWorkspace,"4078d8e4a64f54b301edad3a8747029da86e985d81",()=>l.fetchRemoteBranches,"4089bb43b964c3cc5b2848bc729865dee8e56f60a6",()=>k.dispatchTaskCompletionEvent,"4090685fce0a0471d05e033e1bcbffcfbe830ff4de",()=>e.getRecentLocalProjects,"4090dece3eac4df8d9aa55e39136298bd458446dac",()=>f.createLabel,"40ace337192d4dd9a4a7362eab01bc86850fb4a0d8",()=>k.setOnboardingProgress,"40b312e080b33001e97622ba996bad24f8aaf9fe1d",()=>j.checkExtension,"40b400ff5b05c6a2cc9e22bb08c49c3a9384b04f0d",()=>n.stopPtyExecution,"40b4afd819167bb48c681e66a7e9184ef54b187356",()=>j.uninstallExtension,"40b9da4796cde7c3039167d8c9a106bd4eca5494bf",()=>q.getTaskNotes,"40c0e84099b888ee15c70367c45cfde562ecbaf67f",()=>r.deleteAsset,"40c7f324fe557fb80c37a1a32181503a0536257351",()=>i.checkMigrationSafety,"40ccc3be5ee2c307201017260aa05492281bf067fb",()=>e.createProject,"40d2dd1b5fc5c81f4ded0113d429d62fa7910ff56d",()=>m.openInTerminal,"40dbb1eb469e90f3055f19af1546fa852e53b8460d",()=>e.deleteProject,"40def74beab8ac4c567000df3bff092d0b29baef01",()=>o.checkWorktreeClean,"40e35bb2d01b14eeccf0c46897d86399797ff36feb",()=>n.getTaskExecutions,"40ecd40642698958b84412a7dd960a70f41dfd5a26",()=>e.getOrCreateTowerTaskId,"40f1890174662fd3e05a8ab2f28cc37679e3f35653",()=>r.uploadAsset,"40f28d24ba27f24fcda354e690ce301b9209fb8247",()=>m.openInEditor,"40f89aa83057e20a65456875f67e50fe3a99de604e",()=>f.deleteLabel,"6003b9bf4e05e9d923ec7aa8ed47b1d2e8b1806cb7",()=>k.setOnboardingExtensions,"6022565280345647acafc879d6697aabada2ec392f",()=>k.completeOnboarding,"603afc0abc8a99c0d1556130213be4f1900ced3cf3",()=>i.analyzeProjectDirectory,"605c2fc35fe8ffc8c86eea4b9b750a9ac5c7b745f6",()=>g.globalSearch,"60910320dd81c673865c275b5918d9dfcfbc61867f",()=>o.commitWorktreeChanges,"609263c53e73f969487fb3a78f5cad865efcc601e8",()=>e.updateWorkspace,"60b8e086436311cfc8d3cd29d47d42cc43cd016c8e",()=>o.updateTask,"60c086bb0d6a417695daf1a78de8b35ca7f8183e15",()=>h.setConfigValue,"60c86ef167fca66c0b566738b7d16ce04945d66ce2",()=>i.migrateProjectPath,"60d6e7b79a52a7f8d9c05a2958d4ab5f6f8559f51a",()=>o.updateTaskStatus,"60d71d3fa805fa2e9c75423c15e1c97fab192e0bbb",()=>e.updateProject,"60ee0e6712a226685ca6e1745323baabb2172f74b5",()=>n.resumePtyExecution,"60f10eb3d02a926463eb7257c3ae897d6d4176cbd4",()=>f.setTaskLabels,"60fed8ee888cd0a6a4480474a484ee4fe77a6d9c20",()=>h.getConfigValue,"7c1e12d6aeb59bf8e240aa5902e48cd569ebcc127a",()=>n.startPtyExecutionSafe,"7ce9d6cf599f47d28dee6ce3b03c08930d3f12476e",()=>n.startPtyExecution]),c()}catch(a){c(a)}},!1),76052,a=>{a.v(b=>Promise.all(["server/chunks/ssr/src_lib_0rk2hla._.js"].map(b=>a.l(b))).then(()=>b(492067)))},98813,a=>{a.v(a=>Promise.resolve().then(()=>a(962620)))},507502,a=>{a.v(a=>Promise.resolve().then(()=>a(845427)))},752453,a=>{a.v(b=>Promise.all(["server/chunks/ssr/_0k9b94s._.js"].map(b=>a.l(b))).then(()=>b(897667)))},173855,a=>{a.v(b=>Promise.all(["server/chunks/ssr/src_lib_open-targets_ts_12a-_~u._.js"].map(b=>a.l(b))).then(()=>b(289288)))},889618,a=>{a.v(a=>Promise.resolve().then(()=>a(163812)))},482848,a=>{a.v(a=>Promise.resolve().then(()=>a(874533)))},268548,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[externals]_node_util_0xr.y7p._.js"].map(b=>a.l(b))).then(()=>b(812057)))},144264,a=>{a.v(a=>Promise.resolve().then(()=>a(233405)))},534777,a=>{a.v(a=>Promise.resolve().then(()=>a(224361)))},662330,a=>{a.v(b=>Promise.all(["server/chunks/ssr/_0hu0tyg._.js"].map(b=>a.l(b))).then(()=>b(818992)))},610073,a=>{a.v(a=>Promise.resolve().then(()=>a(4634)))},260815,a=>{a.v(a=>Promise.resolve().then(()=>a(924868)))},200442,a=>{a.v(b=>Promise.all(["server/chunks/ssr/_0l3l_d6._.js"].map(b=>a.l(b))).then(()=>b(941750)))},323970,a=>{a.v(a=>Promise.resolve().then(()=>a(522734)))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0-tolks._.js.map