(input: {
command: string;
client: OpenCodeClient;
sessionId?: string;
rawArgs: string;
cwd?: string;
bridge?: OpenCodeBridgeContext;
})
| 454 | } |
| 455 | |
| 456 | export async function handleCliCommand(input: { |
| 457 | command: string; |
| 458 | client: OpenCodeClient; |
| 459 | sessionId?: string; |
| 460 | rawArgs: string; |
| 461 | cwd?: string; |
| 462 | bridge?: OpenCodeBridgeContext; |
| 463 | }): Promise<void> { |
| 464 | try { |
| 465 | if (input.command === "plannotator-review") { |
| 466 | const result = await runPlannotatorCli({ |
| 467 | client: input.client, |
| 468 | args: ["opencode-review"], |
| 469 | cwd: input.cwd, |
| 470 | input: JSON.stringify({ |
| 471 | arguments: input.rawArgs, |
| 472 | ...buildBridgePayload(input.bridge), |
| 473 | }), |
| 474 | readyLabel: "code review", |
| 475 | bridge: input.bridge, |
| 476 | }); |
| 477 | if (result.exitCode !== 0) { |
| 478 | log(input.client, "error", result.stderr.trim() || `Plannotator CLI exited with code ${result.exitCode}`); |
| 479 | return; |
| 480 | } |
| 481 | |
| 482 | logCliWarnings(input.client, result.stderr); |
| 483 | const outcome = parseLastJson<CliReviewOutcome>(result.stdout); |
| 484 | const prompt = buildReviewPromptFromBridgeOutcome(outcome); |
| 485 | if (prompt.message) { |
| 486 | await injectSessionPrompt(input.client, input.sessionId, prompt.message, { |
| 487 | agent: prompt.agent, |
| 488 | }); |
| 489 | } |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | if (input.command === "plannotator-annotate") { |
| 494 | const parsed = parseAnnotateArgs(input.rawArgs); |
| 495 | if (!parsed.filePath) { |
| 496 | log(input.client, "error", "Usage: /plannotator-annotate <file.md | file.txt | file.html | https://... | folder/> [--markdown] [--no-jina] [--gate] [--json]"); |
| 497 | return; |
| 498 | } |
| 499 | |
| 500 | const result = await runPlannotatorCli({ |
| 501 | client: input.client, |
| 502 | args: buildAnnotateCliArgs(parsed), |
| 503 | cwd: input.cwd, |
| 504 | readyLabel: "annotation UI", |
| 505 | bridge: input.bridge, |
| 506 | }); |
| 507 | if (result.exitCode !== 0) { |
| 508 | log(input.client, "error", result.stderr.trim() || `Plannotator CLI exited with code ${result.exitCode}`); |
| 509 | return; |
| 510 | } |
| 511 | |
| 512 | logCliWarnings(input.client, result.stderr); |
| 513 | const outcome = parseLastJson<CliAnnotateOutcome>(result.stdout); |
no test coverage detected