@autonomos/cli 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,7 +33,14 @@ autonomos update
33
33
 
34
34
  ### `status`
35
35
 
36
- Show project status and a summary of tasks from `TASKS.md`.
36
+ Show project status and current task records from `.autonomos/TASKS.md`.
37
+
38
+ Use `--history` to add a separate historical summary from archive `TASKS.md`
39
+ registries. History is not read by default. Counts recognize task IDs even without
40
+ priority/complexity metadata and ignore fenced examples. Archived status is
41
+ historical, not current work; abandoned records need not be marked completed.
42
+ Symbolic links are not followed. Skipped/unreadable registries and duplicate task
43
+ IDs produce diagnostics and exit code 1; incomplete history is labelled.
37
44
 
38
45
  For projects using the protocol version bundled with the CLI, status also verifies
39
46
  that `PROTOCOL.md` and installed harness workflows match their canonical published
@@ -43,6 +50,7 @@ unverifiable rather than incorrectly judged against the current release.
43
50
 
44
51
  ```bash
45
52
  autonomos status
53
+ autonomos status --history
46
54
  ```
47
55
 
48
56
  ### `agents`
@@ -74,14 +82,17 @@ The CLI manages the `.autonomos/` directory in your project, which contains:
74
82
 
75
83
  It also creates a root `AGENT.md` file if it doesn't exist, which serves as the primary context for AI agents.
76
84
 
77
- Optional project-owned `.autonomos/specs/` and `.autonomos/decisions/` directories
85
+ Optional project-owned `.autonomos/archive/`, `.autonomos/specs/` and `.autonomos/decisions/` directories
78
86
  are first-use artifacts, not empty directories created by `init`. `update`
79
87
  refreshes managed protocol files and harness workflows while preserving those
80
88
  directories, `AGENT.md`, `TASKS.md`, `ISSUES.md`, worklogs, and user documentation.
81
89
  For semantic migration of an existing project's scattered knowledge, use the
82
90
  installed `/adopt` workflow: it proposes a source-to-destination map, waits for
83
91
  user approval, writes draft/proposed records, and leaves historical records
84
- unchanged. Follow it with `/reconcile`.
92
+ unchanged. Follow it with `/reconcile`. That workflow also archives eligible
93
+ settled history after preserving current knowledge and references. Installation
94
+ and updates never archive or relocate project records. Archive IDs stay reserved;
95
+ use targeted Markdown search before assigning new issue/task IDs.
85
96
 
86
97
  ## License
87
98
 
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
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,displayRelative as p,findAncestorAgents as m,findProjectRoot as h,generateAgentTemplate as g,generateManifestContent as _,isSamePath as v,listHarnesses as y,parseManifest as b,resolveTargets as x}from"@autonomos/core";import{existsSync as S,mkdirSync as C,readFileSync as w,readdirSync as T,statSync as E,writeFileSync as D}from"node:fs";import{basename as O,join as k,relative as A,resolve as j}from"node:path";import{checkbox as M,confirm as N}from"@inquirer/prompts";import{fileURLToPath as P}from"node:url";function F(e,t,r=0){let i=[],a=k(e,n);S(a)&&i.push({path:a,relativePath:A(t,a)||n,depth:r});try{let n=T(e);for(let a of n){if(a.startsWith(`.`)||a===`node_modules`||a===`dist`||a===`build`)continue;let n=k(e,a);try{E(n).isDirectory()&&i.push(...F(n,t,r+1))}catch{}}}catch{}return i}function I(e,t){if(e.length===0)return` (no AGENT.md files found)`;let r=O(t),i={name:r,isAgent:!1,children:{}};for(let t of e){let e=t.relativePath.split(`/`),r=i;for(let t of e){let e=t===n,i=r.children[t];i||(i={name:t,isAgent:e,children:{}},r.children[t]=i),r=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
- `)}function L(e){return e.length===0?` (no AGENT.md files found in the ancestor chain)`:e.map((t,n)=>` ${(n+1).toString().padStart(e.length.toString().length,` `)}. ${t.relativeDir===`.`?`./AGENT.md`:`${t.relativeDir}/AGENT.md`}`).join(`
4
- `)}function R(e={}){let t=e.cwd??process.cwd();if(e.target){let n=h(t)??t,r;try{r=m(j(t,e.target),n)}catch(e){return{success:!1,message:`Failed to look up ancestors: ${e instanceof Error?e.message:String(e)}`,mode:`ancestors`}}let i=L(r);return{success:!0,message:`Found ${r.length} ancestor AGENT.md file(s) for "${e.target}" (root → target):\n${i}`,count:r.length,ancestors:r,mode:`ancestors`}}let n;if(e.all){let e=h(t);if(!e)return{success:!1,message:`Could not find project root (.autonomos or .git directory).`,mode:`tree`};n=e}else n=t;let r=F(n,n);if(r.length===0)return{success:!0,message:`No AGENT.md files found.`,count:0,mode:`tree`};let i=I(r,n);return{success:!0,message:`Found ${r.length} AGENT.md file(s)`,tree:i,count:r.length,mode:`tree`}}var z=`0.5.0`;const B=[`protocol-session.md`,`protocol-task.md`,`protocol-crystallize.md`,`protocol-issue.md`,`protocol-adopt.md`,`protocol-reconcile.md`];function V(e=import.meta.url){let t=P(e);return[j(t,`..`,`..`,`..`,`core`,`src`,`workflows`),j(t,`..`,`..`,`..`,`core`,`dist`,`workflows`),j(t,`..`,`..`,`..`,`..`,`core`,`dist`,`workflows`)]}function H(){let e=V();for(let t of e)if(S(t))return t;throw Error(`Could not locate the workflows directory inside @autonomos/core`)}function U(e,t){return e.replace(/^protocol-/,``).replace(/\.[^.]+$/,``)+t}function W(e,t){if(t!==s)return{state:`unverifiable`,driftedFiles:[]};let n=[];G(k(e,r,a),o,e,n);let i=H(),c=x(y().map(({id:e})=>e),e);for(let t of c){let r=B.map(e=>({source:w(k(i,e),`utf-8`),destination:k(t.path,U(e,t.fileExtension))}));if(r.some(({destination:e})=>S(e)))for(let t of r)G(t.destination,t.source,e,n)}return{state:n.length===0?`valid`:`drifted`,driftedFiles:n}}function G(e,t,n,r){(!S(e)||w(e,`utf-8`)!==t)&&r.push(A(n,e))}const K=z;async function ee(){return M({message:`Which AI harnesses do you want to install the protocol for? (space to toggle, enter to confirm)`,choices:y().map(({id:e,harness:t})=>({name:t.name,value:e,checked:t.preferred}))})}async function te(e,t){let n=[],r=h(e);if(!r)return S(k(e,`.git`))||n.push("No Git repository detected. Consider running `git init` first."),{installDir:e,warnings:n};if(v(r,e))return{installDir:e,warnings:n};let i=p(e,r);return t.force||process.env.AUTONOMOS_FORCE===`1`?(n.push(`Detected project root at ${p(r,e)} (AUTONOMOS_FORCE=1); installing there instead of "${i}".`),{installDir:r,warnings:n}):t.isInteractive&&!t.noPrompt?await N({message:`You're inside a project rooted at ${r}.\nThe protocol should be installed at the project root, not in "${i}".\nInstall at the project root instead?`,default:!0})?(n.push(`Detected project root above "${i}"; installing at ${r}.`),{installDir:r,warnings:n}):{installDir:e,warnings:n,abort:{message:`Aborted: refusing to install Autonomos inside a subdirectory. Run the command from ${r} (or pass --force / set AUTONOMOS_FORCE=1).`}}:{installDir:e,warnings:n,abort:{message:`Cannot initialize Autonomos from a subdirectory.\n Current directory : ${e}\n Detected root : ${r}\nRe-run from the project root, or pass --force (or set AUTONOMOS_FORCE=1) to install here anyway.`}}}async function ne(e={}){let t=e.cwd??process.cwd(),u=e.dryRun??!1,p=e.interactiveOverride??(process.stdin.isTTY===!0&&!e.dryRun),m=await te(t,{force:e.force??!1,noPrompt:e.noPrompt??!1,isInteractive:p});if(m.abort)return{success:!1,message:m.abort.message,created:[],warnings:m.warnings,dryRun:u};let h=m.installDir,v=[...m.warnings],b=[],T=[],O=k(h,`package.json`),A=S(O)&&E(O).isFile(),j=k(h,r),M=S(j),N;if(N=e.all?y().map(({id:e})=>e):e.harnesses&&e.harnesses.length>0?e.harnesses:e.noPrompt||e.dryRun?[]:await ee(),M&&N.length===0)return{success:!1,message:`Project already initialized with Protocol v${s}. Use \`autonomos update\` to update, or specify harnesses with --harness to install workflow files.`,created:[],warnings:[],dryRun:u};let P=x(N,h);if(u){M?(b.push(`${r}/${i} (update)`),b.push(`${r}/${a} (update)`)):(b.push(r),b.push(`${r}/${d}`),b.push(`${r}/${i}`),b.push(`${r}/${a}`),b.push(`${r}/${c}`)),S(k(h,n))?v.push(`${n} already exists, would skip.`):b.push(n);for(let e of P)for(let t of B){let n=U(t,e.fileExtension);T.push(`${e.path}/${n}`)}return{success:!0,message:`Would ${M?`update workflows in`:`initialize`} project with Agent Protocol v${s}${N.length?` (harnesses: ${N.join(`, `)})`:``}`,created:b,warnings:v,dryRun:!0,harnessFiles:T}}S(j)||(C(j,{recursive:!0}),b.push(r));let F=k(j,d);S(F)||(C(F,{recursive:!0}),b.push(`${r}/${d}`));let I=f(K);D(k(j,i),_(I)),b.push(`${r}/${i}`),D(k(j,a),o),b.push(`${r}/${a}`);let L=k(j,c);S(L)?v.push(`${c} already exists, skipping.`):(D(L,l),b.push(`${r}/${c}`));let R=k(h,n);if(S(R)?v.push(`${n} already exists, skipping.`):(D(R,g(h.split(`/`).pop()??`Project`)),b.push(n)),A)try{let t=w(O,`utf-8`),n=JSON.parse(t),r=!!n.scripts?.autonomos,i=n.devDependencies?.[`@autonomos/cli`],a=`^${K}`;n.scripts||={},e.noInstall||e.dryRun?(n.scripts.autonomos=`npx --yes @autonomos/cli`,D(O,JSON.stringify(n,null,4)+`
5
- `),b.push(`package.json (scripts.autonomos via npx)`),r||v.push('Added "autonomos" npm script using npx (--no-install mode). Run `npm install` when ready.')):(n.scripts.autonomos=`autonomos`,n.devDependencies||={},n.devDependencies[`@autonomos/cli`]=a,D(O,JSON.stringify(n,null,4)+`
6
- `),b.push(`package.json (scripts.autonomos + devDependencies.@autonomos/cli)`),!r&&!i?v.push('Added "autonomos" npm script and @autonomos/cli devDependency. Run `npm install` to install.'):i&&i!==a?v.push(`Bumped @autonomos/cli devDependency: ${i} → ${a}. Run \`npm install\` to apply.`):!r&&i&&v.push(`Added "autonomos" npm script (devDependency was already set).`))}catch{v.push(`Could not update package.json (invalid JSON or read error).`)}let z=H();for(let e of P){C(e.path,{recursive:!0});for(let t of B){let n=w(k(z,t),`utf-8`),r=U(t,e.fileExtension);D(k(e.path,r),n),T.push(`${e.path}/${r}`)}}return{success:!0,message:`Project initialized with Agent Protocol v${s}${N.length>0?` for harnesses: ${N.join(`, `)}`:` (no harness workflows installed)`}`,created:b,warnings:v,dryRun:!1,harnessFiles:T}}function re(e={}){let t=e.cwd??process.cwd(),n=k(t,r),a=k(n,i);if(!S(a))return{success:!1,message:"Project not initialized. Run `autonomos init` first.",initialized:!1};let o;try{o=b(w(a,`utf-8`))}catch{return{success:!1,message:`Could not read manifest.json`,initialized:!0}}let s,l=k(n,c);if(S(l))try{let e=w(l,`utf-8`),t=u.parse(e);s={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{}let d=W(t,o.protocolVersion);return{success:!0,message:`Project status retrieved`,protocolVersion:o.protocolVersion,cliVersion:o.cliVersion,initialized:!0,taskSummary:s,artifactIntegrity:d.state,driftedArtifacts:d.driftedFiles}}const q=z;function J(e,t){let n=e=>{let[t=``,n]=e.split(`-`,2);return{parts:t.split(`.`).map(Number),prerelease:n}},r=n(e),i=n(t);for(let e=0;e<3;e++){let t=r.parts[e]??0,n=i.parts[e]??0;if(t<n)return-1;if(t>n)return 1}return r.prerelease===i.prerelease?0:r.prerelease===void 0?1:i.prerelease===void 0?-1:r.prerelease.localeCompare(i.prerelease)}function Y(e){let t=k(e,`package.json`);if(!S(t))return null;let n;try{n=JSON.parse(w(t,`utf-8`))}catch{return null}let r=`^${q}`,i=n.devDependencies?.[`@autonomos/cli`];if(i===r)return null;n.devDependencies||={},n.devDependencies[`@autonomos/cli`]=r;try{D(t,JSON.stringify(n,null,4)+`
7
- `)}catch{return null}return i?`Bumped @autonomos/cli devDependency: ${i} → ${r}.`:`Added @autonomos/cli devDependency: ${r}.`}function X(e,t,n){if(t.length===0)return[];let r=x(t,e),i=[];for(let e of r){C(e.path,{recursive:!0});for(let t of B){let r=w(k(n,t),`utf-8`),a=U(t,e.fileExtension);D(k(e.path,a),r),i.push(`${e.path}/${a}`)}}return i}function Z(e,t){let n=x(y().map(({id:e})=>e),e),r=[];for(let e of n){if(!S(e.path))continue;let n=B.map(n=>({source:w(k(t,n),`utf-8`),dest:k(e.path,U(n,e.fileExtension))}));if(!n.some(({dest:e})=>S(e)))continue;let i=!1;for(let{source:e,dest:t}of n)(!S(t)||w(t,`utf-8`)!==e)&&(D(t,e),i=!0);i&&r.push(e.path)}return r}function ie(e={}){let t=e.cwd??process.cwd(),n=h(t)??t,c=k(n,r),l=k(c,i);if(!S(l))return{success:!1,message:"Project not initialized. Run `autonomos init` first."};let u=b(w(l,`utf-8`)),d=u.protocolVersion,f;try{f=(e.resolveWorkflowsDir??H)()}catch(e){return{success:!1,message:`Cannot update protocol artifacts: ${e instanceof Error?e.message:String(e)}`,previousVersion:d,newVersion:s}}let p=Y(n),m=J(d,s);if(m===0){let t=[];try{t=Z(n,f)}catch(e){console.warn(`Warning: Could not update harness workflows: ${e instanceof Error?e.message:String(e)}`)}let r=X(n,e.all?y().map(({id:e})=>e):e.harnesses??[],f);return(u.cliVersion!==q||t.length>0||r.length>0)&&D(l,_({...u,cliVersion:q,lastUpdated:new Date().toISOString()})),{success:!0,message:`Already up to date (Protocol v${s}).${t.length>0?` Refreshed workflows in ${t.join(`, `)}.`:``}${r.length>0?` Installed: ${r.join(`, `)}.`:``}${p?` ${p}`:``}`,previousVersion:d,newVersion:s,touchedHarnesses:[...t,...r]}}if(m>0)return{success:!1,message:`This project uses Protocol v${d}, but your CLI only knows v${s}. Update your CLI with \`npm i -g @autonomos/cli\`.`,previousVersion:d,newVersion:s,cliOutdated:!0};D(k(c,a),o),D(l,_({...u,protocolVersion:s,cliVersion:q,lastUpdated:new Date().toISOString()}));let g=[];try{g.push(...Z(n,f))}catch(e){console.warn(`Warning: Could not update harness workflows: ${e instanceof Error?e.message:String(e)}`)}let v=X(n,e.all?y().map(({id:e})=>e):e.harnesses??[],f);return{success:!0,message:`Protocol updated: v${d} → v${s}${g.length>0?` (updated workflows in ${g.join(`, `)})`:``}${v.length>0?` (installed: ${v.join(`, `)})`:``}${p?` ${p}`:``}`,previousVersion:d,newVersion:s,touchedHarnesses:[...g,...v]}}const Q=z,$=new e;$.name(`autonomos`).description(t.cyan(`CLI for the Autonomos Agent Protocol
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,WORKLOGS_DIR as u,createManifest as d,displayRelative as f,findAncestorAgents as p,findProjectRoot as m,generateAgentTemplate as h,generateManifestContent as g,isSamePath as _,listHarnesses as v,parseManifest as y,readTaskRegistry as b,resolveTargets as x}from"@autonomos/core";import{existsSync as S,lstatSync as C,mkdirSync as w,readFileSync as T,readdirSync as E,statSync as D,writeFileSync as O}from"node:fs";import{basename as k,join as A,relative as j,resolve as M}from"node:path";import{checkbox as N,confirm as P}from"@inquirer/prompts";import{fileURLToPath as F}from"node:url";function I(e,t,r=0){let i=[],a=A(e,n);S(a)&&i.push({path:a,relativePath:j(t,a)||n,depth:r});try{let n=E(e);for(let a of n){if(a.startsWith(`.`)||a===`node_modules`||a===`dist`||a===`build`)continue;let n=A(e,a);try{D(n).isDirectory()&&i.push(...I(n,t,r+1))}catch{}}}catch{}return i}function L(e,t){if(e.length===0)return` (no AGENT.md files found)`;let r=k(t),i={name:r,isAgent:!1,children:{}};for(let t of e){let e=t.relativePath.split(`/`),r=i;for(let t of e){let e=t===n,i=r.children[t];i||(i={name:t,isAgent:e,children:{}},r.children[t]=i),r=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
+ `)}function R(e){return e.length===0?` (no AGENT.md files found in the ancestor chain)`:e.map((t,n)=>` ${(n+1).toString().padStart(e.length.toString().length,` `)}. ${t.relativeDir===`.`?`./AGENT.md`:`${t.relativeDir}/AGENT.md`}`).join(`
4
+ `)}function z(e={}){let t=e.cwd??process.cwd();if(e.target){let n=m(t)??t,r;try{r=p(M(t,e.target),n)}catch(e){return{success:!1,message:`Failed to look up ancestors: ${e instanceof Error?e.message:String(e)}`,mode:`ancestors`}}let i=R(r);return{success:!0,message:`Found ${r.length} ancestor AGENT.md file(s) for "${e.target}" (root → target):\n${i}`,count:r.length,ancestors:r,mode:`ancestors`}}let n;if(e.all){let e=m(t);if(!e)return{success:!1,message:`Could not find project root (.autonomos or .git directory).`,mode:`tree`};n=e}else n=t;let r=I(n,n);if(r.length===0)return{success:!0,message:`No AGENT.md files found.`,count:0,mode:`tree`};let i=L(r,n);return{success:!0,message:`Found ${r.length} AGENT.md file(s)`,tree:i,count:r.length,mode:`tree`}}var B=`0.7.0`;const V=[`protocol-session.md`,`protocol-task.md`,`protocol-crystallize.md`,`protocol-issue.md`,`protocol-adopt.md`,`protocol-reconcile.md`,`protocol-design.md`];function H(e=import.meta.url){let t=F(e);return[M(t,`..`,`..`,`..`,`core`,`src`,`workflows`),M(t,`..`,`..`,`..`,`core`,`dist`,`workflows`),M(t,`..`,`..`,`..`,`..`,`core`,`dist`,`workflows`)]}function U(){let e=H();for(let t of e)if(S(t))return t;throw Error(`Could not locate the workflows directory inside @autonomos/core`)}function W(e,t){return e.replace(/^protocol-/,``).replace(/\.[^.]+$/,``)+t}function G(e,t){if(t!==s)return{state:`unverifiable`,driftedFiles:[]};let n=[];K(A(e,r,a),o,e,n);let i=U(),c=x(v().map(({id:e})=>e),e);for(let t of c){let r=V.map(e=>({source:T(A(i,e),`utf-8`),destination:A(t.path,W(e,t.fileExtension))}));if(r.some(({destination:e})=>S(e)))for(let t of r)K(t.destination,t.source,e,n)}return{state:n.length===0?`valid`:`drifted`,driftedFiles:n}}function K(e,t,n,r){(!S(e)||T(e,`utf-8`)!==t)&&r.push(j(n,e))}const q=B;async function J(){return N({message:`Which AI harnesses do you want to install the protocol for? (space to toggle, enter to confirm)`,choices:v().map(({id:e,harness:t})=>({name:t.name,value:e,checked:t.preferred}))})}async function ee(e,t){let n=[],r=m(e);if(!r)return S(A(e,`.git`))||n.push("No Git repository detected. Consider running `git init` first."),{installDir:e,warnings:n};if(_(r,e))return{installDir:e,warnings:n};let i=f(e,r);return t.force||process.env.AUTONOMOS_FORCE===`1`?(n.push(`Detected project root at ${f(r,e)} (AUTONOMOS_FORCE=1); installing there instead of "${i}".`),{installDir:r,warnings:n}):t.isInteractive&&!t.noPrompt?await P({message:`You're inside a project rooted at ${r}.\nThe protocol should be installed at the project root, not in "${i}".\nInstall at the project root instead?`,default:!0})?(n.push(`Detected project root above "${i}"; installing at ${r}.`),{installDir:r,warnings:n}):{installDir:e,warnings:n,abort:{message:`Aborted: refusing to install Autonomos inside a subdirectory. Run the command from ${r} (or pass --force / set AUTONOMOS_FORCE=1).`}}:{installDir:e,warnings:n,abort:{message:`Cannot initialize Autonomos from a subdirectory.\n Current directory : ${e}\n Detected root : ${r}\nRe-run from the project root, or pass --force (or set AUTONOMOS_FORCE=1) to install here anyway.`}}}async function te(e={}){let t=e.cwd??process.cwd(),f=e.dryRun??!1,p=e.interactiveOverride??(process.stdin.isTTY===!0&&!e.dryRun),m=await ee(t,{force:e.force??!1,noPrompt:e.noPrompt??!1,isInteractive:p});if(m.abort)return{success:!1,message:m.abort.message,created:[],warnings:m.warnings,dryRun:f};let _=m.installDir,y=[...m.warnings],b=[],C=[],E=A(_,`package.json`),k=S(E)&&D(E).isFile(),j=A(_,r),M=S(j),N;if(N=e.all?v().map(({id:e})=>e):e.harnesses&&e.harnesses.length>0?e.harnesses:e.noPrompt||e.dryRun?[]:await J(),M&&N.length===0)return{success:!1,message:`Project already initialized with Protocol v${s}. Use \`autonomos update\` to update, or specify harnesses with --harness to install workflow files.`,created:[],warnings:[],dryRun:f};let P=x(N,_);if(f){M?(b.push(`${r}/${i} (update)`),b.push(`${r}/${a} (update)`)):(b.push(r),b.push(`${r}/${u}`),b.push(`${r}/${i}`),b.push(`${r}/${a}`),b.push(`${r}/${c}`)),S(A(_,n))?y.push(`${n} already exists, would skip.`):b.push(n);for(let e of P)for(let t of V){let n=W(t,e.fileExtension);C.push(`${e.path}/${n}`)}return{success:!0,message:`Would ${M?`update workflows in`:`initialize`} project with Agent Protocol v${s}${N.length?` (harnesses: ${N.join(`, `)})`:``}`,created:b,warnings:y,dryRun:!0,harnessFiles:C}}S(j)||(w(j,{recursive:!0}),b.push(r));let F=A(j,u);S(F)||(w(F,{recursive:!0}),b.push(`${r}/${u}`));let I=d(q);O(A(j,i),g(I)),b.push(`${r}/${i}`),O(A(j,a),o),b.push(`${r}/${a}`);let L=A(j,c);S(L)?y.push(`${c} already exists, skipping.`):(O(L,l),b.push(`${r}/${c}`));let R=A(_,n);if(S(R)?y.push(`${n} already exists, skipping.`):(O(R,h(_.split(`/`).pop()??`Project`)),b.push(n)),k)try{let t=T(E,`utf-8`),n=JSON.parse(t),r=!!n.scripts?.autonomos,i=n.devDependencies?.[`@autonomos/cli`],a=`^${q}`;n.scripts||={},e.noInstall||e.dryRun?(n.scripts.autonomos=`npx --yes @autonomos/cli`,O(E,JSON.stringify(n,null,4)+`
5
+ `),b.push(`package.json (scripts.autonomos via npx)`),r||y.push('Added "autonomos" npm script using npx (--no-install mode). Run `npm install` when ready.')):(n.scripts.autonomos=`autonomos`,n.devDependencies||={},n.devDependencies[`@autonomos/cli`]=a,O(E,JSON.stringify(n,null,4)+`
6
+ `),b.push(`package.json (scripts.autonomos + devDependencies.@autonomos/cli)`),!r&&!i?y.push('Added "autonomos" npm script and @autonomos/cli devDependency. Run `npm install` to install.'):i&&i!==a?y.push(`Bumped @autonomos/cli devDependency: ${i} → ${a}. Run \`npm install\` to apply.`):!r&&i&&y.push(`Added "autonomos" npm script (devDependency was already set).`))}catch{y.push(`Could not update package.json (invalid JSON or read error).`)}let z=U();for(let e of P){w(e.path,{recursive:!0});for(let t of V){let n=T(A(z,t),`utf-8`),r=W(t,e.fileExtension);O(A(e.path,r),n),C.push(`${e.path}/${r}`)}}return{success:!0,message:`Project initialized with Agent Protocol v${s}${N.length>0?` for harnesses: ${N.join(`, `)}`:` (no harness workflows installed)`}`,created:b,warnings:y,dryRun:!1,harnessFiles:C}}function ne(e={}){let t=e.cwd??process.cwd(),n=A(t,r),a=A(n,i);if(S(n)&&!C(n).isDirectory())return{success:!1,message:`Expected a regular .autonomos directory; symbolic links are not followed.`,initialized:!1};if(!S(a))return{success:!1,message:"Project not initialized. Run `autonomos init` first.",initialized:!1};let o;try{o=y(T(a,`utf-8`))}catch{return{success:!1,message:`Could not read manifest.json`,initialized:!0}}let s,l=b(t,{history:e.history}),u=e=>({total:e.length,todo:e.filter(e=>e.status===`TODO`).length,inProgress:e.filter(e=>e.status===`IN_PROGRESS`).length,done:e.filter(e=>e.status===`DONE`).length,blocked:e.filter(e=>e.status===`BLOCKED`).length});S(A(n,c))&&(s=u(l.current));let d=G(t,o.protocolVersion);return{success:!0,message:`Project status retrieved`,protocolVersion:o.protocolVersion,cliVersion:o.cliVersion,initialized:!0,taskSummary:s,...e.history?{archivedTaskSummary:u(l.archived),historyComplete:l.complete}:{},duplicateTaskIds:l.duplicateIds,warnings:l.warnings,artifactIntegrity:d.state,driftedArtifacts:d.driftedFiles}}const Y=B;function re(e,t){let n=e=>{let[t=``,n]=e.split(`-`,2);return{parts:t.split(`.`).map(Number),prerelease:n}},r=n(e),i=n(t);for(let e=0;e<3;e++){let t=r.parts[e]??0,n=i.parts[e]??0;if(t<n)return-1;if(t>n)return 1}return r.prerelease===i.prerelease?0:r.prerelease===void 0?1:i.prerelease===void 0?-1:r.prerelease.localeCompare(i.prerelease)}function ie(e){let t=A(e,`package.json`);if(!S(t))return null;let n;try{n=JSON.parse(T(t,`utf-8`))}catch{return null}let r=`^${Y}`,i=n.devDependencies?.[`@autonomos/cli`];if(i===r)return null;n.devDependencies||={},n.devDependencies[`@autonomos/cli`]=r;try{O(t,JSON.stringify(n,null,4)+`
7
+ `)}catch{return null}return i?`Bumped @autonomos/cli devDependency: ${i} → ${r}.`:`Added @autonomos/cli devDependency: ${r}.`}function X(e,t,n){if(t.length===0)return[];let r=x(t,e),i=[];for(let e of r){w(e.path,{recursive:!0});for(let t of V){let r=T(A(n,t),`utf-8`),a=W(t,e.fileExtension);O(A(e.path,a),r),i.push(`${e.path}/${a}`)}}return i}function Z(e,t){let n=x(v().map(({id:e})=>e),e),r=[];for(let e of n){if(!S(e.path))continue;let n=V.map(n=>({source:T(A(t,n),`utf-8`),dest:A(e.path,W(n,e.fileExtension))}));if(!n.some(({dest:e})=>S(e)))continue;let i=!1;for(let{source:e,dest:t}of n)(!S(t)||T(t,`utf-8`)!==e)&&(O(t,e),i=!0);i&&r.push(e.path)}return r}function ae(e={}){let t=e.cwd??process.cwd(),n=m(t)??t,c=A(n,r),l=A(c,i);if(!S(l))return{success:!1,message:"Project not initialized. Run `autonomos init` first."};let u=y(T(l,`utf-8`)),d=u.protocolVersion,f;try{f=(e.resolveWorkflowsDir??U)()}catch(e){return{success:!1,message:`Cannot update protocol artifacts: ${e instanceof Error?e.message:String(e)}`,previousVersion:d,newVersion:s}}let p=ie(n),h=re(d,s);if(h===0){let t=[];try{t=Z(n,f)}catch(e){console.warn(`Warning: Could not update harness workflows: ${e instanceof Error?e.message:String(e)}`)}let r=X(n,e.all?v().map(({id:e})=>e):e.harnesses??[],f);return(u.cliVersion!==Y||t.length>0||r.length>0)&&O(l,g({...u,cliVersion:Y,lastUpdated:new Date().toISOString()})),{success:!0,message:`Already up to date (Protocol v${s}).${t.length>0?` Refreshed workflows in ${t.join(`, `)}.`:``}${r.length>0?` Installed: ${r.join(`, `)}.`:``}${p?` ${p}`:``}`,previousVersion:d,newVersion:s,touchedHarnesses:[...t,...r]}}if(h>0)return{success:!1,message:`This project uses Protocol v${d}, but your CLI only knows v${s}. Update your CLI with \`npm i -g @autonomos/cli\`.`,previousVersion:d,newVersion:s,cliOutdated:!0};O(A(c,a),o),O(l,g({...u,protocolVersion:s,cliVersion:Y,lastUpdated:new Date().toISOString()}));let _=[];try{_.push(...Z(n,f))}catch(e){console.warn(`Warning: Could not update harness workflows: ${e instanceof Error?e.message:String(e)}`)}let b=X(n,e.all?v().map(({id:e})=>e):e.harnesses??[],f);return{success:!0,message:`Protocol updated: v${d} → v${s}${_.length>0?` (updated workflows in ${_.join(`, `)})`:``}${b.length>0?` (installed: ${b.join(`, `)})`:``}${p?` ${p}`:``}`,previousVersion:d,newVersion:s,touchedHarnesses:[..._,...b]}}const Q=B,$=new e;$.name(`autonomos`).description(t.cyan(`CLI for the Autonomos Agent Protocol
8
8
 
9
9
  The Agent Protocol is a specification for AI agents to interact with codebases
10
10
  in a structured, consistent way. It defines how agents should read context,
@@ -19,7 +19,8 @@ ${t.bold(`Examples:`)}
19
19
 
20
20
  Project knowledge workflows installed for supported harnesses include
21
21
  ${t.cyan(`/issue`)} (triage), ${t.cyan(`/adopt`)} (reviewable migration),
22
- ${t.cyan(`/reconcile`)} (drift audit), and ${t.cyan(`/crystallize`)} (close-out).
22
+ ${t.cyan(`/reconcile`)} (drift repair and archival), ${t.cyan(`/design`)} (project-specific
23
+ direction), and ${t.cyan(`/crystallize`)} (close-out).
23
24
 
24
25
  ${t.bold(`More info:`)}
25
26
  Run '${t.cyan(`autonomos <command> --help`)}' for detailed information about a command.
@@ -33,11 +34,12 @@ This command creates the following structure:
33
34
  ${t.white(`AGENT.md`)} # Project context file (at root)
34
35
 
35
36
  Additionally, when one or more harnesses are selected, the protocol workflow
36
- files (session / task / issue / adopt / reconcile / crystallize) are installed at the harness-specific
37
+ files (session / task / issue / adopt / reconcile / design / crystallize) are installed at the harness-specific
37
38
  target directory, e.g. .clinerules/workflows/ for Cline, .claude/skills/ for
38
39
  Claude Code, .agents/skills/ for the cross-tool standard (Cursor, Codex, etc.).
39
- Optional project-owned specs and decisions directories are created only when the
40
- project first adopts them; init never creates empty directories for them.
40
+ Optional project-owned archives, specs and decisions directories are created only when the
41
+ project first adopts them; \`DESIGN.md\` is never created automatically, and init
42
+ never creates empty directories for project-owned records.
41
43
 
42
44
  ${t.bold(`Harness selection:`)}
43
45
  (default) Interactive multi-select prompt at the start of init.
@@ -59,11 +61,12 @@ ${t.bold(`Project root detection:`)}
59
61
  git/Autonomos project. Run it from the project root, or pass
60
62
  ${t.cyan(`--force`)} (or set ${t.cyan(`AUTONOMOS_FORCE=1`)}) to install
61
63
  in ${t.cyan(`cwd`)} anyway. In a TTY, you'll be asked to confirm.
62
- `).option(`-n, --dry-run`,`Preview what would be created without writing files`).option(`--harness <name...>`,`Install workflows for the specified harness id(s); skip the prompt`).option(`--all`,`Install workflows for all known harnesses; skip the prompt`).option(`--no-prompt`,`Skip the interactive harness prompt (use with --harness or --all)`).option(`--no-install`,`Skip installing @autonomos/cli as devDependency; use npx instead`).option(`-f, --force`,`Install in cwd even if a parent project root is detected (also via AUTONOMOS_FORCE=1)`).action(async e=>{try{let n=await ne({dryRun:e.dryRun,harnesses:e.harness,all:e.all,noPrompt:e.prompt===!1,noInstall:e.install===!1,force:e.force});n.success||(console.error(t.red(`\nāŒ ${n.message}`)),process.exit(1)),n.dryRun?console.log(t.cyan(`\nšŸ” ${n.message} (dry-run)`)):console.log(t.green(`\nāœ… ${n.message}`)),n.created.length>0&&(console.log(`\n${t.bold(n.dryRun?`Would create:`:`Created:`)}`),n.created.forEach(e=>console.log(` ${t.blue(`šŸ“„`)} ${t.white(e)}`))),n.harnessFiles&&n.harnessFiles.length>0&&(console.log(`\n${t.bold(`Harness workflow files:`)}`),n.harnessFiles.forEach(e=>console.log(` ${t.cyan(`āš™ļø `)} ${t.white(e)}`))),n.warnings.length>0&&(console.log(t.yellow(`
64
+ `).option(`-n, --dry-run`,`Preview what would be created without writing files`).option(`--harness <name...>`,`Install workflows for the specified harness id(s); skip the prompt`).option(`--all`,`Install workflows for all known harnesses; skip the prompt`).option(`--no-prompt`,`Skip the interactive harness prompt (use with --harness or --all)`).option(`--no-install`,`Skip installing @autonomos/cli as devDependency; use npx instead`).option(`-f, --force`,`Install in cwd even if a parent project root is detected (also via AUTONOMOS_FORCE=1)`).action(async e=>{try{let n=await te({dryRun:e.dryRun,harnesses:e.harness,all:e.all,noPrompt:e.prompt===!1,noInstall:e.install===!1,force:e.force});n.success||(console.error(t.red(`\nāŒ ${n.message}`)),process.exit(1)),n.dryRun?console.log(t.cyan(`\nšŸ” ${n.message} (dry-run)`)):console.log(t.green(`\nāœ… ${n.message}`)),n.created.length>0&&(console.log(`\n${t.bold(n.dryRun?`Would create:`:`Created:`)}`),n.created.forEach(e=>console.log(` ${t.blue(`šŸ“„`)} ${t.white(e)}`))),n.harnessFiles&&n.harnessFiles.length>0&&(console.log(`\n${t.bold(`Harness workflow files:`)}`),n.harnessFiles.forEach(e=>console.log(` ${t.cyan(`āš™ļø `)} ${t.white(e)}`))),n.warnings.length>0&&(console.log(t.yellow(`
63
65
  Warnings:`)),n.warnings.forEach(e=>console.log(` ${t.yellow(`āš ļø`)} ${e}`)))}catch(e){let n=e instanceof Error?e.message:String(e);console.error(t.red(`\nāŒ ${n}`)),process.exit(1)}}),$.command(`update`).description(`Update the Protocol to the latest version`).addHelpText(`after`,`
64
66
  This command updates the managed protocol artifacts embedded in the CLI.
65
67
  Your ${t.white(`AGENT.md`)}, ${t.white(`TASKS.md`)}, ${t.white(`ISSUES.md`)},
66
- worklogs, specifications, decisions, and user documentation are preserved.
68
+ worklogs, archives, specifications, decisions, and user documentation are preserved.
69
+ Installing an update never archives project records automatically.
67
70
 
68
71
  It also:
69
72
  - Refreshes the @autonomos/cli devDependency in your package.json to the
@@ -84,16 +87,20 @@ ${t.bold(`Examples:`)}
84
87
  $ ${t.cyan(`autonomos update --harness opencode`)}
85
88
  $ ${t.cyan(`autonomos update --harness opencode --harness kilocode`)}
86
89
  $ ${t.cyan(`autonomos update --all`)}
87
- `).option(`--harness <name...>`,`Install workflow files for the specified harness id(s) in addition to refreshing existing ones`).option(`--all`,`Install workflow files for every known harness in addition to refreshing existing ones`).action(e=>{let n=ie({harnesses:e.harness,all:e.all});n.success||(n.cliOutdated?console.error(t.yellow(`\nāš ļø ${n.message}`)):console.error(t.red(`\nāŒ ${n.message}`)),process.exit(1)),console.log(t.green(`\nāœ… ${n.message}`))}),$.command(`status`).description(`Show project status and task summary`).addHelpText(`after`,`
90
+ `).option(`--harness <name...>`,`Install workflow files for the specified harness id(s) in addition to refreshing existing ones`).option(`--all`,`Install workflow files for every known harness in addition to refreshing existing ones`).action(e=>{let n=ae({harnesses:e.harness,all:e.all});n.success||(n.cliOutdated?console.error(t.yellow(`\nāš ļø ${n.message}`)):console.error(t.red(`\nāŒ ${n.message}`)),process.exit(1)),console.log(t.green(`\nāœ… ${n.message}`))}),$.command(`status`).description(`Show project status and task summary`).addHelpText(`after`,`
88
91
  Displays information about the current project:
89
92
  - Protocol version
90
93
  - Protocol artifact integrity for the installed version
91
94
  - CLI version used for initialization
92
- - Task summary (todo, in-progress, done, blocked)
95
+ - Current task registry summary (todo, in-progress, done, blocked)
96
+ - With --history: separate archived counts and task ID collisions
97
+ Only archive/**/TASKS.md registries are counted; history is not read by default.
98
+ Archived does not imply completed. Read diagnostics and partial counts are explicit.
93
99
 
94
100
  ${t.bold(`Examples:`)}
95
101
  $ ${t.cyan(`autonomos status`)}
96
- `).action(()=>{let e=re();if(e.success||(console.error(t.red(`\nāŒ ${e.message}`)),process.exit(1)),console.log(`\n${t.bold(`šŸ“¦ Protocol`)} ${t.green(`v${e.protocolVersion}`)} ${t.dim(`(CLI v${e.cliVersion})`)}`),e.artifactIntegrity===`valid`)console.log(` ${t.green(`āœ“ Artifacts match the published protocol version`)}`);else if(e.artifactIntegrity===`drifted`){console.log(` ${t.red(`āœ— Protocol artifact drift detected`)}`);for(let n of e.driftedArtifacts??[])console.log(` ${t.red(`•`)} ${n}`);console.log(` ${t.dim("Run `autonomos update` to restore canonical artifacts.")}`)}else console.log(` ${t.yellow(`! Artifact integrity is unverifiable with this CLI version`)}`);if(e.taskSummary){let n=e.taskSummary;console.log(`\n${t.bold(`šŸ“‹ Tasks:`)} ${t.cyan(n.total)} total`),console.log(` ${t.white(`⬜ Todo:`)} ${t.white(n.todo)}`),console.log(` ${t.blue(`šŸ”„ In Progress:`)} ${t.blue(n.inProgress)}`),console.log(` ${t.green(`āœ… Done:`)} ${t.green(n.done)}`),n.blocked>0&&console.log(` ${t.red(`🚫 Blocked:`)} ${t.red(n.blocked)}`)}}),$.command(`agents`).description(`List all AGENT.md files in the project, or the ancestor chain for a path`).argument(`[path]`,`Optional file or folder. When provided, return the ordered list of ancestor AGENT.md files (root -> target) instead of the full tree.`).option(`-a, --all`,`In tree mode: search from project root instead of current directory`).addHelpText(`after`,`
102
+ $ ${t.cyan(`autonomos status --history`)}
103
+ `).option(`--history`,`Include archived task registries and check reserved task IDs`).action(e=>{let n=ne({history:e.history});if(n.success||(console.error(t.red(`\nāŒ ${n.message}`)),process.exit(1)),console.log(`\n${t.bold(`šŸ“¦ Protocol`)} ${t.green(`v${n.protocolVersion}`)} ${t.dim(`(CLI v${n.cliVersion})`)}`),n.artifactIntegrity===`valid`)console.log(` ${t.green(`āœ“ Artifacts match the published protocol version`)}`);else if(n.artifactIntegrity===`drifted`){console.log(` ${t.red(`āœ— Protocol artifact drift detected`)}`);for(let e of n.driftedArtifacts??[])console.log(` ${t.red(`•`)} ${e}`);console.log(` ${t.dim("Run `autonomos update` to restore canonical artifacts.")}`)}else console.log(` ${t.yellow(`! Artifact integrity is unverifiable with this CLI version`)}`);if(n.taskSummary){let e=n.taskSummary;console.log(`\n${t.bold(`šŸ“‹ Current tasks:`)} ${t.cyan(e.total)} total`),console.log(` ${t.white(`⬜ Todo:`)} ${t.white(e.todo)}`),console.log(` ${t.blue(`šŸ”„ In Progress:`)} ${t.blue(e.inProgress)}`),console.log(` ${t.green(`āœ… Done:`)} ${t.green(e.done)}`),e.blocked>0&&console.log(` ${t.red(`🚫 Blocked:`)} ${t.red(e.blocked)}`)}if(n.archivedTaskSummary){let e=n.archivedTaskSummary;console.log(`\n${t.bold(`Historical task records:`)} ${e.total}${n.historyComplete?``:` (incomplete scan)`}`),console.log(` Todo: ${e.todo}; in progress: ${e.inProgress}; done: ${e.done}; blocked: ${e.blocked}`),console.log(t.dim(` Historical status is not current work; archived does not mean completed.`))}for(let e of n.warnings??[])console.warn(t.yellow(`! ${e}`));n.duplicateTaskIds?.length&&console.warn(t.yellow(`! Duplicate task IDs: ${n.duplicateTaskIds.join(`, `)}`)),(n.warnings?.length||n.duplicateTaskIds?.length)&&(process.exitCode=1)}),$.command(`agents`).description(`List all AGENT.md files in the project, or the ancestor chain for a path`).argument(`[path]`,`Optional file or folder. When provided, return the ordered list of ancestor AGENT.md files (root -> target) instead of the full tree.`).option(`-a, --all`,`In tree mode: search from project root instead of current directory`).addHelpText(`after`,`
97
104
  This command has two modes:
98
105
 
99
106
  ${t.bold(`Tree mode`)} (default, or with ${t.cyan(`--all`)}):
@@ -111,7 +118,7 @@ ${t.bold(`Examples:`)}
111
118
  $ ${t.cyan(`autonomos agents --all`)} # Tree, from project root
112
119
  $ ${t.cyan(`autonomos agents apps/web`)} # Ancestors for apps/web
113
120
  $ ${t.cyan(`autonomos agents apps/web/components/ui/button.tsx`)} # Ancestors for a file
114
- `).action((e,n)=>{let r=R({all:n.all,target:e});r.success||(console.error(t.red(`
121
+ `).action((e,n)=>{let r=z({all:n.all,target:e});r.success||(console.error(t.red(`
115
122
  āŒ ${r.message}`)),process.exit(1)),r.mode===`ancestors`?console.log(t.cyan(`
116
123
  šŸ” ${r.message}`)):(console.log(`
117
124
  `+(r.tree??r.message)),console.log(t.dim(`
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["CLI_VERSION","packageJson.version","CLI_VERSION","packageJson.version","packageJson.version"],"sources":["../src/commands/agents.ts","../package.json","../src/protocol-artifacts.ts","../src/commands/init.ts","../src/commands/status.ts","../src/commands/update.ts","../src/index.ts"],"sourcesContent":["import { existsSync, readdirSync, statSync } from 'node:fs'\nimport { basename, join, relative, resolve } from 'node:path'\n\nimport {\n AGENT_FILE,\n findAncestorAgents,\n findProjectRoot,\n type AncestorAgent,\n} from '@autonomos/core'\n\ninterface AgentsOptions {\n cwd?: string\n /**\n * When true, search from the project root (discovered by walking up to\n * .autonomos or .git) instead of the current directory.\n */\n all?: boolean\n /**\n * Optional target path (file or directory). When provided, the command\n * switches to \"ancestor lookup\" mode and prints the ordered list of\n * AGENT.md files on the path from the target up to the project root.\n * Existing ancestors only; gaps are silently skipped.\n */\n target?: string\n}\n\ninterface AgentEntry {\n path: string\n relativePath: string\n depth: number\n}\n\n/**\n * Recursively find all AGENT.md files in a directory\n */\nfunction findAgentFiles(dir: string, baseDir: string, depth = 0): AgentEntry[] {\n const entries: AgentEntry[] = []\n\n // Check if AGENT.md exists in current directory\n const agentPath = join(dir, AGENT_FILE)\n if (existsSync(agentPath)) {\n entries.push({\n path: agentPath,\n relativePath: relative(baseDir, agentPath) || AGENT_FILE,\n depth,\n })\n }\n\n // Scan subdirectories\n try {\n const items = readdirSync(dir)\n for (const item of items) {\n // Skip hidden directories and node_modules\n if (\n item.startsWith('.') ||\n item === 'node_modules' ||\n item === 'dist' ||\n item === 'build'\n ) {\n continue\n }\n\n const itemPath = join(dir, item)\n try {\n if (statSync(itemPath).isDirectory()) {\n entries.push(...findAgentFiles(itemPath, baseDir, depth + 1))\n }\n } catch {\n // Skip inaccessible directories\n }\n }\n } catch {\n // Skip inaccessible directories\n }\n\n return entries\n}\n\ninterface TreeNode {\n name: string\n isAgent: boolean\n children: Record<string, TreeNode>\n}\n\n/**\n * Format agent entries as a true tree structure\n */\nfunction formatAsTree(entries: AgentEntry[], baseDir: string): string {\n if (entries.length === 0) {\n return ' (no AGENT.md files found)'\n }\n\n const rootName = basename(baseDir)\n const tree: TreeNode = { name: rootName, isAgent: false, children: {} }\n\n // Build the tree\n for (const entry of entries) {\n const parts = entry.relativePath.split('/')\n let current = tree\n\n for (const part of parts) {\n const isAgent = part === AGENT_FILE\n\n let child = current.children[part]\n if (!child) {\n child = {\n name: part,\n isAgent,\n children: {},\n }\n current.children[part] = child\n }\n current = child\n }\n }\n\n const lines: string[] = []\n lines.push(`šŸ“ ${rootName}/`)\n\n function render(node: TreeNode, prefix = '', _isLast = true): void {\n const children = Object.values(node.children)\n children.sort((a, b) => {\n // Folders first\n if (!a.isAgent && b.isAgent) return -1\n if (a.isAgent && !b.isAgent) return 1\n return a.name.localeCompare(b.name)\n })\n\n children.forEach((child, index) => {\n const childIsLast = index === children.length - 1\n const branch = childIsLast ? '└── ' : 'ā”œā”€ā”€ '\n const icon = child.isAgent ? 'šŸ“„' : 'šŸ“'\n const name = child.isAgent ? child.name : `${child.name}/`\n\n lines.push(`${prefix}${branch}${icon} ${name}`)\n\n if (!child.isAgent) {\n const nextPrefix = prefix + (childIsLast ? ' ' : '│ ')\n render(child, nextPrefix, childIsLast)\n }\n })\n }\n\n render(tree)\n return lines.join('\\n')\n}\n\n/**\n * Format the ancestor-lookup result as a numbered, root-first list.\n */\nfunction formatAncestors(ancestors: AncestorAgent[]): string {\n if (ancestors.length === 0) {\n return ' (no AGENT.md files found in the ancestor chain)'\n }\n const lines = ancestors.map((a, i) => {\n const idx = (i + 1).toString().padStart(ancestors.length.toString().length, ' ')\n return ` ${idx}. ${a.relativeDir === '.' ? './AGENT.md' : `${a.relativeDir}/AGENT.md`}`\n })\n return lines.join('\\n')\n}\n\ninterface AgentsResult {\n success: boolean\n message: string\n tree?: string\n count?: number\n /**\n * When in ancestor-lookup mode, the list of ancestor AGENT.md files\n * (root-first order). Each entry has `dir`, `path`, `relativeDir`.\n */\n ancestors?: AncestorAgent[]\n /** The mode that was used. Useful for the caller to format output. */\n mode: 'tree' | 'ancestors'\n}\n\n/**\n * List AGENT.md files in the project.\n *\n * Two modes:\n *\n * 1. **Tree mode** (default, or with `--all`): list all AGENT.md files\n * in a tree structure. Used at session start to get the full fractal\n * picture of the project.\n *\n * 2. **Ancestors mode** (with a positional `<path>` argument): return\n * the ordered list of AGENT.md files on the path from the target\n * up to the project root. Root-first, with non-existent ancestors\n * silently skipped. Used at task start to get the precise fractal\n * context for the file or folder being worked on.\n */\nexport function agents(options: AgentsOptions = {}): AgentsResult {\n const cwd = options.cwd ?? process.cwd()\n\n // --- Ancestors mode (positional <path> arg) ---\n if (options.target) {\n const projectRoot = findProjectRoot(cwd) ?? cwd\n let ancestors: AncestorAgent[]\n try {\n ancestors = findAncestorAgents(resolve(cwd, options.target), projectRoot)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n return {\n success: false,\n message: `Failed to look up ancestors: ${message}`,\n mode: 'ancestors',\n }\n }\n const list = formatAncestors(ancestors)\n return {\n success: true,\n message: `Found ${ancestors.length} ancestor AGENT.md file(s) for \"${options.target}\" (root → target):\\n${list}`,\n count: ancestors.length,\n ancestors,\n mode: 'ancestors',\n }\n }\n\n // --- Tree mode (default) ---\n let searchBase: string\n if (options.all) {\n const projectRoot = findProjectRoot(cwd)\n if (!projectRoot) {\n return {\n success: false,\n message: 'Could not find project root (.autonomos or .git directory).',\n mode: 'tree',\n }\n }\n searchBase = projectRoot\n } else {\n searchBase = cwd\n }\n\n const entries = findAgentFiles(searchBase, searchBase)\n\n if (entries.length === 0) {\n return {\n success: true,\n message: 'No AGENT.md files found.',\n count: 0,\n mode: 'tree',\n }\n }\n\n const tree = formatAsTree(entries, searchBase)\n return {\n success: true,\n message: `Found ${entries.length} AGENT.md file(s)`,\n tree,\n count: entries.length,\n mode: 'tree',\n }\n}\n","","import { existsSync, readFileSync } from 'node:fs'\nimport { join, relative, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport {\n AUTONOMOS_DIR,\n listHarnesses,\n PROTOCOL_FILE,\n PROTOCOL_TEMPLATE,\n PROTOCOL_VERSION,\n resolveTargets,\n} from '@autonomos/core'\n\nexport const WORKFLOW_FILES = [\n 'protocol-session.md',\n 'protocol-task.md',\n 'protocol-crystallize.md',\n 'protocol-issue.md',\n 'protocol-adopt.md',\n 'protocol-reconcile.md',\n] as const\n\nexport type ArtifactIntegrity = 'valid' | 'drifted' | 'unverifiable'\n\nexport interface ArtifactIntegrityResult {\n state: ArtifactIntegrity\n driftedFiles: string[]\n}\n\nexport function getWorkflowDirCandidates(moduleUrl: string = import.meta.url): string[] {\n const here = fileURLToPath(moduleUrl)\n return [\n resolve(here, '..', '..', '..', 'core', 'src', 'workflows'),\n resolve(here, '..', '..', '..', 'core', 'dist', 'workflows'),\n resolve(here, '..', '..', '..', '..', 'core', 'dist', 'workflows'),\n ]\n}\n\nexport function getWorkflowsDir(): string {\n const candidates = getWorkflowDirCandidates()\n for (const candidate of candidates) {\n if (existsSync(candidate)) return candidate\n }\n throw new Error('Could not locate the workflows directory inside @autonomos/core')\n}\n\nexport function buildTargetFilename(sourceFile: string, targetExtension: string): string {\n const withoutPrefix = sourceFile.replace(/^protocol-/, '')\n const withoutExt = withoutPrefix.replace(/\\.[^.]+$/, '')\n return withoutExt + targetExtension\n}\n\nexport function verifyProtocolArtifacts(\n cwd: string,\n declaredVersion: string\n): ArtifactIntegrityResult {\n if (declaredVersion !== PROTOCOL_VERSION) {\n return { state: 'unverifiable', driftedFiles: [] }\n }\n\n const driftedFiles: string[] = []\n const protocolPath = join(cwd, AUTONOMOS_DIR, PROTOCOL_FILE)\n compareFile(protocolPath, PROTOCOL_TEMPLATE, cwd, driftedFiles)\n\n const workflowsDir = getWorkflowsDir()\n const targets = resolveTargets(\n listHarnesses().map(({ id }) => id),\n cwd\n )\n\n for (const target of targets) {\n const expected = WORKFLOW_FILES.map(sourceFile => ({\n source: readFileSync(join(workflowsDir, sourceFile), 'utf-8'),\n destination: join(target.path, buildTargetFilename(sourceFile, target.fileExtension)),\n }))\n if (!expected.some(({ destination }) => existsSync(destination))) continue\n for (const file of expected) {\n compareFile(file.destination, file.source, cwd, driftedFiles)\n }\n }\n\n return {\n state: driftedFiles.length === 0 ? 'valid' : 'drifted',\n driftedFiles,\n }\n}\n\nfunction compareFile(path: string, expected: string, cwd: string, driftedFiles: string[]): void {\n if (!existsSync(path) || readFileSync(path, 'utf-8') !== expected) {\n driftedFiles.push(relative(cwd, path))\n }\n}\n","import { checkbox, confirm } from '@inquirer/prompts'\nimport { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport {\n AGENT_FILE,\n AUTONOMOS_DIR,\n createManifest,\n displayRelative,\n findProjectRoot,\n generateAgentTemplate,\n generateManifestContent,\n isSamePath,\n listHarnesses,\n MANIFEST_FILE,\n PROTOCOL_FILE,\n PROTOCOL_TEMPLATE,\n PROTOCOL_VERSION,\n resolveTargets,\n TASKS_FILE,\n TASKS_TEMPLATE,\n WORKLOGS_DIR,\n} from '@autonomos/core'\n\n// Synchronize with the package.json version at build time. The bundler\n// inlines this JSON, so the resolved value is always current.\n// (package.json import — inlined by the bundler)\nimport packageJson from '../../package.json' with { type: 'json' }\nimport { buildTargetFilename, getWorkflowsDir, WORKFLOW_FILES } from '../protocol-artifacts'\nconst CLI_VERSION: string = packageJson.version\n\ninterface InitOptions {\n cwd?: string\n dryRun?: boolean\n /** Specific harness ids to install for. */\n harnesses?: string[]\n /** Install for all known harnesses (overrides `harnesses`). */\n all?: boolean\n /** Skip the interactive prompt even when no harnesses are specified. */\n noPrompt?: boolean\n /** When true, skip installing @autonomos/cli devDependency.\n * The npm script will use npx instead. */\n noInstall?: boolean\n /**\n * When true, ignore the \"you're inside a bigger project\" check and\n * initialize the protocol in `cwd` no matter what. Mirrors the\n * `AUTONOMOS_FORCE=1` env var, which is more convenient in scripts.\n */\n force?: boolean\n /**\n * When set, treat stdin as a TTY (true) or non-TTY (false) regardless\n * of the real value. Tests use this to opt in/out of the project-root\n * confirmation prompt without mutating the real TTY state.\n */\n interactiveOverride?: boolean\n}\n\nexport interface ResolveInstallResult {\n installDir: string\n warnings: string[]\n abort?: { message: string }\n}\n\ninterface ResolveInstallOptions {\n force: boolean\n noPrompt: boolean\n isInteractive: boolean\n}\n\ninterface InitResult {\n success: boolean\n message: string\n created: string[]\n warnings: string[]\n dryRun?: boolean\n harnessFiles?: string[]\n}\n\n/**\n * Prompt the user interactively for which harnesses to install for.\n * Returns the selected harness ids. An empty array means the user chose\n * to skip harness installation entirely.\n */\nasync function promptForHarnesses(): Promise<string[]> {\n const harnesses = listHarnesses()\n return checkbox({\n message:\n 'Which AI harnesses do you want to install the protocol for? (space to toggle, enter to confirm)',\n choices: harnesses.map(({ id, harness }) => ({\n name: harness.name,\n value: id,\n checked: harness.preferred,\n })),\n })\n}\n\n/**\n * Resolve which directory the protocol should be installed into.\n *\n * The protocol expects to live at the root of the user's project (where\n * `.git` / `.autonomos` already exists, or where one would be created).\n * When `init` is invoked from a subdirectory of such a project, we must\n * either:\n *\n * - point the user at the actual root and refuse to install, or\n * - install at the detected root on their behalf.\n *\n * We pick the first option by default, because silently installing\n * elsewhere is the bug that motivated this helper. The user can opt\n * into the second behavior with `--force` or `AUTONOMOS_FORCE=1`.\n *\n * Returns the directory to install in. When the caller passes `--force`\n * (or the env var is set), and a different project root is detected, we\n * install at that root instead. In interactive mode we also confirm the\n * detour with the user.\n */\nexport async function resolveInstallDir(\n requestedCwd: string,\n options: ResolveInstallOptions\n): Promise<ResolveInstallResult> {\n const warnings: string[] = []\n const detectedRoot = findProjectRoot(requestedCwd)\n\n // No project root found above us: nothing to bubble up to. Either\n // we're in a fresh directory (warn about no git) or we're literally\n // at the root of a project that uses neither marker. Either way we\n // install in place.\n if (!detectedRoot) {\n if (!existsSync(join(requestedCwd, '.git'))) {\n warnings.push('No Git repository detected. Consider running `git init` first.')\n }\n return { installDir: requestedCwd, warnings }\n }\n\n // The project root is exactly where we are: ideal case, no detour.\n if (isSamePath(detectedRoot, requestedCwd)) {\n return { installDir: requestedCwd, warnings }\n }\n\n // The project root is somewhere above us. Decide what to do.\n const relCwd = displayRelative(requestedCwd, detectedRoot)\n const force = options.force || process.env.AUTONOMOS_FORCE === '1'\n\n if (force) {\n warnings.push(\n `Detected project root at ${displayRelative(detectedRoot, requestedCwd)} ` +\n `(AUTONOMOS_FORCE=1); installing there instead of \"${relCwd}\".`\n )\n return { installDir: detectedRoot, warnings }\n }\n\n if (options.isInteractive && !options.noPrompt) {\n const proceed = await confirm({\n message:\n `You're inside a project rooted at ${detectedRoot}.\\n` +\n `The protocol should be installed at the project root, not in \"${relCwd}\".\\n` +\n `Install at the project root instead?`,\n default: true,\n })\n if (proceed) {\n warnings.push(`Detected project root above \"${relCwd}\"; installing at ${detectedRoot}.`)\n return { installDir: detectedRoot, warnings }\n }\n return {\n installDir: requestedCwd,\n warnings,\n abort: {\n message:\n `Aborted: refusing to install Autonomos inside a subdirectory. ` +\n `Run the command from ${detectedRoot} (or pass --force / set AUTONOMOS_FORCE=1).`,\n },\n }\n }\n\n return {\n installDir: requestedCwd,\n warnings,\n abort: {\n message:\n `Cannot initialize Autonomos from a subdirectory.\\n` +\n ` Current directory : ${requestedCwd}\\n` +\n ` Detected root : ${detectedRoot}\\n` +\n `Re-run from the project root, or pass --force (or set AUTONOMOS_FORCE=1) to install here anyway.`,\n },\n }\n}\n\n/**\n * Initialize the Autonomos Agent Protocol in a directory.\n */\nexport async function init(options: InitOptions = {}): Promise<InitResult> {\n const requestedCwd = options.cwd ?? process.cwd()\n const dryRun = options.dryRun ?? false\n\n // Resolve the install target. We do this before any other check so a\n // bad install location fails fast with a clear message.\n const isInteractive =\n options.interactiveOverride ?? (process.stdin.isTTY === true && !options.dryRun)\n const resolution = await resolveInstallDir(requestedCwd, {\n force: options.force ?? false,\n noPrompt: options.noPrompt ?? false,\n isInteractive,\n })\n if (resolution.abort) {\n return {\n success: false,\n message: resolution.abort.message,\n created: [],\n warnings: resolution.warnings,\n dryRun,\n }\n }\n const cwd = resolution.installDir\n const warnings: string[] = [...resolution.warnings]\n\n const created: string[] = []\n const harnessFiles: string[] = []\n\n // Detect package.json for npm script registration\n const packageJsonPath = join(cwd, 'package.json')\n const hasPackageJson = existsSync(packageJsonPath) && statSync(packageJsonPath).isFile()\n\n // Check if already initialized\n const autonomosDir = join(cwd, AUTONOMOS_DIR)\n const isInitialized = existsSync(autonomosDir)\n\n // Resolve which harnesses to install for\n let selectedHarnesses: string[]\n if (options.all) {\n selectedHarnesses = listHarnesses().map(({ id }) => id)\n } else if (options.harnesses && options.harnesses.length > 0) {\n selectedHarnesses = options.harnesses\n } else if (options.noPrompt || options.dryRun) {\n selectedHarnesses = []\n } else {\n selectedHarnesses = await promptForHarnesses()\n }\n\n if (isInitialized && selectedHarnesses.length === 0) {\n return {\n success: false,\n message: `Project already initialized with Protocol v${PROTOCOL_VERSION}. Use \\`autonomos update\\` to update, or specify harnesses with --harness to install workflow files.`,\n created: [],\n warnings: [],\n dryRun,\n }\n }\n\n // Compute the unique target directories\n const targets = resolveTargets(selectedHarnesses, cwd)\n\n // In dry-run mode, just collect what would be created\n if (dryRun) {\n if (!isInitialized) {\n created.push(AUTONOMOS_DIR)\n created.push(`${AUTONOMOS_DIR}/${WORKLOGS_DIR}`)\n created.push(`${AUTONOMOS_DIR}/${MANIFEST_FILE}`)\n created.push(`${AUTONOMOS_DIR}/${PROTOCOL_FILE}`)\n created.push(`${AUTONOMOS_DIR}/${TASKS_FILE}`)\n } else {\n created.push(`${AUTONOMOS_DIR}/${MANIFEST_FILE} (update)`)\n created.push(`${AUTONOMOS_DIR}/${PROTOCOL_FILE} (update)`)\n }\n\n const agentPath = join(cwd, AGENT_FILE)\n if (!existsSync(agentPath)) {\n created.push(AGENT_FILE)\n } else {\n warnings.push(`${AGENT_FILE} already exists, would skip.`)\n }\n\n for (const target of targets) {\n for (const workflowFile of WORKFLOW_FILES) {\n const filename = buildTargetFilename(workflowFile, target.fileExtension)\n harnessFiles.push(`${target.path}/${filename}`)\n }\n }\n\n return {\n success: true,\n message: `Would ${isInitialized ? 'update workflows in' : 'initialize'} project with Agent Protocol v${PROTOCOL_VERSION}${selectedHarnesses.length ? ` (harnesses: ${selectedHarnesses.join(', ')})` : ''}`,\n created,\n warnings,\n dryRun: true,\n harnessFiles,\n }\n }\n\n // Create .autonomos directory\n if (!existsSync(autonomosDir)) {\n mkdirSync(autonomosDir, { recursive: true })\n created.push(AUTONOMOS_DIR)\n }\n\n // Create worklogs directory\n const worklogsDir = join(autonomosDir, WORKLOGS_DIR)\n if (!existsSync(worklogsDir)) {\n mkdirSync(worklogsDir, { recursive: true })\n created.push(`${AUTONOMOS_DIR}/${WORKLOGS_DIR}`)\n }\n\n // Create manifest.json\n const manifest = createManifest(CLI_VERSION)\n const manifestPath = join(autonomosDir, MANIFEST_FILE)\n writeFileSync(manifestPath, generateManifestContent(manifest))\n created.push(`${AUTONOMOS_DIR}/${MANIFEST_FILE}`)\n\n // Create PROTOCOL.md\n const protocolPath = join(autonomosDir, PROTOCOL_FILE)\n writeFileSync(protocolPath, PROTOCOL_TEMPLATE)\n created.push(`${AUTONOMOS_DIR}/${PROTOCOL_FILE}`)\n\n // Create TASKS.md (only if it doesn't exist)\n const tasksPath = join(autonomosDir, TASKS_FILE)\n if (!existsSync(tasksPath)) {\n writeFileSync(tasksPath, TASKS_TEMPLATE)\n created.push(`${AUTONOMOS_DIR}/${TASKS_FILE}`)\n } else {\n warnings.push(`${TASKS_FILE} already exists, skipping.`)\n }\n\n // Create AGENT.md at root (only if it doesn't exist)\n const agentPath = join(cwd, AGENT_FILE)\n if (!existsSync(agentPath)) {\n const projectName = cwd.split('/').pop() ?? 'Project'\n writeFileSync(agentPath, generateAgentTemplate(projectName))\n created.push(AGENT_FILE)\n } else {\n warnings.push(`${AGENT_FILE} already exists, skipping.`)\n }\n\n // Register npm script \"autonomos\" if package.json exists\n if (hasPackageJson) {\n try {\n const pkgRaw = readFileSync(packageJsonPath, 'utf-8')\n const pkg = JSON.parse(pkgRaw)\n const hadScript = !!pkg.scripts?.['autonomos']\n const previousDevDep = pkg.devDependencies?.['@autonomos/cli']\n const newDevDep = `^${CLI_VERSION}`\n\n if (!pkg.scripts) pkg.scripts = {}\n\n if (options.noInstall || options.dryRun) {\n // Mode B: npx only, no devDependency\n pkg.scripts['autonomos'] = 'npx --yes @autonomos/cli'\n writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 4) + '\\n')\n created.push('package.json (scripts.autonomos via npx)')\n if (!hadScript) {\n warnings.push(\n 'Added \"autonomos\" npm script using npx (--no-install mode). Run `npm install` when ready.'\n )\n }\n } else {\n // Mode A (default): install as devDependency\n pkg.scripts['autonomos'] = 'autonomos'\n\n if (!pkg.devDependencies) pkg.devDependencies = {}\n pkg.devDependencies['@autonomos/cli'] = newDevDep\n\n writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 4) + '\\n')\n created.push('package.json (scripts.autonomos + devDependencies.@autonomos/cli)')\n\n // Three distinct situations to communicate:\n // 1. fresh install: nothing existed before\n // 2. devDep was already there but pinned to a stale\n // version (typical of older CLI builds that wrote\n // ^0.2.0, which doesn't exist on the registry)\n // 3. devDep was already there at the current version\n // and only the script needed adding\n if (!hadScript && !previousDevDep) {\n warnings.push(\n 'Added \"autonomos\" npm script and @autonomos/cli devDependency. Run `npm install` to install.'\n )\n } else if (previousDevDep && previousDevDep !== newDevDep) {\n // Covers both \"old script + stale devDep\" and\n // \"no script + stale devDep\" cases. Refreshing the\n // devDep is what unblocks `pnpm i` when the pinned\n // version isn't on the registry.\n warnings.push(\n `Bumped @autonomos/cli devDependency: ${previousDevDep} → ${newDevDep}. Run \\`npm install\\` to apply.`\n )\n } else if (!hadScript && previousDevDep) {\n warnings.push('Added \"autonomos\" npm script (devDependency was already set).')\n }\n }\n } catch {\n warnings.push('Could not update package.json (invalid JSON or read error).')\n }\n }\n\n // Install workflow files for each selected harness\n const workflowsDir = getWorkflowsDir()\n for (const target of targets) {\n mkdirSync(target.path, { recursive: true })\n for (const workflowFile of WORKFLOW_FILES) {\n const source = readFileSync(join(workflowsDir, workflowFile), 'utf-8')\n const filename = buildTargetFilename(workflowFile, target.fileExtension)\n const dest = join(target.path, filename)\n writeFileSync(dest, source)\n harnessFiles.push(`${target.path}/${filename}`)\n }\n }\n\n const harnessMsg =\n selectedHarnesses.length > 0\n ? ` for harnesses: ${selectedHarnesses.join(', ')}`\n : ' (no harness workflows installed)'\n\n return {\n success: true,\n message: `Project initialized with Agent Protocol v${PROTOCOL_VERSION}${harnessMsg}`,\n created,\n warnings,\n dryRun: false,\n harnessFiles,\n }\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport {\n AUTONOMOS_DIR,\n MANIFEST_FILE,\n parseManifest,\n TaskParser,\n TASKS_FILE,\n type Manifest,\n} from '@autonomos/core'\nimport { verifyProtocolArtifacts, type ArtifactIntegrity } from '../protocol-artifacts'\n\ninterface StatusOptions {\n cwd?: string\n}\n\ninterface TaskSummary {\n total: number\n todo: number\n inProgress: number\n done: number\n blocked: number\n}\n\nexport interface StatusResult {\n success: boolean\n message: string\n protocolVersion?: string\n cliVersion?: string\n initialized: boolean\n taskSummary?: TaskSummary\n artifactIntegrity?: ArtifactIntegrity\n driftedArtifacts?: string[]\n}\n\n/**\n * Get project status and task summary\n */\nexport function status(options: StatusOptions = {}): StatusResult {\n const cwd = options.cwd ?? process.cwd()\n\n // Check if initialized\n const autonomosDir = join(cwd, AUTONOMOS_DIR)\n const manifestPath = join(autonomosDir, MANIFEST_FILE)\n\n if (!existsSync(manifestPath)) {\n return {\n success: false,\n message: 'Project not initialized. Run `autonomos init` first.',\n initialized: false,\n }\n }\n\n // Read manifest\n let manifest: Manifest\n try {\n const manifestContent = readFileSync(manifestPath, 'utf-8')\n manifest = parseManifest(manifestContent)\n } catch {\n return {\n success: false,\n message: 'Could not read manifest.json',\n initialized: true,\n }\n }\n\n // Parse tasks\n let taskSummary: TaskSummary | undefined\n const tasksPath = join(autonomosDir, TASKS_FILE)\n\n if (existsSync(tasksPath)) {\n try {\n const tasksContent = readFileSync(tasksPath, 'utf-8')\n const tasks = TaskParser.parse(tasksContent)\n\n taskSummary = {\n total: tasks.length,\n todo: tasks.filter(t => t.status === 'TODO').length,\n inProgress: tasks.filter(t => t.status === 'IN_PROGRESS').length,\n done: tasks.filter(t => t.status === 'DONE').length,\n blocked: tasks.filter(t => t.status === 'BLOCKED').length,\n }\n } catch {\n // Tasks file exists but couldn't be parsed\n }\n }\n\n const integrity = verifyProtocolArtifacts(cwd, manifest.protocolVersion)\n\n return {\n success: true,\n message: 'Project status retrieved',\n protocolVersion: manifest.protocolVersion,\n cliVersion: manifest.cliVersion,\n initialized: true,\n taskSummary,\n artifactIntegrity: integrity.state,\n driftedArtifacts: integrity.driftedFiles,\n }\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport {\n AUTONOMOS_DIR,\n findProjectRoot,\n generateManifestContent,\n listHarnesses,\n MANIFEST_FILE,\n parseManifest,\n PROTOCOL_FILE,\n PROTOCOL_TEMPLATE,\n PROTOCOL_VERSION,\n resolveTargets,\n type Manifest,\n} from '@autonomos/core'\n\nimport packageJson from '../../package.json' with { type: 'json' }\nimport { buildTargetFilename, getWorkflowsDir, WORKFLOW_FILES } from '../protocol-artifacts'\nconst CLI_VERSION: string = packageJson.version\n\ninterface UpdateOptions {\n cwd?: string\n /**\n * When provided, install the workflow files for these harness ids in\n * addition to refreshing existing ones. Lets users add a new AI\n * harness (e.g. opencode) to a project that was already initialized\n * with the protocol, without re-running `init`.\n */\n harnesses?: string[]\n /** Convenience flag equivalent to `harnesses: listHarnesses().map(id)`. */\n all?: boolean\n /** Test seam for packaged workflow resolution. */\n resolveWorkflowsDir?: () => string\n}\n\ninterface UpdateResult {\n success: boolean\n message: string\n previousVersion?: string\n newVersion?: string\n cliOutdated?: boolean\n /** Harnesses that had workflow files installed (or refreshed) by this run. */\n touchedHarnesses?: string[]\n}\n\n/**\n * Compare two SemVer versions\n * Returns: -1 if a < b, 0 if a === b, 1 if a > b\n */\nfunction compareVersions(a: string, b: string): number {\n const parse = (version: string) => {\n const [numeric = '', prerelease] = version.split('-', 2)\n return { parts: numeric.split('.').map(Number), prerelease }\n }\n const aVersion = parse(a)\n const bVersion = parse(b)\n\n for (let i = 0; i < 3; i++) {\n const aNum = aVersion.parts[i] ?? 0\n const bNum = bVersion.parts[i] ?? 0\n if (aNum < bNum) return -1\n if (aNum > bNum) return 1\n }\n\n if (aVersion.prerelease === bVersion.prerelease) return 0\n if (aVersion.prerelease === undefined) return 1\n if (bVersion.prerelease === undefined) return -1\n\n return aVersion.prerelease.localeCompare(bVersion.prerelease)\n}\n\n/**\n * Bump the `@autonomos/cli` devDependency in the project's package.json\n * to the current CLI version, when one is present. Older init runs\n * (including the previously published 0.2.0) pinned a version that is\n * not on the registry, which broke `pnpm i`. Doing the bump here means\n * users can recover with a single `autonomos update` instead of editing\n * package.json by hand.\n *\n * Returns a human-readable note when something changed, or null when\n * nothing needed to be done.\n */\nfunction refreshDevDependency(cwd: string): string | null {\n const packageJsonPath = join(cwd, 'package.json')\n if (!existsSync(packageJsonPath)) return null\n\n let pkg: any\n try {\n pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))\n } catch {\n return null\n }\n\n const newSpec = `^${CLI_VERSION}`\n const previous = pkg.devDependencies?.['@autonomos/cli']\n if (previous === newSpec) return null\n\n if (!pkg.devDependencies) pkg.devDependencies = {}\n pkg.devDependencies['@autonomos/cli'] = newSpec\n\n try {\n writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 4) + '\\n')\n } catch {\n return null\n }\n\n return previous\n ? `Bumped @autonomos/cli devDependency: ${previous} → ${newSpec}.`\n : `Added @autonomos/cli devDependency: ${newSpec}.`\n}\n\nfunction writeHarnessWorkflows(cwd: string, harnessIds: string[], workflowsDir: string): string[] {\n if (harnessIds.length === 0) return []\n const targets = resolveTargets(harnessIds, cwd)\n const written: string[] = []\n for (const target of targets) {\n mkdirSync(target.path, { recursive: true })\n for (const workflowFile of WORKFLOW_FILES) {\n const source = readFileSync(join(workflowsDir, workflowFile), 'utf-8')\n const filename = buildTargetFilename(workflowFile, target.fileExtension)\n const dest = join(target.path, filename)\n writeFileSync(dest, source)\n written.push(`${target.path}/${filename}`)\n }\n }\n return written\n}\n\n/**\n * Refresh workflows for harnesses already installed in the project.\n * A workflow update is independent from the protocol version: workflow files\n * are executable artifacts and may be fixed between protocol releases.\n */\nfunction refreshInstalledHarnessWorkflows(cwd: string, workflowsDir: string): string[] {\n const targets = resolveTargets(\n listHarnesses().map(({ id }) => id),\n cwd\n )\n const updatedTargets: string[] = []\n\n for (const target of targets) {\n if (!existsSync(target.path)) continue\n\n const files = WORKFLOW_FILES.map(workflowFile => ({\n source: readFileSync(join(workflowsDir, workflowFile), 'utf-8'),\n dest: join(target.path, buildTargetFilename(workflowFile, target.fileExtension)),\n }))\n if (!files.some(({ dest }) => existsSync(dest))) continue\n\n let changed = false\n for (const { source, dest } of files) {\n if (!existsSync(dest) || readFileSync(dest, 'utf-8') !== source) {\n writeFileSync(dest, source)\n changed = true\n }\n }\n if (changed) updatedTargets.push(target.path)\n }\n\n return updatedTargets\n}\n\n/**\n * Update the Protocol to the latest version\n */\nexport function update(options: UpdateOptions = {}): UpdateResult {\n const requestedCwd = options.cwd ?? process.cwd()\n\n // Bubble up to the project root if the user ran us from a subdir.\n // Unlike `init` we don't refuse here: there's nothing destructive\n // about a refresh, and the only way to find the manifest is to look\n // for it where it lives.\n const cwd = findProjectRoot(requestedCwd) ?? requestedCwd\n\n // Check if initialized\n const autonomosDir = join(cwd, AUTONOMOS_DIR)\n const manifestPath = join(autonomosDir, MANIFEST_FILE)\n\n if (!existsSync(manifestPath)) {\n return {\n success: false,\n message: 'Project not initialized. Run `autonomos init` first.',\n }\n }\n\n // Read current manifest\n const manifestContent = readFileSync(manifestPath, 'utf-8')\n const manifest: Manifest = parseManifest(manifestContent)\n const currentVersion = manifest.protocolVersion\n\n // Resolve every packaged input before mutating project-owned files. A broken\n // CLI installation must fail without leaving a partially updated protocol.\n let workflowsDir: string\n try {\n workflowsDir = (options.resolveWorkflowsDir ?? getWorkflowsDir)()\n } catch (error) {\n return {\n success: false,\n message: `Cannot update protocol artifacts: ${error instanceof Error ? error.message : String(error)}`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n }\n }\n\n // Refresh devDependency. We do this even when the protocol version\n // is already up to date, because the user may have run `update`\n // precisely to repair a pinned-but-unresolvable version.\n const devDepNote = refreshDevDependency(cwd)\n\n // Compare versions\n const comparison = compareVersions(currentVersion, PROTOCOL_VERSION)\n\n if (comparison === 0) {\n // Workflows are executable artifacts, so refresh installed harnesses\n // even when the protocol specification itself is already current.\n let updatedTargets: string[] = []\n try {\n updatedTargets = refreshInstalledHarnessWorkflows(cwd, workflowsDir)\n } catch (err) {\n console.warn(\n `Warning: Could not update harness workflows: ${err instanceof Error ? err.message : String(err)}`\n )\n }\n\n // Still install any newly requested harnesses even when the protocol\n // is current. This is the path used to add a new harness.\n const requestedHarnesses = options.all\n ? listHarnesses().map(({ id }) => id)\n : (options.harnesses ?? [])\n const newlyInstalled = writeHarnessWorkflows(cwd, requestedHarnesses, workflowsDir)\n\n if (\n manifest.cliVersion !== CLI_VERSION ||\n updatedTargets.length > 0 ||\n newlyInstalled.length > 0\n ) {\n writeFileSync(\n manifestPath,\n generateManifestContent({\n ...manifest,\n cliVersion: CLI_VERSION,\n lastUpdated: new Date().toISOString(),\n })\n )\n }\n\n const workflowMsg =\n updatedTargets.length > 0 ? ` Refreshed workflows in ${updatedTargets.join(', ')}.` : ''\n const installedMsg =\n newlyInstalled.length > 0 ? ` Installed: ${newlyInstalled.join(', ')}.` : ''\n const devDepMsg = devDepNote ? ` ${devDepNote}` : ''\n return {\n success: true,\n message: `Already up to date (Protocol v${PROTOCOL_VERSION}).${workflowMsg}${installedMsg}${devDepMsg}`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n touchedHarnesses: [...updatedTargets, ...newlyInstalled],\n }\n }\n\n if (comparison > 0) {\n // Project uses a newer version than CLI knows\n return {\n success: false,\n message: `This project uses Protocol v${currentVersion}, but your CLI only knows v${PROTOCOL_VERSION}. Update your CLI with \\`npm i -g @autonomos/cli\\`.`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n cliOutdated: true,\n }\n }\n\n // Update Protocol (comparison < 0)\n const protocolPath = join(autonomosDir, PROTOCOL_FILE)\n writeFileSync(protocolPath, PROTOCOL_TEMPLATE)\n\n // Update manifest\n const updatedManifest: Manifest = {\n ...manifest,\n protocolVersion: PROTOCOL_VERSION,\n cliVersion: CLI_VERSION,\n lastUpdated: new Date().toISOString(),\n }\n writeFileSync(manifestPath, generateManifestContent(updatedManifest))\n\n // Update workflow files in active harnesses\n const updatedTargets: string[] = []\n try {\n updatedTargets.push(...refreshInstalledHarnessWorkflows(cwd, workflowsDir))\n } catch (err) {\n // Log warning but don't fail the update\n console.warn(\n `Warning: Could not update harness workflows: ${err instanceof Error ? err.message : String(err)}`\n )\n }\n\n // Also install any harnesses the user explicitly asked for. This\n // covers the \"I'm on a newer protocol but want to add a new harness\"\n // case as well as the more common \"my init never installed opencode\".\n const requestedHarnesses = options.all\n ? listHarnesses().map(({ id }) => id)\n : (options.harnesses ?? [])\n const newlyInstalled = writeHarnessWorkflows(cwd, requestedHarnesses, workflowsDir)\n\n const harnessInfo =\n updatedTargets.length > 0 ? ` (updated workflows in ${updatedTargets.join(', ')})` : ''\n const installedInfo =\n newlyInstalled.length > 0 ? ` (installed: ${newlyInstalled.join(', ')})` : ''\n const devDepInfo = devDepNote ? ` ${devDepNote}` : ''\n\n return {\n success: true,\n message: `Protocol updated: v${currentVersion} → v${PROTOCOL_VERSION}${harnessInfo}${installedInfo}${devDepInfo}`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n touchedHarnesses: [...updatedTargets, ...newlyInstalled],\n }\n}\n","#!/usr/bin/env node\nimport { Command } from 'commander'\nimport pc from 'picocolors'\n\nimport { PROTOCOL_VERSION } from '@autonomos/core'\nimport { agents } from './commands/agents'\nimport { init } from './commands/init'\nimport { status } from './commands/status'\nimport { update } from './commands/update'\n\n// Synchronize with the package.json version at build time. The bundler\n// inlines this JSON, so the resolved value is always current.\n// (package.json import — inlined by the bundler)\nimport packageJson from '../package.json' with { type: 'json' }\nconst CLI_VERSION: string = packageJson.version\n\nconst program = new Command()\n\nprogram\n .name('autonomos')\n .description(\n pc.cyan(`CLI for the Autonomos Agent Protocol\n\nThe Agent Protocol is a specification for AI agents to interact with codebases\nin a structured, consistent way. It defines how agents should read context,\nexecute tasks, and persist knowledge.`) +\n `\n\nDocumentation: ${pc.underline('https://github.com/saoudi-h/autonomos')}`\n )\n .version(\n `${pc.bold('CLI:')} ${pc.green(CLI_VERSION)}\\n${pc.bold('Protocol:')} ${pc.green(PROTOCOL_VERSION)}`,\n '-v, --version',\n 'Show version information'\n )\n .helpOption('-h, --help', 'Show help information')\n .addHelpText(\n 'after',\n `\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos init')} Initialize the Agent Protocol in current directory\n $ ${pc.cyan('autonomos update')} Update Protocol to the latest version\n $ ${pc.cyan('autonomos status')} Show project status and task summary\n $ ${pc.cyan('autonomos agents')} List all AGENT.md files in the project\n\nProject knowledge workflows installed for supported harnesses include\n${pc.cyan('/issue')} (triage), ${pc.cyan('/adopt')} (reviewable migration),\n${pc.cyan('/reconcile')} (drift audit), and ${pc.cyan('/crystallize')} (close-out).\n\n${pc.bold('More info:')}\n Run '${pc.cyan('autonomos <command> --help')}' for detailed information about a command.\n`\n )\n\nprogram\n .command('init')\n .description('Initialize the Agent Protocol in the current directory')\n .addHelpText(\n 'after',\n `\nThis command creates the following structure:\n ${pc.blue('.autonomos/')}\n ā”œā”€ā”€ ${pc.white('manifest.json')} # Protocol metadata and version\n ā”œā”€ā”€ ${pc.white('PROTOCOL.md')} # Immutable protocol specification\n ā”œā”€ā”€ ${pc.white('TASKS.md')} # Task registry\n └── ${pc.blue('worklogs/')} # Session logs directory\n ${pc.white('AGENT.md')} # Project context file (at root)\n\nAdditionally, when one or more harnesses are selected, the protocol workflow\nfiles (session / task / issue / adopt / reconcile / crystallize) are installed at the harness-specific\ntarget directory, e.g. .clinerules/workflows/ for Cline, .claude/skills/ for\nClaude Code, .agents/skills/ for the cross-tool standard (Cursor, Codex, etc.).\nOptional project-owned specs and decisions directories are created only when the\nproject first adopts them; init never creates empty directories for them.\n\n${pc.bold('Harness selection:')}\n (default) Interactive multi-select prompt at the start of init.\n --harness Skip the prompt and install only for the given harness id(s).\n May be repeated, e.g. --harness cline --harness claude-code.\n --all Skip the prompt and install for all known harnesses.\n --no-prompt Same as not specifying a TTY; useful in CI/scripted contexts.\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos init')}\n $ ${pc.cyan('autonomos init --harness cline')}\n $ ${pc.cyan('autonomos init --harness cline --harness claude-code')}\n $ ${pc.cyan('autonomos init --all')}\n $ ${pc.cyan('autonomos init --dry-run')}\n $ ${pc.cyan('cd my-project && autonomos init')}\n\n${pc.bold('Project root detection:')}\n By default, ${pc.cyan('init')} refuses to run from a subdirectory of a\n git/Autonomos project. Run it from the project root, or pass\n ${pc.cyan('--force')} (or set ${pc.cyan('AUTONOMOS_FORCE=1')}) to install\n in ${pc.cyan('cwd')} anyway. In a TTY, you'll be asked to confirm.\n`\n )\n .option('-n, --dry-run', 'Preview what would be created without writing files')\n .option(\n '--harness <name...>',\n 'Install workflows for the specified harness id(s); skip the prompt'\n )\n .option('--all', 'Install workflows for all known harnesses; skip the prompt')\n .option('--no-prompt', 'Skip the interactive harness prompt (use with --harness or --all)')\n .option('--no-install', 'Skip installing @autonomos/cli as devDependency; use npx instead')\n .option(\n '-f, --force',\n 'Install in cwd even if a parent project root is detected (also via AUTONOMOS_FORCE=1)'\n )\n .action(\n async (opts: {\n dryRun?: boolean\n harness?: string[]\n all?: boolean\n prompt?: boolean\n install?: boolean\n force?: boolean\n }) => {\n try {\n const result = await init({\n dryRun: opts.dryRun,\n harnesses: opts.harness,\n all: opts.all,\n noPrompt: opts.prompt === false,\n noInstall: opts.install === false,\n force: opts.force,\n })\n\n if (!result.success) {\n console.error(pc.red(`\\nāŒ ${result.message}`))\n process.exit(1)\n }\n\n if (result.dryRun) {\n console.log(pc.cyan(`\\nšŸ” ${result.message} (dry-run)`))\n } else {\n console.log(pc.green(`\\nāœ… ${result.message}`))\n }\n\n if (result.created.length > 0) {\n console.log(`\\n${pc.bold(result.dryRun ? 'Would create:' : 'Created:')}`)\n result.created.forEach(file =>\n console.log(` ${pc.blue('šŸ“„')} ${pc.white(file)}`)\n )\n }\n\n if (result.harnessFiles && result.harnessFiles.length > 0) {\n console.log(`\\n${pc.bold('Harness workflow files:')}`)\n result.harnessFiles.forEach(file =>\n console.log(` ${pc.cyan('āš™ļø ')} ${pc.white(file)}`)\n )\n }\n\n if (result.warnings.length > 0) {\n console.log(pc.yellow('\\nWarnings:'))\n result.warnings.forEach(warn => console.log(` ${pc.yellow('āš ļø')} ${warn}`))\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n console.error(pc.red(`\\nāŒ ${message}`))\n process.exit(1)\n }\n }\n )\n\nprogram\n .command('update')\n .description('Update the Protocol to the latest version')\n .addHelpText(\n 'after',\n `\nThis command updates the managed protocol artifacts embedded in the CLI.\nYour ${pc.white('AGENT.md')}, ${pc.white('TASKS.md')}, ${pc.white('ISSUES.md')},\nworklogs, specifications, decisions, and user documentation are preserved.\n\nIt also:\n - Refreshes the @autonomos/cli devDependency in your package.json to the\n current CLI version (useful when an older init pinned an unresolvable\n version such as ^0.2.0).\n - When ${pc.white('--harness')} or ${pc.white('--all')} is passed, installs\n the workflow files for the given harness(es). This is the recommended\n way to add a new AI harness to an already-initialized project.\n\n${pc.bold('Version comparison:')}\n - If your project has an older version: Updates to the new version\n - If your project has a newer version: Warns you to update the CLI\n - If versions match: No action needed (but the devDependency is still\n refreshed and any newly requested harnesses are still installed)\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos update')}\n $ ${pc.cyan('autonomos update --harness opencode')}\n $ ${pc.cyan('autonomos update --harness opencode --harness kilocode')}\n $ ${pc.cyan('autonomos update --all')}\n`\n )\n .option(\n '--harness <name...>',\n 'Install workflow files for the specified harness id(s) in addition to refreshing existing ones'\n )\n .option(\n '--all',\n 'Install workflow files for every known harness in addition to refreshing existing ones'\n )\n .action((opts: { harness?: string[]; all?: boolean }) => {\n const result = update({ harnesses: opts.harness, all: opts.all })\n\n if (!result.success) {\n if (result.cliOutdated) {\n console.error(pc.yellow(`\\nāš ļø ${result.message}`))\n } else {\n console.error(pc.red(`\\nāŒ ${result.message}`))\n }\n process.exit(1)\n }\n\n console.log(pc.green(`\\nāœ… ${result.message}`))\n })\n\nprogram\n .command('status')\n .description('Show project status and task summary')\n .addHelpText(\n 'after',\n `\nDisplays information about the current project:\n - Protocol version\n - Protocol artifact integrity for the installed version\n - CLI version used for initialization\n - Task summary (todo, in-progress, done, blocked)\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos status')}\n`\n )\n .action(() => {\n const result = status()\n\n if (!result.success) {\n console.error(pc.red(`\\nāŒ ${result.message}`))\n process.exit(1)\n }\n\n console.log(\n `\\n${pc.bold('šŸ“¦ Protocol')} ${pc.green(`v${result.protocolVersion}`)} ${pc.dim(`(CLI v${result.cliVersion})`)}`\n )\n\n if (result.artifactIntegrity === 'valid') {\n console.log(` ${pc.green('āœ“ Artifacts match the published protocol version')}`)\n } else if (result.artifactIntegrity === 'drifted') {\n console.log(` ${pc.red('āœ— Protocol artifact drift detected')}`)\n for (const file of result.driftedArtifacts ?? []) {\n console.log(` ${pc.red('•')} ${file}`)\n }\n console.log(` ${pc.dim('Run `autonomos update` to restore canonical artifacts.')}`)\n } else {\n console.log(\n ` ${pc.yellow('! Artifact integrity is unverifiable with this CLI version')}`\n )\n }\n\n if (result.taskSummary) {\n const s = result.taskSummary\n console.log(`\\n${pc.bold('šŸ“‹ Tasks:')} ${pc.cyan(s.total)} total`)\n console.log(` ${pc.white('⬜ Todo:')} ${pc.white(s.todo)}`)\n console.log(` ${pc.blue('šŸ”„ In Progress:')} ${pc.blue(s.inProgress)}`)\n console.log(` ${pc.green('āœ… Done:')} ${pc.green(s.done)}`)\n if (s.blocked > 0) {\n console.log(` ${pc.red('🚫 Blocked:')} ${pc.red(s.blocked)}`)\n }\n }\n })\n\nprogram\n .command('agents')\n .description('List all AGENT.md files in the project, or the ancestor chain for a path')\n .argument(\n '[path]',\n 'Optional file or folder. When provided, return the ordered list of ancestor AGENT.md files (root -> target) instead of the full tree.'\n )\n .option('-a, --all', 'In tree mode: search from project root instead of current directory')\n .addHelpText(\n 'after',\n `\nThis command has two modes:\n\n${pc.bold('Tree mode')} (default, or with ${pc.cyan('--all')}):\n Discover and display all ${pc.white('AGENT.md')} files in a tree structure.\n Used at session start to get the broader fractal picture of the project.\n\n${pc.bold('Ancestors mode')} (with a positional ${pc.cyan('<path>')} argument):\n Return the ordered list of ${pc.white('AGENT.md')} files on the path from the\n target up to the project root. Root-first; non-existent ancestors are\n silently skipped. Used at task start to get the precise fractal context\n for the file or folder being worked on.\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos agents')} # Tree, from current dir\n $ ${pc.cyan('autonomos agents --all')} # Tree, from project root\n $ ${pc.cyan('autonomos agents apps/web')} # Ancestors for apps/web\n $ ${pc.cyan('autonomos agents apps/web/components/ui/button.tsx')} # Ancestors for a file\n`\n )\n .action((path: string | undefined, opts: { all?: boolean }) => {\n const result = agents({ all: opts.all, target: path })\n\n if (!result.success) {\n console.error(\n pc.red(`\nāŒ ${result.message}`)\n )\n process.exit(1)\n }\n\n if (result.mode === 'ancestors') {\n console.log(\n pc.cyan(`\nšŸ” ${result.message}`)\n )\n } else {\n console.log('\\n' + (result.tree ?? result.message))\n console.log(\n pc.dim(`\n${result.message}`)\n )\n }\n })\n\nprogram\n .command('version')\n .description('Show the current Protocol version')\n .action(() => {\n console.log(\n `${pc.bold('Agent Protocol')} ${pc.green(`v${PROTOCOL_VERSION}`)} ${pc.dim(`(CLI v${CLI_VERSION})`)}`\n )\n })\n\nprogram.parse()\n"],"mappings":";oxBAmCA,SAAS,EAAe,EAAa,EAAiB,EAAQ,EAAiB,CAC3E,IAAM,EAAwB,CAAC,EAGzB,EAAY,EAAK,EAAK,CAAU,EAClC,EAAW,CAAS,GACpB,EAAQ,KAAK,CACT,KAAM,EACN,aAAc,EAAS,EAAS,CAAS,GAAK,EAC9C,OACJ,CAAC,EAIL,GAAI,CACA,IAAM,EAAQ,EAAY,CAAG,EAC7B,IAAK,IAAM,KAAQ,EAAO,CAEtB,GACI,EAAK,WAAW,GAAG,GACnB,IAAS,gBACT,IAAS,QACT,IAAS,QAET,SAGJ,IAAM,EAAW,EAAK,EAAK,CAAI,EAC/B,GAAI,CACI,EAAS,CAAQ,CAAC,CAAC,YAAY,GAC/B,EAAQ,KAAK,GAAG,EAAe,EAAU,EAAS,EAAQ,CAAC,CAAC,CAEpE,MAAQ,CAER,CACJ,CACJ,MAAQ,CAER,CAEA,OAAO,CACX,CAWA,SAAS,EAAa,EAAuB,EAAyB,CAClE,GAAI,EAAQ,SAAW,EACnB,MAAO,8BAGX,IAAM,EAAW,EAAS,CAAO,EAC3B,EAAiB,CAAE,KAAM,EAAU,QAAS,GAAO,SAAU,CAAC,CAAE,EAGtE,IAAK,IAAM,KAAS,EAAS,CACzB,IAAM,EAAQ,EAAM,aAAa,MAAM,GAAG,EACtC,EAAU,EAEd,IAAK,IAAM,KAAQ,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Q,IACJ,GAAG,EAAG,KAAK,gBAAgB,EAAE,GAAG,EAAG,MAAM,IAAI,GAAkB,EAAE,GAAG,EAAG,IAAI,SAAS,EAAY,EAAE,GACtG,CACJ,CAAC,EAEL,EAAQ,MAAM"}
1
+ {"version":3,"file":"index.mjs","names":["CLI_VERSION","packageJson.version","CLI_VERSION","packageJson.version","packageJson.version"],"sources":["../src/commands/agents.ts","../package.json","../src/protocol-artifacts.ts","../src/commands/init.ts","../src/commands/status.ts","../src/commands/update.ts","../src/index.ts"],"sourcesContent":["import { existsSync, readdirSync, statSync } from 'node:fs'\nimport { basename, join, relative, resolve } from 'node:path'\n\nimport {\n AGENT_FILE,\n findAncestorAgents,\n findProjectRoot,\n type AncestorAgent,\n} from '@autonomos/core'\n\ninterface AgentsOptions {\n cwd?: string\n /**\n * When true, search from the project root (discovered by walking up to\n * .autonomos or .git) instead of the current directory.\n */\n all?: boolean\n /**\n * Optional target path (file or directory). When provided, the command\n * switches to \"ancestor lookup\" mode and prints the ordered list of\n * AGENT.md files on the path from the target up to the project root.\n * Existing ancestors only; gaps are silently skipped.\n */\n target?: string\n}\n\ninterface AgentEntry {\n path: string\n relativePath: string\n depth: number\n}\n\n/**\n * Recursively find all AGENT.md files in a directory\n */\nfunction findAgentFiles(dir: string, baseDir: string, depth = 0): AgentEntry[] {\n const entries: AgentEntry[] = []\n\n // Check if AGENT.md exists in current directory\n const agentPath = join(dir, AGENT_FILE)\n if (existsSync(agentPath)) {\n entries.push({\n path: agentPath,\n relativePath: relative(baseDir, agentPath) || AGENT_FILE,\n depth,\n })\n }\n\n // Scan subdirectories\n try {\n const items = readdirSync(dir)\n for (const item of items) {\n // Skip hidden directories and node_modules\n if (\n item.startsWith('.') ||\n item === 'node_modules' ||\n item === 'dist' ||\n item === 'build'\n ) {\n continue\n }\n\n const itemPath = join(dir, item)\n try {\n if (statSync(itemPath).isDirectory()) {\n entries.push(...findAgentFiles(itemPath, baseDir, depth + 1))\n }\n } catch {\n // Skip inaccessible directories\n }\n }\n } catch {\n // Skip inaccessible directories\n }\n\n return entries\n}\n\ninterface TreeNode {\n name: string\n isAgent: boolean\n children: Record<string, TreeNode>\n}\n\n/**\n * Format agent entries as a true tree structure\n */\nfunction formatAsTree(entries: AgentEntry[], baseDir: string): string {\n if (entries.length === 0) {\n return ' (no AGENT.md files found)'\n }\n\n const rootName = basename(baseDir)\n const tree: TreeNode = { name: rootName, isAgent: false, children: {} }\n\n // Build the tree\n for (const entry of entries) {\n const parts = entry.relativePath.split('/')\n let current = tree\n\n for (const part of parts) {\n const isAgent = part === AGENT_FILE\n\n let child = current.children[part]\n if (!child) {\n child = {\n name: part,\n isAgent,\n children: {},\n }\n current.children[part] = child\n }\n current = child\n }\n }\n\n const lines: string[] = []\n lines.push(`šŸ“ ${rootName}/`)\n\n function render(node: TreeNode, prefix = '', _isLast = true): void {\n const children = Object.values(node.children)\n children.sort((a, b) => {\n // Folders first\n if (!a.isAgent && b.isAgent) return -1\n if (a.isAgent && !b.isAgent) return 1\n return a.name.localeCompare(b.name)\n })\n\n children.forEach((child, index) => {\n const childIsLast = index === children.length - 1\n const branch = childIsLast ? '└── ' : 'ā”œā”€ā”€ '\n const icon = child.isAgent ? 'šŸ“„' : 'šŸ“'\n const name = child.isAgent ? child.name : `${child.name}/`\n\n lines.push(`${prefix}${branch}${icon} ${name}`)\n\n if (!child.isAgent) {\n const nextPrefix = prefix + (childIsLast ? ' ' : '│ ')\n render(child, nextPrefix, childIsLast)\n }\n })\n }\n\n render(tree)\n return lines.join('\\n')\n}\n\n/**\n * Format the ancestor-lookup result as a numbered, root-first list.\n */\nfunction formatAncestors(ancestors: AncestorAgent[]): string {\n if (ancestors.length === 0) {\n return ' (no AGENT.md files found in the ancestor chain)'\n }\n const lines = ancestors.map((a, i) => {\n const idx = (i + 1).toString().padStart(ancestors.length.toString().length, ' ')\n return ` ${idx}. ${a.relativeDir === '.' ? './AGENT.md' : `${a.relativeDir}/AGENT.md`}`\n })\n return lines.join('\\n')\n}\n\ninterface AgentsResult {\n success: boolean\n message: string\n tree?: string\n count?: number\n /**\n * When in ancestor-lookup mode, the list of ancestor AGENT.md files\n * (root-first order). Each entry has `dir`, `path`, `relativeDir`.\n */\n ancestors?: AncestorAgent[]\n /** The mode that was used. Useful for the caller to format output. */\n mode: 'tree' | 'ancestors'\n}\n\n/**\n * List AGENT.md files in the project.\n *\n * Two modes:\n *\n * 1. **Tree mode** (default, or with `--all`): list all AGENT.md files\n * in a tree structure. Used at session start to get the full fractal\n * picture of the project.\n *\n * 2. **Ancestors mode** (with a positional `<path>` argument): return\n * the ordered list of AGENT.md files on the path from the target\n * up to the project root. Root-first, with non-existent ancestors\n * silently skipped. Used at task start to get the precise fractal\n * context for the file or folder being worked on.\n */\nexport function agents(options: AgentsOptions = {}): AgentsResult {\n const cwd = options.cwd ?? process.cwd()\n\n // --- Ancestors mode (positional <path> arg) ---\n if (options.target) {\n const projectRoot = findProjectRoot(cwd) ?? cwd\n let ancestors: AncestorAgent[]\n try {\n ancestors = findAncestorAgents(resolve(cwd, options.target), projectRoot)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n return {\n success: false,\n message: `Failed to look up ancestors: ${message}`,\n mode: 'ancestors',\n }\n }\n const list = formatAncestors(ancestors)\n return {\n success: true,\n message: `Found ${ancestors.length} ancestor AGENT.md file(s) for \"${options.target}\" (root → target):\\n${list}`,\n count: ancestors.length,\n ancestors,\n mode: 'ancestors',\n }\n }\n\n // --- Tree mode (default) ---\n let searchBase: string\n if (options.all) {\n const projectRoot = findProjectRoot(cwd)\n if (!projectRoot) {\n return {\n success: false,\n message: 'Could not find project root (.autonomos or .git directory).',\n mode: 'tree',\n }\n }\n searchBase = projectRoot\n } else {\n searchBase = cwd\n }\n\n const entries = findAgentFiles(searchBase, searchBase)\n\n if (entries.length === 0) {\n return {\n success: true,\n message: 'No AGENT.md files found.',\n count: 0,\n mode: 'tree',\n }\n }\n\n const tree = formatAsTree(entries, searchBase)\n return {\n success: true,\n message: `Found ${entries.length} AGENT.md file(s)`,\n tree,\n count: entries.length,\n mode: 'tree',\n }\n}\n","","import { existsSync, readFileSync } from 'node:fs'\nimport { join, relative, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport {\n AUTONOMOS_DIR,\n listHarnesses,\n PROTOCOL_FILE,\n PROTOCOL_TEMPLATE,\n PROTOCOL_VERSION,\n resolveTargets,\n} from '@autonomos/core'\n\nexport const WORKFLOW_FILES = [\n 'protocol-session.md',\n 'protocol-task.md',\n 'protocol-crystallize.md',\n 'protocol-issue.md',\n 'protocol-adopt.md',\n 'protocol-reconcile.md',\n 'protocol-design.md',\n] as const\n\nexport type ArtifactIntegrity = 'valid' | 'drifted' | 'unverifiable'\n\nexport interface ArtifactIntegrityResult {\n state: ArtifactIntegrity\n driftedFiles: string[]\n}\n\nexport function getWorkflowDirCandidates(moduleUrl: string = import.meta.url): string[] {\n const here = fileURLToPath(moduleUrl)\n return [\n resolve(here, '..', '..', '..', 'core', 'src', 'workflows'),\n resolve(here, '..', '..', '..', 'core', 'dist', 'workflows'),\n resolve(here, '..', '..', '..', '..', 'core', 'dist', 'workflows'),\n ]\n}\n\nexport function getWorkflowsDir(): string {\n const candidates = getWorkflowDirCandidates()\n for (const candidate of candidates) {\n if (existsSync(candidate)) return candidate\n }\n throw new Error('Could not locate the workflows directory inside @autonomos/core')\n}\n\nexport function buildTargetFilename(sourceFile: string, targetExtension: string): string {\n const withoutPrefix = sourceFile.replace(/^protocol-/, '')\n const withoutExt = withoutPrefix.replace(/\\.[^.]+$/, '')\n return withoutExt + targetExtension\n}\n\nexport function verifyProtocolArtifacts(\n cwd: string,\n declaredVersion: string\n): ArtifactIntegrityResult {\n if (declaredVersion !== PROTOCOL_VERSION) {\n return { state: 'unverifiable', driftedFiles: [] }\n }\n\n const driftedFiles: string[] = []\n const protocolPath = join(cwd, AUTONOMOS_DIR, PROTOCOL_FILE)\n compareFile(protocolPath, PROTOCOL_TEMPLATE, cwd, driftedFiles)\n\n const workflowsDir = getWorkflowsDir()\n const targets = resolveTargets(\n listHarnesses().map(({ id }) => id),\n cwd\n )\n\n for (const target of targets) {\n const expected = WORKFLOW_FILES.map(sourceFile => ({\n source: readFileSync(join(workflowsDir, sourceFile), 'utf-8'),\n destination: join(target.path, buildTargetFilename(sourceFile, target.fileExtension)),\n }))\n if (!expected.some(({ destination }) => existsSync(destination))) continue\n for (const file of expected) {\n compareFile(file.destination, file.source, cwd, driftedFiles)\n }\n }\n\n return {\n state: driftedFiles.length === 0 ? 'valid' : 'drifted',\n driftedFiles,\n }\n}\n\nfunction compareFile(path: string, expected: string, cwd: string, driftedFiles: string[]): void {\n if (!existsSync(path) || readFileSync(path, 'utf-8') !== expected) {\n driftedFiles.push(relative(cwd, path))\n }\n}\n","import { checkbox, confirm } from '@inquirer/prompts'\nimport { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport {\n AGENT_FILE,\n AUTONOMOS_DIR,\n createManifest,\n displayRelative,\n findProjectRoot,\n generateAgentTemplate,\n generateManifestContent,\n isSamePath,\n listHarnesses,\n MANIFEST_FILE,\n PROTOCOL_FILE,\n PROTOCOL_TEMPLATE,\n PROTOCOL_VERSION,\n resolveTargets,\n TASKS_FILE,\n TASKS_TEMPLATE,\n WORKLOGS_DIR,\n} from '@autonomos/core'\n\n// Synchronize with the package.json version at build time. The bundler\n// inlines this JSON, so the resolved value is always current.\n// (package.json import — inlined by the bundler)\nimport packageJson from '../../package.json' with { type: 'json' }\nimport { buildTargetFilename, getWorkflowsDir, WORKFLOW_FILES } from '../protocol-artifacts'\nconst CLI_VERSION: string = packageJson.version\n\ninterface InitOptions {\n cwd?: string\n dryRun?: boolean\n /** Specific harness ids to install for. */\n harnesses?: string[]\n /** Install for all known harnesses (overrides `harnesses`). */\n all?: boolean\n /** Skip the interactive prompt even when no harnesses are specified. */\n noPrompt?: boolean\n /** When true, skip installing @autonomos/cli devDependency.\n * The npm script will use npx instead. */\n noInstall?: boolean\n /**\n * When true, ignore the \"you're inside a bigger project\" check and\n * initialize the protocol in `cwd` no matter what. Mirrors the\n * `AUTONOMOS_FORCE=1` env var, which is more convenient in scripts.\n */\n force?: boolean\n /**\n * When set, treat stdin as a TTY (true) or non-TTY (false) regardless\n * of the real value. Tests use this to opt in/out of the project-root\n * confirmation prompt without mutating the real TTY state.\n */\n interactiveOverride?: boolean\n}\n\nexport interface ResolveInstallResult {\n installDir: string\n warnings: string[]\n abort?: { message: string }\n}\n\ninterface ResolveInstallOptions {\n force: boolean\n noPrompt: boolean\n isInteractive: boolean\n}\n\ninterface InitResult {\n success: boolean\n message: string\n created: string[]\n warnings: string[]\n dryRun?: boolean\n harnessFiles?: string[]\n}\n\n/**\n * Prompt the user interactively for which harnesses to install for.\n * Returns the selected harness ids. An empty array means the user chose\n * to skip harness installation entirely.\n */\nasync function promptForHarnesses(): Promise<string[]> {\n const harnesses = listHarnesses()\n return checkbox({\n message:\n 'Which AI harnesses do you want to install the protocol for? (space to toggle, enter to confirm)',\n choices: harnesses.map(({ id, harness }) => ({\n name: harness.name,\n value: id,\n checked: harness.preferred,\n })),\n })\n}\n\n/**\n * Resolve which directory the protocol should be installed into.\n *\n * The protocol expects to live at the root of the user's project (where\n * `.git` / `.autonomos` already exists, or where one would be created).\n * When `init` is invoked from a subdirectory of such a project, we must\n * either:\n *\n * - point the user at the actual root and refuse to install, or\n * - install at the detected root on their behalf.\n *\n * We pick the first option by default, because silently installing\n * elsewhere is the bug that motivated this helper. The user can opt\n * into the second behavior with `--force` or `AUTONOMOS_FORCE=1`.\n *\n * Returns the directory to install in. When the caller passes `--force`\n * (or the env var is set), and a different project root is detected, we\n * install at that root instead. In interactive mode we also confirm the\n * detour with the user.\n */\nexport async function resolveInstallDir(\n requestedCwd: string,\n options: ResolveInstallOptions\n): Promise<ResolveInstallResult> {\n const warnings: string[] = []\n const detectedRoot = findProjectRoot(requestedCwd)\n\n // No project root found above us: nothing to bubble up to. Either\n // we're in a fresh directory (warn about no git) or we're literally\n // at the root of a project that uses neither marker. Either way we\n // install in place.\n if (!detectedRoot) {\n if (!existsSync(join(requestedCwd, '.git'))) {\n warnings.push('No Git repository detected. Consider running `git init` first.')\n }\n return { installDir: requestedCwd, warnings }\n }\n\n // The project root is exactly where we are: ideal case, no detour.\n if (isSamePath(detectedRoot, requestedCwd)) {\n return { installDir: requestedCwd, warnings }\n }\n\n // The project root is somewhere above us. Decide what to do.\n const relCwd = displayRelative(requestedCwd, detectedRoot)\n const force = options.force || process.env.AUTONOMOS_FORCE === '1'\n\n if (force) {\n warnings.push(\n `Detected project root at ${displayRelative(detectedRoot, requestedCwd)} ` +\n `(AUTONOMOS_FORCE=1); installing there instead of \"${relCwd}\".`\n )\n return { installDir: detectedRoot, warnings }\n }\n\n if (options.isInteractive && !options.noPrompt) {\n const proceed = await confirm({\n message:\n `You're inside a project rooted at ${detectedRoot}.\\n` +\n `The protocol should be installed at the project root, not in \"${relCwd}\".\\n` +\n `Install at the project root instead?`,\n default: true,\n })\n if (proceed) {\n warnings.push(`Detected project root above \"${relCwd}\"; installing at ${detectedRoot}.`)\n return { installDir: detectedRoot, warnings }\n }\n return {\n installDir: requestedCwd,\n warnings,\n abort: {\n message:\n `Aborted: refusing to install Autonomos inside a subdirectory. ` +\n `Run the command from ${detectedRoot} (or pass --force / set AUTONOMOS_FORCE=1).`,\n },\n }\n }\n\n return {\n installDir: requestedCwd,\n warnings,\n abort: {\n message:\n `Cannot initialize Autonomos from a subdirectory.\\n` +\n ` Current directory : ${requestedCwd}\\n` +\n ` Detected root : ${detectedRoot}\\n` +\n `Re-run from the project root, or pass --force (or set AUTONOMOS_FORCE=1) to install here anyway.`,\n },\n }\n}\n\n/**\n * Initialize the Autonomos Agent Protocol in a directory.\n */\nexport async function init(options: InitOptions = {}): Promise<InitResult> {\n const requestedCwd = options.cwd ?? process.cwd()\n const dryRun = options.dryRun ?? false\n\n // Resolve the install target. We do this before any other check so a\n // bad install location fails fast with a clear message.\n const isInteractive =\n options.interactiveOverride ?? (process.stdin.isTTY === true && !options.dryRun)\n const resolution = await resolveInstallDir(requestedCwd, {\n force: options.force ?? false,\n noPrompt: options.noPrompt ?? false,\n isInteractive,\n })\n if (resolution.abort) {\n return {\n success: false,\n message: resolution.abort.message,\n created: [],\n warnings: resolution.warnings,\n dryRun,\n }\n }\n const cwd = resolution.installDir\n const warnings: string[] = [...resolution.warnings]\n\n const created: string[] = []\n const harnessFiles: string[] = []\n\n // Detect package.json for npm script registration\n const packageJsonPath = join(cwd, 'package.json')\n const hasPackageJson = existsSync(packageJsonPath) && statSync(packageJsonPath).isFile()\n\n // Check if already initialized\n const autonomosDir = join(cwd, AUTONOMOS_DIR)\n const isInitialized = existsSync(autonomosDir)\n\n // Resolve which harnesses to install for\n let selectedHarnesses: string[]\n if (options.all) {\n selectedHarnesses = listHarnesses().map(({ id }) => id)\n } else if (options.harnesses && options.harnesses.length > 0) {\n selectedHarnesses = options.harnesses\n } else if (options.noPrompt || options.dryRun) {\n selectedHarnesses = []\n } else {\n selectedHarnesses = await promptForHarnesses()\n }\n\n if (isInitialized && selectedHarnesses.length === 0) {\n return {\n success: false,\n message: `Project already initialized with Protocol v${PROTOCOL_VERSION}. Use \\`autonomos update\\` to update, or specify harnesses with --harness to install workflow files.`,\n created: [],\n warnings: [],\n dryRun,\n }\n }\n\n // Compute the unique target directories\n const targets = resolveTargets(selectedHarnesses, cwd)\n\n // In dry-run mode, just collect what would be created\n if (dryRun) {\n if (!isInitialized) {\n created.push(AUTONOMOS_DIR)\n created.push(`${AUTONOMOS_DIR}/${WORKLOGS_DIR}`)\n created.push(`${AUTONOMOS_DIR}/${MANIFEST_FILE}`)\n created.push(`${AUTONOMOS_DIR}/${PROTOCOL_FILE}`)\n created.push(`${AUTONOMOS_DIR}/${TASKS_FILE}`)\n } else {\n created.push(`${AUTONOMOS_DIR}/${MANIFEST_FILE} (update)`)\n created.push(`${AUTONOMOS_DIR}/${PROTOCOL_FILE} (update)`)\n }\n\n const agentPath = join(cwd, AGENT_FILE)\n if (!existsSync(agentPath)) {\n created.push(AGENT_FILE)\n } else {\n warnings.push(`${AGENT_FILE} already exists, would skip.`)\n }\n\n for (const target of targets) {\n for (const workflowFile of WORKFLOW_FILES) {\n const filename = buildTargetFilename(workflowFile, target.fileExtension)\n harnessFiles.push(`${target.path}/${filename}`)\n }\n }\n\n return {\n success: true,\n message: `Would ${isInitialized ? 'update workflows in' : 'initialize'} project with Agent Protocol v${PROTOCOL_VERSION}${selectedHarnesses.length ? ` (harnesses: ${selectedHarnesses.join(', ')})` : ''}`,\n created,\n warnings,\n dryRun: true,\n harnessFiles,\n }\n }\n\n // Create .autonomos directory\n if (!existsSync(autonomosDir)) {\n mkdirSync(autonomosDir, { recursive: true })\n created.push(AUTONOMOS_DIR)\n }\n\n // Create worklogs directory\n const worklogsDir = join(autonomosDir, WORKLOGS_DIR)\n if (!existsSync(worklogsDir)) {\n mkdirSync(worklogsDir, { recursive: true })\n created.push(`${AUTONOMOS_DIR}/${WORKLOGS_DIR}`)\n }\n\n // Create manifest.json\n const manifest = createManifest(CLI_VERSION)\n const manifestPath = join(autonomosDir, MANIFEST_FILE)\n writeFileSync(manifestPath, generateManifestContent(manifest))\n created.push(`${AUTONOMOS_DIR}/${MANIFEST_FILE}`)\n\n // Create PROTOCOL.md\n const protocolPath = join(autonomosDir, PROTOCOL_FILE)\n writeFileSync(protocolPath, PROTOCOL_TEMPLATE)\n created.push(`${AUTONOMOS_DIR}/${PROTOCOL_FILE}`)\n\n // Create TASKS.md (only if it doesn't exist)\n const tasksPath = join(autonomosDir, TASKS_FILE)\n if (!existsSync(tasksPath)) {\n writeFileSync(tasksPath, TASKS_TEMPLATE)\n created.push(`${AUTONOMOS_DIR}/${TASKS_FILE}`)\n } else {\n warnings.push(`${TASKS_FILE} already exists, skipping.`)\n }\n\n // Create AGENT.md at root (only if it doesn't exist)\n const agentPath = join(cwd, AGENT_FILE)\n if (!existsSync(agentPath)) {\n const projectName = cwd.split('/').pop() ?? 'Project'\n writeFileSync(agentPath, generateAgentTemplate(projectName))\n created.push(AGENT_FILE)\n } else {\n warnings.push(`${AGENT_FILE} already exists, skipping.`)\n }\n\n // Register npm script \"autonomos\" if package.json exists\n if (hasPackageJson) {\n try {\n const pkgRaw = readFileSync(packageJsonPath, 'utf-8')\n const pkg = JSON.parse(pkgRaw)\n const hadScript = !!pkg.scripts?.['autonomos']\n const previousDevDep = pkg.devDependencies?.['@autonomos/cli']\n const newDevDep = `^${CLI_VERSION}`\n\n if (!pkg.scripts) pkg.scripts = {}\n\n if (options.noInstall || options.dryRun) {\n // Mode B: npx only, no devDependency\n pkg.scripts['autonomos'] = 'npx --yes @autonomos/cli'\n writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 4) + '\\n')\n created.push('package.json (scripts.autonomos via npx)')\n if (!hadScript) {\n warnings.push(\n 'Added \"autonomos\" npm script using npx (--no-install mode). Run `npm install` when ready.'\n )\n }\n } else {\n // Mode A (default): install as devDependency\n pkg.scripts['autonomos'] = 'autonomos'\n\n if (!pkg.devDependencies) pkg.devDependencies = {}\n pkg.devDependencies['@autonomos/cli'] = newDevDep\n\n writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 4) + '\\n')\n created.push('package.json (scripts.autonomos + devDependencies.@autonomos/cli)')\n\n // Three distinct situations to communicate:\n // 1. fresh install: nothing existed before\n // 2. devDep was already there but pinned to a stale\n // version (typical of older CLI builds that wrote\n // ^0.2.0, which doesn't exist on the registry)\n // 3. devDep was already there at the current version\n // and only the script needed adding\n if (!hadScript && !previousDevDep) {\n warnings.push(\n 'Added \"autonomos\" npm script and @autonomos/cli devDependency. Run `npm install` to install.'\n )\n } else if (previousDevDep && previousDevDep !== newDevDep) {\n // Covers both \"old script + stale devDep\" and\n // \"no script + stale devDep\" cases. Refreshing the\n // devDep is what unblocks `pnpm i` when the pinned\n // version isn't on the registry.\n warnings.push(\n `Bumped @autonomos/cli devDependency: ${previousDevDep} → ${newDevDep}. Run \\`npm install\\` to apply.`\n )\n } else if (!hadScript && previousDevDep) {\n warnings.push('Added \"autonomos\" npm script (devDependency was already set).')\n }\n }\n } catch {\n warnings.push('Could not update package.json (invalid JSON or read error).')\n }\n }\n\n // Install workflow files for each selected harness\n const workflowsDir = getWorkflowsDir()\n for (const target of targets) {\n mkdirSync(target.path, { recursive: true })\n for (const workflowFile of WORKFLOW_FILES) {\n const source = readFileSync(join(workflowsDir, workflowFile), 'utf-8')\n const filename = buildTargetFilename(workflowFile, target.fileExtension)\n const dest = join(target.path, filename)\n writeFileSync(dest, source)\n harnessFiles.push(`${target.path}/${filename}`)\n }\n }\n\n const harnessMsg =\n selectedHarnesses.length > 0\n ? ` for harnesses: ${selectedHarnesses.join(', ')}`\n : ' (no harness workflows installed)'\n\n return {\n success: true,\n message: `Project initialized with Agent Protocol v${PROTOCOL_VERSION}${harnessMsg}`,\n created,\n warnings,\n dryRun: false,\n harnessFiles,\n }\n}\n","import { existsSync, lstatSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport {\n AUTONOMOS_DIR,\n MANIFEST_FILE,\n parseManifest,\n readTaskRegistry,\n TASKS_FILE,\n type Manifest,\n type TaskReference,\n} from '@autonomos/core'\nimport { verifyProtocolArtifacts, type ArtifactIntegrity } from '../protocol-artifacts'\n\ninterface StatusOptions {\n cwd?: string\n history?: boolean\n}\n\ninterface TaskSummary {\n total: number\n todo: number\n inProgress: number\n done: number\n blocked: number\n}\n\nexport interface StatusResult {\n success: boolean\n message: string\n protocolVersion?: string\n cliVersion?: string\n initialized: boolean\n taskSummary?: TaskSummary\n archivedTaskSummary?: TaskSummary\n historyComplete?: boolean\n duplicateTaskIds?: string[]\n warnings?: string[]\n artifactIntegrity?: ArtifactIntegrity\n driftedArtifacts?: string[]\n}\n\n/**\n * Get project status and task summary\n */\nexport function status(options: StatusOptions = {}): StatusResult {\n const cwd = options.cwd ?? process.cwd()\n\n // Check if initialized\n const autonomosDir = join(cwd, AUTONOMOS_DIR)\n const manifestPath = join(autonomosDir, MANIFEST_FILE)\n\n if (existsSync(autonomosDir) && !lstatSync(autonomosDir).isDirectory()) {\n return {\n success: false,\n message: 'Expected a regular .autonomos directory; symbolic links are not followed.',\n initialized: false,\n }\n }\n\n if (!existsSync(manifestPath)) {\n return {\n success: false,\n message: 'Project not initialized. Run `autonomos init` first.',\n initialized: false,\n }\n }\n\n // Read manifest\n let manifest: Manifest\n try {\n const manifestContent = readFileSync(manifestPath, 'utf-8')\n manifest = parseManifest(manifestContent)\n } catch {\n return {\n success: false,\n message: 'Could not read manifest.json',\n initialized: true,\n }\n }\n\n // History stays opt-in: ordinary bootstrap must not traverse archives.\n let taskSummary: TaskSummary | undefined\n const registry = readTaskRegistry(cwd, { history: options.history })\n const summarize = (tasks: TaskReference[]): TaskSummary => ({\n total: tasks.length,\n todo: tasks.filter(t => t.status === 'TODO').length,\n inProgress: tasks.filter(t => t.status === 'IN_PROGRESS').length,\n done: tasks.filter(t => t.status === 'DONE').length,\n blocked: tasks.filter(t => t.status === 'BLOCKED').length,\n })\n if (existsSync(join(autonomosDir, TASKS_FILE))) {\n taskSummary = summarize(registry.current)\n }\n\n const integrity = verifyProtocolArtifacts(cwd, manifest.protocolVersion)\n\n return {\n success: true,\n message: 'Project status retrieved',\n protocolVersion: manifest.protocolVersion,\n cliVersion: manifest.cliVersion,\n initialized: true,\n taskSummary,\n ...(options.history\n ? {\n archivedTaskSummary: summarize(registry.archived),\n historyComplete: registry.complete,\n }\n : {}),\n duplicateTaskIds: registry.duplicateIds,\n warnings: registry.warnings,\n artifactIntegrity: integrity.state,\n driftedArtifacts: integrity.driftedFiles,\n }\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport {\n AUTONOMOS_DIR,\n findProjectRoot,\n generateManifestContent,\n listHarnesses,\n MANIFEST_FILE,\n parseManifest,\n PROTOCOL_FILE,\n PROTOCOL_TEMPLATE,\n PROTOCOL_VERSION,\n resolveTargets,\n type Manifest,\n} from '@autonomos/core'\n\nimport packageJson from '../../package.json' with { type: 'json' }\nimport { buildTargetFilename, getWorkflowsDir, WORKFLOW_FILES } from '../protocol-artifacts'\nconst CLI_VERSION: string = packageJson.version\n\ninterface UpdateOptions {\n cwd?: string\n /**\n * When provided, install the workflow files for these harness ids in\n * addition to refreshing existing ones. Lets users add a new AI\n * harness (e.g. opencode) to a project that was already initialized\n * with the protocol, without re-running `init`.\n */\n harnesses?: string[]\n /** Convenience flag equivalent to `harnesses: listHarnesses().map(id)`. */\n all?: boolean\n /** Test seam for packaged workflow resolution. */\n resolveWorkflowsDir?: () => string\n}\n\ninterface UpdateResult {\n success: boolean\n message: string\n previousVersion?: string\n newVersion?: string\n cliOutdated?: boolean\n /** Harnesses that had workflow files installed (or refreshed) by this run. */\n touchedHarnesses?: string[]\n}\n\n/**\n * Compare two SemVer versions\n * Returns: -1 if a < b, 0 if a === b, 1 if a > b\n */\nfunction compareVersions(a: string, b: string): number {\n const parse = (version: string) => {\n const [numeric = '', prerelease] = version.split('-', 2)\n return { parts: numeric.split('.').map(Number), prerelease }\n }\n const aVersion = parse(a)\n const bVersion = parse(b)\n\n for (let i = 0; i < 3; i++) {\n const aNum = aVersion.parts[i] ?? 0\n const bNum = bVersion.parts[i] ?? 0\n if (aNum < bNum) return -1\n if (aNum > bNum) return 1\n }\n\n if (aVersion.prerelease === bVersion.prerelease) return 0\n if (aVersion.prerelease === undefined) return 1\n if (bVersion.prerelease === undefined) return -1\n\n return aVersion.prerelease.localeCompare(bVersion.prerelease)\n}\n\n/**\n * Bump the `@autonomos/cli` devDependency in the project's package.json\n * to the current CLI version, when one is present. Older init runs\n * (including the previously published 0.2.0) pinned a version that is\n * not on the registry, which broke `pnpm i`. Doing the bump here means\n * users can recover with a single `autonomos update` instead of editing\n * package.json by hand.\n *\n * Returns a human-readable note when something changed, or null when\n * nothing needed to be done.\n */\nfunction refreshDevDependency(cwd: string): string | null {\n const packageJsonPath = join(cwd, 'package.json')\n if (!existsSync(packageJsonPath)) return null\n\n let pkg: any\n try {\n pkg = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))\n } catch {\n return null\n }\n\n const newSpec = `^${CLI_VERSION}`\n const previous = pkg.devDependencies?.['@autonomos/cli']\n if (previous === newSpec) return null\n\n if (!pkg.devDependencies) pkg.devDependencies = {}\n pkg.devDependencies['@autonomos/cli'] = newSpec\n\n try {\n writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 4) + '\\n')\n } catch {\n return null\n }\n\n return previous\n ? `Bumped @autonomos/cli devDependency: ${previous} → ${newSpec}.`\n : `Added @autonomos/cli devDependency: ${newSpec}.`\n}\n\nfunction writeHarnessWorkflows(cwd: string, harnessIds: string[], workflowsDir: string): string[] {\n if (harnessIds.length === 0) return []\n const targets = resolveTargets(harnessIds, cwd)\n const written: string[] = []\n for (const target of targets) {\n mkdirSync(target.path, { recursive: true })\n for (const workflowFile of WORKFLOW_FILES) {\n const source = readFileSync(join(workflowsDir, workflowFile), 'utf-8')\n const filename = buildTargetFilename(workflowFile, target.fileExtension)\n const dest = join(target.path, filename)\n writeFileSync(dest, source)\n written.push(`${target.path}/${filename}`)\n }\n }\n return written\n}\n\n/**\n * Refresh workflows for harnesses already installed in the project.\n * A workflow update is independent from the protocol version: workflow files\n * are executable artifacts and may be fixed between protocol releases.\n */\nfunction refreshInstalledHarnessWorkflows(cwd: string, workflowsDir: string): string[] {\n const targets = resolveTargets(\n listHarnesses().map(({ id }) => id),\n cwd\n )\n const updatedTargets: string[] = []\n\n for (const target of targets) {\n if (!existsSync(target.path)) continue\n\n const files = WORKFLOW_FILES.map(workflowFile => ({\n source: readFileSync(join(workflowsDir, workflowFile), 'utf-8'),\n dest: join(target.path, buildTargetFilename(workflowFile, target.fileExtension)),\n }))\n if (!files.some(({ dest }) => existsSync(dest))) continue\n\n let changed = false\n for (const { source, dest } of files) {\n if (!existsSync(dest) || readFileSync(dest, 'utf-8') !== source) {\n writeFileSync(dest, source)\n changed = true\n }\n }\n if (changed) updatedTargets.push(target.path)\n }\n\n return updatedTargets\n}\n\n/**\n * Update the Protocol to the latest version\n */\nexport function update(options: UpdateOptions = {}): UpdateResult {\n const requestedCwd = options.cwd ?? process.cwd()\n\n // Bubble up to the project root if the user ran us from a subdir.\n // Unlike `init` we don't refuse here: there's nothing destructive\n // about a refresh, and the only way to find the manifest is to look\n // for it where it lives.\n const cwd = findProjectRoot(requestedCwd) ?? requestedCwd\n\n // Check if initialized\n const autonomosDir = join(cwd, AUTONOMOS_DIR)\n const manifestPath = join(autonomosDir, MANIFEST_FILE)\n\n if (!existsSync(manifestPath)) {\n return {\n success: false,\n message: 'Project not initialized. Run `autonomos init` first.',\n }\n }\n\n // Read current manifest\n const manifestContent = readFileSync(manifestPath, 'utf-8')\n const manifest: Manifest = parseManifest(manifestContent)\n const currentVersion = manifest.protocolVersion\n\n // Resolve every packaged input before mutating project-owned files. A broken\n // CLI installation must fail without leaving a partially updated protocol.\n let workflowsDir: string\n try {\n workflowsDir = (options.resolveWorkflowsDir ?? getWorkflowsDir)()\n } catch (error) {\n return {\n success: false,\n message: `Cannot update protocol artifacts: ${error instanceof Error ? error.message : String(error)}`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n }\n }\n\n // Refresh devDependency. We do this even when the protocol version\n // is already up to date, because the user may have run `update`\n // precisely to repair a pinned-but-unresolvable version.\n const devDepNote = refreshDevDependency(cwd)\n\n // Compare versions\n const comparison = compareVersions(currentVersion, PROTOCOL_VERSION)\n\n if (comparison === 0) {\n // Workflows are executable artifacts, so refresh installed harnesses\n // even when the protocol specification itself is already current.\n let updatedTargets: string[] = []\n try {\n updatedTargets = refreshInstalledHarnessWorkflows(cwd, workflowsDir)\n } catch (err) {\n console.warn(\n `Warning: Could not update harness workflows: ${err instanceof Error ? err.message : String(err)}`\n )\n }\n\n // Still install any newly requested harnesses even when the protocol\n // is current. This is the path used to add a new harness.\n const requestedHarnesses = options.all\n ? listHarnesses().map(({ id }) => id)\n : (options.harnesses ?? [])\n const newlyInstalled = writeHarnessWorkflows(cwd, requestedHarnesses, workflowsDir)\n\n if (\n manifest.cliVersion !== CLI_VERSION ||\n updatedTargets.length > 0 ||\n newlyInstalled.length > 0\n ) {\n writeFileSync(\n manifestPath,\n generateManifestContent({\n ...manifest,\n cliVersion: CLI_VERSION,\n lastUpdated: new Date().toISOString(),\n })\n )\n }\n\n const workflowMsg =\n updatedTargets.length > 0 ? ` Refreshed workflows in ${updatedTargets.join(', ')}.` : ''\n const installedMsg =\n newlyInstalled.length > 0 ? ` Installed: ${newlyInstalled.join(', ')}.` : ''\n const devDepMsg = devDepNote ? ` ${devDepNote}` : ''\n return {\n success: true,\n message: `Already up to date (Protocol v${PROTOCOL_VERSION}).${workflowMsg}${installedMsg}${devDepMsg}`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n touchedHarnesses: [...updatedTargets, ...newlyInstalled],\n }\n }\n\n if (comparison > 0) {\n // Project uses a newer version than CLI knows\n return {\n success: false,\n message: `This project uses Protocol v${currentVersion}, but your CLI only knows v${PROTOCOL_VERSION}. Update your CLI with \\`npm i -g @autonomos/cli\\`.`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n cliOutdated: true,\n }\n }\n\n // Update Protocol (comparison < 0)\n const protocolPath = join(autonomosDir, PROTOCOL_FILE)\n writeFileSync(protocolPath, PROTOCOL_TEMPLATE)\n\n // Update manifest\n const updatedManifest: Manifest = {\n ...manifest,\n protocolVersion: PROTOCOL_VERSION,\n cliVersion: CLI_VERSION,\n lastUpdated: new Date().toISOString(),\n }\n writeFileSync(manifestPath, generateManifestContent(updatedManifest))\n\n // Update workflow files in active harnesses\n const updatedTargets: string[] = []\n try {\n updatedTargets.push(...refreshInstalledHarnessWorkflows(cwd, workflowsDir))\n } catch (err) {\n // Log warning but don't fail the update\n console.warn(\n `Warning: Could not update harness workflows: ${err instanceof Error ? err.message : String(err)}`\n )\n }\n\n // Also install any harnesses the user explicitly asked for. This\n // covers the \"I'm on a newer protocol but want to add a new harness\"\n // case as well as the more common \"my init never installed opencode\".\n const requestedHarnesses = options.all\n ? listHarnesses().map(({ id }) => id)\n : (options.harnesses ?? [])\n const newlyInstalled = writeHarnessWorkflows(cwd, requestedHarnesses, workflowsDir)\n\n const harnessInfo =\n updatedTargets.length > 0 ? ` (updated workflows in ${updatedTargets.join(', ')})` : ''\n const installedInfo =\n newlyInstalled.length > 0 ? ` (installed: ${newlyInstalled.join(', ')})` : ''\n const devDepInfo = devDepNote ? ` ${devDepNote}` : ''\n\n return {\n success: true,\n message: `Protocol updated: v${currentVersion} → v${PROTOCOL_VERSION}${harnessInfo}${installedInfo}${devDepInfo}`,\n previousVersion: currentVersion,\n newVersion: PROTOCOL_VERSION,\n touchedHarnesses: [...updatedTargets, ...newlyInstalled],\n }\n}\n","#!/usr/bin/env node\nimport { Command } from 'commander'\nimport pc from 'picocolors'\n\nimport { PROTOCOL_VERSION } from '@autonomos/core'\nimport { agents } from './commands/agents'\nimport { init } from './commands/init'\nimport { status } from './commands/status'\nimport { update } from './commands/update'\n\n// Synchronize with the package.json version at build time. The bundler\n// inlines this JSON, so the resolved value is always current.\n// (package.json import — inlined by the bundler)\nimport packageJson from '../package.json' with { type: 'json' }\nconst CLI_VERSION: string = packageJson.version\n\nconst program = new Command()\n\nprogram\n .name('autonomos')\n .description(\n pc.cyan(`CLI for the Autonomos Agent Protocol\n\nThe Agent Protocol is a specification for AI agents to interact with codebases\nin a structured, consistent way. It defines how agents should read context,\nexecute tasks, and persist knowledge.`) +\n `\n\nDocumentation: ${pc.underline('https://github.com/saoudi-h/autonomos')}`\n )\n .version(\n `${pc.bold('CLI:')} ${pc.green(CLI_VERSION)}\\n${pc.bold('Protocol:')} ${pc.green(PROTOCOL_VERSION)}`,\n '-v, --version',\n 'Show version information'\n )\n .helpOption('-h, --help', 'Show help information')\n .addHelpText(\n 'after',\n `\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos init')} Initialize the Agent Protocol in current directory\n $ ${pc.cyan('autonomos update')} Update Protocol to the latest version\n $ ${pc.cyan('autonomos status')} Show project status and task summary\n $ ${pc.cyan('autonomos agents')} List all AGENT.md files in the project\n\nProject knowledge workflows installed for supported harnesses include\n${pc.cyan('/issue')} (triage), ${pc.cyan('/adopt')} (reviewable migration),\n${pc.cyan('/reconcile')} (drift repair and archival), ${pc.cyan('/design')} (project-specific\ndirection), and ${pc.cyan('/crystallize')} (close-out).\n\n${pc.bold('More info:')}\n Run '${pc.cyan('autonomos <command> --help')}' for detailed information about a command.\n`\n )\n\nprogram\n .command('init')\n .description('Initialize the Agent Protocol in the current directory')\n .addHelpText(\n 'after',\n `\nThis command creates the following structure:\n ${pc.blue('.autonomos/')}\n ā”œā”€ā”€ ${pc.white('manifest.json')} # Protocol metadata and version\n ā”œā”€ā”€ ${pc.white('PROTOCOL.md')} # Immutable protocol specification\n ā”œā”€ā”€ ${pc.white('TASKS.md')} # Task registry\n └── ${pc.blue('worklogs/')} # Session logs directory\n ${pc.white('AGENT.md')} # Project context file (at root)\n\nAdditionally, when one or more harnesses are selected, the protocol workflow\nfiles (session / task / issue / adopt / reconcile / design / crystallize) are installed at the harness-specific\ntarget directory, e.g. .clinerules/workflows/ for Cline, .claude/skills/ for\nClaude Code, .agents/skills/ for the cross-tool standard (Cursor, Codex, etc.).\nOptional project-owned archives, specs and decisions directories are created only when the\nproject first adopts them; \\`DESIGN.md\\` is never created automatically, and init\nnever creates empty directories for project-owned records.\n\n${pc.bold('Harness selection:')}\n (default) Interactive multi-select prompt at the start of init.\n --harness Skip the prompt and install only for the given harness id(s).\n May be repeated, e.g. --harness cline --harness claude-code.\n --all Skip the prompt and install for all known harnesses.\n --no-prompt Same as not specifying a TTY; useful in CI/scripted contexts.\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos init')}\n $ ${pc.cyan('autonomos init --harness cline')}\n $ ${pc.cyan('autonomos init --harness cline --harness claude-code')}\n $ ${pc.cyan('autonomos init --all')}\n $ ${pc.cyan('autonomos init --dry-run')}\n $ ${pc.cyan('cd my-project && autonomos init')}\n\n${pc.bold('Project root detection:')}\n By default, ${pc.cyan('init')} refuses to run from a subdirectory of a\n git/Autonomos project. Run it from the project root, or pass\n ${pc.cyan('--force')} (or set ${pc.cyan('AUTONOMOS_FORCE=1')}) to install\n in ${pc.cyan('cwd')} anyway. In a TTY, you'll be asked to confirm.\n`\n )\n .option('-n, --dry-run', 'Preview what would be created without writing files')\n .option(\n '--harness <name...>',\n 'Install workflows for the specified harness id(s); skip the prompt'\n )\n .option('--all', 'Install workflows for all known harnesses; skip the prompt')\n .option('--no-prompt', 'Skip the interactive harness prompt (use with --harness or --all)')\n .option('--no-install', 'Skip installing @autonomos/cli as devDependency; use npx instead')\n .option(\n '-f, --force',\n 'Install in cwd even if a parent project root is detected (also via AUTONOMOS_FORCE=1)'\n )\n .action(\n async (opts: {\n dryRun?: boolean\n harness?: string[]\n all?: boolean\n prompt?: boolean\n install?: boolean\n force?: boolean\n }) => {\n try {\n const result = await init({\n dryRun: opts.dryRun,\n harnesses: opts.harness,\n all: opts.all,\n noPrompt: opts.prompt === false,\n noInstall: opts.install === false,\n force: opts.force,\n })\n\n if (!result.success) {\n console.error(pc.red(`\\nāŒ ${result.message}`))\n process.exit(1)\n }\n\n if (result.dryRun) {\n console.log(pc.cyan(`\\nšŸ” ${result.message} (dry-run)`))\n } else {\n console.log(pc.green(`\\nāœ… ${result.message}`))\n }\n\n if (result.created.length > 0) {\n console.log(`\\n${pc.bold(result.dryRun ? 'Would create:' : 'Created:')}`)\n result.created.forEach(file =>\n console.log(` ${pc.blue('šŸ“„')} ${pc.white(file)}`)\n )\n }\n\n if (result.harnessFiles && result.harnessFiles.length > 0) {\n console.log(`\\n${pc.bold('Harness workflow files:')}`)\n result.harnessFiles.forEach(file =>\n console.log(` ${pc.cyan('āš™ļø ')} ${pc.white(file)}`)\n )\n }\n\n if (result.warnings.length > 0) {\n console.log(pc.yellow('\\nWarnings:'))\n result.warnings.forEach(warn => console.log(` ${pc.yellow('āš ļø')} ${warn}`))\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n console.error(pc.red(`\\nāŒ ${message}`))\n process.exit(1)\n }\n }\n )\n\nprogram\n .command('update')\n .description('Update the Protocol to the latest version')\n .addHelpText(\n 'after',\n `\nThis command updates the managed protocol artifacts embedded in the CLI.\nYour ${pc.white('AGENT.md')}, ${pc.white('TASKS.md')}, ${pc.white('ISSUES.md')},\nworklogs, archives, specifications, decisions, and user documentation are preserved.\nInstalling an update never archives project records automatically.\n\nIt also:\n - Refreshes the @autonomos/cli devDependency in your package.json to the\n current CLI version (useful when an older init pinned an unresolvable\n version such as ^0.2.0).\n - When ${pc.white('--harness')} or ${pc.white('--all')} is passed, installs\n the workflow files for the given harness(es). This is the recommended\n way to add a new AI harness to an already-initialized project.\n\n${pc.bold('Version comparison:')}\n - If your project has an older version: Updates to the new version\n - If your project has a newer version: Warns you to update the CLI\n - If versions match: No action needed (but the devDependency is still\n refreshed and any newly requested harnesses are still installed)\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos update')}\n $ ${pc.cyan('autonomos update --harness opencode')}\n $ ${pc.cyan('autonomos update --harness opencode --harness kilocode')}\n $ ${pc.cyan('autonomos update --all')}\n`\n )\n .option(\n '--harness <name...>',\n 'Install workflow files for the specified harness id(s) in addition to refreshing existing ones'\n )\n .option(\n '--all',\n 'Install workflow files for every known harness in addition to refreshing existing ones'\n )\n .action((opts: { harness?: string[]; all?: boolean }) => {\n const result = update({ harnesses: opts.harness, all: opts.all })\n\n if (!result.success) {\n if (result.cliOutdated) {\n console.error(pc.yellow(`\\nāš ļø ${result.message}`))\n } else {\n console.error(pc.red(`\\nāŒ ${result.message}`))\n }\n process.exit(1)\n }\n\n console.log(pc.green(`\\nāœ… ${result.message}`))\n })\n\nprogram\n .command('status')\n .description('Show project status and task summary')\n .addHelpText(\n 'after',\n `\nDisplays information about the current project:\n - Protocol version\n - Protocol artifact integrity for the installed version\n - CLI version used for initialization\n - Current task registry summary (todo, in-progress, done, blocked)\n - With --history: separate archived counts and task ID collisions\n Only archive/**/TASKS.md registries are counted; history is not read by default.\n Archived does not imply completed. Read diagnostics and partial counts are explicit.\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos status')}\n $ ${pc.cyan('autonomos status --history')}\n`\n )\n .option('--history', 'Include archived task registries and check reserved task IDs')\n .action((opts: { history?: boolean }) => {\n const result = status({ history: opts.history })\n\n if (!result.success) {\n console.error(pc.red(`\\nāŒ ${result.message}`))\n process.exit(1)\n }\n\n console.log(\n `\\n${pc.bold('šŸ“¦ Protocol')} ${pc.green(`v${result.protocolVersion}`)} ${pc.dim(`(CLI v${result.cliVersion})`)}`\n )\n\n if (result.artifactIntegrity === 'valid') {\n console.log(` ${pc.green('āœ“ Artifacts match the published protocol version')}`)\n } else if (result.artifactIntegrity === 'drifted') {\n console.log(` ${pc.red('āœ— Protocol artifact drift detected')}`)\n for (const file of result.driftedArtifacts ?? []) {\n console.log(` ${pc.red('•')} ${file}`)\n }\n console.log(` ${pc.dim('Run `autonomos update` to restore canonical artifacts.')}`)\n } else {\n console.log(\n ` ${pc.yellow('! Artifact integrity is unverifiable with this CLI version')}`\n )\n }\n\n if (result.taskSummary) {\n const s = result.taskSummary\n console.log(`\\n${pc.bold('šŸ“‹ Current tasks:')} ${pc.cyan(s.total)} total`)\n console.log(` ${pc.white('⬜ Todo:')} ${pc.white(s.todo)}`)\n console.log(` ${pc.blue('šŸ”„ In Progress:')} ${pc.blue(s.inProgress)}`)\n console.log(` ${pc.green('āœ… Done:')} ${pc.green(s.done)}`)\n if (s.blocked > 0) {\n console.log(` ${pc.red('🚫 Blocked:')} ${pc.red(s.blocked)}`)\n }\n }\n if (result.archivedTaskSummary) {\n const s = result.archivedTaskSummary\n console.log(\n `\\n${pc.bold('Historical task records:')} ${s.total}${result.historyComplete ? '' : ' (incomplete scan)'}`\n )\n console.log(\n ` Todo: ${s.todo}; in progress: ${s.inProgress}; done: ${s.done}; blocked: ${s.blocked}`\n )\n console.log(\n pc.dim(\n ' Historical status is not current work; archived does not mean completed.'\n )\n )\n }\n for (const warning of result.warnings ?? []) console.warn(pc.yellow(`! ${warning}`))\n if (result.duplicateTaskIds?.length) {\n console.warn(pc.yellow(`! Duplicate task IDs: ${result.duplicateTaskIds.join(', ')}`))\n }\n if (result.warnings?.length || result.duplicateTaskIds?.length) process.exitCode = 1\n })\n\nprogram\n .command('agents')\n .description('List all AGENT.md files in the project, or the ancestor chain for a path')\n .argument(\n '[path]',\n 'Optional file or folder. When provided, return the ordered list of ancestor AGENT.md files (root -> target) instead of the full tree.'\n )\n .option('-a, --all', 'In tree mode: search from project root instead of current directory')\n .addHelpText(\n 'after',\n `\nThis command has two modes:\n\n${pc.bold('Tree mode')} (default, or with ${pc.cyan('--all')}):\n Discover and display all ${pc.white('AGENT.md')} files in a tree structure.\n Used at session start to get the broader fractal picture of the project.\n\n${pc.bold('Ancestors mode')} (with a positional ${pc.cyan('<path>')} argument):\n Return the ordered list of ${pc.white('AGENT.md')} files on the path from the\n target up to the project root. Root-first; non-existent ancestors are\n silently skipped. Used at task start to get the precise fractal context\n for the file or folder being worked on.\n\n${pc.bold('Examples:')}\n $ ${pc.cyan('autonomos agents')} # Tree, from current dir\n $ ${pc.cyan('autonomos agents --all')} # Tree, from project root\n $ ${pc.cyan('autonomos agents apps/web')} # Ancestors for apps/web\n $ ${pc.cyan('autonomos agents apps/web/components/ui/button.tsx')} # Ancestors for a file\n`\n )\n .action((path: string | undefined, opts: { all?: boolean }) => {\n const result = agents({ all: opts.all, target: path })\n\n if (!result.success) {\n console.error(\n pc.red(`\nāŒ ${result.message}`)\n )\n process.exit(1)\n }\n\n if (result.mode === 'ancestors') {\n console.log(\n pc.cyan(`\nšŸ” ${result.message}`)\n )\n } else {\n console.log('\\n' + (result.tree ?? result.message))\n console.log(\n pc.dim(`\n${result.message}`)\n )\n }\n })\n\nprogram\n .command('version')\n .description('Show the current Protocol version')\n .action(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ACrC,EAAG,MAAM,UAAU,EAAE;;;;;EAKlD,EAAG,KAAK,WAAW,EAAE;MACjB,EAAG,KAAK,kBAAkB,EAAE;MAC5B,EAAG,KAAK,wBAAwB,EAAE;MAClC,EAAG,KAAK,2BAA2B,EAAE;MACrC,EAAG,KAAK,oDAAoD,EAAE;CAEhE,CAAC,CACA,QAAQ,EAA0B,IAA4B,CAC3D,IAAM,EAAS,EAAO,CAAE,IAAK,EAAK,IAAK,OAAQ,CAAK,CAAC,EAEhD,EAAO,UACR,QAAQ,MACJ,EAAG,IAAI;IACnB,EAAO,SAAS,CACR,EACA,QAAQ,KAAK,CAAC,GAGd,EAAO,OAAS,YAChB,QAAQ,IACJ,EAAG,KAAK;KACnB,EAAO,SAAS,CACT,GAEA,QAAQ,IAAI;GAAQ,EAAO,MAAQ,EAAO,QAAQ,EAClD,QAAQ,IACJ,EAAG,IAAI;EACrB,EAAO,SAAS,CACN,EAER,CAAC,EAEL,EACK,QAAQ,SAAS,CAAC,CAClB,YAAY,mCAAmC,CAAC,CAChD,WAAa,CACV,QAAQ,IACJ,GAAG,EAAG,KAAK,gBAAgB,EAAE,GAAG,EAAG,MAAM,IAAI,GAAkB,EAAE,GAAG,EAAG,IAAI,SAAS,EAAY,EAAE,GACtG,CACJ,CAAC,EAEL,EAAQ,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonomos/cli",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "CLI tool for the Autonomos Agent Protocol",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  "commander": "^14.0.2",
39
39
  "picocolors": "1.1.1",
40
40
  "@inquirer/prompts": "^7.0.0",
41
- "@autonomos/core": "0.5.0"
41
+ "@autonomos/core": "0.7.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tala-tools/eslint": "0.1.3",