@ai-atomic-framework/cli 0.1.15 → 0.1.16

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.
@@ -555,10 +555,10 @@
555
555
  {
556
556
  "path": "runtime.mjs",
557
557
  "kind": "runtime-entrypoint",
558
- "bytes": 2481244,
559
- "sha256": "sha256:0e9025caad1c895f17a69f1366f9b5088f9c98a312c1dbea4e1a3fb47032dfe0"
558
+ "bytes": 2481314,
559
+ "sha256": "sha256:b5ec98f9161cba05df8072daaceb1ce5ec1b9616e50a8c5bf7834ce7abb09f93"
560
560
  }
561
561
  ],
562
562
  "fileCount": 83,
563
- "totalBytes": 2799490
563
+ "totalBytes": 2799560
564
564
  }
@@ -374,7 +374,7 @@ ${s.join(`
374
374
  `),r=AV({command:e.command,planningRoot:e.planningRoot,relativePath:e.relativePath,content:t});return Yve(t,r)}function Yve(e,t){return`${e.trimEnd()}
375
375
 
376
376
  <!-- atmPlanningCreationSeal ${JSON.stringify(t)} -->
377
- `}function AV(e){return{schemaId:"atm.planningCreationSeal.v1",command:e.command,createdAt:new Date().toISOString(),planningRoot:e.planningRoot.replace(/\\/g,"/"),relativePath:Rh(e.relativePath),contentDigest:`sha256:${fit("sha256").update(e.content,"utf8").digest("hex")}`}}function Qve(e,t){if(Ch(e))throw new h("ATM_PLAN_ARTIFACT_EXISTS",`planning artifact already exists: ${e}`,{exitCode:1});return yV(Cr.dirname(e),{recursive:!0}),Uve(e,t,"utf8"),[e]}function Rs(e){return new h("ATM_CLI_USAGE",e,{exitCode:2})}function Th(e,t){if(!e)throw Rs(`missing required ${t}`);return e}function da(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function nP(e){let t=e.trim().toUpperCase();if(!t)throw Rs("task prefix is required");if(/^(TASK|ATM)-[A-Z0-9]+$/.test(t))return t;if(/^[A-Z0-9]+$/.test(t))return`TASK-${t}`;throw Rs(`invalid task prefix: ${e}`)}function gw(e){return e.trim().toUpperCase().replace(/^(TASK|ATM)-/,"")}function Xve(e){let t=Rh(e);if(!t||t.includes("..")||Cr.isAbsolute(t))throw Rs(`invalid family dir: ${e}`);return t}function Tit(e){let t=Rh(e);if(!t.endsWith(".md")||t.includes("/")||t.includes(".."))throw Rs(`invalid doc name: ${e}`);return t}function Rh(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Cit(e){let t=(e??"active").trim().toLowerCase();return t==="archived"||t==="reserved"?t:"active"}function Zve(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"untitled"}function vV(e){return[...new Set(e.filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function Rit(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}E();bt();import{execSync as xit}from"node:child_process";import _it from"node:path";async function twe(e){let t=Pit(e);if(t.action==="register"){let m=ou(t.actorKind);if(!t.actorId)throw new h("ATM_CLI_USAGE","actor register requires --id <actor-id>.",{exitCode:2});if(!m)throw new h("ATM_CLI_USAGE","actor register requires --kind <human|ai-agent|automation>.",{exitCode:2});if(!t.displayName)throw new h("ATM_CLI_USAGE","actor register requires --name <display-name>.",{exitCode:2});let u=lg(t.cwd,{actorId:t.actorId,actorKind:m,displayName:t.displayName,provider:t.provider??void 0,editor:t.editor??void 0,gitName:t.gitName??void 0,gitEmail:t.gitEmail??void 0,contact:t.contact??void 0,capabilities:t.capabilities});return x({ok:!0,command:"actor",cwd:t.cwd,messages:[S("info","ATM_ACTOR_REGISTERED","Actor identity has been registered.",{actorId:u.actor.actorId,actorKind:u.actor.actorKind})],evidence:{actor:u.actor,registryPath:u.path}})}if(t.action==="adopt")return Eit(t);if(t.action==="list"){let m=fS(t.cwd);return x({ok:!0,command:"actor",cwd:t.cwd,messages:[S("info","ATM_ACTOR_LIST",`Loaded ${m.actors.length} actor identity record(s).`)],evidence:{registryPath:Vt,actors:m.actors}})}let r=Mit(t.actorId),o=Ha(t.cwd,r);if(!o)throw new h("ATM_ACTOR_NOT_FOUND",`Actor ${r.actorId} is not registered in ${Vt}.`,{exitCode:1,details:{actorId:r.actorId,source:r.source}});if(t.action==="resolve")return x({ok:!0,command:"actor",cwd:t.cwd,messages:[S("info","ATM_ACTOR_RESOLVED","Resolved actor identity from explicit option or environment.")],evidence:{resolvedFrom:r.source,actorId:r.actorId,actor:o,envPriority:[Sr,"AGENT_IDENTITY"]}});let a=ewe(t.cwd,"user.name"),n=ewe(t.cwd,"user.email"),s=o.gitName??null,i=o.gitEmail??null,c=s!==null&&a===s,d=i!==null&&n===i,l=c&&d;return x({ok:l,command:"actor",cwd:t.cwd,messages:[l?S("info","ATM_ACTOR_VERIFY_GIT_OK","Git identity matches the resolved actor."):S("error","ATM_ACTOR_VERIFY_GIT_MISMATCH","Git identity does not match the resolved actor.",{actorId:o.actorId,expectedName:s,expectedEmail:i,actualName:a,actualEmail:n})],evidence:{actorId:o.actorId,resolvedFrom:r.source,expected:{gitName:s,gitEmail:i},actual:{gitName:a,gitEmail:n},matches:{gitName:c,gitEmail:d}}})}function Eit(e){if(!e.editor)throw new h("ATM_CLI_USAGE","actor adopt requires --editor <editor-slug>.",{exitCode:2});if(!e.model)throw new h("ATM_CLI_USAGE","actor adopt requires --model <model-slug>.",{exitCode:2});let t=ou(e.actorKind??"ai-agent");if(!t)throw new h("ATM_CLI_USAGE","actor adopt --kind must be human | ai-agent | automation.",{exitCode:2});let r=y2(e.editor,e.model),o=e.gitName??r,a=e.gitEmail??`${r}@atm.local`,n=e.displayName??r,i=Ro(e.cwd)?.actorId??null,c=h2(e.cwd),d=null,l=!1;try{d=lg(e.cwd,{actorId:r,actorKind:t,displayName:n,provider:e.provider??void 0,editor:e.editor,gitName:o,gitEmail:a,contact:e.contact??void 0,capabilities:e.capabilities}).path,g2(e.cwd,o,a),l=c.name!==o||c.email!==a,ru(e.cwd,{schemaId:"atm.identityDefault.v1",specVersion:"0.1.0",actorId:r,gitName:o,gitEmail:a,editor:e.editor,provider:e.provider??null,activeSessionId:e.session??null,updatedAt:new Date().toISOString()})}catch(m){try{k2(e.cwd,c)}catch{}let u=m instanceof Error?m.message:String(m);throw new h("ATM_ACTOR_ADOPT_FAILED",`actor adopt transaction failed and git config was rolled back: ${u}`,{exitCode:1,details:{actorId:r,gitSnapshot:c}})}return x({ok:!0,command:"actor",cwd:e.cwd,messages:[S("info","ATM_ACTOR_ADOPTED","Actor identity adopted; registry, git config, and runtime default are in sync.",{actorId:r,previousActorId:i,gitConfigChanged:l})],evidence:{actorId:r,previousActorId:i,gitConfigChanged:l,runtimeDefaultPath:Bn,registryPath:d,editor:e.editor,model:e.model,activeSessionId:e.session??null}})}function Pit(e){let t={cwd:process.cwd(),action:null,actorId:null,actorKind:null,displayName:null,provider:null,editor:null,model:null,session:null,gitName:null,gitEmail:null,contact:null,capabilities:[]};for(let r=0;r<e.length;r+=1){let o=e[r];if(o==="--cwd"){t.cwd=Ba(e,r,"--cwd"),r+=1;continue}if(o==="--id"){t.actorId=Ba(e,r,"--id"),r+=1;continue}if(o==="--kind"){t.actorKind=Ba(e,r,"--kind"),r+=1;continue}if(o==="--name"){t.displayName=Ba(e,r,"--name"),r+=1;continue}if(o==="--provider"){t.provider=Ba(e,r,"--provider"),r+=1;continue}if(o==="--editor"){t.editor=Ba(e,r,"--editor"),r+=1;continue}if(o==="--model"){t.model=Ba(e,r,"--model"),r+=1;continue}if(o==="--session"){t.session=Ba(e,r,"--session"),r+=1;continue}if(o==="--git-name"){t.gitName=Ba(e,r,"--git-name"),r+=1;continue}if(o==="--git-email"){t.gitEmail=Ba(e,r,"--git-email"),r+=1;continue}if(o==="--contact"){t.contact=Ba(e,r,"--contact"),r+=1;continue}if(o==="--capabilities"){t.capabilities=Ba(e,r,"--capabilities").split(",").map(a=>a.trim()).filter(Boolean),r+=1;continue}if(!(o==="--json"||o==="--pretty")){if(o.startsWith("--"))throw new h("ATM_CLI_USAGE",`actor does not support option ${o}`,{exitCode:2});if(t.action)throw new h("ATM_CLI_USAGE","actor accepts only one action.",{exitCode:2});t.action=o}}if(!t.action||!["register","list","resolve","verify-git","adopt"].includes(t.action))throw new h("ATM_CLI_USAGE","actor supports: register, list, resolve, verify-git, adopt",{exitCode:2});return{cwd:_it.resolve(t.cwd),action:t.action,actorId:t.actorId,actorKind:t.actorKind,displayName:t.displayName,provider:t.provider,editor:t.editor,model:t.model,session:t.session,gitName:t.gitName,gitEmail:t.gitEmail,contact:t.contact,capabilities:t.capabilities}}function Ba(e,t,r){let o=e[t+1];if(!o||o.startsWith("--"))throw new h("ATM_CLI_USAGE",`actor requires a value for ${r}`,{exitCode:2});return o}function Mit(e){let t=ye(e);if(t)return t;throw new h("ATM_ACTOR_ID_MISSING",`No actor identity was provided. Use --id or set ${Sr} (legacy alias: AGENT_IDENTITY).`,{exitCode:2})}function ewe(e,t){try{return xit(`git config --local --get ${t}`,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}bt();Hr();iy();E();import Oit from"node:path";async function rwe(e){let t=Dit(e);if(t.action==="show"){let u=t.actorId?Ga(t.cwd,t.actorId):Ro(t.cwd),f=u?.activeSessionId?Et(t.cwd,{sessionId:u.activeSessionId,includeNonActive:!0}):null,p=gS(t.actorId,t.cwd),g=tC({explicitActorId:t.actorId,envActorId:p.envActorId,legacyEnvActorId:p.legacyEnvActorId,repoDefaultActorId:p.repoDefaultActorId,activeClaimOwnerActorId:null,laneSessionId:u?.activeSessionId??null,buildCommand:"npm run build"});return x({ok:!0,command:"identity",cwd:t.cwd,messages:[S("info","ATM_IDENTITY_SHOW",u?t.actorId?`Loaded actor identity for ${u.actorId}.`:`Loaded repo default identity for ${u.actorId}.`:t.actorId?`No actor identity is configured yet for ${t.actorId}.`:"No repo default identity is configured yet.",{actorResolution:p,sharedWriteAuthority:g})],evidence:{identity:u,identityPath:u?t.actorId?Od(t.actorId):Bn:null,actorResolution:p,sharedWriteAuthority:g,activeSession:f,recentSessions:ha(t.cwd).slice(0,5)}})}if(t.action==="clear"){let u=t.actorId?Od(t.actorId):Bn,f=t.actorId?p2(t.cwd,t.actorId):f2(t.cwd);return x({ok:!0,command:"identity",cwd:t.cwd,messages:[S("info","ATM_IDENTITY_CLEARED",t.actorId?`Actor runtime identity cleared for ${t.actorId}.`:"Repo default runtime identity cleared.",{actorId:t.actorId,identityPath:u,removed:f,nextStep:'Set an explicit editor/agent actor identity before governed work: node atm.mjs identity set --actor <actor-id> --editor <editor-id> --git-name "<git user.name>" --git-email "<git user.email>" --json'})],evidence:{action:"clear",actorId:t.actorId,identityPath:u,removed:f}})}let r=Ro(t.cwd),o=t.actorId??r?.actorId??null;if(!o)throw new h("ATM_CLI_USAGE","identity set requires --actor <actor-id> or an existing repo default identity.",{exitCode:2});let a=Ha(t.cwd,{actorId:o,source:"option"}),n=new Date().toISOString(),s=t.actorId?Ga(t.cwd,o):r,i={schemaId:"atm.identityDefault.v1",specVersion:"0.1.0",actorId:o,gitName:t.gitName??s?.gitName??a?.gitName??null,gitEmail:t.gitEmail??s?.gitEmail??a?.gitEmail??null,editor:t.editor??s?.editor??a?.editor??null,provider:t.provider??s?.provider??a?.provider??null,activeSessionId:t.activeSessionId??s?.activeSessionId??null,updatedAt:n},c=t.actorId?hS(t.cwd,o,i):ru(t.cwd,i),d=null,l=ou(t.actorKind)??a?.actorKind??null,m=t.displayName??a?.displayName??null;return l&&m&&(d=lg(t.cwd,{actorId:o,actorKind:l,displayName:m,provider:t.provider??a?.provider??void 0,editor:t.editor??a?.editor??void 0,gitName:t.gitName??a?.gitName??void 0,gitEmail:t.gitEmail??a?.gitEmail??void 0,contact:t.contact??a?.contact??void 0,capabilities:t.capabilities.length>0?t.capabilities:a?.capabilities}).path),x({ok:!0,command:"identity",cwd:t.cwd,messages:[S("info","ATM_IDENTITY_SET",t.actorId?`Actor identity set to ${o}.`:`Repo default identity set to ${o}.`,{actorId:o,actorScoped:!!t.actorId,registryUpdated:!!d})],evidence:{identity:i,identityPath:c,registryPath:d,actorRegistered:!!d}})}function Dit(e){let t={cwd:process.cwd(),action:null,actorId:null,displayName:null,actorKind:null,provider:null,editor:null,gitName:null,gitEmail:null,contact:null,capabilities:[],activeSessionId:null};for(let r=0;r<e.length;r+=1){let o=e[r];if(o==="--cwd"){t.cwd=En(e,r,"--cwd"),r+=1;continue}if(o==="--actor"){t.actorId=En(e,r,"--actor"),r+=1;continue}if(o==="--name"){t.displayName=En(e,r,"--name"),r+=1;continue}if(o==="--kind"){t.actorKind=En(e,r,"--kind"),r+=1;continue}if(o==="--provider"){t.provider=En(e,r,"--provider"),r+=1;continue}if(o==="--editor"){t.editor=En(e,r,"--editor"),r+=1;continue}if(o==="--git-name"){t.gitName=En(e,r,"--git-name"),r+=1;continue}if(o==="--git-email"){t.gitEmail=En(e,r,"--git-email"),r+=1;continue}if(o==="--contact"){t.contact=En(e,r,"--contact"),r+=1;continue}if(o==="--capabilities"){t.capabilities=En(e,r,"--capabilities").split(",").map(a=>a.trim()).filter(Boolean),r+=1;continue}if(o==="--active-session"){t.activeSessionId=En(e,r,"--active-session"),r+=1;continue}if(!(o==="--json"||o==="--pretty")){if(o.startsWith("--"))throw new h("ATM_CLI_USAGE",`identity does not support option ${o}`,{exitCode:2});if(t.action)throw new h("ATM_CLI_USAGE","identity accepts only one action.",{exitCode:2});t.action=o==="status"?"show":o}}if(!t.action||t.action!=="set"&&t.action!=="show"&&t.action!=="clear")throw new h("ATM_CLI_USAGE","identity supports: set, show, status, clear",{exitCode:2});return{cwd:Oit.resolve(t.cwd),action:t.action,actorId:t.actorId,displayName:t.displayName,actorKind:t.actorKind,provider:t.provider,editor:t.editor,gitName:t.gitName,gitEmail:t.gitEmail,contact:t.contact,capabilities:t.capabilities,activeSessionId:t.activeSessionId}}function En(e,t,r){let o=e[t+1];if(!o||o.startsWith("--"))throw new h("ATM_CLI_USAGE",`identity requires a value for ${r}`,{exitCode:2});return o}import{existsSync as cwe,readFileSync as Wit}from"node:fs";import dwe from"node:path";E();Lg();import{existsSync as Fit,readFileSync as awe,writeFileSync as jit}from"node:fs";import nwe from"node:path";var owe="# ATM runtime state (managed by ATM bootstrap):start",$it="# ATM runtime state (managed by ATM bootstrap):end",Nit=[".atm/runtime/telemetry/",".atm/runtime/guidance/",".atm/runtime/locks/",".atm/runtime/emergency/",".atm/runtime/current-task.json",".atm/runtime/batch-run.json",".atm/runtime/batch-runs/",".atm/runtime/identity/",".atm/runtime/sessions/",".atm/runtime/task-intent.json",".atm/runtime/task-queues/",".atm/runtime/quickfix-lock.json",".atm/runtime/validator-cache/",".atm/runtime/validator-runs/",".atm/runtime/validation-receipts/",".atm/runtime/evidence-ledger/",".atm/runtime/incidents/",".atm/runtime/write-broker.registry.json",".atm/runtime/git-commit-attempts/",".atm/runtime/lane-sessions/",".atm/runtime/close-transactions/",".atm/runtime/broker-intents/",".atm/runtime/broker-shared-surface-freezes.json",".atm/runtime/broker-shared-surface-queues.json",".atm-temp/","node_modules/"];function swe(e){if(Lit(e))return{status:"framework-repository"};let t=nwe.join(e,".gitignore"),r=Fit(t)?awe(t,"utf8"):"";if(r.includes(owe))return{status:"existing",path:".gitignore"};let o=r.includes(`\r
377
+ `}function AV(e){return{schemaId:"atm.planningCreationSeal.v1",command:e.command,createdAt:new Date().toISOString(),planningRoot:e.planningRoot.replace(/\\/g,"/"),relativePath:Rh(e.relativePath),contentDigest:`sha256:${fit("sha256").update(e.content,"utf8").digest("hex")}`}}function Qve(e,t){if(Ch(e))throw new h("ATM_PLAN_ARTIFACT_EXISTS",`planning artifact already exists: ${e}`,{exitCode:1});return yV(Cr.dirname(e),{recursive:!0}),Uve(e,t,"utf8"),[e]}function Rs(e){return new h("ATM_CLI_USAGE",e,{exitCode:2})}function Th(e,t){if(!e)throw Rs(`missing required ${t}`);return e}function da(e){return typeof e=="string"&&e.trim().length>0?e.trim():null}function nP(e){let t=e.trim().toUpperCase();if(!t)throw Rs("task prefix is required");if(/^(TASK|ATM)-[A-Z0-9]+$/.test(t))return t;if(/^[A-Z0-9]+$/.test(t))return`TASK-${t}`;throw Rs(`invalid task prefix: ${e}`)}function gw(e){return e.trim().toUpperCase().replace(/^(TASK|ATM)-/,"")}function Xve(e){let t=Rh(e);if(!t||t.includes("..")||Cr.isAbsolute(t))throw Rs(`invalid family dir: ${e}`);return t}function Tit(e){let t=Rh(e);if(!t.endsWith(".md")||t.includes("/")||t.includes(".."))throw Rs(`invalid doc name: ${e}`);return t}function Rh(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function Cit(e){let t=(e??"active").trim().toLowerCase();return t==="archived"||t==="reserved"?t:"active"}function Zve(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"untitled"}function vV(e){return[...new Set(e.filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function Rit(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}E();bt();import{execSync as xit}from"node:child_process";import _it from"node:path";async function twe(e){let t=Pit(e);if(t.action==="register"){let m=ou(t.actorKind);if(!t.actorId)throw new h("ATM_CLI_USAGE","actor register requires --id <actor-id>.",{exitCode:2});if(!m)throw new h("ATM_CLI_USAGE","actor register requires --kind <human|ai-agent|automation>.",{exitCode:2});if(!t.displayName)throw new h("ATM_CLI_USAGE","actor register requires --name <display-name>.",{exitCode:2});let u=lg(t.cwd,{actorId:t.actorId,actorKind:m,displayName:t.displayName,provider:t.provider??void 0,editor:t.editor??void 0,gitName:t.gitName??void 0,gitEmail:t.gitEmail??void 0,contact:t.contact??void 0,capabilities:t.capabilities});return x({ok:!0,command:"actor",cwd:t.cwd,messages:[S("info","ATM_ACTOR_REGISTERED","Actor identity has been registered.",{actorId:u.actor.actorId,actorKind:u.actor.actorKind})],evidence:{actor:u.actor,registryPath:u.path}})}if(t.action==="adopt")return Eit(t);if(t.action==="list"){let m=fS(t.cwd);return x({ok:!0,command:"actor",cwd:t.cwd,messages:[S("info","ATM_ACTOR_LIST",`Loaded ${m.actors.length} actor identity record(s).`)],evidence:{registryPath:Vt,actors:m.actors}})}let r=Mit(t.actorId),o=Ha(t.cwd,r);if(!o)throw new h("ATM_ACTOR_NOT_FOUND",`Actor ${r.actorId} is not registered in ${Vt}.`,{exitCode:1,details:{actorId:r.actorId,source:r.source}});if(t.action==="resolve")return x({ok:!0,command:"actor",cwd:t.cwd,messages:[S("info","ATM_ACTOR_RESOLVED","Resolved actor identity from explicit option or environment.")],evidence:{resolvedFrom:r.source,actorId:r.actorId,actor:o,envPriority:[Sr,"AGENT_IDENTITY"]}});let a=ewe(t.cwd,"user.name"),n=ewe(t.cwd,"user.email"),s=o.gitName??null,i=o.gitEmail??null,c=s!==null&&a===s,d=i!==null&&n===i,l=c&&d;return x({ok:l,command:"actor",cwd:t.cwd,messages:[l?S("info","ATM_ACTOR_VERIFY_GIT_OK","Git identity matches the resolved actor."):S("error","ATM_ACTOR_VERIFY_GIT_MISMATCH","Git identity does not match the resolved actor.",{actorId:o.actorId,expectedName:s,expectedEmail:i,actualName:a,actualEmail:n})],evidence:{actorId:o.actorId,resolvedFrom:r.source,expected:{gitName:s,gitEmail:i},actual:{gitName:a,gitEmail:n},matches:{gitName:c,gitEmail:d}}})}function Eit(e){if(!e.editor)throw new h("ATM_CLI_USAGE","actor adopt requires --editor <editor-slug>.",{exitCode:2});if(!e.model)throw new h("ATM_CLI_USAGE","actor adopt requires --model <model-slug>.",{exitCode:2});let t=ou(e.actorKind??"ai-agent");if(!t)throw new h("ATM_CLI_USAGE","actor adopt --kind must be human | ai-agent | automation.",{exitCode:2});let r=y2(e.editor,e.model),o=e.gitName??r,a=e.gitEmail??`${r}@atm.local`,n=e.displayName??r,i=Ro(e.cwd)?.actorId??null,c=h2(e.cwd),d=null,l=!1;try{d=lg(e.cwd,{actorId:r,actorKind:t,displayName:n,provider:e.provider??void 0,editor:e.editor,gitName:o,gitEmail:a,contact:e.contact??void 0,capabilities:e.capabilities}).path,g2(e.cwd,o,a),l=c.name!==o||c.email!==a,ru(e.cwd,{schemaId:"atm.identityDefault.v1",specVersion:"0.1.0",actorId:r,gitName:o,gitEmail:a,editor:e.editor,provider:e.provider??null,activeSessionId:e.session??null,updatedAt:new Date().toISOString()})}catch(m){try{k2(e.cwd,c)}catch{}let u=m instanceof Error?m.message:String(m);throw new h("ATM_ACTOR_ADOPT_FAILED",`actor adopt transaction failed and git config was rolled back: ${u}`,{exitCode:1,details:{actorId:r,gitSnapshot:c}})}return x({ok:!0,command:"actor",cwd:e.cwd,messages:[S("info","ATM_ACTOR_ADOPTED","Actor identity adopted; registry, git config, and runtime default are in sync.",{actorId:r,previousActorId:i,gitConfigChanged:l})],evidence:{actorId:r,previousActorId:i,gitConfigChanged:l,runtimeDefaultPath:Bn,registryPath:d,editor:e.editor,model:e.model,activeSessionId:e.session??null}})}function Pit(e){let t={cwd:process.cwd(),action:null,actorId:null,actorKind:null,displayName:null,provider:null,editor:null,model:null,session:null,gitName:null,gitEmail:null,contact:null,capabilities:[]};for(let r=0;r<e.length;r+=1){let o=e[r];if(o==="--cwd"){t.cwd=Ba(e,r,"--cwd"),r+=1;continue}if(o==="--id"){t.actorId=Ba(e,r,"--id"),r+=1;continue}if(o==="--kind"){t.actorKind=Ba(e,r,"--kind"),r+=1;continue}if(o==="--name"){t.displayName=Ba(e,r,"--name"),r+=1;continue}if(o==="--provider"){t.provider=Ba(e,r,"--provider"),r+=1;continue}if(o==="--editor"){t.editor=Ba(e,r,"--editor"),r+=1;continue}if(o==="--model"){t.model=Ba(e,r,"--model"),r+=1;continue}if(o==="--session"){t.session=Ba(e,r,"--session"),r+=1;continue}if(o==="--git-name"){t.gitName=Ba(e,r,"--git-name"),r+=1;continue}if(o==="--git-email"){t.gitEmail=Ba(e,r,"--git-email"),r+=1;continue}if(o==="--contact"){t.contact=Ba(e,r,"--contact"),r+=1;continue}if(o==="--capabilities"){t.capabilities=Ba(e,r,"--capabilities").split(",").map(a=>a.trim()).filter(Boolean),r+=1;continue}if(!(o==="--json"||o==="--pretty")){if(o.startsWith("--"))throw new h("ATM_CLI_USAGE",`actor does not support option ${o}`,{exitCode:2});if(t.action)throw new h("ATM_CLI_USAGE","actor accepts only one action.",{exitCode:2});t.action=o}}if(!t.action||!["register","list","resolve","verify-git","adopt"].includes(t.action))throw new h("ATM_CLI_USAGE","actor supports: register, list, resolve, verify-git, adopt",{exitCode:2});return{cwd:_it.resolve(t.cwd),action:t.action,actorId:t.actorId,actorKind:t.actorKind,displayName:t.displayName,provider:t.provider,editor:t.editor,model:t.model,session:t.session,gitName:t.gitName,gitEmail:t.gitEmail,contact:t.contact,capabilities:t.capabilities}}function Ba(e,t,r){let o=e[t+1];if(!o||o.startsWith("--"))throw new h("ATM_CLI_USAGE",`actor requires a value for ${r}`,{exitCode:2});return o}function Mit(e){let t=ye(e);if(t)return t;throw new h("ATM_ACTOR_ID_MISSING",`No actor identity was provided. Use --id or set ${Sr} (legacy alias: AGENT_IDENTITY).`,{exitCode:2})}function ewe(e,t){try{return xit(`git config --local --get ${t}`,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}bt();Hr();iy();E();import Oit from"node:path";async function rwe(e){let t=Dit(e);if(t.action==="show"){let u=t.actorId?Ga(t.cwd,t.actorId):Ro(t.cwd),f=u?.activeSessionId?Et(t.cwd,{sessionId:u.activeSessionId,includeNonActive:!0}):null,p=gS(t.actorId,t.cwd),g=tC({explicitActorId:t.actorId,envActorId:p.envActorId,legacyEnvActorId:p.legacyEnvActorId,repoDefaultActorId:p.repoDefaultActorId,activeClaimOwnerActorId:null,laneSessionId:u?.activeSessionId??null,buildCommand:"npm run build"});return x({ok:!0,command:"identity",cwd:t.cwd,messages:[S("info","ATM_IDENTITY_SHOW",u?t.actorId?`Loaded actor identity for ${u.actorId}.`:`Loaded repo default identity for ${u.actorId}.`:t.actorId?`No actor identity is configured yet for ${t.actorId}.`:"No repo default identity is configured yet.",{actorResolution:p,sharedWriteAuthority:g})],evidence:{identity:u,identityPath:u?t.actorId?Od(t.actorId):Bn:null,actorResolution:p,sharedWriteAuthority:g,activeSession:f,recentSessions:ha(t.cwd).slice(0,5)}})}if(t.action==="clear"){let u=t.actorId?Od(t.actorId):Bn,f=t.actorId?p2(t.cwd,t.actorId):f2(t.cwd);return x({ok:!0,command:"identity",cwd:t.cwd,messages:[S("info","ATM_IDENTITY_CLEARED",t.actorId?`Actor runtime identity cleared for ${t.actorId}.`:"Repo default runtime identity cleared.",{actorId:t.actorId,identityPath:u,removed:f,nextStep:'Set an explicit editor/agent actor identity before governed work: node atm.mjs identity set --actor <actor-id> --editor <editor-id> --git-name "<git user.name>" --git-email "<git user.email>" --json'})],evidence:{action:"clear",actorId:t.actorId,identityPath:u,removed:f}})}let r=Ro(t.cwd),o=t.actorId??r?.actorId??null;if(!o)throw new h("ATM_CLI_USAGE","identity set requires --actor <actor-id> or an existing repo default identity.",{exitCode:2});let a=Ha(t.cwd,{actorId:o,source:"option"}),n=new Date().toISOString(),s=t.actorId?Ga(t.cwd,o):r,i={schemaId:"atm.identityDefault.v1",specVersion:"0.1.0",actorId:o,gitName:t.gitName??s?.gitName??a?.gitName??null,gitEmail:t.gitEmail??s?.gitEmail??a?.gitEmail??null,editor:t.editor??s?.editor??a?.editor??null,provider:t.provider??s?.provider??a?.provider??null,activeSessionId:t.activeSessionId??s?.activeSessionId??null,updatedAt:n},c=t.actorId?hS(t.cwd,o,i):ru(t.cwd,i),d=null,l=ou(t.actorKind)??a?.actorKind??null,m=t.displayName??a?.displayName??null;return l&&m&&(d=lg(t.cwd,{actorId:o,actorKind:l,displayName:m,provider:t.provider??a?.provider??void 0,editor:t.editor??a?.editor??void 0,gitName:t.gitName??a?.gitName??void 0,gitEmail:t.gitEmail??a?.gitEmail??void 0,contact:t.contact??a?.contact??void 0,capabilities:t.capabilities.length>0?t.capabilities:a?.capabilities}).path),x({ok:!0,command:"identity",cwd:t.cwd,messages:[S("info","ATM_IDENTITY_SET",t.actorId?`Actor identity set to ${o}.`:`Repo default identity set to ${o}.`,{actorId:o,actorScoped:!!t.actorId,registryUpdated:!!d})],evidence:{identity:i,identityPath:c,registryPath:d,actorRegistered:!!d}})}function Dit(e){let t={cwd:process.cwd(),action:null,actorId:null,displayName:null,actorKind:null,provider:null,editor:null,gitName:null,gitEmail:null,contact:null,capabilities:[],activeSessionId:null};for(let r=0;r<e.length;r+=1){let o=e[r];if(o==="--cwd"){t.cwd=En(e,r,"--cwd"),r+=1;continue}if(o==="--actor"){t.actorId=En(e,r,"--actor"),r+=1;continue}if(o==="--name"){t.displayName=En(e,r,"--name"),r+=1;continue}if(o==="--kind"){t.actorKind=En(e,r,"--kind"),r+=1;continue}if(o==="--provider"){t.provider=En(e,r,"--provider"),r+=1;continue}if(o==="--editor"){t.editor=En(e,r,"--editor"),r+=1;continue}if(o==="--git-name"){t.gitName=En(e,r,"--git-name"),r+=1;continue}if(o==="--git-email"){t.gitEmail=En(e,r,"--git-email"),r+=1;continue}if(o==="--contact"){t.contact=En(e,r,"--contact"),r+=1;continue}if(o==="--capabilities"){t.capabilities=En(e,r,"--capabilities").split(",").map(a=>a.trim()).filter(Boolean),r+=1;continue}if(o==="--active-session"){t.activeSessionId=En(e,r,"--active-session"),r+=1;continue}if(!(o==="--json"||o==="--pretty")){if(o.startsWith("--"))throw new h("ATM_CLI_USAGE",`identity does not support option ${o}`,{exitCode:2});if(t.action)throw new h("ATM_CLI_USAGE","identity accepts only one action.",{exitCode:2});t.action=o==="status"?"show":o}}if(!t.action||t.action!=="set"&&t.action!=="show"&&t.action!=="clear")throw new h("ATM_CLI_USAGE","identity supports: set, show, status, clear",{exitCode:2});return{cwd:Oit.resolve(t.cwd),action:t.action,actorId:t.actorId,displayName:t.displayName,actorKind:t.actorKind,provider:t.provider,editor:t.editor,gitName:t.gitName,gitEmail:t.gitEmail,contact:t.contact,capabilities:t.capabilities,activeSessionId:t.activeSessionId}}function En(e,t,r){let o=e[t+1];if(!o||o.startsWith("--"))throw new h("ATM_CLI_USAGE",`identity requires a value for ${r}`,{exitCode:2});return o}import{existsSync as cwe,readFileSync as Wit}from"node:fs";import dwe from"node:path";E();Lg();import{existsSync as Fit,readFileSync as awe,writeFileSync as jit}from"node:fs";import nwe from"node:path";var owe="# ATM runtime state (managed by ATM bootstrap):start",$it="# ATM runtime state (managed by ATM bootstrap):end",Nit=[".atm/runtime/telemetry/",".atm/runtime/guidance/",".atm/runtime/locks/",".atm/runtime/emergency/",".atm/runtime/current-task.json",".atm/runtime/batch-run.json",".atm/runtime/batch-runs/",".atm/runtime/identity/",".atm/runtime/sessions/",".atm/runtime/task-intent.json",".atm/runtime/task-queues/",".atm/runtime/quickfix-lock.json",".atm/runtime/validator-cache/",".atm/runtime/validator-runs/",".atm/runtime/validation-receipts/",".atm/runtime/evidence-ledger/",".atm/runtime/incidents/",".atm/runtime/write-broker.registry.json",".atm/runtime/git-commit-attempts/",".atm/runtime/lane-sessions/",".atm/runtime/close-transactions/",".atm/runtime/broker-intents/",".atm/runtime/broker-shared-surface-freezes.json",".atm/runtime/broker-shared-surface-queues.json",".atm/runtime/version-cache.json",".atm/history/reports/task-import/",".atm-temp/","node_modules/"];function swe(e){if(Lit(e))return{status:"framework-repository"};let t=nwe.join(e,".gitignore"),r=Fit(t)?awe(t,"utf8"):"";if(r.includes(owe))return{status:"existing",path:".gitignore"};let o=r.includes(`\r
378
378
  `)?`\r
379
379
  `:`
380
380
  `,a=[owe,...Nit,$it].join(o),n=r.length===0?"":r.endsWith(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-atomic-framework/cli",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "description": "CLI entrypoint for AI-Atomic-Framework repository adoption and validation.",
6
6
  "license": "Apache-2.0",