@autonomos/cli 0.0.2 → 0.0.3
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.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as e}from"commander";import t from"picocolors";import{AGENT_FILE as n,AUTONOMOS_DIR as r,MANIFEST_FILE as i,PROTOCOL_FILE as a,PROTOCOL_TEMPLATE as o,PROTOCOL_VERSION as s,TASKS_FILE as c,TASKS_TEMPLATE as l,TaskParser as u,WORKLOGS_DIR as d,createManifest as f,generateAgentTemplate as p,generateManifestContent as m,parseManifest as h}from"@autonomos/core";import{existsSync as g,mkdirSync as _,readFileSync as v,readdirSync as y,statSync as b,writeFileSync as x}from"node:fs";import{basename as S,join as C,relative as w}from"node:path";function T(e){let t=e;for(;t!==`/`;){if(g(C(t,r))||g(C(t,`.git`)))return t;t=C(t,`..`)}return null}function E(e,t,r=0){let i=[],a=C(e,n);g(a)&&i.push({path:a,relativePath:w(t,a)||n,depth:r});try{let n=y(e);for(let a of n){if(a.startsWith(`.`)||a===`node_modules`||a===`dist`||a===`build`)continue;let n=C(e,a);try{b(n).isDirectory()&&i.push(...E(n,t,r+1))}catch{}}}catch{}return i}function D(e,t){if(e.length===0)return` (no AGENT.md files found)`;let
|
|
2
|
+
import{Command as e}from"commander";import t from"picocolors";import{AGENT_FILE as n,AUTONOMOS_DIR as r,MANIFEST_FILE as i,PROTOCOL_FILE as a,PROTOCOL_TEMPLATE as o,PROTOCOL_VERSION as s,TASKS_FILE as c,TASKS_TEMPLATE as l,TaskParser as u,WORKLOGS_DIR as d,createManifest as f,generateAgentTemplate as p,generateManifestContent as m,parseManifest as h}from"@autonomos/core";import{existsSync as g,mkdirSync as _,readFileSync as v,readdirSync as y,statSync as b,writeFileSync as x}from"node:fs";import{basename as S,join as C,relative as w}from"node:path";function T(e){let t=e;for(;t!==`/`;){if(g(C(t,r))||g(C(t,`.git`)))return t;t=C(t,`..`)}return null}function E(e,t,r=0){let i=[],a=C(e,n);g(a)&&i.push({path:a,relativePath:w(t,a)||n,depth:r});try{let n=y(e);for(let a of n){if(a.startsWith(`.`)||a===`node_modules`||a===`dist`||a===`build`)continue;let n=C(e,a);try{b(n).isDirectory()&&i.push(...E(n,t,r+1))}catch{}}}catch{}return i}function D(e,t){if(e.length===0)return` (no AGENT.md files found)`;let r=S(t),i={name:r,isAgent:!1,children:{}};for(let t of e){let e=t.relativePath.split(`/`),r=i;for(let t=0;t<e.length;t++){let i=e[t],a=i===n;r.children[i]||(r.children[i]={name:i,isAgent:a,children:{}}),r=r.children[i]}}let a=[];a.push(`📁 ${r}/`);function o(e,t=``,n=!0){let r=Object.values(e.children);r.sort((e,t)=>!e.isAgent&&t.isAgent?-1:e.isAgent&&!t.isAgent?1:e.name.localeCompare(t.name)),r.forEach((e,n)=>{let i=n===r.length-1,s=i?`└── `:`├── `,c=e.isAgent?`📄`:`📁`,l=e.isAgent?e.name:`${e.name}/`;a.push(`${t}${s}${c} ${l}`),e.isAgent||o(e,t+(i?` `:`│ `),i)})}return o(i),a.join(`
|
|
3
3
|
`)}function O(e={}){let t=e.cwd??process.cwd(),n;if(e.all){let e=T(t);if(!e)return{success:!1,message:`Could not find project root (.autonomos or .git directory).`};n=e}else n=t;let r=E(n,n);if(r.length===0)return{success:!0,message:`No AGENT.md files found.`,count:0};let i=D(r,n);return{success:!0,message:`Found ${r.length} AGENT.md file(s)`,tree:i,count:r.length}}function k(e={}){let t=e.cwd??process.cwd(),u=e.dryRun??!1,h=[],v=[];g(C(t,`.git`))||v.push("No Git repository detected. Consider running `git init` first.");let y=C(t,r);if(g(y))return{success:!1,message:`Project already initialized with Protocol v${s}. Use \`autonomos update\` to update.`,created:[],warnings:[],dryRun:u};if(u)return h.push(r),h.push(`${r}/${d}`),h.push(`${r}/${i}`),h.push(`${r}/${a}`),h.push(`${r}/${c}`),g(C(t,n))?v.push(`${n} already exists, would skip.`):h.push(n),{success:!0,message:`Would initialize project with Agent Protocol v${s}`,created:h,warnings:v,dryRun:!0};_(y,{recursive:!0}),h.push(r),_(C(y,d),{recursive:!0}),h.push(`${r}/${d}`);let b=f(`0.0.1`);x(C(y,i),m(b)),h.push(`${r}/${i}`),x(C(y,a),o),h.push(`${r}/${a}`),x(C(y,c),l),h.push(`${r}/${c}`);let S=C(t,n);return g(S)?v.push(`${n} already exists, skipping.`):(x(S,p(t.split(`/`).pop()??`Project`)),h.push(n)),{success:!0,message:`Project initialized with Agent Protocol v${s}`,created:h,warnings:v,dryRun:!1}}function A(e={}){let t=C(e.cwd??process.cwd(),r),n=C(t,i);if(!g(n))return{success:!1,message:"Project not initialized. Run `autonomos init` first.",initialized:!1};let a;try{a=h(v(n,`utf-8`))}catch{return{success:!1,message:`Could not read manifest.json`,initialized:!0}}let o,s=C(t,c);if(g(s))try{let e=v(s,`utf-8`),t=u.parse(e);o={total:t.length,todo:t.filter(e=>e.status===`TODO`).length,inProgress:t.filter(e=>e.status===`IN_PROGRESS`).length,done:t.filter(e=>e.status===`DONE`).length,blocked:t.filter(e=>e.status===`BLOCKED`).length}}catch{}return{success:!0,message:`Project status retrieved`,protocolVersion:a.protocolVersion,cliVersion:a.cliVersion,initialized:!0,taskSummary:o}}function j(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){let t=n[e]??0,i=r[e]??0;if(t<i)return-1;if(t>i)return 1}return 0}function M(e={}){let t=C(e.cwd??process.cwd(),r),n=C(t,i);if(!g(n))return{success:!1,message:"Project not initialized. Run `autonomos init` first."};let c=h(v(n,`utf-8`)),l=c.protocolVersion,u=j(l,s);return u===0?{success:!0,message:`Already up to date (Protocol v${s})`,previousVersion:l,newVersion:s}:u>0?{success:!1,message:`This project uses Protocol v${l}, but your CLI only knows v${s}. Update your CLI with \`npm i -g @autonomos/cli\`.`,previousVersion:l,newVersion:s,cliOutdated:!0}:(x(C(t,a),o),x(n,m({...c,protocolVersion:s,cliVersion:`0.0.1`,lastUpdated:new Date().toISOString()})),{success:!0,message:`Protocol updated: v${l} → v${s}`,previousVersion:l,newVersion:s})}const N=`0.0.1`,P=new e;P.name(`autonomos`).description(t.cyan(`CLI for the Autonomos Agent Protocol
|
|
4
4
|
|
|
5
5
|
The Agent Protocol is a specification for AI agents to interact with codebases
|