taskgraph-ai 0.50.1 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{o as e}from"./ai-services-unified-DbjBfAvG.js";import{At as t,Ct as n,Dt as r,Mt as i,Ot as a,Pt as o,Tt as s,j as c,jt as l,kt as u,nt as d,tt as f,wt as ee,xt as p}from"./config-manager-Da0wEujO.js";import{r as m}from"./git-utils-CrYiSKu0.js";import{a as h,dt as g}from"./dependency-manager-DIbDdrUV.js";import _ from"chalk";import*as v from"node:path";import y from"path";import*as b from"node:fs";import{execSync as x}from"child_process";import S from"fs";import{fileURLToPath as C}from"url";import w from"boxen";import T from"readline";import te from"figlet";import ne from"gradient-string";import re from"ora";import ie from"os";import{randomUUID as ae}from"crypto";const E=[`claude`];function oe(e){return e.filter(e=>!se(e))}function se(e){return E.includes(e)}const D=`# Task files`,O=`tasks.json`,k=`tasks/`;function A(e){return e.trim().replace(/^#/,``).trim()}function j(e){let t=A(e);return t===O||t===k}function ce(e,t){return e.map(e=>{if(j(e)){let n=A(e),r=e.match(/\s*$/)[0];return t?`# ${n}${r}`:`${n}${r}`}return e})}function le(e){let t=[],n=!1;for(let r of e){if(r.trim()===D){n=!0;continue}j(r)||n&&!r.trim()||(n&&r.trim()&&!j(r)&&(n=!1),n||t.push(r))}return t}function ue(e,t){return e.filter(e=>{let n=e.trim();return!n||j(e)||n===D?!1:!t.has(n)})}function de(e){let t=[D];return e?t.push(`# ${O}`,`# ${k} `):t.push(O,`${k} `),t}function M(e){if(e.some(e=>e.trim())){let t=e[e.length-1];t&&t.trim()&&e.push(``)}}function fe(e,t,n){if(!e||typeof e!=`string`)throw Error(`targetPath must be a non-empty string`);if(!e.endsWith(`.gitignore`))throw Error(`targetPath must end with .gitignore`);if(!t||typeof t!=`string`)throw Error(`content must be a non-empty string`);if(typeof n!=`boolean`)throw Error(`storeTasksInGit must be a boolean`)}function pe(e,t,n){try{S.writeFileSync(e,t.join(`
1
+ import{o as e}from"./ai-services-unified-DwHuNUlO.js";import{At as t,Ct as n,Dt as r,Mt as i,Ot as a,Pt as o,Tt as s,j as c,jt as l,kt as u,nt as d,tt as f,wt as ee,xt as p}from"./config-manager-DG87FsDF.js";import{r as m}from"./git-utils-CrYiSKu0.js";import{a as h,dt as g}from"./dependency-manager-CjxVGmuC.js";import _ from"chalk";import*as v from"node:path";import y from"path";import*as b from"node:fs";import{execSync as x}from"child_process";import S from"fs";import{fileURLToPath as C}from"url";import w from"boxen";import T from"readline";import te from"figlet";import ne from"gradient-string";import re from"ora";import ie from"os";import{randomUUID as ae}from"crypto";const E=[`claude`];function oe(e){return e.filter(e=>!se(e))}function se(e){return E.includes(e)}const D=`# Task files`,O=`tasks.json`,k=`tasks/`;function A(e){return e.trim().replace(/^#/,``).trim()}function j(e){let t=A(e);return t===O||t===k}function ce(e,t){return e.map(e=>{if(j(e)){let n=A(e),r=e.match(/\s*$/)[0];return t?`# ${n}${r}`:`${n}${r}`}return e})}function le(e){let t=[],n=!1;for(let r of e){if(r.trim()===D){n=!0;continue}j(r)||n&&!r.trim()||(n&&r.trim()&&!j(r)&&(n=!1),n||t.push(r))}return t}function ue(e,t){return e.filter(e=>{let n=e.trim();return!n||j(e)||n===D?!1:!t.has(n)})}function de(e){let t=[D];return e?t.push(`# ${O}`,`# ${k} `):t.push(O,`${k} `),t}function M(e){if(e.some(e=>e.trim())){let t=e[e.length-1];t&&t.trim()&&e.push(``)}}function fe(e,t,n){if(!e||typeof e!=`string`)throw Error(`targetPath must be a non-empty string`);if(!e.endsWith(`.gitignore`))throw Error(`targetPath must end with .gitignore`);if(!t||typeof t!=`string`)throw Error(`content must be a non-empty string`);if(typeof n!=`boolean`)throw Error(`storeTasksInGit must be a boolean`)}function pe(e,t,n){try{S.writeFileSync(e,t.join(`
2
2
  `)+`
3
3
  `),typeof n==`function`&&n(`success`,`Created ${e} with full template`)}catch(t){throw typeof n==`function`&&n(`error`,`Failed to create ${e}: ${t.message}`),t}}function me(e,t,n,r){try{let i=le(S.readFileSync(e,`utf8`).split(`
4
4
  `)),a=ue(t,new Set(i.map(e=>e.trim()).filter(e=>e))),o=[...i];a.length>0&&(M(o),o.push(...a)),M(o),o.push(...de(n)),S.writeFileSync(e,o.join(`
@@ -3455,6 +3455,6 @@ ${r}
3455
3455
  `)}`;S.writeFileSync(t,n),J(`success`,`Updated ${t} with additional entries`)}else J(`info`,`No new content to add to ${t}`);return}if(e===`README-taskgraph.md`){J(`info`,`${t} already exists`);let e=y.join(y.dirname(t),`README-taskgraph.md`);S.writeFileSync(e,r),J(`success`,`Created ${e} (preserved original README-taskgraph.md)`);return}J(`debug`,`${t} already exists, skipping.`);return}S.writeFileSync(t,r),J(`info`,`Created file: ${t}`)}async function ut(e={}){f()||ct(),e.git===!0?e.initGit=!0:e.git===!1&&(e.initGit=!1),e.gitTasks===!0?e.storeTasksInGit=!0:e.gitTasks===!1&&(e.storeTasksInGit=!1);let t=e.yes||e.name&&e.description,n;if(n=e.rulesExplicitlyProvided?e.rules:[],t){f()||console.log(`SKIPPING PROMPTS - Using defaults or provided values`),e.name,e.description,e.version,e.author;let t=e.dryRun||!1,r=e.initGit===void 0?!0:e.initGit,i=e.storeTasksInGit===void 0?!0:e.storeTasksInGit;if(t)return J(`info`,`DRY RUN MODE: No files will be modified`),J(`info`,`Would initialize TaskGraph project`),J(`info`,`Would create/update necessary project files`),J(`info`,`${r?`Would initialize Git repository`:`Would skip Git initialization`}`),J(`info`,`${i?`Would store tasks in Git`:`Would exclude tasks from Git`}`),{dryRun:!0};await $(!0,r,i,t,{...e,preferredLanguage:`English`},n)}else{J(`debug`,`Required options not provided, proceeding with prompts.`);let t;try{J(`debug`,`Init started - taskgraph_id: ${dt()}`),t=T.createInterface({input:process.stdin,output:process.stdout});let r=!0,i=!0;r=e.initGit===void 0?(await Q(t,_.cyan(`Initialize a Git repository in project root? (Y/n): `),e=>{let t=e.trim().toLowerCase()!==`n`,n=t?_.green(`✓`):_.red(`✗`);return _.cyan(`Initialize a Git repository in project root?`)+` `+n+` `+_.dim(t?`Yes`:`No`)})).trim().toLowerCase()!==`n`:e.initGit,i=e.storeTasksInGit===void 0?(await Q(t,_.cyan(`Store tasks in Git (tasks.json and tasks/ directory)? (Y/n): `),e=>{let t=e.trim().toLowerCase()!==`n`,n=t?_.green(`✓`):_.red(`✗`);return _.cyan(`Store tasks in Git (tasks.json and tasks/ directory)?`)+` `+n+` `+_.dim(t?`Yes`:`No`)})).trim().toLowerCase()!==`n`:e.storeTasksInGit;let a=!1;e.rulesExplicitlyProvided?J(`info`,`Using rule profiles provided via command line: ${n.join(`, `)}`):a=(await Q(t,_.cyan(`Set up Claude Code integration (CLAUDE.md import)? (y/N): `),e=>{let t=e.trim().toLowerCase()===`y`,n=t?_.green(`✓`):_.red(`✗`);return _.cyan(`Set up Claude Code integration?`)+` `+n+` `+_.dim(t?`Yes`:`No`)})).trim().toLowerCase()===`y`;let o=(await Q(t,_.cyan(`Preferred response language (English): `))).trim()||`English`;console.log(`
3456
3456
  `+_.bold(`TaskGraph Project Settings:`)),console.log(_.dim(`─`.repeat(50)));let s=a?_.green(`✓`):_.dim(`✗`);console.log(` `+_.dim(`Claude Code integration:`.padEnd(32)),s+` `+_.dim(a?`Yes`:`No`)),console.log(` `+_.dim(`Response language:`.padEnd(32)),p.text(o));let c=r?_.green(`✓`):_.dim(`✗`);console.log(` `+_.dim(`Initialize Git repository:`.padEnd(32)),c+` `+_.dim(r?`Yes`:`No`));let l=i?_.green(`✓`):_.dim(`✗`);if(console.log(` `+_.dim(`Store tasks in Git:`.padEnd(32)),l+` `+_.dim(i?`Yes`:`No`)),console.log(_.dim(`─`.repeat(50))),(await Q(t,_.yellow(`
3457
3457
  Do you want to continue with these settings? (Y/n): `))).trim().toLowerCase()===`n`){t.close(),J(`info`,`Project initialization cancelled by user`),process.exit(0);return}let u=e.dryRun||!1;if(u)return J(`info`,`DRY RUN MODE: No files will be modified`),J(`info`,`Would initialize TaskGraph project`),J(`info`,`Would create/update necessary project files`),J(`info`,`${r?`Would initialize Git repository`:`Would skip Git initialization`}`),J(`info`,`${i?`Would store tasks in Git`:`Would exclude tasks from Git`}`),{dryRun:!0};await $(!0,r,i,u,{...e,shouldSetupRules:a,preferredLanguage:o},a?E:n),t.close()}catch(e){t&&t.close(),J(`error`,`Error during initialization process: ${e.message}`),process.exit(1)}}}function Q(e,t,n){return new Promise(r=>{e.question(t,e=>{T.moveCursor(process.stdout,0,-1),T.cursorTo(process.stdout,0),T.clearLine(process.stdout,0),n&&process.stdout.write(n(e)+`
3458
- `),r(e)})})}function dt(){return ae()}function ft(e){try{if(!S.existsSync(e)){J(`warn`,`Config file does not exist, skipping storage configuration`);return}let t=S.readFileSync(e,`utf8`),n=JSON.parse(t);n.storage||={},n.storage.type=`file`,n.storage.operatingMode=`solo`,J(`debug`,`Configured storage for local file storage`),S.writeFileSync(e,JSON.stringify(n,null,2)),J(`debug`,`Storage configuration updated in config.json`)}catch(e){J(`error`,`Failed to update storage configuration: ${e.message}`)}}async function $(e,c,l,d,p,g=E){let v=process.cwd();J(`debug`,`Initializing project in ${v}`),Y(y.join(v,a)),Y(y.join(v,i)),Y(y.join(v,u)),Y(y.join(v,t)),Y(y.join(v,o)),lt(v);let b={year:new Date().getFullYear()};function S(e){let t=it(e);t?at(v,t,{mode:`solo`}):J(`warn`,`Unknown rule profile: ${e}`)}Z(`env.example`,y.join(v,n),b),Z(`config.json`,y.join(v,r),{...b});let C=y.join(v,r);st(C)?J(`debug`,`Updated config with correct maxTokens values`):J(`debug`,`Could not update maxTokens in config`),ft(C);try{let e=L(`gitignore`,`utf8`);he(y.join(v,s),e,l,J)}catch(e){J(`error`,`Failed to create .gitignore: ${e.message}`)}Z(`example_prd.txt`,y.join(v,ee)),Z(`example_prd_rpg.txt`,y.join(v,o,`example_prd_rpg.txt`));try{c===!1?J(`info`,`Git initialization skipped due to --no-git flag.`):c===!0?m()?J(`debug`,`Existing Git repository detected – skipping git init despite --git flag.`):(J(`info`,`Initializing Git repository due to --git flag...`),x(`git init`,{cwd:v,stdio:`ignore`}),J(`success`,`Git repository initialized`)):m()?J(`debug`,`Existing Git repository detected – skipping git init.`):(J(`info`,`No Git repository detected. Initializing one in project root...`),x(`git init`,{cwd:v,stdio:`ignore`}),J(`success`,`Git repository initialized`))}catch{J(`warn`,`Git not available, skipping repository initialization`)}if(g.length>0){J(`info`,`Setting up Claude Code integration...`);for(let e of g)S(e)}e&&X();let T={cwd:v,stdio:`inherit`};if(f()&&(T.stdio=`ignore`,J(`info`,`Running npm install silently...`)),p.preferredLanguage&&!d)try{let e=(await import(`./response-language-CGnha79j.js`)).default;e(p.preferredLanguage,{projectRoot:v,silent:!0}),J(`debug`,`Response language set to: ${p.preferredLanguage}`)}catch(e){J(`warn`,`Failed to set response language: ${e.message}`)}else f()&&!d?J(`debug`,`Skipping response language setup in silent (MCP) mode.`):d&&J(`debug`,`DRY RUN: Skipping response language setup.`);if(!f()&&!d&&!p?.yes){console.log(w(_.cyan(`Configuring AI Models...`),{padding:.5,margin:{top:1,bottom:.5},borderStyle:`round`,borderColor:`cyan`,width:60})),J(`info`,`Running interactive model setup. Please select your preferred AI models.`);try{x(`npx taskgraph models --setup`,{stdio:`inherit`,cwd:v}),J(`success`,`AI Models configured.`)}catch(e){J(`error`,`Failed to configure AI models:`,e.message),J(`warn`,`You may need to run "taskgraph models --setup" manually.`)}}else f()&&!d?(J(`info`,`Skipping interactive model setup in silent (MCP) mode.`),J(`warn`,`Please configure AI models using "taskgraph models --set-..." or the "models" MCP tool.`)):d?J(`info`,`DRY RUN: Skipping interactive model setup.`):p?.yes&&(J(`info`,`Skipping interactive model setup due to --yes flag.`),J(`info`,`Default AI models will be used. You can configure different models later using "taskgraph models --setup" or "taskgraph models --set-..." commands.`));if(e&&!d?(J(`debug`,`Adding shell aliases...`),X()&&J(`debug`,`Shell aliases added successfully`)):e&&d&&J(`debug`,`DRY RUN: Would add shell aliases (tm, taskgraph)`),f()||console.log(w(`${h.multiline(te.textSync(`Success!`,{font:`Standard`}))}\n${_.green(`Project initialized successfully!`)}`,{padding:1,margin:1,borderStyle:`double`,borderColor:`green`,width:60})),!f()){let e=ot();console.log(w(_.yellow.bold(`Workflow
3458
+ `),r(e)})})}function dt(){return ae()}function ft(e){try{if(!S.existsSync(e)){J(`warn`,`Config file does not exist, skipping storage configuration`);return}let t=S.readFileSync(e,`utf8`),n=JSON.parse(t);n.storage||={},n.storage.type=`file`,n.storage.operatingMode=`solo`,J(`debug`,`Configured storage for local file storage`),S.writeFileSync(e,JSON.stringify(n,null,2)),J(`debug`,`Storage configuration updated in config.json`)}catch(e){J(`error`,`Failed to update storage configuration: ${e.message}`)}}async function $(e,c,l,d,p,g=E){let v=process.cwd();J(`debug`,`Initializing project in ${v}`),Y(y.join(v,a)),Y(y.join(v,i)),Y(y.join(v,u)),Y(y.join(v,t)),Y(y.join(v,o)),lt(v);let b={year:new Date().getFullYear()};function S(e){let t=it(e);t?at(v,t,{mode:`solo`}):J(`warn`,`Unknown rule profile: ${e}`)}Z(`env.example`,y.join(v,n),b),Z(`config.json`,y.join(v,r),{...b});let C=y.join(v,r);st(C)?J(`debug`,`Updated config with correct maxTokens values`):J(`debug`,`Could not update maxTokens in config`),ft(C);try{let e=L(`gitignore`,`utf8`);he(y.join(v,s),e,l,J)}catch(e){J(`error`,`Failed to create .gitignore: ${e.message}`)}Z(`example_prd.txt`,y.join(v,ee)),Z(`example_prd_rpg.txt`,y.join(v,o,`example_prd_rpg.txt`));try{c===!1?J(`info`,`Git initialization skipped due to --no-git flag.`):c===!0?m()?J(`debug`,`Existing Git repository detected – skipping git init despite --git flag.`):(J(`info`,`Initializing Git repository due to --git flag...`),x(`git init`,{cwd:v,stdio:`ignore`}),J(`success`,`Git repository initialized`)):m()?J(`debug`,`Existing Git repository detected – skipping git init.`):(J(`info`,`No Git repository detected. Initializing one in project root...`),x(`git init`,{cwd:v,stdio:`ignore`}),J(`success`,`Git repository initialized`))}catch{J(`warn`,`Git not available, skipping repository initialization`)}if(g.length>0){J(`info`,`Setting up Claude Code integration...`);for(let e of g)S(e)}e&&X();let T={cwd:v,stdio:`inherit`};if(f()&&(T.stdio=`ignore`,J(`info`,`Running npm install silently...`)),p.preferredLanguage&&!d)try{let e=(await import(`./response-language-Bod1H20U.js`)).default;e(p.preferredLanguage,{projectRoot:v,silent:!0}),J(`debug`,`Response language set to: ${p.preferredLanguage}`)}catch(e){J(`warn`,`Failed to set response language: ${e.message}`)}else f()&&!d?J(`debug`,`Skipping response language setup in silent (MCP) mode.`):d&&J(`debug`,`DRY RUN: Skipping response language setup.`);if(!f()&&!d&&!p?.yes){console.log(w(_.cyan(`Configuring AI Models...`),{padding:.5,margin:{top:1,bottom:.5},borderStyle:`round`,borderColor:`cyan`,width:60})),J(`info`,`Running interactive model setup. Please select your preferred AI models.`);try{x(`npx taskgraph models --setup`,{stdio:`inherit`,cwd:v}),J(`success`,`AI Models configured.`)}catch(e){J(`error`,`Failed to configure AI models:`,e.message),J(`warn`,`You may need to run "taskgraph models --setup" manually.`)}}else f()&&!d?(J(`info`,`Skipping interactive model setup in silent (MCP) mode.`),J(`warn`,`Please configure AI models using "taskgraph models --set-..." or the "models" MCP tool.`)):d?J(`info`,`DRY RUN: Skipping interactive model setup.`):p?.yes&&(J(`info`,`Skipping interactive model setup due to --yes flag.`),J(`info`,`Default AI models will be used. You can configure different models later using "taskgraph models --setup" or "taskgraph models --set-..." commands.`));if(e&&!d?(J(`debug`,`Adding shell aliases...`),X()&&J(`debug`,`Shell aliases added successfully`)):e&&d&&J(`debug`,`DRY RUN: Would add shell aliases (tm, taskgraph)`),f()||console.log(w(`${h.multiline(te.textSync(`Success!`,{font:`Standard`}))}\n${_.green(`Project initialized successfully!`)}`,{padding:1,margin:1,borderStyle:`double`,borderColor:`green`,width:60})),!f()){let e=ot();console.log(w(_.yellow.bold(`Workflow
3459
3459
  `)+`
3460
3460
  `+e,{padding:1,margin:{top:0,bottom:1,left:0,right:0},borderStyle:`round`,borderColor:`yellow`,width:60}))}}export{E as n,oe as r,ut as t};