warp-task-master
Version:
BETA: Experimental Task Master fork with Warp AI integration and human-readable profile names. For production use, see task-master-ai.
180 lines (141 loc) โข 277 kB
JavaScript
import{generateObjectService as e,generateTextService as t,streamObjectService as n}from"./ai-services-unified-Bp0J8TPk.js";import{CUSTOM_PROVIDERS as r,LEGACY_CONFIG_FILE as i,LEGACY_TASKS_FILE as a,TASKMASTER_CONFIG_FILE as o,TASKMASTER_TASKS_FILE as s,addComplexityToTask as c,aggregateTelemetry as l,ensureTagMetadata as u,findComplexityReportPath as d,findConfigPath as f,findCycles as p,findPRDPath as m,findProjectRoot as h,findTaskById as g,findTaskInComplexityReport as _,findTasksPath as v,flattenTasksWithSubtasks as y,formatTaskId as b,getAllProviders as x,getAvailableModels as S,getBaseUrlForRole as C,getConfig as w,getCurrentTag as T,getDebugFlag as E,getDefaultPriority as D,getDefaultSubtasks as O,getFallbackModelId as k,getFallbackProvider as A,getMainModelId as j,getMainProvider as ee,getMcpApiKeyStatus as M,getParametersForRole as N,getProjectName as P,getResearchModelId as F,getResearchProvider as I,hasCodebaseAnalysis as te,isApiKeySet as ne,isConfigFilePresent as L,isSilentMode as R,log as z,markMigrationForNotice as re,normalizeProjectRoot as ie,performCompleteTagMigration as ae,readComplexityReport as oe,readJSON as B,resolveComplexityReportOutputPath as se,taskExists as ce,traverseDependencies as le,truncate as V,writeConfig as ue,writeJSON as H}from"./utils-Can7ymw4.js";import{getProfileMap as de,profileNameToId as fe}from"./ai-providers-DH3IjRav.js";import U from"path";import W from"chalk";import G from"boxen";import*as pe from"fs";import K from"fs";import me from"https";import he from"http";import ge from"inquirer";import _e from"ora";import{fileURLToPath as ve}from"url";import{z as q}from"zod";import"child_process";import J from"cli-table3";import"@streamparser/json";import ye from"figlet";import be from"gradient-string";import xe from"readline";import Se from"ajv";import Ce from"ajv-formats";import we from"cli-progress";import Te from"gpt-tokens";import Ee from"fuse.js";import{FastMCP as De}from"fastmcp";import{LRUCache as Oe}from"lru-cache";import{highlight as ke}from"cli-highlight";var Ae={name:`warp-task-master`,version:`1.0.0-beta.7`,description:`BETA: Experimental Task Master fork with Warp AI integration and human-readable profile names. For production use, see task-master-ai.`,main:`index.js`,type:`module`,bin:{"warp-task-master":`dist/task-master.js`,"warp-task-master-mcp":`dist/mcp-server.js`},workspaces:[`apps/*`,`packages/*`,`.`],scripts:{build:`npm run build:build-config && cross-env NODE_ENV=production tsdown`,dev:`tsdown --watch`,"turbo:dev":`turbo dev`,"turbo:build":`turbo build`,"turbo:typecheck":`turbo typecheck`,"build:build-config":`npm run build -w @tm/build-config`,test:`node --experimental-vm-modules node_modules/.bin/jest`,"test:unit":`node --experimental-vm-modules node_modules/.bin/jest --testPathPattern=unit`,"test:integration":`node --experimental-vm-modules node_modules/.bin/jest --testPathPattern=integration`,"test:fails":`node --experimental-vm-modules node_modules/.bin/jest --onlyFailures`,"test:watch":`node --experimental-vm-modules node_modules/.bin/jest --watch`,"test:coverage":`node --experimental-vm-modules node_modules/.bin/jest --coverage`,"test:ci":`node --experimental-vm-modules node_modules/.bin/jest --coverage --ci`,"test:e2e":`./tests/e2e/run_e2e.sh`,"test:e2e-report":`./tests/e2e/run_e2e.sh --analyze-log`,postpack:`chmod +x dist/task-master.js dist/mcp-server.js`,changeset:`changeset`,release:`changeset publish`,"publish-packages":`turbo run build lint test && changeset version && changeset publish`,inspector:`npx @modelcontextprotocol/inspector node dist/mcp-server.js`,"mcp-server":`node dist/mcp-server.js`,"format-check":`biome format .`,format:`biome format . --write`,"deps:check":`manypkg check || echo 'Note: Workspace package version warnings are expected for internal @tm/* packages'`,"deps:fix":`manypkg fix`},keywords:[`warp`,`task`,`management`,`ai`,`development`,`claude`,`cursor`,`anthropic`,`llm`,`mcp`,`context`,`terminal`,`profiles`,`beta`,`experimental`,`fork`],author:`TheLazyIndianTechie (fork of task-master-ai by Eyal Toledano)`,license:`MIT WITH Commons-Clause`,dependencies:{"@ai-sdk/amazon-bedrock":`^2.2.9`,"@ai-sdk/anthropic":`^1.2.10`,"@ai-sdk/azure":`^1.3.17`,"@ai-sdk/google":`^1.2.13`,"@ai-sdk/google-vertex":`^2.2.23`,"@ai-sdk/groq":`^1.2.9`,"@ai-sdk/mistral":`^1.2.7`,"@ai-sdk/openai":`^1.3.20`,"@ai-sdk/perplexity":`^1.1.7`,"@ai-sdk/xai":`^1.2.15`,"@anthropic-ai/sdk":`^0.39.0`,"@aws-sdk/credential-providers":`^3.817.0`,"@inquirer/search":`^3.0.15`,"@openrouter/ai-sdk-provider":`^0.4.5`,"@streamparser/json":`^0.0.22`,"@supabase/supabase-js":`^2.57.4`,ai:`^4.3.10`,ajv:`^8.17.1`,"ajv-formats":`^3.0.1`,boxen:`^8.0.1`,chalk:`5.6.2`,"cli-highlight":`^2.1.11`,"cli-progress":`^3.12.0`,"cli-table3":`^0.6.5`,commander:`^12.1.0`,cors:`^2.8.5`,dotenv:`^16.3.1`,express:`^4.21.2`,fastmcp:`^3.5.0`,figlet:`^1.8.0`,"fuse.js":`^7.1.0`,"gpt-tokens":`^1.3.14`,"gradient-string":`^3.0.0`,helmet:`^8.1.0`,inquirer:`^12.5.0`,"jsonc-parser":`^3.3.1`,jsonrepair:`^3.13.0`,jsonwebtoken:`^9.0.2`,"lru-cache":`^10.2.0`,marked:`^15.0.12`,"marked-terminal":`^7.3.0`,"ollama-ai-provider":`^1.2.0`,openai:`^4.89.0`,ora:`^8.2.0`,uuid:`^11.1.0`,zod:`^3.23.8`,"zod-to-json-schema":`^3.24.5`},optionalDependencies:{"@anthropic-ai/claude-code":`^1.0.88`,"@biomejs/cli-linux-x64":`^1.9.4`,"ai-sdk-provider-gemini-cli":`^0.1.3`},engines:{node:`>=18.0.0`,npm:`>=8.0.0`},os:[`darwin`,`linux`,`win32`],packageManager:`npm@10.9.2`,repository:{type:`git`,url:`git+https://github.com/TheLazyIndianTechie/warp-task-master.git`},homepage:`https://github.com/TheLazyIndianTechie/warp-task-master#readme`,bugs:{url:`https://github.com/TheLazyIndianTechie/warp-task-master/issues`},files:[`dist/**`,`README.md`,`CHANGELOG.md`,`LICENSE`,`scripts/init.js`],overrides:{"node-fetch":`^2.6.12`,"whatwg-url":`^11.0.0`},devDependencies:{"@biomejs/biome":`^1.9.4`,"@changesets/changelog-github":`^0.5.1`,"@changesets/cli":`^2.28.1`,"@manypkg/cli":`^0.25.1`,"@tm/cli":`*`,"@types/jest":`^29.5.14`,"@types/marked-terminal":`^6.1.1`,concurrently:`^9.2.1`,"cross-env":`^10.0.0`,"dotenv-mono":`^1.5.1`,execa:`^8.0.1`,jest:`^29.7.0`,"jest-environment-node":`^29.7.0`,"mock-fs":`^5.5.0`,prettier:`^3.5.3`,supertest:`^7.1.0`,"ts-jest":`^29.4.2`,tsdown:`^0.15.2`,tsx:`^4.20.4`,turbo:`^2.5.6`,typescript:`^5.7.3`}},je=class e extends Error{constructor(t,n){super(t),this.name=`StreamingError`,this.code=n,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};const Me={NOT_ASYNC_ITERABLE:`STREAMING_NOT_SUPPORTED`,STREAM_PROCESSING_FAILED:`STREAM_PROCESSING_FAILED`,STREAM_NOT_ITERABLE:`STREAM_NOT_ITERABLE`,BUFFER_SIZE_EXCEEDED:`BUFFER_SIZE_EXCEEDED`};var Ne=class e{static async withTimeout(e,t,n=`Operation`){let r,i=new Promise((e,i)=>{r=setTimeout(()=>{i(new je(`${n} timed out after ${t/1e3} seconds`,Me.STREAM_PROCESSING_FAILED))},t)});try{let t=await Promise.race([e,i]);return clearTimeout(r),t}catch(e){throw clearTimeout(r),e}}static async withSoftTimeout(e,t,n=void 0){let r,i=new Promise(e=>{r=setTimeout(()=>{e(n)},t)});try{let t=await Promise.race([e,i]);return clearTimeout(r),t}catch(e){return clearTimeout(r),n}}static createController(t,n=`Operation`){return{timeoutMs:t,operationName:n,async wrap(r,i=null){let a=i?`${n} - ${i}`:n;return e.withTimeout(r,t,a)},async wrapSoft(n,r=void 0){return e.withSoftTimeout(n,t,r)}}}static isTimeoutError(e){return e instanceof je&&e.code===Me.STREAM_PROCESSING_FAILED&&e.message.includes(`timed out`)}},Pe=class e{constructor(e,t=`ms`){this.milliseconds=this._toMilliseconds(e,t)}static milliseconds(t){return new e(t,`ms`)}static seconds(t){return new e(t,`s`)}static minutes(t){return new e(t,`m`)}static hours(t){return new e(t,`h`)}get seconds(){return this.milliseconds/1e3}get minutes(){return this.milliseconds/6e4}get hours(){return this.milliseconds/36e5}toString(){return this.milliseconds<1e3?`${this.milliseconds}ms`:this.milliseconds<6e4?`${this.seconds}s`:this.milliseconds<36e5?`${Math.floor(this.minutes)}m ${Math.floor(this.seconds%60)}s`:`${Math.floor(this.hours)}h ${Math.floor(this.minutes%60)}m`}_toMilliseconds(e,t){return e*({ms:1,s:1e3,m:6e4,h:36e5}[t]||1)}};const Fe=[`high`,`medium`,`low`],Ie=`medium`;function Le(e){return Fe.includes(e?.toLowerCase())}function Re(e){if(!e)return null;let t=e.toLowerCase();return Le(t)?t:null}const ze=q.object({id:q.number(),title:q.string().min(1),description:q.string().min(1),details:q.string(),testStrategy:q.string(),priority:q.enum(Fe),dependencies:q.array(q.number()),status:q.string()}),Be=q.object({tasks:q.array(ze),metadata:q.object({projectName:q.string(),totalTasks:q.number(),sourceFile:q.string(),generatedAt:q.string()})});var Ve=class{constructor(e,t,n,r={}){this.prdPath=e,this.tasksPath=t,this.numTasks=n,this.force=r.force||!1,this.append=r.append||!1,this.research=r.research||!1,this.reportProgress=r.reportProgress,this.mcpLog=r.mcpLog,this.session=r.session,this.projectRoot=r.projectRoot,this.tag=r.tag,this.streamingTimeout=r.streamingTimeout||Pe.seconds(180).milliseconds,this.targetTag=this.tag||T(this.projectRoot)||`master`,this.isMCP=!!this.mcpLog,this.outputFormat=this.isMCP&&!this.reportProgress?`json`:`text`,this.useStreaming=!1}hasCodebaseAnalysis(){return te(this.research,this.projectRoot,this.session)}},He=class{constructor(e,t){this.isMCP=!!e,this.outputFormat=this.isMCP&&!t?`json`:`text`,this.logFn=e||{info:(...e)=>z(`info`,...e),warn:(...e)=>z(`warn`,...e),error:(...e)=>z(`error`,...e),debug:(...e)=>z(`debug`,...e),success:(...e)=>z(`success`,...e)}}report(e,t=`info`){this.logFn&&typeof this.logFn[t]==`function`?this.logFn[t](e):!R()&&this.outputFormat===`text`&&z(t,e)}};function Ue(e){let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}m ${n.toString().padStart(2,`0`)}s`}const We={BAR_WIDTH:40,TABLE_COL_WIDTHS:[28,50],DEFAULT_MODEL:`Default`,DEFAULT_TEMPERATURE:.7},Y={HIGH:`high`,MEDIUM:`medium`,LOW:`low`},Ge={[Y.HIGH]:`#CC0000`,[Y.MEDIUM]:`#FF8800`,[Y.LOW]:`#FFCC00`},Ke={main:{padding:{top:1,bottom:1,left:2,right:2},margin:{top:0,bottom:0},borderColor:`blue`,borderStyle:`round`},summary:{padding:{top:1,right:1,bottom:1,left:1},borderColor:`blue`,borderStyle:`round`,margin:{top:1,right:1,bottom:1,left:0}},warning:{padding:1,borderColor:`yellow`,borderStyle:`round`,margin:{top:1,bottom:1}},nextSteps:{padding:1,borderColor:`cyan`,borderStyle:`round`,margin:{top:1,right:0,bottom:1,left:0}}};function qe({prdFilePath:e,outputPath:t,numTasks:n,model:r,temperature:i,append:a,research:o}){let s=a?`Appending`:`Generating`,c=`Model: ${r} | Temperature: ${i}`;return o&&(c+=` | ${W.cyan.bold(`๐ฌ Research Mode`)}`),W.bold(`๐ค Parsing PRD and ${s} Tasks`)+`
`+W.dim(c)+`
`+W.blue(`Input: ${e}`)+`
`+W.blue(`Output: ${t}`)+`
`+W.blue(`Tasks to ${a?`Append`:`Generate`}: ${n}`)}function Je(e){console.log(G(e,Ke.main))}function Ye(e,t){console.log(W.yellow.bold(`๐ Append mode`)+` - Adding to ${e} existing tasks (next ID: ${t})`)}function Xe(e){let t=W.red.bold(`โ ๏ธ Force flag enabled`);return e?`${t} - Will overwrite if conflicts occur`:`${t} - Overwriting existing tasks`}function Ze({prdFilePath:e,outputPath:t,numTasks:n,model:r=We.DEFAULT_MODEL,temperature:i=We.DEFAULT_TEMPERATURE,append:a=!1,research:o=!1,force:s=!1,existingTasks:c=[],nextId:l=1}){if(!e||typeof e!=`string`||e.trim()===``)throw Error(`prdFilePath is required and must be a non-empty string`);if(!t||typeof t!=`string`||t.trim()===``)throw Error(`outputPath is required and must be a non-empty string`);let u=qe({prdFilePath:e,outputPath:t,numTasks:n,model:r,temperature:i,append:a,research:o});Je(u),(a||s)&&(a&&Ye(c.length,l),s&&console.log(Xe(a)),console.log())}function Qe(e,t){let n={};return Object.values(Y).forEach(r=>{let i=e[r]||0;n[r]={count:i,percentage:t>0?Math.round(i/t*100):0}}),n}function $e(e,t){let n=We.BAR_WIDTH,r={};if(t===0)return Object.values(Y).forEach(e=>{r[e]=0}),r;let i={};Object.values(Y).forEach(r=>{i[r]=e[r].count/t*n}),Object.values(Y).forEach(e=>{r[e]=Math.floor(i[e])}),Object.values(Y).forEach(t=>{e[t].count>0&&r[t]===0&&(r[t]=1)});let a=Object.values(r).reduce((e,t)=>e+t,0),o=n-a;if(o>0){let e=Object.values(Y).map(e=>({priority:e,decimal:i[e]-Math.floor(i[e])})).sort((e,t)=>t.decimal-e.decimal);for(let t=0;t<o&&t<e.length;t++)r[e[t].priority]++}return r}function et(e){let t=``;t+=W.hex(Ge[Y.HIGH])(`โ`.repeat(e[Y.HIGH])),t+=W.hex(Ge[Y.MEDIUM])(`โ`.repeat(e[Y.MEDIUM])),t+=W.yellow(`โ`.repeat(e[Y.LOW]));let n=Object.values(e).reduce((e,t)=>e+t,0);return n<We.BAR_WIDTH&&(t+=W.gray(`โ`.repeat(We.BAR_WIDTH-n))),t}function tt(e){let t=[];return Object.entries(Y).forEach(([n,r])=>{let i=e[r],a=r===Y.HIGH?W.hex(Ge[Y.HIGH]):r===Y.MEDIUM?W.hex(Ge[Y.MEDIUM]):W.yellow,o=n.charAt(0)+n.slice(1).toLowerCase();t.push(`${a.bold(i.count)} ${a(o)} (${i.percentage}%)`)}),[W.cyan(`Priority distribution:`),t.join(` ยท `)]}function nt(e){let{totalTasks:t,taskPriorities:n={},prdFilePath:r,outputPath:i,elapsedTime:a,usedFallback:o=!1,actionVerb:s=`generated`}=e,c=Ue(a),l=new J({chars:{top:``,"top-mid":``,"top-left":``,"top-right":``,bottom:``,"bottom-mid":``,"bottom-left":``,"bottom-right":``,left:``,"left-mid":``,mid:``,"mid-mid":``,right:``,"right-mid":``,middle:` `},style:{border:[],"padding-left":2},colWidths:We.TABLE_COL_WIDTHS});if(l.push([W.cyan(`Total tasks ${s}:`),W.bold(t)],[W.cyan(`Processing time:`),W.bold(c)]),n&&Object.keys(n).length>0){let e=Qe(n,t),r=tt(e);l.push(r);let i=$e(e,t),a=et(i);l.push([W.cyan(`Distribution:`),a])}l.push([W.cyan(`PRD source:`),W.italic(r)],[W.cyan(`Tasks file:`),W.italic(i)]),o&&l.push([W.yellow(`Fallback parsing:`),W.yellow(`โ Used fallback parsing`)]);let u=[W.bold.underline(`PRD Parsing Complete - Tasks ${s.charAt(0).toUpperCase()+s.slice(1)}`),``,l.toString()].join(`
`);console.log(G(u,Ke.summary)),o&&rt(),it()}function rt(){let e=W.yellow.bold(`โ ๏ธ Fallback Parsing Used`)+`
`+W.white(`The system used fallback parsing to complete task generation.`)+`
`+W.white(`This typically happens when streaming JSON parsing is incomplete.`)+`
`+W.white(`Your tasks were successfully generated, but consider:`)+`
`+W.white(`โข Reviewing task completeness`)+`
`+W.white(`โข Checking for any missing details`)+`
`+W.white(`This is normal and usually doesn't indicate any issues.`);console.log(G(e,Ke.warning))}function it(){let e=W.white.bold(`Next Steps:`)+`
${W.cyan(`1.`)} Run ${W.yellow(`task-master list`)} to view all tasks\n${W.cyan(`2.`)} Run ${W.yellow(`task-master expand --id=<id>`)} to break down a task into subtasks\n${W.cyan(`3.`)} Run ${W.yellow(`task-master analyze-complexity`)} to analyze task complexity`;console.log(G(e,Ke.nextSteps))}const at=[`pending`,`done`,`in-progress`,`review`,`deferred`,`cancelled`];function ot(e){return at.includes(e)}function st(){return Ae.version||`unknown`}const ct=be([`#00b4d8`,`#0077b6`,`#03045e`]);be([`#fb8b24`,`#e36414`,`#9a031e`]);function lt(e){R()||!e||!e._migrationHappened||console.log(G(W.white.bold(`FYI: `)+W.gray(`Taskmaster now supports separate task lists per tag. `)+W.cyan(`Use the --tag flag to create/read/update/filter tasks by tag.`),{padding:{top:0,bottom:0,left:2,right:2},borderColor:`cyan`,borderStyle:`round`,margin:{top:1,bottom:1}}))}function ut(e,t={}){if(R())return;let{skipIfMaster:n=!1,dim:r=!1}=t;if(n&&e===`master`)return;let i=`๐ท๏ธ`,a=r?W.gray(`${i} tag: ${e}`):W.dim(`${i} tag: `)+W.cyan(e);console.log(a)}function dt(){if(R())return;let e=ye.textSync(`Task Master`,{font:`Standard`,horizontalLayout:`default`,verticalLayout:`default`});console.log(ct(e)),console.log(W.dim(`by `)+W.cyan.underline(`https://x.com/eyaltoledano`));let t=st();console.log(G(W.white(`${W.bold(`Version:`)} ${t} ${W.bold(`Project:`)} ${P(null)}`),{padding:1,margin:{top:0,bottom:1},borderStyle:`round`,borderColor:`cyan`}))}function ft(e){return R()?null:_e({text:e,color:`cyan`}).start()}function X(e){e&&typeof e.stop==`function`&&e.stop()}function pt(e,t=null){e&&typeof e.succeed==`function`&&(t?e.succeed(t):e.succeed())}function mt(e,t=null){e&&typeof e.fail==`function`&&(t?e.fail(t):e.fail())}function ht(e,t=30,n=null){let r=n?Math.min(100,e+(n.deferred||0)+(n.cancelled||0)):e,i=Math.round(e*t/100),a=Math.round(r*t/100),o=a-i,s=t-a,c;c=e<25?W.red:e<50?W.hex(`#FFA500`):e<75?W.yellow:e<100?W.green:W.hex(`#006400`);let l=c(`โ`.repeat(i)),u=W.gray(`โ`.repeat(o)),d=``;if(n&&s>0){let e={pending:W.yellow,"in-progress":W.hex(`#FFA500`),blocked:W.red,review:W.magenta},t=Object.entries(n).filter(([e])=>![`deferred`,`cancelled`,`done`,`completed`].includes(e)).reduce((e,[t,n])=>e+n,0);if(t<=0)d=W.gray(`โ`.repeat(s));else{let r=0;for(let[i,a]of Object.entries(n)){if([`deferred`,`cancelled`,`done`,`completed`].includes(i))continue;let n=Math.round(a/t*s),o=Math.min(n,s-r),c=e[i]||W.gray;d+=c(`โ`.repeat(o)),r+=o}r<s&&(d+=W.gray(`โ`.repeat(s-r)))}}else d=W.gray(`โ`.repeat(s));let f=e===100?W.hex(`#006400`):r===100?W.gray:c;return`${l}${u}${d} ${f(`${r.toFixed(0)}%`)}`}function gt(e,t=!1){if(!e)return W.gray(`โ unknown`);let n={done:{color:W.green,icon:`โ`,tableIcon:`โ`},completed:{color:W.green,icon:`โ`,tableIcon:`โ`},pending:{color:W.yellow,icon:`โ`,tableIcon:`โฑ`},"in-progress":{color:W.hex(`#FFA500`),icon:`๐`,tableIcon:`โบ`},deferred:{color:W.gray,icon:`x`,tableIcon:`โฑ`},blocked:{color:W.red,icon:`!`,tableIcon:`โ`},review:{color:W.magenta,icon:`?`,tableIcon:`?`},cancelled:{color:W.gray,icon:`โ`,tableIcon:`x`}}[e.toLowerCase()]||{color:W.red,icon:`โ`,tableIcon:`โ`};if(t){let t={done:`โ`,completed:`โ`,pending:`โ`,"in-progress":`โบ`,deferred:`x`,blocked:`!`,review:`?`}[e.toLowerCase()]||`x`;return n.color(`${t} ${e}`)}return n.color(`${n.icon} ${e}`)}function _t(e,t,n=!1,r=null){return!e||!Array.isArray(e)||e.length===0?n?W.gray(`None`):`None`:e.map(e=>{let i=e.toString();if(i.includes(`.`)){let a=i.split(`.`);if(a.length!==2||!a[0]||!a[1]){let a=g(t,typeof e==`string`?parseInt(e,10):e,r).task;if(!a)return n?W.red(`${i} (Not found)`):`${i} (Not found)`;let o=a.status||`pending`,s=o.toLowerCase()===`done`||o.toLowerCase()===`completed`,c=o.toLowerCase()===`in-progress`;return n?s?W.green.bold(i):c?W.yellow.bold(i):W.red.bold(i):i}let[o,s]=a.map(e=>parseInt(e,10)),c=t.find(e=>e.id===o);if(!c||!c.subtasks)return n?W.red(`${i} (Not found)`):`${i} (Not found)`;let l=c.subtasks.find(e=>e.id===s);if(!l)return n?W.red(`${i} (Not found)`):`${i} (Not found)`;let u=l.status||`pending`,d=u.toLowerCase()===`done`||u.toLowerCase()===`completed`,f=u.toLowerCase()===`in-progress`;return n?d?W.green.bold(i):f?W.hex(`#FFA500`).bold(i):W.red.bold(i):i}let a=g(t,typeof e==`string`?parseInt(e,10):e,r).task;if(!a)return n?W.red(`${i} (Not found)`):`${i} (Not found)`;let o=a.status||`pending`,s=o.toLowerCase()===`done`||o.toLowerCase()===`completed`,c=o.toLowerCase()===`in-progress`;return n?s?W.green.bold(i):c?W.yellow.bold(i):W.red.bold(i):i}).join(`, `)}function vt(){let e=process.stdout.columns||100;console.log(G(W.white.bold(`Task Master CLI`),{padding:1,borderColor:`blue`,borderStyle:`round`,margin:{top:1,bottom:1}})),[{title:`Project Setup & Configuration`,color:`blue`,commands:[{name:`init`,args:`[--name=<name>] [--description=<desc>] [-y]`,desc:`Initialize a new project with Task Master structure`},{name:`models`,args:``,desc:`View current AI model configuration and available models`},{name:`models --setup`,args:``,desc:`Run interactive setup to configure AI models`},{name:`models --set-main`,args:`<model_id>`,desc:`Set the primary model for task generation`},{name:`models --set-research`,args:`<model_id>`,desc:`Set the model for research operations`},{name:`models --set-fallback`,args:`<model_id>`,desc:`Set the fallback model (optional)`}]},{title:`Task Generation`,color:`cyan`,commands:[{name:`parse-prd`,args:`--input=<file.txt> [--num-tasks=10]`,desc:`Generate tasks from a PRD document`},{name:`generate`,args:``,desc:`Create individual task files from tasks.json`}]},{title:`Task Management`,color:`green`,commands:[{name:`list`,args:`[--status=<status>] [--with-subtasks]`,desc:`List all tasks with their status`},{name:`set-status`,args:`--id=<id> --status=<status>`,desc:`Update task status (${at.join(`, `)})`},{name:`sync-readme`,args:`[--with-subtasks] [--status=<status>]`,desc:`Export tasks to README.md with professional formatting`},{name:`update`,args:`--from=<id> --prompt="<context>"`,desc:`Update multiple tasks based on new requirements`},{name:`update-task`,args:`--id=<id> --prompt="<context>"`,desc:`Update a single specific task with new information`},{name:`update-subtask`,args:`--id=<parentId.subtaskId> --prompt="<context>"`,desc:`Append additional information to a subtask`},{name:`add-task`,args:`--prompt="<text>" [--dependencies=<ids>] [--priority=<priority>]`,desc:`Add a new task using AI`},{name:`remove-task`,args:`--id=<id> [-y]`,desc:`Permanently remove a task or subtask`}]},{title:`Subtask Management`,color:`yellow`,commands:[{name:`add-subtask`,args:`--parent=<id> --title="<title>" [--description="<desc>"]`,desc:`Add a new subtask to a parent task`},{name:`add-subtask`,args:`--parent=<id> --task-id=<id>`,desc:`Convert an existing task into a subtask`},{name:`remove-subtask`,args:`--id=<parentId.subtaskId> [--convert]`,desc:`Remove a subtask (optionally convert to standalone task)`},{name:`clear-subtasks`,args:`--id=<id>`,desc:`Remove all subtasks from specified tasks`},{name:`clear-subtasks --all`,args:``,desc:`Remove subtasks from all tasks`}]},{title:`Task Analysis & Breakdown`,color:`magenta`,commands:[{name:`analyze-complexity`,args:`[--research] [--threshold=5]`,desc:`Analyze tasks and generate expansion recommendations`},{name:`complexity-report`,args:`[--file=<path>]`,desc:`Display the complexity analysis report`},{name:`expand`,args:`--id=<id> [--num=5] [--research] [--prompt="<context>"]`,desc:`Break down tasks into detailed subtasks`},{name:`expand --all`,args:`[--force] [--research]`,desc:`Expand all pending tasks with subtasks`},{name:`research`,args:`"<prompt>" [-i=<task_ids>] [-f=<file_paths>] [-c="<context>"] [--tree] [-s=<save_file>] [-d=<detail_level>]`,desc:`Perform AI-powered research queries with project context`}]},{title:`Task Navigation & Viewing`,color:`cyan`,commands:[{name:`next`,args:``,desc:`Show the next task to work on based on dependencies`},{name:`show`,args:`<id>`,desc:`Display detailed information about a specific task`}]},{title:`Tag Management`,color:`magenta`,commands:[{name:`tags`,args:`[--show-metadata]`,desc:`List all available tags with task counts`},{name:`add-tag`,args:`<tagName> [--copy-from-current] [--copy-from=<tag>] [-d="<desc>"]`,desc:`Create a new tag context for organizing tasks`},{name:`use-tag`,args:`<tagName>`,desc:`Switch to a different tag context`},{name:`delete-tag`,args:`<tagName> [--yes]`,desc:`Delete an existing tag and all its tasks`},{name:`rename-tag`,args:`<oldName> <newName>`,desc:`Rename an existing tag`},{name:`copy-tag`,args:`<sourceName> <targetName> [-d="<desc>"]`,desc:`Copy an existing tag to create a new tag with the same tasks`}]},{title:`Warp AI Integration`,color:`blue`,commands:[{name:`warp-profiles`,args:``,desc:`List available Warp AI profiles and their usage examples`},{name:`models --warp`,args:`--set-main <profile>`,desc:`Configure Warp AI models (e.g., warp:default, warp:reasoning)`},{name:`models --setup`,args:``,desc:`Interactive setup now includes Warp AI profiles as standard options`}]},{title:`Dependency Management`,color:`magenta`,commands:[{name:`add-dependency`,args:`--id=<id> --depends-on=<id>`,desc:`Add a dependency to a task`},{name:`remove-dependency`,args:`--id=<id> --depends-on=<id>`,desc:`Remove a dependency from a task`},{name:`validate-dependencies`,args:``,desc:`Identify invalid dependencies without fixing them`},{name:`fix-dependencies`,args:``,desc:`Fix invalid dependencies automatically`}]}].forEach(t=>{console.log(G(W[t.color].bold(t.title),{padding:{left:2,right:2,top:0,bottom:0},margin:{top:1,bottom:0},borderColor:t.color,borderStyle:`round`}));let n=Math.max(25,Math.floor(e*.2)),r=Math.max(40,Math.floor(e*.35)),i=Math.max(45,Math.floor(e*.45)-10),a=new J({colWidths:[n,r,i],chars:{top:``,"top-mid":``,"top-left":``,"top-right":``,bottom:``,"bottom-mid":``,"bottom-left":``,"bottom-right":``,left:``,"left-mid":``,mid:``,"mid-mid":``,right:``,"right-mid":``,middle:` `},style:{border:[],"padding-left":4},wordWrap:!0});t.commands.forEach((e,t)=>{a.push([`${W.yellow.bold(e.name)}${W.reset(``)}`,`${W.white(e.args)}${W.reset(``)}`,`${W.dim(e.desc)}${W.reset(``)}`])}),console.log(a.toString()),console.log(``)}),console.log(G(W.cyan.bold(`Configuration`),{padding:{left:2,right:2,top:0,bottom:0},margin:{top:1,bottom:0},borderColor:`cyan`,borderStyle:`round`}));let t=e||process.stdout.columns||100,n=Math.max(30,Math.floor(t*.25)),r=Math.max(50,Math.floor(t*.45)),i=Math.max(30,Math.floor(t*.3)-10),a=new J({colWidths:[n,r,i],chars:{top:``,"top-mid":``,"top-left":``,"top-right":``,bottom:``,"bottom-mid":``,"bottom-left":``,"bottom-right":``,left:``,"left-mid":``,mid:``,"mid-mid":``,right:``,"right-mid":``,middle:` `},style:{border:[],"padding-left":4},wordWrap:!0});a.push([`${W.yellow(o)}${W.reset(``)}`,`${W.white(`AI model configuration file (project root)`)}${W.reset(``)}`,`${W.dim(`Managed by models cmd`)}${W.reset(``)}`],[`${W.yellow(`API Keys (.env)`)}${W.reset(``)}`,`${W.white(`API keys for AI providers (ANTHROPIC_API_KEY, etc.)`)}${W.reset(``)}`,`${W.dim(`Required in .env file`)}${W.reset(``)}`],[`${W.yellow(`MCP Keys (mcp.json)`)}${W.reset(``)}`,`${W.white(`API keys for Cursor integration`)}${W.reset(``)}`,`${W.dim(`Required in .cursor/`)}${W.reset(``)}`]),console.log(a.toString()),console.log(``),console.log(G(W.white.bold(`Quick Start:`)+`
`+W.cyan(`1. Create Project: `)+W.white(`warp-task-master init`)+`
`+W.cyan(`2. Setup Models: `)+W.white(`warp-task-master models --setup`)+` `+W.gray(`(Warp AI now featured!)`)+`
`+W.cyan(`3. Parse PRD: `)+W.white(`warp-task-master parse-prd --input=<prd-file>`)+`
`+W.cyan(`4. List Tasks: `)+W.white(`warp-task-master list`)+`
`+W.cyan(`5. Find Next Task: `)+W.white(`warp-task-master next`)+`
`+W.blue.bold(`Warp AI Features:`)+`
`+W.cyan(`โข View Profiles: `)+W.white(`warp-task-master warp-profiles`)+`
`+W.cyan(`โข Set Warp Model: `)+W.white(`warp-task-master models --set-main warp:default --warp`),{padding:1,borderColor:`yellow`,borderStyle:`round`,margin:{top:1},width:Math.min(t-10,100)}))}function yt(e){return e<=3?W.green(`โ ${e}`):e<=6?W.yellow(`โ ${e}`):W.red(`โ ${e}`)}async function bt(e,t=null,n={}){let{projectRoot:r,tag:i}=n,a=B(e,r,i);(!a||!a.tasks)&&(z(`error`,`No valid tasks found.`),process.exit(1));let o=oe(t),s=Qr(a.tasks,o);if(!s){console.log(G(W.yellow(`No eligible tasks found!
`)+`All pending tasks have unsatisfied dependencies, or all tasks are completed.`,{padding:{top:0,bottom:0,left:1,right:1},borderColor:`yellow`,borderStyle:`round`,margin:{top:1}}));return}console.log(G(W.white.bold(`Next Task: #${s.id} - ${s.title}`),{padding:{top:0,bottom:0,left:1,right:1},borderColor:`blue`,borderStyle:`round`,margin:{top:1,bottom:0}}));let c=new J({style:{head:[],border:[],"padding-top":0,"padding-bottom":0,compact:!0},chars:{mid:``,"left-mid":``,"mid-mid":``,"right-mid":``},colWidths:[15,Math.min(75,process.stdout.columns-20||60)],wordWrap:!0}),l={high:W.red.bold,medium:W.yellow,low:W.gray}[s.priority||`medium`]||W.white;c.push([W.cyan.bold(`ID:`),s.id.toString()],[W.cyan.bold(`Title:`),s.title],[W.cyan.bold(`Priority:`),l(s.priority||`medium`)],[W.cyan.bold(`Dependencies:`),_t(s.dependencies,a.tasks,!0,o)],[W.cyan.bold(`Complexity:`),s.complexityScore?yt(s.complexityScore):W.gray(`N/A`)],[W.cyan.bold(`Description:`),s.description]),console.log(c.toString()),s.details&&s.details.trim().length>0&&console.log(G(W.white.bold(`Implementation Details:`)+`
`+s.details,{padding:{top:0,bottom:0,left:1,right:1},borderColor:`cyan`,borderStyle:`round`,margin:{top:1,bottom:0}}));let u=!!s.parentId;if(!u&&s.subtasks&&s.subtasks.length>0){console.log(G(W.white.bold(`Subtasks`),{padding:{top:0,bottom:0,left:1,right:1},margin:{top:1,bottom:0},borderColor:`magenta`,borderStyle:`round`}));let e=process.stdout.columns-10||100,t=Math.floor(e*(8/100)),n=Math.floor(e*(15/100)),r=Math.floor(e*(25/100)),i=Math.floor(e*(52/100)),a=new J({head:[W.magenta.bold(`ID`),W.magenta.bold(`Status`),W.magenta.bold(`Title`),W.magenta.bold(`Deps`)],colWidths:[t,n,i,r],style:{head:[],border:[],"padding-top":0,"padding-bottom":0,compact:!0},chars:{mid:``,"left-mid":``,"mid-mid":``,"right-mid":``},wordWrap:!0});s.subtasks.forEach(e=>{let t={done:W.green,completed:W.green,pending:W.yellow,"in-progress":W.blue}[e.status||`pending`]||W.white,n=`None`;if(e.dependencies&&e.dependencies.length>0){let t=e.dependencies.map(e=>{if(typeof e==`number`&&e<100){let t=s.subtasks.find(t=>t.id===e);if(t){let n=t.status===`done`||t.status===`completed`,r=t.status===`in-progress`;return n?W.green.bold(`${s.id}.${e}`):r?W.hex(`#FFA500`).bold(`${s.id}.${e}`):W.red.bold(`${s.id}.${e}`)}return W.red(`${s.id}.${e} (Not found)`)}return e});n=t.length===1?t[0]:t.join(W.white(`, `))}a.push([`${s.id}.${e.id}`,t(e.status||`pending`),e.title,n])}),console.log(a.toString())}!u&&(!s.subtasks||s.subtasks.length===0)&&console.log(G(W.yellow(`No subtasks found. Consider breaking down this task:`)+`
`+W.white(`Run: ${W.cyan(`task-master expand --id=${s.id}`)}`),{padding:{top:0,bottom:0,left:1,right:1},borderColor:`yellow`,borderStyle:`round`,margin:{top:1,bottom:0}}));let d=W.white.bold(`Suggested Actions:`)+`
`;u?d+=`${W.cyan(`1.`)} Mark as in-progress: ${W.yellow(`task-master set-status --id=${s.id} --status=in-progress`)}\n${W.cyan(`2.`)} Mark as done when completed: ${W.yellow(`task-master set-status --id=${s.id} --status=done`)}\n${W.cyan(`3.`)} View parent task: ${W.yellow(`task-master show --id=${s.parentId}`)}`:d+=`${W.cyan(`1.`)} Mark as in-progress: ${W.yellow(`task-master set-status --id=${s.id} --status=in-progress`)}\n${W.cyan(`2.`)} Mark as done when completed: ${W.yellow(`task-master set-status --id=${s.id} --status=done`)}\n`+(s.subtasks&&s.subtasks.length>0?`${W.cyan(`3.`)} Update subtask status: ${W.yellow(`task-master set-status --id=${s.id}.1 --status=done`)}`:`${W.cyan(`3.`)} Break down into subtasks: ${W.yellow(`task-master expand --id=${s.id}`)}`),console.log(G(d,{padding:{top:0,bottom:0,left:1,right:1},borderColor:`green`,borderStyle:`round`,margin:{top:1}})),lt(a)}async function xt(e){if(!K.existsSync(e)){console.log(G(W.yellow(`No complexity report found at ${e}\n\n`)+`Would you like to generate one now?`,{padding:1,borderColor:`yellow`,borderStyle:`round`,margin:{top:1}}));let t=xe.createInterface({input:process.stdin,output:process.stdout}),n=await new Promise(e=>{t.question(W.cyan(`Generate complexity report? (y/n): `),e)});if(t.close(),n.toLowerCase()===`y`||n.toLowerCase()===`yes`){console.log(W.blue(`Generating complexity report...`));let t=s;return K.existsSync(t)?(await xi({output:e,research:!1,file:t}),xt(e)):(console.error(`โ No tasks.json file found. Please run "task-master init" or create a tasks.json file.`),null)}else{console.log(W.yellow(`Report generation cancelled.`));return}}let t;try{t=JSON.parse(K.readFileSync(e,`utf8`))}catch(e){z(`error`,`Error reading complexity report: ${e.message}`);return}console.log(G(W.white.bold(`Task Complexity Analysis Report`),{padding:1,borderColor:`blue`,borderStyle:`round`,margin:{top:1,bottom:1}}));let n=new J({style:{head:[],border:[],"padding-top":0,"padding-bottom":0,compact:!0},chars:{mid:``,"left-mid":``,"mid-mid":``,"right-mid":``},colWidths:[20,50]});n.push([W.cyan.bold(`Generated:`),new Date(t.meta.generatedAt).toLocaleString()],[W.cyan.bold(`Tasks Analyzed:`),t.meta.tasksAnalyzed],[W.cyan.bold(`Threshold Score:`),t.meta.thresholdScore],[W.cyan.bold(`Project:`),t.meta.projectName],[W.cyan.bold(`Research-backed:`),t.meta.usedResearch?`Yes`:`No`]),console.log(n.toString());let r=[...t.complexityAnalysis].sort((e,t)=>t.complexityScore-e.complexityScore),i=r.filter(e=>e.complexityScore>=t.meta.thresholdScore),a=r.filter(e=>e.complexityScore<t.meta.thresholdScore),o=[0,0,0];r.forEach(e=>{e.complexityScore<5?o[0]++:e.complexityScore<8?o[1]++:o[2]++});let c=Math.round(o[0]/r.length*100),l=Math.round(o[1]/r.length*100),u=Math.round(o[2]/r.length*100);console.log(G(W.white.bold(`Complexity Distribution
`)+`${W.green.bold(`Low (1-4):`)} ${o[0]} tasks (${c}%)\n${W.yellow.bold(`Medium (5-7):`)} ${o[1]} tasks (${l}%)\n${W.red.bold(`High (8-10):`)} ${o[2]} tasks (${u}%)`,{padding:1,borderColor:`cyan`,borderStyle:`round`,margin:{top:1,bottom:1}}));let d=process.stdout.columns||100,f=Math.floor(d*.25),p=d-12-f-8-8-10,m=new J({head:[W.yellow.bold(`ID`),W.yellow.bold(`Title`),W.yellow.bold(`Score`),W.yellow.bold(`Subtasks`),W.yellow.bold(`Expansion Command`)],colWidths:[12,f,8,8,p],style:{head:[],border:[]},wordWrap:!0,wrapOnWordBoundary:!0});if(i.forEach(e=>{let t=`task-master expand --id=${e.taskId} --num=${e.recommendedSubtasks}${e.expansionPrompt?` --prompt="${e.expansionPrompt}"`:``}`;m.push([e.taskId,V(e.taskTitle,f-3),yt(e.complexityScore),e.recommendedSubtasks,W.cyan(t)])}),console.log(m.toString()),a.length>0){console.log(G(W.green.bold(`Simple Tasks (${a.length})`),{padding:{left:2,right:2,top:0,bottom:0},margin:{top:1,bottom:0},borderColor:`green`,borderStyle:`round`}));let e=new J({head:[W.green.bold(`ID`),W.green.bold(`Title`),W.green.bold(`Score`),W.green.bold(`Reasoning`)],colWidths:[5,40,8,50],style:{head:[],border:[]}});a.forEach(t=>{e.push([t.taskId,V(t.taskTitle,37),yt(t.complexityScore),V(t.reasoning,47)])}),console.log(e.toString())}console.log(G(W.white.bold(`Suggested Actions:`)+`
${W.cyan(`1.`)} Expand all complex tasks: ${W.yellow(`task-master expand --all`)}\n${W.cyan(`2.`)} Expand a specific task: ${W.yellow(`task-master expand --id=<id>`)}\n${W.cyan(`3.`)} Regenerate with research: ${W.yellow(`task-master analyze-complexity --research`)}`,{padding:1,borderColor:`cyan`,borderStyle:`round`,margin:{top:1}}))}async function St(e){console.log(G(W.yellow(`It looks like you've already generated tasks for this project.
`)+W.yellow(`Executing this command will overwrite any existing tasks.`),{padding:1,borderColor:`yellow`,borderStyle:`round`,margin:{top:1}}));let t=xe.createInterface({input:process.stdin,output:process.stdout}),n=await new Promise(e=>{t.question(W.cyan(`Are you sure you wish to continue? (y/N): `),e)});return t.close(),n.toLowerCase()===`y`||n.toLowerCase()===`yes`}function Ct(e){if(!e||e.length===0){console.log(W.yellow(`No API key status information available.`));return}let t=new J({head:[W.cyan(`Provider`),W.cyan(`CLI Key (.env)`),W.cyan(`MCP Key (mcp.json)`)],colWidths:[15,20,25],chars:{mid:``,"left-mid":``,"mid-mid":``,"right-mid":``}});e.forEach(({provider:e,cli:n,mcp:r})=>{let i=n?W.green(`โ
Found`):W.red(`โ Missing`),a=r?W.green(`โ
Found`):W.red(`โ Missing`),o=e.charAt(0).toUpperCase()+e.slice(1);t.push([o,i,a])}),console.log(W.bold(`
๐ API Key Status:`)),console.log(t.toString()),console.log(W.gray(` Note: Some providers (e.g., Azure, Ollama) may require additional endpoint configuration in ${o}.`))}const wt=(e,t)=>{if(e==null||e<=0)return`N/A`;let n=`${(e*100).toFixed(1)}%`,r=[...t.map(e=>e.sweScore).filter(e=>e!=null&&e>0)].sort((e,t)=>t-e),i=r.length,a=W.gray(`โโโ`);if(i>0){let t=Math.max(0,Math.floor(i/3)-1),n=Math.max(0,Math.floor(2*i/3)-1);a=e>=r[t]?W.yellow(`โ
โ
โ
`):e>=r[n]?W.yellow(`โ
โ
`)+W.gray(`โ`):W.yellow(`โ
`)+W.gray(`โโ`)}return`${n} ${a}`},Tt=e=>{if(!e)return`N/A`;if(e.input===0&&e.output===0)return W.green(`Free`);let t=e=>{if(e==null)return`N/A`;let t=Number.isInteger(e);return`$${e.toFixed(t?0:2)}`};return`${t(e.input)} in, ${t(e.output)} out`};function Et(e,t=[]){console.log(W.cyan.bold(`
Active Model Configuration:`));let n=e.activeModels,r=new J({head:[`Role`,`Provider`,`Model ID`,`SWE Score`,`Cost ($/1M tkns)`].map(e=>W.cyan.bold(e)),colWidths:[10,14,30,18,20],style:{head:[`cyan`,`bold`]}});r.push([W.white(`Main`),n.main.provider,n.main.modelId,wt(n.main.sweScore,t),Tt(n.main.cost)]),r.push([W.white(`Research`),n.research.provider,n.research.modelId,wt(n.research.sweScore,t),Tt(n.research.cost)]),n.fallback&&n.fallback.provider&&n.fallback.modelId?r.push([W.white(`Fallback`),n.fallback.provider,n.fallback.modelId,wt(n.fallback.sweScore,t),Tt(n.fallback.cost)]):r.push([W.white(`Fallback`),W.gray(`-`),W.gray(`(Not Set)`),W.gray(`-`),W.gray(`-`)]),console.log(r.toString())}function Dt(e){if(!e||e.length===0){console.log(W.gray(`
(No other models available or all are configured)`));return}console.log(W.cyan.bold(`
Other Available Models:`));let t=new J({head:[`Provider`,`Model ID`,`SWE Score`,`Cost ($/1M tkns)`].map(e=>W.cyan.bold(e)),colWidths:[15,40,18,25],style:{head:[`cyan`,`bold`]}});e.forEach(n=>{t.push([n.provider,n.modelId,wt(n.sweScore,e),Tt(n.cost)])}),console.log(t.toString()),console.log(G(W.white.bold(`Next Steps:`)+`
`+W.cyan(`1. Set main model: ${W.yellow(`task-master models --set-main <model_id>`)}`)+`
`+W.cyan(`2. Set research model: ${W.yellow(`task-master models --set-research <model_id>`)}`)+`
`+W.cyan(`3. Set fallback model: ${W.yellow(`task-master models --set-fallback <model_id>`)}`)+`
`+W.cyan(`4. Run interactive setup: ${W.yellow(`task-master models --setup`)}`)+`
`+W.cyan(`5. Use custom ollama/openrouter models: ${W.yellow(`task-master models --openrouter|ollama --set-main|research|fallback <model_id>`)}`),{padding:1,borderColor:`yellow`,borderStyle:`round`,margin:{top:1}}))}function Ot(e,t=`cli`){if(t!==`cli`&&t!==`text`||!e||R())return;let{modelUsed:n,providerName:r,inputTokens:i,outputTokens:a,totalTokens:o,totalCost:s,commandName:c}=e,l=W.bold.blue(`AI Usage Summary:`)+`
`;l+=W.gray(` Command: ${c}\n`),l+=W.gray(` Provider: ${r}\n`),l+=W.gray(` Model: ${n}\n`),l+=W.gray(` Tokens: ${o} (Input: ${i}, Output: ${a})\n`),l+=W.gray(` Est. Cost: $${s.toFixed(6)}`),console.log(G(l,{padding:1,margin:{top:1},borderColor:`blue`,borderStyle:`round`,title:`๐ก Telemetry`,titleAlignment:`center`}))}function kt(e,t,n){if(R()||!e)return;let{highRelevance:r,mediumRelevance:i,recentTasks:a,allRelevantTasks:o}=e,s=W.white.bold(`Context Analysis`)+`
`;s+=W.gray(`Query: `)+W.white(`"${t}"`)+`
`,s+=W.gray(`Context size: `)+W.cyan(`${n.toLocaleString()} characters`)+`
`,s+=W.gray(`Tasks found: `)+W.yellow(`${o.length} relevant tasks`)+`
`,r.length>0&&(s+=W.green.bold(`๐ฏ High Relevance Matches:`)+`
`,r.slice(0,3).forEach(e=>{s+=W.green(` โข Task ${e.id}: ${V(e.title,50)}`)+`
`}),r.length>3&&(s+=W.green(` โข ... and ${r.length-3} more high relevance tasks`)+`
`),s+=`
`),i.length>0&&(s+=W.yellow.bold(`๐ Medium Relevance Matches:`)+`
`,i.slice(0,3).forEach(e=>{s+=W.yellow(` โข Task ${e.id}: ${V(e.title,50)}`)+`
`}),i.length>3&&(s+=W.yellow(` โข ... and ${i.length-3} more medium relevance tasks`)+`
`),s+=`
`);let c=a.filter(e=>!r.some(t=>t.id===e.id)&&!i.some(t=>t.id===e.id));c.length>0&&(s+=W.cyan.bold(`๐ Recent Tasks (for context):`)+`
`,c.slice(0,2).forEach(e=>{s+=W.cyan(` โข Task ${e.id}: ${V(e.title,50)}`)+`
`}),c.length>2&&(s+=W.cyan(` โข ... and ${c.length-2} more recent tasks`)+`
`)),console.log(G(s,{padding:{top:1,bottom:1,left:2,right:2},margin:{top:1,bottom:0},borderStyle:`round`,borderColor:`blue`,title:W.blue(`๐ Context Gathering`),titleAlignment:`center`}))}function At(e,t,n,r){console.log(W.red(`\nโ Cannot move tasks from "${t}" to "${n}"`)),console.log(W.yellow(`
Cross-tag dependency conflicts detected:`)),e.length>0&&e.forEach(e=>{console.log(` โข ${e.message}`)}),console.log(W.cyan(`
Resolution options:`)),console.log(` 1. Move with dependencies: task-master move --from=${r} --from-tag=${t} --to-tag=${n} --with-dependencies`),console.log(` 2. Break dependencies: task-master move --from=${r} --from-tag=${t} --to-tag=${n} --ignore-dependencies`),console.log(` 3. Validate and fix dependencies: task-master validate-dependencies && task-master fix-dependencies`),e.length>0&&console.log(` 4. Move dependencies first: task-master move --from=${e.map(e=>e.dependencyId).join(`,`)} --from-tag=${e[0].dependencyTag} --to-tag=${n}`)}function jt(e){return e===null?`null`:e===void 0?`undefined`:e===``?`(empty)`:b(e)||`unknown`}function Mt(e,t,n){let r=jt(e),i=e||`unknown`,a=i;if(i.includes(`.`)){let e=i.split(`.`);e.length===2&&e[0]&&e[1]?a=e[0]:(console.log(W.yellow(`\nโ ๏ธ Warning: Unexpected taskId format "${i}". Using as-is for command suggestions.`)),a=i)}console.log(W.red(`\nโ Cannot move subtask ${r} directly between tags`)),console.log(W.yellow(`
Subtask movement restriction:`)),console.log(` โข Subtasks cannot be moved directly between tags`),console.log(` โข They must be promoted to full tasks first`),console.log(` โข Source tag: "${t}"`),console.log(` โข Target tag: "${n}"`),console.log(W.cyan(`
Resolution options:`)),console.log(` 1. Promote subtask to full task: task-master remove-subtask --id=${r} --convert`),console.log(` 2. Then move the promoted task: task-master move --from=${a} --from-tag=${t} --to-tag=${n}`),console.log(` 3. Or move the parent task with all subtasks: task-master move --from=${a} --from-tag=${t} --to-tag=${n} --with-dependencies`)}function Nt(e,t,n){console.log(W.red(`
โ Invalid tag combination`)),console.log(W.yellow(`
Error details:`)),console.log(` โข Source tag: "${e}"`),console.log(` โข Target tag: "${t}"`),console.log(` โข Reason: ${n}`),console.log(W.cyan(`
Resolution options:`)),console.log(` 1. Use different tags for cross-tag moves`),console.log(` 2. Use within-tag move: task-master move --from=<id> --to=<id> --tag=${e}`),console.log(` 3. Check available tags: task-master tags`)}function Pt(e=`general`){let t={"before-move":[`๐ก Tip: Run "task-master validate-dependencies" to check for dependency issues before moving tasks`,`๐ก Tip: Use "task-master fix-dependencies" to automatically resolve common dependency problems`,`๐ก Tip: Consider using --with-dependencies flag to move dependent tasks together`],"after-error":[`๐ง Quick fix: Run "task-master validate-dependencies" to identify specific issues`,`๐ง Quick fix: Use "task-master fix-dependencies" to automatically resolve problems`,`๐ง Quick fix: Check "task-master show <id>" to see task dependencies before moving`],general:[`๐ก Use "task-master validate-dependencies" to check for dependency issues`,`๐ก Use "task-master fix-dependencies" to automatically resolve problems`,`๐ก Use "task-master show <id>" to view task dependencies`,`๐ก Use --with-dependencies flag to move dependent tasks together`]},n=t[e]||t.general;console.log(W.cyan(`
Helpful hints:`)),new Set(n).forEach(e=>{console.log(` ${e}`)})}var Ft={id:`analyze-complexity`,version:`1.0.0`,description:`Analyze task complexity and generate expansion recommendations`,metadata:{author:`system`,created:`2024-01-01T00:00:00Z`,updated:`2024-01-01T00:00:00Z`,tags:[`analysis`,`complexity`,`expansion`,`recommendations`]},parameters:{tasks:{type:`array`,required:!0,description:`Array of tasks to analyze`},gatheredContext:{type:`string`,default:``,description:`Additional project context`},threshold:{type:`number`,default:5,min:1,max:10,description:`Complexity threshold for expansion recommendation`},useResearch:{type:`boolean`,default:!1,description:`Use research mode for deeper analysis`},hasCodebaseAnalysis:{type:`boolean`,default:!1,description:`Whether codebase analysis is available`},projectRoot:{type:`string`,default:``,description:`Project root path for context`}},prompts:{default:{system:`You are an expert software architect and project manager analyzing task complexity. Respond only with the requested valid JSON array.`,user:`{{#if hasCodebaseAnalysis}}## IMPORTANT: Codebase Analysis Required
You have access to powerful codebase analysis tools. Before analyzing task complexity:
1. Use the Glob tool to explore the project structure and understand the codebase size
2. Use the Grep tool to search for existing implementations related to each task
3. Use the Read tool to examine key files that would be affected by these tasks
4. Understand the current implementation state, patterns used, and technical debt
Based on your codebase analysis:
- Assess complexity based on ACTUAL code that needs to be modified/created
- Consider existing abstractions and patterns that could simplify implementation
- Identify tasks that require refactoring vs. greenfield development
- Factor in dependencies between existing code and new features
- Provide more accurate subtask recommendations based on real code structure
Project Root: {{projectRoot}}
{{/if}}Analyze the following tasks to determine their complexity (1-10 scale) and recommend the number of subtasks for expansion. Provide a brief reasoning and an initial expansion prompt for each.{{#if useResearch}} Consider current best practices, common implementation patterns, and industry standards in your analysis.{{/if}}
Tasks:
{{{json tasks}}}
{{#if gatheredContext}}
# Project Context
{{gatheredContext}}
{{/if}}
Respond ONLY with a valid JSON array matching the schema:
[
{
"taskId": <number>,
"taskTitle": "<string>",
"complexityScore": <number 1-10>,
"recommendedSubtasks": <number>,
"expansionPrompt": "<string>",
"reasoning": "<string>"
},
...
]
Do not include any explanatory text, markdown formatting, or code block markers before or after the JSON array.`}}},It={id:`expand-task`,version:`1.0.0`,description:`Break down a task into detailed subtasks`,metadata:{author:`system`,created:`2024-01-01T00:00:00Z`,updated:`2024-01-01T00:00:00Z`,tags:[`expansion`,`subtasks`,`breakdown`]},parameters:{subtaskCount:{type:`number`,required:!0,description:`Number of subtasks to generate`},task:{type:`object`,required:!0,description:`The task to expand`},nextSubtaskId:{type:`number`,required:!0,description:`Starting ID for new subtasks`},useResearch:{type:`boolean`,default:!1,description:`Use research mode`},expansionPrompt:{type:`string`,required:!1,description:`Expansion prompt from complexity report`},additionalContext:{type:`string`,required:!1,default:``,description:`Additional context for task expansion`},complexityReasoningContext:{type:`string`,required:!1,default:``,description:`Complexity analysis reasoning context`},gatheredContext:{type:`string`,required:!1,default:``,description:`Gathered project context`},hasCodebaseAnalysis:{type:`boolean`,required:!1,default:!1,description:`Whether codebase analysis is available`},projectRoot:{type:`string`,required:!1,default:``,description:`Project root path for context`}},prompts:{"complexity-report":{condition:`expansionPrompt`,system:`You are an AI assistant helping with task breakdown. Generate {{#if (gt subtaskCount 0)}}exactly {{subtaskCount}}{{else}}an appropriate number of{{/if}} subtasks based on the provided prompt and context.
Respond ONLY with a valid JSON object containing a single key "subtasks" whose value is an array of the generated subtask objects.
Each subtask object in the array must have keys: "id", "title", "description", "dependencies", "details", "status".
Ensure the 'id' starts from {{nextSubtaskId}} and is sequential.
For 'dependencies', use the full subtask ID format: "{{task.id}}.1", "{{task.id}}.2", etc. Only reference subtasks within this same task.
Ensure 'status' is 'pending'.
Do not include any other text or explanation.`,user:`Break down the following task based on the analysis prompt:
Parent Task:
ID: {{task.id}}
Title: {{task.title}}
Description: {{task.description}}
Current details: {{#if task.details}}{{task.details}}{{else}}None{{/if}}
Expansion Guidance:
{{expansionPrompt}}{{#if additionalContext}}
{{additionalContext}}{{/if}}{{#if complexityReasoningContext}}
{{complexityReasoningContext}}{{/if}}{{#if gatheredContext}}
# Project Context
{{gatheredContext}}{{/if}}
Generate {{#if (gt subtaskCount 0)}}exactly {{subtaskCount}}{{else}}an appropriate number of{{/if}} subtasks with sequential IDs starting from {{nextSubtaskId}}.`},research:{condition:`useResearch === true && !expansionPrompt`,system:`You are an AI assistant that responds ONLY with valid JSON objects as requested. The object should contain a 'subtasks' array.`,user:`{{#if hasCodebaseAnalysis}}## IMPORTANT: Codebase Analysis Required
You have access to powerful codebase analysis tools. Before generating subtasks:
1. Use the Glob tool to explore relevant files for this task (e.g., "**/*.js", "src/**/*.ts")
2. Use the Grep tool to search for existing implementations related to this task
3. Use the Read tool to examine files that would be affected by this task
4. Understand the current implementation state and patterns used
Based on your analysis:
- Identify existing code that relates to this task
- Understand patterns and conventions to follow
- Generate subtasks that integrate smoothly with existing code
- Ensure subtasks are specific and actionable based on the actual codebase
Project Root: {{projectRoot}}
{{/if}}Analyze the following task and break it down into {{#if (gt subtaskCount 0)}}exactly {{subtaskCount}}{{else}}an appropriate number of{{/if}} specific subtasks using your research capabilities. Assign sequential IDs starting from {{nextSubtaskId}}.
Parent Task:
ID: {{task.id}}
Title: {{task.title}}
Description: {{task.description}}
Current details: {{#if task.details}}{{task.details}}{{else}}None{{/if}}{{#if additionalContext}}
Consider this context: {{additionalContext}}{{/if}}{{#if complexityReasoningContext}}
Complexity Analysis Reasoning: {{complexityReasoningContext}}{{/if}}{{#if gatheredContext}}
# Project Context
{{gatheredContext}}{{/if}}
CRITICAL: Respond ONLY with a valid JSON object containing a single key "subtasks". The value must be an array of the generated subtasks, strictly matching this structure:
{
"subtasks": [
{
"id": <number>, // Sequential ID starting from {{nextSubtaskId}}
"title": "<string>",
"description": "<string>",
"dependencies": ["<string>"], // Use full subtask IDs like ["{{task.id}}.1", "{{task.id}}.2"]. If no dependencies, use an empty array [].
"