From 81ba9c7bc9fe52fd65897cbd72e1afec571cdf48 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Tue, 17 Mar 2026 10:57:10 +0530 Subject: [PATCH] plan: fix inconsistencies in npm package plan --- .opencode/plans/1773656570427-mighty-tiger.md | 101 ++++++------------ 1 file changed, 34 insertions(+), 67 deletions(-) diff --git a/.opencode/plans/1773656570427-mighty-tiger.md b/.opencode/plans/1773656570427-mighty-tiger.md index 2108bec..9098c1c 100644 --- a/.opencode/plans/1773656570427-mighty-tiger.md +++ b/.opencode/plans/1773656570427-mighty-tiger.md @@ -226,16 +226,17 @@ export function getBinaryName(context?: { config?: { multiModelBinary?: string } ```typescript // src/core/launch.ts -import type { MultiModelOptions, MultiModelResult } from "../types.js"; +import type { MultiModelOptions, MultiModelResult } from "../types"; import { runCommand, shellQuote, normalizeModels, findDuplicates, createWindowPlans, suggestModels, formatInvalidModelError, sanitizeName, getWorktreePath, undoWorktree, getBinaryName -} from "./utils.js"; +} from "./utils"; export async function launchMultiModel(options: MultiModelOptions): Promise { // Core implementation from current multi-model.ts // All the validation, tmux setup, worktree creation, etc. + const safeSessionName = sanitizeName(options.sessionName); // Returns result with instructions for connecting and cleanup return { @@ -267,8 +268,8 @@ Or manually: ```typescript // src/core/close.ts -import type { CloseSessionOptions, CloseSessionResult } from "../types.ts"; -import { runCommand, getWorktreePath, getWorktreesForSession, sanitizeName } from "./utils.ts"; +import type { CloseSessionOptions, CloseSessionResult } from "../types"; +import { runCommand, getWorktreePath, getWorktreesForSession, sanitizeName } from "./utils"; import * as readline from "readline"; async function promptUser(question: string): Promise { @@ -320,7 +321,7 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise { return { @@ -470,9 +471,8 @@ export const OpenCodeMultiModelPlugin: Plugin = async (ctx) => { }; }; -export default OpenCodeMultiModelPlugin; export { openTool, closeTool }; -export * from "./core/index.ts"; +export * from "./core/index"; ``` ### 10. Create CLI Entry Point (with env support) @@ -481,9 +481,9 @@ export * from "./core/index.ts"; // src/cli.ts #!/usr/bin/env node import { Command } from "commander"; -import { launchMultiModel } from "./core/launch.js"; -import { closeMultiModel } from "./core/close.js"; -import { getBinaryName } from "./core/utils.js"; +import { launchMultiModel } from "./core/launch"; +import { closeMultiModel } from "./core/close"; +import { getBinaryName } from "./core/utils"; const program = new Command(); @@ -527,16 +527,14 @@ program .command("close") .description("Close a multi-model tmux session") .argument("", "Name of the tmux session to close") - .option("-c, --cleanup", "Remove worktrees and delete branches", false) + .option("-c, --cleanup-worktrees", "Remove worktrees and delete branches", true) .option("-f, --force", "Skip confirmation prompts", false) - .option("-k, --keep-branches", "Keep git branches (only remove worktrees)", false) .action(async (sessionName, options) => { try { const result = await closeMultiModel({ sessionName, - cleanup: options.cleanup, + cleanupWorktrees: options.cleanupWorktrees, force: options.force, - keepBranches: options.keepBranches }); if (result.success) { @@ -557,35 +555,6 @@ program } }); -// Default to open command for backwards compatibility -program - .argument("[session-name]", "Name for the tmux session (deprecated, use 'open' command)") - .option("-m, --models ", "Model IDs to launch", []) - .option("-b, --binary ", "Binary to use") - .action(async (sessionName, options) => { - if (!sessionName) { - program.help(); - return; - } - - console.warn("Warning: Direct session name is deprecated. Use 'opencode-multi-model open ' instead."); - - const binaryName = options.binary || getBinaryName(); - - const result = await launchMultiModel({ - sessionName, - models: options.models, - binaryName - }); - - if (result.success) { - console.log(result.instructions); - } else { - console.error(`✗ Failed: ${result.error}`); - process.exit(1); - } - }); - program.parse(); ``` @@ -595,10 +564,10 @@ program.parse(); // .opencode/tools/multi-model.ts // Re-export both open and close tools for project-level use -import { openTool, closeTool } from "../../src/tools/open.js"; +import { openTool } from "../../src/tools/open"; +import { closeTool } from "../../src/tools/close"; export { openTool, closeTool }; -export default openTool; // Default to open for backwards compatibility ``` ### 12. Add Build Configuration @@ -636,7 +605,7 @@ export default openTool; // Default to open for backwards compatibility **Tests**: Copy `.opencode/multi-model.test.ts` to `tests/multi-model.test.ts` and update imports: - Change `import multiModelTool, { __testing_helpers } from "./tools/multi-model"` -- To `import { launchMultiModel, closeMultiModel, runCommand, ... } from "../src/core"` +- To `import { launchMultiModel, closeMultiModel } from "../src/core"` and `import { runCommand, ... } from "../src/core/utils"` The existing tests should work with minimal changes since the core logic remains the same. @@ -679,7 +648,6 @@ opencode-multi-model open my-session -m openai/gpt-4o // .opencode/tools/multi-model.ts import { openTool, closeTool } from "@username/opencode-multi-model" export { openTool, closeTool } -export default openTool ``` ## Usage @@ -695,7 +663,7 @@ sessionName: my-session, models: ["openai/gpt-4o", "anthropic/claude-3-5-sonnet" **Close a session:** ``` Use multi-model-close tool: -sessionName: my-session, cleanup: true +sessionName: my-session, cleanupWorktrees: true ``` ### CLI Usage @@ -719,7 +687,7 @@ opencode-multi-model open my-session -m openai/gpt-4o opencode-multi-model close my-session # Close and cleanup worktrees -opencode-multi-model close my-session --cleanup +opencode-multi-model close my-session --cleanup-worktrees ``` **Help:** @@ -767,13 +735,12 @@ For local development and testing without publishing: ```typescript // .opencode/tools/multi-model.ts -import { openTool, closeTool } from "../../src/tools/open.js" +import { openTool } from "../../src/tools/open" +import { closeTool } from "../../src/tools/close" export { openTool, closeTool } -export default openTool ``` This allows testing the tool without publishing to npm. -``` ## Files to Create/Modify @@ -846,7 +813,7 @@ npm install -g @username/opencode-multi-model opencode-multi-model open compare-session -m openai/gpt-4o anthropic/claude-3-opus google/gemini-pro # Close session with cleanup -opencode-multi-model close compare-session --cleanup +opencode-multi-model close compare-session --cleanup-worktrees ``` ### Developer - Project Tool @@ -854,9 +821,9 @@ opencode-multi-model close compare-session --cleanup ```typescript // .opencode/tools/multi-model.ts // For testing local changes before publishing -import { openTool, closeTool } from "../../src/tools/open.js" +import { openTool } from "../../src/tools/open" +import { closeTool } from "../../src/tools/close" export { openTool, closeTool } -export default openTool ``` This allows testing the tool without publishing to npm.