taskgraph-ai 0.52.23 → 0.54.12

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.
Files changed (40) hide show
  1. package/README.md +38 -34
  2. package/dist/ai-services-unified-BPPVDTpt.js +3 -0
  3. package/dist/ai-services-unified-Dskm2lPO.js +1 -0
  4. package/dist/assets/AGENTS.md +12 -13
  5. package/dist/commands-DJc5m0Gi.js +126 -0
  6. package/dist/config-manager-CKwBfpAp.js +1 -0
  7. package/dist/config-manager-Db2R8Tgw.js +1 -0
  8. package/dist/git-utils-CRR3iPaC.js +1 -0
  9. package/dist/{git-utils--i2q96hv.js → git-utils-NnZtE3nY.js} +1 -1
  10. package/dist/init-CK_i6ZcN.js +24 -0
  11. package/dist/mcp-server.js +2 -2
  12. package/dist/research-BKsPc_oX.js +1 -0
  13. package/dist/research-C8rAJdp0.js +585 -0
  14. package/dist/{response-language-ip84ug-k.js → response-language-C8euRV2w.js} +1 -1
  15. package/dist/response-language-DiIdcmnK.js +1 -0
  16. package/dist/rolldown-runtime-BxhE39jg.js +1 -0
  17. package/dist/src-CK3olqVP.js +468 -0
  18. package/dist/src-DRpuDe-k.js +207 -0
  19. package/dist/tag-management-BL0w3Tk3.js +1 -0
  20. package/dist/task-manager-B_UFNQnE.js +1 -0
  21. package/dist/task-manager-BipYRXFW.js +167 -0
  22. package/dist/taskgraph.js +1 -1
  23. package/package.json +3 -8
  24. package/dist/ai-services-unified-CigO4oTy.js +0 -1
  25. package/dist/ai-services-unified-kmQRPU0g.js +0 -3
  26. package/dist/assets/claude/TM_COMMANDS_GUIDE.md +0 -147
  27. package/dist/assets/scripts_README.md +0 -443
  28. package/dist/commands-dFNugMWF.js +0 -116
  29. package/dist/config-manager-C5Ih13nA.js +0 -1
  30. package/dist/config-manager-DhVH8AQp.js +0 -1
  31. package/dist/dependency-manager-CCREovZA.js +0 -758
  32. package/dist/git-utils-BezpEZd4.js +0 -1
  33. package/dist/init-p_pWjmVE.js +0 -3139
  34. package/dist/research-blv_5JOT.js +0 -1
  35. package/dist/response-language-D9UxmXBp.js +0 -1
  36. package/dist/src-TZm8h0X-.js +0 -207
  37. package/dist/src-yE1DeXKG.js +0 -468
  38. package/dist/tag-management-Br2FX-YC.js +0 -1
  39. package/dist/task-manager-DWPIhAB7.js +0 -1
  40. package/index.js +0 -157
@@ -1,116 +0,0 @@
1
- import{c as e,l as t}from"./src-TZm8h0X-.js";import{$ as n,Ct as r,Dt as i,I as a,K as o,O as s,St as c,T as l,b as u,dt as d,gt as f,ht as p,rt as m,s as h,t as g,wt as _,xt as v}from"./config-manager-DhVH8AQp.js";import{A as y,C as ee,E as te,H as b,M as ne,S as re,T as ie,U as ae,W as x,_ as oe,a as se,b as ce,g as le,i as ue,j as S,l as de,m as fe,n as pe,o as C,r as me,s as he,t as ge,u as _e,v as ve,w,y as T}from"./src-yE1DeXKG.js";import{A as ye,B as be,C as xe,H as Se,I as E,L as D,M as O,N as k,O as A,R as j,T as M,V as N,_ as Ce,a as we,b as Te,c as Ee,d as P,f as De,g as Oe,h as F,i as ke,j as Ae,k as je,l as I,m as Me,n as Ne,o as Pe,p as Fe,r as Ie,s as Le,t as Re,u as ze,v as Be,w as L,y as Ve,z as He}from"./dependency-manager-CCREovZA.js";import{t as Ue}from"./response-language-ip84ug-k.js";import{n as R,r as We,t as Ge}from"./init-p_pWjmVE.js";import z from"chalk";import Ke from"node:path";import B from"path";import V from"node:fs";import qe from"node:os";import H from"fs";import{Command as Je,Option as U}from"commander";import W from"boxen";import Ye from"process";import G from"https";import K from"inquirer";function Xe(){let e=Ye.env.TM_PUBLIC_VERSION;return e&&e!==`unknown`?e:(console.warn(`Could not read version from TM_PUBLIC_VERSION, using fallback`),`0.0.0`)}function q(e,t){let n=e=>{let[t,n=``]=e.split(`-`,2);return{nums:t.split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n}},r=n(e),i=n(t),a=Math.max(r.nums.length,i.nums.length);for(let e=0;e<a;e++){let t=(r.nums[e]||0)-(i.nums[e]||0);if(t!==0)return t<0?-1:1}return r.pre&&!i.pre?-1:!r.pre&&i.pre?1:r.pre===i.pre?0:r.pre<i.pre?-1:1}async function Ze(e){return new Promise(t=>{let n={hostname:`raw.githubusercontent.com`,path:`/${ce}/main/CHANGELOG.md`,method:`GET`,headers:{"User-Agent":`${T}/${e}`}},r=G.request(n,n=>{let r=``;n.on(`data`,e=>{r+=e}),n.on(`end`,()=>{try{if(n.statusCode!==200){t([]);return}t(Qe(r,e))}catch{t([])}})});r.on(`error`,()=>{t([])}),r.setTimeout(3e3,()=>{r.destroy(),t([])}),r.end()})}function Qe(e,t){try{if(!/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(t))return[];let n=RegExp(`## ${t.replace(/\./g,`\\.`)}\\s*\\n`,`i`),r=e.match(n);if(!r)return[];let i=r.index+r[0].length,a=e.indexOf(`
2
- ## `,i),o=(a>0?e.slice(i,a):e.slice(i)).match(/### Minor Changes\s*\n([\s\S]*?)(?=\n###|\n##|$)/i);if(!o)return[];let s=o[1],c=[],l=/^-\s+\[#\d+\][^\n]*?!\s+-\s+(.+?)$/gm,u;for(;(u=l.exec(s))!==null;){let e=u[1].trim();c.push(e)}return c}catch{return[]}}const J=()=>Ke.join(qe.tmpdir(),`taskgraph-update-cache.json`);function $e(){try{let e=J();if(!V.existsSync(e))return null;let t=JSON.parse(V.readFileSync(e,`utf-8`));return Date.now()-t.timestamp>36e5?null:t}catch{return null}}function et(e,t){try{V.writeFileSync(J(),JSON.stringify({timestamp:Date.now(),latestVersion:e,highlights:t},null,2))}catch{}}function tt(e){return new Promise(t=>{let n=G.request({hostname:`registry.npmjs.org`,path:`/${T}`,method:`GET`,headers:{Accept:`application/vnd.npm.install-v1+json`,"User-Agent":`${T}/${e}`}},e=>{let n=``;e.on(`data`,e=>n+=e),e.on(`end`,()=>{try{if(e.statusCode!==200){t(null);return}t(JSON.parse(n)[`dist-tags`]?.latest||null)}catch{t(null)}})});n.on(`error`,()=>t(null)),n.setTimeout(3e3,()=>{n.destroy(),t(null)}),n.end()})}function Y(e,t,n){return{currentVersion:e,latestVersion:t,needsUpdate:q(e,t)<0,highlights:n}}async function nt(e){let t=e||Xe(),n=$e();if(n)return Y(t,n.latestVersion,n.highlights);let r=await tt(t);if(!r)return Y(t,t);let i=q(t,r)<0?await Ze(r):void 0;return et(r,i),Y(t,r,i)}var rt=class{#e;#t;constructor(e,t){this.#e=Object.freeze({...e}),this.#t=t}getProjectRoot(){return this.#e.projectRoot}getTaskGraphDir(){return this.#e.taskGraphDir}getTasksPath(){return this.#e.tasksPath}getPrdPath(){return this.#e.prdPath}getComplexityReportPath(){if(this.#e.complexityReportPath)return this.#e.complexityReportPath;let e=this.getCurrentTag()===`master`?f:f.replace(`.json`,`_${this.getCurrentTag()}.json`);return B.join(this.#e.projectRoot,e)}getConfigPath(){return this.#e.configPath}getStatePath(){return this.#e.statePath}getAllPaths(){return this.#e}getCurrentTag(){if(this.#t)return this.#t;try{if(H.existsSync(this.#e.statePath)){let e=H.readFileSync(this.#e.statePath,`utf8`),t=JSON.parse(e);if(t&&t.currentTag)return t.currentTag}}catch{}try{if(H.existsSync(this.#e.configPath)){let e=H.readFileSync(this.#e.configPath,`utf8`),t=JSON.parse(e);if(t&&t.global&&t.global.defaultTag)return t.global.defaultTag}}catch{}return`master`}};function X(e={}){let t=(e,t,n=[],r=null,i=!1)=>{if(typeof t==`string`){let n=B.isAbsolute(t)?t:B.resolve(r||process.cwd(),t);if(i){let t=B.dirname(n);if(!H.existsSync(t))try{H.mkdirSync(t,{recursive:!0})}catch(n){throw Error(`Could not create directory for ${e}: ${t}. Error: ${n.message}`)}}else if(!H.existsSync(n))throw Error(`${e} override path does not exist: ${n}`);return n}if(t===!0){for(let e of n){let t=B.isAbsolute(e)?e:B.join(r||process.cwd(),e);if(H.existsSync(t))return t}throw Error(`Required ${e} not found. Searched: ${n.join(`, `)}`)}for(let e of n){let t=B.isAbsolute(e)?e:B.join(r||process.cwd(),e);if(H.existsSync(t))return t}return null},n={};if(e.projectRoot){let t=B.resolve(e.projectRoot);if(!H.existsSync(t))throw Error(`Project root override path does not exist: ${t}`);if(!H.existsSync(B.join(t,`.taskgraph`)))throw Error(`Project root override is not a valid taskgraph project: ${t}`);n.projectRoot=t}else n.projectRoot=a();return n.taskGraphDir=`taskGraphDir`in e?t(`taskgraph directory`,e.taskGraphDir,[c],n.projectRoot):t(`taskgraph directory`,!1,[c],n.projectRoot),n.configPath=B.join(n.projectRoot,v),n.statePath=B.join(n.taskGraphDir||B.join(n.projectRoot,`.taskgraph`),`state.json`),n.tasksPath=B.join(n.projectRoot,i),`configPath`in e&&(n.configPath=t(`config file`,e.configPath,[v],n.projectRoot)),`statePath`in e&&(n.statePath=t(`state file`,e.statePath,[`state.json`],n.taskGraphDir)),`tasksPath`in e&&(n.tasksPath=t(`tasks file`,e.tasksPath,[i],n.projectRoot)),`prdPath`in e&&(n.prdPath=t(`PRD file`,e.prdPath,[B.join(r,`PRD.md`),B.join(r,`prd.md`),B.join(r,`PRD.txt`),B.join(r,`prd.txt`)],n.projectRoot)),`complexityReportPath`in e&&(n.complexityReportPath=t(`complexity report`,e.complexityReportPath,[B.join(_,`task-complexity-report.json`),B.join(_,`complexity-report.json`)],n.projectRoot,!0)),new rt(n,e.tag)}function Z(e){let t=e?.message??``;if(/overloaded|rate limit|\b(429|529)\b/i.test(t))return`Claude is busy. Wait a minute and try again`;if(/empty stream response|did not return a valid/i.test(t))return`Try again, or reword the prompt`}function it(e){e.on(`option:unknown`,function(e){let t=this._name||`unknown`;x(`Unknown option '${e}'`,`Run \`taskgraph ${t} --help\` to see its options`),process.exit(1)}),e.command(`help`).description(`Show help information`).action(()=>{e.help()}),e.configureHelp({helpWidth:120,sortSubcommands:!1}),e.command(`parse-prd`).description(`Parse a PRD file and generate tasks`).argument(`[file]`,`Path to the PRD file`).option(`-i, --input <file>`,`Path to the PRD file (alternative to positional argument)`).option(`-o, --output <file>`,`Output file path`).option(`-n, --num-tasks <number>`,`Number of tasks to generate`,h()).option(`-f, --force`,`Skip confirmation when overwriting existing tasks`).option(`--append`,`Append new tasks to existing tasks.json instead of overwriting`).option(`-r, --research`,`Use Claude Code web research for research-backed task generation, providing more comprehensive and accurate task breakdown`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async(e,t)=>{let r=t.input||e;r&&!H.existsSync(B.resolve(r))&&(x(`${r} not found`,`Check the spelling; paths are relative to this folder`),process.exit(1));let i;try{let e={prdPath:r||!0,tag:t.tag};t.output&&(e.tasksPath=t.output),i=X(e)}catch(e){b(e,{hint:r?void 0:"Try `taskgraph parse-prd prd.md`"}),process.exit(1)}let a=parseInt(t.numTasks,10),o=t.force||!1,s=t.append||!1,c=t.research||!1,l=o,u=s,d=i.getCurrentTag();await I(d);async function f(){let e=!1,t=i.getTasksPath();if(H.existsSync(t))try{let n=H.readFileSync(t,`utf8`),r=JSON.parse(n);r[d]&&Array.isArray(r[d].tasks)&&r[d].tasks.length>0&&(e=!0)}catch{e=!1}if(e&&!l&&!u){if(!await we(t))return n(`info`,`Operation cancelled.`),!1;l=!0}return!0}try{if(!await f())return;s&&console.log(p.brand(`Appending to existing tasks...`)),c&&console.log(p.brand(`Using Claude Code web research for research-backed task generation`));let e=i.getTasksPath()||B.join(i.getProjectRoot(),`.taskgraph/tasks/tasks.json`);await Ae(i.getPrdPath(),e,a,{append:u,force:l,research:c,projectRoot:i.getProjectRoot(),tag:d})}catch(e){console.error(z.red(`Error parsing PRD: ${e.message}`)),process.exit(1)}}),e.command(`update`).description(`Update multiple tasks with ID >= "from" based on new information or implementation changes`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--from <id>`,`Task ID to start updating from (tasks with ID >= this value will be updated)`,`1`).option(`-p, --prompt <text>`,`Prompt explaining the changes or new context (required)`).option(`-r, --research`,`Use Claude Code web research for research-backed task updates`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=parseInt(e.from,10),r=e.prompt,i=e.research||!1;t.getTasksPath();let a=t.getCurrentTag();await I(a),(process.argv.includes(`--id`)||process.argv.some(e=>e.startsWith(`--id=`)))&&(console.error(z.red(`Error: The update command uses --from=<id>, not --id=<id>`)),console.log(z.yellow(`
3
- To update multiple tasks:`)),console.log(` taskgraph update --from=${n} --prompt="Your prompt here"`),console.log(z.yellow(`
4
- To update a single specific task, use the update-task command instead:`)),console.log(` taskgraph update-task --id=<id> --prompt="Your prompt here"`),process.exit(1)),r||(console.error(z.red(`Error: --prompt parameter is required. Please provide information about the changes.`)),process.exit(1)),i&&console.log(p.brand(`Using Claude Code web research for research-backed task updates`)),await Be(t.getTasksPath(),n,r,i,{projectRoot:t.getProjectRoot(),tag:a})}),e.command(`update-task`).description(`Update a single specific task by ID with new information`).argument(`[id]`,`Task ID to update (e.g., 1, 1.1, TAS-123)`).argument(`[prompt...]`,`Update prompt - multiple words, no quotes needed`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-i, --id <id>`,`Task ID to update (fallback if not using positional)`).option(`-p, --prompt <text>`,`Prompt (fallback if not using positional)`).option(`-r, --research`,`Use Claude Code web research for research-backed task updates`).option(`--append`,`Append timestamped information to task details instead of full update`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async(e,t,n)=>{try{let r=X({tasksPath:n.file||!0,tag:n.tag}),i=r.getTasksPath(),a=r.getCurrentTag();await I(a);let o=e||n.id,s=t.length>0?t.join(` `):n.prompt;o||(x(`Missing task ID`,'Try `taskgraph update-task --id=3 --prompt="what changed"`'),process.exit(1)),/^\d+$/.test(o)||(x(`"${o}" isn't a task ID`,o.includes(`.`)?"Update subtasks with `taskgraph update-subtask`":"Use a number like `3`"),process.exit(1)),s||(x(`Missing prompt`,`Try \`taskgraph update-task --id=${o} --prompt="what changed"\``),process.exit(1));let c=n.research||!1;H.existsSync(i)||(console.error(z.red(`Error: Tasks file not found at path: ${i}`)),console.log(i===`.taskgraph/tasks/tasks.json`?z.yellow(`Hint: Run taskgraph init or taskgraph parse-prd to create tasks.json first`):z.yellow(`Hint: Check if the file path is correct: ${i}`)),process.exit(1)),c&&console.log(p.brand(`Using Claude Code web research for this update`));let l=n.append||!1;await Ve(r.getTasksPath(),o,s,c,{projectRoot:r.getProjectRoot(),tag:a},`text`,l)||console.log(z.yellow(`
5
- Task update was not completed. Review the messages above for details.`))}catch(e){b(e,{hint:Z(e)})}}),e.command(`update-subtask`).description(`Update a subtask by appending additional timestamped information`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-i, --id <id>`,`Subtask ID to update (required)`).option(`-p, --prompt <text>`,`Prompt explaining what information to add (required)`).option(`-r, --research`,`Use Claude Code web research for research-backed updates`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{try{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=t.getTasksPath(),r=t.getCurrentTag();await I(r),e.id||(console.error(z.red(`Error: --id parameter is required`)),console.log(z.yellow(`Usage example: taskgraph update-subtask --id=5.2 --prompt="Add more details about the API endpoint"`)),process.exit(1));let i=e.id;e.prompt||(console.error(z.red(`Error: --prompt parameter is required. Please provide information to add to the subtask.`)),console.log(z.yellow(`Usage example: taskgraph update-subtask --id=5.2 --prompt="Add more details about the API endpoint"`)),process.exit(1));let a=e.prompt,o=e.research||!1;H.existsSync(n)||(console.error(z.red(`Error: Tasks file not found at path: ${n}`)),console.log(n===`.taskgraph/tasks/tasks.json`?z.yellow(`Hint: Run taskgraph init or taskgraph parse-prd to create tasks.json first`):z.yellow(`Hint: Check if the file path is correct: ${n}`)),process.exit(1)),o&&console.log(p.brand(`Using Claude Code web research for this update`)),await Te(t.getTasksPath(),i,a,o,{projectRoot:t.getProjectRoot(),tag:r})}catch(e){b(e,{hint:Z(e)})}}),e.command(`scope-up`).description(`Increase task complexity with AI assistance`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-i, --id <ids>`,`Comma-separated task/subtask IDs to scope up (required)`).option(`-s, --strength <level>`,`Complexity increase strength: light, regular, heavy`,`regular`).option(`-p, --prompt <text>`,`Custom instructions for targeted scope adjustments`).option(`-r, --research`,`Use research AI for more informed adjustments`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{try{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=t.getTasksPath(),r=t.getCurrentTag();await I(r),e.id||(console.error(z.red(`Error: --id parameter is required`)),console.log(z.yellow(`Usage example: taskgraph scope-up --id=1,2,3 --strength=regular`)),process.exit(1));let i=e.id.split(`,`).map(e=>{let t=parseInt(e.trim(),10);return(Number.isNaN(t)||t<=0)&&(console.error(z.red(`Error: Invalid task ID: ${e.trim()}`)),process.exit(1)),t});M(e.strength)||(console.error(z.red(`Error: Invalid strength level: ${e.strength}. Must be one of: light, regular, heavy`)),process.exit(1)),H.existsSync(n)||(console.error(z.red(`Error: Tasks file not found at path: ${n}`)),process.exit(1)),console.log(p.brand(`Scoping up ${i.length===1?`task`:`tasks`} ${i.join(`, `)}`));let a={projectRoot:t.getProjectRoot(),tag:r,commandName:`scope-up`,outputType:`cli`,research:e.research||!1},o=await L(n,i,e.strength,e.prompt||null,a,`text`);console.log(z.green(`✓ Scoped up ${o.updatedTasks.length} ${o.updatedTasks.length===1?`task`:`tasks`}`))}catch(e){b(e,{hint:Z(e)})}}),e.command(`scope-down`).description(`Decrease task complexity with AI assistance`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-i, --id <ids>`,`Comma-separated task/subtask IDs to scope down (required)`).option(`-s, --strength <level>`,`Complexity decrease strength: light, regular, heavy`,`regular`).option(`-p, --prompt <text>`,`Custom instructions for targeted scope adjustments`).option(`-r, --research`,`Use research AI for more informed adjustments`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{try{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=t.getTasksPath(),r=t.getCurrentTag();await I(r),e.id||(console.error(z.red(`Error: --id parameter is required`)),console.log(z.yellow(`Usage example: taskgraph scope-down --id=1,2,3 --strength=regular`)),process.exit(1));let i=e.id.split(`,`).map(e=>{let t=parseInt(e.trim(),10);return(Number.isNaN(t)||t<=0)&&(console.error(z.red(`Error: Invalid task ID: ${e.trim()}`)),process.exit(1)),t});M(e.strength)||(console.error(z.red(`Error: Invalid strength level: ${e.strength}. Must be one of: light, regular, heavy`)),process.exit(1)),H.existsSync(n)||(console.error(z.red(`Error: Tasks file not found at path: ${n}`)),process.exit(1)),console.log(p.brand(`Scoping down ${i.length===1?`task`:`tasks`} ${i.join(`, `)}`));let a={projectRoot:t.getProjectRoot(),tag:r,commandName:`scope-down`,outputType:`cli`,research:e.research||!1},o=await xe(n,i,e.strength,e.prompt||null,a,`text`);console.log(z.green(`✓ Scoped down ${o.updatedTasks.length} ${o.updatedTasks.length===1?`task`:`tasks`}`))}catch(e){b(e,{hint:Z(e)})}}),se(e),e.command(`expand`).description(`Expand a task into subtasks using AI`).option(`-i, --id <id>`,`ID of the task to expand`).option(`-a, --all`,`Expand all pending tasks based on complexity analysis`).option(`-n, --num <number>`,`Number of subtasks to generate (uses complexity analysis by default if available)`).option(`-r, --research`,`Enable research-backed generation (web research via Claude Code)`,!1).option(`-p, --prompt <text>`,`Additional context for subtask generation`).option(`-f, --force`,`Force expansion even if subtasks exist`,!1).option(`--file <file>`,`Path to the tasks file (relative to project root)`,i).option(`--complexity-report <file>`,`Path to the complexity report file (use this to specify the complexity report, not --file)`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t={tasksPath:e.file||!0,tag:e.tag};e.complexityReport&&(t.complexityReportPath=e.complexityReport);let n=X(t),r=n.getCurrentTag();if(await I(r),e.all){console.log(p.brand(`Expanding all pending tasks...`));try{await E(n.getTasksPath(),e.num,e.research,e.prompt,e.force,{projectRoot:n.getProjectRoot(),tag:r,complexityReportPath:n.getComplexityReportPath()})}catch(e){b(e,{hint:Z(e)})}}else if(e.id){e.id||(console.error(z.red(`Error: Task ID is required unless using --all.`)),process.exit(1));try{await D(n.getTasksPath(),e.id,e.num,e.research,e.prompt,{projectRoot:n.getProjectRoot(),tag:r,complexityReportPath:n.getComplexityReportPath()},e.force)}catch(e){b(e,{hint:Z(e)})}}else x(`Missing task ID`,"Try `taskgraph expand --id=3`, or `--all` for every pending task"),process.exit(1)}),e.command(`analyze-complexity`).description(`Analyze tasks and generate expansion recommendations${z.reset(``)}`).option(`-o, --output <file>`,`Output file path for the report`).option(`-m, --model <model>`,`LLM model to use for analysis (defaults to configured model)`).option(`-t, --threshold <number>`,`Minimum complexity score to recommend expansion (1-10)`,`5`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-r, --research`,`Use configured research model for research-backed complexity analysis`).option(`-i, --id <ids>`,`Comma-separated list of specific task IDs to analyze (e.g., "1,3,5")`).option(`--from <id>`,`Starting task ID in a range to analyze`).option(`--to <id>`,`Ending task ID in a range to analyze`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t={tasksPath:e.file||!0,tag:e.tag};e.output&&(t.complexityReportPath=e.output);let n=X(t),r=n.getCurrentTag();await I(r);let i=n.getComplexityReportPath(),a={...e,output:i,tag:r,projectRoot:n.getProjectRoot(),file:n.getTasksPath()};await He(a)}),e.command(`research`).description(`Perform AI-powered research queries with project context`).argument(`[prompt]`,`Research prompt to investigate`).option(`--file <file>`,`Path to the tasks file`).option(`-i, --id <ids>`,`Comma-separated task/subtask IDs to include as context (e.g., "15,16.2")`).option(`-f, --files <paths>`,`Comma-separated file paths to include as context`).option(`-c, --context <text>`,`Additional custom context to include in the research prompt`).option(`-t, --tree`,`Include project file tree structure in the research context`).option(`-s, --save <file>`,`Save the answer to a markdown file`).option(`-d, --detail <level>`,`Output detail level: low, medium, high`,`medium`).option(`--save-to <id>`,`Add the answer to a task or subtask's details (e.g., "15" or "15.2")`).option(`--save-file`,`Save the answer to .taskgraph/docs/research/`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async(e,t)=>{let n=X({tasksPath:t.file||!0,tag:t.tag}),r=(e,t)=>{x(e,t),process.exit(1)},i=e=>/^\d+(\.\d+)?$/.test(e);(!e||typeof e!=`string`||e.trim().length===0)&&r(`Research needs a question`,`Example: taskgraph research "How should we store sessions?" --id=3`);let a=(t.detail||`medium`).toLowerCase();[`low`,`medium`,`high`].includes(a)||r(`--detail must be low, medium or high, not "${t.detail}"`);let o=t.id?t.id.split(`,`).map(e=>e.trim()).filter(Boolean):[],s=o.find(e=>!i(e));s&&r(`"${s}" isn't a task ID`,`Use --id=15 or --id=15,16.2`);let c=t.files?t.files.split(`,`).map(e=>e.trim()).filter(Boolean):[],l=t.saveTo?t.saveTo.trim():null;t.saveTo!==void 0&&!i(l||``)&&r(`"${t.saveTo}" isn't a task ID`,`Use --save-to=15 for a task or --save-to=15.2 for a subtask`);let u=t.save?t.save.trim():null;t.save!==void 0&&(!u||u.includes(`..`)||B.isAbsolute(u))&&r(`--save needs a relative file path without ".."`);let d=n.getCurrentTag(),f=n.getProjectRoot(),p=n.getTasksPath();await I(d);let h=[...o,...l?[l]:[]];if(h.length>0){let e=m(p,f,d)?.tasks||[],t=t=>{let[n,r]=t.split(`.`).map(e=>Number.parseInt(e,10)),i=e.find(e=>Number(e.id)===n);return!i||r===void 0?!!i:(i.subtasks||[]).some(e=>Number(e.id)===r)},n=h.find(e=>!t(e));n&&r(`${n.includes(`.`)?`Subtask`:`Task`} ${n} doesn't exist in tag '${d}'`,"Run `taskgraph list` to see task IDs")}let g=c.find(e=>!H.existsSync(B.isAbsolute(e)?e:B.join(f,e)));g&&r(`File not found: ${g}`);let _=e.trim(),v;try{let{performResearch:e}=await import(`./research-blv_5JOT.js`);v=await e(_,{taskIds:o,filePaths:c,customContext:t.context?t.context.trim():``,includeProjectTree:!!t.tree,detailLevel:a,projectRoot:f,saveToFile:!!t.saveFile,tag:d},{commandName:`research`,outputType:`cli`,tag:d},`text`,!0)}catch(e){r(`Research failed: ${e.message}`)}if(l&&!v.interactiveSaveOccurred){let e={kind:`task`,id:l};try{let{appendResearchToTask:t}=await import(`./research-blv_5JOT.js`);t(p,l,`## Research: ${_}\n\n${v.result}`,{projectRoot:f,tag:d}),console.log(S(e))}catch(t){console.log(y(e,t.message)),process.exitCode=1}}if(u){let e={kind:`file`,path:u};try{H.writeFileSync(u,`# Research: ${_}\n\n${v.result}\n`,`utf-8`),console.log(S(e))}catch(t){console.log(y(e,t.message)),process.exitCode=1}}}),e.command(`clear-subtasks`).description(`Clear subtasks from specified tasks`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-i, --id <ids>`,`Task IDs (comma-separated) to clear subtasks from`).option(`--all`,`Clear subtasks from all tasks`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{!e.id&&!e.all&&(x(`Choose which tasks to clear`,"Use `--id=<ids>`, such as `--id=3,5`, or `--all`"),process.exit(1));let t=X({tasksPath:e.file||!0,tag:e.tag}),n=t.getCurrentTag(),r=t.getTasksPath(),i=t.getProjectRoot();await I(n);let a=e.id;if(e.all&&(a=(m(r,i,n)?.tasks??[]).map(e=>e.id).join(`,`),!a))console.log(`No subtasks to clear`);else try{let e=j(r,a,{projectRoot:i,tag:n});console.log(ne(e))}catch(e){if(e?.name!==`ClearSubtasksError`)throw e;let t={SUBTASK_ID:`Use \`taskgraph remove-subtask --id=${e.taskId}\` for one subtask, or \`--id=${String(e.taskId).split(`.`)[0]}\` for all`,INVALID_TASK_ID:"Use task numbers, such as `--id=3,5`",TASK_NOT_FOUND:"Run `taskgraph list` to see task IDs",NO_TASKS:`Run \`taskgraph list\` to check the "${n}" tag`};x(`${e.message}; nothing was cleared`,t[e.code]),process.exit(1)}}),e.command(`add-task`).description(`Add a new task using AI, optionally providing manual details`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-p, --prompt <prompt>`,`Description of the task to add (required if not using manual fields)`).option(`-t, --title <title>`,`Task title (for manual task creation)`).option(`-d, --description <description>`,`Task description (for manual task creation)`).option(`--details <details>`,`Implementation details (for manual task creation)`).option(`--dependencies <dependencies>`,`Comma-separated list of task IDs this task depends on`).option(`--priority <priority>`,`Task priority (high, medium, low)`,`medium`).option(`-r, --research`,`Whether to use research capabilities for task creation`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=e.title&&e.description;!e.prompt&&!t&&(console.error(z.red(`Error: Either --prompt or both --title and --description must be provided`)),process.exit(1));let n=X({tasksPath:e.file||!0,tag:e.tag}),r=n.getProjectRoot(),i=n.getCurrentTag();await I(i);let a=null;t&&(a={title:e.title,description:e.description,details:e.details||``,testStrategy:e.testStrategy||``});let o=e.dependencies?e.dependencies.split(`,`).map(e=>e.trim()):[],s={projectRoot:r,tag:i,commandName:`add-task`,outputType:`cli`};try{let{newTaskId:t,telemetryData:r}=await be(n.getTasksPath(),e.prompt,o,e.priority,s,`text`,a,e.research)}catch(e){b(e,{hint:Z(e)})}}),e.command(`add-dependency`).description(`Add a dependency to a task`).option(`-i, --id <id>`,`Task ID to add dependency to`).option(`-d, --depends-on <id>`,`Task ID that will become a dependency`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=e.id,r=e.dependsOn,i=t.getCurrentTag();await I(i),(!n||!r)&&(console.error(z.red(`Error: Both --id and --depends-on are required`)),process.exit(1));let a=n.includes(`.`)?n:parseInt(n,10),o=r.includes(`.`)?r:parseInt(r,10);await Re(t.getTasksPath(),a,o,{projectRoot:t.getProjectRoot(),tag:i})}),e.command(`remove-dependency`).description(`Remove a dependency from a task`).option(`-i, --id <id>`,`Task ID to remove dependency from`).option(`-d, --depends-on <id>`,`Task ID to remove as a dependency`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=e.id,r=e.dependsOn,i=t.getCurrentTag();await I(i),(!n||!r)&&(console.error(z.red(`Error: Both --id and --depends-on are required`)),process.exit(1));let a=n.includes(`.`)?n:parseInt(n,10),o=r.includes(`.`)?r:parseInt(r,10);await Ie(t.getTasksPath(),a,o,{projectRoot:t.getProjectRoot(),tag:i})}),e.command(`validate-dependencies`).description(`Identify invalid dependencies without fixing them${z.reset(``)}`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=t.getCurrentTag();await I(n);let r=await ke(t.getTasksPath(),{context:{projectRoot:t.getProjectRoot(),tag:n}});console.log(re(r)),r.valid||(process.exitCode=1)}),e.command(`fix-dependencies`).description(`Fix invalid dependencies automatically${z.reset(``)}`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=t.getCurrentTag();await I(n);let r=await Ne(t.getTasksPath(),{context:{projectRoot:t.getProjectRoot(),tag:n}});console.log(ee(r)),r.remaining.length>0&&(process.exitCode=1)}),e.command(`complexity-report`).description(`Display the complexity analysis report${z.reset(``)}`).option(`-f, --file <file>`,`Path to the report file`,f).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t={tag:e.tag};e.file&&e.file!==`.taskgraph/reports/task-complexity-report.json`&&(t.complexityReportPath=e.file);let n=X(t);await I(n.getCurrentTag()),await Le(n.getComplexityReportPath())}),e.command(`add-subtask`).description(`Add a subtask to an existing task`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-p, --parent <id>`,`Parent task ID (required)`).option(`-i, --task-id <id>`,`Existing task ID to convert to subtask`).option(`-t, --title <title>`,`Title for the new subtask (when creating a new subtask)`).option(`-d, --description <text>`,`Description for the new subtask`).option(`--details <text>`,`Implementation details for the new subtask`).option(`--dependencies <ids>`,`Comma-separated list of dependency IDs for the new subtask`).option(`-s, --status <status>`,`Status for the new subtask`,`pending`).option(`--generate`,`Regenerate task files after adding subtask`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let n=X({tasksPath:e.file||!0,tag:e.tag}),r=e.parent,i=e.taskId,a=e.generate||!1,o=n.getCurrentTag();await I(o),r||(console.error(z.red(`Error: --parent parameter is required. Please provide a parent task ID.`)),t(),process.exit(1));let s=[];e.dependencies&&(s=e.dependencies.split(`,`).map(e=>e.includes(`.`)?e.trim():parseInt(e.trim(),10)));try{if(i)console.log(p.brand(`Converting task ${i} to a subtask of ${r}...`)),await N(n.getTasksPath(),r,i,null,a,{projectRoot:n.getProjectRoot(),tag:o}),console.log(z.green(`✓ Task ${i} successfully converted to a subtask of task ${r}`));else if(e.title){let t={title:e.title,description:e.description||``,details:e.details||``,status:e.status||`pending`,dependencies:s},i=await N(n.getTasksPath(),r,null,t,a,{projectRoot:n.getProjectRoot(),tag:o});console.log(W(p.text.bold(`Subtask ${r}.${i.id} Added Successfully`)+`
6
-
7
- `+p.text(`Title: ${i.title}`)+`
8
- `+p.text(`Status: ${F(i.status)}`)+`
9
- `+(s.length>0?p.text(`Dependencies: ${s.join(`, `)}`)+`
10
- `:``)+`
11
- `+p.text.bold(`Next Steps:`)+`
12
- `+z.cyan(`1. Run ${z.yellow(`taskgraph show ${r}`)} to see the parent task with all subtasks`)+`
13
- `+z.cyan(`2. Run ${z.yellow(`taskgraph set-status --id=${r}.${i.id} --status=in-progress`)} to start working on it`),{padding:1,borderColor:`green`,borderStyle:`round`,margin:{top:1}}))}else console.error(z.red(`Error: Either --task-id or --title must be provided.`)),console.log(W(p.text.bold(`Usage Examples:`)+`
14
-
15
- `+p.text(`Convert existing task to subtask:`)+`
16
- `+z.yellow(` taskgraph add-subtask --parent=5 --task-id=8`)+`
17
-
18
- `+p.text(`Create new subtask:`)+`
19
- `+z.yellow(` taskgraph add-subtask --parent=5 --title="Implement login UI" --description="Create the login form"`)+`
20
-
21
- `,{padding:1,borderColor:d,borderStyle:`round`})),process.exit(1)}catch(e){b(e)}}).on(`error`,function(e){console.error(z.red(`Error: ${e.message}`)),t(),process.exit(1)});function t(){console.log(W(`${p.text.bold(`Add Subtask Command Help`)}\n\n${z.cyan(`Usage:`)}\n taskgraph add-subtask --parent=<id> [options]\n\n${z.cyan(`Options:`)}\n -p, --parent <id> Parent task ID (required)\n -i, --task-id <id> Existing task ID to convert to subtask\n -t, --title <title> Title for the new subtask\n -d, --description <text> Description for the new subtask\n --details <text> Implementation details for the new subtask\n --dependencies <ids> Comma-separated list of dependency IDs\n -s, --status <status> Status for the new subtask (default: "pending")\n -f, --file <file> Path to the tasks file (default: "${i}")\n --generate Regenerate task files after adding subtask\n\n${z.cyan(`Examples:`)}\n taskgraph add-subtask --parent=5 --task-id=8\n taskgraph add-subtask -p 5 -t "Implement login UI" -d "Create the login form" --generate`,{padding:1,borderColor:d,borderStyle:`round`}))}e.command(`remove-subtask`).description(`Remove a subtask from its parent task`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-i, --id <id>`,`Subtask ID(s) to remove in format "parentId.subtaskId" (can be comma-separated for multiple subtasks)`).option(`-c, --convert`,`Convert the subtask to a standalone task instead of deleting it`).option(`--generate`,`Regenerate task files after removing subtask`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=e.id,i=e.convert||!1,a=e.generate||!1,o=t.getCurrentTag();n||(console.error(z.red(`Error: --id parameter is required. Please provide subtask ID(s) in format "parentId.subtaskId".`)),r(),process.exit(1));try{let e=n.split(`,`).map(e=>e.trim());for(let n of e){n.includes(`.`)||(console.error(z.red(`Error: Subtask ID "${n}" must be in format "parentId.subtaskId"`)),r(),process.exit(1)),i&&console.log(p.brand(`The subtask will be converted to a standalone task`));let e=await ye(t.getTasksPath(),n,i,a,{projectRoot:t.getProjectRoot(),tag:o});console.log(W(i&&e?p.text.bold(`Subtask ${n} Converted to Task #${e.id}`)+`
22
-
23
- `+p.text(`Title: ${e.title}`)+`
24
- `+p.text(`Status: ${F(e.status)}`)+`
25
- `+p.text(`Dependencies: ${e.dependencies.join(`, `)}`)+`
26
-
27
- `+p.text.bold(`Next Steps:`)+`
28
- `+z.cyan(`1. Run ${z.yellow(`taskgraph show ${e.id}`)} to see details of the new task`)+`
29
- `+z.cyan(`2. Run ${z.yellow(`taskgraph set-status --id=${e.id} --status=in-progress`)} to start working on it`):p.text.bold(`Subtask ${n} Removed`)+`
30
-
31
- `+p.text(`The subtask has been successfully deleted.`),{padding:1,borderColor:`green`,borderStyle:`round`,margin:{top:1}}))}}catch(e){b(e)}}).on(`error`,function(e){console.error(z.red(`Error: ${e.message}`)),r(),process.exit(1)});function r(){console.log(W(p.text.bold(`Remove Subtask Command Help`)+`
32
-
33
- `+z.cyan(`Usage:`)+`
34
- taskgraph remove-subtask --id=<parentId.subtaskId> [options]
35
-
36
- `+z.cyan(`Options:`)+`
37
- -i, --id <id> Subtask ID(s) to remove in format "parentId.subtaskId" (can be comma-separated, required)
38
- -c, --convert Convert the subtask to a standalone task instead of deleting it
39
- -f, --file <file> Path to the tasks file (default: "`+i+`")
40
- --skip-generate Skip regenerating task files
41
-
42
- `+z.cyan(`Examples:`)+`
43
- taskgraph remove-subtask --id=5.2
44
- taskgraph remove-subtask --id=5.2,6.3,7.1
45
- taskgraph remove-subtask --id=5.2 --convert`,{padding:1,borderColor:d,borderStyle:`round`}))}e.command(`remove-task`).description(`Remove one or more tasks or subtasks permanently`).option(`-i, --id <ids>`,`ID(s) of the task(s) or subtask(s) to remove (e.g., "5", "5.2", or "5,6.1,7")`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-y, --yes`,`Skip confirmation prompt`,!1).option(`--tag <tag>`,`Specify tag context for task operations`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=e.id,r=t.getCurrentTag();await I(r),n||(console.error(z.red(`Error: Task ID(s) are required`)),console.error(z.yellow(`Usage: taskgraph remove-task --id=<taskId1,taskId2...>`)),process.exit(1));let i=n.split(`,`).map(e=>e.trim()).filter(Boolean);i.length===0&&(console.error(z.red(`Error: No valid task IDs provided.`)),process.exit(1));try{let n=t.getTasksPath(),a=m(n,t.getProjectRoot(),r);(!a||!a.tasks)&&(console.error(z.red(`Error: No valid tasks found in ${n}`)),process.exit(1));let s=[],c=[],l=0,u=[];for(let e of i)if(!je(a.tasks,e))c.push(e);else{let t=o(a.tasks,e).task;if(t){if(s.push({id:e,task:t}),!t.isSubtask){t.subtasks&&t.subtasks.length>0&&(l+=t.subtasks.length);let n=a.tasks.filter(t=>t.dependencies&&t.dependencies.includes(parseInt(e,10)));n.length>0&&u.push(` - Task ${e}: ${n.length} dependent tasks (${n.map(e=>e.id).join(`, `)})`)}}else c.push(`${e} (error finding details)`)}let d=`${c.length===1?`Task`:`Tasks`} ${c.join(`, `)} not found`;if(s.length===0&&(x(d,"Run `taskgraph list` to see task IDs"),process.exit(1)),c.length>0&&console.warn(z.yellow(`${d}, skipping`)),!e.yes){console.log(),console.log(z.red.bold(`⚠️ WARNING: This will permanently delete the following ${s.length} item(s):`)),console.log(),s.forEach(({id:e,task:t})=>{t&&(t.isSubtask?(console.log(p.text(` Subtask ${e}: ${t.title||`(no title)`}`)),t.parentTask&&console.log(p.muted(` (Parent: ${t.parentTask.id} - ${t.parentTask.title||`(no title)`})`))):console.log(p.text.bold(` Task ${e}: ${t.title||`(no title)`}`)))}),l>0&&console.log(z.yellow(`⚠️ This will also delete ${l} subtasks associated with the selected main tasks!`)),u.length>0&&(console.log(z.yellow(`⚠️ Warning: Dependencies on the following tasks will be removed:`)),u.forEach(e=>console.log(z.yellow(e)))),console.log();let{confirm:e}=await K.prompt([{type:`confirm`,name:`confirm`,message:z.red.bold(`Are you sure you want to permanently delete these ${s.length} item(s)?`),default:!1}]);e||(console.log(p.brand(`Task deletion cancelled.`)),process.exit(0))}let f=Oe(`Removing ${s.length} task(s)/subtask(s)...`),h=s.map(({id:e})=>e).join(`,`),g=await A(t.getTasksPath(),h,{projectRoot:t.getProjectRoot(),tag:r});Ce(f),g.success?console.log(W(z.green(`Successfully removed ${g.removedTasks.length} task(s)/subtask(s).`)+(g.message?`\n\nDetails:\n${g.message}`:``)+(g.error?`\n\nWarnings:\n${z.yellow(g.error)}`:``),{padding:1,borderColor:`green`,borderStyle:`round`})):(console.error(W(z.red(`Operation completed with errors. Removed ${g.removedTasks.length} task(s)/subtask(s).`)+(g.message?`\n\nDetails:\n${g.message}`:``)+(g.error?`\n\nErrors:\n${z.red(g.error)}`:``),{padding:1,borderColor:`red`,borderStyle:`round`})),process.exit(1)),c.length>0&&(console.warn(z.yellow(`Note: The following IDs were not found initially and were skipped: ${c.join(`, `)}`)),g.removedTasks.length===0&&process.exit(1))}catch(e){b(e)}}),e.command(`init`).description(`Initialize a new project with TaskGraph structure`).option(`-y, --yes`,`Skip prompts and use default values`).option(`-n, --name <name>`,`Project name`).option(`-d, --description <description>`,`Project description`).option(`-v, --version <version>`,`Project version`,`0.1.0`).option(`-a, --author <author>`,`Author name`).option(`-r, --rules <rules...>`,`Rule profiles to install (claude). Accepts comma or space separated values.`).option(`--skip-install`,`Skip installing dependencies`).option(`--dry-run`,`Show what would be done without making changes`).option(`--aliases`,`Add shell aliases (tm, taskgraph)`).option(`--no-aliases`,`Skip shell aliases (tm, taskgraph)`).option(`--git`,`Initialize Git repository`).option(`--no-git`,`Skip Git repository initialization`).option(`--git-tasks`,`Store tasks in Git`).option(`--no-git-tasks`,`No Git storage of tasks`).action(async e=>{let t=R,n=!1;if(e.rules&&Array.isArray(e.rules)){let r=e.rules.flatMap(e=>e.split(`,`)).map(e=>e.trim()).filter(Boolean),i=We(r);i.length>0&&(x(`"${i.join(`, `)}" isn't a rule profile`,`TaskGraph supports Claude Code only; use \`--rules ${R.join(`,`)}\``),process.exit(1)),r.length>0&&(t=r,n=!0)}e.rules=t,e.rulesExplicitlyProvided=n;try{await Ge(e)}catch(e){b(e)}}),e.command(`models`).description(`Manage AI model configurations (Claude Code models)`).option(`--set-main <model_id>`,`Set the primary model for task generation/updates`).option(`--set-research <model_id>`,`Set the model for research-backed operations`).option(`--set-fallback <model_id>`,`Set the model to use if the primary fails`).option(`--setup`,`Run interactive setup to configure models`).addOption(new U(`--claude-code`).hideHelp()).addOption(new U(`--openrouter`).hideHelp()).addOption(new U(`--ollama`).hideHelp()).addOption(new U(`--bedrock`).hideHelp()).addOption(new U(`--azure`).hideHelp()).addOption(new U(`--vertex`).hideHelp()).addOption(new U(`--gemini-cli`).hideHelp()).addOption(new U(`--codex-cli`).hideHelp()).addOption(new U(`--lmstudio`).hideHelp()).addOption(new U(`--openai-compatible`).hideHelp()).addOption(new U(`--baseURL <url>`).hideHelp()).addHelpText(`after`,`
46
- TaskGraph uses Claude Code. Available models: opus, sonnet, haiku.
47
-
48
- Examples:
49
- $ taskgraph models # View current configuration
50
- $ taskgraph models --set-main sonnet # Set main model
51
- $ taskgraph models --set-research opus # Set research model
52
- $ taskgraph models --set-fallback haiku # Set fallback
53
- $ taskgraph models --setup # Run interactive setup`).action(async e=>{let t=X({tasksPath:e.file||!1}).getProjectRoot(),n=[`openrouter`,`ollama`,`bedrock`,`azure`,`vertex`,`geminiCli`,`codexCli`,`lmstudio`,`openaiCompatible`,`baseURL`].filter(t=>e[t]);if(n.length>0){let e=`--${n[0]===`baseURL`?`baseURL`:n[0].replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`;x(`${e} isn't supported any more; TaskGraph runs on Claude Code`,"Choose a model with `taskgraph models --set-main <opus|sonnet|haiku>`"),process.exit(1)}if(l(t)||(x(`No .taskgraph/config.json in this project`,"Run `taskgraph init` to recreate it"),process.exit(1)),e.setup){try{!await ge(t)&&!process.exitCode&&(process.exitCode=1)}catch(e){b(e)}return}let r=await me({projectRoot:t});r.success||(x(`Couldn't read the model settings: ${r.error.message}`,"Run `taskgraph init` to recreate .taskgraph/config.json"),process.exit(1));let i=r.data.activeModels,a=await pe({projectRoot:t}),o=a.success?a.data.models.map(e=>e.modelId):[],s=[[`main`,e.setMain],[`research`,e.setResearch],[`fallback`,e.setFallback]].filter(([,e])=>e);if(s.length>0){let e=s.find(([,e])=>!o.includes(e));e&&(x(`"${e[1]}" isn't a Claude Code model`,`Choose ${ie(o)}`),process.exit(1));let n=[];for(let[e,r]of s){let a=await ue(e,r,{projectRoot:t});a.success||(n.length>0&&console.log(w(n)),x(`Couldn't set the ${e} model: ${a.error.message}`),process.exit(1)),n.push({role:e,from:i[e]?.modelId??null,to:r})}console.log(w(n))}else console.log(te({main:i.main?.modelId??null,research:i.research?.modelId??null,fallback:i.fallback?.modelId??null},o))}),e.command(`lang`).description(`Show or set the language AI responses are written in`).option(`--response <response_language>`,`Set the response language`).option(`--setup`,`Choose the response language interactively`).addHelpText(`after`,`
54
- Examples:
55
- $ taskgraph lang # Show the response language
56
- $ taskgraph lang --response French # Set it
57
- $ taskgraph lang --setup # Choose it interactively`).action(async e=>{let t=X({}).getProjectRoot();l(t)||(x(`No .taskgraph/config.json in this project`,"Run `taskgraph init` to recreate it"),process.exit(1));let n=u(t)||`English`,r=e.response;if(e.setup)try{r=(await K.prompt([{type:`input`,name:`language`,message:`Language for AI responses?`,default:n}])).language}catch(e){if(e?.name!==`ExitPromptError`)throw e;console.log(p.muted(`
58
- Cancelled; response language unchanged`)),process.exitCode=130;return}if(r===void 0){console.log(`Response language: ${p.brand(n)}`),console.log(p.muted(`Change it with `)+p.brand(`taskgraph lang --response <language>`));return}r=r.trim();let i=Ue(r,{projectRoot:t});i.success||(x(`Couldn't set the response language: ${i.error.message}`),process.exit(1));let a=r===n?`${p.brand(r)} ${p.muted(`(unchanged)`)}`:`${n} → ${p.brand(r)}`;console.log(`${z.green(`✓`)} Response language ${a}`)}),e.command(`move`).description(`Move tasks between tags or reorder within tags. Supports cross-tag moves with dependency resolution options.`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--from <id>`,`ID of the task/subtask to move (e.g., "5" or "5.2"). Can be comma-separated to move multiple tasks (e.g., "5,6,7")`).option(`--to <id>`,`ID of the destination (e.g., "7" or "7.3"). Must match the number of source IDs if comma-separated`).option(`--tag <tag>`,`Specify tag context for task operations`).option(`--from-tag <tag>`,`Source tag for cross-tag moves`).option(`--to-tag <tag>`,`Target tag for cross-tag moves`).option(`--with-dependencies`,`Move dependent tasks along with main task`).option(`--ignore-dependencies`,`Break cross-tag dependencies during move`).action(async e=>{function t(){console.log(p.text.bold(`Move Command Help`)+`
59
-
60
- `+z.cyan(`Move tasks between tags or reorder within tags.`)+`
61
-
62
- `+z.yellow.bold(`Within-Tag Moves:`)+`
63
- `+p.text(` taskgraph move --from=5 --to=7`)+`
64
- `+p.text(` taskgraph move --from=5.2 --to=7.3`)+`
65
- `+p.text(` taskgraph move --from=5,6,7 --to=10,11,12`)+`
66
-
67
- `+z.yellow.bold(`Cross-Tag Moves:`)+`
68
- `+p.text(` taskgraph move --from=5 --from-tag=backlog --to-tag=in-progress`)+`
69
- `+p.text(` taskgraph move --from=5,6 --from-tag=backlog --to-tag=done`)+`
70
-
71
- `+z.yellow.bold(`Dependency Resolution:`)+`
72
- `+p.text(` # Move with dependencies`)+`
73
- `+p.text(` taskgraph move --from=5 --from-tag=backlog --to-tag=in-progress --with-dependencies`)+`
74
-
75
- `+p.text(` # Break dependencies`)+`
76
- `+p.text(` taskgraph move --from=5 --from-tag=backlog --to-tag=in-progress --ignore-dependencies`)+`
77
-
78
-
79
- `+z.yellow.bold(`Best Practices:`)+`
80
- `+p.text(` • Use --with-dependencies to move dependent tasks together`)+`
81
- `+p.text(` • Use --ignore-dependencies to break cross-tag dependencies`)+`
82
- `+p.text(` • Check dependencies first: taskgraph validate-dependencies`)+`
83
- `+p.text(` • Fix dependency issues: taskgraph fix-dependencies`)+`
84
-
85
- `+z.yellow.bold(`Error Resolution:`)+`
86
- `+p.text(` • Cross-tag dependency conflicts: Use --with-dependencies or --ignore-dependencies`)+`
87
- `+p.text(` • Subtask movement: Promote subtask first with remove-subtask --convert`)+`
88
- `+p.text(` • Invalid tags: Check available tags with taskgraph tags`)+`
89
-
90
- `+p.muted(`For more help, run: taskgraph move --help`))}async function n(e,n){let{sourceId:r,sourceTag:i,toTag:a,taskGraph:o}=e;r||(console.error(z.red(`Error: --from parameter is required for cross-tag moves`)),t(),process.exit(1));let s=r.split(`,`).map(e=>e.trim()),c={withDependencies:n.withDependencies||!1,ignoreDependencies:n.ignoreDependencies||!1};console.log(p.brand(`Moving tasks ${s.join(`, `)} from "${i}" to "${a}"...`));let l=await k(o.getTasksPath(),s,i,a,c,{projectRoot:o.getProjectRoot()});console.log(z.green(`✓ ${l.message}`)),Array.isArray(l.tips)&&l.tips.length>0&&(console.log(`
91
- `+z.yellow.bold(`Next Steps:`)),l.tips.forEach(e=>console.log(p.text(` • ${e}`))))}async function r(e){let{sourceId:t,destinationId:n,tag:r,taskGraph:i}=e;(!t||!n)&&(console.error(z.red(`Error: Both --from and --to parameters are required for within-tag moves`)),console.log(z.yellow(`Usage: taskgraph move --from=<sourceId> --to=<destinationId>`)),process.exit(1));let a=t.split(`,`).map(e=>e.trim()),o=n.split(`,`).map(e=>e.trim());if(a.length!==o.length&&(console.error(z.red(`Error: The number of source and destination IDs must match`)),console.log(z.yellow(`Example: taskgraph move --from=5,6,7 --to=10,11,12`)),process.exit(1)),a.length>1){console.log(p.brand(`Moving multiple tasks: ${a.join(`, `)} to ${o.join(`, `)}...`));let e=m(i.getTasksPath(),i.getProjectRoot(),r);(!e||!e.tasks)&&(console.error(z.red(`Error: Invalid or missing tasks file at ${i.getTasksPath()}`)),process.exit(1));let t=[],n=[];for(let e=0;e<a.length;e++){let s=a[e],c=o[e];if(s===c)console.log(z.yellow(`Skipping ${s} -> ${c} (same ID)`));else try{await O(i.getTasksPath(),s,c,e===a.length-1,{projectRoot:i.getProjectRoot(),tag:r}),console.log(z.green(`✓ Successfully moved task/subtask ${s} to ${c}`)),n.push({fromId:s,toId:c})}catch(e){let n={fromId:s,toId:c,error:e.message};t.push(n),console.error(z.red(`Error moving ${s} to ${c}: ${e.message}`))}}t.length>0?(console.log(z.yellow(`
92
- --- Move Operation Summary ---`)),console.log(z.green(`✓ Successfully moved: ${n.length} tasks`)),console.log(z.red(`✗ Failed to move: ${t.length} tasks`)),n.length>0&&(console.log(z.cyan(`
93
- Successful moves:`)),n.forEach(({fromId:e,toId:t})=>{console.log(z.cyan(` ${e} → ${t}`))})),console.log(z.red(`
94
- Failed moves:`)),t.forEach(({fromId:e,toId:t,error:n})=>{console.log(z.red(` ${e} → ${t}: ${n}`))}),console.log(z.yellow(`
95
- Note: Some tasks were moved successfully. Check the errors above for failed moves.`))):console.log(z.green(`
96
- ✓ All tasks moved successfully!`))}else await O(i.getTasksPath(),t,n,!0,{projectRoot:i.getProjectRoot(),tag:r}),console.log(z.green(`✓ Successfully moved task/subtask ${t} to ${n}`))}function i(e,t){if([`CROSS_TAG_DEPENDENCY_CONFLICTS`,`CANNOT_MOVE_SUBTASK`,`SOURCE_TARGET_TAGS_SAME`,`SAME_SOURCE_TARGET_TAG`].includes(e.code)||b(e,{hint:/already exists/i.test(e.message)?"Run `taskgraph list` to see which IDs are taken":void 0}),console.error(z.red(`Error: ${e.message}`)),e.code===`CROSS_TAG_DEPENDENCY_CONFLICTS`){let n=e.data.conflicts||[],r=e.data.taskIds||[];Ee(n,t.sourceTag,t.toTag,r.join(`, `))}else if(e.code===`CANNOT_MOVE_SUBTASK`){let n=e.data.taskId||t.sourceId?.split(`,`)[0];Fe(n,t.sourceTag,t.toTag)}else e.code===`SOURCE_TARGET_TAGS_SAME`||e.code===`SAME_SOURCE_TARGET_TAG`?De(t.sourceTag,t.toTag,`Source and target tags are identical`):ze(`after-error`);process.exit(1)}let a=X({tasksPath:e.file||!0,tag:e.tag}),o=e.from,s=e.to,c=e.fromTag,l=e.toTag,u=a.getCurrentTag(),d=c||a.getCurrentTag(),f=d&&l&&d!==l,h={sourceId:o,destinationId:s,sourceTag:d,toTag:l,tag:u,taskGraph:a};try{f?await n(h,e):await r(h)}catch(e){let t=String(e&&(e.message||e));t.includes(`already exists in target tag`)&&(console.error(z.red(`Error: ${t}`)),console.log(`
97
- `+z.yellow.bold(`Conflict: ID already exists in target tag`)+`
98
- `+p.text(` • Choose a different target tag without conflicting IDs`)+`
99
- `+p.text(` • Move a different set of IDs (avoid existing ones)`)+`
100
- `+p.text(` • If needed, move within-tag to a new ID first, then cross-tag move`)),process.exit(1)),i(e,h)}}),e.command(`sync-readme`).description(`Sync the current task list to README.md in the project root`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--with-subtasks`,`Include subtasks in the README output`).option(`-s, --status <status>`,`Show only tasks matching this status (e.g., pending, done)`).option(`-t, --tag <tag>`,`Tag to use for the task list (default: master)`).action(async e=>{let t=X({tasksPath:e.file||!0,tag:e.tag}),n=e.withSubtasks||!1,r=e.status||null,i=t.getCurrentTag();console.log(p.brand(`📝 Syncing tasks to README.md${n?` (with subtasks)`:``}${r?` (status: ${r})`:``}...`)),await syncTasksToReadme(t.getProjectRoot(),{withSubtasks:n,status:r,tasksPath:t.getTasksPath(),tag:i})||(console.error(z.red(`❌ Failed to sync tasks to README.md`)),process.exit(1))});function a(e,t){console.error(`${z.yellow(`⚠`)} ${e} is deprecated; use ${p.brand(`taskgraph ${t}`)}`)}return e.command(`add-tag`).description(`[DEPRECATED] Create a new tag context for organizing tasks (use "taskgraph tags add" instead)`).argument(`[tagName]`,`Name of the new tag to create (optional when using --from-branch)`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`--copy-from-current`,`Copy tasks from the current tag to the new tag`).option(`--copy-from <tag>`,`Copy tasks from the specified tag to the new tag`).option(`--from-branch`,`Create tag name from current git branch (ignores tagName argument)`).option(`-d, --description <text>`,`Optional description for the tag`).action(async(e,t)=>{a(`add-tag`,`tags add`);try{let n=X({tasksPath:t.file||!0}),r=n.getTasksPath();H.existsSync(r)||(x(`No tasks yet`,$),process.exit(1)),!e&&!t.fromBranch&&(x(`add-tag needs a tag name`,"Example: `taskgraph tags add feature-auth`, or `--from-branch`"),process.exit(1));let i={projectRoot:n.getProjectRoot(),commandName:`add-tag`,outputType:`cli`};if(t.fromBranch){let{createTagFromBranch:e}=await import(`./tag-management-Br2FX-YC.js`),r=await import(`./git-utils-BezpEZd4.js`);await r.isGitRepository(i.projectRoot)||(x(`--from-branch needs a git repository, and this isn't one`,"Name the tag instead: `taskgraph tags add <name>`"),process.exit(1));let a=await r.getCurrentBranch(i.projectRoot);a||(x(`Couldn't tell which git branch is checked out`,"Name the tag instead: `taskgraph tags add <name>`"),process.exit(1));let o={copyFromCurrent:t.copyFromCurrent||!1,copyFromTag:t.copyFrom,description:t.description};await e(n.getTasksPath(),a,o,i,`text`)}else{let r={copyFromCurrent:t.copyFromCurrent||!1,copyFromTag:t.copyFrom,description:t.description};await he(n.getTasksPath(),e,r,i,`text`)}if(t.autoSwitch){let{useTag:r}=await import(`./tag-management-Br2FX-YC.js`),a=t.fromBranch?(await import(`./git-utils-BezpEZd4.js`)).sanitizeBranchNameForTag(await(await import(`./git-utils-BezpEZd4.js`)).getCurrentBranch(projectRoot)):e;await r(n.getTasksPath(),a,{},i,`text`)}}catch(e){b(e)}}).on(`error`,function(e){b(e)}),e.command(`delete-tag`).description(`[DEPRECATED] Delete an existing tag and all its tasks (use "taskgraph tags remove" instead)`).argument(`<tagName>`,`Name of the tag to delete`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-y, --yes`,`Skip confirmation prompts`).action(async(e,t)=>{a(`delete-tag`,`tags remove`);try{let n=X({tasksPath:t.file||!0}),r=n.getTasksPath();H.existsSync(r)||(x(`No tasks yet`,$),process.exit(1));let i={yes:t.yes||!1},a={projectRoot:n.getProjectRoot(),commandName:`delete-tag`,outputType:`cli`};await de(n.getTasksPath(),e,i,a,`text`)}catch(e){b(e)}}).on(`error`,function(e){b(e)}),e.command(`use-tag`).description(`[DEPRECATED] Switch to a different tag context (use "taskgraph tags use" instead)`).argument(`<tagName>`,`Name of the tag to switch to`).option(`-f, --file <file>`,`Path to the tasks file`,i).action(async(e,t)=>{a(`use-tag`,`tags use`);try{let n=X({tasksPath:t.file||!0}),r=n.getTasksPath();H.existsSync(r)||(x(`No tasks yet`,$),process.exit(1));let i={projectRoot:n.getProjectRoot(),commandName:`use-tag`,outputType:`cli`};await fe(n.getTasksPath(),e,{},i,`text`)}catch(e){b(e)}}).on(`error`,function(e){b(e)}),e.command(`rename-tag`).description(`[DEPRECATED] Rename an existing tag (use "taskgraph tags rename" instead)`).argument(`<oldName>`,`Current name of the tag`).argument(`<newName>`,`New name for the tag`).option(`-f, --file <file>`,`Path to the tasks file`,i).action(async(e,t,n)=>{a(`rename-tag`,`tags rename`);try{let r=X({tasksPath:n.file||!0}),i=r.getTasksPath();H.existsSync(i)||(x(`No tasks yet`,$),process.exit(1));let a={projectRoot:r.getProjectRoot(),commandName:`rename-tag`,outputType:`cli`};await _e(r.getTasksPath(),e,t,{},a,`text`)}catch(e){b(e)}}).on(`error`,function(e){b(e)}),e.command(`copy-tag`).description(`[DEPRECATED] Copy an existing tag to create a new tag with the same tasks (use "taskgraph tags copy" instead)`).argument(`<sourceName>`,`Name of the source tag to copy from`).argument(`<targetName>`,`Name of the new tag to create`).option(`-f, --file <file>`,`Path to the tasks file`,i).option(`-d, --description <text>`,`Optional description for the new tag`).action(async(e,t,n)=>{a(`copy-tag`,`tags copy`);try{let r=X({tasksPath:n.file||!0}),i=r.getTasksPath();H.existsSync(i)||(x(`No tasks yet`,$),process.exit(1));let a={description:n.description},o={projectRoot:r.getProjectRoot(),commandName:`copy-tag`,outputType:`cli`};await C(i,e,t,a,o,`text`)}catch(e){b(e)}}).on(`error`,function(e){b(e)}),e.command(`tui`).alias(`repl`).description(`Launch the interactive TUI/REPL mode`).action(async()=>{await Q()}),e}async function at(){return null}async function Q(){let e=await at();if(!e){console.log(z.yellow(`TUI mode coming soon!`)),console.log(z.dim(`Showing help instead...
101
- `)),P();return}let t=await import(`react`),{render:n,Shell:r}=e,i=`master`,a=process.cwd();try{let e=X({});i=e.getCurrentTag(),a=e.getProjectRoot()||process.cwd()}catch{}let o=process.stdin.isTTY&&typeof process.stdin.setRawMode==`function`;console.clear();let s={showBanner:!0,showSplash:o,initialTag:i,isInteractive:o,projectRoot:a,onExit:()=>{console.log(z.dim(`
102
- Goodbye! 👋`)),process.exit(0)}},c=n(t.createElement(r,s));o||setTimeout(()=>{c.unmount(),console.log(z.dim(`
103
- 💡 Run in an interactive terminal for full REPL mode.`)),process.exit(0)},200)}const $="Create some with `taskgraph parse-prd <file>`",ot=/* @__PURE__ */ new Set([`init`,`help`,`completion`,`tui`,`repl`]);function st(n,r){let i=r;for(;i.parent?.parent;)i=i.parent;if([i.name(),...i.aliases()].some(e=>ot.has(e))||r.getOptionValueSource(`file`)===`cli`)return;let a=r.options.some(e=>e.attributeName()===`project`)?r.opts().project:null,o=typeof a==`string`?B.resolve(a):null;t(o||e())||(o?x(`No TaskGraph project at ${o}`,"Run `taskgraph init` in that folder to set one up"):x(`No TaskGraph project in this folder`,"Run `taskgraph init` to set one up, or cd into your project"),process.exit(1))}function ct(){let e=new Je().name(`taskgraph`).description(`AI-driven development task management`).version(`0.52.23`).helpOption(`-h, --help`,`Display help`).addHelpCommand(!1),t=e.helpInformation.bind(e);e.helpInformation=function(){return this.parent&&this.parent!==e?t():(P(),``)},it(e);let n=(e,t)=>{e.configureOutput({outputError:(e,n)=>n(`\n${ae(e,t||void 0)}\n`)});for(let r of e.commands)n(r,t?`${t} ${r.name()}`:r.name())};return n(e,``),e.hook(`preAction`,st),e}async function lt(e=process.argv){try{if(e.length<=2){await Q();return}let t=e.includes(`init`);[`init`,`models`,`lang`].includes(e[2])&&s(!0);let n=e.includes(`tui`)||e.includes(`repl`),r=e.includes(`--no-banner`);process.stdout.isTTY&&!t&&!n&&!r&&Pe();let i=e[2]===`completion`,a=process.env.TASKGRAPH_SKIP_AUTO_UPDATE===`1`||process.env.CI||process.env.NODE_ENV===`test`||i,o=Se(),c=a?{currentVersion:o,latestVersion:o,needsUpdate:!1}:await nt(o);if(c.needsUpdate&&(ve(c.currentVersion,c.latestVersion,c.highlights),await oe(c.latestVersion))){le(e);return}let l=ct(),u=e.filter(e=>e!==`--no-banner`);await l.parseAsync(u);try{if(i)return;let e=X({}).getStatePath();if(e&&H.existsSync(e)){let t=JSON.parse(H.readFileSync(e,`utf8`));t?.migrationNoticePending===!0&&(Me({_migrationHappened:!0}),t.migrationNoticePending=!1,t.migrationNoticeShown=!0,H.writeFileSync(e,JSON.stringify(t,null,2)))}}catch{}}catch(e){e instanceof g?console.error(W(z.red.bold(`Configuration Update Required!`)+`
104
-
105
- `+p.text(`TaskGraph now uses a `)+z.yellow.bold(`configuration file`)+p.text(` in your project for AI model choices and settings.
106
-
107
- This file appears to be `)+z.red.bold(`missing`)+p.text(`. No worries though.
108
-
109
- `)+z.cyan.bold(`To create this file, run the interactive setup:`)+`
110
- `+z.green(` taskgraph models --setup`)+`
111
-
112
- `+p.text.bold(`Key Points:`)+`
113
- `+p.text(`* `)+z.yellow.bold(`Configuration file`)+p.text(`: Stores your AI model settings (do not manually edit)
114
- `)+p.text(`* `)+z.yellow.bold(`.env & .mcp.json`)+p.text(`: Still used `)+z.red.bold(`only`)+p.text(` for your AI provider API keys.
115
-
116
- `)+z.cyan("`taskgraph models` to check your config & available models\n")+z.cyan("`taskgraph models --setup` to adjust the AI models used by TaskGraph"),{padding:1,margin:{top:1},borderColor:`red`,borderStyle:`round`})):b(e),process.exit(1)}}export{lt as runCLI};
@@ -1 +0,0 @@
1
- import"./src-TZm8h0X-.js";export{S as getUserId}from"./config-manager-DhVH8AQp.js";
@@ -1 +0,0 @@
1
- import{_ as e,c as t,g as n,u as r}from"./src-TZm8h0X-.js";import{t as i}from"./git-utils--i2q96hv.js";import a from"chalk";import o from"path";import{z as s}from"zod";import c from"dotenv";import l from"fs";import{fileURLToPath as u}from"url";const d=[`add-task`,`analyze-complexity`,`expand-task`,`parse-prd`,`research`,`research-save`,`update-subtask`,`update-task`,`update-tasks`],f=`.taskgraph`,ee=`.taskgraph/tasks`,te=`.taskgraph/docs`,ne=`.taskgraph/reports`,re=`.taskgraph/templates`,p=`.taskgraph/config.json`,ie=`.taskgraph/state.json`,m=`.taskgraph/reports/task-complexity-report.json`,ae=`.taskgraph/docs/prd.txt`,oe=`.taskgraph/templates/example_prd.txt`,h=`.taskgraph/tasks/tasks.json`,se=`.env.example`,ce=`.gitignore`,g={primary:`#0088CC`,accent:`#0096C7`,deep:`#0080C0`},le=[g.accent,g.primary,g.deep],ue=g.accent,de=[`dim`],fe={dimBorder:!0},pe={brand:a.cyan,heading:a.cyan.bold,accent:a.magenta,active:a.cyan.bold,muted:a.dim,text:a};let _=!1;const me={maxRetries:5,retryDelay:100,staleLockAge:1e4};function he(e){if(typeof SharedArrayBuffer<`u`&&typeof Atomics<`u`&&typeof Atomics.wait==`function`)try{let t=new SharedArrayBuffer(4),n=new Int32Array(t);Atomics.wait(n,0,0,e);return}catch{}let t=Date.now()+e;for(;Date.now()<t;);}function ge(e,t,n={}){let{createIfMissing:r=!1}=n,i=o.dirname(e);if(l.existsSync(i)||l.mkdirSync(i,{recursive:!0}),r)try{l.writeFileSync(e,`{}`,{flag:`wx`})}catch(e){if(e.code!==`EEXIST`)throw e}let a=`${e}.lock`,{maxRetries:s,retryDelay:c,staleLockAge:u}=me,d=!1;for(let e=0;e<s;e++)try{let e=JSON.stringify({pid:process.pid,timestamp:Date.now()});l.writeFileSync(a,e,{flag:`wx`}),d=!0;break}catch(t){if(t.code===`EEXIST`){try{let e=l.statSync(a);if(Date.now()-e.mtimeMs>u){let e=`${a}.stale.${process.pid}.${Date.now()}`;try{l.renameSync(a,e);try{l.unlinkSync(e)}catch{}continue}catch{}}}catch(e){if(e.code===`ENOENT`)continue;throw e}e<s-1&&he(c*2**e)}else throw t}if(!d)throw Error(`Failed to acquire lock on ${e} after ${s} attempts`);try{return t()}finally{try{l.unlinkSync(a)}catch(t){S(`warn`,`Failed to release lock for ${e}: ${t.message}`)}}}function v(e,t=null,n=null){if(t?.env?.[e])return t.env[e];if(n){let t=o.join(n,`.env`);if(l.existsSync(t))try{let n=l.readFileSync(t,`utf-8`),r=c.parse(n);if(r&&r[e])return r[e]}catch(e){S(`warn`,`Could not read or parse ${t}: ${e.message}`)}}if(process.env[e])return process.env[e]}function y(e=process.cwd(),t=[`package.json`,`pyproject.toml`,`.git`]){let n=o.resolve(e),r=o.parse(n).root;for(;n!==r;){if(t.some(e=>{let t=o.join(n,e);return l.existsSync(t)}))return n;n=o.dirname(n)}return t.some(e=>{let t=o.join(r,e);return l.existsSync(t)})?r:null}const b={debug:0,info:1,warn:2,error:3,success:1};function _e(){_=!0}function ve(){_=!1}function x(){return _}function S(e,...t){if(x())return;let n=`info`;try{n=Ye()||`info`}catch{n=`info`}let r={debug:pe.muted(`[debug]`),info:``,warn:a.yellow(`⚠`),error:a.red(`✗`),success:a.green(`✓`)},i=b.hasOwnProperty(e)?e:`info`;if(b[i]>=(b[n]??b.info)){let e=r[i]||``,n=t.map(e=>typeof e==`object`?JSON.stringify(e):e).join(` `);console.log(e?`${e} ${n}`:n)}}function C(e){if(!e||typeof e!=`object`)return!1;for(let t in e)if(e.hasOwnProperty(t)&&typeof e[t]==`object`&&Array.isArray(e[t].tasks))return!0;return!1}function w(e){Array.isArray(e)&&e.forEach(e=>{if(e.id!==void 0){let t=parseInt(e.id,10);!isNaN(t)&&t>0&&(e.id=t)}Array.isArray(e.subtasks)&&e.subtasks.forEach(e=>{if(e.id!==void 0){if(typeof e.id==`string`&&e.id.includes(`.`)){let t=e.id.split(`.`);e.id=parseInt(t[t.length-1],10)}else{let t=parseInt(e.id,10);!isNaN(t)&&t>0&&(e.id=t)}}})})}function ye(e,t){let n=o.relative(process.cwd(),e),r=n&&!n.startsWith(`..`)&&!o.isAbsolute(n)?n:e,i=/\(line (\d+) column (\d+)\)/.exec(t.message),a=i?` (line ${i[1]}, column ${i[2]})`:``,s=Error(`${r} isn't valid JSON${a}`,{cause:t});return s.code=`JSON_PARSE_ERROR`,s}function T(e,t=null,n=null){let r=!1;try{r=$()}catch{}if(r&&console.log(`readJSON called with: ${e}, projectRoot: ${t}, tag: ${n}`),!e)return null;let a;try{a=JSON.parse(l.readFileSync(e,`utf8`)),r&&console.log(`Successfully read JSON from ${e}`)}catch(t){if(r&&console.log(`Failed to read JSON from ${e}: ${t.message}`),t instanceof SyntaxError&&o.basename(e)===`tasks.json`)throw ye(e,t);return null}if(!e.includes(`tasks.json`)||!a)return r&&console.log(`File is not tasks.json or data is null, returning as-is`),a;if(Array.isArray(a.tasks)&&!a._rawTaggedData&&!C(a)){r&&console.log(`File is in legacy format, performing migration...`),w(a.tasks);let n={master:{tasks:a.tasks,metadata:a.metadata||{created:(/* @__PURE__ */ new Date()).toISOString(),updated:(/* @__PURE__ */ new Date()).toISOString(),description:`Tasks for master context`}}};try{if(k(e,n),r&&console.log(`Successfully migrated legacy format to tagged format`),E(e),t)try{i(t,e)}catch{}O(e)}catch(e){r&&console.log(`Error writing migrated data: ${e.message}`)}a=n}if(typeof a==`object`&&!a.tasks){r&&console.log(`File is in tagged format, resolving tag...`);for(let e in a)if(a.hasOwnProperty(e)&&typeof a[e]==`object`&&a[e].tasks)try{P(a[e],{description:`Tasks for ${e} context`,skipUpdate:!0})}catch(t){r&&console.log(`Failed to ensure metadata for tag ${e}: ${t.message}`)}let s=JSON.parse(JSON.stringify(a));for(let e in s)s[e]&&Array.isArray(s[e].tasks)&&w(s[e].tasks);if(t)try{i(t,e)}catch{}try{let i=`master`;try{if(n)i=n;else if(t)i=N({projectRoot:t});else{let t=y(o.dirname(e));t&&(i=N({projectRoot:t}))}}catch(e){r&&console.log(`Tag resolution failed, using master: ${e.message}`)}r&&console.log(`Resolved tag: ${i}`);let c=a[i];if(c&&c.tasks){w(c.tasks);let e={...c,tag:i,_rawTaggedData:s};return r&&console.log(`Returning data for tag '${i}' with ${c.tasks.length} tasks`),e}{let e=a.master;return e&&e.tasks?(w(e.tasks),r&&console.log(`Tag '${i}' not found, falling back to master with ${e.tasks.length} tasks`),{...e,tag:`master`,_rawTaggedData:s}):(r&&console.log(`No valid tag data found, returning empty structure`),{tasks:[],tag:`master`,_rawTaggedData:s})}}catch(e){r&&console.log(`Error during tag resolution: ${e.message}`);let t=a.master;return t&&t.tasks?(w(t.tasks),{...t,_rawTaggedData:s}):{tasks:[],_rawTaggedData:s}}}return r&&console.log(`File format not recognized, returning as-is`),a}function E(e){try{let t=y(o.dirname(e))||o.dirname(e),n=o.join(t,`.taskgraph`,`config.json`);l.existsSync(n)&&be(n);let r=o.join(t,`.taskgraph`,`state.json`);l.existsSync(r)||D(r),$()&&S(`debug`,`Complete tag migration performed for project: ${t}`)}catch(e){$()&&S(`warn`,`Error during complete tag migration: ${e.message}`)}}function be(e){try{let t=l.readFileSync(e,`utf8`),n=JSON.parse(t);if(!n)return;let r=!1;n.global||={},n.global.defaultTag||(n.global.defaultTag=`master`,r=!0),r&&(l.writeFileSync(e,JSON.stringify(n,null,2),`utf8`),process.env.TASKGRAPH_DEBUG===`true`&&console.log(`[DEBUG] Updated config.json with tagged task system settings`))}catch(e){process.env.TASKGRAPH_DEBUG===`true`&&console.warn(`[WARN] Error migrating config.json: ${e.message}`)}}function D(e){try{let t={currentTag:`master`,lastSwitched:(/* @__PURE__ */ new Date()).toISOString(),branchTagMapping:{},migrationNoticeShown:!1};l.writeFileSync(e,JSON.stringify(t,null,2),`utf8`),process.env.TASKGRAPH_DEBUG===`true`&&console.log(`[DEBUG] Created initial state.json for tagged task system`)}catch(e){process.env.TASKGRAPH_DEBUG===`true`&&console.warn(`[WARN] Error creating state.json: ${e.message}`)}}function O(e){try{let t=o.join(o.dirname(o.dirname(e)),`state.json`);l.existsSync(t)||D(t);try{let e=l.readFileSync(t,`utf8`),n=JSON.parse(e)||{};n.migrationNoticePending=!0,n.migrationNoticeShown=!1,l.writeFileSync(t,JSON.stringify(n,null,2),`utf8`)}catch(e){process.env.TASKGRAPH_DEBUG===`true`&&console.warn(`[WARN] Error updating state for migration notice: ${e.message}`)}}catch(e){process.env.TASKGRAPH_DEBUG===`true`&&console.warn(`[WARN] Error marking migration for notice: ${e.message}`)}}function k(e,t,n=null,r=null){let i=process.env.TASKGRAPH_DEBUG===`true`;try{ge(e,()=>{let a=t;if(t&&!t._rawTaggedData&&n&&Array.isArray(t.tasks)&&!C(t)){let o=r||M(n);i&&console.log(`writeJSON: Detected resolved tag data missing _rawTaggedData. Re-reading raw data to prevent data loss for tag '${o}'.`);let s={};try{s=JSON.parse(l.readFileSync(e,`utf8`))}catch(e){i&&console.log(`writeJSON: Could not read existing file, starting fresh: ${e.message}`)}a={...s,[o]:{metadata:{...s[o]?.metadata||{},...t.metadata||{}},tasks:t.tasks}}}else if(t&&t._rawTaggedData&&n){let o=r||M(n),s;try{s=JSON.parse(l.readFileSync(e,`utf8`))}catch(e){s=t._rawTaggedData,i&&console.log(`writeJSON: Using _rawTaggedData as fallback: ${e.message}`)}let{_rawTaggedData:c,tag:u,...d}=t;a={...s,[o]:d},i&&console.log(`writeJSON: Merging resolved data back into tag '${o}'`)}let o=a;if(o&&typeof o==`object`){let{_rawTaggedData:e,tag:t,...n}=o;if(o=n,typeof o==`object`&&!Array.isArray(o)){let e={};for(let[t,n]of Object.entries(o))if(n&&typeof n==`object`&&Array.isArray(n.tasks)){let{created:r,description:i,...a}=n;a.metadata||={},r&&!a.metadata.created&&(a.metadata.created=r),i&&!a.metadata.description&&(a.metadata.description=i),e[t]=a}else e[t]=n;o=e}}let s=`${e}.tmp.${process.pid}`;try{l.writeFileSync(s,JSON.stringify(o,null,2),`utf8`),l.renameSync(s,e)}catch(e){try{l.existsSync(s)&&l.unlinkSync(s)}catch{}throw e}i&&console.log(`writeJSON: Successfully wrote to ${e}`)},{createIfMissing:!0})}catch(t){throw S(`error`,`Error writing JSON file ${e}:`,t.message),i&&S(`error`,`Full error details:`,t),t}}function xe(e=null){let t=!1;try{t=$()}catch{t=!1}try{let n;if(n=e||o.join(process.cwd(),m),!l.existsSync(n))return t&&S(`debug`,`Complexity report not found at ${n}`),null;let r=T(n);return t&&S(`debug`,`Successfully read complexity report from ${n}`),r}catch(e){return t&&S(`error`,`Error reading complexity report: ${e.message}`),null}}function A(e,t){return!e||!e.complexityAnalysis||!Array.isArray(e.complexityAnalysis)?null:e.complexityAnalysis.find(e=>e.taskId===t)}function j(e,t){let n;n=e.isSubtask?e.parentTask.id:e.parentId?e.parentId:e.id;let r=A(t,n);r&&(e.complexityScore=r.complexityScore)}function Se(e,t){if(!t||!e||!Array.isArray(e))return!1;if(typeof t==`string`&&t.includes(`.`)){let[n,r]=t.split(`.`).map(e=>parseInt(e,10)),i=e.find(e=>e.id===n);return!i||!i.subtasks?!1:i.subtasks.some(e=>e.id===r)}let n=parseInt(t,10);return e.some(e=>e.id===n)}function Ce(e){return typeof e==`string`&&e.includes(`.`)?e:typeof e==`number`?e.toString():e}function we(e,t,n=null,r=null){if(!t||!e||!Array.isArray(e))return{task:null,originalSubtaskCount:null};if(typeof t==`string`&&t.includes(`.`)){let[r,i]=t.split(`.`).map(e=>parseInt(e,10)),a=e.find(e=>e.id===r);if(!a||!a.subtasks)return{task:null,originalSubtaskCount:null,originalSubtasks:null};let o=a.subtasks.find(e=>e.id===i);return o&&(o.parentTask={id:a.id,title:a.title,status:a.status},o.isSubtask=!0),o&&n&&j(o,n),{task:o||null,originalSubtaskCount:null,originalSubtasks:null}}let i=null,a=null,o=null,s=parseInt(t,10),c=e.find(e=>e.id===s)||null;if(!c)return{task:null,originalSubtaskCount:null,originalSubtasks:null};if(i=c,r&&c.subtasks&&Array.isArray(c.subtasks)){o=[...c.subtasks],a=c.subtasks.length;let e={...c};e.subtasks=c.subtasks.filter(e=>e.status&&e.status.toLowerCase()===r.toLowerCase()),i=e}return i&&n&&j(i,n),{task:i,originalSubtaskCount:a,originalSubtasks:o}}function Te(e,t){return!e||e.length<=t?e:`${e.slice(0,t-3)}...`}function Ee(e){return Array.isArray(e)?e.length===0:typeof e==`object`&&e?Object.keys(e).length===0:!1}function De(e,t,n={}){let{maxDepth:r=50,includeSelf:i=!1,direction:a=`forward`,logger:o=null}=n,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set;function l(e){if(typeof e==`string`){if(e.includes(`.`))return e;let t=parseInt(e,10);return isNaN(t)?e:t}return e}function u(e,n=0){if(n>=r){let t=`Maximum recursion depth (${r}) reached for task ${e}`;o&&typeof o.warn==`function`?o.warn(t):S!==void 0&&S.warn?S.warn(t):console.warn(t);return}if(c.has(e))return;c.add(e);let a=t.find(t=>t.id===e);a&&Array.isArray(a.dependencies)&&a.dependencies.forEach(t=>{let r=l(t);r==null||!i&&r===e||(s.add(r),u(r,n+1))})}function d(e,n=0){if(n>=r){let t=`Maximum recursion depth (${r}) reached for task ${e}`;o&&typeof o.warn==`function`?o.warn(t):S!==void 0&&S.warn?S.warn(t):console.warn(t)}else c.has(e)||(c.add(e),t.forEach(t=>{if(t.dependencies&&Array.isArray(t.dependencies)&&t.dependencies.some(t=>l(t)===e)){if(t.id==null||!i&&t.id===e)return;s.add(t.id),d(t.id,n+1)}}))}let f=a===`reverse`?d:u;return e.forEach(e=>{e&&e.id&&f(e.id)}),Array.from(s)}function Oe(e,t){if(!e||e.length===0)return null;let n={timestamp:(/* @__PURE__ */ new Date()).toISOString(),userId:e[0].userId,commandName:t,modelUsed:`Multiple`,providerName:`Multiple`,inputTokens:0,outputTokens:0,cachedInputTokens:0,totalTokens:0,totalCost:0,currency:e[0].currency||`USD`},r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;return e.forEach(e=>{n.inputTokens+=e.inputTokens||0,n.outputTokens+=e.outputTokens||0,n.cachedInputTokens+=e.cachedInputTokens||0,n.totalCost+=e.totalCost||0,r.add(e.modelUsed),i.add(e.providerName),a.add(e.currency||`USD`)}),n.totalTokens=n.inputTokens+n.outputTokens,n.totalCost=parseFloat(n.totalCost.toFixed(6)),r.size===1&&(n.modelUsed=[...r][0]),i.size===1&&(n.providerName=[...i][0]),a.size>1?n.currency=`Multiple`:a.size===1&&(n.currency=[...a][0]),n}function M(e){if(!e)throw Error(`projectRoot is required for getCurrentTag`);try{let t=o.join(e,`.taskgraph`,`state.json`);if(l.existsSync(t)){let e=l.readFileSync(t,`utf8`),n=JSON.parse(e);if(n&&n.currentTag)return n.currentTag}}catch{}try{let t=o.join(e,`.taskgraph`,`config.json`);if(l.existsSync(t)){let e=l.readFileSync(t,`utf8`),n=JSON.parse(e);if(n&&n.global&&n.global.defaultTag)return n.global.defaultTag}}catch{}return`master`}function N(e={}){let{projectRoot:t,tag:n}=e;if(!t)throw Error(`projectRoot is required for resolveTag`);return n||M(t)}function ke(e,t){return!e||!t?[]:e[t]&&e[t].tasks&&Array.isArray(e[t].tasks)?e[t].tasks:[]}function Ae(e){let t=[];for(let n of e)if(t.push({...n,searchableId:n.id.toString(),isSubtask:!1}),n.subtasks&&n.subtasks.length>0)for(let e of n.subtasks)t.push({...e,searchableId:`${n.id}.${e.id}`,isSubtask:!0,parentId:n.id,parentTitle:n.title,title:`${e.title} (subtask of: ${n.title})`,description:`${e.description} [Parent: ${n.description}]`});return t}function P(e,t={}){if(!e||typeof e!=`object`)throw Error(`tagObj must be a valid object`);let n=(/* @__PURE__ */ new Date()).toISOString();return e.metadata?(e.metadata.created||(e.metadata.created=n),t.skipUpdate||(e.metadata.updated=n),t.description&&!e.metadata.description&&(e.metadata.description=t.description)):e.metadata={created:n,updated:n,...t.description?{description:t.description}:{}},e}function je(){return{info:(e,...t)=>S(`info`,e,...t),warn:(e,...t)=>S(`warn`,e,...t),error:(e,...t)=>S(`error`,e,...t),debug:(e,...t)=>S(`debug`,e,...t),success:(e,...t)=>S(`success`,e,...t)}}function F(e=null){return e||je()}function I(e){return r(e)}function L(e=process.cwd()){return t(e)}function Me(e=null,t=null,n=null){let r=F(n),i=t?.projectRoot||L();if(!i)return r.warn?.(`Could not determine project root directory`),null;let a=I(i);if(e){let t=o.isAbsolute(e)?e:o.resolve(a,e);if(l.existsSync(t))return r.info?.(`Using explicit tasks path: ${t}`),t;r.warn?.(`Explicit tasks path not found: ${t}, trying fallbacks`)}let s=o.join(a,h);return l.existsSync(s)?(r.info?.(`Found tasks file at: ${s}`),s):(r.warn?.(`No tasks.json found in project: ${a}`),null)}function Ne(e=null,t=null,n=null){let r=F(n);if(e){let t=process.env.TASKGRAPH_ORIGINAL_CWD||process.cwd(),n=o.isAbsolute(e)?e:o.resolve(t,e);if(l.existsSync(n))return r.info?.(`Using explicit PRD path: ${n}`),n;r.warn?.(`Explicit PRD path not found: ${n}, trying fallbacks`)}let i=t?.projectRoot||L();if(!i)return r.warn?.(`Could not determine project root directory`),null;let a=I(i);for(let e of[`PRD.md`,`prd.md`,`PRD.txt`,`prd.txt`]){let t=o.join(a,te,e);if(l.existsSync(t))return r.info?.(`Found PRD document at: ${t}`),t}return r.warn?.(`No PRD document found in project: ${a}`),null}function Pe(e=null,t=null,n=null){let r=F(n);if(e){let t=process.env.TASKGRAPH_ORIGINAL_CWD||process.cwd(),n=o.isAbsolute(e)?e:o.resolve(t,e);if(l.existsSync(n))return r.info?.(`Using explicit complexity report path: ${n}`),n;r.warn?.(`Explicit complexity report path not found: ${n}, trying fallbacks`)}let i=t?.projectRoot||L();if(!i)return r.warn?.(`Could not determine project root directory`),null;let a=I(i),s=[`task-complexity-report`,`task-complexity`,`complexity-report`].map(e=>t?.tag&&t?.tag!==`master`?`${e}_${t.tag}.json`:`${e}.json`);for(let e of s){let t=o.join(a,ne,e);if(l.existsSync(t))return r.info?.(`Found complexity report at: ${t}`),t}return r.warn?.(`No complexity report found in project: ${a}`),null}function Fe(e=null,t=null,n=null){let r=F(n),i=t?.tag;if(e){let t=process.env.TASKGRAPH_ORIGINAL_CWD||process.cwd(),n=o.isAbsolute(e)?e:o.resolve(t,e);return r.info?.(`Using explicit complexity report output path: ${n}`),n}let a=I(t?.projectRoot||L()||process.cwd()),s=`task-complexity-report.json`;i&&i!==`master`&&(s=`task-complexity-report_${i}.json`);let c=o.join(a,`.taskgraph/reports`,s);r.info?.(`Using tag-aware complexity report output path: ${c}`);let u=o.dirname(c);return l.existsSync(u)||(r.info?.(`Creating reports directory: ${u}`),l.mkdirSync(u,{recursive:!0})),c}function R(e=null,t=null,n=null){let r=F(n);if(e){let t=process.env.TASKGRAPH_ORIGINAL_CWD||process.cwd(),n=o.isAbsolute(e)?e:o.resolve(t,e);if(l.existsSync(n))return r.info?.(`Using explicit config path: ${n}`),n;r.warn?.(`Explicit config path not found: ${n}, trying fallbacks`)}let i=t?.projectRoot||L();if(!i)return r.warn?.(`Could not determine project root directory`),null;let a=I(i),s=o.join(a,p);if(l.existsSync(s))return s;if(!U()){let e=`config_warning_${a}`;global._tmConfigWarningsThisRun||(global._tmConfigWarningsThisRun=/* @__PURE__ */ new Set),global._tmConfigWarningsThisRun.has(e)||(global._tmConfigWarningsThisRun.add(e),r.debug?.(`No configuration file found in project: ${a}`))}return null}var z={"claude-code":[{id:`opus`,swe_score:.725,cost_per_1m_tokens:{input:0,output:0},allowed_roles:[`main`,`fallback`,`research`],max_tokens:32e3,supported:!0},{id:`sonnet`,swe_score:.727,cost_per_1m_tokens:{input:0,output:0},allowed_roles:[`main`,`fallback`,`research`],max_tokens:64e3,supported:!0},{id:`haiku`,swe_score:.45,cost_per_1m_tokens:{input:0,output:0},allowed_roles:[`main`,`fallback`,`research`],max_tokens:2e5,supported:!0}]};const Ie=u(import.meta.url);o.dirname(Ie);const B={models:{main:{provider:`claude-code`,modelId:`sonnet`,maxTokens:64e3,temperature:.2},research:{provider:`claude-code`,modelId:`sonnet`,maxTokens:8700,temperature:.1},fallback:{provider:`claude-code`,modelId:`sonnet`,maxTokens:64e3,temperature:.2}},global:{logLevel:`info`,debug:!1,defaultNumTasks:10,defaultSubtasks:5,defaultPriority:`medium`,projectName:`TaskGraph`,responseLanguage:`English`,enableCodebaseAnalysis:!0,enableProxy:!1},claudeCode:{}};let V=null,H=null;function Le(e){global._tmSuppressConfigWarnings=e}function U(){return global._tmSuppressConfigWarnings===!0}var Re=class extends Error{constructor(e){super(e),this.name=`ConfigurationError`}};function ze(e=null){let t=B,n=e;e&&`${e}`,n||(n=y(),n||=process.cwd(),`${n}`);let r=null,i={...t};if(l.existsSync(o.join(n,`.taskgraph`))&&(r=R(null,{projectRoot:n})),r)try{let e=l.readFileSync(r,`utf-8`),n=JSON.parse(e);i={models:{main:{...t.models.main,...n?.models?.main},research:{...t.models.research,...n?.models?.research},fallback:n?.models?.fallback?.provider&&n?.models?.fallback?.modelId?{...t.models.fallback,...n.models.fallback}:{...t.models.fallback}},global:{...t.global,...n?.global},claudeCode:{...t.claudeCode,...n?.claudeCode}},`${r}`,K(i.models.main.provider)||(console.warn(a.yellow(`Warning: Invalid main provider "${i.models.main.provider}" in ${r}. Falling back to default. Run 'taskgraph models --setup' to choose a Claude Code model.`)),i.models.main={...t.models.main}),K(i.models.research.provider)||(console.warn(a.yellow(`Warning: Invalid research provider "${i.models.research.provider}" in ${r}. Falling back to default. Run 'taskgraph models --setup' to choose a Claude Code model.`)),i.models.research={...t.models.research}),i.models.fallback?.provider&&!K(i.models.fallback.provider)&&(console.warn(a.yellow(`Warning: Invalid fallback provider "${i.models.fallback.provider}" in ${r}. Fallback model configuration will be ignored. Run 'taskgraph models --setup' to choose a Claude Code model.`)),i.models.fallback.provider=void 0,i.models.fallback.modelId=void 0),i.claudeCode&&!Ee(i.claudeCode)&&(i.claudeCode=q(i.claudeCode))}catch(e){console.error(a.red(`Error reading or parsing ${r}: ${e.message}. Using default configuration.`)),i={...t},`${r}`}else(e||l.existsSync(o.join(n,`.taskgraph/tasks/tasks.json`)))&&!U()&&Be(e||n),i={...t},`${n}`;return i}const W=/* @__PURE__ */ new Set;function Be(e){W.has(e)||(W.add(e),console.warn(`${a.yellow(`⚠`)} No .taskgraph/config.json in ${e}; using default settings\n`+a.dim(` Run taskgraph init to recreate it`)))}function G(e=null,t=!1){if(!V||t||e&&e!==H){let n=ze(e);return(t||e)&&(V=n,H=e),n}return V}function K(t){return!!e.includes(t)}function Ve(e){return z[e]?z[e].filter(e=>e.supported!==!1).map(e=>e.id):[]}function q(e){let t=s.object({pathToClaudeCodeExecutable:s.string().optional(),maxTurns:s.number().int().positive().optional(),customSystemPrompt:s.string().optional(),appendSystemPrompt:s.string().optional(),permissionMode:s.enum([`default`,`acceptEdits`,`plan`,`bypassPermissions`]).optional(),allowedTools:s.array(s.string()).optional(),disallowedTools:s.array(s.string()).optional(),mcpServers:s.record(s.string(),s.object({type:s.enum([`stdio`,`sse`]).optional(),command:s.string(),args:s.array(s.string()).optional(),env:s.record(s.string(),s.string()).optional(),url:s.url().optional(),headers:s.record(s.string(),s.string()).optional()})).optional()}),n=s.record(s.string(),t).refine(e=>Object.keys(e||{}).every(e=>d.includes(e)),{message:`Invalid command name in commandSpecific`}),r=t.extend({commandSpecific:n.optional()}),i={};try{i=r.parse(e)}catch(e){console.warn(a.yellow(`Warning: Invalid Claude Code settings in config: ${e.message}. Falling back to default.`)),i={}}return i}function J(e=null,t=!1){let n=G(e,t);return{...B.claudeCode,...n?.claudeCode||{}}}function He(e,t=null,n=!1){let r=J(t,n),i=r?.commandSpecific||{};return{...r,...i[e]}}function Y(e,t=null){return G(t)?.models?.[e]||(S(`warn`,`No model configuration found for role: ${e}. Returning default.`),B.models[e]||{})}function X(e=null){return Y(`main`,e).provider}function Ue(e=null){return Y(`main`,e).modelId}function Z(e=null){return Y(`research`,e).provider}function We(e=null,t=null){let n=v(`TASKGRAPH_ENABLE_CODEBASE_ANALYSIS`,e,t);if(n!=null&&n!==``)return n.toLowerCase()===`true`||n===`1`;if(e?.env?.TASKGRAPH_ENABLE_CODEBASE_ANALYSIS){let t=e.env.TASKGRAPH_ENABLE_CODEBASE_ANALYSIS;return t.toLowerCase()===`true`||t===`1`}return Q(t).enableCodebaseAnalysis!==!1}function Ge(e=!1,t=null,r=null){return!We(r,t)||e?!1:(e?Z(t):X(t))===n.CLAUDE_CODE}function Ke(e=null){return Y(`research`,e).modelId}function qe(e=null){return Y(`fallback`,e).provider}function Je(e=null){return Y(`fallback`,e).modelId}function Q(e=null){let t=G(e);return{...B.global,...t?.global||{}}}function Ye(e=null){return Q(e).logLevel.toLowerCase()}function $(e=null){return Q(e).debug===!0}function Xe(e=null){let t=Q(e).defaultSubtasks,n=parseInt(t,10);return Number.isNaN(n)?B.global.defaultSubtasks:n}function Ze(e=null){let t=Q(e).defaultNumTasks,n=parseInt(t,10);return Number.isNaN(n)?B.global.defaultNumTasks:n}function Qe(e=null){return Q(e).defaultPriority}function $e(e=null){return Q(e).projectName}function et(e=null){return Q(e).responseLanguage}function tt(e=null){return Q(e).enableProxy===!0}function nt(e=null,t=null){let n=v(`TASKGRAPH_ENABLE_PROXY`,e,t);if(n!=null&&n!==``)return n.toLowerCase()===`true`||n===`1`;if(e?.env?.TASKGRAPH_ENABLE_PROXY){let t=e.env.TASKGRAPH_ENABLE_PROXY;return t.toLowerCase()===`true`||t===`1`}return tt(t)}function rt(e,t=null){let n=Y(e,t),r=n.maxTokens,i=n.temperature,a=n.modelId,o=n.provider,s=r,c=i;try{let e=z[o];if(e&&Array.isArray(e)){let t=e.find(e=>e.id===a);if(t&&typeof t.max_tokens==`number`&&t.max_tokens>0){let e=t.max_tokens;s=Math.min(r,e),S(`debug`,`Applying model-specific max_tokens (${e}) for ${a}. Effective limit: ${s}`)}else S(`debug`,`No valid model-specific max_tokens override found for ${a}. Using role default: ${r}`);t&&typeof t.temperature==`number`&&t.temperature>=0&&t.temperature<=1&&(c=t.temperature,S(`debug`,`Applying model-specific temperature (${t.temperature}) for ${a}`))}else S(`debug`,`No model definitions found for provider ${o} in MODEL_MAP. Using role default maxTokens: ${r}`)}catch(e){S(`warn`,`Error looking up model-specific parameters for ${a}: ${e.message}. Using role defaults.`),s=r,c=i}return{maxTokens:s,temperature:c}}function it(){let e=[];for(let[t,n]of Object.entries(z))n.length>0&&n.filter(e=>!!e.supported).forEach(n=>{let r=n.id,i=n.swe_score,a=n.cost_per_1m_tokens,o=n.allowed_roles||[`main`,`fallback`],s=n.name;s||=r.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),e.push({id:r,name:s,provider:t,swe_score:i,cost_per_1m_tokens:a,allowed_roles:o,max_tokens:n.max_tokens})});return e}function at(e,t=null){let n=t;if(t==null){let e=y();if(!e)return console.error(a.red(`Error: Could not determine project root. Configuration not saved.`)),!1;n=e}let r=o.join(n,`.taskgraph`),i=o.join(r,`config.json`);try{return l.existsSync(r)||l.mkdirSync(r,{recursive:!0}),l.writeFileSync(i,JSON.stringify(e,null,2)),V=e,!0}catch(e){return console.error(a.red(`Error writing configuration to ${i}: ${e.message}`)),!1}}function ot(e=null){return R(null,{projectRoot:e})!==null}function st(e=null){let t=G(e);return t.global||={},t.global.userId||(t.global.userId=`1234567890`,at(t,e)||S(`warning`,`Failed to write updated configuration with new userId. Please let the developers know.`)),t.global.userId}export{S as $,K as A,j as B,Ge as C,te as Ct,nt as D,h as Dt,U as E,ee as Et,Ne as F,y as G,ve as H,L as I,Ae as J,we as K,Me as L,z as M,Pe as N,Le as O,re as Ot,R as P,x as Q,I as R,st as S,f as St,ot as T,ie as Tt,_e as U,Oe as V,P as W,M as X,Ce as Y,ke as Z,tt as _,se as _t,G as a,N as at,et as b,ae as bt,Qe as c,Te as ct,qe as d,ue as dt,O as et,Ye as f,g as ft,$e as g,m as gt,rt as h,pe as ht,He as i,v as it,at as j,q as k,Xe as l,k as lt,X as m,de as mt,it as n,xe as nt,$ as o,Se as ot,Ue as p,fe as pt,A as q,J as r,T as rt,Ze as s,De as st,Re as t,E as tt,Je as u,le as ut,Ke as v,oe as vt,We as w,ne as wt,Ve as x,p as xt,Z as y,ce as yt,Fe as z};