@crewx/cli 0.9.0-rc.180 → 0.9.0-rc.182

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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CLI_PROVIDER_INFO=void 0;exports.formatBytes=$;exports.inspectNpxCache=y;exports.inspectHookCommands=R;exports.inspectCrewxExecutable=E;exports.inspectCrewxShims=x;exports.checkCliProviders=S;exports.handleDoctor=ee;const w=require("node:child_process");const u=require("node:fs");const F=require("node:os");const c=require("node:path");const d=require("@crewx/sdk");const N=require("./parse-common-flags");const I=require("./hook/command-marker");exports.CLI_PROVIDER_INFO={codex:{cmd:"codex",install:"npm install -g @openai/codex"},claude:{cmd:"claude",install:"npm install -g @anthropic-ai/claude-code"},grok:{cmd:"grok",install:"curl -fsSL https://x.ai/cli/install.sh | bash"},opencode:{cmd:"opencode",install:"npm install -g opencode"},antigravity:{cmd:"antigravity",install:"npm install -g antigravity"},copilot:{cmd:"gh",install:"brew install gh # or visit cli.github.com"}};function v(e){switch(e){case"success":return"\u2705";case"warning":return"\u26A0\uFE0F ";case"error":return"\u274C"}}function P(e){try{(0,w.execSync)(`which ${e}`,{stdio:"ignore"});return true}catch{return false}}function $(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB","TB"];let n=e;let s=0;while(n>=1024&&s<t.length-1){n/=1024;s+=1}const o=s===0||n>=10?Math.round(n):n.toFixed(1);return`${o} ${t[s]}`}function p(e){try{const t=(0,u.lstatSync)(e);if(!t.isDirectory())return t.size;return(0,u.readdirSync)(e,{withFileTypes:true}).reduce((n,s)=>{return n+p((0,c.join)(e,s.name))},0)}catch{return 0}}function b(e){try{return(0,u.readdirSync)(e,{withFileTypes:true}).filter(t=>t.isDirectory()).map(t=>(0,c.join)(e,t.name)).sort()}catch{return[]}}function _(e){try{const t=JSON.parse((0,u.readFileSync)(e,"utf8"));if(typeof t!=="object"||t===null||Array.isArray(t))return void 0;return t}catch{return void 0}}function O(e=process.env){const t=e.NPM_CONFIG_CACHE??e.npm_config_cache;const n=t?.trim()||(0,c.join)((0,F.homedir)(),".npm");const s=(0,c.resolve)(n);return(0,c.basename)(s)==="_npx"?s:(0,c.join)(s,"_npx")}const L=["dependencies","devDependencies","optionalDependencies","peerDependencies"];function T(e){const t=_((0,c.join)(e,"package.json"));if(!t)return[];const n=[];for(const s of L){const o=t[s];if(typeof o!=="object"||o===null||Array.isArray(o))continue;for(const[i,r]of Object.entries(o)){if(typeof r!=="string"||!r.startsWith("file:"))continue;const a=(0,c.resolve)(e,r.slice("file:".length));if(!(0,u.existsSync)(a)){n.push(`${s}.${i}=${r} (missing ${a})`)}}}return n}function k(e,t,n){const s=e.get(t);if(s){s.details.push(...n);return s}const o={directory:t,sizeBytes:p(t),details:[...n]};e.set(t,o);return o}function y(e=O()){const t=(0,c.resolve)(e);const n=[];const s=[];const o=new Map;for(const i of b(t)){const r=(0,c.join)(i,"package-lock.json");try{const l=(0,u.statSync)(r);if(l.isFile()&&l.size===0){const h=k(o,i,[`0-byte lockfile: ${r}`]);n.push(h)}}catch{}const a=T(i);if(a.length>0){const l=k(o,i,a);s.push(l)}}return{cacheRoot:t,zeroByteLockfileDirectories:n,staleFileCacheDirectories:s,cleanableDirectories:[...o.values()]}}function C(e){if(typeof e!=="object"||e===null||Array.isArray(e))return void 0;return e}function X(e){const t=C(e.hooks)??e;const n=t.PreToolUse;if(!Array.isArray(n))return[];const s=[];for(const o of n){const i=C(o);const r=i?.hooks;if(!Array.isArray(r))continue;for(const a of r){const l=C(a)?.command;if(typeof l==="string"&&I.CREWX_HOOK_COMMAND_RE.test(l)){s.push(l)}}}return s}function B(e){const t=e.trim();if(!t)return"";if(t.startsWith("'")||t.startsWith('"')){const n=t[0];const s=t.indexOf(n,1);return s===-1?t.slice(1):t.slice(1,s)}return t.split(/\s+/,1)[0]}function H(e){return(0,c.isAbsolute)(e)||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")}function q(e){const t=B(e);if(/^(?:npx|pnpm|yarn)$/i.test(t))return"launcher";if(!H(t))return"non-absolute";return void 0}function R(e){const t=[{provider:"claude",settingsPath:(0,c.join)((0,c.resolve)(e),".claude","settings.json")},{provider:"codex",settingsPath:(0,c.join)((0,c.resolve)(e),".codex","hooks.json")}];const n=[];const s=[];for(const o of t){if(!(0,u.existsSync)(o.settingsPath))continue;n.push(o.settingsPath);const i=_(o.settingsPath);if(!i)continue;for(const r of X(i)){const a=q(r);if(a){s.push({provider:o.provider,settingsPath:o.settingsPath,command:r,reason:a})}}}return{inspectedFiles:n,issues:s}}function W(e,t="global_first"){try{const n=(0,d.loadYamlFile)(e);const s=n.settings?.bin_resolution;return s==="local_first"||s==="global_first"?s:t}catch{return t}}function z(e,t,n){if(n!=="win32")return[];try{(0,d.primeWindowsConsoleCodePage)();const s=(0,w.execFileSync)("where.exe",["crewx"],{cwd:e,env:t,encoding:null,stdio:["ignore","pipe","ignore"]});return(0,d.decodeConsoleBuffer)(s,{platform:n}).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0)}catch{return[]}}function E(e={}){const t=e.platform??process.platform;const n=(0,c.resolve)(e.cwd??process.cwd());const s=e.env??process.env;const o=e.configPath??(0,c.join)(n,"crewx.yaml");const i=e.resolution??(0,d.resolveCrewxExecutable)({env:s,cwd:n,platform:t});const r=e.pathCandidates?[...e.pathCandidates]:z(n,s,t);const a=i.ok?Object.keys(i.requiredEnv??{}).filter(l=>l==="ELECTRON_RUN_AS_NODE"):[];return{platform:t,pathCandidates:r,...i.ok?{stage:i.stage,argv:[...i.argv],adoptedPath:i.argv[0]}:{resolutionError:i.reason},electron:a.includes("ELECTRON_RUN_AS_NODE"),requiredEnvKeys:a,binResolution:e.binResolution??W(o)}}function M(e){const t=[`platform: ${e.platform}`,`stage: ${e.stage??"(unresolved)"}`,`argv: ${e.argv?(0,d.formatCrewxExecutableArgv)(e.argv):"(unresolved)"}`,`adopted path: ${e.adoptedPath??"(none)"}`,`Electron runtime: ${e.electron?"yes":"no"}`,`required environment keys: ${e.requiredEnvKeys.length>0?e.requiredEnvKeys.join(", "):"(none)"}`,`bin_resolution setting: ${e.binResolution}`,...e.platform==="win32"?[`where.exe crewx candidates: ${e.pathCandidates.length>0?e.pathCandidates.join(", "):"(none)"}`]:[]];if(e.resolutionError){return{name:"CrewX Executable",status:"warning",message:"Could not resolve the CrewX executable",details:`${t.join("\n")}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CLI_PROVIDER_INFO=void 0;exports.formatBytes=$;exports.inspectNpxCache=y;exports.inspectHookCommands=R;exports.inspectCrewxExecutable=E;exports.inspectCrewxShims=x;exports.checkCliProviders=S;exports.handleDoctor=ee;const w=require("node:child_process");const u=require("node:fs");const F=require("node:os");const c=require("node:path");const d=require("@crewx/sdk");const N=require("./parse-common-flags");const I=require("./hook/command-marker");exports.CLI_PROVIDER_INFO={codex:{cmd:"codex",install:"npm install -g @openai/codex"},claude:{cmd:"claude",install:"npm install -g @anthropic-ai/claude-code"},grok:{cmd:"grok",install:"curl -fsSL https://x.ai/cli/install.sh | bash"},opencode:{cmd:"opencode",install:"npm install -g opencode"},antigravity:{cmd:"agy",install:"https://antigravity.google/docs/getting-started/"},copilot:{cmd:"gh",install:"brew install gh # or visit cli.github.com"}};function v(e){switch(e){case"success":return"\u2705";case"warning":return"\u26A0\uFE0F ";case"error":return"\u274C"}}function P(e){try{(0,w.execSync)(`which ${e}`,{stdio:"ignore"});return true}catch{return false}}function $(e){if(!Number.isFinite(e)||e<=0)return"0 B";const t=["B","KB","MB","GB","TB"];let n=e;let s=0;while(n>=1024&&s<t.length-1){n/=1024;s+=1}const o=s===0||n>=10?Math.round(n):n.toFixed(1);return`${o} ${t[s]}`}function p(e){try{const t=(0,u.lstatSync)(e);if(!t.isDirectory())return t.size;return(0,u.readdirSync)(e,{withFileTypes:true}).reduce((n,s)=>{return n+p((0,c.join)(e,s.name))},0)}catch{return 0}}function b(e){try{return(0,u.readdirSync)(e,{withFileTypes:true}).filter(t=>t.isDirectory()).map(t=>(0,c.join)(e,t.name)).sort()}catch{return[]}}function _(e){try{const t=JSON.parse((0,u.readFileSync)(e,"utf8"));if(typeof t!=="object"||t===null||Array.isArray(t))return void 0;return t}catch{return void 0}}function O(e=process.env){const t=e.NPM_CONFIG_CACHE??e.npm_config_cache;const n=t?.trim()||(0,c.join)((0,F.homedir)(),".npm");const s=(0,c.resolve)(n);return(0,c.basename)(s)==="_npx"?s:(0,c.join)(s,"_npx")}const L=["dependencies","devDependencies","optionalDependencies","peerDependencies"];function T(e){const t=_((0,c.join)(e,"package.json"));if(!t)return[];const n=[];for(const s of L){const o=t[s];if(typeof o!=="object"||o===null||Array.isArray(o))continue;for(const[i,r]of Object.entries(o)){if(typeof r!=="string"||!r.startsWith("file:"))continue;const a=(0,c.resolve)(e,r.slice("file:".length));if(!(0,u.existsSync)(a)){n.push(`${s}.${i}=${r} (missing ${a})`)}}}return n}function k(e,t,n){const s=e.get(t);if(s){s.details.push(...n);return s}const o={directory:t,sizeBytes:p(t),details:[...n]};e.set(t,o);return o}function y(e=O()){const t=(0,c.resolve)(e);const n=[];const s=[];const o=new Map;for(const i of b(t)){const r=(0,c.join)(i,"package-lock.json");try{const l=(0,u.statSync)(r);if(l.isFile()&&l.size===0){const h=k(o,i,[`0-byte lockfile: ${r}`]);n.push(h)}}catch{}const a=T(i);if(a.length>0){const l=k(o,i,a);s.push(l)}}return{cacheRoot:t,zeroByteLockfileDirectories:n,staleFileCacheDirectories:s,cleanableDirectories:[...o.values()]}}function C(e){if(typeof e!=="object"||e===null||Array.isArray(e))return void 0;return e}function X(e){const t=C(e.hooks)??e;const n=t.PreToolUse;if(!Array.isArray(n))return[];const s=[];for(const o of n){const i=C(o);const r=i?.hooks;if(!Array.isArray(r))continue;for(const a of r){const l=C(a)?.command;if(typeof l==="string"&&I.CREWX_HOOK_COMMAND_RE.test(l)){s.push(l)}}}return s}function B(e){const t=e.trim();if(!t)return"";if(t.startsWith("'")||t.startsWith('"')){const n=t[0];const s=t.indexOf(n,1);return s===-1?t.slice(1):t.slice(1,s)}return t.split(/\s+/,1)[0]}function H(e){return(0,c.isAbsolute)(e)||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")}function q(e){const t=B(e);if(/^(?:npx|pnpm|yarn)$/i.test(t))return"launcher";if(!H(t))return"non-absolute";return void 0}function R(e){const t=[{provider:"claude",settingsPath:(0,c.join)((0,c.resolve)(e),".claude","settings.json")},{provider:"codex",settingsPath:(0,c.join)((0,c.resolve)(e),".codex","hooks.json")}];const n=[];const s=[];for(const o of t){if(!(0,u.existsSync)(o.settingsPath))continue;n.push(o.settingsPath);const i=_(o.settingsPath);if(!i)continue;for(const r of X(i)){const a=q(r);if(a){s.push({provider:o.provider,settingsPath:o.settingsPath,command:r,reason:a})}}}return{inspectedFiles:n,issues:s}}function W(e,t="global_first"){try{const n=(0,d.loadYamlFile)(e);const s=n.settings?.bin_resolution;return s==="local_first"||s==="global_first"?s:t}catch{return t}}function z(e,t,n){if(n!=="win32")return[];try{(0,d.primeWindowsConsoleCodePage)();const s=(0,w.execFileSync)("where.exe",["crewx"],{cwd:e,env:t,encoding:null,stdio:["ignore","pipe","ignore"]});return(0,d.decodeConsoleBuffer)(s,{platform:n}).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0)}catch{return[]}}function E(e={}){const t=e.platform??process.platform;const n=(0,c.resolve)(e.cwd??process.cwd());const s=e.env??process.env;const o=e.configPath??(0,c.join)(n,"crewx.yaml");const i=e.resolution??(0,d.resolveCrewxExecutable)({env:s,cwd:n,platform:t});const r=e.pathCandidates?[...e.pathCandidates]:z(n,s,t);const a=i.ok?Object.keys(i.requiredEnv??{}).filter(l=>l==="ELECTRON_RUN_AS_NODE"):[];return{platform:t,pathCandidates:r,...i.ok?{stage:i.stage,argv:[...i.argv],adoptedPath:i.argv[0]}:{resolutionError:i.reason},electron:a.includes("ELECTRON_RUN_AS_NODE"),requiredEnvKeys:a,binResolution:e.binResolution??W(o)}}function M(e){const t=[`platform: ${e.platform}`,`stage: ${e.stage??"(unresolved)"}`,`argv: ${e.argv?(0,d.formatCrewxExecutableArgv)(e.argv):"(unresolved)"}`,`adopted path: ${e.adoptedPath??"(none)"}`,`Electron runtime: ${e.electron?"yes":"no"}`,`required environment keys: ${e.requiredEnvKeys.length>0?e.requiredEnvKeys.join(", "):"(none)"}`,`bin_resolution setting: ${e.binResolution}`,...e.platform==="win32"?[`where.exe crewx candidates: ${e.pathCandidates.length>0?e.pathCandidates.join(", "):"(none)"}`]:[]];if(e.resolutionError){return{name:"CrewX Executable",status:"warning",message:"Could not resolve the CrewX executable",details:`${t.join("\n")}
2
2
  Resolution failed; no environment values were printed.`}}return{name:"CrewX Executable",status:"success",message:"SDK child executable contract is available",details:t.join("\n")}}function x(e=(0,d.getCrewxHome)(),t=(()=>{const n=(0,d.resolveCrewxExecutable)();return n.ok?(0,d.crewxCliShimFingerprint)(n):void 0})()){const n=(0,c.join)((0,c.resolve)(e),"bin-shim");const s=[];if(t){for(const o of b(n)){const i=o.slice(n.length+1);if(i===t)continue;s.push({fingerprint:i,directory:o,sizeBytes:p(o),details:[`not current fingerprint (${t})`]})}}return{shimRoot:n,currentFingerprint:t,staleDirectories:s}}function K(e){const t=e.zeroByteLockfileDirectories.length;const n=e.staleFileCacheDirectories.length;const s=e.cleanableDirectories.length;if(t===0&&n===0){return{name:"npx Cache",status:"success",message:`No stale entries found in ${e.cacheRoot}`}}const o=[];if(t>0){o.push(`0-byte package-lock.json: ${e.zeroByteLockfileDirectories.map(i=>i.directory).join(", ")}`)}if(n>0){o.push(`stale file: cache: ${e.staleFileCacheDirectories.map(i=>i.directory).join(", ")}`)}o.push("Run `crewx doctor --clean-npx-cache` to remove these cache directories explicitly.");return{name:"npx Cache",status:"warning",message:`Found ${s} problematic npx cache director${s===1?"y":"ies"}`,details:o.join("\n")}}function U(e){if(e.issues.length===0){return{name:"CrewX Hooks",status:"success",message:e.inspectedFiles.length>0?"Installed CrewX hook commands use absolute entrypoints":"No installed CrewX hooks found"}}const t=e.issues.map(n=>`${n.settingsPath}: ${n.command} (${n.reason})`).join("\n");return{name:"CrewX Hooks",status:"warning",message:`Found ${e.issues.length} hook command(s) that need an absolute CrewX entrypoint`,details:`${t}
3
3
  Run \`crewx hook install\` to refresh the hook after reviewing the change.`}}function V(e){if(!e.currentFingerprint){return{name:"CrewX PATH Shims",status:"warning",message:"Could not resolve the current CrewX executable; skipped orphan shim cleanup",details:`Shim root: ${e.shimRoot}`}}if(e.staleDirectories.length===0){return{name:"CrewX PATH Shims",status:"success",message:"No orphaned CrewX PATH shims found"}}return{name:"CrewX PATH Shims",status:"warning",message:`Found ${e.staleDirectories.length} orphaned CrewX PATH shim director${e.staleDirectories.length===1?"y":"ies"}`,details:`${e.staleDirectories.map(t=>t.directory).join(", ")}
4
4
  Run \`crewx doctor --clean-npx-cache\` to remove stale shims explicitly.`}}function D(e,t){const n=(0,c.resolve)(t);let s=0;const o=[];for(const i of e){const r=(0,c.resolve)(i.directory);if((0,c.dirname)(r)!==n){o.push(`${r} (unexpected parent)`);continue}try{(0,u.rmSync)(r,{recursive:true,force:true});if(!(0,u.existsSync)(r))s+=1;else o.push(r)}catch{o.push(r)}}return{removed:s,failed:o}}function G(e,t){const n=e.cleanableDirectories;const s=t.staleDirectories;const o=[...n,...s];const i=o.reduce((h,g)=>h+g.sizeBytes,0);console.log(`\u26A0\uFE0F --clean-npx-cache: before cleanup, ${n.length} npx cache director${n.length===1?"y":"ies"} and ${s.length} orphan shim director${s.length===1?"y":"ies"} (${$(i)}).`);const r=D(n,e.cacheRoot);const a=D(s,t.shimRoot);const l=[...r.failed,...a.failed];console.log(` Removed ${r.removed+a.removed} director${r.removed+a.removed===1?"y":"ies"}.`);if(l.length>0){console.log(` Could not remove: ${l.join(", ")}`)}}function J(e){if(!(0,u.existsSync)(e)){return{name:"Configuration File",status:"error",message:`Configuration file not found: ${e}`,details:"Run 'crewx init' to create a default configuration file."}}try{const t=(0,d.loadYamlFile)(e);const n=t;if(!n?.agents||!Array.isArray(n.agents)){return{name:"Configuration File",status:"error",message:"Invalid configuration format",details:"Configuration file exists but has invalid structure."}}if(n.agents.length===0){return{name:"Configuration File",status:"warning",message:"No agents configured",details:"Add agent definitions to your crewx.yaml."}}return{name:"Configuration File",status:"success",message:`Found ${n.agents.length} agent(s) in ${e}`}}catch(t){return{name:"Configuration File",status:"error",message:"Failed to parse configuration",details:`Error: ${t instanceof Error?t.message:String(t)}`}}}function Y(){const e=(0,c.join)(process.cwd(),".crewx","logs");if(!(0,u.existsSync)(e)){return{name:"Logs Directory",status:"warning",message:"Logs directory not found",details:`Will be created automatically at ${e}`}}return{name:"Logs Directory",status:"success",message:`Logs directory exists: ${e}`}}function S(){return d.PROVIDER_ORDER.map(e=>{const t=exports.CLI_PROVIDER_INFO[e];if(!t){return{name:`${e.toUpperCase()} CLI`,status:"error",message:"Diagnostic metadata is missing",details:`Add ${e} to CLI_PROVIDER_INFO.`}}const n=e==="copilot"?"copilot (gh)":e;const s=P(t.cmd);return{name:`${n.toUpperCase()} CLI`,status:s?"success":"warning",message:s?"Installed and available":"Not installed or not on PATH",details:s?void 0:`Install: ${t.install}`}})}function Z(){const e=process.env.CREWX_CLI;if(e){return{name:"CREWX_CLI",status:"success",message:`Set to: ${e}`}}return{name:"CREWX_CLI",status:"warning",message:'Not set \u2014 defaulting to "crewx"',details:"This is auto-set at CLI startup; no action needed."}}function Q(e){const t=e.filter(o=>o.status==="error").length;const n=e.filter(o=>o.status==="warning").length;const s=e.filter(o=>o.status==="success").length;if(t>0){return{status:"error",message:`System has ${t} error(s) that need attention`}}if(n>0){return{status:"warning",message:`System is functional with ${n} warning(s)`}}return{status:"success",message:`System is healthy \u2014 all ${s} checks passed`}}async function ee(e){const t=e.includes("--clean-npx-cache");const n=e.filter(f=>f!=="--clean-npx-cache");const{config:s}=(0,N.parseCommonFlags)(n);const o=s??process.env.CREWX_CONFIG??(0,c.join)(process.cwd(),"crewx.yaml");console.log("\u{1FA7A} Starting CrewX system diagnosis...\n");let i=y();let r=x();const a=(0,c.dirname)((0,c.resolve)(o));const l=R(a);const h=E({configPath:o,cwd:process.cwd()});if(t){G(i,r);i=y();r=x()}const g=[J(o),Y(),Z(),M(h),...S(),K(i),U(l),V(r)];g.forEach(f=>{const A=v(f.status);console.log(`${A} ${f.name}: ${f.message}`);if(f.details){console.log(` ${f.details}`)}});const m=Q(g);const j=v(m.status);console.log("");console.log("\u2500".repeat(60));console.log(`${j} Overall: ${m.message}`);if(m.status==="success"){console.log("\nNext steps:");console.log(' crewx q --to crewx "hello"')}else{console.log("\nAddress the issues above, then run `crewx doctor` again.")}if(m.status==="error"){process.exit(1)}}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handlePs=h;const d=require("@crewx/sdk/repository");const m=require("./cal");function c(t){const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const e=Math.floor(n/60);const o=n%60;if(e<60)return`${e}m ${o}s`;const r=Math.floor(e/60);return`${r}h ${e%60}m`}function u(t){const n=(t??"").trim();if(!n)return false;const e=n.split(/\s+/)[0]??"";const o=e.split("/").pop()??e;return o.startsWith("agy")}function p(t,n){try{const e=n.readLogsTail(t.id,1)?.entries??[];if(Array.isArray(e)&&e.length>0){const o=e[e.length-1];const r=o?.timestamp;const s=r?new Date(r).getTime():NaN;if(r&&!Number.isNaN(s)){const a=Math.max(0,Date.now()-s);return{display:`${c(a)} ago`,isoTimestamp:r,logCapable:true}}}}catch{}if(u(t.coding_agent_command)){return{display:"n/a",isoTimestamp:null,logCapable:false}}return{display:"\u2014",isoTimestamp:null,logCapable:true}}function g(t,n){const e=c(Date.now()-new Date(t.started_at).getTime());const o=p(t,n);return[t.id,t.agent_id??"\u2014",t.status,t.pid!==null&&t.pid!==void 0?String(t.pid):"\u2014",e,t.mode??"\u2014",o.display]}function f(t,n){const e=t.map((s,a)=>Math.max(s.length,...n.map(i=>(i[a]??"").length)));const o=e.map(s=>"-".repeat(s)).join(" ");const r=t.map((s,a)=>s.padEnd(e[a]??s.length)).join(" ");console.log(r);console.log(o);for(const s of n){console.log(s.map((a,i)=>a.padEnd(e[i]??a.length)).join(" "))}}async function h(t){const n=new d.TaskRepository;const e=await n.reapOrphanedTasks();if(e>0)console.error(`Reaped ${e} orphaned task(s)`);n.reapRunningWorkflowTasks();const o=n.getActiveTasks();if(t.includes("--json")){const a=o.map(i=>{const l=p(i,n);return{...i,last_active_at:l.isoTimestamp,log_capable:l.logCapable}});console.log(JSON.stringify(a,null,2));return}if(o.length===0){console.log("No active tasks.");return}const r=["TASK ID","AGENT","STATUS","PID","ELAPSED","MODE","LAST ACTIVE"];const s=o.map(a=>g(a,n));f(r,s);console.log(`
2
- ${o.length} active task(s)`);(0,m.writeCalFooter)({commandId:"crewx.ps",params:{taskId:o[0].id}})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handlePs=f;const d=require("@crewx/sdk/repository");const u=require("./cal");function c(e){const n=Math.floor(e/1e3);if(n<60)return`${n}s`;const t=Math.floor(n/60);const o=n%60;if(t<60)return`${t}m ${o}s`;const r=Math.floor(t/60);return`${r}h ${t%60}m`}function p(e,n){try{const t=n.readLogsTail(e.id,1)?.entries??[];if(Array.isArray(t)&&t.length>0){const o=t[t.length-1];const r=o?.timestamp;const s=r?new Date(r).getTime():NaN;if(r&&!Number.isNaN(s)){const a=Math.max(0,Date.now()-s);return{display:`${c(a)} ago`,isoTimestamp:r,logCapable:true}}}}catch{}return{display:"\u2014",isoTimestamp:null,logCapable:true}}function g(e,n){const t=c(Date.now()-new Date(e.started_at).getTime());const o=p(e,n);return[e.id,e.agent_id??"\u2014",e.status,e.pid!==null&&e.pid!==void 0?String(e.pid):"\u2014",t,e.mode??"\u2014",o.display]}function m(e,n){const t=e.map((s,a)=>Math.max(s.length,...n.map(i=>(i[a]??"").length)));const o=t.map(s=>"-".repeat(s)).join(" ");const r=e.map((s,a)=>s.padEnd(t[a]??s.length)).join(" ");console.log(r);console.log(o);for(const s of n){console.log(s.map((a,i)=>a.padEnd(t[i]??a.length)).join(" "))}}async function f(e){const n=new d.TaskRepository;const t=await n.reapOrphanedTasks();if(t>0)console.error(`Reaped ${t} orphaned task(s)`);n.reapRunningWorkflowTasks();const o=n.getActiveTasks();if(e.includes("--json")){const a=o.map(i=>{const l=p(i,n);return{...i,last_active_at:l.isoTimestamp,log_capable:l.logCapable}});console.log(JSON.stringify(a,null,2));return}if(o.length===0){console.log("No active tasks.");return}const r=["TASK ID","AGENT","STATUS","PID","ELAPSED","MODE","LAST ACTIVE"];const s=o.map(a=>g(a,n));m(r,s);console.log(`
2
+ ${o.length} active task(s)`);(0,u.writeCalFooter)({commandId:"crewx.ps",params:{taskId:o[0].id}})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewx/cli",
3
- "version": "0.9.0-rc.180",
3
+ "version": "0.9.0-rc.182",
4
4
  "license": "UNLICENSED",
5
5
  "engines": {
6
6
  "node": ">=20.19.0"
@@ -25,20 +25,20 @@
25
25
  "better-sqlite3": "*",
26
26
  "dotenv": "17.2.3",
27
27
  "isomorphic-git": "1.37.1",
28
- "@crewx/sdk": "0.9.0-rc.180",
29
- "@crewx/search": "0.1.10-rc.176",
30
- "@crewx/knowledge-core": "0.1.17-rc.190",
31
- "@crewx/memory": "0.1.23-rc.197",
32
- "@crewx/doc": "0.1.9-rc.173",
33
- "@crewx/wbs": "0.1.10-rc.206",
34
- "@crewx/cron": "0.1.10-rc.215",
35
- "@crewx/workflow": "0.3.22-rc.226",
36
- "@crewx/skill": "0.1.20-rc.74",
37
- "@crewx/chromex": "0.1.0-rc.213",
38
- "@crewx/wi": "0.1.10-rc.200",
39
- "@crewx/app": "0.1.0-rc.61",
40
- "@crewx/notify": "0.1.0-rc.151",
41
- "@crewx/shared": "0.0.6-rc.95"
28
+ "@crewx/sdk": "0.9.0-rc.182",
29
+ "@crewx/knowledge-core": "0.1.17-rc.192",
30
+ "@crewx/workflow": "0.3.22-rc.228",
31
+ "@crewx/search": "0.1.10-rc.178",
32
+ "@crewx/doc": "0.1.9-rc.175",
33
+ "@crewx/cron": "0.1.10-rc.217",
34
+ "@crewx/notify": "0.1.0-rc.153",
35
+ "@crewx/skill": "0.1.20-rc.76",
36
+ "@crewx/memory": "0.1.23-rc.199",
37
+ "@crewx/wbs": "0.1.10-rc.208",
38
+ "@crewx/wi": "0.1.10-rc.202",
39
+ "@crewx/chromex": "0.1.0-rc.215",
40
+ "@crewx/shared": "0.0.6-rc.97",
41
+ "@crewx/app": "0.1.0-rc.63"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/better-sqlite3": "*",