prjct-cli 1.55.0 → 1.56.0
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/CHANGELOG.md +18 -2
- package/dist/bin/prjct-core.mjs +414 -395
- package/dist/daemon/entry.mjs +370 -351
- package/dist/mcp/server.mjs +14 -3
- package/package.json +1 -1
package/dist/mcp/server.mjs
CHANGED
|
@@ -480,7 +480,18 @@ ${_t(t,e)}`}function di(i){let t=Object.entries(i).filter(([,n])=>n!=null);if(t.
|
|
|
480
480
|
|
|
481
481
|
CREATE INDEX IF NOT EXISTS idx_user_prompts_project ON user_prompts(project_id);
|
|
482
482
|
CREATE INDEX IF NOT EXISTS idx_user_prompts_session ON user_prompts(session_id);
|
|
483
|
-
`);try{i.run("ALTER TABLE memories ADD COLUMN session_id TEXT")}catch{}},"up")}
|
|
483
|
+
`);try{i.run("ALTER TABLE memories ADD COLUMN session_id TEXT")}catch{}},"up")},{version:12,name:"task-body-and-comments",up:l(i=>{try{i.run("ALTER TABLE queue_tasks ADD COLUMN body TEXT")}catch{}i.run(`
|
|
484
|
+
CREATE TABLE IF NOT EXISTS queue_task_comments (
|
|
485
|
+
id TEXT PRIMARY KEY,
|
|
486
|
+
task_id TEXT NOT NULL,
|
|
487
|
+
author TEXT NOT NULL DEFAULT 'user',
|
|
488
|
+
content TEXT NOT NULL,
|
|
489
|
+
created_at TEXT NOT NULL,
|
|
490
|
+
updated_at TEXT NOT NULL
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
CREATE INDEX IF NOT EXISTS idx_qtc_task_id ON queue_task_comments(task_id);
|
|
494
|
+
`)},"up")}],Xs=3,ke=class{static{l(this,"PrjctDatabase")}connections=new Map;accessOrder=[];getDbPath(t){return Vn.join(D.getGlobalProjectPath(t),"prjct.db")}getDb(t){let e=this.connections.get(t);if(e)return this.touchAccessOrder(t),e;this.connections.size>=Xs&&this.evictLru();let r=this.getDbPath(t),n=Vn.dirname(r);Ee.existsSync(n)||Ee.mkdirSync(n,{recursive:!0});let s=Us(r);return s.run("PRAGMA journal_mode = WAL"),s.run("PRAGMA synchronous = NORMAL"),s.run("PRAGMA cache_size = -2000"),s.run("PRAGMA temp_store = MEMORY"),s.run("PRAGMA mmap_size = 33554432"),this.runMigrations(s),this.connections.set(t,s),this.touchAccessOrder(t),s}close(t){if(t){let e=this.connections.get(t);e&&(e.close(),this.connections.delete(t),this.accessOrder=this.accessOrder.filter(r=>r!==t))}else this.connections.forEach(e=>{e.close()}),this.connections.clear(),this.accessOrder=[]}touchAccessOrder(t){this.accessOrder=this.accessOrder.filter(e=>e!==t),this.accessOrder.push(t)}evictLru(){if(this.accessOrder.length===0)return;let t=this.accessOrder.shift(),e=this.connections.get(t);e&&(e.close(),this.connections.delete(t))}checkpointAll(){for(let[t,e]of this.connections)try{e.run("PRAGMA wal_checkpoint(TRUNCATE)")}catch{}}exists(t){return Ee.existsSync(this.getDbPath(t))}getDoc(t,e){let n=this.getDb(t).prepare("SELECT data FROM kv_store WHERE key = ?").get(e);return n?JSON.parse(n.data):null}setDoc(t,e,r){let n=this.getDb(t),s=JSON.stringify(r),o=new Date().toISOString();n.prepare("INSERT OR REPLACE INTO kv_store (key, data, updated_at) VALUES (?, ?, ?)").run(e,s,o)}deleteDoc(t,e){this.getDb(t).prepare("DELETE FROM kv_store WHERE key = ?").run(e)}hasDoc(t,e){return this.getDb(t).prepare("SELECT 1 FROM kv_store WHERE key = ?").get(e)!==null}appendEvent(t,e,r,n){let s=this.getDb(t),o=new Date().toISOString();s.prepare("INSERT INTO events (type, task_id, data, timestamp) VALUES (?, ?, ?, ?)").run(e,n??null,JSON.stringify(r),o)}getEvents(t,e,r=100){let n=this.getDb(t);return e?n.prepare("SELECT * FROM events WHERE type = ? ORDER BY id DESC LIMIT ?").all(e,r):n.prepare("SELECT * FROM events ORDER BY id DESC LIMIT ?").all(r)}query(t,e,...r){return this.getDb(t).prepare(e).all(...r)}run(t,e,...r){this.getDb(t).prepare(e).run(...r)}get(t,e,...r){return this.getDb(t).prepare(e).get(...r)??null}transaction(t,e){let r=this.getDb(t);return r.transaction(e)(r)}runMigrations(t){t.run(`
|
|
484
495
|
CREATE TABLE IF NOT EXISTS _migrations (
|
|
485
496
|
version INTEGER PRIMARY KEY,
|
|
486
497
|
name TEXT NOT NULL,
|
|
@@ -536,7 +547,7 @@ Context: ${n}`:""}`,tags:o,userTriggered:!0,topicKey:`preference:${e}`})}async f
|
|
|
536
547
|
Compactions: ${n.compactions}`];if(s.length>0){o.push(`
|
|
537
548
|
### Recent Transitions (${s.length})`);for(let a of s){let c=a.action?` \u2192 ${a.action}`:"";o.push(`- ${a.from} \u2192 ${a.to} (${a.usagePercent}%${c}) at ${a.timestamp}`)}}return{content:[{type:"text",text:o.join(`
|
|
538
549
|
`)}]}})),t.tool("prjct_audit_log","Recent history events (decisions, preferences, task actions)",{projectPath:At.string().describe("Project directory path"),limit:At.number().optional().default(20).describe("Max events to return (default 20)")},y("prjct_audit_log",async e=>{let r=await b(e.projectPath),n=await G.getRecentHistory(r,e.limit);if(!n||n.length===0)return{content:[{type:"text",text:"No history events found."}]};let s=[`## Audit Log (${n.length} events)`,""];for(let o of n){let a=o.type||"unknown",c=o.timestamp||"",u=Object.entries(o).filter(([p])=>p!=="type"&&p!=="timestamp").map(([p,d])=>`${p}=${typeof d=="string"?d:JSON.stringify(d)}`).join(", ");s.push(`- [${a}] ${u}${c?` (${c})`:""}`)}return{content:[{type:"text",text:s.join(`
|
|
539
|
-
`)}]}}))}l(gr,"registerContextTools");import{z as yt}from"zod";de();import{z as m}from"zod";var yo=m.enum(["low","medium","high","critical"]),te=m.enum(["feature","bug","improvement","chore"]),To=m.enum(["active","backlog","previously_active"]),wo=m.enum(["pending","in_progress","completed","blocked","paused","failed","skipped"]),bo=m.enum(["task_completed","feature_shipped","idea_captured","session_started"]),We=m.object({title:m.string(),description:m.string(),filesChanged:m.array(m.object({path:m.string(),action:m.enum(["created","modified","deleted"])})),whatWasDone:m.array(m.string()).min(1),outputForNextAgent:m.string().min(1),notes:m.string().optional()}),hr=m.object({output:m.string().min(1,"Subtask output is required"),summary:We}),yr=m.object({id:m.string(),description:m.string(),domain:m.string(),agent:m.string(),status:wo,dependsOn:m.array(m.string()),startedAt:m.string().optional(),completedAt:m.string().optional(),output:m.string().optional(),summary:We.optional(),skipReason:m.string().optional(),blockReason:m.string().optional(),estimatedPoints:m.number().optional(),estimatedMinutes:m.number().optional()}),Tr=m.object({completed:m.number(),total:m.number(),percentage:m.number()}),Xe=m.object({id:m.string(),description:m.string(),type:te.optional(),startedAt:m.string(),sessionId:m.string(),featureId:m.string().optional(),subtasks:m.array(yr).optional(),currentSubtaskIndex:m.number().optional(),subtaskProgress:Tr.optional(),linearId:m.string().optional(),linearUuid:m.string().optional(),estimatedPoints:m.number().optional(),estimatedMinutes:m.number().optional(),modelMetadata:Wt.optional(),tokensIn:m.number().optional(),tokensOut:m.number().optional(),parentDescription:m.string().optional(),branch:m.string().optional(),prUrl:m.string().optional()}),fr=m.object({id:m.string(),description:m.string(),status:m.literal("paused"),startedAt:m.string(),pausedAt:m.string(),pauseReason:m.string().optional(),type:te.optional(),sessionId:m.string().optional(),featureId:m.string().optional(),subtasks:m.array(yr).optional(),currentSubtaskIndex:m.number().optional(),subtaskProgress:Tr.optional(),linearId:m.string().optional(),linearUuid:m.string().optional(),estimatedPoints:m.number().optional(),estimatedMinutes:m.number().optional(),modelMetadata:Wt.optional(),tokensIn:m.number().optional(),tokensOut:m.number().optional()}),Eo=m.object({stackConfirmed:m.array(m.string()).optional(),patternsDiscovered:m.array(m.string()).optional(),agentAccuracy:m.array(m.object({agent:m.string(),rating:m.enum(["helpful","neutral","inaccurate"]),note:m.string().optional()})).optional(),issuesEncountered:m.array(m.string()).optional()}),ko=m.object({taskId:m.string(),title:m.string(),classification:te,startedAt:m.string(),completedAt:m.string(),subtaskCount:m.number(),subtaskSummaries:m.array(We),outcome:m.string(),branchName:m.string(),linearId:m.string().optional(),linearUuid:m.string().optional(),prUrl:m.string().optional(),feedback:Eo.optional(),tokensIn:m.number().optional(),tokensOut:m.number().optional()}),So=Xe.extend({workspaceId:m.string(),worktreePath:m.string().optional(),agentSessionId:m.string().optional(),jiraId:m.string().optional(),jiraUuid:m.string().optional(),dispatchedFrom:m.string().optional()}),wr=m.object({currentTask:Xe.nullable(),previousTask:fr.nullable().optional(),pausedTasks:m.array(fr).optional(),taskHistory:m.array(ko).optional(),activeTasks:m.array(So).optional(),lastUpdated:m.string()}),br=m.object({id:m.string(),description:m.string(),priority:yo,type:te,featureId:m.string().optional(),originFeature:m.string().optional(),completed:m.boolean(),completedAt:m.string().optional(),createdAt:m.string(),section:To,agent:m.string().optional(),groupName:m.string().optional(),groupId:m.string().optional()}),Er=m.object({tasks:m.array(br),lastUpdated:m.string()}),xo=m.object({tasksToday:m.number(),tasksThisWeek:m.number(),streak:m.number(),velocity:m.string(),avgDuration:m.string()}),_o=m.object({type:bo,description:m.string(),timestamp:m.string(),duration:m.string().optional()}),Zu=m.object({projectId:m.string(),currentTask:Xe.nullable(),queue:m.array(br),stats:xo,recentActivity:m.array(_o),lastSync:m.string()});W();var Ct={idle:{transitions:["task","next"],prompt:"p. task <description> Start working",description:"No active task"},working:{transitions:["done","pause"],prompt:"p. done Complete task | p. pause Switch context",description:"Task in progress"},paused:{transitions:["resume","task","ship"],prompt:"p. resume Continue | p. task <new> Start different | p. ship Ship directly",description:"Task paused"},completed:{transitions:["ship","task","next","pause","reopen"],prompt:"p. ship Ship it | p. task <next> Start next | p. reopen Reopen for rework",description:"Task completed"},shipped:{transitions:["task","next"],prompt:"p. task <description> Start new task",description:"Feature shipped"}},Be=class{static{l(this,"WorkflowStateMachine")}getCurrentState(t,e){let r=null;if(e&&t?.activeTasks?.length&&(r=t.activeTasks.find(s=>s.workspaceId===e)),r||(r=t?.currentTask),!r)return(t?.pausedTasks?.length||0)>0||t?.previousTask?.status==="paused"?"paused":"idle";switch((typeof r.status=="string"?r.status:"").toLowerCase()){case"in_progress":case"working":return"working";case"paused":return"paused";case"completed":case"done":return"completed";case"shipped":return"shipped";default:return r?"working":"idle"}}canTransition(t,e){let r=Ct[t];if(r.transitions.includes(e))return{valid:!0};let n=r.transitions.map(s=>`p. ${s}`).join(", ");return{valid:!1,error:`Cannot run 'p. ${e}' in ${t} state`,suggestion:`Valid commands: ${n}`}}getNextState(t,e){switch(e){case"task":return"working";case"done":return"completed";case"pause":return"paused";case"resume":return"working";case"ship":return"shipped";case"reopen":return"working";case"next":return t;default:return t}}getStateInfo(t){return Ct[t]}getPrompt(t){return Ct[t].prompt}getValidCommands(t){return Ct[t].transitions}formatNextSteps(t){return Ct[t].transitions.map(r=>{switch(r){case"task":return"p. task <desc> Start new task";case"done":return"p. done Complete current task";case"pause":return"p. pause Pause and switch context";case"resume":return"p. resume Continue paused task";case"ship":return"p. ship Ship the feature";case"reopen":return"p. reopen Reopen for rework";case"next":return"p. next View task queue";default:return`p. ${r}`}})}},He=new Be;W();var ee={SHIPPED_RETENTION_DAYS:90,IDEA_DORMANT_DAYS:180,QUEUE_COMPLETED_DAYS:7,PAUSED_TASK_DAYS:30,MEMORY_MAX_ENTRIES:500},Ge=class{static{l(this,"ArchiveStorage")}archive(t,e){let r=F(),n=f();return _.run(t,"INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)",r,e.entityType,e.entityId,JSON.stringify(e.entityData),e.summary??null,n,e.reason),r}archiveMany(t,e){if(e.length===0)return 0;let r=f();return _.transaction(t,n=>{let s=n.prepare("INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)");for(let o of e)s.run(F(),o.entityType,o.entityId,JSON.stringify(o.entityData),o.summary??null,r,o.reason)}),e.length}getArchived(t,e,r=50){return e?_.query(t,"SELECT * FROM archives WHERE entity_type = ? ORDER BY archived_at DESC LIMIT ?",e,r):_.query(t,"SELECT * FROM archives ORDER BY archived_at DESC LIMIT ?",r)}getStats(t){let e=_.query(t,"SELECT entity_type, COUNT(*) as count FROM archives GROUP BY entity_type"),r={shipped:0,idea:0,queue_task:0,paused_task:0,memory_entry:0,total:0};for(let n of e){let s=n.entity_type;s in r&&(r[s]=n.count),r.total+=n.count}return r}restore(t,e){let r=_.get(t,"SELECT * FROM archives WHERE id = ?",e);return r?(_.run(t,"DELETE FROM archives WHERE id = ?",e),JSON.parse(r.entity_data)):null}pruneOldArchives(t,e){let r=new Date(Date.now()-e*24*60*60*1e3).toISOString(),n=this.getTotalCount(t);_.run(t,"DELETE FROM archives WHERE archived_at < ?",r);let s=this.getTotalCount(t);return n-s}getTotalCount(t){return _.get(t,"SELECT COUNT(*) as count FROM archives")?.count??0}},St=new Ge;W();st();var qe=class{static{l(this,"SyncEventBus")}async publish(t){let e=D.getSyncPendingPath(t.projectId),r=await Ut(e,[])??[];r.push(t),await rt(e,r)}async getPending(t){let e=D.getSyncPendingPath(t);return await Ut(e,[])??[]}async clearPending(t){let e=D.getSyncPendingPath(t);await rt(e,[])}async updateLastSync(t){let e=D.getLastSyncPath(t),r={timestamp:f(),success:!0};await rt(e,r)}async getLastSync(t){let e=D.getLastSyncPath(t);return await Ut(e,null)}},kr=new qe;me();W();var pt=class{static{l(this,"StorageManager")}filename;cache;constructor(t,e){this.filename=t,this.cache=new Xt({ttl:5e3,maxSize:50})}getStoreKey(){return this.filename.replace(".json","")}async read(t){let e=this.cache.get(t);if(e!==null)return e;try{let r=_.getDoc(t,this.getStoreKey());if(r!==null)return this.cache.set(t,r),r}catch{}return this.getDefault()}async write(t,e){_.setDoc(t,this.getStoreKey(),e),this.cache.set(t,e)}async update(t,e){let r=await this.read(t),n=e(r);return await this.write(t,n),n}async publishEvent(t,e,r){let n={type:e,path:[this.filename.replace(".json","")],data:r,timestamp:f(),projectId:t};await kr.publish(n)}async publishEntityEvent(t,e,r,n){let s=`${e}.${r}`,o={...n,timestamp:f()};await this.publishEvent(t,s,o)}async exists(t){try{return _.hasDoc(t,this.getStoreKey())}catch{return!1}}clearCache(t){t?this.cache.delete(t):this.cache.clear()}getCacheStats(){return this.cache.stats()}};var ze=class extends pt{static{l(this,"StateStorage")}constructor(){super("state.json",wr)}getDefault(){return{currentTask:null,previousTask:null,pausedTasks:[],taskHistory:[],activeTasks:[],lastUpdated:""}}getEventType(t){return`state.${t}d`}validateTransition(t,e){let r=He.getCurrentState(t),n=He.canTransition(r,e);if(!n.valid)throw new Error(`${n.error}. ${n.suggestion||""}`.trim())}async getCurrentTask(t){return(await this.read(t)).currentTask}async startTask(t,e){let r=await this.read(t);this.validateTransition(r,"task");let n={...e,startedAt:f()};return await this.update(t,s=>({...s,currentTask:n,lastUpdated:f()})),await this.publishEvent(t,"task.started",{taskId:n.id,description:n.description,startedAt:n.startedAt,sessionId:n.sessionId}),n}async updateCurrentTask(t,e){let r=await this.read(t);if(!r.currentTask)return null;let n={...r.currentTask,...e};return await this.update(t,s=>({...s,currentTask:n,lastUpdated:f()})),n}async completeTask(t,e){let r=await this.read(t),n=r.currentTask;if(!n)return null;this.validateTransition(r,"done");let s=f(),o=this.createTaskHistoryEntry(n,s,e),a=this.getTaskHistoryFromState(r),c=[o,...a].slice(0,this.maxTaskHistory);return await this.update(t,u=>({...u,currentTask:null,previousTask:null,taskHistory:c,lastUpdated:s})),await this.publishEvent(t,"task.completed",{taskId:n.id,description:n.description,startedAt:n.startedAt,completedAt:s}),n}createTaskHistoryEntry(t,e,r){let n=(t.subtasks||[]).filter(a=>a.status==="completed"&&a.summary).map(a=>a.summary),s=n.length>0?n.map(a=>a.title).join(", "):"Task completed",o={taskId:t.id,title:t.parentDescription||t.description,classification:t.type||"improvement",startedAt:t.startedAt,completedAt:e,subtaskCount:t.subtasks?.length||0,subtaskSummaries:n,outcome:s,branchName:t.branch||"unknown",linearId:t.linearId,linearUuid:t.linearUuid,prUrl:t.prUrl};return r&&(o.feedback=r),t.tokensIn&&(o.tokensIn=t.tokensIn),t.tokensOut&&(o.tokensOut=t.tokensOut),o}maxPausedTasks=5;maxTaskHistory=20;stalenessThresholdDays=30;async pauseTask(t,e){let r=await this.read(t);if(!r.currentTask)return null;this.validateTransition(r,"pause");let n={...r.currentTask,status:"paused",pausedAt:f(),pauseReason:e},s=this.getPausedTasksFromState(r),o=[n,...s].slice(0,this.maxPausedTasks);return await this.update(t,a=>({...a,currentTask:null,previousTask:null,pausedTasks:o,lastUpdated:f()})),await this.publishEvent(t,"task.paused",{taskId:n.id,description:n.description,pausedAt:n.pausedAt,reason:e,pausedCount:o.length}),n}async resumeTask(t,e){let r=await this.read(t),n=this.getPausedTasksFromState(r);if(n.length===0)return null;this.validateTransition(r,"resume");let s=0;if(e&&(s=n.findIndex(h=>h.id===e),s===-1))return null;let o=n[s],a=n.filter((h,j)=>j!==s),{status:c,pausedAt:u,pauseReason:p,...d}=o,g={...d,startedAt:f(),sessionId:o.sessionId??F()};return await this.update(t,h=>({...h,currentTask:g,previousTask:null,pausedTasks:a,lastUpdated:f()})),await this.publishEvent(t,"task.resumed",{taskId:g.id,description:g.description,resumedAt:g.startedAt,remainingPaused:a.length}),g}getPausedTasksFromState(t){return t.pausedTasks&&t.pausedTasks.length>0?t.pausedTasks:t.previousTask?[t.previousTask]:[]}getTaskHistoryFromState(t){return t.taskHistory||[]}async getStalePausedTasks(t){let e=await this.read(t),r=this.getPausedTasksFromState(e),n=Date.now()-this.stalenessThresholdDays*24*60*60*1e3;return r.filter(s=>new Date(s.pausedAt).getTime()<n)}async archiveStalePausedTasks(t){let e=await this.read(t),r=this.getPausedTasksFromState(e),n=Date.now()-this.stalenessThresholdDays*24*60*60*1e3,s=r.filter(a=>new Date(a.pausedAt).getTime()<n),o=r.filter(a=>new Date(a.pausedAt).getTime()>=n);if(s.length===0)return[];St.archiveMany(t,s.map(a=>({entityType:"paused_task",entityId:a.id,entityData:a,summary:a.description,reason:"staleness"}))),await this.update(t,a=>({...a,pausedTasks:o,previousTask:null,lastUpdated:f()}));for(let a of s)await this.publishEvent(t,"task.archived",{taskId:a.id,description:a.description,pausedAt:a.pausedAt,reason:"staleness"});return s}async clearTask(t){await this.update(t,()=>({currentTask:null,previousTask:null,pausedTasks:[],activeTasks:[],lastUpdated:f()}))}async hasTask(t){let e=await this.read(t),r=this.getPausedTasksFromState(e);return e.currentTask!==null||r.length>0}async getPausedTask(t){let e=await this.read(t);return this.getPausedTasksFromState(e)[0]||null}async getAllPausedTasks(t){let e=await this.read(t);return this.getPausedTasksFromState(e)}async getTaskHistory(t){let e=await this.read(t);return this.getTaskHistoryFromState(e)}async getMostRecentTask(t){let e=await this.read(t);return this.getTaskHistoryFromState(e)[0]||null}async getTaskHistoryByType(t,e){let r=await this.read(t);return this.getTaskHistoryFromState(r).filter(s=>s.classification===e)}async getAggregatedFeedback(t){let r=(await this.getTaskHistory(t)).filter(g=>g.feedback),n=[],s=[],o=[],a=[];for(let g of r){let h=g.feedback;Array.isArray(h.stackConfirmed)&&n.push(...h.stackConfirmed),Array.isArray(h.patternsDiscovered)&&s.push(...h.patternsDiscovered),Array.isArray(h.agentAccuracy)&&o.push(...h.agentAccuracy),Array.isArray(h.issuesEncountered)&&a.push(...h.issuesEncountered)}let c=[...new Set(n)],u=[...new Set(s)],p=new Map;for(let g of a)p.set(g,(p.get(g)||0)+1);let d=[...p.entries()].filter(([g,h])=>h>=2).map(([g])=>g);return{stackConfirmed:c,patternsDiscovered:u,agentAccuracy:o,issuesEncountered:[...new Set(a)],knownGotchas:d}}async startTaskInWorkspace(t,e,r){let n={...e,workspaceId:r,startedAt:f()};return await this.update(t,s=>({...s,activeTasks:[...s.activeTasks||[],n],lastUpdated:f()})),await this.publishEvent(t,"task.started",{taskId:n.id,description:n.description,startedAt:n.startedAt,sessionId:n.sessionId,workspaceId:r}),n}async getCurrentTaskForWorkspace(t,e){return((await this.read(t)).activeTasks||[]).find(n=>n.workspaceId===e)??null}async completeTaskInWorkspace(t,e,r){let n=await this.read(t),o=(n.activeTasks||[]).find(d=>d.workspaceId===e);if(!o)return null;let a=f(),c=this.createTaskHistoryEntry(o,a,r),u=this.getTaskHistoryFromState(n),p=[c,...u].slice(0,this.maxTaskHistory);return await this.update(t,d=>({...d,activeTasks:(d.activeTasks||[]).filter(g=>g.workspaceId!==e),taskHistory:p,lastUpdated:a})),await this.publishEvent(t,"task.completed",{taskId:o.id,description:o.description,startedAt:o.startedAt,completedAt:a,workspaceId:e}),o}async getActiveTasks(t){return(await this.read(t)).activeTasks||[]}async getActiveTaskCount(t){return((await this.read(t)).activeTasks||[]).length}async updateWorkspaceTask(t,e,r){let s=(await this.read(t)).activeTasks||[],o=s.findIndex(c=>c.workspaceId===e);if(o===-1)return null;let a={...s[o],...r,workspaceId:e};return await this.update(t,c=>{let u=[...c.activeTasks||[]];return u[o]=a,{...c,activeTasks:u,lastUpdated:f()}}),a}async addTokens(t,e,r){let n=await this.read(t);if(!n.currentTask)return null;let s=(n.currentTask.tokensIn||0)+e,o=(n.currentTask.tokensOut||0)+r;return await this.update(t,a=>({...a,currentTask:{...a.currentTask,tokensIn:s,tokensOut:o},lastUpdated:f()})),{tokensIn:s,tokensOut:o}}async createSubtasks(t,e){let r=await this.read(t);if(!r.currentTask)return;let n=e.map((s,o)=>({...s,status:o===0?"in_progress":"pending",startedAt:o===0?f():void 0,dependsOn:s.dependsOn||[]}));await this.update(t,s=>({...s,currentTask:{...s.currentTask,subtasks:n,currentSubtaskIndex:0,subtaskProgress:{completed:0,total:n.length,percentage:0}},lastUpdated:f()})),await this.publishEvent(t,"subtasks.created",{taskId:r.currentTask.id,subtaskCount:n.length,subtasks:n.map(s=>({id:s.id,description:s.description,domain:s.domain}))})}async completeSubtask(t,e){let r=hr.safeParse(e);if(!r.success){let j=r.error.issues.map(w=>`${w.path.join(".")}: ${w.message}`);throw new Error(`Subtask completion requires handoff data:
|
|
550
|
+
`)}]}}))}l(gr,"registerContextTools");import{z as yt}from"zod";de();import{z as m}from"zod";var yo=m.enum(["low","medium","high","critical"]),te=m.enum(["feature","bug","improvement","chore"]),To=m.enum(["active","backlog","previously_active"]),wo=m.enum(["pending","in_progress","completed","blocked","paused","failed","skipped"]),bo=m.enum(["task_completed","feature_shipped","idea_captured","session_started"]),We=m.object({title:m.string(),description:m.string(),filesChanged:m.array(m.object({path:m.string(),action:m.enum(["created","modified","deleted"])})),whatWasDone:m.array(m.string()).min(1),outputForNextAgent:m.string().min(1),notes:m.string().optional()}),hr=m.object({output:m.string().min(1,"Subtask output is required"),summary:We}),yr=m.object({id:m.string(),description:m.string(),domain:m.string(),agent:m.string(),status:wo,dependsOn:m.array(m.string()),startedAt:m.string().optional(),completedAt:m.string().optional(),output:m.string().optional(),summary:We.optional(),skipReason:m.string().optional(),blockReason:m.string().optional(),estimatedPoints:m.number().optional(),estimatedMinutes:m.number().optional()}),Tr=m.object({completed:m.number(),total:m.number(),percentage:m.number()}),Xe=m.object({id:m.string(),description:m.string(),type:te.optional(),startedAt:m.string(),sessionId:m.string(),featureId:m.string().optional(),subtasks:m.array(yr).optional(),currentSubtaskIndex:m.number().optional(),subtaskProgress:Tr.optional(),linearId:m.string().optional(),linearUuid:m.string().optional(),estimatedPoints:m.number().optional(),estimatedMinutes:m.number().optional(),modelMetadata:Wt.optional(),tokensIn:m.number().optional(),tokensOut:m.number().optional(),parentDescription:m.string().optional(),branch:m.string().optional(),prUrl:m.string().optional()}),fr=m.object({id:m.string(),description:m.string(),status:m.literal("paused"),startedAt:m.string(),pausedAt:m.string(),pauseReason:m.string().optional(),type:te.optional(),sessionId:m.string().optional(),featureId:m.string().optional(),subtasks:m.array(yr).optional(),currentSubtaskIndex:m.number().optional(),subtaskProgress:Tr.optional(),linearId:m.string().optional(),linearUuid:m.string().optional(),estimatedPoints:m.number().optional(),estimatedMinutes:m.number().optional(),modelMetadata:Wt.optional(),tokensIn:m.number().optional(),tokensOut:m.number().optional()}),Eo=m.object({stackConfirmed:m.array(m.string()).optional(),patternsDiscovered:m.array(m.string()).optional(),agentAccuracy:m.array(m.object({agent:m.string(),rating:m.enum(["helpful","neutral","inaccurate"]),note:m.string().optional()})).optional(),issuesEncountered:m.array(m.string()).optional()}),ko=m.object({taskId:m.string(),title:m.string(),classification:te,startedAt:m.string(),completedAt:m.string(),subtaskCount:m.number(),subtaskSummaries:m.array(We),outcome:m.string(),branchName:m.string(),linearId:m.string().optional(),linearUuid:m.string().optional(),prUrl:m.string().optional(),feedback:Eo.optional(),tokensIn:m.number().optional(),tokensOut:m.number().optional()}),So=Xe.extend({workspaceId:m.string(),worktreePath:m.string().optional(),agentSessionId:m.string().optional(),jiraId:m.string().optional(),jiraUuid:m.string().optional(),dispatchedFrom:m.string().optional()}),wr=m.object({currentTask:Xe.nullable(),previousTask:fr.nullable().optional(),pausedTasks:m.array(fr).optional(),taskHistory:m.array(ko).optional(),activeTasks:m.array(So).optional(),lastUpdated:m.string()}),br=m.object({id:m.string(),description:m.string(),body:m.string().optional(),priority:yo,type:te,featureId:m.string().optional(),originFeature:m.string().optional(),completed:m.boolean(),completedAt:m.string().optional(),createdAt:m.string(),section:To,agent:m.string().optional(),groupName:m.string().optional(),groupId:m.string().optional()}),Er=m.object({tasks:m.array(br),lastUpdated:m.string()}),xo=m.object({tasksToday:m.number(),tasksThisWeek:m.number(),streak:m.number(),velocity:m.string(),avgDuration:m.string()}),_o=m.object({type:bo,description:m.string(),timestamp:m.string(),duration:m.string().optional()}),Zu=m.object({projectId:m.string(),currentTask:Xe.nullable(),queue:m.array(br),stats:xo,recentActivity:m.array(_o),lastSync:m.string()});W();var Ct={idle:{transitions:["task","next"],prompt:"p. task <description> Start working",description:"No active task"},working:{transitions:["done","pause"],prompt:"p. done Complete task | p. pause Switch context",description:"Task in progress"},paused:{transitions:["resume","task","ship"],prompt:"p. resume Continue | p. task <new> Start different | p. ship Ship directly",description:"Task paused"},completed:{transitions:["ship","task","next","pause","reopen"],prompt:"p. ship Ship it | p. task <next> Start next | p. reopen Reopen for rework",description:"Task completed"},shipped:{transitions:["task","next"],prompt:"p. task <description> Start new task",description:"Feature shipped"}},Be=class{static{l(this,"WorkflowStateMachine")}getCurrentState(t,e){let r=null;if(e&&t?.activeTasks?.length&&(r=t.activeTasks.find(s=>s.workspaceId===e)),r||(r=t?.currentTask),!r)return(t?.pausedTasks?.length||0)>0||t?.previousTask?.status==="paused"?"paused":"idle";switch((typeof r.status=="string"?r.status:"").toLowerCase()){case"in_progress":case"working":return"working";case"paused":return"paused";case"completed":case"done":return"completed";case"shipped":return"shipped";default:return r?"working":"idle"}}canTransition(t,e){let r=Ct[t];if(r.transitions.includes(e))return{valid:!0};let n=r.transitions.map(s=>`p. ${s}`).join(", ");return{valid:!1,error:`Cannot run 'p. ${e}' in ${t} state`,suggestion:`Valid commands: ${n}`}}getNextState(t,e){switch(e){case"task":return"working";case"done":return"completed";case"pause":return"paused";case"resume":return"working";case"ship":return"shipped";case"reopen":return"working";case"next":return t;default:return t}}getStateInfo(t){return Ct[t]}getPrompt(t){return Ct[t].prompt}getValidCommands(t){return Ct[t].transitions}formatNextSteps(t){return Ct[t].transitions.map(r=>{switch(r){case"task":return"p. task <desc> Start new task";case"done":return"p. done Complete current task";case"pause":return"p. pause Pause and switch context";case"resume":return"p. resume Continue paused task";case"ship":return"p. ship Ship the feature";case"reopen":return"p. reopen Reopen for rework";case"next":return"p. next View task queue";default:return`p. ${r}`}})}},He=new Be;W();var ee={SHIPPED_RETENTION_DAYS:90,IDEA_DORMANT_DAYS:180,QUEUE_COMPLETED_DAYS:7,PAUSED_TASK_DAYS:30,MEMORY_MAX_ENTRIES:500},Ge=class{static{l(this,"ArchiveStorage")}archive(t,e){let r=F(),n=f();return _.run(t,"INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)",r,e.entityType,e.entityId,JSON.stringify(e.entityData),e.summary??null,n,e.reason),r}archiveMany(t,e){if(e.length===0)return 0;let r=f();return _.transaction(t,n=>{let s=n.prepare("INSERT INTO archives (id, entity_type, entity_id, entity_data, summary, archived_at, reason) VALUES (?, ?, ?, ?, ?, ?, ?)");for(let o of e)s.run(F(),o.entityType,o.entityId,JSON.stringify(o.entityData),o.summary??null,r,o.reason)}),e.length}getArchived(t,e,r=50){return e?_.query(t,"SELECT * FROM archives WHERE entity_type = ? ORDER BY archived_at DESC LIMIT ?",e,r):_.query(t,"SELECT * FROM archives ORDER BY archived_at DESC LIMIT ?",r)}getStats(t){let e=_.query(t,"SELECT entity_type, COUNT(*) as count FROM archives GROUP BY entity_type"),r={shipped:0,idea:0,queue_task:0,paused_task:0,memory_entry:0,total:0};for(let n of e){let s=n.entity_type;s in r&&(r[s]=n.count),r.total+=n.count}return r}restore(t,e){let r=_.get(t,"SELECT * FROM archives WHERE id = ?",e);return r?(_.run(t,"DELETE FROM archives WHERE id = ?",e),JSON.parse(r.entity_data)):null}pruneOldArchives(t,e){let r=new Date(Date.now()-e*24*60*60*1e3).toISOString(),n=this.getTotalCount(t);_.run(t,"DELETE FROM archives WHERE archived_at < ?",r);let s=this.getTotalCount(t);return n-s}getTotalCount(t){return _.get(t,"SELECT COUNT(*) as count FROM archives")?.count??0}},St=new Ge;W();st();var qe=class{static{l(this,"SyncEventBus")}async publish(t){let e=D.getSyncPendingPath(t.projectId),r=await Ut(e,[])??[];r.push(t),await rt(e,r)}async getPending(t){let e=D.getSyncPendingPath(t);return await Ut(e,[])??[]}async clearPending(t){let e=D.getSyncPendingPath(t);await rt(e,[])}async updateLastSync(t){let e=D.getLastSyncPath(t),r={timestamp:f(),success:!0};await rt(e,r)}async getLastSync(t){let e=D.getLastSyncPath(t);return await Ut(e,null)}},kr=new qe;me();W();var pt=class{static{l(this,"StorageManager")}filename;cache;constructor(t,e){this.filename=t,this.cache=new Xt({ttl:5e3,maxSize:50})}getStoreKey(){return this.filename.replace(".json","")}async read(t){let e=this.cache.get(t);if(e!==null)return e;try{let r=_.getDoc(t,this.getStoreKey());if(r!==null)return this.cache.set(t,r),r}catch{}return this.getDefault()}async write(t,e){_.setDoc(t,this.getStoreKey(),e),this.cache.set(t,e)}async update(t,e){let r=await this.read(t),n=e(r);return await this.write(t,n),n}async publishEvent(t,e,r){let n={type:e,path:[this.filename.replace(".json","")],data:r,timestamp:f(),projectId:t};await kr.publish(n)}async publishEntityEvent(t,e,r,n){let s=`${e}.${r}`,o={...n,timestamp:f()};await this.publishEvent(t,s,o)}async exists(t){try{return _.hasDoc(t,this.getStoreKey())}catch{return!1}}clearCache(t){t?this.cache.delete(t):this.cache.clear()}getCacheStats(){return this.cache.stats()}};var ze=class extends pt{static{l(this,"StateStorage")}constructor(){super("state.json",wr)}getDefault(){return{currentTask:null,previousTask:null,pausedTasks:[],taskHistory:[],activeTasks:[],lastUpdated:""}}getEventType(t){return`state.${t}d`}validateTransition(t,e){let r=He.getCurrentState(t),n=He.canTransition(r,e);if(!n.valid)throw new Error(`${n.error}. ${n.suggestion||""}`.trim())}async getCurrentTask(t){return(await this.read(t)).currentTask}async startTask(t,e){let r=await this.read(t);this.validateTransition(r,"task");let n={...e,startedAt:f()};return await this.update(t,s=>({...s,currentTask:n,lastUpdated:f()})),await this.publishEvent(t,"task.started",{taskId:n.id,description:n.description,startedAt:n.startedAt,sessionId:n.sessionId}),n}async updateCurrentTask(t,e){let r=await this.read(t);if(!r.currentTask)return null;let n={...r.currentTask,...e};return await this.update(t,s=>({...s,currentTask:n,lastUpdated:f()})),n}async completeTask(t,e){let r=await this.read(t),n=r.currentTask;if(!n)return null;this.validateTransition(r,"done");let s=f(),o=this.createTaskHistoryEntry(n,s,e),a=this.getTaskHistoryFromState(r),c=[o,...a].slice(0,this.maxTaskHistory);return await this.update(t,u=>({...u,currentTask:null,previousTask:null,taskHistory:c,lastUpdated:s})),await this.publishEvent(t,"task.completed",{taskId:n.id,description:n.description,startedAt:n.startedAt,completedAt:s}),n}createTaskHistoryEntry(t,e,r){let n=(t.subtasks||[]).filter(a=>a.status==="completed"&&a.summary).map(a=>a.summary),s=n.length>0?n.map(a=>a.title).join(", "):"Task completed",o={taskId:t.id,title:t.parentDescription||t.description,classification:t.type||"improvement",startedAt:t.startedAt,completedAt:e,subtaskCount:t.subtasks?.length||0,subtaskSummaries:n,outcome:s,branchName:t.branch||"unknown",linearId:t.linearId,linearUuid:t.linearUuid,prUrl:t.prUrl};return r&&(o.feedback=r),t.tokensIn&&(o.tokensIn=t.tokensIn),t.tokensOut&&(o.tokensOut=t.tokensOut),o}maxPausedTasks=5;maxTaskHistory=20;stalenessThresholdDays=30;async pauseTask(t,e){let r=await this.read(t);if(!r.currentTask)return null;this.validateTransition(r,"pause");let n={...r.currentTask,status:"paused",pausedAt:f(),pauseReason:e},s=this.getPausedTasksFromState(r),o=[n,...s].slice(0,this.maxPausedTasks);return await this.update(t,a=>({...a,currentTask:null,previousTask:null,pausedTasks:o,lastUpdated:f()})),await this.publishEvent(t,"task.paused",{taskId:n.id,description:n.description,pausedAt:n.pausedAt,reason:e,pausedCount:o.length}),n}async resumeTask(t,e){let r=await this.read(t),n=this.getPausedTasksFromState(r);if(n.length===0)return null;this.validateTransition(r,"resume");let s=0;if(e&&(s=n.findIndex(h=>h.id===e),s===-1))return null;let o=n[s],a=n.filter((h,j)=>j!==s),{status:c,pausedAt:u,pauseReason:p,...d}=o,g={...d,startedAt:f(),sessionId:o.sessionId??F()};return await this.update(t,h=>({...h,currentTask:g,previousTask:null,pausedTasks:a,lastUpdated:f()})),await this.publishEvent(t,"task.resumed",{taskId:g.id,description:g.description,resumedAt:g.startedAt,remainingPaused:a.length}),g}getPausedTasksFromState(t){return t.pausedTasks&&t.pausedTasks.length>0?t.pausedTasks:t.previousTask?[t.previousTask]:[]}getTaskHistoryFromState(t){return t.taskHistory||[]}async getStalePausedTasks(t){let e=await this.read(t),r=this.getPausedTasksFromState(e),n=Date.now()-this.stalenessThresholdDays*24*60*60*1e3;return r.filter(s=>new Date(s.pausedAt).getTime()<n)}async archiveStalePausedTasks(t){let e=await this.read(t),r=this.getPausedTasksFromState(e),n=Date.now()-this.stalenessThresholdDays*24*60*60*1e3,s=r.filter(a=>new Date(a.pausedAt).getTime()<n),o=r.filter(a=>new Date(a.pausedAt).getTime()>=n);if(s.length===0)return[];St.archiveMany(t,s.map(a=>({entityType:"paused_task",entityId:a.id,entityData:a,summary:a.description,reason:"staleness"}))),await this.update(t,a=>({...a,pausedTasks:o,previousTask:null,lastUpdated:f()}));for(let a of s)await this.publishEvent(t,"task.archived",{taskId:a.id,description:a.description,pausedAt:a.pausedAt,reason:"staleness"});return s}async clearTask(t){await this.update(t,()=>({currentTask:null,previousTask:null,pausedTasks:[],activeTasks:[],lastUpdated:f()}))}async hasTask(t){let e=await this.read(t),r=this.getPausedTasksFromState(e);return e.currentTask!==null||r.length>0}async getPausedTask(t){let e=await this.read(t);return this.getPausedTasksFromState(e)[0]||null}async getAllPausedTasks(t){let e=await this.read(t);return this.getPausedTasksFromState(e)}async getTaskHistory(t){let e=await this.read(t);return this.getTaskHistoryFromState(e)}async getMostRecentTask(t){let e=await this.read(t);return this.getTaskHistoryFromState(e)[0]||null}async getTaskHistoryByType(t,e){let r=await this.read(t);return this.getTaskHistoryFromState(r).filter(s=>s.classification===e)}async getAggregatedFeedback(t){let r=(await this.getTaskHistory(t)).filter(g=>g.feedback),n=[],s=[],o=[],a=[];for(let g of r){let h=g.feedback;Array.isArray(h.stackConfirmed)&&n.push(...h.stackConfirmed),Array.isArray(h.patternsDiscovered)&&s.push(...h.patternsDiscovered),Array.isArray(h.agentAccuracy)&&o.push(...h.agentAccuracy),Array.isArray(h.issuesEncountered)&&a.push(...h.issuesEncountered)}let c=[...new Set(n)],u=[...new Set(s)],p=new Map;for(let g of a)p.set(g,(p.get(g)||0)+1);let d=[...p.entries()].filter(([g,h])=>h>=2).map(([g])=>g);return{stackConfirmed:c,patternsDiscovered:u,agentAccuracy:o,issuesEncountered:[...new Set(a)],knownGotchas:d}}async startTaskInWorkspace(t,e,r){let n={...e,workspaceId:r,startedAt:f()};return await this.update(t,s=>({...s,activeTasks:[...s.activeTasks||[],n],lastUpdated:f()})),await this.publishEvent(t,"task.started",{taskId:n.id,description:n.description,startedAt:n.startedAt,sessionId:n.sessionId,workspaceId:r}),n}async getCurrentTaskForWorkspace(t,e){return((await this.read(t)).activeTasks||[]).find(n=>n.workspaceId===e)??null}async completeTaskInWorkspace(t,e,r){let n=await this.read(t),o=(n.activeTasks||[]).find(d=>d.workspaceId===e);if(!o)return null;let a=f(),c=this.createTaskHistoryEntry(o,a,r),u=this.getTaskHistoryFromState(n),p=[c,...u].slice(0,this.maxTaskHistory);return await this.update(t,d=>({...d,activeTasks:(d.activeTasks||[]).filter(g=>g.workspaceId!==e),taskHistory:p,lastUpdated:a})),await this.publishEvent(t,"task.completed",{taskId:o.id,description:o.description,startedAt:o.startedAt,completedAt:a,workspaceId:e}),o}async getActiveTasks(t){return(await this.read(t)).activeTasks||[]}async getActiveTaskCount(t){return((await this.read(t)).activeTasks||[]).length}async updateWorkspaceTask(t,e,r){let s=(await this.read(t)).activeTasks||[],o=s.findIndex(c=>c.workspaceId===e);if(o===-1)return null;let a={...s[o],...r,workspaceId:e};return await this.update(t,c=>{let u=[...c.activeTasks||[]];return u[o]=a,{...c,activeTasks:u,lastUpdated:f()}}),a}async addTokens(t,e,r){let n=await this.read(t);if(!n.currentTask)return null;let s=(n.currentTask.tokensIn||0)+e,o=(n.currentTask.tokensOut||0)+r;return await this.update(t,a=>({...a,currentTask:{...a.currentTask,tokensIn:s,tokensOut:o},lastUpdated:f()})),{tokensIn:s,tokensOut:o}}async createSubtasks(t,e){let r=await this.read(t);if(!r.currentTask)return;let n=e.map((s,o)=>({...s,status:o===0?"in_progress":"pending",startedAt:o===0?f():void 0,dependsOn:s.dependsOn||[]}));await this.update(t,s=>({...s,currentTask:{...s.currentTask,subtasks:n,currentSubtaskIndex:0,subtaskProgress:{completed:0,total:n.length,percentage:0}},lastUpdated:f()})),await this.publishEvent(t,"subtasks.created",{taskId:r.currentTask.id,subtaskCount:n.length,subtasks:n.map(s=>({id:s.id,description:s.description,domain:s.domain}))})}async completeSubtask(t,e){let r=hr.safeParse(e);if(!r.success){let j=r.error.issues.map(w=>`${w.path.join(".")}: ${w.message}`);throw new Error(`Subtask completion requires handoff data:
|
|
540
551
|
${j.join(`
|
|
541
552
|
`)}`)}let{output:n,summary:s}=r.data,o=await this.read(t);if(!o.currentTask?.subtasks)return null;let a=o.currentTask.currentSubtaskIndex||0,c=o.currentTask.subtasks[a];if(!c)return null;let u=[...o.currentTask.subtasks];u[a]={...c,status:"completed",completedAt:f(),output:n,summary:s};let p=u.filter(j=>j.status==="completed").length,d=u.length,g=Math.round(p/d*100),h=a+1;return h<u.length&&(u[h]={...u[h],status:"in_progress",startedAt:f()}),await this.update(t,j=>({...j,currentTask:{...j.currentTask,subtasks:u,currentSubtaskIndex:h<d?h:a,subtaskProgress:{completed:p,total:d,percentage:g}},lastUpdated:f()})),await this.publishEvent(t,"subtask.completed",{taskId:o.currentTask.id,subtaskId:c.id,description:c.description,output:n,handoff:s.outputForNextAgent,filesChanged:s.filesChanged.length,progress:{completed:p,total:d,percentage:g}}),h<d?u[h]:null}async getCurrentSubtask(t){let e=await this.read(t);if(!e.currentTask?.subtasks)return null;let r=e.currentTask.currentSubtaskIndex||0;return e.currentTask.subtasks[r]||null}async getNextSubtask(t){let e=await this.read(t);if(!e.currentTask?.subtasks)return null;let r=(e.currentTask.currentSubtaskIndex||0)+1;return e.currentTask.subtasks[r]||null}async getPreviousSubtask(t){let e=await this.read(t);if(!e.currentTask?.subtasks)return null;let r=(e.currentTask.currentSubtaskIndex||0)-1;return r<0?null:e.currentTask.subtasks[r]||null}async getPreviousHandoff(t){let e=await this.getPreviousSubtask(t);return e?.summary?.outputForNextAgent?{fromSubtask:e.description,outputForNextAgent:e.summary.outputForNextAgent,filesChanged:e.summary.filesChanged,whatWasDone:e.summary.whatWasDone}:null}async getSubtasks(t){return(await this.read(t)).currentTask?.subtasks||[]}async getSubtaskProgress(t){return(await this.read(t)).currentTask?.subtaskProgress||null}async hasSubtasks(t){return((await this.read(t)).currentTask?.subtasks?.length||0)>0}async areAllSubtasksComplete(t){let e=await this.read(t);return e.currentTask?.subtasks?e.currentTask.subtasks.every(r=>r.status==="completed"||r.status==="failed"||r.status==="skipped"):!0}async failSubtask(t,e){let r=await this.read(t);if(!r.currentTask?.subtasks)return null;let n=r.currentTask.currentSubtaskIndex||0,s=r.currentTask.subtasks[n];if(!s)return null;let o=[...r.currentTask.subtasks];o[n]={...s,status:"failed",completedAt:f(),output:`Failed: ${e}`};let a=n+1,c=o.length;a<c&&(o[a]={...o[a],status:"in_progress",startedAt:f()});let u=o.filter(d=>d.status==="completed"||d.status==="failed"||d.status==="skipped").length,p=Math.round(u/c*100);return await this.update(t,d=>({...d,currentTask:{...d.currentTask,subtasks:o,currentSubtaskIndex:a<c?a:n,subtaskProgress:{completed:u,total:c,percentage:p}},lastUpdated:f()})),await this.publishEvent(t,"subtask.failed",{taskId:r.currentTask.id,subtaskId:s.id,description:s.description,error:e}),a<c?o[a]:null}async skipSubtask(t,e){let r=await this.read(t);if(!r.currentTask?.subtasks)return null;let n=r.currentTask.currentSubtaskIndex||0,s=r.currentTask.subtasks[n];if(!s)return null;let o=[...r.currentTask.subtasks];o[n]={...s,status:"skipped",completedAt:f(),output:`Skipped: ${e}`,skipReason:e};let a=n+1,c=o.length;a<c&&(o[a]={...o[a],status:"in_progress",startedAt:f()});let u=o.filter(d=>d.status==="completed"||d.status==="failed"||d.status==="skipped").length,p=Math.round(u/c*100);return await this.update(t,d=>({...d,currentTask:{...d.currentTask,subtasks:o,currentSubtaskIndex:a<c?a:n,subtaskProgress:{completed:u,total:c,percentage:p}},lastUpdated:f()})),await this.publishEvent(t,"subtask.skipped",{taskId:r.currentTask.id,subtaskId:s.id,description:s.description,reason:e}),a<c?o[a]:null}async blockSubtask(t,e){let r=await this.read(t);if(!r.currentTask?.subtasks)return null;let n=r.currentTask.currentSubtaskIndex||0,s=r.currentTask.subtasks[n];if(!s)return null;let o=[...r.currentTask.subtasks];o[n]={...s,status:"blocked",output:`Blocked: ${e}`,blockReason:e};let a=n+1,c=o.length;return a<c&&(o[a]={...o[a],status:"in_progress",startedAt:f()}),await this.update(t,u=>({...u,currentTask:{...u.currentTask,subtasks:o,currentSubtaskIndex:a<c?a:n},lastUpdated:f()})),await this.publishEvent(t,"subtask.blocked",{taskId:r.currentTask.id,subtaskId:s.id,description:s.description,blocker:e}),a<c?o[a]:null}},X=new ze;ft();ht();import vo from"node:fs/promises";import ne from"node:path";var Po={frontend:["component","page","view","ui","layout","style","css","scss","sass","hook","context","store","redux","zustand","react","vue","svelte","angular","next","nuxt","app","client"],backend:["api","route","controller","service","middleware","handler","resolver","schema","model","entity","repository","server","socket","graphql","rest","trpc"],database:["migration","seed","schema","model","entity","repository","prisma","drizzle","sequelize","typeorm","mongoose","knex","sql","db"],auth:["auth","login","logout","session","token","jwt","oauth","passport","credential","permission","role","user","account"],testing:["test","spec","e2e","integration","unit","mock","fixture","stub","jest","vitest","cypress","playwright"],config:["config","env","setting","constant","option","tsconfig","eslint","prettier","vite","webpack","rollup"],infra:["docker","compose","kubernetes","k8s","ci","cd","github","gitlab","jenkins","terraform","ansible","deploy"],util:["util","helper","lib","common","shared","core","base","abstract"]},jo=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".py",".go",".rs",".java",".kt",".swift",".rb",".php",".c",".cpp",".h",".hpp",".cs",".vue",".svelte"]),Ro=new Set(["node_modules",".git","dist","build",".next",".nuxt",".output","coverage",".cache","__pycache__",".pytest_cache","vendor","target",".turbo",".vercel"]);async function Sr(i,t,e={}){let r=Date.now(),n=e.maxFiles??30,s=e.minScore??.1,o=e.includeTests??!1,a=Do(i),c=await Ao(t),u=await Co(t),p=[];for(let g of c){if(!o&&Io(g))continue;let h=No(g,a,u,e.historicalBoosts);h.score>=s&&p.push(h)}p.sort((g,h)=>h.score-g.score);let d=p.slice(0,n);return{files:d,metrics:{filesScanned:c.length,filesReturned:d.length,scanDuration:Date.now()-r}}}l(Sr,"findRelevantFiles");function Do(i){let t=i.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),e=new Set(["a","an","the","and","or","but","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","must","shall","can","need","to","of","in","for","on","with","at","by","from","as","into","through","during","before","after","above","below","between","under","again","further","then","once","here","there","when","where","why","how","all","each","few","more","most","other","some","such","no","nor","not","only","own","same","so","than","too","very","just","add","create","make","implement","fix","update","change","modify","remove","delete","new"]);return t.filter(r=>!e.has(r)&&r.length>2)}l(Do,"extractKeywords");async function Ao(i){let t=[];async function e(r,n=""){try{let s=await vo.readdir(r,{withFileTypes:!0});for(let o of s){let a=ne.join(r,o.name),c=ne.join(n,o.name);if(o.isDirectory()){if(Ro.has(o.name)||o.name.startsWith("."))continue;await e(a,c)}else if(o.isFile()){let u=ne.extname(o.name).toLowerCase();jo.has(u)&&t.push(c)}}}catch(s){B(s)}}return l(e,"walk"),await e(i),t}l(Ao,"getAllCodeFiles");async function Co(i){let t=new Map;try{let{stdout:e}=await R(`git log -30 --pretty=format:"%H %ct" --name-only | awk '
|
|
542
553
|
/^[a-f0-9]{40}/ { commit=$1; timestamp=$2; next }
|
|
@@ -609,7 +620,7 @@ ${o.join(`
|
|
|
609
620
|
### Agent Accuracy`);for(let a of n.agentAccuracy)s.push(`- ${a.agent}: ${a.rating}${a.note?` \u2014 ${a.note}`:""}`)}if(n.issuesEncountered.length>0){s.push(`
|
|
610
621
|
### Issues Encountered`);for(let a of n.issuesEncountered)s.push(`- ${a}`)}return n.stackConfirmed.length===0&&n.patternsDiscovered.length===0&&n.knownGotchas.length===0&&s.push(`
|
|
611
622
|
No task feedback recorded yet.`),{content:[{type:"text",text:s.join(`
|
|
612
|
-
`)}]}}))}l(Nr,"registerMemoryTools");import Gr from"node:path";import{z as A}from"zod";import M from"node:fs/promises";import E from"node:path";var Ir={critical:0,high:1,medium:2,low:3},Mr={active:0,previously_active:1,backlog:2};function Or(i){return[...i].sort((t,e)=>{let r=Mr[t.section]-Mr[e.section];return r!==0?r:Ir[t.priority]-Ir[e.priority]})}l(Or,"sortBySectionAndPriority");W();var Qe=class extends pt{static{l(this,"QueueStorage")}constructor(){super("queue.json",Er)}getDefault(){return{tasks:[],lastUpdated:""}}getEventType(t){return`queue.${t}d`}async getTasks(t){return(await this.read(t)).tasks}async getActiveTasks(t){return(await this.read(t)).tasks.filter(r=>r.section==="active"&&!r.completed)}async getBacklog(t){return(await this.read(t)).tasks.filter(r=>r.section==="backlog"&&!r.completed)}async getNextTask(t){let e=await this.getActiveTasks(t);return Or(e)[0]||null}async addTask(t,e){let r={...e,id:F(),createdAt:f(),completed:!1};return await this.update(t,n=>({tasks:[...n.tasks,r],lastUpdated:f()})),await this.publishEvent(t,"queue.task_added",{taskId:r.id,description:r.description,priority:r.priority,section:r.section}),r}async addTasks(t,e){let r=f(),n=e.map(s=>({...s,id:F(),createdAt:r,completed:!1}));return await this.update(t,s=>({tasks:[...s.tasks,...n],lastUpdated:r})),await this.publishEvent(t,"queue.tasks_added",{count:n.length,tasks:n.map(s=>({id:s.id,description:s.description}))}),n}async removeTask(t,e){await this.update(t,r=>({tasks:r.tasks.filter(n=>n.id!==e),lastUpdated:f()})),await this.publishEvent(t,"queue.task_removed",{taskId:e})}async completeTask(t,e){let r=null;if(await this.update(t,n=>({tasks:n.tasks.map(o=>o.id===e?(r={...o,completed:!0,completedAt:f()},r):o),lastUpdated:f()})),r){let n=r;await this.publishEvent(t,"queue.task_completed",{taskId:e,description:n.description,completedAt:n.completedAt})}return r}async moveToSection(t,e,r){await this.update(t,n=>({tasks:n.tasks.map(s=>s.id===e?{...s,section:r}:s),lastUpdated:f()}))}async setPriority(t,e,r){await this.update(t,n=>({tasks:n.tasks.map(s=>s.id===e?{...s,priority:r}:s),lastUpdated:f()}))}async clearCompleted(t){let r=(await this.read(t)).tasks.filter(n=>n.completed).length;return await this.update(t,n=>({tasks:n.tasks.filter(s=>!s.completed),lastUpdated:f()})),r}async removeStaleCompleted(t){let e=await this.read(t),r=$t(ee.QUEUE_COMPLETED_DAYS),n=e.tasks.filter(o=>o.completed&&o.completedAt&&new Date(o.completedAt)<r);if(n.length===0)return 0;St.archiveMany(t,n.map(o=>({entityType:"queue_task",entityId:o.id,entityData:o,summary:o.description,reason:"age"})));let s=new Set(n.map(o=>o.id));return await this.update(t,o=>({tasks:o.tasks.filter(a=>!s.has(a.id)),lastUpdated:f()})),await this.publishEvent(t,"queue.stale_removed",{count:n.length}),n.length}},Nt=new Qe;import{z as v}from"zod";var Vo=v.enum(["feature","fix","improvement","refactor"]),Lr=v.enum(["pass","warning","fail","skipped"]),Yo=v.enum(["added","changed","fixed","removed"]),Ko=v.object({hours:v.number(),minutes:v.number(),totalMinutes:v.number()}),Jo=v.object({filesChanged:v.number().nullable().optional(),linesAdded:v.number().nullable().optional(),linesRemoved:v.number().nullable().optional(),commits:v.number().nullable().optional()}),Qo=v.object({description:v.string(),type:Yo.optional()}),Zo=v.object({lintStatus:Lr.nullable().optional(),lintDetails:v.string().optional(),testStatus:Lr.nullable().optional(),testDetails:v.string().optional()}),ti=v.object({hash:v.string().optional(),message:v.string().optional(),branch:v.string().optional()}),ei=v.object({id:v.string(),name:v.string(),version:v.string().nullable().optional(),type:Vo,agent:v.string().optional(),description:v.string().optional(),changes:v.array(Qo).optional(),codeSnippets:v.array(v.string()).optional(),commit:ti.optional(),codeMetrics:Jo.optional(),qualityMetrics:Zo.optional(),quantitativeImpact:v.string().optional(),duration:Ko.optional(),tasksCompleted:v.number().nullable().optional(),shippedAt:v.string(),featureId:v.string().optional()}),$r=v.object({shipped:v.array(ei),lastUpdated:v.string()});W();var Ze=class extends pt{static{l(this,"ShippedStorage")}constructor(){super("shipped.json",$r)}getDefault(){return{shipped:[],lastUpdated:""}}getEventType(t){return`shipped.${t}d`}async getAll(t){return(await this.read(t)).shipped}async getRecent(t,e=5){return(await this.read(t)).shipped.sort((n,s)=>new Date(s.shippedAt).getTime()-new Date(n.shippedAt).getTime()).slice(0,e)}async addShipped(t,e){let r={...e,id:F(),shippedAt:f()};return await this.update(t,n=>({shipped:[r,...n.shipped],lastUpdated:f()})),await this.publishEvent(t,"feature.shipped",{shipId:r.id,name:r.name,version:r.version,shippedAt:r.shippedAt}),r}async getByVersion(t,e){return(await this.read(t)).shipped.find(n=>n.version===e)}async getCount(t){return(await this.read(t)).shipped.length}async getByDateRange(t,e,r){return(await this.read(t)).shipped.filter(s=>{let o=new Date(s.shippedAt);return o>=e&&o<=r})}async getStats(t,e="month"){let r=new Date,n;switch(e){case"week":n=new Date(r.getTime()-10080*60*1e3);break;case"month":n=new Date(r.getFullYear(),r.getMonth(),1);break;case"year":n=new Date(r.getFullYear(),0,1);break}return{count:(await this.getByDateRange(t,n,r)).length,period:e}}async archiveOldShipped(t){let e=await this.read(t),r=$t(ee.SHIPPED_RETENTION_DAYS),n=e.shipped.filter(o=>new Date(o.shippedAt)<r);if(n.length===0)return 0;St.archiveMany(t,n.map(o=>({entityType:"shipped",entityId:o.id,entityData:o,summary:`${o.name} v${o.version}`,reason:"age"})));let s=new Set(e.shipped.filter(o=>new Date(o.shippedAt)>=r).map(o=>o.id));return await this.update(t,o=>({shipped:o.shipped.filter(a=>s.has(a.id)),lastUpdated:f()})),await this.publishEvent(t,"shipped.archived",{count:n.length,oldestShippedAt:n[n.length-1]?.shippedAt}),n.length}},Fr=new Ze;tn();var en=class i{static{l(this,"ObsidianExporter")}getProjectPath(t,e){let r=t.projectFolder||e;return E.join(t.vaultPath,"projects",r)}async exportAll(t,e,r){let n=this.getProjectPath(r,e),s=[],o={success:!0,projectFolder:n,exported:{board:0,queue:0,shipped:0,roadmap:0,daily:!1},errors:s};await this.ensureStructure(n);try{o.exported.board=await this.exportBoard(t,n)}catch(a){s.push(`board: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.queue=await this.exportQueue(t,n)}catch(a){s.push(`queue: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.shipped=await this.exportShipped(t,n)}catch(a){s.push(`shipped: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.roadmap=await this.exportRoadmap(t,n)}catch(a){s.push(`roadmap: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.daily=await this.exportDaily(t,n)}catch(a){s.push(`daily: ${a instanceof Error?a.message:String(a)}`)}try{await this.exportIndex(e,n)}catch(a){s.push(`index: ${a instanceof Error?a.message:String(a)}`)}return o.success=s.length===0,o}async ensureStructure(t){let e=["board","queue","shipped","roadmap","architecture","design","research","meetings","notes","daily","retros"];for(let r of e)await M.mkdir(E.join(t,r),{recursive:!0})}async writeLink(t,e,r){let n=[`projectId: ${e}`,`projectPath: ${r}`,`linkedAt: ${new Date().toISOString()}`].join(`
|
|
623
|
+
`)}]}}))}l(Nr,"registerMemoryTools");import Gr from"node:path";import{z as A}from"zod";import M from"node:fs/promises";import E from"node:path";var Ir={critical:0,high:1,medium:2,low:3},Mr={active:0,previously_active:1,backlog:2};function Or(i){return[...i].sort((t,e)=>{let r=Mr[t.section]-Mr[e.section];return r!==0?r:Ir[t.priority]-Ir[e.priority]})}l(Or,"sortBySectionAndPriority");W();var Qe=class extends pt{static{l(this,"QueueStorage")}constructor(){super("queue.json",Er)}getDefault(){return{tasks:[],lastUpdated:""}}getEventType(t){return`queue.${t}d`}async getTasks(t){return(await this.read(t)).tasks}async getActiveTasks(t){return(await this.read(t)).tasks.filter(r=>r.section==="active"&&!r.completed)}async getBacklog(t){return(await this.read(t)).tasks.filter(r=>r.section==="backlog"&&!r.completed)}async getNextTask(t){let e=await this.getActiveTasks(t);return Or(e)[0]||null}async addTask(t,e){let r={...e,id:F(),createdAt:f(),completed:!1};return await this.update(t,n=>({tasks:[...n.tasks,r],lastUpdated:f()})),await this.publishEvent(t,"queue.task_added",{taskId:r.id,description:r.description,priority:r.priority,section:r.section}),r}async addTasks(t,e){let r=f(),n=e.map(s=>({...s,id:F(),createdAt:r,completed:!1}));return await this.update(t,s=>({tasks:[...s.tasks,...n],lastUpdated:r})),await this.publishEvent(t,"queue.tasks_added",{count:n.length,tasks:n.map(s=>({id:s.id,description:s.description}))}),n}async removeTask(t,e){await this.update(t,r=>({tasks:r.tasks.filter(n=>n.id!==e),lastUpdated:f()})),await this.publishEvent(t,"queue.task_removed",{taskId:e})}async completeTask(t,e){let r=null;if(await this.update(t,n=>({tasks:n.tasks.map(o=>o.id===e?(r={...o,completed:!0,completedAt:f()},r):o),lastUpdated:f()})),r){let n=r;await this.publishEvent(t,"queue.task_completed",{taskId:e,description:n.description,completedAt:n.completedAt})}return r}async moveToSection(t,e,r){await this.update(t,n=>({tasks:n.tasks.map(s=>s.id===e?{...s,section:r}:s),lastUpdated:f()}))}async setPriority(t,e,r){await this.update(t,n=>({tasks:n.tasks.map(s=>s.id===e?{...s,priority:r}:s),lastUpdated:f()}))}async getTask(t,e){return(await this.read(t)).tasks.find(n=>n.id===e)||null}async updateTask(t,e,r){let n=null;return await this.update(t,s=>({tasks:s.tasks.map(o=>o.id===e?(n={...o,...r},n):o),lastUpdated:f()})),n&&await this.publishEvent(t,"queue.task_updated",{taskId:e}),n}async clearCompleted(t){let r=(await this.read(t)).tasks.filter(n=>n.completed).length;return await this.update(t,n=>({tasks:n.tasks.filter(s=>!s.completed),lastUpdated:f()})),r}async removeStaleCompleted(t){let e=await this.read(t),r=$t(ee.QUEUE_COMPLETED_DAYS),n=e.tasks.filter(o=>o.completed&&o.completedAt&&new Date(o.completedAt)<r);if(n.length===0)return 0;St.archiveMany(t,n.map(o=>({entityType:"queue_task",entityId:o.id,entityData:o,summary:o.description,reason:"age"})));let s=new Set(n.map(o=>o.id));return await this.update(t,o=>({tasks:o.tasks.filter(a=>!s.has(a.id)),lastUpdated:f()})),await this.publishEvent(t,"queue.stale_removed",{count:n.length}),n.length}},Nt=new Qe;import{z as v}from"zod";var Vo=v.enum(["feature","fix","improvement","refactor"]),Lr=v.enum(["pass","warning","fail","skipped"]),Yo=v.enum(["added","changed","fixed","removed"]),Ko=v.object({hours:v.number(),minutes:v.number(),totalMinutes:v.number()}),Jo=v.object({filesChanged:v.number().nullable().optional(),linesAdded:v.number().nullable().optional(),linesRemoved:v.number().nullable().optional(),commits:v.number().nullable().optional()}),Qo=v.object({description:v.string(),type:Yo.optional()}),Zo=v.object({lintStatus:Lr.nullable().optional(),lintDetails:v.string().optional(),testStatus:Lr.nullable().optional(),testDetails:v.string().optional()}),ti=v.object({hash:v.string().optional(),message:v.string().optional(),branch:v.string().optional()}),ei=v.object({id:v.string(),name:v.string(),version:v.string().nullable().optional(),type:Vo,agent:v.string().optional(),description:v.string().optional(),changes:v.array(Qo).optional(),codeSnippets:v.array(v.string()).optional(),commit:ti.optional(),codeMetrics:Jo.optional(),qualityMetrics:Zo.optional(),quantitativeImpact:v.string().optional(),duration:Ko.optional(),tasksCompleted:v.number().nullable().optional(),shippedAt:v.string(),featureId:v.string().optional()}),$r=v.object({shipped:v.array(ei),lastUpdated:v.string()});W();var Ze=class extends pt{static{l(this,"ShippedStorage")}constructor(){super("shipped.json",$r)}getDefault(){return{shipped:[],lastUpdated:""}}getEventType(t){return`shipped.${t}d`}async getAll(t){return(await this.read(t)).shipped}async getRecent(t,e=5){return(await this.read(t)).shipped.sort((n,s)=>new Date(s.shippedAt).getTime()-new Date(n.shippedAt).getTime()).slice(0,e)}async addShipped(t,e){let r={...e,id:F(),shippedAt:f()};return await this.update(t,n=>({shipped:[r,...n.shipped],lastUpdated:f()})),await this.publishEvent(t,"feature.shipped",{shipId:r.id,name:r.name,version:r.version,shippedAt:r.shippedAt}),r}async getByVersion(t,e){return(await this.read(t)).shipped.find(n=>n.version===e)}async getCount(t){return(await this.read(t)).shipped.length}async getByDateRange(t,e,r){return(await this.read(t)).shipped.filter(s=>{let o=new Date(s.shippedAt);return o>=e&&o<=r})}async getStats(t,e="month"){let r=new Date,n;switch(e){case"week":n=new Date(r.getTime()-10080*60*1e3);break;case"month":n=new Date(r.getFullYear(),r.getMonth(),1);break;case"year":n=new Date(r.getFullYear(),0,1);break}return{count:(await this.getByDateRange(t,n,r)).length,period:e}}async archiveOldShipped(t){let e=await this.read(t),r=$t(ee.SHIPPED_RETENTION_DAYS),n=e.shipped.filter(o=>new Date(o.shippedAt)<r);if(n.length===0)return 0;St.archiveMany(t,n.map(o=>({entityType:"shipped",entityId:o.id,entityData:o,summary:`${o.name} v${o.version}`,reason:"age"})));let s=new Set(e.shipped.filter(o=>new Date(o.shippedAt)>=r).map(o=>o.id));return await this.update(t,o=>({shipped:o.shipped.filter(a=>s.has(a.id)),lastUpdated:f()})),await this.publishEvent(t,"shipped.archived",{count:n.length,oldestShippedAt:n[n.length-1]?.shippedAt}),n.length}},Fr=new Ze;tn();var en=class i{static{l(this,"ObsidianExporter")}getProjectPath(t,e){let r=t.projectFolder||e;return E.join(t.vaultPath,"projects",r)}async exportAll(t,e,r){let n=this.getProjectPath(r,e),s=[],o={success:!0,projectFolder:n,exported:{board:0,queue:0,shipped:0,roadmap:0,daily:!1},errors:s};await this.ensureStructure(n);try{o.exported.board=await this.exportBoard(t,n)}catch(a){s.push(`board: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.queue=await this.exportQueue(t,n)}catch(a){s.push(`queue: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.shipped=await this.exportShipped(t,n)}catch(a){s.push(`shipped: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.roadmap=await this.exportRoadmap(t,n)}catch(a){s.push(`roadmap: ${a instanceof Error?a.message:String(a)}`)}try{o.exported.daily=await this.exportDaily(t,n)}catch(a){s.push(`daily: ${a instanceof Error?a.message:String(a)}`)}try{await this.exportIndex(e,n)}catch(a){s.push(`index: ${a instanceof Error?a.message:String(a)}`)}return o.success=s.length===0,o}async ensureStructure(t){let e=["board","queue","shipped","roadmap","architecture","design","research","meetings","notes","daily","retros"];for(let r of e)await M.mkdir(E.join(t,r),{recursive:!0})}async writeLink(t,e,r){let n=[`projectId: ${e}`,`projectPath: ${r}`,`linkedAt: ${new Date().toISOString()}`].join(`
|
|
613
624
|
`);await M.writeFile(E.join(t,".prjct-link.yml"),n,"utf-8")}async exportBoard(t,e){let r=await X.read(t),n=E.join(e,"board"),s=0;if(r.currentTask){let c=r.currentTask,u=c.subtasks||[],p=c.currentSubtaskIndex??0,d={prjct_id:c.id,prjct_type:"task",status:"in_progress",type:c.type||"feature",description:c.description,branch:c.branch,linear_id:c.linearId,estimated_points:c.estimatedPoints,started_at:c.startedAt,updated_at:new Date().toISOString()},g=u.map((k,I)=>{let z=k.status==="completed"?"x":" ",V=I===p&&k.status!=="completed"?" <- current":"";return`- [${z}] ${k.description}${V}`}),h=u.filter(k=>k.status==="completed").length,j=u.length>0?`${h}/${u.length} (${Math.round(h/u.length*100)}%)`:"",w=ct(d,c.description,g.length>0?`## Subtasks
|
|
614
625
|
${g.join(`
|
|
615
626
|
`)}`:null,j?`## Progress
|