@moxxy/cli 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24280,9 +24280,42 @@ Handle any errors by adapting. Report the results of each step.`,
24280
24280
  const result = await supervisor.sendInstruction(agentId, instruction);
24281
24281
  return { response: result.response, sessionKey: result.sessionKey };
24282
24282
  }
24283
+ function extractJSON(response, stageName) {
24284
+ const fenceMatch = response.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
24285
+ if (fenceMatch) {
24286
+ try {
24287
+ return JSON.parse(fenceMatch[1].trim());
24288
+ } catch {
24289
+ }
24290
+ }
24291
+ const braceMatch = response.match(/\{[\s\S]*\}/);
24292
+ if (braceMatch) {
24293
+ try {
24294
+ return JSON.parse(braceMatch[0]);
24295
+ } catch {
24296
+ }
24297
+ }
24298
+ const firstBrace = response.indexOf("{");
24299
+ if (firstBrace !== -1) {
24300
+ let depth = 0;
24301
+ for (let i = firstBrace; i < response.length; i++) {
24302
+ if (response[i] === "{") depth++;
24303
+ else if (response[i] === "}") depth--;
24304
+ if (depth === 0) {
24305
+ try {
24306
+ return JSON.parse(response.slice(firstBrace, i + 1));
24307
+ } catch {
24308
+ break;
24309
+ }
24310
+ }
24311
+ }
24312
+ }
24313
+ const snippet = response.length > 200 ? `${response.slice(0, 200)}...` : response;
24314
+ throw new Error(`No valid JSON found in ${stageName} response. Response was: ${snippet}`);
24315
+ }
24283
24316
  async function inspectIssue(supervisor, agentId, payload, research) {
24284
24317
  const instruction = {
24285
- prompt: `Deeply inspect the following files for issue #${payload.issueNumber}: ${payload.title}
24318
+ prompt: `Deeply inspect the following files for issue #${payload.issueNumber}: ${payload.title}. You MUST respond with ONLY a raw JSON object \u2014 no markdown, no explanation, no code fences.
24286
24319
 
24287
24320
  Files to inspect:
24288
24321
  ${research.relevantFiles.map((f) => `- ${f}`).join("\n")}
@@ -24292,17 +24325,16 @@ Provide detailed analysis:
24292
24325
  2. Root cause or implementation location
24293
24326
  3. Required changes
24294
24327
 
24295
- Return JSON: {"findings": [...], "rootCause": "...", "suggestedApproach": "...", "estimatedChanges": [...]}`,
24328
+ Respond with exactly this JSON structure (no other text):
24329
+ {"findings": [...], "rootCause": "...", "suggestedApproach": "...", "estimatedChanges": [{"file": "...", "description": "..."}]}`,
24296
24330
  metadata: { stage: "inspect", issueNumber: payload.issueNumber }
24297
24331
  };
24298
24332
  const result = await supervisor.sendInstruction(agentId, instruction);
24299
- const jsonMatch = result.response.match(/\{[\s\S]*\}/);
24300
- if (!jsonMatch) throw new Error("No JSON found in inspect response");
24301
- return JSON.parse(jsonMatch[0]);
24333
+ return extractJSON(result.response, "inspect");
24302
24334
  }
24303
24335
  async function planIssue(supervisor, agentId, payload, inspection) {
24304
24336
  const instruction = {
24305
- prompt: `Create a detailed implementation plan for issue #${payload.issueNumber}: ${payload.title}
24337
+ prompt: `Create a detailed implementation plan for issue #${payload.issueNumber}: ${payload.title}. You MUST respond with ONLY a raw JSON object \u2014 no markdown, no explanation, no code fences.
24306
24338
 
24307
24339
  Inspection findings:
24308
24340
  ${JSON.stringify(inspection, null, 2)}
@@ -24312,17 +24344,16 @@ Create a step-by-step plan listing:
24312
24344
  2. Specific changes for each file
24313
24345
  3. Testing approach
24314
24346
 
24315
- Return JSON: {"steps": [{"action": "create|modify|delete", "path": "...", "description": "...", "content": "..."}], "testPlan": "...", "commitMessage": "..."}`,
24347
+ Respond with exactly this JSON structure (no other text):
24348
+ {"steps": [{"action": "create|modify|delete", "path": "...", "description": "...", "content": "..."}], "testPlan": "...", "commitMessage": "..."}`,
24316
24349
  metadata: { stage: "plan", issueNumber: payload.issueNumber }
24317
24350
  };
24318
24351
  const result = await supervisor.sendInstruction(agentId, instruction);
24319
- const jsonMatch = result.response.match(/\{[\s\S]*\}/);
24320
- if (!jsonMatch) throw new Error("No JSON found in plan response");
24321
- return JSON.parse(jsonMatch[0]);
24352
+ return extractJSON(result.response, "plan");
24322
24353
  }
24323
24354
  async function researchIssue(supervisor, agentId, payload, classification) {
24324
24355
  const instruction = {
24325
- prompt: `Research this ${classification.type} issue in the codebase.
24356
+ prompt: `Research this ${classification.type} issue in the codebase. You MUST respond with ONLY a raw JSON object \u2014 no markdown, no explanation, no code fences.
24326
24357
 
24327
24358
  Issue #${payload.issueNumber}: ${payload.title}
24328
24359
  ${payload.body || ""}
@@ -24334,29 +24365,27 @@ Analyze the codebase and identify:
24334
24365
  2. Dependencies and related modules
24335
24366
  3. Potential impact areas
24336
24367
 
24337
- Return JSON: {"relevantFiles": [...], "relatedModules": [...], "potentialImpact": "...", "techStack": [...]}`,
24368
+ Respond with exactly this JSON structure (no other text):
24369
+ {"relevantFiles": [...], "relatedModules": [...], "potentialImpact": "...", "techStack": [...]}`,
24338
24370
  metadata: { stage: "research", issueNumber: payload.issueNumber }
24339
24371
  };
24340
24372
  const result = await supervisor.sendInstruction(agentId, instruction);
24341
- const jsonMatch = result.response.match(/\{[\s\S]*\}/);
24342
- if (!jsonMatch) throw new Error("No JSON found in research response");
24343
- return JSON.parse(jsonMatch[0]);
24373
+ return extractJSON(result.response, "research");
24344
24374
  }
24345
24375
  async function triageIssue(supervisor, agentId, payload) {
24346
24376
  const instruction = {
24347
- prompt: `Classify this GitHub issue. Return ONLY a JSON object.
24377
+ prompt: `Classify this GitHub issue. You MUST respond with ONLY a raw JSON object \u2014 no markdown, no explanation, no code fences.
24348
24378
 
24349
24379
  Issue #${payload.issueNumber}: ${payload.title}
24350
24380
  ${payload.body || "No description provided."}
24351
24381
  Labels: ${payload.labels.join(", ") || "none"}
24352
24382
 
24353
- Return JSON: {"type": "feature|bug|refactor|docs|test|chore", "priority": "low|medium|high|urgent", "complexity": "trivial|small|medium|large|epic", "confidence": 0.0-1.0, "reasoning": "..."}`,
24383
+ Respond with exactly this JSON structure (no other text):
24384
+ {"type": "feature|bug|refactor|docs|test|chore", "priority": "low|medium|high|urgent", "complexity": "trivial|small|medium|large|epic", "confidence": 0.0-1.0, "reasoning": "..."}`,
24354
24385
  metadata: { stage: "triage", issueNumber: payload.issueNumber }
24355
24386
  };
24356
24387
  const result = await supervisor.sendInstruction(agentId, instruction);
24357
- const jsonMatch = result.response.match(/\{[\s\S]*\}/);
24358
- if (!jsonMatch) throw new Error("No JSON found in triage response");
24359
- return JSON.parse(jsonMatch[0]);
24388
+ return extractJSON(result.response, "triage");
24360
24389
  }
24361
24390
  function buildWorkflow(payload, plan, branchName) {
24362
24391
  const steps = [];
@@ -24513,12 +24542,21 @@ var init_dist7 = __esm({
24513
24542
  }
24514
24543
  }
24515
24544
  async commentOnIssue(owner, repo, issueNumber, body) {
24516
- await this.octokit.issues.createComment({
24545
+ const { data } = await this.octokit.issues.createComment({
24517
24546
  owner,
24518
24547
  repo,
24519
24548
  issue_number: issueNumber,
24520
24549
  body
24521
24550
  });
24551
+ return data.id;
24552
+ }
24553
+ async updateComment(owner, repo, commentId, body) {
24554
+ await this.octokit.issues.updateComment({
24555
+ owner,
24556
+ repo,
24557
+ comment_id: commentId,
24558
+ body
24559
+ });
24522
24560
  }
24523
24561
  async createBranch(owner, repo, branchName, fromRef) {
24524
24562
  const { data: ref } = await this.octokit.git.getRef({
@@ -24601,8 +24639,9 @@ var init_dist7 = __esm({
24601
24639
  updatedAt: Date.now()
24602
24640
  };
24603
24641
  const activeStages = PIPELINE_STAGES.filter((s) => this.enabledStages.has(s));
24642
+ let commentId;
24604
24643
  try {
24605
- await this.github.commentOnIssue(
24644
+ commentId = await this.github.commentOnIssue(
24606
24645
  payload.repo.owner,
24607
24646
  payload.repo.name,
24608
24647
  payload.issueNumber,
@@ -24678,23 +24717,27 @@ Automated implementation by Moxxy.${classificationNote}`,
24678
24717
  pipelineRun.prNumber = prNumber;
24679
24718
  pipelineRun.status = "completed";
24680
24719
  pipelineRun.updatedAt = Date.now();
24681
- await this.github.commentOnIssue(
24682
- payload.repo.owner,
24683
- payload.repo.name,
24684
- payload.issueNumber,
24685
- buildSuccessComment(pipelineRun, payload)
24686
- );
24720
+ if (commentId) {
24721
+ await this.github.updateComment(
24722
+ payload.repo.owner,
24723
+ payload.repo.name,
24724
+ commentId,
24725
+ buildSuccessComment(pipelineRun, payload)
24726
+ );
24727
+ }
24687
24728
  return pipelineRun;
24688
24729
  } catch (error2) {
24689
24730
  pipelineRun.status = "failed";
24690
24731
  pipelineRun.updatedAt = Date.now();
24691
- await this.github.commentOnIssue(
24692
- payload.repo.owner,
24693
- payload.repo.name,
24694
- payload.issueNumber,
24695
- buildFailureComment(pipelineRun, error2)
24696
- ).catch(() => {
24697
- });
24732
+ if (commentId) {
24733
+ await this.github.updateComment(
24734
+ payload.repo.owner,
24735
+ payload.repo.name,
24736
+ commentId,
24737
+ buildFailureComment(pipelineRun, error2)
24738
+ ).catch(() => {
24739
+ });
24740
+ }
24698
24741
  return pipelineRun;
24699
24742
  }
24700
24743
  }
@@ -24925,12 +24968,22 @@ function registerStartCommand(program) {
24925
24968
  connectSpinner.succeed(`Connected to ${sdkName}`);
24926
24969
  const supervisorSpinner = spinner("Initializing agent supervisor");
24927
24970
  const supervisor = new MoltAgentSupervisor2(sdk);
24928
- const agentId = config.agent?.moltAgentId;
24971
+ let agentId = config.agent?.moltAgentId;
24972
+ if (!agentId) {
24973
+ const agentList = await sdk.agents.list();
24974
+ const agents = agentList.agents ?? [];
24975
+ if (agents.length > 0) {
24976
+ const picked = agentList.defaultAgentId && agents.find((a) => (a.agentId || a.id) === agentList.defaultAgentId) || agents[0];
24977
+ agentId = picked.agentId || picked.id;
24978
+ }
24979
+ }
24929
24980
  if (agentId) {
24930
24981
  await supervisor.assignAgent(agentId, "developer");
24931
24982
  supervisorSpinner.succeed(`Agent ${import_chalk.default.bold(agentId)} assigned`);
24932
24983
  } else {
24933
- supervisorSpinner.succeed("Supervisor ready (no agent configured)");
24984
+ supervisorSpinner.warn(
24985
+ `No agents found. Run ${import_chalk.default.cyan("moxxy agent create <id>")} to create one.`
24986
+ );
24934
24987
  }
24935
24988
  const integrationManager = new IntegrationManager2();
24936
24989
  const github = new GitHubIntegration2();
@@ -25092,7 +25145,7 @@ __export(cli_exports, {
25092
25145
  });
25093
25146
  function createProgram() {
25094
25147
  const program = new import_commander.Command();
25095
- program.name("moxxy").description("Moxxy - Agent orchestration platform").version("0.0.4");
25148
+ program.name("moxxy").description("Moxxy - Agent orchestration platform").version("0.0.7");
25096
25149
  registerStartCommand(program);
25097
25150
  registerRepoCommand(program);
25098
25151
  registerConfigCommand(program);
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  ConfigManager,
3
3
  createProgram
4
- } from "./chunk-FHHLXTEZ.mjs";
4
+ } from "./chunk-CPL5V56X.mjs";
5
5
  import "./chunk-GSNMMI3H.mjs";
6
6
  import "./chunk-6DZX6EAA.mjs";
7
7
 
8
8
  // src/index.ts
9
9
  async function run() {
10
- const { createProgram: createProgram2 } = await import("./cli-E7U56QVQ.mjs");
10
+ const { createProgram: createProgram2 } = await import("./cli-2QKJ5UUL.mjs");
11
11
  const program = createProgram2();
12
12
  await program.parseAsync(process.argv);
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxxy/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "User-facing CLI for Moxxy agent orchestration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -51,12 +51,12 @@
51
51
  "tsup": "^8.0.1",
52
52
  "typescript": "^5.7.0",
53
53
  "vitest": "^2.1.0",
54
+ "@moxxy/types": "1.0.0",
55
+ "@moxxy/molt": "1.0.0",
54
56
  "@moxxy/integration-base": "1.0.0",
55
- "@moxxy/claude": "0.1.0",
56
57
  "@moxxy/agents": "1.0.0",
57
58
  "@moxxy/integration-github": "1.0.0",
58
- "@moxxy/types": "1.0.0",
59
- "@moxxy/molt": "1.0.0"
59
+ "@moxxy/claude": "0.1.0"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "tsup",