@zibby/cli 0.1.35 → 0.1.37

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import{dirname as T,join as O,resolve as j}from"path";import{fileURLToPath as b}from"url";import{readFileSync as R,existsSync as L}from"fs";import{compileGraph as A,validateGraphConfig as G}from"@zibby/core/framework/graph-compiler.js";import{WorkflowGraph as J}from"@zibby/core/framework/graph.js";import{buildAnalysisGraph as U}from"@zibby/core/templates/code-analysis/graph.js";import{analysisStateSchema as z}from"@zibby/core/templates/code-analysis/state.js";import"@zibby/core/templates/register-nodes.js";import{fetchExecutionContext as D}from"../utils/execution-context.js";import{reportProgress as W,reportArtifact as K,reportFinalStatus as M}from"../utils/progress-reporter.js";import{writeMcpConfig as N}from"@zibby/core/utils/mcp-config-writer.js";const F=b(import.meta.url),B=T(F),q=JSON.parse(R(O(B,"../../package.json"),"utf-8")),H={analyze_ticket:t=>({key:"analysis",value:{raw:t.raw,structured:t.output}}),generate_code:t=>({key:"codeImplementation",value:t.output?.codeImplementation}),generate_test_cases:t=>({key:"tests",value:t.output?.tests}),finalize:t=>({key:"report",value:t.output?.report})};function Q(t,h){return async function(a,v,u){const I=Date.now(),f=[];let E="";const _=console.log,$=process.stdout.write.bind(process.stdout),p=process.stderr.write.bind(process.stderr);let S=!1;console.log=(...e)=>{const c=e.map(i=>typeof i=="string"?i:JSON.stringify(i)).join(" ");f.push(c),S=!0,_(...e),S=!1};let n="";process.stdout.write=(e,c,i)=>{if(!S){const s=typeof e=="string"?e:e.toString();n+=s;const d=n.split(`
2
+ import{dirname as x,join as O,resolve as M}from"path";import{fileURLToPath as b}from"url";import{readFileSync as P,existsSync as L}from"fs";import{compileGraph as A,validateGraphConfig as G}from"@zibby/core/framework/graph-compiler.js";import{WorkflowGraph as J}from"@zibby/core/framework/graph.js";import{buildAnalysisGraph as U}from"@zibby/core/templates/code-analysis/graph.js";import{analysisStateSchema as z}from"@zibby/core/templates/code-analysis/state.js";import"@zibby/core/templates/register-nodes.js";import{fetchExecutionContext as D}from"../utils/execution-context.js";import{reportProgress as W,reportArtifact as K,reportFinalStatus as R}from"../utils/progress-reporter.js";import{writeMcpConfig as N}from"@zibby/core/utils/mcp-config-writer.js";const F=b(import.meta.url),B=x(F),q=JSON.parse(P(O(B,"../../package.json"),"utf-8")),H={analyze_ticket:t=>({key:"analysis",value:{raw:t.raw,structured:t.output}}),generate_code:t=>({key:"codeImplementation",value:t.output?.codeImplementation}),generate_test_cases:t=>({key:"tests",value:t.output?.tests}),finalize:t=>({key:"report",value:t.output?.report})};function Q(t,h){return async function(a,v,u){const I=Date.now(),f=[];let k="";const _=console.log,$=process.stdout.write.bind(process.stdout),p=process.stderr.write.bind(process.stderr);let S=!1;console.log=(...e)=>{const c=e.map(i=>typeof i=="string"?i:JSON.stringify(i)).join(" ");f.push(c),S=!0,_(...e),S=!1};let n="";process.stdout.write=(e,c,i)=>{if(!S){const s=typeof e=="string"?e:e.toString();n+=s;const d=n.split(`
3
3
  `);n=d.pop()||"";for(const g of d){const m=g.trim();m&&f.push(m)}}return $(e,c,i)},_(`[Middleware] Started capturing logs for ${a}`);let y=!1;const C=setInterval(()=>{if(y)return;const e=f.join(`
4
- `);e!==E&&e.length>0&&(E=e,p(`\u{1F4E1} [Middleware] Sending live update for ${a}: ${e.length} chars, ${f.length} lines
4
+ `);e!==k&&e.length>0&&(k=e,p(`\u{1F4E1} [Middleware] Sending live update for ${a}: ${e.length} chars, ${f.length} lines
5
5
  `),t(a,"in_progress",e,u).catch(c=>{p(`\u26A0\uFE0F [Middleware] Failed to send live update: ${c.message}
6
6
  `)}))},500);try{await t(a,"in_progress","",u);const e=await v(),c=((Date.now()-I)/1e3).toFixed(1);y=!0,clearInterval(C),await new Promise(s=>setImmediate(s)),console.log=_,process.stdout.write=$,n.trim()&&(f.push(n.trim()),n="");const i=f.join(`
7
7
  `);if(p(`\u{1F4E1} [Middleware] Sending final update for ${a}: ${i.length} chars, ${f.length} total lines captured
@@ -10,9 +10,9 @@ import{dirname as T,join as O,resolve as j}from"path";import{fileURLToPath as b}
10
10
  Error: ${e.error}`,u);return e}catch(e){y=!0,clearInterval(C),await new Promise(i=>setImmediate(i)),console.log=_,process.stdout.write=$;const c=`${f.join(`
11
11
  `)}
12
12
 
13
- Error: ${e.message}`;throw await t(a,"failed",c,u),e}}}async function X(t){const{EXECUTION_ID:h,TICKET_KEY:k,PROJECT_ID:a,REPOS:v,PROGRESS_QUEUE_URL:u,PROGRESS_API_URL:I,SQS_AUTH_TOKEN:f,PROJECT_API_TOKEN:E,GITHUB_TOKEN:_,MODEL:$}=process.env;(!h||!k||!a)&&(console.error("\u274C Missing required environment variables"),console.error(" Required: EXECUTION_ID, TICKET_KEY, PROJECT_ID"),process.exit(1));const p=await D(h,a),S=p.ticketContext;let n=p.nodeConfigs||{};const y=v?JSON.parse(v):p.repos,C=process.env.WORKSPACE||"/workspace",e=b(import.meta.resolve("@zibby/core")),c=O(T(e),"templates","code-analysis","prompts");console.log(`
14
- \u{1F680} Zibby Analysis (Graph Mode)`),console.log(`@zibby/cli v${q.version} | Node.js ${process.version}`),console.log("\u2500".repeat(60)),console.log(`Ticket: ${k}`),console.log(`Repositories: ${y.length}`),console.log(`Workspace: ${C}`),console.log(`AI Model: ${$||"auto"}`),console.log("\u2500".repeat(60));const i=Q(W,K);let s,d,g=null;if(t?.workflow){const o=j(process.cwd(),t.workflow);if(L(o)||(console.error(`\u274C Workflow file not found: ${o}`),process.exit(1)),o.endsWith(".js")||o.endsWith(".mjs"))try{const{pathToFileURL:r}=await import("url");g=await import(r(o).href),d=`local JS module (${o})`}catch(r){console.error(`\u274C Failed to load workflow JS module: ${r.message}`),process.exit(1)}else{try{const l=JSON.parse(R(o,"utf-8")),{_meta:w,...P}=l;s=P,d=`local file (${o})`}catch(l){console.error(`\u274C Failed to parse workflow file: ${l.message}`),process.exit(1)}const r=G(s);r.valid||(console.error("\u274C Invalid workflow file:"),r.errors.forEach(l=>console.error(` - ${l}`)),process.exit(1))}}else if(p.graphConfig)s=p.graphConfig,d="custom (from project workflow)";else{const o=new J;U(o),s=o.serialize(),d="default"}let m;if(g){const r={...g.nodeConfigs||{},...n};m=g.buildGraph({nodeMiddleware:i}),console.log(`\u{1F4D0} Graph source: ${d}`),console.log(` Nodes: ${m.nodes.size}`),n=r}else{if(n&&Object.keys(n).length>0){const o=s.nodeConfigs||{},r={...o};for(const[l,w]of Object.entries(n))r[l]={...o[l],...w};s.nodeConfigs=r}console.log(`\u{1F4D0} Graph source: ${d}`),console.log(` Nodes: ${s.nodes?.length||0}`),console.log(` Edges: ${s.edges?.length||0}`),m=A(s,{nodeMiddleware:i,stateSchema:z})}N(n);const x={EXECUTION_ID:h,PROGRESS_QUEUE_URL:u,PROGRESS_API_URL:I,SQS_AUTH_TOKEN:f,PROJECT_API_TOKEN:E,workspace:C,repos:y,ticketContext:S,promptsDir:c,githubToken:_,model:$,nodeConfigs:n};try{const r=(await m.run(null,x)).state,l=r.analyze_ticket_output?.validation||r.analyze_ticket_output?.analysis?.structured?.validation;let w="completed";l&&!l.canProceed&&(w=l.status==="insufficient_context"?"insufficient_context":"blocked"),console.log(`
13
+ Error: ${e.message}`;throw await t(a,"failed",c,u),e}}}async function X(t){const{EXECUTION_ID:h,TICKET_KEY:E,PROJECT_ID:a,REPOS:v,PROGRESS_QUEUE_URL:u,PROGRESS_API_URL:I,SQS_AUTH_TOKEN:f,PROJECT_API_TOKEN:k,GITHUB_TOKEN:_,MODEL:$}=process.env;(!h||!E||!a)&&(console.error("\u274C Missing required environment variables"),console.error(" Required: EXECUTION_ID, TICKET_KEY, PROJECT_ID"),process.exit(1));const p=await D(h,a),S=p.ticketContext;let n=p.nodeConfigs||{};const y=v?JSON.parse(v):p.repos,C=process.env.WORKSPACE||"/workspace",e=b(import.meta.resolve("@zibby/core/package.json")),c=O(x(e),"templates","code-analysis","prompts");console.log(`
14
+ \u{1F680} Zibby Analysis (Graph Mode)`),console.log(`@zibby/cli v${q.version} | Node.js ${process.version}`),console.log("\u2500".repeat(60)),console.log(`Ticket: ${E}`),console.log(`Repositories: ${y.length}`),console.log(`Workspace: ${C}`),console.log(`AI Model: ${$||"auto"}`),console.log("\u2500".repeat(60));const i=Q(W,K);let s,d,g=null;if(t?.workflow){const o=M(process.cwd(),t.workflow);if(L(o)||(console.error(`\u274C Workflow file not found: ${o}`),process.exit(1)),o.endsWith(".js")||o.endsWith(".mjs"))try{const{pathToFileURL:r}=await import("url");g=await import(r(o).href),d=`local JS module (${o})`}catch(r){console.error(`\u274C Failed to load workflow JS module: ${r.message}`),process.exit(1)}else{try{const l=JSON.parse(P(o,"utf-8")),{_meta:w,...j}=l;s=j,d=`local file (${o})`}catch(l){console.error(`\u274C Failed to parse workflow file: ${l.message}`),process.exit(1)}const r=G(s);r.valid||(console.error("\u274C Invalid workflow file:"),r.errors.forEach(l=>console.error(` - ${l}`)),process.exit(1))}}else if(p.graphConfig)s=p.graphConfig,d="custom (from project workflow)";else{const o=new J;U(o),s=o.serialize(),d="default"}let m;if(g){const r={...g.nodeConfigs||{},...n};m=g.buildGraph({nodeMiddleware:i}),console.log(`\u{1F4D0} Graph source: ${d}`),console.log(` Nodes: ${m.nodes.size}`),n=r}else{if(n&&Object.keys(n).length>0){const o=s.nodeConfigs||{},r={...o};for(const[l,w]of Object.entries(n))r[l]={...o[l],...w};s.nodeConfigs=r}console.log(`\u{1F4D0} Graph source: ${d}`),console.log(` Nodes: ${s.nodes?.length||0}`),console.log(` Edges: ${s.edges?.length||0}`),m=A(s,{nodeMiddleware:i,stateSchema:z})}N(n);const T={EXECUTION_ID:h,PROGRESS_QUEUE_URL:u,PROGRESS_API_URL:I,SQS_AUTH_TOKEN:f,PROJECT_API_TOKEN:k,workspace:C,repos:y,ticketContext:S,promptsDir:c,githubToken:_,model:$,nodeConfigs:n};try{const r=(await m.run(null,T)).state,l=r.analyze_ticket_output?.validation||r.analyze_ticket_output?.analysis?.structured?.validation;let w="completed";l&&!l.canProceed&&(w=l.status==="insufficient_context"?"insufficient_context":"blocked"),console.log(`
15
15
  \u{1F4CB} Validation: canProceed=${l?.canProceed}, status=${l?.status}, finalStatus=${w}`),console.log(`
16
- \u{1F4CA} Sending final status: ${w}`),await M(x,{status:w}),console.log(`
16
+ \u{1F4CA} Sending final status: ${w}`),await R(T,{status:w}),console.log(`
17
17
  \u2705 Analysis completed successfully`),process.exit(0)}catch(o){if(console.error(`
18
- \u274C Analysis failed:`,o.message),h)try{console.log("\u{1F4E1} Reporting failure..."),await M(x,{status:"failed",error:o.message})}catch{console.error("\u26A0\uFE0F Failed to report error")}process.exit(1)}}import.meta.url===`file://${process.argv[1]}`&&X();export{X as analyzeCommand};
18
+ \u274C Analysis failed:`,o.message),h)try{console.log("\u{1F4E1} Reporting failure..."),await R(T,{status:"failed",error:o.message})}catch{console.error("\u26A0\uFE0F Failed to report error")}process.exit(1)}}import.meta.url===`file://${process.argv[1]}`&&X();export{X as analyzeCommand};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-sqs": "^3.1029.0",
36
- "@zibby/core": "^0.1.25",
36
+ "@zibby/core": "^0.1.26",
37
37
  "@zibby/memory": "^0.1.4",
38
38
  "@zibby/skills": "^0.1.5",
39
39
  "adm-zip": "^0.5.17",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-sqs": "^3.1029.0",
36
- "@zibby/core": "^0.1.25",
36
+ "@zibby/core": "^0.1.26",
37
37
  "@zibby/memory": "^0.1.4",
38
38
  "@zibby/skills": "^0.1.5",
39
39
  "adm-zip": "^0.5.17",