ai-projects 1.0.0 → 1.0.1
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/index.js +11 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {z}from'zod';import {parser}from'zod-opts';import {exec,spawn}from'child_process';import _ from'fs/promises';import j from'lodash';import H from'moment';import R from'path';import {fileURLToPath}from'url';import {inspect}from'util';import De from'dotenv';import ve from'fs';import Oe from'os';import ut from'yaml';var Te=Object.defineProperty;var g=(t,e)=>()=>(t&&(e=t(t=0)),e);var
|
|
2
|
+
import {z}from'zod';import {parser}from'zod-opts';import {exec,spawn}from'child_process';import _ from'fs/promises';import j from'lodash';import H from'moment';import R from'path';import {fileURLToPath}from'url';import {inspect}from'util';import De from'dotenv';import ve from'fs';import Oe from'os';import ut from'yaml';var Te=Object.defineProperty;var g=(t,e)=>()=>(t&&(e=t(t=0)),e);var be=(t,e)=>{for(var o in e)Te(t,o,{get:e[o],enumerable:true});};function p(t){let{description:e,options:o=z.object({}),args:r,handler:n}=t,i=o.shape,a={};for(let[l,u]of Object.entries(i))a[l]={type:u};let m=parser().options(a);if(r){let l=r.shape,u=Object.entries(l).map(([h,k])=>({name:h,type:k}));u.length>0&&(m=m.args(u));}return e&&(m=m.description(e)),{description:e,options:o,args:r,parser:m,handler:n,cli:l=>n(m.parse(l))}}var f=g(()=>{});var T,s,w=g(()=>{T={REPO:fileURLToPath(import.meta.url.replace(/\/(dist|src)\/.*/,"/")),join:(...t)=>R.join(...t),onRepo:(...t)=>T.join(T.REPO,...t),async ensureDir(t){await _.mkdir(t,{recursive:true});},async write(t,e){await T.ensureDir(R.dirname(t)),await _.writeFile(t,e,"utf8");},async read(t){return _.readFile(t,"utf8")},async readRepo(...t){return T.read(T.onRepo(...t))},async readMany(...t){return (await Promise.all(t.map(async o=>{if(await T.fileExists(o)){let r=await T.read(o);return `# ${o}
|
|
3
3
|
|
|
4
4
|
${r}`}return ""}))).filter(Boolean)},async logFiles(...t){let e=await T.readMany(...t);console.log(e.join(`
|
|
5
5
|
|
|
@@ -9,13 +9,13 @@ ${r}`}return ""}))).filter(Boolean)},async logFiles(...t){let e=await T.readMany
|
|
|
9
9
|
`).replace(/\r/g,"").replace(/[ \t]*\n[ \t]*/g,`
|
|
10
10
|
`).replace(/\n{3,}/g,`
|
|
11
11
|
|
|
12
|
-
`).replace(/ {2,}/g," ").trim(),oneLine:t=>t.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/ +/g," ").trim(),fuzzySearch:(t,e)=>j.includes(j.toLower(t||""),j.toLower(e||"")),elapsed:(t,e=Date.now())=>H.duration(H(e).diff(t||0)),iso:t=>H.utc(t).toISOString(),isoDate:t=>T.iso(t).slice(0,10),memoizeKey:(...t)=>t.join(""),exit:(t=0)=>{process.exit(t);},set:(t,e,o)=>(t[e]=o,t),run:async t=>{try{await t(),process.exit(0);}catch(e){console.error(e),process.exit(1);}},isMain:()=>{let t=process.argv[1]||"";return t.includes("/index.")||t.endsWith("/bin/aip")},errorMessage:t=>t instanceof Error?t.message:String(t),slugify:t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")},s=T;});var c,E=g(()=>{c={dirs:{PROJECTS:"projects",SKILLS:"skills",AGENTS:"agents",TASKS:"tasks",INPUTS:"inputs",OUTPUTS:"outputs",HOOKS:"hooks"},files:{MAIN:"main.md",STATUS:"status.md",LOG:"audit.log",SKILL:"SKILL.md"},hookTypes:["pre-create","post-create","pre-complete","post-complete","pre-start","post-start","pre-update","post-update"],languages:["ts","js","sh","py"],targets:["project","task"]};});function Ne(t,e){return process.env[t]??e}var Ce,dt,D,Re,y,O=g(()=>{Ce=()=>{let t=fileURLToPath(import.meta.url),e=R.dirname(t),o=10;for(let r=0;r<o;r++)try{if(ve.existsSync(R.join(e,"package.json")))return e;let n=R.dirname(e);if(n===e)break;e=n;}catch{break}return process.cwd()};dt=Ce(),D=process.env.AIP_HOME;D||(De.config({path:R.join(dt,".env"),quiet:true}),D=process.env.AIP_HOME
|
|
12
|
+
`).replace(/ {2,}/g," ").trim(),oneLine:t=>t.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/ +/g," ").trim(),fuzzySearch:(t,e)=>j.includes(j.toLower(t||""),j.toLower(e||"")),elapsed:(t,e=Date.now())=>H.duration(H(e).diff(t||0)),iso:t=>H.utc(t).toISOString(),isoDate:t=>T.iso(t).slice(0,10),memoizeKey:(...t)=>t.join(""),exit:(t=0)=>{process.exit(t);},set:(t,e,o)=>(t[e]=o,t),run:async t=>{try{await t(),process.exit(0);}catch(e){console.error(e),process.exit(1);}},isMain:()=>{let t=process.argv[1]||"";return t.includes("/index.")||t.endsWith("/bin/aip")},errorMessage:t=>t instanceof Error?t.message:String(t),slugify:t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")},s=T;});var c,E=g(()=>{c={dirs:{PROJECTS:"projects",SKILLS:"skills",AGENTS:"agents",TASKS:"tasks",INPUTS:"inputs",OUTPUTS:"outputs",HOOKS:"hooks"},files:{MAIN:"main.md",STATUS:"status.md",LOG:"audit.log",SKILL:"SKILL.md"},hookTypes:["pre-create","post-create","pre-complete","post-complete","pre-start","post-start","pre-update","post-update"],languages:["ts","js","sh","py"],targets:["project","task"]};});function Ne(t,e){return process.env[t]??e}var Ce,dt,D,Re,y,O=g(()=>{Ce=()=>{let t=fileURLToPath(import.meta.url),e=R.dirname(t),o=10;for(let r=0;r<o;r++)try{if(ve.existsSync(R.join(e,"package.json")))return e;let n=R.dirname(e);if(n===e)break;e=n;}catch{break}return process.cwd()};dt=Ce(),D=process.env.AIP_HOME;D||(De.config({path:R.join(dt,".env"),quiet:true}),D=process.env.AIP_HOME);D?.startsWith("~")&&(D=R.join(Oe.homedir(),D.slice(1)));(!D||!R.isAbsolute(D))&&(console.error("AIP_HOME env var must be set and be an absolute path",D),process.exit(1));Re={ROOT:dt,AIP_HOME:D,NODE_ENV:Ne("NODE_ENV","development")},y=Re;});var gt,L,et,M,ft=g(()=>{w();gt=t=>{let e=t.trim();if(!e.startsWith("---"))return null;let o=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);return o?{frontmatter:ut.parse(o[1]),content:o[2].trim()}:null},L=async(t,e,o="")=>{let n=`---
|
|
13
13
|
${ut.stringify(e).trim()}
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
${o}`.trim();await s.write(t,n+`
|
|
17
|
-
`);},et=async(t,e)=>{let o=await s.read(t),r=gt(o);if(!r)throw new Error(`No frontmatter found in ${t}`);let n={...r.frontmatter,...e};return await L(t,n,r.content),n},M=async t=>{let e=await s.read(t),o=gt(e);if(!o)throw new Error(`No frontmatter found in ${t}`);return o.frontmatter};});var Ie,d,P=g(()=>{E();O();ft();
|
|
18
|
-
Expected at: ${o}`);console.log(e);}});});var xt,St=g(()=>{E();f();O();
|
|
17
|
+
`);},et=async(t,e)=>{let o=await s.read(t),r=gt(o);if(!r)throw new Error(`No frontmatter found in ${t}`);let n={...r.frontmatter,...e};return await L(t,n,r.content),n},M=async t=>{let e=await s.read(t),o=gt(e);if(!o)throw new Error(`No frontmatter found in ${t}`);return o.frontmatter};});var Ie,d,P=g(()=>{E();O();ft();w();Ie={getProjectDir(t){return s.join(y.AIP_HOME,c.dirs.PROJECTS,t)},getTaskDir(t,e){return s.join(this.getProjectDir(t),c.dirs.TASKS,e)},getAgentDir(t){return s.join(y.AIP_HOME,c.dirs.AGENTS,t)},async listProjects(){let t=s.join(y.AIP_HOME,c.dirs.PROJECTS),e=await s.listDir(t),o=[];for(let r of e){let n=this.getProjectDir(r);await s.fileExists(n)&&r!==c.dirs.AGENTS&&o.push(r);}return o},async listTasks(t){let e=s.join(this.getProjectDir(t),c.dirs.TASKS);return await s.fileExists(e)?await s.listDir(e):[]},async listAgents(){let t=s.join(y.AIP_HOME,c.dirs.AGENTS);return await s.fileExists(t)?await s.listDir(t):[]},async createProject(t,e){let o=this.getProjectDir(t);return await s.ensureDir(o),await s.ensureDir(s.join(o,c.dirs.TASKS)),await s.ensureDir(s.join(o,c.dirs.HOOKS)),await L(s.join(o,c.files.MAIN),e),await s.write(s.join(o,c.files.STATUS),""),o},async createTask(t,e,o){let r=this.getTaskDir(t,e);return await s.ensureDir(r),await s.ensureDir(s.join(r,c.dirs.HOOKS)),await L(s.join(r,c.files.MAIN),o),await s.write(s.join(r,c.files.STATUS),""),r},async createAgent(t,e){let o=this.getAgentDir(t);return await s.ensureDir(o),await L(s.join(o,c.files.MAIN),e),o},async getProject(t){let e=s.join(this.getProjectDir(t),c.files.MAIN);return await s.fileExists(e)?await M(e):null},async getTask(t,e){let o=s.join(this.getTaskDir(t,e),c.files.MAIN);return await s.fileExists(o)?await M(o):null},async getAgent(t){let e=s.join(this.getAgentDir(t),c.files.MAIN);return await s.fileExists(e)?await M(e):null},async updateProject(t,e){let o=s.join(this.getProjectDir(t),c.files.MAIN);return await et(o,e)},async updateTask(t,e,o){let r=s.join(this.getTaskDir(t,e),c.files.MAIN);if((await M(r))?.status==="ongoing")throw new Error("Cannot update ongoing task. Should be done by user or update manually");return await et(r,o)},async ingestTask(t,e){let o=this.getTaskDir(t,e),r=this.getProjectDir(t),n=[s.join(r,c.files.MAIN),s.join(o,c.files.MAIN),s.join(o,c.files.STATUS)];await s.logFiles(...n);},async ingestProject(t){let e=this.getProjectDir(t),o=[s.join(e,c.files.MAIN),s.join(e,c.files.STATUS)],r=await this.listTasks(t);for(let n of r)o.push(s.join(this.getTaskDir(t,n),c.files.MAIN));await s.logFiles(...o);},async ingestFiles(t){await s.logFiles(...t);}},d=Ie;});var yt,kt=g(()=>{f();w();P();yt=p({options:z.object({description:z.string().describe("Agent description"),status:z.string().default("active").describe("Initial status")}),args:z.object({name:z.string().describe("Agent name")}),handler:async({name:t,description:e,status:o})=>{let r=s.slugify(t);await d.createAgent(r,{name:t,description:e,status:o,created:new Date().toISOString()}),console.log(`Agent created: ${r}`),console.log(` Path: ${d.getAgentDir(r)}`);}});});var ht,jt=g(()=>{f();ht=p({options:z.object({}),handler:async()=>{let t=process.env.CURRENT_AGENT;t||(console.error("CURRENT_AGENT not set"),process.exit(1)),console.log(t);}});});var Tt,bt=g(()=>{f();P();Tt=p({options:z.object({}),handler:async()=>{let t=await d.listAgents(),e=[];for(let o of t){let r=await d.getAgent(o);r&&e.push({slug:o,name:r.name||o,status:r.status,description:r.description});}if(e.length===0){console.log("No agents found");return}console.log("Agents:"),console.log("---");for(let o of e)console.log(`${o.slug.padEnd(20)} ${o.name?.padEnd(30)||""} ${o.status||""} ${o.description||""}`);}});});var wt,Pt=g(()=>{E();f();O();w();wt=p({description:"Output agent directory path (for cd)",options:z.object({}),args:z.object({name:z.string().describe("Agent name (directory name)")}),handler:async({name:t})=>{let e=s.join(y.AIP_HOME,c.dirs.AGENTS,t),o=s.join(e,c.files.MAIN);if(!await s.fileExists(o))throw new Error(`Agent not found: ${t}
|
|
18
|
+
Expected at: ${o}`);console.log(e);}});});var xt,St=g(()=>{E();f();O();w();xt=p({description:"Start an agent: read SOUL.md and AGENTS.md content",options:z.object({}),args:z.object({name:z.string().describe("Agent name (directory name)")}),handler:async({name:t})=>{let e=s.join(y.AIP_HOME,c.dirs.AGENTS,t),o=s.join(e,c.files.MAIN),r=s.join(e,"SOUL.md");if(!await s.fileExists(o))throw new Error(`Agent not found: ${t}
|
|
19
19
|
Expected at: ${o}`);let i=[r,o];await s.logFiles(...i);}});});var Et,At,He,Dt,vt=g(()=>{f();Et=t=>{let e=t.shape,o=[];for(let[r,n]of Object.entries(e)){let i=n._def,a="unknown",m,l;i.typeName==="ZodString"?a="string":i.typeName==="ZodNumber"?a="number":i.typeName==="ZodBoolean"?a="boolean":i.typeName==="ZodEnum"?a=`enum: ${i.values.join(" | ")}`:i.typeName==="ZodOptional"?a=At(i.innerType):i.typeName==="ZodDefault"&&(a=At(i.innerType),l=i.defaultValue()),i.description&&(m=i.description);let u=i.typeName!=="ZodOptional"&&i.typeName!=="ZodDefault";o.push({name:r,type:a,required:u,description:m,defaultValue:l});}return o},At=t=>{let e=t._def;return e.typeName==="ZodString"?"string":e.typeName==="ZodNumber"?"number":e.typeName==="ZodBoolean"?"boolean":e.typeName==="ZodEnum"?`enum: ${e.values.join(" | ")}`:"unknown"},He=(t,e,o)=>{let r=Et(o.options),n=o.args?Et(o.args):[],i=o.description,a=`\`${t} ${e}\``;if(i&&(a+=`: ${i}`),a+=`
|
|
20
20
|
`,r.length>0||n.length>0){let l=[];for(let u of n){let h=u.required?`<${u.name}>`:`[${u.name}]`,k=u.description||"";u.defaultValue!==void 0&&(k+=k?` (default: ${u.defaultValue})`:`(default: ${u.defaultValue})`),l.push(`\xB7 ${h}${k?": "+k:""}`);}for(let u of r){let h=u.description||"";u.defaultValue!==void 0&&(h+=h?` (default: ${u.defaultValue})`:`(default: ${u.defaultValue})`),l.push(`\xB7 --${u.name}${h?": "+h:""}`);}a+=l.join(`
|
|
21
21
|
`)+`
|
|
@@ -359,9 +359,9 @@ aip task ingest {project} {task} # Full context for AI
|
|
|
359
359
|
---
|
|
360
360
|
|
|
361
361
|
*Structure enables autonomy. Clean files = clear context = better execution.*
|
|
362
|
-
`,Ct=p({description:"Project and task directory layout for autonomous work",options:z.object({}),handler:async()=>{console.log(ze);}});});var nt,Rt=g(()=>{nt={name:"ai-projects",version:"1.0.
|
|
363
|
-
`));else {let n=r[0]??`${t} {?}`;console.log(o,`Usage: aip ${n} [options]`);}}});});var at,Je,
|
|
364
|
-
`)},getTargetDir(t,e=process.cwd()){let o=this.getCurrentContext(e);if(t==="project"){let r=this.getProjectFromPwd(e);if(!r)throw new Error("Not in a project directory. Use --project flag or cd into a project.");let n=s.join(y.AIP_HOME,c.dirs.PROJECTS,r);return {targetDir:n,projectDir:n,entityType:"project"}}if(t==="task"){if(!o.project||!o.task)throw new Error("Not in a task directory. Use --project and --task flags or cd into a task.");let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project);return {targetDir:s.join(r,c.dirs.TASKS,o.task),projectDir:r,entityType:"task"}}if(o.task&&o.project){let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project);return {targetDir:s.join(r,c.dirs.TASKS,o.task),projectDir:r,entityType:"task"}}if(o.project){let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project);return {targetDir:r,projectDir:r,entityType:"project"}}throw new Error("Not in a project or task directory. Specify --target flag.")}},
|
|
362
|
+
`,Ct=p({description:"Project and task directory layout for autonomous work",options:z.object({}),handler:async()=>{console.log(ze);}});});var nt,Rt=g(()=>{nt={name:"ai-projects",version:"1.0.1",type:"module",description:"AI project management CLI - create and manage projects, tasks, and agents",main:"dist/index.js",types:"dist/index.d.ts",bin:{aip:"dist/index.js"},files:["dist/**/*","README.md","LICENSE"],scripts:{build:"npm run build:map && npm run build:code","build:map":"tsx bin/map-commands.ts","build:code":"tsup --no-dts","build:all":"npm run build:map && tsup","build:check":"tsc --noEmit","build:watch":"npm run build:code -- --watch","build:clean":"rimraf dist/*","build:incr":"tsup --no-dts",start:"dist/index.js",dev:'npm run build:watch -- --onSuccess "dist/index.js"',cli:"npm run build && npm start --",ts:"tsx",vitest:"VITE_CJS_IGNORE_WARNING=true vitest",test:"npm run test:types && npm run test:unit","test:unit":"npm run vitest -- run","test:types:test":"tsc -p tsconfig.test.json --incremental --tsBuildInfoFile dist/test.tsbuildinfo","test:types:bin":"tsc -p bin/tsconfig.json --incremental --tsBuildInfoFile dist/bin.tsbuildinfo","test:types":"npm run test:types:test && npm run test:types:bin","test:full":"npm run lint:full && npm run test",eslint:"eslint --cache",lint:"npm run eslint -- '{src,bin}/**/*.ts'","lint:fix":"npm run lint -- --fix","lint:full":"npm run build:incr && npm run test:types:bin && npm run lint:fix","lint:full:silent":"npm run -s lint:full && echo LINT OK",map:"npm run build:map",link:"npm link",unlink:"npm unlink",prepare:'[ "$CI" != "true" ] && [ -d node_modules/husky ] && husky || true',prepack:"npm run test:full && npm run build:all","publish:dry":"npm pack --dry-run",publish:"npm publish","version:patch":"npm version patch","version:minor":"npm version minor","version:major":"npm version major"},keywords:["ai","project-management","task-management","cli","hermes-agent","autonomous-agents"],author:"Ariel Flesler <aflesler@gmail.com>",license:"MIT",repository:{type:"git",url:"git+https://github.com/flesler/ai-projects.git"},homepage:"https://github.com/flesler/ai-projects#readme",bugs:{url:"https://github.com/flesler/ai-projects/issues"},engines:{node:">=20.0.0"},dependencies:{dotenv:"^17.3.1",lodash:"^4.17.21",moment:"^2.30.1",tslib:"^2.8.1",yaml:"^2.8.0",zod:"^3.25.76","zod-opts":"^1.0.0"},devDependencies:{"@eslint/js":"^10.0.1","@stylistic/eslint-plugin":"^5.7.0","@types/dotenv":"^8.2.3","@types/eslint":"^9.6.1","@types/lodash":"^4.17.23","@types/moment":"^2.13.0","@types/node":"^25.0.9","@types/source-map-support":"^0.5.10","@typescript-eslint/eslint-plugin":"^8.53.0","@typescript-eslint/parser":"^8.53.0",eslint:"^10.0.3","eslint-plugin-import-x":"^4.16.2","eslint-plugin-unused-imports":"^4.4.1","fast-glob":"^3.3.3",husky:"^9.1.7",rimraf:"^6.0.1","source-map-support":"^0.5.21",tsup:"^8.5.1",tsx:"^4.20.3","types-package-json":"^2.0.39",typescript:"^5.8.3",vitest:"^4.0.17"}};});var It,Ft=g(()=>{Rt();f();w();It=p({description:"Print compact CLI usage (all nouns, or one noun if name is given)",options:z.object({}),args:z.object({name:z.string().optional().describe("Noun (e.g. task) to list verbs for")}),handler:async({name:t})=>{let{default:e}=await Promise.resolve().then(()=>(J(),st)),o=`${nt.name} ${nt.version} -`,r=s.dumpCommandMapLines(e,t);if(!t)console.log(o,"Usage: aip <noun> <verb> [options]"),console.log(r.map(n=>`-> ${n}`).join(`
|
|
363
|
+
`));else {let n=r[0]??`${t} {?}`;console.log(o,`Usage: aip ${n} [options]`);}}});});var at,Je,b,v=g(()=>{E();O();w();at=s.join(y.AIP_HOME,c.dirs.PROJECTS),Je={getProjectFromPwd(t=process.cwd()){let e=R.relative(at,t);if(!e||e.startsWith(".."))return null;let o=e.split(R.sep).filter(Boolean);return o.length===0?null:o[0]},getTaskFromPwd(t=process.cwd()){let e=R.relative(at,t);if(!e||e.startsWith(".."))return null;let o=e.split(R.sep).filter(Boolean);return o.length<3||o[1]!==c.dirs.TASKS?null:o[2]},getCurrentContext(t=process.cwd()){return {project:this.getProjectFromPwd(t),task:this.getTaskFromPwd(t)}},requireProject(t=process.cwd()){let e=this.getProjectFromPwd(t);if(!e)throw new Error(`Not in a project directory. PWD: ${t}, projects: ${at}`);return e},requireTask(t=process.cwd()){let e=this.getCurrentContext(t);if(!e.project||!e.task)throw new Error(`Not in a task directory. PWD: ${t}`);return {project:e.project,task:e.task}},exportContext(t=process.cwd()){let e=this.getCurrentContext(t),o=[];return e.project&&o.push(`export CURRENT_PROJECT="${e.project}"`),e.task&&o.push(`export CURRENT_TASK="${e.task}"`),process.env.CURRENT_AGENT&&o.push(`export CURRENT_AGENT="${process.env.CURRENT_AGENT}"`),o.join(`
|
|
364
|
+
`)},getTargetDir(t,e=process.cwd()){let o=this.getCurrentContext(e);if(t==="project"){let r=this.getProjectFromPwd(e);if(!r)throw new Error("Not in a project directory. Use --project flag or cd into a project.");let n=s.join(y.AIP_HOME,c.dirs.PROJECTS,r);return {targetDir:n,projectDir:n,entityType:"project"}}if(t==="task"){if(!o.project||!o.task)throw new Error("Not in a task directory. Use --project and --task flags or cd into a task.");let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project);return {targetDir:s.join(r,c.dirs.TASKS,o.task),projectDir:r,entityType:"task"}}if(o.task&&o.project){let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project);return {targetDir:s.join(r,c.dirs.TASKS,o.task),projectDir:r,entityType:"task"}}if(o.project){let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project);return {targetDir:r,projectDir:r,entityType:"project"}}throw new Error("Not in a project or task directory. Specify --target flag.")}},b=Je;});var Ut,_t=g(()=>{f();w();v();E();Ut=p({options:z.object({lang:z.enum(c.languages).default("ts").describe("Language"),target:z.enum(c.targets).default("project").describe("Target level")}),args:z.object({type:z.enum(c.hookTypes).describe("Hook type (e.g., pre-create, post-complete)")}),handler:async({type:t,lang:e,target:o})=>{let r=e,n=`.${r}`,{targetDir:i,entityType:a}=b.getTargetDir(o),m=s.join(i,c.dirs.HOOKS);await s.ensureDir(m);let l=s.join(m,`${t}${n}`);if(await s.fileExists(l))throw new Error(`Hook already exists: ${l}`);let h;if(r==="ts")h=`#!/usr/bin/env tsx
|
|
365
365
|
/** ${t} hook for ${a} */
|
|
366
366
|
|
|
367
367
|
import { env } from 'node:process'
|
|
@@ -408,12 +408,12 @@ if os.environ.get('TASK_SLUG'):
|
|
|
408
408
|
|
|
409
409
|
# Exit with non-zero to prevent action (for pre-hooks)
|
|
410
410
|
# sys.exit(1)
|
|
411
|
-
`;else throw new Error(`Unsupported language: ${r}`);await s.write(l,h);let{chmod:k}=await import('fs/promises');await k(l,493),console.log(`Hook created: ${l}`);}});});var Ze,x,I=g(()=>{E();O();
|
|
412
|
-
`},async appendStatus(t,e,o){let r=s.join(t,c.files.STATUS),n=this.formatLogEntry(e,o);await s.write(r,n);},async appendStatusIfExists(t,e,o){let r=s.join(t,c.files.STATUS);if(!await s.fileExists(r))return false;let i=this.formatLogEntry(e,o);return await s.write(r,i),true},async readStatus(t){let e=s.join(t,c.files.STATUS);return await s.fileExists(e)?await s.read(e):""},getCurrentAgent(){return process.env.CURRENT_AGENT},async logTask(t,e){let o=
|
|
413
|
-
Expected at: ${o}`);await s.logFiles(o);}});});var ee,oe=g(()=>{f();I();
|
|
411
|
+
`;else throw new Error(`Unsupported language: ${r}`);await s.write(l,h);let{chmod:k}=await import('fs/promises');await k(l,493),console.log(`Hook created: ${l}`);}});});var Ze,x,I=g(()=>{E();O();w();Ze={async findHooks(t,e){let o=s.join(t,c.dirs.HOOKS);if(!await s.fileExists(o))return [];let n=await s.listDir(o),i=`${e}.`;return n.filter(a=>a.startsWith(i)).map(a=>s.join(o,a))},async executeHook(t,e,o){if(!await s.fileExists(t))return true;let n=e.project?s.join(y.AIP_HOME,c.dirs.PROJECTS,e.project):o,i=e.task?s.join(n,c.dirs.TASKS,e.task):"",a={...process.env,HOOK_TYPE:e.action,ENTITY_TYPE:e.entityType,TARGET_DIR:o,PROJECT_DIR:n,...e.project?{PROJECT_SLUG:e.project}:{},...e.task?{TASK_SLUG:e.task,TASK_DIR:i}:{}};return new Promise(m=>{let l=spawn(t,[],{stdio:"inherit",env:a,cwd:R.dirname(t),shell:false});l.on("close",(u,h)=>{u===0?m(true):(console.error(`Hook ${R.basename(t)} failed (code=${u??h})`),m(false));}),l.on("error",u=>{console.error(`Failed to execute hook ${t}: ${u.message}`),m(false);});})},async runHooks(t,e,o){let r=await this.findHooks(t,e),n=e.startsWith("pre-");for(let i of r)if(!await this.executeHook(i,o,t)&&n)return false;return true},async runHooksForContext(t,e,o,r){return !(!await this.runHooks(t,o,r)||e&&!await this.runHooks(e,o,r))}},x=Ze;});var Lt,Mt=g(()=>{f();I();v();E();Lt=p({options:z.object({target:z.enum(c.targets).optional().describe("Target level")}),args:z.object({type:z.enum(c.hookTypes).describe("Hook type to run")}),handler:async({type:t,target:e})=>{let{targetDir:o,entityType:r}=b.getTargetDir(e),n={action:t,entityType:r,project:b.getProjectFromPwd()||void 0,task:b.getTaskFromPwd()||void 0};await x.runHooks(o,t,n)||(console.error(`Hook ${t} failed`),process.exit(1)),console.log(`Hook ${t} completed successfully`);}});});var Be,S,F=g(()=>{E();v();O();w();Be={formatLogEntry(t,e){let o=new Date().toISOString().replace("T"," ").replace(/\.\d{3}Z$/,""),r=e?` | ${e}`:"";return `[${o}${r}] ${t}
|
|
412
|
+
`},async appendStatus(t,e,o){let r=s.join(t,c.files.STATUS),n=this.formatLogEntry(e,o);await s.write(r,n);},async appendStatusIfExists(t,e,o){let r=s.join(t,c.files.STATUS);if(!await s.fileExists(r))return false;let i=this.formatLogEntry(e,o);return await s.write(r,i),true},async readStatus(t){let e=s.join(t,c.files.STATUS);return await s.fileExists(e)?await s.read(e):""},getCurrentAgent(){return process.env.CURRENT_AGENT},async logTask(t,e){let o=b.getCurrentContext();if(!o.project||!o.task)throw new Error("Not in a task directory");let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o.project,c.dirs.TASKS,o.task);await this.appendStatus(r,t,e||this.getCurrentAgent());},async logProject(t,e){let o=b.getProjectFromPwd();if(!o)throw new Error("Not in a project directory");let r=s.join(y.AIP_HOME,c.dirs.PROJECTS,o);await this.appendStatus(r,t,e||this.getCurrentAgent());},async logStatusChange(t,e,o,r){let n=e;if(o&&Object.keys(o).length>0){let i=Object.entries(o).map(([a,m])=>`${a}=${m}`).join(", ");n=`${e}: ${i}`;}await this.appendStatus(t,n,r);}},S=Be;});var Kt,zt=g(()=>{f();w();P();I();F();Kt=p({description:"Create a new project with name, description, optional status and assignee",options:z.object({description:z.string().describe("Project description"),status:z.string().default("active").describe("Initial status"),assignee:z.string().optional().describe("Assignee agent slug")}),args:z.object({name:z.string().describe("Project name")}),handler:async({name:t,description:e,status:o,assignee:r})=>{let n=s.slugify(t),i=d.getProjectDir(n);if(!await x.runHooks(i,"pre-create",{action:"pre-create",entityType:"project"}))throw new Error("Pre-create hook failed, aborting project creation");await d.createProject(n,{name:t,description:e,status:o,assignee:r,created:new Date().toISOString()}),await S.appendStatus(i,`Project created: ${t}`),await x.runHooks(i,"post-create",{action:"post-create",entityType:"project"}),console.log(`Project created: ${n}`),console.log(` Path: ${i}`);}});});var Gt,Jt=g(()=>{f();v();Gt=p({options:z.object({}),handler:async()=>{let t=b.getProjectFromPwd();t||(console.error("Not in a project directory"),process.exit(1)),console.log(t);}});});var Zt,Bt=g(()=>{f();P();Zt=p({description:"List all projects, optionally filtered by status",options:z.object({status:z.string().optional().describe("Filter by status")}),handler:async({status:t})=>{let e=await d.listProjects(),o=[];for(let r of e){let n=await d.getProject(r);n&&(t&&n.status!==t||o.push({slug:r,name:n.name||r,status:n.status,assignee:n.assignee}));}if(o.length===0){console.log("No projects found");return}console.log("Projects:"),console.log("---");for(let r of o)console.log(`${r.slug.padEnd(20)} ${r.name?.padEnd(30)||""} ${r.status||""} ${r.assignee||""}`);}});});var Vt,qt=g(()=>{f();P();Vt=p({description:"Output project directory path (for cd)",options:z.object({}),args:z.object({name:z.string().describe("Project name (slug)")}),handler:async({name:t})=>{let e=d.getProjectDir(t);console.log(e);}});});var Yt,Xt=g(()=>{f();P();I();F();v();Yt=p({description:"Update project properties: name, description, status, assignee, or append summary",options:z.object({name:z.string().optional().describe("New name"),description:z.string().optional().describe("New description"),status:z.string().optional().describe("New status"),assignee:z.string().optional().describe("New assignee"),summary:z.string().optional().describe("Optional summary to append to status.md")}),args:z.object({project:z.string().optional().describe("Project slug (defaults to current project from $PWD)")}),handler:async({project:t,name:e,description:o,status:r,assignee:n,summary:i})=>{let a=t||b.getProjectFromPwd();if(!a)throw new Error("No project specified and not in a project directory");let m=d.getProjectDir(a);if(!await x.runHooks(m,"pre-update",{action:"pre-update",entityType:"project"}))throw new Error("Pre-update hook failed, aborting update");let u={};if(e&&(u.name=e),o&&(u.description=o),r&&(u.status=r),n&&(u.assignee=n),Object.keys(u).length===0){console.log("No updates provided");return}await d.updateProject(a,u);let h=Object.entries(u).map(([k,tt])=>`${k}=${tt}`).join(", ");await S.appendStatus(m,`Updated: ${h}`),i&&await S.appendStatus(m,i),await x.runHooks(m,"post-update",{action:"post-update",entityType:"project"}),console.log(`Project ${a} updated`);}});});var Qt,te=g(()=>{E();f();O();w();Qt=p({description:"Read a skill's SKILL.md file into the console for agent context",options:z.object({}),args:z.object({name:z.string().describe("Skill name (directory name)")}),handler:async({name:t})=>{let e=s.join(y.AIP_HOME,c.dirs.SKILLS,t),o=s.join(e,c.files.SKILL);if(!await s.fileExists(o))throw new Error(`Skill not found: ${t}
|
|
413
|
+
Expected at: ${o}`);await s.logFiles(o);}});});var ee,oe=g(()=>{f();I();w();P();F();ee=p({description:"Create a new task with optional priority, assignee, and initial status",options:z.object({description:z.string().optional().describe("Task description"),priority:z.enum(["low","medium","high"]).optional().describe("Task priority"),assignee:z.string().optional().describe("Assignee agent slug"),status:z.enum(["pending","in-progress","ongoing","done"]).default("pending").describe("Initial status")}),args:z.object({project:z.string().describe("Project slug"),name:z.string().describe("Task name")}),handler:async({project:t,name:e,description:o,priority:r,assignee:n,status:i})=>{let a=s.slugify(e),m=d.getTaskDir(t,a);if(!await x.runHooksForContext(d.getProjectDir(t),m,"pre-create",{action:"pre-create",entityType:"task",project:t}))throw new Error("Pre-create hook failed, aborting task creation");await d.createTask(t,a,{name:e,description:o,priority:r,assignee:n,status:i,created:new Date().toISOString()}),await S.appendStatus(m,`Task created: ${e}`),await x.runHooksForContext(d.getProjectDir(t),m,"post-create",{action:"post-create",entityType:"task",project:t}),console.log(`Task created: ${a}`),console.log(` Project: ${t}`),console.log(` Path: ${m}`);}});});var re,se=g(()=>{f();v();re=p({description:"Get the current task slug from PWD",options:z.object({}),handler:async()=>{let t=b.getTaskFromPwd();t||(console.error("Not in a task directory"),process.exit(1)),console.log(t);}});});var ne,ie=g(()=>{v();f();P();ne=p({description:"Output full task context (main.md, status.md) for ingestion by agents",options:z.object({}),args:z.object({project:z.string().optional().describe("Project slug (default: from $PWD)"),task:z.string().optional().describe("Task slug (default: from $PWD)")}),handler:async({project:t,task:e})=>{let o=b.getCurrentContext(),r=t??o.project,n=e??o.task;if(!r||!n)throw new Error("Need project and task (or cd into task dir)");await d.ingestTask(r,n);}});});var ae,ce=g(()=>{f();P();v();ae=p({description:"List tasks in a project, optionally filtered by status or assignee",options:z.object({project:z.string().optional().describe("Project slug (defaults to current project from $PWD)"),status:z.string().optional().describe("Filter by status"),assignee:z.string().optional().describe("Filter by assignee")}),handler:async({project:t,status:e,assignee:o})=>{let r=t||b.getProjectFromPwd();if(!r)throw new Error("No project specified and not in a project directory");let n=await d.listTasks(r),i=[];for(let a of n){let m=await d.getTask(r,a);m&&(e&&m.status!==e||o&&m.assignee!==o||i.push({slug:a,name:m.name||a,status:m.status,assignee:m.assignee,priority:m.priority}));}if(i.length===0){console.log("No tasks found");return}console.log(`Tasks in ${r}:`),console.log("---");for(let a of i)console.log(`${a.slug.padEnd(20)} ${a.name?.padEnd(30)||""} ${a.status||""} ${a.assignee||""} ${a.priority||""}`);}});});var pe,me=g(()=>{f();P();pe=p({description:"Output task directory path (for cd)",options:z.object({}),args:z.object({project:z.string().describe("Project slug"),task:z.string().describe("Task slug")}),handler:async({project:t,task:e})=>{let o=d.getTaskDir(t,e);console.log(o);}});});var Y,mt=g(()=>{f();I();P();F();Y=p({description:"Update task properties: name, description, status, priority, assignee, or append summary",options:z.object({name:z.string().optional().describe("New name"),description:z.string().optional().describe("New description"),status:z.enum(["pending","in-progress","ongoing","done","blocked"]).optional().describe("New status"),priority:z.enum(["low","medium","high"]).optional().describe("New priority"),assignee:z.string().optional().describe("New assignee"),summary:z.string().optional().describe("Optional summary to append to status.md")}),args:z.object({project:z.string().optional().describe("Project slug (defaults to current project from $PWD)"),task:z.string().optional().describe("Task slug (defaults to current task from $PWD)")}),handler:async({project:t,task:e,name:o,description:r,status:n,priority:i,assignee:a,summary:m})=>{let l={project:t,task:e};if(!l.project||!l.task)throw new Error("No task specified and not in a task directory. Use --project and --task flags.");let u=d.getTaskDir(l.project,l.task);if(!await x.runHooksForContext(d.getProjectDir(l.project),u,"pre-update",{action:"pre-update",entityType:"task",project:l.project,task:l.task}))throw new Error("Pre-update hook failed, aborting update");let k={};if(o&&(k.name=o),r&&(k.description=r),n&&(k.status=n),i&&(k.priority=i),a&&(k.assignee=a),Object.keys(k).length===0&&!m){console.log("No updates provided");return}if(Object.keys(k).length>0){await d.updateTask(l.project,l.task,k);let tt=Object.entries(k).map(([he,je])=>`${he}=${je}`).join(", ");await S.appendStatus(u,`Updated: ${tt}`);}m&&await S.appendStatus(u,m),await x.runHooksForContext(d.getProjectDir(l.project),u,"post-update",{action:"post-update",entityType:"task",project:l.project,task:l.task}),console.log(`Task ${l.task} updated`);}});});var le,de=g(()=>{f();P();mt();le=p({description:"Start a task: set status to in-progress, optionally print context",options:z.object({ingest:z.boolean().default(false).describe("Also output context for this task")}),args:z.object({project:z.string().describe("Project slug"),task:z.string().describe("Task slug")}),handler:async({project:t,task:e,ingest:o})=>{(await d.getTask(t,e))?.status!=="in-progress"&&await Y.handler({project:t,task:e,status:"in-progress"}),o&&await d.ingestTask(t,e);}});});var ue,ge=g(()=>{f();P();F();ue=p({description:"Post-mortem analysis for a completed task",options:z.object({}),args:z.object({project:z.string().describe("Project slug"),task:z.string().describe("Task slug")}),handler:async({project:t,task:e})=>{let o=d.getTaskDir(t,e),r=await d.getTask(t,e),i=(await S.readStatus(o)).split(`
|
|
414
414
|
`).filter(l=>l.startsWith("[")).length,a=[],m=r?.name||e;i>5&&a.push("High status update count - consider breaking into smaller tasks"),m.toLowerCase().includes("implement")&&a.push("Implementation task - check if similar patterns exist to reuse"),m.toLowerCase().includes("create")&&m.toLowerCase().includes("command")&&a.push("Command creation - check existing command patterns in src/commands/"),console.log(`
|
|
415
415
|
=== Post-Mortem Analysis ===`),console.log(`Project: ${t}`),console.log(`Task: ${e}`),console.log(`Name: ${m}`),console.log(`Status: ${r?.status||"unknown"}`),console.log(`Priority: ${r?.priority||"none"}`),console.log(`Status updates: ${i}`),a.length>0?(console.log(`
|
|
416
416
|
Suggestions:`),a.forEach(l=>console.log(` - ${l}`))):console.log(`
|
|
417
417
|
No specific suggestions - task looks well-scoped`),console.log(`
|
|
418
418
|
=== End Post-Mortem ===
|
|
419
|
-
`);}});});var fe,ye=g(()=>{f();
|
|
419
|
+
`);}});});var fe,ye=g(()=>{f();w();fe=p({description:"Read one or more files into the console",options:z.object({}),args:z.object({paths:z.array(z.string()).describe("File paths to read")}),handler:async({paths:t})=>{await s.logFiles(...t);}});});var st={};be(st,{default:()=>N});var Ye,N,J=g(()=>{kt();jt();bt();Pt();St();vt();$t();Nt();Ft();_t();Mt();zt();Jt();Bt();qt();Xt();te();oe();se();ie();ce();me();de();mt();ge();ye();Ye={agent:{create:yt,current:ht,list:Tt,path:wt,start:xt},help:{api:Dt,hooks:Ot,structure:Ct,usage:It},hook:{create:Ut,run:Lt},project:{create:Kt,current:Gt,list:Zt,path:Vt,update:Yt},skill:{read:Qt},task:{create:ee,current:re,ingest:ne,list:ae,path:pe,start:le,update:Y},util:{postmortem:ue,read:fe}},N=Ye;});J();w();process.on("unhandledRejection",t=>{console.error("Unhandled Rejection:",t),process.exit(1);});process.on("uncaughtException",t=>{console.error("Unhandled Exception:",t),process.exit(1);});async function ke(t){let[e,o,...r]=t;try{(!e||!s.isKeyOf(e,N))&&(await N.help.usage.handler({}),process.exit(1));let n=N[e];(!o||!s.isKeyOf(o,n))&&(await N.help.usage.handler({name:e}),process.exit(1));let i=n[o];i||(console.error(`Error: unknown command '${e} ${o}'`),console.log("Run with --help for more information"),process.exit(1)),await i.handler(i.parser.name(`${e} ${o}`).parse(r));}catch(n){console.error("Error:",s.errorMessage(n)),process.exit(1);}}var Un=ke,_n=N;s.isMain()&&ke(process.argv.slice(2));export{_n as commands,Un as default};
|