@hhsw2015/task-master-ai 0.43.14 → 0.43.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-services-unified-D56eIxmP.js +1 -0
- package/dist/{ai-services-unified-DHz7C__S.js → ai-services-unified-tvfkaOTr.js} +1 -1
- package/dist/{commands-DvBvhm_z.js → commands-BxyWkKtz.js} +4 -4
- package/dist/{config-manager-DWjTTpDf.js → config-manager-B7h71nH_.js} +1 -1
- package/dist/{config-manager-DofXOeM1.js → config-manager-Cm3z1HZv.js} +6 -4
- package/dist/{dependency-manager-CUmj7nyx.js → dependency-manager-w4WB-z27.js} +95 -48
- package/dist/mcp-server.js +2 -2
- package/dist/{profiles-DRnFfVbj.js → profiles-8g-QHzaH.js} +2 -2
- package/dist/research-CsRfCMgE.js +1 -0
- package/dist/{response-language-Sn-WtY_I.js → response-language-BnJvZzdq.js} +1 -1
- package/dist/response-language-BspVHfZg.js +1 -0
- package/dist/{sentry-RGpmJbg4.js → sentry-hPhwSfRH.js} +1 -1
- package/dist/tag-management-CLGUfzO5.js +1 -0
- package/dist/{task-manager-BFgKqJGL.js → task-manager-BqPKod2q.js} +1 -1
- package/dist/task-master.js +1 -1
- package/dist/update-subtask-by-id-BJ6qzOVq.js +1 -0
- package/dist/update-task-by-id-5w9dOdGk.js +1 -0
- package/dist/{utils-BZ8Kv4nm.js → utils-ClsTocu1.js} +1 -1
- package/package.json +1 -1
- package/dist/ai-services-unified-BImUXDJx.js +0 -1
- package/dist/research-BYKGH4A5.js +0 -1
- package/dist/response-language-Dll9UAYo.js +0 -1
- package/dist/tag-management-BmWTtKzr.js +0 -1
- package/dist/update-subtask-by-id-hn-FpfWZ.js +0 -1
- package/dist/update-task-by-id-Df3tERy8.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./ai-services-unified-tvfkaOTr.js";import"./config-manager-Cm3z1HZv.js";import"./git-utils-DllbRE35.js";import"./sentry-hPhwSfRH.js";export{i as generateObjectService,n as generateTextService,r as logAiUsage,t as streamObjectService,e as streamTextService};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,Et as n,F as r,H as i,I as a,J as o,L as s,M as c,N as l,O as u,P as d,a as f,f as p,ht as m,j as h,l as g,m as _,o as ee,s as te,ut as v,v as y,w as b,x,y as S,yt as C}from"./config-manager-DofXOeM1.js";import{n as w,t as T}from"./sentry-RGpmJbg4.js";import{createRequire as E}from"node:module";import D,{promises as O}from"fs";import k,{join as A}from"path";import{homedir as j}from"os";import{execSync as M,spawn as N}from"child_process";import*as P from"ai";import{jsonrepair as F}from"jsonrepair";import{EnvHttpProxyAgent as I}from"undici";import{createAnthropic as ne}from"@ai-sdk/anthropic";import{createPerplexity as re}from"@ai-sdk/perplexity";import{createGoogleGenerativeAI as ie}from"@ai-sdk/google";import{createOpenAI as ae}from"@ai-sdk/openai";import{createXai as oe}from"@ai-sdk/xai";import{createGroq as se}from"@ai-sdk/groq";import{createOpenRouter as ce}from"@openrouter/ai-sdk-provider";import{createOllama as le}from"ollama-ai-provider-v2";import{createAmazonBedrock as ue}from"@ai-sdk/amazon-bedrock";import{fromNodeProviderChain as de}from"@aws-sdk/credential-providers";import{createAzure as fe}from"@ai-sdk/azure";import{createVertex as pe}from"@ai-sdk/google-vertex";import{createClaudeCode as me}from"ai-sdk-provider-claude-code";import{createGeminiProvider as he}from"ai-sdk-provider-gemini-cli";import{APICallError as L,LoadAPIKeyError as ge,NoSuchModelError as R}from"@ai-sdk/provider";import{generateId as z}from"@ai-sdk/provider-utils";import{parse as _e}from"jsonc-parser";import{createCodexCli as ve}from"ai-sdk-provider-codex-cli";import{createOpenAICompatible as ye}from"@ai-sdk/openai-compatible";var be=Object.defineProperty,xe=e=>{let t={};for(var n in e)be(t,n,{get:e[n],enumerable:!0});return t},B=E(import.meta.url);let V=null;var H=class e{constructor(){this._providers=new Map,this._initialized=!1}static getInstance(){return V||=new e,V}initialize(){return this._initialized||=!0,this}registerProvider(e,t,n={}){if(!e||typeof e!=`string`)throw Error(`Provider name must be a non-empty string`);if(!t)throw Error(`Provider instance is required`);if(typeof t.generateText!=`function`||typeof t.streamText!=`function`||typeof t.generateObject!=`function`)throw Error(`Provider must implement BaseAIProvider interface`);return this._providers.set(e,{instance:t,options:n,registeredAt:new Date}),this}hasProvider(e){return this._providers.has(e)}getProvider(e){let t=this._providers.get(e);return t?t.instance:null}getAllProviders(){return new Map(this._providers)}unregisterProvider(e){return this._providers.has(e)?(this._providers.delete(e),!0):!1}reset(){this._providers.clear(),this._initialized=!1}};H.getInstance().initialize();var U=H;const{JSONParseError:Se,NoObjectGeneratedError:Ce,generateObject:we,generateText:Te,streamObject:Ee,streamText:De,zodSchema:Oe}=P,W=P.jsonSchema,ke=new Set([`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`]),Ae=[`additionalProperties`,`contains`,`if`,`then`,`else`,`not`,`propertyNames`],je=[`allOf`,`anyOf`,`oneOf`,`prefixItems`],Me=[`definitions`,`$defs`,`dependentSchemas`,`patternProperties`,`properties`],Ne=e=>e?Array.isArray(e)?e.includes(`integer`):e===`integer`:!1,G=e=>{if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(G);let t={...e};if(Ne(t.type))for(let e of ke)e in t&&delete t[e];for(let e of Ae)t[e]&&(t[e]=G(t[e]));for(let e of je)Array.isArray(t[e])&&(t[e]=t[e].map(G));for(let e of Me)if(t[e]&&typeof t[e]==`object`){let n={};for(let[r,i]of Object.entries(t[e]))n[r]=G(i);t[e]=n}return t.items&&=G(t.items),t},K=e=>{if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(K);let t={};for(let[n,r]of Object.entries(e))t[n]=K(r);let n=t.type===`object`,r=t.properties&&typeof t.properties==`object`&&!Array.isArray(t.properties),i=Object.prototype.hasOwnProperty.call(t,`additionalProperties`),a=r?Object.keys(t.properties):[],o=Array.isArray(t.required),s=o?new Set(t.required):new Set,c=o&&a.every(e=>s.has(e))&&t.required.length===a.length;return n&&r&&!i&&(t.additionalProperties=!1),n&&r&&!c&&(t.required=a),t},q=e=>{let t=Oe(e);if(!t||typeof t!=`object`||!t.jsonSchema)return t;let n=K(G(t.jsonSchema));return typeof W==`function`?W(n,{validate:t.validate}):{...t,jsonSchema:n}};var J=class e{constructor(){if(this.constructor===e)throw Error(`BaseAIProvider cannot be instantiated directly`);this.name=this.constructor.name,this._proxyAgent=null,this.needsExplicitJsonSchema=!1,this.supportsTemperature=!0}validateAuth(e){if(!e.apiKey)throw Error(`${this.name} API key is required`)}createProxyFetch(){this._projectRoot||=v();let e=this._projectRoot;if(i(null,e))return this._proxyAgent||=new I,(e,t={})=>fetch(e,{...t,dispatcher:this._proxyAgent})}validateParams(e){if(this.validateAuth(e),!e.modelId)throw Error(`${this.name} Model ID is required`);this.validateOptionalParams(e)}validateOptionalParams(e){if(e.temperature!==void 0&&(e.temperature<0||e.temperature>1))throw Error(`Temperature must be between 0 and 1`);if(e.maxTokens!==void 0){let t=Number(e.maxTokens);if(!Number.isFinite(t)||t<=0)throw Error(`maxTokens must be a finite number greater than 0`)}}validateMessages(e){if(!e||!Array.isArray(e)||e.length===0)throw Error(`Invalid or empty messages array provided`);for(let t of e)if(!t.role||!t.content)throw Error(`Invalid message format. Each message must have role and content`)}handleError(e,t){let n=t.message||`Unknown error occurred`;throw C(`error`,`${this.name} ${e} failed: ${n}`,{error:t}),Error(`${this.name} API error during ${e}: ${n}`)}getClient(e){throw Error(`getClient must be implemented by provider`)}isRequiredApiKey(){return!0}getRequiredApiKeyName(){throw Error(`getRequiredApiKeyName must be implemented by provider`)}prepareTokenParam(e,t){return t===void 0?{}:{maxOutputTokens:Math.floor(Number(t))}}async generateText(e){try{this.validateParams(e),this.validateMessages(e.messages),C(`debug`,`Generating ${this.name} text with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.generateText`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=await Te({model:t(e.modelId),messages:e.messages,...this.prepareTokenParam(e.modelId,e.maxTokens),...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r}});C(`debug`,`${this.name} generateText completed successfully for model: ${e.modelId}`);let a=i.usage?.inputTokens??i.usage?.promptTokens??0,o=i.usage?.outputTokens??i.usage?.completionTokens??0,s=i.usage?.totalTokens??a+o;return{text:i.text,usage:{inputTokens:a,outputTokens:o,totalTokens:s}}}catch(e){this.handleError(`text generation`,e)}}async streamText(e){try{this.validateParams(e),this.validateMessages(e.messages),C(`debug`,`Streaming ${this.name} text with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.streamText`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=await De({model:t(e.modelId),messages:e.messages,...this.prepareTokenParam(e.modelId,e.maxTokens),...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r},...e.experimental_transform&&{experimental_transform:e.experimental_transform}});return C(`debug`,`${this.name} streamText initiated successfully for model: ${e.modelId}`),i}catch(e){this.handleError(`text streaming`,e)}}async streamObject(e){try{if(this.validateParams(e),this.validateMessages(e.messages),!e.schema)throw Error(`Schema is required for object streaming`);C(`debug`,`Streaming ${this.name} object with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.streamObject`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=q(e.schema),a=await Ee({model:t(e.modelId),messages:e.messages,schema:i,mode:e.mode||`auto`,maxOutputTokens:e.maxTokens,...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r}});return C(`debug`,`${this.name} streamObject initiated successfully for model: ${e.modelId}`),a}catch(e){this.handleError(`object streaming`,e)}}async generateObject(e){try{if(this.validateParams(e),this.validateMessages(e.messages),!e.schema)throw Error(`Schema is required for object generation`);if(!e.objectName)throw Error(`Object name is required for object generation`);C(`debug`,`Generating ${this.name} object ('${e.objectName}') with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.generateObject.${e.objectName}`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=q(e.schema),a=await we({model:t(e.modelId),messages:e.messages,schema:i,mode:this.needsExplicitJsonSchema?`json`:`auto`,schemaName:e.objectName,schemaDescription:`Generate a valid JSON object for ${e.objectName}`,maxTokens:e.maxTokens,...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r}});C(`debug`,`${this.name} generateObject completed successfully for model: ${e.modelId}`);let o=a.usage?.inputTokens??a.usage?.promptTokens??0,s=a.usage?.outputTokens??a.usage?.completionTokens??0,c=a.usage?.totalTokens??o+s;return{object:a.object,usage:{inputTokens:o,outputTokens:s,totalTokens:c}}}catch(e){if(Ce.isInstance(e)&&e.cause instanceof Se&&e.cause.text){C(`warn`,`${this.name} generated malformed JSON, attempting to repair...`);try{let t=F(e.cause.text),n=JSON.parse(t);return C(`info`,`Successfully repaired ${this.name} JSON output`),{object:n,usage:{inputTokens:e.usage?.promptTokens||e.usage?.inputTokens||0,outputTokens:e.usage?.completionTokens||e.usage?.outputTokens||0,totalTokens:e.usage?.totalTokens||0}}}catch(e){C(`error`,`Failed to repair ${this.name} JSON: ${e.message}`)}}this.handleError(`object generation`,e)}}},Pe=class extends J{constructor(){super(),this.name=`Anthropic`}getRequiredApiKeyName(){return`ANTHROPIC_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return ne({apiKey:t,...n&&{baseURL:n},headers:{"anthropic-beta":`output-128k-2025-02-19`},...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}},Fe=class extends J{constructor(){super(),this.name=`Perplexity`}getRequiredApiKeyName(){return`PERPLEXITY_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return re({apiKey:t,baseURL:n||`https://api.perplexity.ai`,...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}async generateObject(e){return super.generateObject({...e,mode:`json`})}},Ie=class extends J{constructor(){super(),this.name=`Google`}getRequiredApiKeyName(){return`GOOGLE_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return ie({apiKey:t,...n&&{baseURL:n},...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}},Le=class extends J{constructor(){super(),this.name=`OpenAI`}getRequiredApiKeyName(){return`OPENAI_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return ae({apiKey:t,...n&&{baseURL:n},...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}},Re=class extends J{constructor(){super(),this.name=`xAI`}getRequiredApiKeyName(){return`XAI_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e;return oe({apiKey:t,baseURL:n||`https://api.x.ai/v1`})}catch(e){this.handleError(`client initialization`,e)}}},ze=class extends J{constructor(){super(),this.name=`Groq`}getRequiredApiKeyName(){return`GROQ_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e;return se({apiKey:t,...n&&{baseURL:n}})}catch(e){this.handleError(`client initialization`,e)}}},Be=class extends J{constructor(){super(),this.name=`OpenRouter`}getRequiredApiKeyName(){return`OPENROUTER_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e;return ce({apiKey:t,...n&&{baseURL:n}})}catch(e){this.handleError(`client initialization`,e)}}},Ve=class extends J{constructor(){super(),this.name=`Ollama`}validateAuth(e){}getClient(e){try{let{baseURL:t}=e;return le({...t&&{baseURL:t}})}catch(e){this.handleError(`client initialization`,e)}}isRequiredApiKey(){return!1}getRequiredApiKeyName(){return`OLLAMA_API_KEY`}},He=class extends J{constructor(){super(),this.name=`Bedrock`}isRequiredApiKey(){return!1}getRequiredApiKeyName(){return`AWS_ACCESS_KEY_ID`}validateAuth(e){}getClient(e){try{let e=de(),t=this.createProxyFetch();return ue({credentialProvider:e,...t&&{fetch:t}})}catch(e){this.handleError(`client initialization`,e)}}},Ue=class extends J{constructor(){super(),this.name=`Azure OpenAI`}getRequiredApiKeyName(){return`AZURE_OPENAI_API_KEY`}validateAuth(e){if(!e.apiKey)throw Error(`Azure API key is required`);if(!e.baseURL)throw Error(`Azure endpoint URL is required. Set it in .taskmasterconfig global.azureBaseURL or models.[role].baseURL`)}normalizeBaseURL(e){if(!e)return e;try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return n.endsWith(`/openai`)||(n=`${n}/openai`),t.pathname=n,t.toString()}catch{let t=e.replace(/\/+$/,``);return t.endsWith(`/openai`)?t:`${t}/openai`}}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.normalizeBaseURL(n),i=this.createProxyFetch();return fe({apiKey:t,baseURL:r,...i&&{fetch:i}})}catch(e){this.handleError(`client initialization`,e)}}},Y=class extends Error{constructor(e){super(e),this.name=`VertexAuthError`,this.code=`vertex_auth_error`}},X=class extends Error{constructor(e){super(e),this.name=`VertexConfigError`,this.code=`vertex_config_error`}},We=class extends Error{constructor(e,t){super(e),this.name=`VertexApiError`,this.code=`vertex_api_error`,this.statusCode=t}},Ge=class extends J{constructor(){super(),this.name=`Google Vertex AI`}getRequiredApiKeyName(){return`GOOGLE_API_KEY`}isRequiredApiKey(){return!1}isAuthenticationRequired(){return!0}isValidCredential(e){return e?typeof e==`string`?e.trim().length>0:typeof e==`object`:!1}validateAuth(e){let{apiKey:t,projectId:n,location:r,credentials:i}=e,a=this.isValidCredential(t),o=this.isValidCredential(i);if(!a&&!o)throw new Y(`Vertex AI requires authentication. Provide one of the following:
|
|
1
|
+
import{C as e,E as t,Et as n,F as r,H as i,I as a,J as o,L as s,M as c,N as l,O as u,P as d,a as f,f as p,ht as m,j as h,l as g,m as _,o as ee,s as te,ut as v,v as y,w as b,x,y as S,yt as C}from"./config-manager-Cm3z1HZv.js";import{n as w,t as T}from"./sentry-hPhwSfRH.js";import{createRequire as E}from"node:module";import D,{promises as O}from"fs";import k,{join as A}from"path";import{homedir as j}from"os";import{execSync as M,spawn as N}from"child_process";import*as P from"ai";import{jsonrepair as F}from"jsonrepair";import{EnvHttpProxyAgent as I}from"undici";import{createAnthropic as ne}from"@ai-sdk/anthropic";import{createPerplexity as re}from"@ai-sdk/perplexity";import{createGoogleGenerativeAI as ie}from"@ai-sdk/google";import{createOpenAI as ae}from"@ai-sdk/openai";import{createXai as oe}from"@ai-sdk/xai";import{createGroq as se}from"@ai-sdk/groq";import{createOpenRouter as ce}from"@openrouter/ai-sdk-provider";import{createOllama as le}from"ollama-ai-provider-v2";import{createAmazonBedrock as ue}from"@ai-sdk/amazon-bedrock";import{fromNodeProviderChain as de}from"@aws-sdk/credential-providers";import{createAzure as fe}from"@ai-sdk/azure";import{createVertex as pe}from"@ai-sdk/google-vertex";import{createClaudeCode as me}from"ai-sdk-provider-claude-code";import{createGeminiProvider as he}from"ai-sdk-provider-gemini-cli";import{APICallError as L,LoadAPIKeyError as ge,NoSuchModelError as R}from"@ai-sdk/provider";import{generateId as z}from"@ai-sdk/provider-utils";import{parse as _e}from"jsonc-parser";import{createCodexCli as ve}from"ai-sdk-provider-codex-cli";import{createOpenAICompatible as ye}from"@ai-sdk/openai-compatible";var be=Object.defineProperty,xe=e=>{let t={};for(var n in e)be(t,n,{get:e[n],enumerable:!0});return t},B=E(import.meta.url);let V=null;var H=class e{constructor(){this._providers=new Map,this._initialized=!1}static getInstance(){return V||=new e,V}initialize(){return this._initialized||=!0,this}registerProvider(e,t,n={}){if(!e||typeof e!=`string`)throw Error(`Provider name must be a non-empty string`);if(!t)throw Error(`Provider instance is required`);if(typeof t.generateText!=`function`||typeof t.streamText!=`function`||typeof t.generateObject!=`function`)throw Error(`Provider must implement BaseAIProvider interface`);return this._providers.set(e,{instance:t,options:n,registeredAt:new Date}),this}hasProvider(e){return this._providers.has(e)}getProvider(e){let t=this._providers.get(e);return t?t.instance:null}getAllProviders(){return new Map(this._providers)}unregisterProvider(e){return this._providers.has(e)?(this._providers.delete(e),!0):!1}reset(){this._providers.clear(),this._initialized=!1}};H.getInstance().initialize();var U=H;const{JSONParseError:Se,NoObjectGeneratedError:Ce,generateObject:we,generateText:Te,streamObject:Ee,streamText:De,zodSchema:Oe}=P,W=P.jsonSchema,ke=new Set([`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`]),Ae=[`additionalProperties`,`contains`,`if`,`then`,`else`,`not`,`propertyNames`],je=[`allOf`,`anyOf`,`oneOf`,`prefixItems`],Me=[`definitions`,`$defs`,`dependentSchemas`,`patternProperties`,`properties`],Ne=e=>e?Array.isArray(e)?e.includes(`integer`):e===`integer`:!1,G=e=>{if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(G);let t={...e};if(Ne(t.type))for(let e of ke)e in t&&delete t[e];for(let e of Ae)t[e]&&(t[e]=G(t[e]));for(let e of je)Array.isArray(t[e])&&(t[e]=t[e].map(G));for(let e of Me)if(t[e]&&typeof t[e]==`object`){let n={};for(let[r,i]of Object.entries(t[e]))n[r]=G(i);t[e]=n}return t.items&&=G(t.items),t},K=e=>{if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(K);let t={};for(let[n,r]of Object.entries(e))t[n]=K(r);let n=t.type===`object`,r=t.properties&&typeof t.properties==`object`&&!Array.isArray(t.properties),i=Object.prototype.hasOwnProperty.call(t,`additionalProperties`),a=r?Object.keys(t.properties):[],o=Array.isArray(t.required),s=o?new Set(t.required):new Set,c=o&&a.every(e=>s.has(e))&&t.required.length===a.length;return n&&r&&!i&&(t.additionalProperties=!1),n&&r&&!c&&(t.required=a),t},q=e=>{let t=Oe(e);if(!t||typeof t!=`object`||!t.jsonSchema)return t;let n=K(G(t.jsonSchema));return typeof W==`function`?W(n,{validate:t.validate}):{...t,jsonSchema:n}};var J=class e{constructor(){if(this.constructor===e)throw Error(`BaseAIProvider cannot be instantiated directly`);this.name=this.constructor.name,this._proxyAgent=null,this.needsExplicitJsonSchema=!1,this.supportsTemperature=!0}validateAuth(e){if(!e.apiKey)throw Error(`${this.name} API key is required`)}createProxyFetch(){this._projectRoot||=v();let e=this._projectRoot;if(i(null,e))return this._proxyAgent||=new I,(e,t={})=>fetch(e,{...t,dispatcher:this._proxyAgent})}validateParams(e){if(this.validateAuth(e),!e.modelId)throw Error(`${this.name} Model ID is required`);this.validateOptionalParams(e)}validateOptionalParams(e){if(e.temperature!==void 0&&(e.temperature<0||e.temperature>1))throw Error(`Temperature must be between 0 and 1`);if(e.maxTokens!==void 0){let t=Number(e.maxTokens);if(!Number.isFinite(t)||t<=0)throw Error(`maxTokens must be a finite number greater than 0`)}}validateMessages(e){if(!e||!Array.isArray(e)||e.length===0)throw Error(`Invalid or empty messages array provided`);for(let t of e)if(!t.role||!t.content)throw Error(`Invalid message format. Each message must have role and content`)}handleError(e,t){let n=t.message||`Unknown error occurred`;throw C(`error`,`${this.name} ${e} failed: ${n}`,{error:t}),Error(`${this.name} API error during ${e}: ${n}`)}getClient(e){throw Error(`getClient must be implemented by provider`)}isRequiredApiKey(){return!0}getRequiredApiKeyName(){throw Error(`getRequiredApiKeyName must be implemented by provider`)}prepareTokenParam(e,t){return t===void 0?{}:{maxOutputTokens:Math.floor(Number(t))}}async generateText(e){try{this.validateParams(e),this.validateMessages(e.messages),C(`debug`,`Generating ${this.name} text with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.generateText`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=await Te({model:t(e.modelId),messages:e.messages,...this.prepareTokenParam(e.modelId,e.maxTokens),...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r}});C(`debug`,`${this.name} generateText completed successfully for model: ${e.modelId}`);let a=i.usage?.inputTokens??i.usage?.promptTokens??0,o=i.usage?.outputTokens??i.usage?.completionTokens??0,s=i.usage?.totalTokens??a+o;return{text:i.text,usage:{inputTokens:a,outputTokens:o,totalTokens:s}}}catch(e){this.handleError(`text generation`,e)}}async streamText(e){try{this.validateParams(e),this.validateMessages(e.messages),C(`debug`,`Streaming ${this.name} text with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.streamText`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=await De({model:t(e.modelId),messages:e.messages,...this.prepareTokenParam(e.modelId,e.maxTokens),...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r},...e.experimental_transform&&{experimental_transform:e.experimental_transform}});return C(`debug`,`${this.name} streamText initiated successfully for model: ${e.modelId}`),i}catch(e){this.handleError(`text streaming`,e)}}async streamObject(e){try{if(this.validateParams(e),this.validateMessages(e.messages),!e.schema)throw Error(`Schema is required for object streaming`);C(`debug`,`Streaming ${this.name} object with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.streamObject`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=q(e.schema),a=await Ee({model:t(e.modelId),messages:e.messages,schema:i,mode:e.mode||`auto`,maxOutputTokens:e.maxTokens,...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r}});return C(`debug`,`${this.name} streamObject initiated successfully for model: ${e.modelId}`),a}catch(e){this.handleError(`object streaming`,e)}}async generateObject(e){try{if(this.validateParams(e),this.validateMessages(e.messages),!e.schema)throw Error(`Schema is required for object generation`);if(!e.objectName)throw Error(`Object name is required for object generation`);C(`debug`,`Generating ${this.name} object ('${e.objectName}') with model: ${e.modelId}`);let t=await this.getClient(e),n=e.commandName||`unknown`,r=T(`${this.name}.${e.modelId}.${n}.generateObject.${e.objectName}`,{command:n,outputType:e.outputType,tag:e.tag,projectHash:w(e.projectRoot),userId:e.userId,briefId:e.briefId}),i=q(e.schema),a=await we({model:t(e.modelId),messages:e.messages,schema:i,mode:this.needsExplicitJsonSchema?`json`:`auto`,schemaName:e.objectName,schemaDescription:`Generate a valid JSON object for ${e.objectName}`,maxTokens:e.maxTokens,...this.supportsTemperature&&e.temperature!==void 0?{temperature:e.temperature}:{},...r&&{experimental_telemetry:r}});C(`debug`,`${this.name} generateObject completed successfully for model: ${e.modelId}`);let o=a.usage?.inputTokens??a.usage?.promptTokens??0,s=a.usage?.outputTokens??a.usage?.completionTokens??0,c=a.usage?.totalTokens??o+s;return{object:a.object,usage:{inputTokens:o,outputTokens:s,totalTokens:c}}}catch(e){if(Ce.isInstance(e)&&e.cause instanceof Se&&e.cause.text){C(`warn`,`${this.name} generated malformed JSON, attempting to repair...`);try{let t=F(e.cause.text),n=JSON.parse(t);return C(`info`,`Successfully repaired ${this.name} JSON output`),{object:n,usage:{inputTokens:e.usage?.promptTokens||e.usage?.inputTokens||0,outputTokens:e.usage?.completionTokens||e.usage?.outputTokens||0,totalTokens:e.usage?.totalTokens||0}}}catch(e){C(`error`,`Failed to repair ${this.name} JSON: ${e.message}`)}}this.handleError(`object generation`,e)}}},Pe=class extends J{constructor(){super(),this.name=`Anthropic`}getRequiredApiKeyName(){return`ANTHROPIC_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return ne({apiKey:t,...n&&{baseURL:n},headers:{"anthropic-beta":`output-128k-2025-02-19`},...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}},Fe=class extends J{constructor(){super(),this.name=`Perplexity`}getRequiredApiKeyName(){return`PERPLEXITY_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return re({apiKey:t,baseURL:n||`https://api.perplexity.ai`,...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}async generateObject(e){return super.generateObject({...e,mode:`json`})}},Ie=class extends J{constructor(){super(),this.name=`Google`}getRequiredApiKeyName(){return`GOOGLE_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return ie({apiKey:t,...n&&{baseURL:n},...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}},Le=class extends J{constructor(){super(),this.name=`OpenAI`}getRequiredApiKeyName(){return`OPENAI_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.createProxyFetch();return ae({apiKey:t,...n&&{baseURL:n},...r&&{fetch:r}})}catch(e){this.handleError(`client initialization`,e)}}},Re=class extends J{constructor(){super(),this.name=`xAI`}getRequiredApiKeyName(){return`XAI_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e;return oe({apiKey:t,baseURL:n||`https://api.x.ai/v1`})}catch(e){this.handleError(`client initialization`,e)}}},ze=class extends J{constructor(){super(),this.name=`Groq`}getRequiredApiKeyName(){return`GROQ_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e;return se({apiKey:t,...n&&{baseURL:n}})}catch(e){this.handleError(`client initialization`,e)}}},Be=class extends J{constructor(){super(),this.name=`OpenRouter`}getRequiredApiKeyName(){return`OPENROUTER_API_KEY`}getClient(e){try{let{apiKey:t,baseURL:n}=e;return ce({apiKey:t,...n&&{baseURL:n}})}catch(e){this.handleError(`client initialization`,e)}}},Ve=class extends J{constructor(){super(),this.name=`Ollama`}validateAuth(e){}getClient(e){try{let{baseURL:t}=e;return le({...t&&{baseURL:t}})}catch(e){this.handleError(`client initialization`,e)}}isRequiredApiKey(){return!1}getRequiredApiKeyName(){return`OLLAMA_API_KEY`}},He=class extends J{constructor(){super(),this.name=`Bedrock`}isRequiredApiKey(){return!1}getRequiredApiKeyName(){return`AWS_ACCESS_KEY_ID`}validateAuth(e){}getClient(e){try{let e=de(),t=this.createProxyFetch();return ue({credentialProvider:e,...t&&{fetch:t}})}catch(e){this.handleError(`client initialization`,e)}}},Ue=class extends J{constructor(){super(),this.name=`Azure OpenAI`}getRequiredApiKeyName(){return`AZURE_OPENAI_API_KEY`}validateAuth(e){if(!e.apiKey)throw Error(`Azure API key is required`);if(!e.baseURL)throw Error(`Azure endpoint URL is required. Set it in .taskmasterconfig global.azureBaseURL or models.[role].baseURL`)}normalizeBaseURL(e){if(!e)return e;try{let t=new URL(e),n=t.pathname.replace(/\/+$/,``);return n.endsWith(`/openai`)||(n=`${n}/openai`),t.pathname=n,t.toString()}catch{let t=e.replace(/\/+$/,``);return t.endsWith(`/openai`)?t:`${t}/openai`}}getClient(e){try{let{apiKey:t,baseURL:n}=e,r=this.normalizeBaseURL(n),i=this.createProxyFetch();return fe({apiKey:t,baseURL:r,...i&&{fetch:i}})}catch(e){this.handleError(`client initialization`,e)}}},Y=class extends Error{constructor(e){super(e),this.name=`VertexAuthError`,this.code=`vertex_auth_error`}},X=class extends Error{constructor(e){super(e),this.name=`VertexConfigError`,this.code=`vertex_config_error`}},We=class extends Error{constructor(e,t){super(e),this.name=`VertexApiError`,this.code=`vertex_api_error`,this.statusCode=t}},Ge=class extends J{constructor(){super(),this.name=`Google Vertex AI`}getRequiredApiKeyName(){return`GOOGLE_API_KEY`}isRequiredApiKey(){return!1}isAuthenticationRequired(){return!0}isValidCredential(e){return e?typeof e==`string`?e.trim().length>0:typeof e==`object`:!1}validateAuth(e){let{apiKey:t,projectId:n,location:r,credentials:i}=e,a=this.isValidCredential(t),o=this.isValidCredential(i);if(!a&&!o)throw new Y(`Vertex AI requires authentication. Provide one of the following:
|
|
2
2
|
• GOOGLE_API_KEY environment variable (typical for API-based auth), OR
|
|
3
3
|
• GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON file (recommended for production)`);if(!n||typeof n==`string`&&n.trim().length===0)throw new X(`Google Cloud project ID is required for Vertex AI. Set VERTEX_PROJECT_ID environment variable.`);if(!r||typeof r==`string`&&r.trim().length===0)throw new X(`Google Cloud location is required for Vertex AI. Set VERTEX_LOCATION environment variable (e.g., "us-central1").`)}getClient(e){try{let{apiKey:t,projectId:n,location:r,credentials:i,baseURL:a}=e,o=this.createProxyFetch(),s={};return t?s.googleAuthOptions={...i,apiKey:t}:i&&(s.googleAuthOptions=i),pe({...s,project:n,location:r,...a&&{baseURL:a},...o&&{fetch:o}})}catch(e){this.handleError(`client initialization`,e)}}handleError(e,t){if(C(`error`,`Vertex AI ${e} error:`,t),t.name===`VertexAuthError`||t.name===`VertexConfigError`||t.name===`VertexApiError`)throw t;if(t.response){let e=t.response.status,n=t.response.data?.error?.message||t.message;throw e===401||e===403?new Y(`Authentication failed: ${n}`):e===400?new X(`Invalid request: ${n}`):new We(`API error (${e}): ${n}`,e)}throw Error(`Vertex AI ${e} failed: ${t.message}`)}};let Ke=!1;var qe=class extends J{constructor(){super(),this.name=`Claude Code`,this.supportedModels=d(`claude-code`),this.supportedModels.length===0&&C(`warn`,`No supported models found for claude-code provider. Check supported-models.json configuration.`),this.needsExplicitJsonSchema=!0,this.supportsTemperature=!1}getRequiredApiKeyName(){return`CLAUDE_CODE_API_KEY`}isRequiredApiKey(){return!1}validateAuth(e){if(process.env.NODE_ENV!==`test`&&!Ke&&!process.env.CLAUDE_CODE_OAUTH_TOKEN)try{M(`claude --version`,{stdio:`pipe`,timeout:1e3})}catch{C(`warn`,`Claude Code CLI not detected. Install it with: npm install -g @anthropic-ai/claude-code`)}finally{Ke=!0}}getClient(e={}){try{let t=g(e.commandName)||{},n=process.env.ANTHROPIC_API_KEY,r=process.env.CLAUDE_CODE_API_KEY;try{return r?process.env.ANTHROPIC_API_KEY=r:n&&delete process.env.ANTHROPIC_API_KEY,me({defaultSettings:{systemPrompt:{type:`preset`,preset:`claude_code`},settingSources:[`user`,`project`,`local`],...t}})}finally{n?process.env.ANTHROPIC_API_KEY=n:delete process.env.ANTHROPIC_API_KEY}}catch(e){let t=String(e?.message||``);if(e?.code===`ENOENT`||/claude/i.test(t)){let t=Error(`Claude Code CLI not available. Please install Claude Code CLI first. Original error: ${e.message}`);t.cause=e,this.handleError(`Claude Code CLI initialization`,t)}else this.handleError(`client initialization`,e)}}getSupportedModels(){return this.supportedModels}isModelSupported(e){return e?this.supportedModels.includes(String(e).toLowerCase()):!1}},Je=class extends J{constructor(){super(),this.name=`Gemini CLI`,this.supportsTemperature=!1}validateAuth(e){}async getClient(e){try{let t={};return t=e.apiKey&&e.apiKey!==`gemini-cli-no-key-required`?{authType:`api-key`,apiKey:e.apiKey}:{authType:`oauth-personal`},e.baseURL&&(t.baseURL=e.baseURL),he(t)}catch(e){this.handleError(`client initialization`,e)}}getRequiredApiKeyName(){return`GEMINI_API_KEY`}isRequiredApiKey(){return!1}};function Z({message:e,code:t,exitCode:n,stderr:r,stdout:i,promptExcerpt:a,isRetryable:o=!1}){return new L({message:e,isRetryable:o,url:`grok-cli://command`,requestBodyValues:a?{prompt:a}:void 0,data:{code:t,exitCode:n,stderr:r,stdout:i,promptExcerpt:a}})}function Ye({message:e}){return new ge({message:e||`Authentication failed. Please ensure Grok CLI is properly configured with API key.`})}function Xe({message:e,promptExcerpt:t,timeoutMs:n}){return new L({message:e,isRetryable:!0,url:`grok-cli://command`,requestBodyValues:t?{prompt:t}:void 0,data:{code:`TIMEOUT`,promptExcerpt:t,timeoutMs:n}})}function Ze({message:e}){return new L({message:e||`Grok CLI is not installed or not found in PATH. Please install with: npm install -g @vibe-kit/grok-cli`,isRetryable:!1,url:`grok-cli://installation`,requestBodyValues:void 0})}function Qe(e){let t=e.trim(),n=/```(?:json)?\s*([\s\S]*?)\s*```/i.exec(t);n&&(t=n[1]);let r=/^\s*(?:const|let|var)\s+\w+\s*=\s*([\s\S]*)/i.exec(t);r&&(t=r[1],t.trim().endsWith(`;`)&&(t=t.trim().slice(0,-1)));let i=t.indexOf(`{`),a=t.indexOf(`[`);if(i===-1&&a===-1)return e;let o=a===-1?i:i===-1?a:Math.min(i,a);t=t.slice(o);let s=e=>{let t=[];try{let n=_e(e,t,{allowTrailingComma:!0});if(t.length===0)return JSON.stringify(n,null,2)}catch{}},c=s(t);if(c!==void 0)return c;let l=t[0],u=l===`{`?`}`:`]`,d=[],f=0,p=!1,m=!1;for(let e=0;e<t.length;e++){let n=t[e];if(m){m=!1;continue}if(n===`\\`){m=!0;continue}if(n===`"`&&!p){p=!0;continue}if(n===`"`&&p){p=!1;continue}p||(n===l?f++:n===u&&(f--,f===0&&d.push(e+1)))}for(let e=d.length-1;e>=0;e--){let n=s(t.slice(0,d[e]));if(n!==void 0)return n}let h=Math.max(0,t.length-1e3);for(let e=t.length-1;e>h;e--){let n=s(t.slice(0,e));if(n!==void 0)return n}return e}function $e(e){return e.map(e=>{let t=``;return typeof e.content==`string`?t=e.content:Array.isArray(e.content)?t=e.content.filter(e=>e.type===`text`).map(e=>e.text||``).join(`
|
|
4
4
|
`):e.content&&typeof e.content==`object`&&(t=e.content.text||JSON.stringify(e.content)),{role:e.role,content:t.trim()}})}function et(e){try{let t=e.trim().split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./ai-services-unified-
|
|
1
|
+
import"./ai-services-unified-tvfkaOTr.js";import{B as e,Bt as t,D as n,Ht as r,Kt as i,Lt as a,Nt as o,On as s,Q as c,Rt as l,Tt as u,U as d,Ut as f,Vt as p,dt as m,h,hn as g,ln as ee,m as _,mn as te,p as v,t as y,ut as ne,yt as b,z as x}from"./config-manager-Cm3z1HZv.js";import"./git-utils-DllbRE35.js";import"./sentry-hPhwSfRH.js";import{$ as S,C,D as w,F as T,I as E,J as re,L as ie,M as ae,N as oe,O as se,P as ce,Q as le,S as ue,St as de,X as D,Y as fe,Z as pe,_ as me,_t as he,a as ge,at as O,b as _e,bt as ve,c as ye,ct as be,d as k,dt as xe,et as A,f as Se,g as Ce,h as we,ht as Te,i as Ee,it as De,j as Oe,k as j,l as ke,m as Ae,n as je,nt as Me,o as Ne,ot as Pe,p as M,r as Fe,rt as Ie,s as Le,st as Re,t as ze,tt as Be,u as Ve,ut as He,v as N,vt as Ue,w as We,wt as Ge,xt as Ke,y as qe,yt as Je}from"./dependency-manager-w4WB-z27.js";import{t as Ye}from"./response-language-BnJvZzdq.js";import{_ as Xe,a as Ze,c as Qe,d as $e,f as et,g as tt,h as nt,i as rt,l as P,m as it,n as at,o as F,p as ot,r as st,s as I,t as L,u as R,v as z}from"./profiles-8g-QHzaH.js";import B from"chalk";import V from"fs";import H from"path";import U from"boxen";import{Command as ct}from"commander";import W from"inquirer";const G={AUTHENTICATION:`authentication`,VALIDATION:`validation`,NETWORK:`network`,API:`api`,FILE_SYSTEM:`file_system`,TASK:`task`,PERMISSION:`permission`,TIMEOUT:`timeout`,GENERIC:`generic`},lt=[/\b[A-Za-z0-9_-]{20,}\b/g,/sk-[A-Za-z0-9]{32,}/g,/api[_-]?key[:\s=]+[^\s]+/gi,/bearer\s+[^\s]+/gi,/token[:\s=]+[^\s]+/gi,/\/Users\/[^/]+/g,/C:\\Users\\[^\\]+/g,/\/home\/[^/]+/g,/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,/https?:\/\/[^:]+:[^@]+@/g];function K(e){if(!e||typeof e!=`string`)return e;let t=e;for(let e of lt)t=t.replace(e,`***REDACTED***`);return t}function ut(e){if(!e)return G.GENERIC;let t=(e.message||``).toLowerCase(),n=(e.code||``).toLowerCase();return t.includes(`auth`)||t.includes(`unauthorized`)||t.includes(`forbidden`)||t.includes(`api key`)||t.includes(`token`)||n.includes(`auth`)?G.AUTHENTICATION:t.includes(`invalid`)||t.includes(`validation`)||t.includes(`required`)||t.includes(`must be`)||n.includes(`validation`)?G.VALIDATION:t.includes(`network`)||t.includes(`connection`)||t.includes(`econnrefused`)||t.includes(`enotfound`)||n.includes(`network`)||n.includes(`econnrefused`)||n.includes(`enotfound`)?G.NETWORK:t.includes(`timeout`)||t.includes(`timed out`)||n.includes(`timeout`)?G.TIMEOUT:t.includes(`api`)||t.includes(`rate limit`)||t.includes(`quota`)||n.includes(`api`)?G.API:t.includes(`enoent`)||t.includes(`eacces`)||t.includes(`file`)||t.includes(`directory`)||n.includes(`enoent`)||n.includes(`eacces`)?G.FILE_SYSTEM:t.includes(`permission`)||t.includes(`access denied`)||n.includes(`eperm`)?G.PERMISSION:t.includes(`task`)||t.includes(`subtask`)?G.TASK:G.GENERIC}function dt(e,t,n){let r=[],i=(t.message||``).toLowerCase();switch(e){case G.AUTHENTICATION:i.includes(`api key`)?(r.push(`Check that your API key is correctly set in the .env file`),r.push(`Verify the API key has not expired or been revoked`)):i.includes(`token`)?(r.push(`Your authentication token may have expired`),r.push(`Try running: tm auth refresh`)):(r.push(`Verify your credentials are correctly configured`),r.push(`Check the authentication status with: tm auth status`));break;case G.VALIDATION:i.includes(`brief id`)?(r.push(`Brief IDs are case-insensitive (e.g., "ham32" = "HAM-32")`),r.push(`Check the brief ID format: usually LETTERS-NUMBERS`)):i.includes(`task id`)||i.includes(`invalid id`)?(r.push(`Task IDs should be numbers (e.g., 1, 2, 3)`),r.push(`Subtask IDs use dot notation (e.g., 1.1, 2.3)`)):(r.push(`Check that all required parameters are provided`),r.push(`Verify parameter values match expected formats`));break;case G.NETWORK:i.includes(`econnrefused`)?(r.push(`Could not connect to the server`),r.push(`Check your internet connection`),r.push(`Verify the API endpoint URL is correct`)):i.includes(`enotfound`)?(r.push(`Could not resolve the server hostname`),r.push(`Check your internet connection`)):(r.push(`Check your network connection`),r.push(`Verify firewall settings are not blocking the request`));break;case G.TIMEOUT:r.push(`The operation took too long to complete`),r.push(`Try again with a simpler request`),r.push(`Check your network speed and stability`);break;case G.API:i.includes(`rate limit`)?(r.push(`You have exceeded the API rate limit`),r.push(`Wait a few minutes before trying again`)):i.includes(`quota`)?(r.push(`You have reached your API quota`),r.push(`Check your account usage and limits`)):(r.push(`The API returned an error`),r.push(`Try again in a few moments`));break;case G.FILE_SYSTEM:i.includes(`enoent`)?(r.push(`The specified file or directory does not exist`),r.push(`Check the file path and ensure it is correct`),n.includes(`tasks.json`)&&r.push(`Initialize the project with: tm init`)):i.includes(`eacces`)?(r.push(`Permission denied to access the file`),r.push(`Check file permissions or run with appropriate privileges`)):r.push(`Check that the file or directory exists and is accessible`);break;case G.PERMISSION:r.push(`You do not have permission to perform this operation`),r.push(`Check file/directory permissions`),r.push(`You may need elevated privileges (sudo)`);break;case G.TASK:i.includes(`not found`)?(r.push(`The specified task does not exist`),r.push(`Use: tm list to see all available tasks`)):i.includes(`dependency`)||i.includes(`circular`)?(r.push(`Task dependencies form a circular reference`),r.push(`Use: tm validate-dependencies to identify issues`)):(r.push(`Check that the task ID is correct`),r.push(`Use: tm show <id> to view task details`));break;default:r.push(`Check the error message for specific details`),n&&r.push(`Operation failed while: ${n}`)}return r.slice(0,2)}function ft(e,t={}){let{context:n=``,debug:r=!1,command:i=``}=t;typeof e==`string`&&(e=Error(e)),(!e||typeof e!=`object`)&&(e=Error(`An unknown error occurred`));let a=K(e.message||`Unknown error`),o=ut(e),s=dt(o,e,n);return{type:o,message:a,context:n||`Unknown operation`,hints:s,command:i||null,code:e.code||null,stack:r?K(e.stack):null}}function q(e,t={}){let n=ft(e,t),r=B.red.bold(`✗ Error
|
|
2
2
|
|
|
3
3
|
`);r+=B.white(n.message)+`
|
|
4
4
|
|
|
@@ -103,7 +103,7 @@ Subtask update was not completed. Review the messages above for details.`))}catc
|
|
|
103
103
|
To fix this issue:`)),console.log(` 1. Run task-master list --with-subtasks to see all available subtask IDs`),console.log(` 2. Use a valid subtask ID with the --id parameter in format "parentId.subtaskId"`)):e.message.includes(`API key`)&&console.log(B.yellow(`
|
|
104
104
|
This error is related to API keys. Check your environment variables.`)),_()&&console.error(e),process.exit(1)}}),t.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=J({tasksPath:e.file||!0,tag:e.tag}),n=t.getTasksPath(),r=t.getCurrentTag();await k(r),e.id||(console.error(B.red(`Error: --id parameter is required`)),console.log(B.yellow(`Usage example: task-master 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(B.red(`Error: Invalid task ID: ${e.trim()}`)),process.exit(1)),t});j(e.strength)||(console.error(B.red(`Error: Invalid strength level: ${e.strength}. Must be one of: light, regular, heavy`)),process.exit(1)),V.existsSync(n)||(console.error(B.red(`Error: Tasks file not found at path: ${n}`)),process.exit(1)),console.log(B.blue(`Scoping up ${i.length} task(s): ${i.join(`, `)}`)),console.log(B.blue(`Strength level: ${e.strength}`)),e.prompt&&console.log(B.blue(`Custom instructions: ${e.prompt}`));let a={projectRoot:t.getProjectRoot(),tag:r,commandName:`scope-up`,outputType:`cli`,research:e.research||!1},o=await se(n,i,e.strength,e.prompt||null,a,`text`);console.log(B.green(`✅ Successfully scoped up ${o.updatedTasks.length} task(s)`))}catch(e){console.error(B.red(`Error: ${e.message}`)),e.message.includes(`not found`)&&(console.log(B.yellow(`
|
|
105
105
|
To fix this issue:`)),console.log(` 1. Run task-master list to see all available task IDs`),console.log(` 2. Use valid task IDs with the --id parameter`)),_()&&console.error(e),process.exit(1)}}),t.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=J({tasksPath:e.file||!0,tag:e.tag}),n=t.getTasksPath(),r=t.getCurrentTag();await k(r),e.id||(console.error(B.red(`Error: --id parameter is required`)),console.log(B.yellow(`Usage example: task-master 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(B.red(`Error: Invalid task ID: ${e.trim()}`)),process.exit(1)),t});j(e.strength)||(console.error(B.red(`Error: Invalid strength level: ${e.strength}. Must be one of: light, regular, heavy`)),process.exit(1)),V.existsSync(n)||(console.error(B.red(`Error: Tasks file not found at path: ${n}`)),process.exit(1)),console.log(B.blue(`Scoping down ${i.length} task(s): ${i.join(`, `)}`)),console.log(B.blue(`Strength level: ${e.strength}`)),e.prompt&&console.log(B.blue(`Custom instructions: ${e.prompt}`));let a={projectRoot:t.getProjectRoot(),tag:r,commandName:`scope-down`,outputType:`cli`,research:e.research||!1},o=await w(n,i,e.strength,e.prompt||null,a,`text`);console.log(B.green(`✅ Successfully scoped down ${o.updatedTasks.length} task(s)`))}catch(e){console.error(B.red(`Error: ${e.message}`)),e.message.includes(`not found`)&&(console.log(B.yellow(`
|
|
106
|
-
To fix this issue:`)),console.log(` 1. Run task-master list to see all available task IDs`),console.log(` 2. Use valid task IDs with the --id parameter`)),_()&&console.error(e),process.exit(1)}}),Pe(t),t.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 (e.g., using Perplexity)`,!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(`-cr, --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 n={tasksPath:e.file||!0,tag:e.tag};e.complexityReport&&(n.complexityReportPath=e.complexityReport);let r=J(n),i=r.getCurrentTag();if(await k(i),e.all){console.log(B.blue(`Expanding all pending tasks...`));try{await re(r.getTasksPath(),e.num,e.research,e.prompt,e.force,{projectRoot:r.getProjectRoot(),tag:i,complexityReportPath:r.getComplexityReportPath()})}catch(e){console.error(B.red(`Error expanding all tasks: ${e.message}`)),process.exit(1)}}else if(e.id){e.id||(console.error(B.red(`Error: Task ID is required unless using --all.`)),process.exit(1)),console.log(B.blue(`Expanding task ${e.id}...`));try{await fe(r.getTasksPath(),e.id,e.num,e.research,e.prompt,{projectRoot:r.getProjectRoot(),tag:i,complexityReportPath:r.getComplexityReportPath()},e.force)}catch(t){console.error(B.red(`Error expanding task ${e.id}: ${t.message}`)),process.exit(1)}}else console.error(B.red(`Error: You must specify either a task ID (--id) or --all.`)),t.help()}),t.command(`analyze-complexity`).description(`Analyze tasks and generate expansion recommendations${B.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=J(t);e.model,parseFloat(e.threshold);let r=e.research||!1,i=n.getCurrentTag();await k(i);let a=n.getComplexityReportPath();if(console.log(B.blue(`Analyzing task complexity from: ${n.getTasksPath()}`)),console.log(B.blue(`Output report will be saved to: ${a}`)),e.id)console.log(B.blue(`Analyzing specific task IDs: ${e.id}`));else if(e.from||e.to){let t=e.from?e.from:`first`,n=e.to?e.to:`last`;console.log(B.blue(`Analyzing tasks in range: ${t} to ${n}`))}r&&console.log(B.blue(`Using Perplexity AI for research-backed complexity analysis`)),await pe({...e,output:a,tag:i,projectRoot:n.getProjectRoot(),file:n.getTasksPath()})}),t.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 research results to the specified task/subtask(s)`).option(`-d, --detail <level>`,`Output detail level: low, medium, high`,`medium`).option(`--save-to <id>`,`Automatically save research results to specified task/subtask ID (e.g., "15" or "15.2")`).option(`--save-file`,`Save research results to .taskmaster/docs/research/ directory`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async(e,t)=>{let n=J({tasksPath:t.file||!0,tag:t.tag});(!e||typeof e!=`string`||e.trim().length===0)&&(console.error(B.red(`Error: Research prompt is required and cannot be empty`)),p(),process.exit(1));let r=[`low`,`medium`,`high`];t.detail&&!r.includes(t.detail.toLowerCase())&&(console.error(B.red(`Error: Detail level must be one of: ${r.join(`, `)}`)),process.exit(1));let i=[];if(t.id)try{i=t.id.split(`,`).map(e=>{let t=e.trim();if(!/^\d+(\.\d+)?$/.test(t))throw Error(`Invalid task ID format: "${t}". Expected format: "15" or "15.2"`);return t})}catch(e){console.error(B.red(`Error parsing task IDs: ${e.message}`)),process.exit(1)}let a=[];if(t.files)try{a=t.files.split(`,`).map(e=>{let t=e.trim();if(t.length===0)throw Error(`Empty file path provided`);return t})}catch(e){console.error(B.red(`Error parsing file paths: ${e.message}`)),process.exit(1)}if(t.saveTo){let e=t.saveTo.trim();e.length===0&&(console.error(B.red(`Error: Save-to ID cannot be empty`)),process.exit(1)),/^\d+(\.\d+)?$/.test(e)||(console.error(B.red(`Error: Save-to ID must be in format "15" for task or "15.2" for subtask`)),process.exit(1))}if(t.save){let e=t.save.trim();e.length===0&&(console.error(B.red(`Error: Save target cannot be empty`)),process.exit(1)),(e.includes(`..`)||e.startsWith(`/`))&&(console.error(B.red(`Error: Save path must be relative and cannot contain ".."`)),process.exit(1))}let o=n.getCurrentTag();if(await k(o),i.length>0)try{let e=u(n.getTasksPath(),n.getProjectRoot(),o);(!e||!e.tasks)&&(console.error(B.red(`Error: No valid tasks found in ${n.getTasksPath()} for tag '${o}'`)),process.exit(1))}catch(e){console.error(B.red(`Error reading tasks file: ${e.message}`)),process.exit(1)}if(a.length>0)for(let e of a){let t=H.isAbsolute(e)?e:H.join(n.getProjectRoot(),e);V.existsSync(t)||(console.error(B.red(`Error: File not found: ${e}`)),process.exit(1))}let s={prompt:e.trim(),taskIds:i,filePaths:a,customContext:t.context?t.context.trim():null,includeProjectTree:!!t.tree,saveTarget:t.save?t.save.trim():null,saveToId:t.saveTo?t.saveTo.trim():null,allowFollowUp:!0,detailLevel:t.detail?t.detail.toLowerCase():`medium`,tasksPath:n.getTasksPath(),projectRoot:n.getProjectRoot()};console.log(B.blue(`Researching: "${s.prompt}"`)),s.taskIds.length>0&&console.log(B.gray(`Task context: ${s.taskIds.join(`, `)}`)),s.filePaths.length>0&&console.log(B.gray(`File context: ${s.filePaths.join(`, `)}`)),s.customContext&&console.log(B.gray(`Custom context: ${s.customContext.substring(0,50)}${s.customContext.length>50?`...`:``}`)),s.includeProjectTree&&console.log(B.gray(`Including project file tree`)),console.log(B.gray(`Detail level: ${s.detailLevel}`));try{let{performResearch:e}=await import(`./research-
|
|
106
|
+
To fix this issue:`)),console.log(` 1. Run task-master list to see all available task IDs`),console.log(` 2. Use valid task IDs with the --id parameter`)),_()&&console.error(e),process.exit(1)}}),Pe(t),t.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 (e.g., using Perplexity)`,!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(`-cr, --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 n={tasksPath:e.file||!0,tag:e.tag};e.complexityReport&&(n.complexityReportPath=e.complexityReport);let r=J(n),i=r.getCurrentTag();if(await k(i),e.all){console.log(B.blue(`Expanding all pending tasks...`));try{await re(r.getTasksPath(),e.num,e.research,e.prompt,e.force,{projectRoot:r.getProjectRoot(),tag:i,complexityReportPath:r.getComplexityReportPath()})}catch(e){console.error(B.red(`Error expanding all tasks: ${e.message}`)),process.exit(1)}}else if(e.id){e.id||(console.error(B.red(`Error: Task ID is required unless using --all.`)),process.exit(1)),console.log(B.blue(`Expanding task ${e.id}...`));try{await fe(r.getTasksPath(),e.id,e.num,e.research,e.prompt,{projectRoot:r.getProjectRoot(),tag:i,complexityReportPath:r.getComplexityReportPath()},e.force)}catch(t){console.error(B.red(`Error expanding task ${e.id}: ${t.message}`)),process.exit(1)}}else console.error(B.red(`Error: You must specify either a task ID (--id) or --all.`)),t.help()}),t.command(`analyze-complexity`).description(`Analyze tasks and generate expansion recommendations${B.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=J(t);e.model,parseFloat(e.threshold);let r=e.research||!1,i=n.getCurrentTag();await k(i);let a=n.getComplexityReportPath();if(console.log(B.blue(`Analyzing task complexity from: ${n.getTasksPath()}`)),console.log(B.blue(`Output report will be saved to: ${a}`)),e.id)console.log(B.blue(`Analyzing specific task IDs: ${e.id}`));else if(e.from||e.to){let t=e.from?e.from:`first`,n=e.to?e.to:`last`;console.log(B.blue(`Analyzing tasks in range: ${t} to ${n}`))}r&&console.log(B.blue(`Using Perplexity AI for research-backed complexity analysis`)),await pe({...e,output:a,tag:i,projectRoot:n.getProjectRoot(),file:n.getTasksPath()})}),t.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 research results to the specified task/subtask(s)`).option(`-d, --detail <level>`,`Output detail level: low, medium, high`,`medium`).option(`--save-to <id>`,`Automatically save research results to specified task/subtask ID (e.g., "15" or "15.2")`).option(`--save-file`,`Save research results to .taskmaster/docs/research/ directory`).option(`--tag <tag>`,`Specify tag context for task operations`).action(async(e,t)=>{let n=J({tasksPath:t.file||!0,tag:t.tag});(!e||typeof e!=`string`||e.trim().length===0)&&(console.error(B.red(`Error: Research prompt is required and cannot be empty`)),p(),process.exit(1));let r=[`low`,`medium`,`high`];t.detail&&!r.includes(t.detail.toLowerCase())&&(console.error(B.red(`Error: Detail level must be one of: ${r.join(`, `)}`)),process.exit(1));let i=[];if(t.id)try{i=t.id.split(`,`).map(e=>{let t=e.trim();if(!/^\d+(\.\d+)?$/.test(t))throw Error(`Invalid task ID format: "${t}". Expected format: "15" or "15.2"`);return t})}catch(e){console.error(B.red(`Error parsing task IDs: ${e.message}`)),process.exit(1)}let a=[];if(t.files)try{a=t.files.split(`,`).map(e=>{let t=e.trim();if(t.length===0)throw Error(`Empty file path provided`);return t})}catch(e){console.error(B.red(`Error parsing file paths: ${e.message}`)),process.exit(1)}if(t.saveTo){let e=t.saveTo.trim();e.length===0&&(console.error(B.red(`Error: Save-to ID cannot be empty`)),process.exit(1)),/^\d+(\.\d+)?$/.test(e)||(console.error(B.red(`Error: Save-to ID must be in format "15" for task or "15.2" for subtask`)),process.exit(1))}if(t.save){let e=t.save.trim();e.length===0&&(console.error(B.red(`Error: Save target cannot be empty`)),process.exit(1)),(e.includes(`..`)||e.startsWith(`/`))&&(console.error(B.red(`Error: Save path must be relative and cannot contain ".."`)),process.exit(1))}let o=n.getCurrentTag();if(await k(o),i.length>0)try{let e=u(n.getTasksPath(),n.getProjectRoot(),o);(!e||!e.tasks)&&(console.error(B.red(`Error: No valid tasks found in ${n.getTasksPath()} for tag '${o}'`)),process.exit(1))}catch(e){console.error(B.red(`Error reading tasks file: ${e.message}`)),process.exit(1)}if(a.length>0)for(let e of a){let t=H.isAbsolute(e)?e:H.join(n.getProjectRoot(),e);V.existsSync(t)||(console.error(B.red(`Error: File not found: ${e}`)),process.exit(1))}let s={prompt:e.trim(),taskIds:i,filePaths:a,customContext:t.context?t.context.trim():null,includeProjectTree:!!t.tree,saveTarget:t.save?t.save.trim():null,saveToId:t.saveTo?t.saveTo.trim():null,allowFollowUp:!0,detailLevel:t.detail?t.detail.toLowerCase():`medium`,tasksPath:n.getTasksPath(),projectRoot:n.getProjectRoot()};console.log(B.blue(`Researching: "${s.prompt}"`)),s.taskIds.length>0&&console.log(B.gray(`Task context: ${s.taskIds.join(`, `)}`)),s.filePaths.length>0&&console.log(B.gray(`File context: ${s.filePaths.join(`, `)}`)),s.customContext&&console.log(B.gray(`Custom context: ${s.customContext.substring(0,50)}${s.customContext.length>50?`...`:``}`)),s.includeProjectTree&&console.log(B.gray(`Including project file tree`)),console.log(B.gray(`Detail level: ${s.detailLevel}`));try{let{performResearch:e}=await import(`./research-CsRfCMgE.js`),n={taskIds:s.taskIds,filePaths:s.filePaths,customContext:s.customContext||``,includeProjectTree:s.includeProjectTree,detailLevel:s.detailLevel,projectRoot:s.projectRoot,saveToFile:!!t.saveFile,tag:o},r=await e(s.prompt,n,{commandName:`research`,outputType:`cli`,tag:o},`text`,s.allowFollowUp);if(s.saveToId&&!r.interactiveSaveOccurred)try{let e=s.saveToId.includes(`.`),t=`## Research Query: ${s.prompt}
|
|
107
107
|
|
|
108
108
|
**Detail Level:** ${r.detailLevel}
|
|
109
109
|
**Context Size:** ${r.contextSize} characters
|
|
@@ -111,7 +111,7 @@ To fix this issue:`)),console.log(` 1. Run task-master list to see all availabl
|
|
|
111
111
|
|
|
112
112
|
### Results
|
|
113
113
|
|
|
114
|
-
${r.result}`;if(e){let{updateSubtaskById:e}=await import(`./update-subtask-by-id-
|
|
114
|
+
${r.result}`;if(e){let{updateSubtaskById:e}=await import(`./update-subtask-by-id-BJ6qzOVq.js`);await e(s.tasksPath,s.saveToId,t,!1,{commandName:`research-save`,outputType:`cli`,projectRoot:s.projectRoot,tag:o},`text`),console.log(B.green(`✅ Research saved to subtask ${s.saveToId}`))}else{let e=(await import(`./update-task-by-id-5w9dOdGk.js`)).default,n=parseInt(s.saveToId,10);await e(s.tasksPath,n,t,!1,{commandName:`research-save`,outputType:`cli`,projectRoot:s.projectRoot,tag:o},`text`,!0),console.log(B.green(`✅ Research saved to task ${s.saveToId}`))}}catch(e){console.log(B.red(`❌ Error saving to task/subtask: ${e.message}`))}if(s.saveTarget){let e=`# Research Query: ${s.prompt}
|
|
115
115
|
|
|
116
116
|
**Detail Level:** ${r.detailLevel}
|
|
117
117
|
**Context Size:** ${r.contextSize} characters
|
|
@@ -306,7 +306,7 @@ Or specify profiles directly:
|
|
|
306
306
|
`));for(let e of t)console.log(` • ${e.displayName} ${B.gray(`(${e.markerPath})`)}`);console.log(``),e=t.map(e=>e.profileName)}else e=await I(i);if(!e||e.length===0){console.log(B.yellow(`No profiles selected. Exiting.`));return}console.log(B.blue(`Installing ${e.length} selected profile(s)...`));let{allSuccessfulProfiles:t,totalSuccess:n,totalFailed:a}=L(await F(e,i,r.mode));console.log(B.green(`\n✓ Successfully installed ${t.length} profile(s)`)),n>0&&console.log(B.gray(` ${n} files processed, ${a} failed`));return}(!t||t.length===0)&&(console.error(`Please specify at least one rule profile (e.g., windsurf, roo).`),process.exit(1));let a=t.flatMap(e=>e.split(`,`).map(e=>e.trim())).filter(Boolean);if(e===P.REMOVE){let e=!0;if(r.force||(e=Qe(i,a)?await gt(a,Ze(i)):await ht(a)),!e){console.log(B.yellow(`Aborted: No rules were removed.`));return}}let o=[],s=[];for(let t of a){if(!nt(t)){console.warn(`Rule profile for "${t}" not found. Valid profiles: ${z.join(`, `)}. Skipping.`);continue}let a=it(t);if(e===P.ADD){console.log(B.blue(`Adding rules for profile: ${t}...`));let e=ot(i,a,{mode:await n(r.mode)});console.log(B.blue(`Completed adding rules for profile: ${t}`)),s.push({profileName:t,success:e.success,failed:e.failed}),console.log(B.green(rt(t,e)))}else if(e===P.REMOVE){console.log(B.blue(`Removing rules for profile: ${t}...`));let e=tt(i,a);o.push(e),console.log(B.green(st(t,e)))}else console.error(`Unknown action. Use "${P.ADD}" or "${P.REMOVE}".`),process.exit(1)}if(e===P.ADD&&s.length>0){let{allSuccessfulProfiles:e,totalSuccess:t,totalFailed:n}=L(s);e.length>0&&(console.log(B.green(`\nSuccessfully processed profiles: ${e.join(`, `)}`)),t>0?console.log(B.green(`Total: ${t} files processed, ${n} failed.`)):console.log(B.green(`Total: ${e.length} profile(s) set up successfully.`)))}if(e===P.REMOVE&&o.length>0){let{successfulRemovals:e,skippedRemovals:t,failedRemovals:n,removalsWithNotices:r}=at(o);e.length>0&&console.log(B.green(`\nSuccessfully removed profiles for: ${e.join(`, `)}`)),t.length>0&&console.log(B.yellow(`Skipped (default or protected): ${t.join(`, `)}`)),n.length>0&&(console.log(B.red(`
|
|
307
307
|
Errors occurred:`)),n.forEach(e=>{console.log(B.red(` ${e.profileName}: ${e.error}`))})),r.length>0&&(console.log(B.cyan(`
|
|
308
308
|
Notices:`)),r.forEach(e=>{console.log(B.cyan(` ${e.profileName}: ${e.notice}`))}));let i=o.length,a=e.length,s=t.length,c=n.length;console.log(B.blue(`\nTotal: ${i} profile(s) processed - ${a} removed, ${s} skipped, ${c} failed.`))}}),t.command(`migrate`).description(`Migrate existing project to use the new .taskmaster directory structure`).option(`-f, --force`,`Force migration even if .taskmaster directory already exists`).option(`--backup`,`Create backup of old files before migration (default: false)`,!1).option(`--cleanup`,`Remove old files after successful migration (default: true)`,!0).option(`-y, --yes`,`Skip confirmation prompts`).option(`--dry-run`,`Show what would be migrated without actually moving files`).action(async e=>{try{await ie(e)}catch(e){console.error(B.red(`Error during migration:`),e.message),process.exit(1)}}),t.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=J({tasksPath:e.file||!0,tag:e.tag}),n=e.withSubtasks||!1,r=e.status||null,i=t.getCurrentTag();console.log(B.blue(`📝 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(B.red(`❌ Failed to sync tasks to README.md`)),process.exit(1))}),t.command(`add-tag`).description(`[DEPRECATED] Create a new tag context for organizing tasks (use "tm 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)=>{console.warn(B.yellow(`⚠ Warning: "tm add-tag" is deprecated. Use "tm tags add" instead.`)),console.log(B.gray(` This command will be removed in a future version.
|
|
309
|
-
`));try{let n=J({tasksPath:t.file||!0}),r=n.getTasksPath();V.existsSync(r)||(console.error(B.red(`Error: Tasks file not found at path: ${r}`)),console.log(B.yellow(`Hint: Run task-master init or task-master parse-prd to create tasks.json first`)),process.exit(1)),!e&&!t.fromBranch&&(console.error(B.red(`Error: Either tagName argument or --from-branch option is required.`)),console.log(B.yellow(`Usage examples:`)),console.log(B.cyan(` task-master add-tag my-tag`)),console.log(B.cyan(` task-master add-tag --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-
|
|
309
|
+
`));try{let n=J({tasksPath:t.file||!0}),r=n.getTasksPath();V.existsSync(r)||(console.error(B.red(`Error: Tasks file not found at path: ${r}`)),console.log(B.yellow(`Hint: Run task-master init or task-master parse-prd to create tasks.json first`)),process.exit(1)),!e&&!t.fromBranch&&(console.error(B.red(`Error: Either tagName argument or --from-branch option is required.`)),console.log(B.yellow(`Usage examples:`)),console.log(B.cyan(` task-master add-tag my-tag`)),console.log(B.cyan(` task-master add-tag --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-CLGUfzO5.js`),r=await import(`./git-utils-PBP1PRVP.js`);await r.isGitRepository(i.projectRoot)||(console.error(B.red(`Error: Not in a git repository. Cannot use --from-branch option.`)),process.exit(1));let a=await r.getCurrentBranch(i.projectRoot);a||(console.error(B.red(`Error: Could not determine current git branch.`)),process.exit(1));let o={copyFromCurrent:t.copyFromCurrent||!1,copyFromTag:t.copyFrom,description:t.description||`Tag created from git branch "${a}"`};await e(n.getTasksPath(),a,o,i,`text`)}else{let r={copyFromCurrent:t.copyFromCurrent||!1,copyFromTag:t.copyFrom,description:t.description};await be(n.getTasksPath(),e,r,i,`text`)}if(t.autoSwitch){let{useTag:r}=await import(`./tag-management-CLGUfzO5.js`),a=t.fromBranch?(await import(`./git-utils-PBP1PRVP.js`)).sanitizeBranchNameForTag(await(await import(`./git-utils-PBP1PRVP.js`)).getCurrentBranch(projectRoot)):e;await r(n.getTasksPath(),a,{},i,`text`)}}catch(e){console.error(B.red(`Error creating tag: ${e.message}`)),l(),process.exit(1)}}).on(`error`,function(e){console.error(B.red(`Error: ${e.message}`)),l(),process.exit(1)}),t.command(`delete-tag`).description(`[DEPRECATED] Delete an existing tag and all its tasks (use "tm 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)=>{console.warn(B.yellow(`⚠ Warning: "tm delete-tag" is deprecated. Use "tm tags remove" instead.`)),console.log(B.gray(` This command will be removed in a future version.
|
|
310
310
|
`));try{let n=J({tasksPath:t.file||!0}),r=n.getTasksPath();V.existsSync(r)||(console.error(B.red(`Error: Tasks file not found at path: ${r}`)),process.exit(1));let i={yes:t.yes||!1},a={projectRoot:n.getProjectRoot(),commandName:`delete-tag`,outputType:`cli`};await He(n.getTasksPath(),e,i,a,`text`)}catch(e){console.error(B.red(`Error deleting tag: ${e.message}`)),d(),process.exit(1)}}).on(`error`,function(e){console.error(B.red(`Error: ${e.message}`)),d(),process.exit(1)}),t.command(`use-tag`).description(`[DEPRECATED] Switch to a different tag context (use "tm 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)=>{console.warn(B.yellow(`⚠ Warning: "tm use-tag" is deprecated. Use "tm tags use" instead.`)),console.log(B.gray(` This command will be removed in a future version.
|
|
311
311
|
`));try{let n=J({tasksPath:t.file||!0}),r=n.getTasksPath();V.existsSync(r)||(console.error(B.red(`Error: Tasks file not found at path: ${r}`)),process.exit(1));let i={projectRoot:n.getProjectRoot(),commandName:`use-tag`,outputType:`cli`};await Te(n.getTasksPath(),e,{},i,`text`)}catch(e){console.error(B.red(`Error switching tag: ${e.message}`)),f(),process.exit(1)}}).on(`error`,function(e){console.error(B.red(`Error: ${e.message}`)),f(),process.exit(1)}),t.command(`rename-tag`).description(`[DEPRECATED] Rename an existing tag (use "tm 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)=>{console.warn(B.yellow(`⚠ Warning: "tm rename-tag" is deprecated. Use "tm tags rename" instead.`)),console.log(B.gray(` This command will be removed in a future version.
|
|
312
312
|
`));try{let r=J({tasksPath:n.file||!0}),i=r.getTasksPath();V.existsSync(i)||(console.error(B.red(`Error: Tasks file not found at path: ${i}`)),process.exit(1));let a={projectRoot:r.getProjectRoot(),commandName:`rename-tag`,outputType:`cli`};await xe(r.getTasksPath(),e,t,{},a,`text`)}catch(e){console.error(B.red(`Error renaming tag: ${e.message}`)),process.exit(1)}}).on(`error`,function(e){console.error(B.red(`Error: ${e.message}`)),process.exit(1)}),t.command(`copy-tag`).description(`[DEPRECATED] Copy an existing tag to create a new tag with the same tasks (use "tm 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)=>{console.warn(B.yellow(`⚠ Warning: "tm copy-tag" is deprecated. Use "tm tags copy" instead.`)),console.log(B.gray(` This command will be removed in a future version.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,Cn as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,_ as C,a as w,b as T,bn as E,c as D,d as O,f as k,g as A,h as j,i as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,q as B,r as V,s as H,t as U,u as W,v as G,w as K,x as q,xn as J,y as Y,z as X}from"./config-manager-
|
|
1
|
+
import{A as e,B as t,C as n,Cn as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,R as _,S as v,T as y,U as b,V as x,W as S,_ as C,a as w,b as T,bn as E,c as D,d as O,f as k,g as A,h as j,i as M,j as N,k as P,l as F,m as I,n as L,o as R,p as z,q as B,r as V,s as H,t as U,u as W,v as G,w as K,x as q,xn as J,y as Y,z as X}from"./config-manager-Cm3z1HZv.js";import"./git-utils-DllbRE35.js";export{E as ALL_PROVIDERS,J as CUSTOM_PROVIDERS,U as ConfigurationError,u as MODEL_MAP,r as VALIDATED_PROVIDERS,L as getAllProviders,V as getAnonymousTelemetryEnabled,M as getAvailableModels,w as getAzureBaseURL,R as getBaseUrlForRole,H as getBedrockBaseURL,D as getClaudeCodeSettings,F as getClaudeCodeSettingsForCommand,W as getCodebaseAnalysisMode,O as getCodexCliSettings,k as getCodexCliSettingsForCommand,z as getConfig,I as getDebugFlag,j as getDefaultNumTasks,A as getDefaultPriority,C as getDefaultSubtasks,G as getFallbackModelId,Y as getFallbackProvider,T as getGrokCliSettings,q as getGrokCliSettingsForCommand,v as getLogLevel,n as getMainModelId,K as getMainProvider,y as getMcpApiKeyStatus,a as getOllamaBaseURL,i as getOperatingMode,h as getParametersForRole,P as getProjectName,e as getProxyEnabled,N as getResearchModelId,p as getResearchProvider,m as getResponseLanguage,g as getSupportedModelsForProvider,o as getUserId,l as getVertexLocation,f as getVertexProjectId,_ as hasCodebaseAnalysis,X as isApiKeySet,t as isConfigFilePresent,x as isConfigWarningSuppressed,c as isProxyEnabled,b as setSuppressConfigWarnings,S as validateClaudeCodeSettings,s as validateCodexCliSettings,d as validateProvider,B as writeConfig};
|
|
@@ -50,11 +50,13 @@ Phase: {{phase}}{{/phase}}{{#testsPassing}}
|
|
|
50
50
|
Tests: {{testsPassing}} passing{{#testsFailing}}, {{testsFailing}} failing{{/testsFailing}}{{/testsPassing}}`};var St=class{templates;preservePlaceholders;constructor(e={}){let t=`customTemplates`in e||`preservePlaceholders`in e?e:{customTemplates:e};this.templates={...xt,...t.customTemplates||{}},this.preservePlaceholders=t.preservePlaceholders??!1}render(e,t,n){let r=n===void 0?this.templates[e]:n;if(r===void 0)throw Error(`Template "${e}" not found`);return this.substituteVariables(r,t)}setTemplate(e,t){this.templates[e]=t}getTemplate(e){return this.templates[e]}hasTemplate(e){return e in this.templates}validateTemplate(e,t){let n=this.extractVariables(e),r=t.filter(e=>!n.includes(e));return{isValid:r.length===0,missingVars:r}}extractVariables(e){let t=e.matchAll(/\{\{\s*([^}#/\s]+)\s*\}\}/g),n=new Set;for(let e of t)n.add(e[1]);return Array.from(n)}substituteVariables(e,t){let n=e;return n=this.processConditionalBlocks(n,t),n=n.replace(/\{\{\s*([^}#/\s]+)\s*\}\}/g,(e,n)=>{let r=t[n];return r==null?this.preservePlaceholders?`{{${n}}}`:``:String(r)}),n}processConditionalBlocks(e,t){let n=e,r=!0;for(;r;){let e=n;n=n.replace(/\{\{#([^}]+)\}\}((?:(?!\{\{#).)*?)\{\{\/\1\}\}/gs,(e,n,r)=>{let i=t[n.trim()];return i!=null&&i!==!1&&i!==``?r:``}),r=n!==e}return n}};const Ct=[`feat`,`fix`,`docs`,`style`,`refactor`,`perf`,`test`,`build`,`ci`,`chore`,`revert`];var wt=class{templateEngine;scopeDetector;constructor(e,t,n){this.templateEngine=new St(e),this.scopeDetector=new bt(t,n)}generateMessage(e){let{type:t,description:n,changedFiles:r,scope:i,body:a,breaking:o=!1,taskId:s,phase:c,tag:l,testsPassing:u,testsFailing:d,coveragePercent:f}=e,p={type:t,scope:i??this.scopeDetector.detectScope(r),breaking:o?`!`:``,description:n,body:a,taskId:s,phase:c,tag:l,testsPassing:u,testsFailing:d,coveragePercent:f};return this.templateEngine.render(`commitMessage`,p)}validateConventionalCommit(e){let t=[],n=e.split(`
|
|
51
51
|
`)[0];if(!n)return t.push(`Missing commit message`),{isValid:!1,errors:t};let r=n.match(/^(\w+)(?:\(([^)]+)\))?(!)?:\s*(.+)$/);if(!r)return t.push(`Invalid conventional commit format. Expected: type(scope): description`),{isValid:!1,errors:t};let[,i,,,a]=r;return Ct.includes(i)||t.push(`Invalid commit type "${i}". Must be one of: ${Ct.join(`, `)}`),(!a||a.trim().length===0)&&t.push(`Missing description`),{isValid:t.length===0,errors:t}}parseCommitMessage(e){let t=e.split(`
|
|
52
52
|
`),n=t[0].match(/^(\w+)(?:\(([^)]+)\))?(!)?:\s*(.+)$/);if(!n)throw Error(`Invalid conventional commit format`);let[,r,i,a,o]=n,s=t.findIndex((e,t)=>t>0&&e===``),c=s===-1?void 0:t.slice(s+1).join(`
|
|
53
|
-
`).trim();return{type:r,scope:i,breaking:a===`!`,description:o,body:c}}getScopeDetector(){return this.scopeDetector}getTemplateEngine(){return this.templateEngine}},Tt=class{gitAdapter;commitGenerator;constructor(e){this.gitAdapter=new _t(e),this.commitGenerator=new wt}async isGitRepository(){return this.gitAdapter.isGitRepository()}async ensureGitRepository(){return this.gitAdapter.ensureGitRepository()}async getRepositoryRoot(){return this.gitAdapter.getRepositoryRoot()}async isWorkingTreeClean(){return this.gitAdapter.isWorkingTreeClean()}async getStatus(){return this.gitAdapter.getStatus()}async getStatusSummary(){return this.gitAdapter.getStatusSummary()}async hasUncommittedChanges(){return this.gitAdapter.hasUncommittedChanges()}async hasStagedChanges(){return this.gitAdapter.hasStagedChanges()}async getCurrentBranch(){return this.gitAdapter.getCurrentBranch()}async listBranches(){return this.gitAdapter.listBranches()}async branchExists(e){return this.gitAdapter.branchExists(e)}async createBranch(e,t){return this.gitAdapter.createBranch(e,t)}async checkoutBranch(e,t){return this.gitAdapter.checkoutBranch(e,t)}async createAndCheckoutBranch(e){return this.gitAdapter.createAndCheckoutBranch(e)}async deleteBranch(e,t){return this.gitAdapter.deleteBranch(e,t)}async getDefaultBranch(){return this.gitAdapter.getDefaultBranch()}async isOnDefaultBranch(){return this.gitAdapter.isOnDefaultBranch()}async stageFiles(e){return this.gitAdapter.stageFiles(e)}async unstageFiles(e){return this.gitAdapter.unstageFiles(e)}async createCommit(e,t){return this.gitAdapter.createCommit(e,t)}async getCommitLog(e){return this.gitAdapter.getCommitLog(e)}async getLastCommit(){return this.gitAdapter.getLastCommit()}async hasRemote(){return this.gitAdapter.hasRemote()}async getRemotes(){return this.gitAdapter.getRemotes()}generateCommitMessage(e){return this.commitGenerator.generateMessage(e)}validateCommitMessage(e){return this.commitGenerator.validateConventionalCommit(e)}parseCommitMessage(e){return this.commitGenerator.parseCommitMessage(e)}},Et=class{detectFormat(e){return!e||typeof e!=`object`?`standard`:Object.keys(e).some(e=>e!==`tasks`&&e!==`metadata`)?`legacy`:`standard`}extractTasks(e,t){return e?this.detectFormat(e)===`legacy`?this.extractTasksFromLegacy(e,t):this.extractTasksFromStandard(e):[]}extractTasksFromLegacy(e,t){if(t in e)return e[t]?.tasks||[];let n=Object.keys(e).filter(e=>e!==`tasks`&&e!==`metadata`);return t===`master`&&n.length>0&&e[n[0]]?.tasks||[]}extractTasksFromStandard(e){return e?.tasks||[]}extractMetadata(e,t){return e?this.detectFormat(e)===`legacy`?this.extractMetadataFromLegacy(e,t):this.extractMetadataFromStandard(e):null}extractMetadataFromLegacy(e,t){if(t in e){let n=e[t];return!n?.metadata&&n?.tasks?this.generateMetadataFromTasks(n.tasks,t):n?.metadata||null}let n=Object.keys(e).filter(e=>e!==`tasks`&&e!==`metadata`);if(t===`master`&&n.length>0){let t=n[0],r=e[t];return!r?.metadata&&r?.tasks?this.generateMetadataFromTasks(r.tasks,t):r?.metadata||null}return null}extractMetadataFromStandard(e){return e?.metadata||null}extractTags(e){return e?this.detectFormat(e)===`legacy`?Object.keys(e).filter(e=>e!==`tasks`&&e!==`metadata`):[`master`]:[]}convertToSaveFormat(e,t,n,r){let i=r||`master`,a=this.normalizeTasks(e);return n&&this.detectFormat(n)===`legacy`?this.convertToLegacyFormat(a,t,i):this.convertToStandardFormat(a,t,r)}convertToLegacyFormat(e,t,n){return{[n]:{tasks:e,metadata:{...t,tags:[n]}}}}convertToStandardFormat(e,t,n){return{tasks:e,metadata:{...t,tags:n?[n]:[]}}}normalizeTasks(e){return e.map(e=>({...e,id:String(e.id),dependencies:e.dependencies?.map(e=>String(e))||[],subtasks:e.subtasks?.map(e=>({...e,id:Number(e.id),parentId:String(e.parentId)}))||[]}))}generateMetadataFromTasks(e,t){return{version:`1.0.0`,lastModified:new Date().toISOString(),taskCount:e.length,completedCount:e.filter(e=>e.status===`done`).length,tags:[t]}}};const Dt={stale:1e4,retries:{retries:5,factor:2,minTimeout:100,maxTimeout:1e3},realpath:!1};var Ot=class{writers=new Map;getWriter(e){let t=this.writers.get(e);return t||(t=new d(e),this.writers.set(e,t)),t}async readJson(e){try{let t=await _.readFile(e,`utf-8`);return JSON.parse(t)}catch(t){throw t.code===`ENOENT`?t:t instanceof SyntaxError?Error(`Invalid JSON in file ${e}: ${t.message}`):Error(`Failed to read file ${e}: ${t.message}`)}}async writeJson(e,t){await this.ensureFileExists(e);let n=null;try{n=await le.lock(e,Dt);let r=JSON.stringify(t,null,2);await this.getWriter(e).write(r)}finally{if(n)try{await n()}catch(t){(process.env.DEBUG||process.env.TASKMASTER_DEBUG===`true`)&&console.warn(`[WARN] Lock release warning for ${e}: ${t.message}`)}}}async modifyJson(e,t){await this.ensureFileExists(e);let n=null;try{n=await le.lock(e,Dt);let r;try{let t=await _.readFile(e,`utf-8`);r=JSON.parse(t)}catch(t){if(t.code===`ENOENT`)r={};else if(t instanceof SyntaxError){let n=await _.readFile(e,`utf-8`).catch(()=>``);if(n.trim()===``||n.trim()===`{}`)r={};else throw Error(`Corrupted JSON in ${e}: ${t.message}. File contains: ${n.substring(0,100)}...`)}else throw Error(`Failed to read ${e} for modification: ${t.message}`)}let i=await t(r),a=JSON.stringify(i,null,2);await this.getWriter(e).write(a)}finally{if(n)try{await n()}catch(t){(process.env.DEBUG||process.env.TASKMASTER_DEBUG===`true`)&&console.warn(`[WARN] Lock release warning for ${e}: ${t.message}`)}}}async ensureFileExists(e){let n=t.dirname(e);await _.mkdir(n,{recursive:!0});try{await _.writeFile(e,`{}`,{flag:`wx`})}catch(e){if(e.code!==`EEXIST`)throw e}}async exists(e){try{return await _.access(e,h.F_OK),!0}catch{return!1}}async getStats(e){return _.stat(e)}async readDir(e){return _.readdir(e)}async ensureDir(e){try{await _.mkdir(e,{recursive:!0})}catch(t){throw Error(`Failed to create directory ${e}: ${t.message}`)}}async deleteFile(e){try{await _.unlink(e)}catch(t){if(t.code!==`ENOENT`)throw Error(`Failed to delete file ${e}: ${t.message}`)}}async moveFile(e,t){try{await _.rename(e,t)}catch(n){throw Error(`Failed to move file from ${e} to ${t}: ${n.message}`)}}async copyFile(e,t){try{await _.copyFile(e,t)}catch(n){throw Error(`Failed to copy file from ${e} to ${t}: ${n.message}`)}}async cleanup(){this.writers.clear()}},kt=class{basePath;tasksDir;tasksFilePath;constructor(e){this.basePath=t.join(e,`.taskmaster`),this.tasksDir=t.join(this.basePath,`tasks`),this.tasksFilePath=t.join(this.tasksDir,`tasks.json`)}getBasePath(){return this.basePath}getTasksDir(){return this.tasksDir}getTasksPath(){return this.tasksFilePath}};const At=S(`ComplexityReportManager`);var jt=class{projectRoot;reportCache=new Map;constructor(e){this.projectRoot=e}getReportPath(e){let t=c.join(this.projectRoot,`.taskmaster`,`reports`),n=e&&e!==`master`?`_${e}`:``;return c.join(t,`task-complexity-report${n}.json`)}async loadReport(e){let t=e||`master`,n=t;if(this.reportCache.has(n))return this.reportCache.get(n);let r=this.getReportPath(e);try{await _.access(r);let e=await _.readFile(r,`utf-8`),i=JSON.parse(e);return!i.meta||!Array.isArray(i.complexityAnalysis)?(At.warn(`Invalid complexity report structure at ${r}, ignoring`),null):(this.reportCache.set(n,i),At.debug(`Loaded complexity report for tag '${t}' with ${i.complexityAnalysis.length} analyses`),i)}catch(e){return e.code===`ENOENT`?(At.debug(`No complexity report found for tag '${t}'`),null):(At.warn(`Failed to load complexity report for tag '${t}': ${e.message}`),null)}}async getComplexityForTask(e,t){let n=await this.loadReport(t);if(!n)return null;let r=n.complexityAnalysis.find(t=>String(t.taskId)===String(e));return r?{complexityScore:r.complexityScore,recommendedSubtasks:r.recommendedSubtasks,expansionPrompt:r.expansionPrompt,complexityReasoning:r.complexityReasoning}:null}async getComplexityForTasks(e,t){let n=new Map,r=await this.loadReport(t);if(!r)return n;let i=new Map;return r.complexityAnalysis.forEach(e=>{i.set(String(e.taskId),e)}),e.forEach(e=>{let t=i.get(String(e));t&&n.set(String(e),{complexityScore:t.complexityScore,recommendedSubtasks:t.recommendedSubtasks,expansionPrompt:t.expansionPrompt,complexityReasoning:t.complexityReasoning})}),n}clearCache(e){e?this.reportCache.delete(e):this.reportCache.clear()}async hasReport(e){let t=this.getReportPath(e);try{return await _.access(t),!0}catch{return!1}}},Mt=class{formatHandler;fileOps;pathResolver;complexityManager;constructor(e){this.formatHandler=new Et,this.fileOps=new Ot,this.pathResolver=new kt(e),this.complexityManager=new jt(e)}async initialize(){await this.fileOps.ensureDir(this.pathResolver.getTasksDir())}async close(){await this.fileOps.cleanup()}getStorageType(){return`file`}getCurrentBriefName(){return null}async getStats(){let e=this.pathResolver.getTasksPath();try{let t=await this.fileOps.getStats(e),n=await this.fileOps.readJson(e),r=this.formatHandler.extractTags(n),i=0,a=r.map(e=>{let r=this.formatHandler.extractTasks(n,e).length;return i+=r,{tag:e,taskCount:r,lastModified:t.mtime.toISOString()}});return{totalTasks:i,totalTags:r.length,lastModified:t.mtime.toISOString(),storageSize:0,tagStats:a}}catch(e){if(e.code===`ENOENT`)return{totalTasks:0,totalTags:0,lastModified:new Date().toISOString(),storageSize:0,tagStats:[]};throw Error(`Failed to get storage stats: ${e.message}`)}}async loadTasks(e,t){let n=this.pathResolver.getTasksPath(),r=e||`master`;try{let e=await this.fileOps.readJson(n),i=this.formatHandler.extractTasks(e,r);return t&&(t.status&&(i=i.filter(e=>e.status===t.status)),t.excludeSubtasks&&(i=i.map(e=>({...e,subtasks:[]})))),await this.enrichTasksWithComplexity(i,r)}catch(e){if(e.code===`ENOENT`)return[];throw Error(`Failed to load tasks: ${e.message}`)}}async loadTask(e,t){let n=await this.loadTasks(t);if(e.includes(`.`)){let[t,r]=e.split(`.`),i=n.find(e=>String(e.id)===t);if(!i||!i.subtasks)return null;let a=i.subtasks.find(e=>String(e.id)===r);if(!a)return null;let o=e=>{let t=String(e);return t.includes(`.`)?t:`${i.id}.${t}`},s=a.dependencies?.map(e=>o(e))??[];return{...a,id:e,title:a.title||`Subtask ${r}`,description:a.description||``,status:a.status||`pending`,priority:a.priority||i.priority||`medium`,dependencies:s,details:a.details||``,testStrategy:a.testStrategy||``,subtasks:[],tags:i.tags||[],assignee:a.assignee||i.assignee,complexity:a.complexity||i.complexity,createdAt:a.createdAt||i.createdAt,updatedAt:a.updatedAt||i.updatedAt,parentTask:{id:i.id,title:i.title,status:i.status},isSubtask:!0}}return n.find(t=>String(t.id)===String(e))||null}async saveTasks(e,t){let n=this.pathResolver.getTasksPath(),r=t||`master`;await this.fileOps.ensureDir(this.pathResolver.getTasksDir());let i={version:`1.0.0`,lastModified:new Date().toISOString(),taskCount:e.length,completedCount:e.filter(e=>e.status===`done`).length,tags:[r]},a=this.normalizeTaskIds(e);await this.fileOps.modifyJson(n,e=>this.formatHandler.detectFormat(e)===`legacy`||Object.keys(e).some(e=>e!==`tasks`&&e!==`metadata`)?(e[r]={tasks:a,metadata:i},e):r===`master`?{tasks:a,metadata:i}:{master:{tasks:e.tasks||[],metadata:e.metadata||i},[r]:{tasks:a,metadata:i}})}normalizeTaskIds(e){return e.map(e=>({...e,id:String(e.id),dependencies:e.dependencies?.map(e=>String(e))||[],subtasks:e.subtasks?.map(e=>({...e,id:Number(e.id),parentId:String(e.parentId)}))||[]}))}async exists(e){let t=this.pathResolver.getTasksPath();return this.fileOps.exists(t)}async getAllTags(){try{let e=this.pathResolver.getTasksPath(),t=await this.fileOps.readJson(e);return this.formatHandler.extractTags(t)}catch(e){if(e.code===`ENOENT`)return[];throw Error(`Failed to get tags: ${e.message}`)}}async loadMetadata(e){let t=this.pathResolver.getTasksPath(),n=e||`master`;try{let e=await this.fileOps.readJson(t);return this.formatHandler.extractMetadata(e,n)}catch(e){if(e.code===`ENOENT`)return null;throw Error(`Failed to load metadata: ${e.message}`)}}async saveMetadata(e,t){let n=await this.loadTasks(t);await this.saveTasks(n,t)}async appendTasks(e,t){let n=[...await this.loadTasks(t),...e];await this.saveTasks(n,t)}async updateTask(e,t,n){let r=await this.loadTasks(n),i=r.findIndex(t=>String(t.id)===String(e));if(i===-1)throw Error(`Task ${e} not found`);let a=r[i],o=t.subtasks;t.subtasks&&a.subtasks&&(o=t.subtasks.map(e=>{let t=a.subtasks?.find(t=>String(t.id)===String(e.id)||e.title&&t.title===e.title);return t?.metadata||e.metadata?{...e,metadata:{...t?.metadata||{},...e.metadata||{}}}:e})),r[i]={...a,...t,...o&&{subtasks:o},id:String(e)},await this.saveTasks(r,n)}async updateTaskWithPrompt(e,t,n,r){throw Error(`File storage does not support updateTaskWithPrompt. Client-side AI logic must process the prompt before calling updateTask().`)}async expandTaskWithPrompt(e,t,n){throw Error(`File storage does not support expandTaskWithPrompt. Client-side AI logic must process the expansion before calling updateTask().`)}async updateTaskStatus(e,t,n){let r=await this.loadTasks(n);if(e.includes(`.`))return this.updateSubtaskStatusInFile(r,e,t,n);let i=r.findIndex(t=>String(t.id)===String(e));if(i===-1)throw Error(`Task ${e} not found`);let a=r[i].status;return a===t?{success:!0,oldStatus:a,newStatus:t,taskId:String(e)}:(r[i]={...r[i],status:t,updatedAt:new Date().toISOString()},await this.saveTasks(r,n),{success:!0,oldStatus:a,newStatus:t,taskId:String(e)})}async updateSubtaskStatusInFile(e,t,n,r){let i=t.split(`.`);if(i.length!==2)throw Error(`Invalid subtask ID format: ${t}. Expected format: parentId.subtaskId`);let[a,o]=i,s=o.trim();if(!/^\d+$/.test(s))throw Error(`Invalid subtask ID: ${s}. Subtask ID must be a positive integer.`);let c=Number(s),l=e.findIndex(e=>String(e.id)===String(a));if(l===-1)throw Error(`Parent task ${a} not found`);let u=e[l],d=u.subtasks.findIndex(e=>e.id===c||String(e.id)===s);if(d===-1)throw Error(`Subtask ${t} not found in parent task ${a}`);let f=u.subtasks[d].status||`pending`;if(f===n)return{success:!0,oldStatus:f,newStatus:n,taskId:t};let p=new Date().toISOString();u.subtasks[d]={...u.subtasks[d],status:n,updatedAt:p};let m=u.subtasks,h=u.status;if(m.length>0){let e=e=>e.status||`pending`,t=t=>{let n=e(t);return n===`done`||n===`completed`},n=m.every(t),r=m.some(t=>e(t)===`in-progress`),i=m.some(t),a=m.every(t=>e(t)===`pending`);n?h=`done`:r||i?h=`in-progress`:a&&(h=`pending`)}return e[l]={...u,...h===u.status?{}:{status:h},updatedAt:p},await this.saveTasks(e,r),{success:!0,oldStatus:f,newStatus:n,taskId:t}}async deleteTask(e,t){let n=await this.loadTasks(t),r=n.filter(t=>String(t.id)!==String(e));if(r.length===n.length)throw Error(`Task ${e} not found`);await this.saveTasks(r,t)}async createTag(e,t){let n=this.pathResolver.getTasksPath();try{await this.fileOps.modifyJson(n,n=>{if(this.formatHandler.detectFormat(n)===`legacy`){if(e in n)throw new b(`Tag ${e} already exists`,y.VALIDATION_ERROR);let r=[];return t?.copyFrom&&t.copyFrom in n&&n[t.copyFrom].tasks&&(r=JSON.parse(JSON.stringify(n[t.copyFrom].tasks))),n[e]={tasks:r,metadata:{created:new Date().toISOString(),updatedAt:new Date().toISOString(),description:t?.description||`Tag created on ${new Date().toLocaleDateString()}`,tags:[e]}},n}else{let r=n.tasks||[],i=n.metadata||{},a=[];return(t?.copyFrom===`master`||!t?.copyFrom)&&(a=JSON.parse(JSON.stringify(r))),{master:{tasks:r,metadata:{...i,tags:[`master`]}},[e]:{tasks:a,metadata:{created:new Date().toISOString(),updatedAt:new Date().toISOString(),description:t?.description||`Tag created on ${new Date().toLocaleDateString()}`,tags:[e]}}}}})}catch(e){throw e.code===`ENOENT`?Error(`Tasks file not found - initialize project first`):e}}async deleteTag(e){let t=this.pathResolver.getTasksPath();try{let n=!1;await this.fileOps.modifyJson(t,t=>{if(this.formatHandler.detectFormat(t)!==`legacy`&&e===`master`)return n=!0,t;if(this.formatHandler.detectFormat(t)===`legacy`){if(e in t)return delete t[e],t;throw Error(`Tag ${e} not found`)}else throw Error(`Tag ${e} not found in standard format`)}),n&&await this.fileOps.deleteFile(t)}catch(t){throw t.code===`ENOENT`?Error(`Tag ${e} not found - file doesn't exist`):t}}async renameTag(e,t){let n=this.pathResolver.getTasksPath();try{await this.fileOps.modifyJson(n,n=>{if(this.formatHandler.detectFormat(n)===`legacy`){if(e in n)return n[t]=n[e],delete n[e],n[t].metadata&&(n[t].metadata.tags=[t]),n;throw Error(`Tag ${e} not found`)}else if(e===`master`){let e=n.tasks||[],r=n.metadata||{};return{[t]:{tasks:e,metadata:{...r,tags:[t]}}}}else throw Error(`Tag ${e} not found in standard format`)})}catch(t){throw t.code===`ENOENT`?Error(`Tag ${e} not found - file doesn't exist`):t}}async copyTag(e,t){let n=await this.loadTasks(e);if(n.length===0)throw Error(`Source tag ${e} not found or has no tasks`);await this.saveTasks(n,t)}async getTagsWithStats(){let e=await this.getAllTags(),t=await this.getActiveTagFromState(),n=await Promise.all(e.map(async e=>{try{let n=await this.loadTasks(e),r={},i=0,a={totalSubtasks:0,subtasksByStatus:{}};n.forEach(e=>{let t=e.status||`pending`;r[t]=(r[t]||0)+1,t===`done`&&i++,e.subtasks&&e.subtasks.length>0&&(a.totalSubtasks+=e.subtasks.length,e.subtasks.forEach(e=>{let t=e.status||`pending`;a.subtasksByStatus[t]=(a.subtasksByStatus[t]||0)+1}))});let o=await this.loadMetadata(e);return{name:e,isCurrent:e===t,taskCount:n.length,completedTasks:i,statusBreakdown:r,subtaskCounts:a.totalSubtasks>0?a:void 0,created:o?.created,description:o?.description}}catch{return{name:e,isCurrent:e===t,taskCount:0,completedTasks:0,statusBreakdown:{}}}}));return{tags:n,currentTag:t,totalTags:n.length}}async getActiveTagFromState(){try{let e=t.join(this.pathResolver.getBasePath(),`state.json`);return(await this.fileOps.readJson(e))?.currentTag||`master`}catch{return`master`}}async watch(e,t){let n=this.pathResolver.getTasksPath(),r=t?.debounceMs??100;if(!await this.fileOps.exists(n))throw new b(`Tasks file not found. Initialize the project first.`,y.NOT_FOUND,{path:n});let i,a=!1,o=m.watch(n,(t,n)=>{a||n&&t===`change`&&(i&&clearTimeout(i),i=setTimeout(()=>{a||e({type:`change`,timestamp:new Date})},r))});return o.on(`error`,t=>{a||e({type:`error`,timestamp:new Date,error:t})}),{unsubscribe:()=>{a=!0,i&&clearTimeout(i),o.close()}}}async enrichTasksWithComplexity(e,t){let n=e.map(e=>e.id),r=await this.complexityManager.getComplexityForTasks(n,t);return r.size===0?e:e.map(e=>{let t=r.get(String(e.id));return t?{...e,complexity:t.complexityScore,recommendedSubtasks:t.recommendedSubtasks,expansionPrompt:t.expansionPrompt,complexityReasoning:t.complexityReasoning}:e})}},Nt=class{configManager;authManager;constructor(e,t){this.configManager=e,this.authManager=t}async exportTasks(e){if(!await this.authManager.hasValidSession())throw new b(`Authentication required for export`,y.AUTHENTICATION_ERROR);let t=await this.authManager.getContext(),n=e.orgId||t?.orgId,r=e.briefId||t?.briefId;if(!n)throw new b(`Organization ID is required for export. Use "tm context org" to select one.`,y.MISSING_CONFIGURATION);if(!r)throw new b(`Brief ID is required for export. Use "tm context brief" or provide --brief flag.`,y.MISSING_CONFIGURATION);let i=this.configManager.getActiveTag(),a=e.tag||i,o=new Mt(this.configManager.getProjectRoot());await o.initialize();let s=await o.loadTasks(a,{status:e.status,excludeSubtasks:e.excludeSubtasks}),c={tasks:s,total:(await o.loadTasks(a)).length,filtered:s.length,tag:a,storageType:`file`};if(c.tasks.length===0)return{success:!1,taskCount:0,briefId:r,orgId:n,message:`No tasks found to export`,error:{code:`NO_TASKS`,message:`No tasks match the specified criteria`}};try{return await this.performExport(n,r,c.tasks),{success:!0,taskCount:c.tasks.length,briefId:r,orgId:n,message:`Successfully exported ${c.tasks.length} task(s) to brief`}}catch(e){return{success:!1,taskCount:0,briefId:r,orgId:n,error:{code:`EXPORT_FAILED`,message:e instanceof Error?e.message:String(e)}}}}async exportFromBriefInput(e){let t=this.extractBriefId(e);if(!t)throw new b(`Invalid brief ID or URL provided`,y.VALIDATION_ERROR);let n=await this.authManager.getBrief(t);if(!n)throw new b(`Brief not found or you do not have access`,y.NOT_FOUND);return this.exportTasks({orgId:n.accountId,briefId:n.id})}async validateContext(){let e=await this.authManager.getContext();return{hasOrg:!!e?.orgId,hasBrief:!!e?.briefId,context:e}}transformTasksForBulkImport(e){let t=[],n=new Set;for(let t of e)if(n.add(String(t.id)),t.subtasks)for(let e of t.subtasks)n.add(`${t.id}.${e.id}`);return e.forEach(e=>{let r=(e.dependencies||[]).map(String).filter(e=>n.has(e));t.push({externalId:String(e.id),title:e.title,description:this.enrichDescription(e),status:this.mapStatusForAPI(e.status),priority:e.priority||`medium`,dependencies:r,details:e.details,testStrategy:e.testStrategy,complexity:e.complexity,metadata:{complexity:e.complexity,originalId:e.id,originalDescription:e.description,originalDetails:e.details,originalTestStrategy:e.testStrategy}}),e.subtasks&&e.subtasks.length>0&&e.subtasks.forEach(r=>{let i=(r.dependencies||[]).map(t=>String(t).includes(`.`)?String(t):`${e.id}.${t}`).filter(e=>n.has(e));t.push({externalId:`${e.id}.${r.id}`,parentExternalId:String(e.id),title:r.title,description:this.enrichDescription(r),status:this.mapStatusForAPI(r.status),priority:r.priority||`medium`,dependencies:i,details:r.details,testStrategy:r.testStrategy,complexity:r.complexity,metadata:{complexity:r.complexity,originalId:r.id,originalDescription:r.description,originalDetails:r.details,originalTestStrategy:r.testStrategy}})})}),t}enrichDescription(e){let t=[];return e.description&&t.push(e.description),e.details&&(t.push(`## Implementation Details
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
`).trim();return{type:r,scope:i,breaking:a===`!`,description:o,body:c}}getScopeDetector(){return this.scopeDetector}getTemplateEngine(){return this.templateEngine}},Tt=class{gitAdapter;commitGenerator;constructor(e){this.gitAdapter=new _t(e),this.commitGenerator=new wt}async isGitRepository(){return this.gitAdapter.isGitRepository()}async ensureGitRepository(){return this.gitAdapter.ensureGitRepository()}async getRepositoryRoot(){return this.gitAdapter.getRepositoryRoot()}async isWorkingTreeClean(){return this.gitAdapter.isWorkingTreeClean()}async getStatus(){return this.gitAdapter.getStatus()}async getStatusSummary(){return this.gitAdapter.getStatusSummary()}async hasUncommittedChanges(){return this.gitAdapter.hasUncommittedChanges()}async hasStagedChanges(){return this.gitAdapter.hasStagedChanges()}async getCurrentBranch(){return this.gitAdapter.getCurrentBranch()}async listBranches(){return this.gitAdapter.listBranches()}async branchExists(e){return this.gitAdapter.branchExists(e)}async createBranch(e,t){return this.gitAdapter.createBranch(e,t)}async checkoutBranch(e,t){return this.gitAdapter.checkoutBranch(e,t)}async createAndCheckoutBranch(e){return this.gitAdapter.createAndCheckoutBranch(e)}async deleteBranch(e,t){return this.gitAdapter.deleteBranch(e,t)}async getDefaultBranch(){return this.gitAdapter.getDefaultBranch()}async isOnDefaultBranch(){return this.gitAdapter.isOnDefaultBranch()}async stageFiles(e){return this.gitAdapter.stageFiles(e)}async unstageFiles(e){return this.gitAdapter.unstageFiles(e)}async createCommit(e,t){return this.gitAdapter.createCommit(e,t)}async getCommitLog(e){return this.gitAdapter.getCommitLog(e)}async getLastCommit(){return this.gitAdapter.getLastCommit()}async hasRemote(){return this.gitAdapter.hasRemote()}async getRemotes(){return this.gitAdapter.getRemotes()}generateCommitMessage(e){return this.commitGenerator.generateMessage(e)}validateCommitMessage(e){return this.commitGenerator.validateConventionalCommit(e)}parseCommitMessage(e){return this.commitGenerator.parseCommitMessage(e)}},Et=class{detectFormat(e){return!e||typeof e!=`object`?`standard`:Object.keys(e).some(e=>e!==`tasks`&&e!==`metadata`)?`legacy`:`standard`}extractTasks(e,t){return e?this.detectFormat(e)===`legacy`?this.extractTasksFromLegacy(e,t):this.extractTasksFromStandard(e):[]}extractTasksFromLegacy(e,t){if(t in e)return e[t]?.tasks||[];let n=Object.keys(e).filter(e=>e!==`tasks`&&e!==`metadata`);return t===`master`&&n.length>0&&e[n[0]]?.tasks||[]}extractTasksFromStandard(e){return e?.tasks||[]}extractMetadata(e,t){return e?this.detectFormat(e)===`legacy`?this.extractMetadataFromLegacy(e,t):this.extractMetadataFromStandard(e):null}extractMetadataFromLegacy(e,t){if(t in e){let n=e[t];return!n?.metadata&&n?.tasks?this.generateMetadataFromTasks(n.tasks,t):n?.metadata||null}let n=Object.keys(e).filter(e=>e!==`tasks`&&e!==`metadata`);if(t===`master`&&n.length>0){let t=n[0],r=e[t];return!r?.metadata&&r?.tasks?this.generateMetadataFromTasks(r.tasks,t):r?.metadata||null}return null}extractMetadataFromStandard(e){return e?.metadata||null}extractTags(e){return e?this.detectFormat(e)===`legacy`?Object.keys(e).filter(e=>e!==`tasks`&&e!==`metadata`):[`master`]:[]}convertToSaveFormat(e,t,n,r){let i=r||`master`,a=this.normalizeTasks(e);return n&&this.detectFormat(n)===`legacy`?this.convertToLegacyFormat(a,t,i):this.convertToStandardFormat(a,t,r)}convertToLegacyFormat(e,t,n){return{[n]:{tasks:e,metadata:{...t,tags:[n]}}}}convertToStandardFormat(e,t,n){return{tasks:e,metadata:{...t,tags:n?[n]:[]}}}normalizeTasks(e){return e.map(e=>({...e,id:String(e.id),dependencies:e.dependencies?.map(e=>String(e))||[],subtasks:e.subtasks?.map(e=>({...e,id:Number(e.id),parentId:String(e.parentId)}))||[]}))}generateMetadataFromTasks(e,t){return{version:`1.0.0`,lastModified:new Date().toISOString(),taskCount:e.length,completedCount:e.filter(e=>e.status===`done`).length,tags:[t]}}};const Dt={stale:1e4,retries:{retries:5,factor:2,minTimeout:100,maxTimeout:1e3},realpath:!1};var Ot=class{writers=new Map;getWriter(e){let t=this.writers.get(e);return t||(t=new d(e),this.writers.set(e,t)),t}async readJson(e){try{let t=await _.readFile(e,`utf-8`);return JSON.parse(t)}catch(t){throw t.code===`ENOENT`?t:t instanceof SyntaxError?Error(`Invalid JSON in file ${e}: ${t.message}`):Error(`Failed to read file ${e}: ${t.message}`)}}async writeJson(e,t){await this.ensureFileExists(e);let n=null;try{n=await le.lock(e,Dt);let r=JSON.stringify(t,null,2);await this.getWriter(e).write(r)}finally{if(n)try{await n()}catch(t){(process.env.DEBUG||process.env.TASKMASTER_DEBUG===`true`)&&console.warn(`[WARN] Lock release warning for ${e}: ${t.message}`)}}}async modifyJson(e,t){await this.ensureFileExists(e);let n=null;try{n=await le.lock(e,Dt);let r;try{let t=await _.readFile(e,`utf-8`);r=JSON.parse(t)}catch(t){if(t.code===`ENOENT`)r={};else if(t instanceof SyntaxError){let n=await _.readFile(e,`utf-8`).catch(()=>``);if(n.trim()===``||n.trim()===`{}`)r={};else throw Error(`Corrupted JSON in ${e}: ${t.message}. File contains: ${n.substring(0,100)}...`)}else throw Error(`Failed to read ${e} for modification: ${t.message}`)}let i=await t(r),a=JSON.stringify(i,null,2);await this.getWriter(e).write(a)}finally{if(n)try{await n()}catch(t){(process.env.DEBUG||process.env.TASKMASTER_DEBUG===`true`)&&console.warn(`[WARN] Lock release warning for ${e}: ${t.message}`)}}}async ensureFileExists(e){let n=t.dirname(e);await _.mkdir(n,{recursive:!0});try{await _.writeFile(e,`{}`,{flag:`wx`})}catch(e){if(e.code!==`EEXIST`)throw e}}async exists(e){try{return await _.access(e,h.F_OK),!0}catch{return!1}}async getStats(e){return _.stat(e)}async readDir(e){return _.readdir(e)}async ensureDir(e){try{await _.mkdir(e,{recursive:!0})}catch(t){throw Error(`Failed to create directory ${e}: ${t.message}`)}}async deleteFile(e){try{await _.unlink(e)}catch(t){if(t.code!==`ENOENT`)throw Error(`Failed to delete file ${e}: ${t.message}`)}}async moveFile(e,t){try{await _.rename(e,t)}catch(n){throw Error(`Failed to move file from ${e} to ${t}: ${n.message}`)}}async copyFile(e,t){try{await _.copyFile(e,t)}catch(n){throw Error(`Failed to copy file from ${e} to ${t}: ${n.message}`)}}async cleanup(){this.writers.clear()}},kt=class{basePath;tasksDir;tasksFilePath;constructor(e){this.basePath=t.join(e,`.taskmaster`),this.tasksDir=t.join(this.basePath,`tasks`),this.tasksFilePath=t.join(this.tasksDir,`tasks.json`)}getBasePath(){return this.basePath}getTasksDir(){return this.tasksDir}getTasksPath(){return this.tasksFilePath}};const At=S(`ComplexityReportManager`);var jt=class{projectRoot;reportCache=new Map;constructor(e){this.projectRoot=e}getReportPath(e){let t=c.join(this.projectRoot,`.taskmaster`,`reports`),n=e&&e!==`master`?`_${e}`:``;return c.join(t,`task-complexity-report${n}.json`)}async loadReport(e){let t=e||`master`,n=t;if(this.reportCache.has(n))return this.reportCache.get(n);let r=this.getReportPath(e);try{await _.access(r);let e=await _.readFile(r,`utf-8`),i=JSON.parse(e);return!i.meta||!Array.isArray(i.complexityAnalysis)?(At.warn(`Invalid complexity report structure at ${r}, ignoring`),null):(this.reportCache.set(n,i),At.debug(`Loaded complexity report for tag '${t}' with ${i.complexityAnalysis.length} analyses`),i)}catch(e){return e.code===`ENOENT`?(At.debug(`No complexity report found for tag '${t}'`),null):(At.warn(`Failed to load complexity report for tag '${t}': ${e.message}`),null)}}async getComplexityForTask(e,t){let n=await this.loadReport(t);if(!n)return null;let r=n.complexityAnalysis.find(t=>String(t.taskId)===String(e));return r?{complexityScore:r.complexityScore,recommendedSubtasks:r.recommendedSubtasks,expansionPrompt:r.expansionPrompt,complexityReasoning:r.complexityReasoning}:null}async getComplexityForTasks(e,t){let n=new Map,r=await this.loadReport(t);if(!r)return n;let i=new Map;return r.complexityAnalysis.forEach(e=>{i.set(String(e.taskId),e)}),e.forEach(e=>{let t=i.get(String(e));t&&n.set(String(e),{complexityScore:t.complexityScore,recommendedSubtasks:t.recommendedSubtasks,expansionPrompt:t.expansionPrompt,complexityReasoning:t.complexityReasoning})}),n}clearCache(e){e?this.reportCache.delete(e):this.reportCache.clear()}async hasReport(e){let t=this.getReportPath(e);try{return await _.access(t),!0}catch{return!1}}},Mt=class{formatHandler;fileOps;pathResolver;complexityManager;constructor(e){this.formatHandler=new Et,this.fileOps=new Ot,this.pathResolver=new kt(e),this.complexityManager=new jt(e)}async initialize(){await this.fileOps.ensureDir(this.pathResolver.getTasksDir())}async close(){await this.fileOps.cleanup()}getStorageType(){return`file`}getCurrentBriefName(){return null}async getStats(){let e=this.pathResolver.getTasksPath();try{let t=await this.fileOps.getStats(e),n=await this.fileOps.readJson(e),r=this.formatHandler.extractTags(n),i=0,a=r.map(e=>{let r=this.formatHandler.extractTasks(n,e).length;return i+=r,{tag:e,taskCount:r,lastModified:t.mtime.toISOString()}});return{totalTasks:i,totalTags:r.length,lastModified:t.mtime.toISOString(),storageSize:0,tagStats:a}}catch(e){if(e.code===`ENOENT`)return{totalTasks:0,totalTags:0,lastModified:new Date().toISOString(),storageSize:0,tagStats:[]};throw Error(`Failed to get storage stats: ${e.message}`)}}async loadTasks(e,t){let n=this.pathResolver.getTasksPath(),r=e||`master`;try{let e=await this.fileOps.readJson(n),i=this.formatHandler.extractTasks(e,r);return t&&(t.status&&(i=i.filter(e=>e.status===t.status)),t.excludeSubtasks&&(i=i.map(e=>({...e,subtasks:[]})))),await this.enrichTasksWithComplexity(i,r)}catch(e){if(e.code===`ENOENT`)return[];throw Error(`Failed to load tasks: ${e.message}`)}}async loadTask(e,t){let n=await this.loadTasks(t);if(e.includes(`.`)){let[t,r]=e.split(`.`),i=n.find(e=>String(e.id)===t);if(!i||!i.subtasks)return null;let a=i.subtasks.find(e=>String(e.id)===r);if(!a)return null;let o=e=>{let t=String(e);return t.includes(`.`)?t:`${i.id}.${t}`},s=a.dependencies?.map(e=>o(e))??[];return{...a,id:e,title:a.title||`Subtask ${r}`,description:a.description||``,status:a.status||`pending`,priority:a.priority||i.priority||`medium`,dependencies:s,details:a.details||``,testStrategy:a.testStrategy||``,subtasks:[],tags:i.tags||[],assignee:a.assignee||i.assignee,complexity:a.complexity||i.complexity,createdAt:a.createdAt||i.createdAt,updatedAt:a.updatedAt||i.updatedAt,parentTask:{id:i.id,title:i.title,status:i.status},isSubtask:!0}}return n.find(t=>String(t.id)===String(e))||null}async saveTasks(e,t){let n=this.pathResolver.getTasksPath(),r=t||`master`;await this.fileOps.ensureDir(this.pathResolver.getTasksDir());let i={version:`1.0.0`,lastModified:new Date().toISOString(),taskCount:e.length,completedCount:e.filter(e=>e.status===`done`).length,tags:[r]},a=this.normalizeTaskIds(e);await this.fileOps.modifyJson(n,e=>this.formatHandler.detectFormat(e)===`legacy`||Object.keys(e).some(e=>e!==`tasks`&&e!==`metadata`)?(e[r]={tasks:a,metadata:i},e):r===`master`?{tasks:a,metadata:i}:{master:{tasks:e.tasks||[],metadata:e.metadata||i},[r]:{tasks:a,metadata:i}})}normalizeTaskIds(e){return e.map(e=>({...e,id:String(e.id),dependencies:e.dependencies?.map(e=>String(e))||[],subtasks:e.subtasks?.map(e=>({...e,id:Number(e.id),parentId:String(e.parentId)}))||[]}))}async exists(e){let t=this.pathResolver.getTasksPath();return this.fileOps.exists(t)}async getAllTags(){try{let e=this.pathResolver.getTasksPath(),t=await this.fileOps.readJson(e);return this.formatHandler.extractTags(t)}catch(e){if(e.code===`ENOENT`)return[];throw Error(`Failed to get tags: ${e.message}`)}}async loadMetadata(e){let t=this.pathResolver.getTasksPath(),n=e||`master`;try{let e=await this.fileOps.readJson(t);return this.formatHandler.extractMetadata(e,n)}catch(e){if(e.code===`ENOENT`)return null;throw Error(`Failed to load metadata: ${e.message}`)}}async saveMetadata(e,t){let n=await this.loadTasks(t);await this.saveTasks(n,t)}async appendTasks(e,t){let n=[...await this.loadTasks(t),...e];await this.saveTasks(n,t)}async updateTask(e,t,n){let r=await this.loadTasks(n),i=r.findIndex(t=>String(t.id)===String(e));if(i===-1)throw Error(`Task ${e} not found`);let a=r[i],o=t.subtasks;t.subtasks&&a.subtasks&&(o=t.subtasks.map(e=>{let t=a.subtasks?.find(t=>String(t.id)===String(e.id)||e.title&&t.title===e.title);return t?.metadata||e.metadata?{...e,metadata:{...t?.metadata||{},...e.metadata||{}}}:e})),r[i]={...a,...t,...o&&{subtasks:o},id:String(e)},await this.saveTasks(r,n)}async updateTaskWithPrompt(e,t,n,r){throw Error(`File storage does not support updateTaskWithPrompt. Client-side AI logic must process the prompt before calling updateTask().`)}async expandTaskWithPrompt(e,t,n){throw Error(`File storage does not support expandTaskWithPrompt. Client-side AI logic must process the expansion before calling updateTask().`)}async updateTaskStatus(e,t,n){let r=await this.loadTasks(n);if(e.includes(`.`))return this.updateSubtaskStatusInFile(r,e,t,n);let i=r.findIndex(t=>String(t.id)===String(e));if(i===-1)throw Error(`Task ${e} not found`);let a=r[i].status;return a===t?{success:!0,oldStatus:a,newStatus:t,taskId:String(e)}:(r[i]={...r[i],status:t,updatedAt:new Date().toISOString()},await this.saveTasks(r,n),{success:!0,oldStatus:a,newStatus:t,taskId:String(e)})}async updateSubtaskStatusInFile(e,t,n,r){let i=t.split(`.`);if(i.length!==2)throw Error(`Invalid subtask ID format: ${t}. Expected format: parentId.subtaskId`);let[a,o]=i,s=o.trim();if(!/^\d+$/.test(s))throw Error(`Invalid subtask ID: ${s}. Subtask ID must be a positive integer.`);let c=Number(s),l=e.findIndex(e=>String(e.id)===String(a));if(l===-1)throw Error(`Parent task ${a} not found`);let u=e[l],d=u.subtasks.findIndex(e=>e.id===c||String(e.id)===s);if(d===-1)throw Error(`Subtask ${t} not found in parent task ${a}`);let f=u.subtasks[d].status||`pending`;if(f===n)return{success:!0,oldStatus:f,newStatus:n,taskId:t};let p=new Date().toISOString();u.subtasks[d]={...u.subtasks[d],status:n,updatedAt:p};let m=u.subtasks,h=u.status;if(m.length>0){let e=e=>e.status||`pending`,t=t=>{let n=e(t);return n===`done`||n===`completed`},n=m.every(t),r=m.some(t=>e(t)===`in-progress`),i=m.some(t),a=m.every(t=>e(t)===`pending`);n?h=`done`:r||i?h=`in-progress`:a&&(h=`pending`)}return e[l]={...u,...h===u.status?{}:{status:h},updatedAt:p},await this.saveTasks(e,r),{success:!0,oldStatus:f,newStatus:n,taskId:t}}async deleteTask(e,t){let n=await this.loadTasks(t),r=n.filter(t=>String(t.id)!==String(e));if(r.length===n.length)throw Error(`Task ${e} not found`);await this.saveTasks(r,t)}async createTag(e,t){let n=this.pathResolver.getTasksPath();try{await this.fileOps.modifyJson(n,n=>{if(this.formatHandler.detectFormat(n)===`legacy`){if(e in n)throw new b(`Tag ${e} already exists`,y.VALIDATION_ERROR);let r=[];return t?.copyFrom&&t.copyFrom in n&&n[t.copyFrom].tasks&&(r=JSON.parse(JSON.stringify(n[t.copyFrom].tasks))),n[e]={tasks:r,metadata:{created:new Date().toISOString(),updatedAt:new Date().toISOString(),description:t?.description||`Tag created on ${new Date().toLocaleDateString()}`,tags:[e]}},n}else{let r=n.tasks||[],i=n.metadata||{},a=[];return(t?.copyFrom===`master`||!t?.copyFrom)&&(a=JSON.parse(JSON.stringify(r))),{master:{tasks:r,metadata:{...i,tags:[`master`]}},[e]:{tasks:a,metadata:{created:new Date().toISOString(),updatedAt:new Date().toISOString(),description:t?.description||`Tag created on ${new Date().toLocaleDateString()}`,tags:[e]}}}}})}catch(e){throw e.code===`ENOENT`?Error(`Tasks file not found - initialize project first`):e}}async deleteTag(e){let t=this.pathResolver.getTasksPath();try{let n=!1;await this.fileOps.modifyJson(t,t=>{if(this.formatHandler.detectFormat(t)!==`legacy`&&e===`master`)return n=!0,t;if(this.formatHandler.detectFormat(t)===`legacy`){if(e in t)return delete t[e],t;throw Error(`Tag ${e} not found`)}else throw Error(`Tag ${e} not found in standard format`)}),n&&await this.fileOps.deleteFile(t)}catch(t){throw t.code===`ENOENT`?Error(`Tag ${e} not found - file doesn't exist`):t}}async renameTag(e,t){let n=this.pathResolver.getTasksPath();try{await this.fileOps.modifyJson(n,n=>{if(this.formatHandler.detectFormat(n)===`legacy`){if(e in n)return n[t]=n[e],delete n[e],n[t].metadata&&(n[t].metadata.tags=[t]),n;throw Error(`Tag ${e} not found`)}else if(e===`master`){let e=n.tasks||[],r=n.metadata||{};return{[t]:{tasks:e,metadata:{...r,tags:[t]}}}}else throw Error(`Tag ${e} not found in standard format`)})}catch(t){throw t.code===`ENOENT`?Error(`Tag ${e} not found - file doesn't exist`):t}}async copyTag(e,t){let n=await this.loadTasks(e);if(n.length===0)throw Error(`Source tag ${e} not found or has no tasks`);await this.saveTasks(n,t)}async getTagsWithStats(){let e=await this.getAllTags(),t=await this.getActiveTagFromState(),n=await Promise.all(e.map(async e=>{try{let n=await this.loadTasks(e),r={},i=0,a={totalSubtasks:0,subtasksByStatus:{}};n.forEach(e=>{let t=e.status||`pending`;r[t]=(r[t]||0)+1,t===`done`&&i++,e.subtasks&&e.subtasks.length>0&&(a.totalSubtasks+=e.subtasks.length,e.subtasks.forEach(e=>{let t=e.status||`pending`;a.subtasksByStatus[t]=(a.subtasksByStatus[t]||0)+1}))});let o=await this.loadMetadata(e);return{name:e,isCurrent:e===t,taskCount:n.length,completedTasks:i,statusBreakdown:r,subtaskCounts:a.totalSubtasks>0?a:void 0,created:o?.created,description:o?.description}}catch{return{name:e,isCurrent:e===t,taskCount:0,completedTasks:0,statusBreakdown:{}}}}));return{tags:n,currentTag:t,totalTags:n.length}}async getActiveTagFromState(){try{let e=t.join(this.pathResolver.getBasePath(),`state.json`);return(await this.fileOps.readJson(e))?.currentTag||`master`}catch{return`master`}}async watch(e,t){let n=this.pathResolver.getTasksPath(),r=t?.debounceMs??100;if(!await this.fileOps.exists(n))throw new b(`Tasks file not found. Initialize the project first.`,y.NOT_FOUND,{path:n});let i,a=!1,o=m.watch(n,(t,n)=>{a||n&&t===`change`&&(i&&clearTimeout(i),i=setTimeout(()=>{a||e({type:`change`,timestamp:new Date})},r))});return o.on(`error`,t=>{a||e({type:`error`,timestamp:new Date,error:t})}),{unsubscribe:()=>{a=!0,i&&clearTimeout(i),o.close()}}}async enrichTasksWithComplexity(e,t){let n=e.map(e=>e.id),r=await this.complexityManager.getComplexityForTasks(n,t);return r.size===0?e:e.map(e=>{let t=r.get(String(e.id));return t?{...e,complexity:t.complexityScore,recommendedSubtasks:t.recommendedSubtasks,expansionPrompt:t.expansionPrompt,complexityReasoning:t.complexityReasoning}:e})}},Nt=class{configManager;authManager;constructor(e,t){this.configManager=e,this.authManager=t}async exportTasks(e){if(!await this.authManager.hasValidSession())throw new b(`Authentication required for export`,y.AUTHENTICATION_ERROR);let t=await this.authManager.getContext(),n=e.orgId||t?.orgId,r=e.briefId||t?.briefId;if(!n)throw new b(`Organization ID is required for export. Use "tm context org" to select one.`,y.MISSING_CONFIGURATION);if(!r)throw new b(`Brief ID is required for export. Use "tm context brief" or provide --brief flag.`,y.MISSING_CONFIGURATION);let i=this.configManager.getActiveTag(),a=e.tag||i,o=new Mt(this.configManager.getProjectRoot());await o.initialize();let s=await o.loadTasks(a,{status:e.status,excludeSubtasks:e.excludeSubtasks}),c={tasks:s,total:(await o.loadTasks(a)).length,filtered:s.length,tag:a,storageType:`file`};if(c.tasks.length===0)return{success:!1,taskCount:0,briefId:r,orgId:n,message:`No tasks found to export`,error:{code:`NO_TASKS`,message:`No tasks match the specified criteria`}};try{return await this.performExport(n,r,c.tasks),{success:!0,taskCount:c.tasks.length,briefId:r,orgId:n,message:`Successfully exported ${c.tasks.length} task(s) to brief`}}catch(e){return{success:!1,taskCount:0,briefId:r,orgId:n,error:{code:`EXPORT_FAILED`,message:e instanceof Error?e.message:String(e)}}}}async exportFromBriefInput(e){let t=this.extractBriefId(e);if(!t)throw new b(`Invalid brief ID or URL provided`,y.VALIDATION_ERROR);let n=await this.authManager.getBrief(t);if(!n)throw new b(`Brief not found or you do not have access`,y.NOT_FOUND);return this.exportTasks({orgId:n.accountId,briefId:n.id})}async validateContext(){let e=await this.authManager.getContext();return{hasOrg:!!e?.orgId,hasBrief:!!e?.briefId,context:e}}transformTasksForBulkImport(e){let t=[],n=this.configManager.getResponseLanguage(),r=new Set;for(let t of e)if(r.add(String(t.id)),t.subtasks)for(let e of t.subtasks)r.add(`${t.id}.${e.id}`);return e.forEach(e=>{let i=(e.dependencies||[]).map(String).filter(e=>r.has(e));t.push({externalId:String(e.id),title:e.title,description:this.enrichDescription(e,n),status:this.mapStatusForAPI(e.status),priority:e.priority||`medium`,dependencies:i,details:e.details,testStrategy:e.testStrategy,complexity:e.complexity,metadata:{complexity:e.complexity,originalId:e.id,originalDescription:e.description,originalDetails:e.details,originalTestStrategy:e.testStrategy}}),e.subtasks&&e.subtasks.length>0&&e.subtasks.forEach(i=>{let a=(i.dependencies||[]).map(t=>String(t).includes(`.`)?String(t):`${e.id}.${t}`).filter(e=>r.has(e));t.push({externalId:`${e.id}.${i.id}`,parentExternalId:String(e.id),title:i.title,description:this.enrichDescription(i,n),status:this.mapStatusForAPI(i.status),priority:i.priority||`medium`,dependencies:a,details:i.details,testStrategy:i.testStrategy,complexity:i.complexity,metadata:{complexity:i.complexity,originalId:i.id,originalDescription:i.description,originalDetails:i.details,originalTestStrategy:i.testStrategy}})})}),t}enrichDescription(e,t){let n=[],r=this.isEnglishLanguage(t),i=r?`## Implementation Details
|
|
54
|
+
`:`## 实现细节
|
|
55
|
+
`,a=r?`## Test Strategy
|
|
56
|
+
`:`## 测试策略
|
|
57
|
+
`,o=r?`No description provided`:`未提供描述`;return e.description&&n.push(e.description),e.details&&(n.push(i),n.push(e.details)),e.testStrategy&&(n.push(a),n.push(e.testStrategy)),n.join(`
|
|
56
58
|
|
|
57
|
-
`).trim()||`No description provided`}mapStatusForAPI(e){switch(e){case`pending`:return`todo`;case`in-progress`:return`in_progress`;case`done`:return`done`;default:return`todo`}}async performExport(e,t,n){let r=new k().getApiBaseUrl();if(r){let i=`${r}/ai/api/v1/briefs/${t}/tasks`,a={source:`task-master-cli`,options:{dryRun:!1,stopOnError:!1},accountId:e,tasks:this.transformTasksForBulkImport(n)},o=await this.authManager.getAccessToken();if(!o)throw Error(`Not authenticated`);let s=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${o}`},body:JSON.stringify(a)});if(!s.ok){let e=await s.text();throw Error(`API request failed: ${s.status} - ${e}`)}let c=await s.json();if(c.failedCount>0){let e=c.results.filter(e=>!e.success).map(e=>`${e.externalId}: ${e.error}`).join(`, `);console.warn(`Warning: ${c.failedCount} tasks failed to import: ${e}`)}console.log(`Successfully exported ${c.successCount} of ${c.totalTasks} tasks to brief ${t}`)}else throw Error(`Export API endpoint not configured. Please set TM_PUBLIC_BASE_DOMAIN environment variable to enable task export.`)}extractBriefId(e){let t=e?.trim()??``;if(!t)return null;let n=e=>{try{return new URL(e)}catch{}try{return new URL(`https://${e}`)}catch{}return null},r=e=>{let t=e.split(`/`).filter(Boolean),n=t.lastIndexOf(`briefs`);return(n>=0&&t.length>n+1?t[n+1]:t[t.length-1])?.trim()||null},i=n(t);if(i){let e=(i.searchParams.get(`id`)||i.searchParams.get(`briefId`)||r(i.pathname))??null;if(e&&(this.isLikelyId(e)||e.length>=8))return e}if(t.includes(`/`)){let e=r(t);if(e&&(this.isLikelyId(e)||e.length>=8))return e}return this.isLikelyId(t)||t.length>=8?t:null}isLikelyId(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)||/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e)||/^[A-Za-z0-9_-]{16,}$/.test(e)}async generateBriefFromTasks(e={}){if(!await this.authManager.hasValidSession())throw new b(`Authentication required for export`,y.AUTHENTICATION_ERROR);let t=await this.authManager.getContext(),n=e.orgId||t?.orgId;if(!n){let e=await this.authManager.getOrganizations();if(e.length===0)return{success:!1,error:{code:`NO_ORGANIZATIONS`,message:`No organizations available. Please create an organization in Hamster first.`}};n=e[0].id}let r=this.configManager.getActiveTag(),i=e.tag||r,a=new Mt(this.configManager.getProjectRoot());await a.initialize();let o=await a.loadTasks(i,{status:e.status,excludeSubtasks:e.excludeSubtasks});if(o.length===0)return{success:!1,error:{code:`NO_TASKS`,message:`No tasks found to export`}};let s=this.transformTasksForImport(o),c=this.getProjectName();return this.callGenerateBriefEndpoint({tasks:s,source:{tool:`task-master`,version:this.getVersion(),tag:i,projectName:c},orgId:n,options:e.options})}transformTasksForImport(e){let t=[],n=new Set;for(let t of e)if(n.add(String(t.id)),t.subtasks)for(let e of t.subtasks)n.add(`${t.id}.${e.id}`);for(let r of e){let e=(r.dependencies||[]).map(String).filter(e=>n.has(e));if(t.push({externalId:String(r.id),title:r.title,description:this.enrichDescription(r),details:r.details,status:this.mapStatusForImport(r.status),priority:this.mapPriorityForImport(r.priority),dependencies:e,metadata:{originalStatus:r.status,originalPriority:r.priority,testStrategy:r.testStrategy,complexity:r.complexity}}),r.subtasks&&r.subtasks.length>0)for(let e of r.subtasks){let i=(e.dependencies||[]).map(e=>String(e).includes(`.`)?String(e):`${r.id}.${e}`).filter(e=>n.has(e));t.push({externalId:`${r.id}.${e.id}`,parentId:String(r.id),title:e.title,description:this.enrichDescription(e),details:e.details,status:this.mapStatusForImport(e.status),priority:this.mapPriorityForImport(e.priority),dependencies:i,metadata:{originalStatus:e.status,originalPriority:e.priority,testStrategy:e.testStrategy,complexity:e.complexity}})}}return t}mapStatusForImport(e){switch(e){case`pending`:return`todo`;case`in-progress`:case`in_progress`:return`in_progress`;case`done`:case`completed`:return`done`;case`blocked`:return`blocked`;default:return`todo`}}mapPriorityForImport(e){switch(e?.toLowerCase()){case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;case`critical`:case`urgent`:return`urgent`;default:return`medium`}}getVersion(){try{return process.env.npm_package_version||`1.0.0`}catch{return`1.0.0`}}getProjectName(){try{return this.configManager.getProjectRoot().split(/[/\\]/).pop()||void 0}catch{return}}async callGenerateBriefEndpoint(e){let t=new k().getApiBaseUrl();if(!t)throw new b(`Export API endpoint not configured. Please set TM_PUBLIC_BASE_DOMAIN environment variable.`,y.MISSING_CONFIGURATION,{operation:`generateBriefFromTasks`});let n=`${t}/ai/api/v1/briefs/generate-from-tasks`,r=await this.authManager.getAccessToken();if(!r)throw new b(`Not authenticated`,y.AUTHENTICATION_ERROR);let i=e.orgId;if(!i)return{success:!1,error:{code:`MISSING_ACCOUNT`,message:`No organization selected. Please run "tm auth" and select an organization first.`}};let a={tasks:e.tasks,source:e.source,accountId:i,options:{generateTitle:e.options?.generateTitle??!0,generateDescription:e.options?.generateDescription??!0,preserveHierarchy:e.options?.preserveHierarchy??!0,preserveDependencies:e.options?.preserveDependencies??!0,title:e.options?.title,description:e.options?.description}};try{let e=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,"x-account-id":i},body:JSON.stringify(a)});if(!(e.headers.get(`content-type`)||``).includes(`application/json`)){let t=await e.text();return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status}): ${t.substring(0,100)}...`}}}let t=await e.json(),o=t;if(!e.ok||!o.success){let n=o.error?.message||t?.message||t?.error||`API request failed: ${e.status} - ${e.statusText}`,r=o.error?.code||t?.code||t?.statusCode||`API_ERROR`;return{success:!1,warnings:o.warnings,error:{code:String(r),message:String(n)}}}return{success:!0,brief:o.brief,taskMapping:o.taskMapping,invitations:o.invitations,warnings:o.warnings}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to connect to API: ${e instanceof Error?e.message:String(e)}`}}}}async generateBriefFromPrd(e){if(!e.prdContent||e.prdContent.trim().length===0)return{success:!1,error:{code:`INVALID_INPUT`,message:`PRD content is required`}};if(!await this.authManager.hasValidSession())throw new b(`Authentication required for PRD import`,y.AUTHENTICATION_ERROR);let t=await this.authManager.getContext(),n=e.orgId||t?.orgId;if(!n){let e=await this.authManager.getOrganizations();if(e.length===0)return{success:!1,error:{code:`NO_ORGANIZATIONS`,message:`No organizations available. Please create an organization in Hamster first.`}};n=e[0].id}return this.callGenerateBriefFromPrdEndpoint({prdContent:e.prdContent,orgId:n,options:e.options})}async callGenerateBriefFromPrdEndpoint(e){let t=new k().getApiBaseUrl();if(!t)throw new b(`API endpoint not configured. Please set TM_PUBLIC_BASE_DOMAIN environment variable.`,y.MISSING_CONFIGURATION,{operation:`generateBriefFromPrd`});let n=`${t}/ai/api/v1/briefs/generate-from-prd`,r=await this.authManager.getAccessToken();if(!r)throw new b(`Not authenticated`,y.AUTHENTICATION_ERROR);let i=e.orgId;if(!i)return{success:!1,error:{code:`MISSING_ACCOUNT`,message:`No organization selected. Please run "tm auth" and select an organization first.`}};let a={prdContent:e.prdContent,accountId:i,options:{generateTitle:e.options?.generateTitle??!0,generateDescription:e.options?.generateDescription??!0,title:e.options?.title,description:e.options?.description}};try{let e=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,"x-account-id":i},body:JSON.stringify(a)});if(!(e.headers.get(`content-type`)||``).includes(`application/json`)){let t=await e.text();return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status}): ${t.substring(0,100)}...`}}}let t=await e.json(),o=t;if(!e.ok||!o.success){let n=o.error?.message||t?.message||t?.error||`API request failed: ${e.status} - ${e.statusText}`,r=o.error?.code||t?.code||t?.statusCode||`API_ERROR`;return{success:!1,error:{code:String(r),message:String(n)}}}return{success:!0,brief:o.brief,orgId:i,jobId:o.jobId,invitations:o.invitations}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to connect to API: ${e instanceof Error?e.message:String(e)}`}}}}async getBriefStatus(e){if(!await this.authManager.hasValidSession())return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Authentication required`}};let t=new k().getApiBaseUrl();if(!t)return{success:!1,error:{code:`MISSING_CONFIGURATION`,message:`API endpoint not configured`}};let n=`${t}/ai/api/v1/briefs/${e}/status`,r=await this.authManager.getAccessToken();if(!r)return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Not authenticated`}};let i=(await this.authManager.getContext())?.orgId;if(!i){let e=await this.authManager.getOrganizations();e.length>0&&(i=e[0].id)}if(!i)return{success:!1,error:{code:`MISSING_ACCOUNT`,message:`No organization available`}};try{let e=await fetch(n,{method:`GET`,headers:{Authorization:`Bearer ${r}`,"x-account-id":i}});if(!(e.headers.get(`content-type`)||``).includes(`application/json`))return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status})`}};let t=await e.json();return e.ok?{success:!0,status:t}:{success:!1,error:{code:`API_ERROR`,message:t?.message||`Failed to get status: ${e.status}`}}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to get brief status: ${e instanceof Error?e.message:String(e)}`}}}}async sendTeamInvitations(e,t,n=`member`){if(!await this.authManager.hasValidSession())return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Authentication required`}};let r=new k().getApiBaseUrl();if(!r)return{success:!1,error:{code:`MISSING_CONFIGURATION`,message:`API endpoint not configured`}};let i=`${r}/api/teams/${e}/invitations`,a=await this.authManager.getAccessToken();if(!a)return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Not authenticated`}};try{let e=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${a}`},body:JSON.stringify({emails:t.slice(0,10),role:n})});if(!(e.headers.get(`content-type`)||``).includes(`application/json`))return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status})`}};let r=await e.json(),o=r.data,s=r.invitations||o?.invitations||o||(Array.isArray(r)?r:null),c=r.error;if(e.ok&&s&&Array.isArray(s))return{success:!0,invitations:s.map(e=>({email:e.email||``,status:e.status||`sent`}))};if(!e.ok||c){let n=typeof c==`object`&&c?c:null;return s&&Array.isArray(s)&&s.length>0&&s.every(e=>e.status===`already_member`)||n?.code===`invitation_failed`&&n?.message?.toLowerCase().includes(`already member`)?{success:!0,invitations:Array.isArray(s)?s:t.map(e=>({email:e,status:`already_member`}))}:{success:!1,error:{code:`API_ERROR`,message:r.message||(typeof c==`string`?c:n?.message||JSON.stringify(c))||`Failed to send invitations: ${e.status}`}}}return{success:!1,error:{code:`INVALID_RESPONSE`,message:`No invitations in response`}}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to send invitations: ${e instanceof Error?e.message:String(e)}`}}}}},Pt=class{exportService;constructor(e){this.exportService=new Nt(e,O.getInstance())}async generateBriefFromTasks(e){return this.exportService.generateBriefFromTasks(e)}async exportTasks(e){return this.exportService.exportTasks(e)}async generateBriefFromPrd(e){return this.exportService.generateBriefFromPrd(e)}async getBriefStatus(e){return this.exportService.getBriefStatus(e)}async sendTeamInvitations(e,t,n=`member`){return this.exportService.sendTeamInvitations(e,t,n)}};const Ft={default:`SETUP: If task-master command not found, run: npm i -g task-master-ai
|
|
59
|
+
`).trim()||o}isEnglishLanguage(e){let t=(e||this.configManager.getResponseLanguage()||``).trim().toLowerCase();return t===`english`||t===`en`||t.startsWith(`english-`)||t.startsWith(`en-`)}mapStatusForAPI(e){switch(e){case`pending`:return`todo`;case`in-progress`:return`in_progress`;case`done`:return`done`;default:return`todo`}}async performExport(e,t,n){let r=new k().getApiBaseUrl();if(r){let i=`${r}/ai/api/v1/briefs/${t}/tasks`,a={source:`task-master-cli`,options:{dryRun:!1,stopOnError:!1},accountId:e,tasks:this.transformTasksForBulkImport(n)},o=await this.authManager.getAccessToken();if(!o)throw Error(`Not authenticated`);let s=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${o}`},body:JSON.stringify(a)});if(!s.ok){let e=await s.text();throw Error(`API request failed: ${s.status} - ${e}`)}let c=await s.json();if(c.failedCount>0){let e=c.results.filter(e=>!e.success).map(e=>`${e.externalId}: ${e.error}`).join(`, `);console.warn(`Warning: ${c.failedCount} tasks failed to import: ${e}`)}console.log(`Successfully exported ${c.successCount} of ${c.totalTasks} tasks to brief ${t}`)}else throw Error(`Export API endpoint not configured. Please set TM_PUBLIC_BASE_DOMAIN environment variable to enable task export.`)}extractBriefId(e){let t=e?.trim()??``;if(!t)return null;let n=e=>{try{return new URL(e)}catch{}try{return new URL(`https://${e}`)}catch{}return null},r=e=>{let t=e.split(`/`).filter(Boolean),n=t.lastIndexOf(`briefs`);return(n>=0&&t.length>n+1?t[n+1]:t[t.length-1])?.trim()||null},i=n(t);if(i){let e=(i.searchParams.get(`id`)||i.searchParams.get(`briefId`)||r(i.pathname))??null;if(e&&(this.isLikelyId(e)||e.length>=8))return e}if(t.includes(`/`)){let e=r(t);if(e&&(this.isLikelyId(e)||e.length>=8))return e}return this.isLikelyId(t)||t.length>=8?t:null}isLikelyId(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)||/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e)||/^[A-Za-z0-9_-]{16,}$/.test(e)}async generateBriefFromTasks(e={}){if(!await this.authManager.hasValidSession())throw new b(`Authentication required for export`,y.AUTHENTICATION_ERROR);let t=await this.authManager.getContext(),n=e.orgId||t?.orgId;if(!n){let e=await this.authManager.getOrganizations();if(e.length===0)return{success:!1,error:{code:`NO_ORGANIZATIONS`,message:`No organizations available. Please create an organization in Hamster first.`}};n=e[0].id}let r=this.configManager.getActiveTag(),i=e.tag||r,a=new Mt(this.configManager.getProjectRoot());await a.initialize();let o=await a.loadTasks(i,{status:e.status,excludeSubtasks:e.excludeSubtasks});if(o.length===0)return{success:!1,error:{code:`NO_TASKS`,message:`No tasks found to export`}};let s=this.transformTasksForImport(o),c=this.getProjectName();return this.callGenerateBriefEndpoint({tasks:s,source:{tool:`task-master`,version:this.getVersion(),tag:i,projectName:c},orgId:n,responseLanguage:e.options?.language||this.configManager.getResponseLanguage(),options:e.options})}transformTasksForImport(e){let t=[],n=this.configManager.getResponseLanguage(),r=new Set;for(let t of e)if(r.add(String(t.id)),t.subtasks)for(let e of t.subtasks)r.add(`${t.id}.${e.id}`);for(let i of e){let e=(i.dependencies||[]).map(String).filter(e=>r.has(e));if(t.push({externalId:String(i.id),title:i.title,description:this.enrichDescription(i,n),details:i.details,status:this.mapStatusForImport(i.status),priority:this.mapPriorityForImport(i.priority),dependencies:e,metadata:{originalStatus:i.status,originalPriority:i.priority,testStrategy:i.testStrategy,complexity:i.complexity}}),i.subtasks&&i.subtasks.length>0)for(let e of i.subtasks){let a=(e.dependencies||[]).map(e=>String(e).includes(`.`)?String(e):`${i.id}.${e}`).filter(e=>r.has(e));t.push({externalId:`${i.id}.${e.id}`,parentId:String(i.id),title:e.title,description:this.enrichDescription(e,n),details:e.details,status:this.mapStatusForImport(e.status),priority:this.mapPriorityForImport(e.priority),dependencies:a,metadata:{originalStatus:e.status,originalPriority:e.priority,testStrategy:e.testStrategy,complexity:e.complexity}})}}return t}mapStatusForImport(e){switch(e){case`pending`:return`todo`;case`in-progress`:case`in_progress`:return`in_progress`;case`done`:case`completed`:return`done`;case`blocked`:return`blocked`;default:return`todo`}}mapPriorityForImport(e){switch(e?.toLowerCase()){case`low`:return`low`;case`medium`:return`medium`;case`high`:return`high`;case`critical`:case`urgent`:return`urgent`;default:return`medium`}}getVersion(){try{return process.env.npm_package_version||`1.0.0`}catch{return`1.0.0`}}getProjectName(){try{return this.configManager.getProjectRoot().split(/[/\\]/).pop()||void 0}catch{return}}async callGenerateBriefEndpoint(e){let t=new k().getApiBaseUrl();if(!t)throw new b(`Export API endpoint not configured. Please set TM_PUBLIC_BASE_DOMAIN environment variable.`,y.MISSING_CONFIGURATION,{operation:`generateBriefFromTasks`});let n=`${t}/ai/api/v1/briefs/generate-from-tasks`,r=await this.authManager.getAccessToken();if(!r)throw new b(`Not authenticated`,y.AUTHENTICATION_ERROR);let i=e.orgId;if(!i)return{success:!1,error:{code:`MISSING_ACCOUNT`,message:`No organization selected. Please run "tm auth" and select an organization first.`}};let a={tasks:e.tasks,source:e.source,accountId:i,options:{generateTitle:e.options?.generateTitle??!0,generateDescription:e.options?.generateDescription??!0,preserveHierarchy:e.options?.preserveHierarchy??!0,preserveDependencies:e.options?.preserveDependencies??!0,title:e.options?.title,description:e.options?.description,language:this.isEnglishLanguage(e.responseLanguage)?`English`:`Chinese`}};try{let e={"Content-Type":`application/json`,Authorization:`Bearer ${r}`,"x-account-id":i},t=await fetch(n,{method:`POST`,headers:e,body:JSON.stringify(a)}),o;if(!t.ok&&t.status===400){let r=await t.text();o=r;let i=r.toLowerCase();if(i.includes(`language`)&&(i.includes(`additional`)||i.includes(`schema`)||i.includes(`unknown`))){let r={...a,options:{...a.options}};delete r.options.language,t=await fetch(n,{method:`POST`,headers:e,body:JSON.stringify(r)}),o=void 0}}if(!(t.headers.get(`content-type`)||``).includes(`application/json`)){let e=o||await t.text();return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${t.status}): ${e.substring(0,100)}...`}}}let s=o?JSON.parse(o):await t.json(),c=s;if(!t.ok||!c.success){let e=c.error?.message||s?.message||s?.error||`API request failed: ${t.status} - ${t.statusText}`,n=c.error?.code||s?.code||s?.statusCode||`API_ERROR`;return{success:!1,warnings:c.warnings,error:{code:String(n),message:String(e)}}}return{success:!0,brief:c.brief,taskMapping:c.taskMapping,invitations:c.invitations,warnings:c.warnings}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to connect to API: ${e instanceof Error?e.message:String(e)}`}}}}async generateBriefFromPrd(e){if(!e.prdContent||e.prdContent.trim().length===0)return{success:!1,error:{code:`INVALID_INPUT`,message:`PRD content is required`}};if(!await this.authManager.hasValidSession())throw new b(`Authentication required for PRD import`,y.AUTHENTICATION_ERROR);let t=await this.authManager.getContext(),n=e.orgId||t?.orgId;if(!n){let e=await this.authManager.getOrganizations();if(e.length===0)return{success:!1,error:{code:`NO_ORGANIZATIONS`,message:`No organizations available. Please create an organization in Hamster first.`}};n=e[0].id}return this.callGenerateBriefFromPrdEndpoint({prdContent:e.prdContent,orgId:n,options:e.options})}async callGenerateBriefFromPrdEndpoint(e){let t=new k().getApiBaseUrl();if(!t)throw new b(`API endpoint not configured. Please set TM_PUBLIC_BASE_DOMAIN environment variable.`,y.MISSING_CONFIGURATION,{operation:`generateBriefFromPrd`});let n=`${t}/ai/api/v1/briefs/generate-from-prd`,r=await this.authManager.getAccessToken();if(!r)throw new b(`Not authenticated`,y.AUTHENTICATION_ERROR);let i=e.orgId;if(!i)return{success:!1,error:{code:`MISSING_ACCOUNT`,message:`No organization selected. Please run "tm auth" and select an organization first.`}};let a={prdContent:e.prdContent,accountId:i,options:{generateTitle:e.options?.generateTitle??!0,generateDescription:e.options?.generateDescription??!0,title:e.options?.title,description:e.options?.description}};try{let e=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${r}`,"x-account-id":i},body:JSON.stringify(a)});if(!(e.headers.get(`content-type`)||``).includes(`application/json`)){let t=await e.text();return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status}): ${t.substring(0,100)}...`}}}let t=await e.json(),o=t;if(!e.ok||!o.success){let n=o.error?.message||t?.message||t?.error||`API request failed: ${e.status} - ${e.statusText}`,r=o.error?.code||t?.code||t?.statusCode||`API_ERROR`;return{success:!1,error:{code:String(r),message:String(n)}}}return{success:!0,brief:o.brief,orgId:i,jobId:o.jobId,invitations:o.invitations}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to connect to API: ${e instanceof Error?e.message:String(e)}`}}}}async getBriefStatus(e){if(!await this.authManager.hasValidSession())return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Authentication required`}};let t=new k().getApiBaseUrl();if(!t)return{success:!1,error:{code:`MISSING_CONFIGURATION`,message:`API endpoint not configured`}};let n=`${t}/ai/api/v1/briefs/${e}/status`,r=await this.authManager.getAccessToken();if(!r)return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Not authenticated`}};let i=(await this.authManager.getContext())?.orgId;if(!i){let e=await this.authManager.getOrganizations();e.length>0&&(i=e[0].id)}if(!i)return{success:!1,error:{code:`MISSING_ACCOUNT`,message:`No organization available`}};try{let e=await fetch(n,{method:`GET`,headers:{Authorization:`Bearer ${r}`,"x-account-id":i}});if(!(e.headers.get(`content-type`)||``).includes(`application/json`))return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status})`}};let t=await e.json();return e.ok?{success:!0,status:t}:{success:!1,error:{code:`API_ERROR`,message:t?.message||`Failed to get status: ${e.status}`}}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to get brief status: ${e instanceof Error?e.message:String(e)}`}}}}async sendTeamInvitations(e,t,n=`member`){if(!await this.authManager.hasValidSession())return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Authentication required`}};let r=new k().getApiBaseUrl();if(!r)return{success:!1,error:{code:`MISSING_CONFIGURATION`,message:`API endpoint not configured`}};let i=`${r}/api/teams/${e}/invitations`,a=await this.authManager.getAccessToken();if(!a)return{success:!1,error:{code:`AUTH_REQUIRED`,message:`Not authenticated`}};try{let e=await fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${a}`},body:JSON.stringify({emails:t.slice(0,10),role:n})});if(!(e.headers.get(`content-type`)||``).includes(`application/json`))return{success:!1,error:{code:`API_ERROR`,message:`API returned non-JSON response (${e.status})`}};let r=await e.json(),o=r.data,s=r.invitations||o?.invitations||o||(Array.isArray(r)?r:null),c=r.error;if(e.ok&&s&&Array.isArray(s))return{success:!0,invitations:s.map(e=>({email:e.email||``,status:e.status||`sent`}))};if(!e.ok||c){let n=typeof c==`object`&&c?c:null;return s&&Array.isArray(s)&&s.length>0&&s.every(e=>e.status===`already_member`)||n?.code===`invitation_failed`&&n?.message?.toLowerCase().includes(`already member`)?{success:!0,invitations:Array.isArray(s)?s:t.map(e=>({email:e,status:`already_member`}))}:{success:!1,error:{code:`API_ERROR`,message:r.message||(typeof c==`string`?c:n?.message||JSON.stringify(c))||`Failed to send invitations: ${e.status}`}}}return{success:!1,error:{code:`INVALID_RESPONSE`,message:`No invitations in response`}}}catch(e){return{success:!1,error:{code:`NETWORK_ERROR`,message:`Failed to send invitations: ${e instanceof Error?e.message:String(e)}`}}}}},Pt=class{exportService;constructor(e){this.exportService=new Nt(e,O.getInstance())}async generateBriefFromTasks(e){return this.exportService.generateBriefFromTasks(e)}async exportTasks(e){return this.exportService.exportTasks(e)}async generateBriefFromPrd(e){return this.exportService.generateBriefFromPrd(e)}async getBriefStatus(e){return this.exportService.getBriefStatus(e)}async sendTeamInvitations(e,t,n=`member`){return this.exportService.sendTeamInvitations(e,t,n)}};const Ft={default:`SETUP: If task-master command not found, run: npm i -g task-master-ai
|
|
58
60
|
|
|
59
61
|
TASK: Implement ONE task/subtask from the Taskmaster backlog.
|
|
60
62
|
|