@iloom/cli 0.7.4 → 0.7.6
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/LICENSE +1 -1
- package/README.md +2 -4
- package/dist/{BranchNamingService-UB2EJGFQ.js → BranchNamingService-AO7BPIUJ.js} +2 -2
- package/dist/{ClaudeContextManager-M57BQUMY.js → ClaudeContextManager-Y2YJC6BU.js} +4 -4
- package/dist/{ClaudeService-FLZ2IXAO.js → ClaudeService-NDVFQRKC.js} +3 -3
- package/dist/{LoomLauncher-5PPVFTFN.js → LoomLauncher-U2B3VHPC.js} +4 -4
- package/dist/{PRManager-YTG6XPMG.js → PRManager-7F3AAY66.js} +4 -4
- package/dist/README.md +2 -4
- package/dist/agents/iloom-issue-analyze-and-plan.md +1 -1
- package/dist/agents/iloom-issue-analyzer.md +1 -1
- package/dist/agents/iloom-issue-complexity-evaluator.md +1 -1
- package/dist/agents/iloom-issue-enhancer.md +1 -1
- package/dist/agents/iloom-issue-implementer.md +1 -1
- package/dist/agents/iloom-issue-planner.md +1 -1
- package/dist/agents/iloom-issue-reviewer.md +1 -1
- package/dist/{chunk-7GKMQJGQ.js → chunk-64HCHVJM.js} +2 -2
- package/dist/{chunk-JWUYPJ7K.js → chunk-6YAMWLCP.js} +3 -3
- package/dist/{chunk-33P5VSKS.js → chunk-C7YW5IMS.js} +2 -2
- package/dist/{chunk-37V2NBYR.js → chunk-CAXFWFV6.js} +2 -2
- package/dist/chunk-CFQVOTHO.js +111 -0
- package/dist/chunk-CFQVOTHO.js.map +1 -0
- package/dist/{chunk-AFRICMSW.js → chunk-ENMTWE74.js} +2 -2
- package/dist/{chunk-RVLRPQU4.js → chunk-ETY2SBW5.js} +21 -18
- package/dist/chunk-ETY2SBW5.js.map +1 -0
- package/dist/{chunk-ITIXKM24.js → chunk-IGKPPACU.js} +2 -2
- package/dist/chunk-IGKPPACU.js.map +1 -0
- package/dist/{chunk-GH4FLYV5.js → chunk-NEPH2O4C.js} +2 -2
- package/dist/{chunk-GJMEKEI5.js → chunk-NPEMVE27.js} +342 -6
- package/dist/chunk-NPEMVE27.js.map +1 -0
- package/dist/{chunk-XAHE76RL.js → chunk-O36JLYNW.js} +2 -2
- package/dist/{chunk-6VQNF44G.js → chunk-Q457PKGH.js} +2 -2
- package/dist/{chunk-7FM7AL7S.js → chunk-VYKKWU36.js} +2 -2
- package/dist/{chunk-EDDIAWVM.js → chunk-WT4UGBE2.js} +8 -7
- package/dist/chunk-WT4UGBE2.js.map +1 -0
- package/dist/{chunk-453NC377.js → chunk-WZYBHD7P.js} +3 -106
- package/dist/chunk-WZYBHD7P.js.map +1 -0
- package/dist/{claude-SNWHWWWM.js → claude-V4HRPR4Z.js} +2 -2
- package/dist/{cleanup-PLMS2KWF.js → cleanup-IO4KV2DL.js} +9 -6
- package/dist/{cleanup-PLMS2KWF.js.map → cleanup-IO4KV2DL.js.map} +1 -1
- package/dist/cli.js +84 -63
- package/dist/cli.js.map +1 -1
- package/dist/{commit-NAGJH4J4.js → commit-3ULFKXNB.js} +4 -4
- package/dist/{dev-server-UKAPBGUR.js → dev-server-OAP3RZC6.js} +4 -3
- package/dist/{dev-server-UKAPBGUR.js.map → dev-server-OAP3RZC6.js.map} +1 -1
- package/dist/{feedback-ICJ44XGB.js → feedback-ZLAX3BVL.js} +3 -3
- package/dist/{ignite-U2JSVOEZ.js → ignite-HA2OJF6Z.js} +20 -36
- package/dist/ignite-HA2OJF6Z.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{init-YDKOPB54.js → init-S6IEGRSX.js} +3 -3
- package/dist/mcp/issue-management-server.js +420 -14
- package/dist/mcp/issue-management-server.js.map +1 -1
- package/dist/{open-QI63XQ4F.js → open-IN3LUZXX.js} +4 -3
- package/dist/{open-QI63XQ4F.js.map → open-IN3LUZXX.js.map} +1 -1
- package/dist/{projects-TWY4RT2Z.js → projects-CTRTTMSK.js} +25 -9
- package/dist/projects-CTRTTMSK.js.map +1 -0
- package/dist/prompts/issue-prompt.txt +16 -0
- package/dist/prompts/pr-prompt.txt +33 -13
- package/dist/prompts/regular-prompt.txt +7 -0
- package/dist/{rebase-AONLKM2V.js → rebase-RLEVFHWN.js} +3 -3
- package/dist/{run-YDVYORT2.js → run-QEIS2EH2.js} +4 -3
- package/dist/{run-YDVYORT2.js.map → run-QEIS2EH2.js.map} +1 -1
- package/dist/{summary-7KYFRAIM.js → summary-MPOOQIOX.js} +38 -7
- package/dist/summary-MPOOQIOX.js.map +1 -0
- package/dist/{test-webserver-NRMGT2HB.js → test-webserver-J6SMNLU2.js} +3 -2
- package/dist/{test-webserver-NRMGT2HB.js.map → test-webserver-J6SMNLU2.js.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-453NC377.js.map +0 -1
- package/dist/chunk-EDDIAWVM.js.map +0 -1
- package/dist/chunk-GJMEKEI5.js.map +0 -1
- package/dist/chunk-ITIXKM24.js.map +0 -1
- package/dist/chunk-RVLRPQU4.js.map +0 -1
- package/dist/ignite-U2JSVOEZ.js.map +0 -1
- package/dist/projects-TWY4RT2Z.js.map +0 -1
- package/dist/summary-7KYFRAIM.js.map +0 -1
- /package/dist/{BranchNamingService-UB2EJGFQ.js.map → BranchNamingService-AO7BPIUJ.js.map} +0 -0
- /package/dist/{ClaudeContextManager-M57BQUMY.js.map → ClaudeContextManager-Y2YJC6BU.js.map} +0 -0
- /package/dist/{ClaudeService-FLZ2IXAO.js.map → ClaudeService-NDVFQRKC.js.map} +0 -0
- /package/dist/{LoomLauncher-5PPVFTFN.js.map → LoomLauncher-U2B3VHPC.js.map} +0 -0
- /package/dist/{PRManager-YTG6XPMG.js.map → PRManager-7F3AAY66.js.map} +0 -0
- /package/dist/{chunk-7GKMQJGQ.js.map → chunk-64HCHVJM.js.map} +0 -0
- /package/dist/{chunk-JWUYPJ7K.js.map → chunk-6YAMWLCP.js.map} +0 -0
- /package/dist/{chunk-33P5VSKS.js.map → chunk-C7YW5IMS.js.map} +0 -0
- /package/dist/{chunk-37V2NBYR.js.map → chunk-CAXFWFV6.js.map} +0 -0
- /package/dist/{chunk-AFRICMSW.js.map → chunk-ENMTWE74.js.map} +0 -0
- /package/dist/{chunk-GH4FLYV5.js.map → chunk-NEPH2O4C.js.map} +0 -0
- /package/dist/{chunk-XAHE76RL.js.map → chunk-O36JLYNW.js.map} +0 -0
- /package/dist/{chunk-6VQNF44G.js.map → chunk-Q457PKGH.js.map} +0 -0
- /package/dist/{chunk-7FM7AL7S.js.map → chunk-VYKKWU36.js.map} +0 -0
- /package/dist/{claude-SNWHWWWM.js.map → claude-V4HRPR4Z.js.map} +0 -0
- /package/dist/{commit-NAGJH4J4.js.map → commit-3ULFKXNB.js.map} +0 -0
- /package/dist/{feedback-ICJ44XGB.js.map → feedback-ZLAX3BVL.js.map} +0 -0
- /package/dist/{init-YDKOPB54.js.map → init-S6IEGRSX.js.map} +0 -0
- /package/dist/{rebase-AONLKM2V.js.map → rebase-RLEVFHWN.js.map} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
DevServerManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ENMTWE74.js";
|
|
5
|
+
import "./chunk-WZYBHD7P.js";
|
|
5
6
|
import {
|
|
6
7
|
getWorkspacePort
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CFQVOTHO.js";
|
|
8
9
|
import {
|
|
9
10
|
IdentifierParser
|
|
10
11
|
} from "./chunk-5V74K5ZA.js";
|
|
@@ -237,4 +238,4 @@ Make sure the project is built (run 'il start' first)`
|
|
|
237
238
|
export {
|
|
238
239
|
OpenCommand
|
|
239
240
|
};
|
|
240
|
-
//# sourceMappingURL=open-
|
|
241
|
+
//# sourceMappingURL=open-IN3LUZXX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/open.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\nimport { execa } from 'execa'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { ProjectCapabilityDetector } from '../lib/ProjectCapabilityDetector.js'\nimport { DevServerManager } from '../lib/DevServerManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\nimport { IdentifierParser } from '../utils/IdentifierParser.js'\nimport { openBrowser } from '../utils/browser.js'\nimport { getWorkspacePort } from '../utils/port.js'\nimport { extractIssueNumber } from '../utils/git.js'\nimport { logger } from '../utils/logger.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport type { GitWorktree } from '../types/worktree.js'\n\nexport interface OpenCommandInput {\n\tidentifier?: string\n\targs?: string[]\n}\n\ninterface ParsedOpenInput {\n\ttype: 'issue' | 'pr' | 'branch'\n\tnumber?: string | number // For issues and PRs\n\tbranchName?: string // For branches\n\toriginalInput: string\n\tautoDetected: boolean\n}\n\n/**\n * OpenCommand - Opens workspace in browser or runs CLI tool\n * Priority: Web first, CLI fallback\n */\nexport class OpenCommand {\n\tconstructor(\n\t\tprivate gitWorktreeManager = new GitWorktreeManager(),\n\t\tprivate capabilityDetector = new ProjectCapabilityDetector(),\n\t\tprivate identifierParser = new IdentifierParser(new GitWorktreeManager()),\n\t\tprivate devServerManager = new DevServerManager(),\n\t\tprivate settingsManager = new SettingsManager()\n\t) {}\n\n\tasync execute(input: OpenCommandInput): Promise<void> {\n\t\t// 1. Parse or auto-detect identifier\n\t\tconst parsed = input.identifier\n\t\t\t? await this.parseExplicitInput(input.identifier)\n\t\t\t: await this.autoDetectFromCurrentDirectory()\n\n\t\tlogger.debug(`Parsed input: ${JSON.stringify(parsed)}`)\n\n\t\t// 2. Find worktree path based on identifier\n\t\tconst worktree = await this.findWorktreeForIdentifier(parsed)\n\n\t\tlogger.info(`Found worktree at: ${worktree.path}`)\n\n\t\t// 3. Detect project capabilities\n\t\tconst { capabilities, binEntries } =\n\t\t\tawait this.capabilityDetector.detectCapabilities(worktree.path)\n\n\t\tlogger.debug(`Detected capabilities: ${capabilities.join(', ')}`)\n\n\t\t// 4. Execute based on capabilities (web first, CLI fallback)\n\t\tif (capabilities.includes('web')) {\n\t\t\tawait this.openWebBrowser(worktree)\n\t\t} else if (capabilities.includes('cli')) {\n\t\t\tawait this.runCLITool(worktree.path, binEntries, input.args ?? [])\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`No web or CLI capabilities detected for workspace at ${worktree.path}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Parse explicit identifier input\n\t */\n\tprivate async parseExplicitInput(identifier: string): Promise<ParsedOpenInput> {\n\t\tconst parsed = await this.identifierParser.parseForPatternDetection(identifier)\n\n\t\t// Description type should never reach open command (converted in start)\n\t\tif (parsed.type === 'description') {\n\t\t\tthrow new Error('Description input type is not supported in open command')\n\t\t}\n\n\t\tconst result: ParsedOpenInput = {\n\t\t\ttype: parsed.type,\n\t\t\toriginalInput: parsed.originalInput,\n\t\t\tautoDetected: false,\n\t\t}\n\n\t\tif (parsed.number !== undefined) {\n\t\t\tresult.number = parsed.number\n\t\t}\n\t\tif (parsed.branchName !== undefined) {\n\t\t\tresult.branchName = parsed.branchName\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Auto-detect identifier from current directory\n\t * Same logic as FinishCommand.autoDetectFromCurrentDirectory()\n\t */\n\tprivate async autoDetectFromCurrentDirectory(): Promise<ParsedOpenInput> {\n\t\tconst currentDir = path.basename(process.cwd())\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\tconst prPattern = /_pr_(\\d+)$/\n\t\tconst prMatch = currentDir.match(prPattern)\n\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tlogger.debug(`Auto-detected PR #${prNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'pr',\n\t\t\t\tnumber: prNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Check for issue pattern in directory\n\t\tconst issueNumber = extractIssueNumber(currentDir)\n\n\t\tif (issueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${issueNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: issueNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Fallback: get current branch name\n\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\tif (!currentBranch) {\n\t\t\tthrow new Error(\n\t\t\t\t'Could not auto-detect identifier. Please provide an issue number, PR number, or branch name.\\n' +\n\t\t\t\t\t'Expected directory pattern: feat/issue-XX-description OR worktree with _pr_N suffix'\n\t\t\t)\n\t\t}\n\n\t\t// Try to extract issue from branch name\n\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\tif (branchIssueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: branchIssueNumber,\n\t\t\t\toriginalInput: currentBranch,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: use branch name\n\t\treturn {\n\t\t\ttype: 'branch',\n\t\t\tbranchName: currentBranch,\n\t\t\toriginalInput: currentBranch,\n\t\t\tautoDetected: true,\n\t\t}\n\t}\n\n\t/**\n\t * Find worktree for the given identifier\n\t */\n\tprivate async findWorktreeForIdentifier(parsed: ParsedOpenInput): Promise<GitWorktree> {\n\t\tlet worktree: GitWorktree | null = null\n\n\t\tif (parsed.type === 'issue' && parsed.number !== undefined) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForIssue(parsed.number)\n\t\t} else if (parsed.type === 'pr' && parsed.number !== undefined) {\n\t\t\t// For PRs, ensure the number is numeric (PRs are always numeric per GitHub)\n\t\t\tconst prNumber = typeof parsed.number === 'number' ? parsed.number : Number(parsed.number)\n\t\t\tif (isNaN(prNumber) || !isFinite(prNumber)) {\n\t\t\t\tthrow new Error(`Invalid PR number: ${parsed.number}. PR numbers must be numeric.`)\n\t\t\t}\n\t\t\t// Pass empty string for branch name since we don't know it yet\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForPR(prNumber, '')\n\t\t} else if (parsed.type === 'branch' && parsed.branchName) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForBranch(\n\t\t\t\tparsed.branchName\n\t\t\t)\n\t\t}\n\n\t\tif (!worktree) {\n\t\t\tthrow new Error(\n\t\t\t\t`No worktree found for ${this.formatParsedInput(parsed)}. ` +\n\t\t\t\t\t`Run 'il start ${parsed.originalInput}' to create one.`\n\t\t\t)\n\t\t}\n\n\t\treturn worktree\n\t}\n\n\t/**\n\t * Format parsed input for display\n\t */\n\tprivate formatParsedInput(parsed: ParsedOpenInput): string {\n\t\tconst autoLabel = parsed.autoDetected ? ' (auto-detected)' : ''\n\n\t\tif (parsed.type === 'issue') {\n\t\t\treturn `issue #${parsed.number}${autoLabel}`\n\t\t}\n\t\tif (parsed.type === 'pr') {\n\t\t\treturn `PR #${parsed.number}${autoLabel}`\n\t\t}\n\t\treturn `branch \"${parsed.branchName}\"${autoLabel}`\n\t}\n\n\t/**\n\t * Open web browser with workspace URL\n\t * Auto-starts dev server if not already running\n\t */\n\tprivate async openWebBrowser(worktree: GitWorktree): Promise<void> {\n\t\tconst cliOverrides = extractSettingsOverrides()\n\t\tconst settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\tconst port = await getWorkspacePort({\n\t\t\tworktreePath: worktree.path,\n\t\t\tworktreeBranch: worktree.branch,\n\t\t\tbasePort: settings.capabilities?.web?.basePort,\n\t\t\tcheckEnvFile: true,\n\t\t})\n\n\t\t// Ensure dev server is running on the port\n\t\tconst serverReady = await this.devServerManager.ensureServerRunning(\n\t\t\tworktree.path,\n\t\t\tport\n\t\t)\n\n\t\tif (!serverReady) {\n\t\t\tlogger.warn(\n\t\t\t\t`Dev server failed to start on port ${port}. Opening browser anyway...`\n\t\t\t)\n\t\t}\n\n\t\t// Construct URL and open browser\n\t\tconst url = `http://localhost:${port}`\n\t\tlogger.info(`Opening browser: ${url}`)\n\t\tawait openBrowser(url)\n\t\tlogger.success('Browser opened')\n\t}\n\n\t/**\n\t * Run CLI tool directly from worktree bin path (NO SYMLINKS!)\n\t */\n\tprivate async runCLITool(\n\t\tworktreePath: string,\n\t\tbinEntries: Record<string, string>,\n\t\targs: string[]\n\t): Promise<void> {\n\t\t// Validate binEntries exist\n\t\tif (Object.keys(binEntries).length === 0) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\n\t\t// Get first bin entry (deterministic)\n\t\tconst firstEntry = Object.entries(binEntries)[0]\n\t\tif (!firstEntry) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\t\tconst [binName, binPath] = firstEntry\n\t\tlogger.debug(`Using bin entry: ${binName} -> ${binPath}`)\n\n\t\t// CRITICAL: Construct absolute path (NO SYMLINKS!)\n\t\tconst binFilePath = path.resolve(worktreePath, binPath)\n\t\tlogger.debug(`Resolved bin file path: ${binFilePath}`)\n\n\t\t// Verify file exists\n\t\tif (!(await fs.pathExists(binFilePath))) {\n\t\t\tthrow new Error(\n\t\t\t\t`CLI executable not found: ${binFilePath}\\n` +\n\t\t\t\t\t`Make sure the project is built (run 'il start' first)`\n\t\t\t)\n\t\t}\n\n\t\t// Execute with Node.js\n\t\tlogger.info(`Running CLI: node ${binFilePath} ${args.join(' ')}`)\n\t\tawait execa('node', [binFilePath, ...args], {\n\t\t\tstdio: 'inherit', // Allow interactive CLIs (prompts, colors, etc.)\n\t\t\tcwd: worktreePath, // Execute in worktree context\n\t\t\tenv: process.env, // Inherit environment\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,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K,QAAQ;AAAA;AAAA,IACd,CAAC;AAAA,EACF;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/commands/open.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\nimport { execa } from 'execa'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { ProjectCapabilityDetector } from '../lib/ProjectCapabilityDetector.js'\nimport { DevServerManager } from '../lib/DevServerManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\nimport { IdentifierParser } from '../utils/IdentifierParser.js'\nimport { openBrowser } from '../utils/browser.js'\nimport { getWorkspacePort } from '../utils/port.js'\nimport { extractIssueNumber } from '../utils/git.js'\nimport { logger } from '../utils/logger.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport type { GitWorktree } from '../types/worktree.js'\n\nexport interface OpenCommandInput {\n\tidentifier?: string\n\targs?: string[]\n}\n\ninterface ParsedOpenInput {\n\ttype: 'issue' | 'pr' | 'branch'\n\tnumber?: string | number // For issues and PRs\n\tbranchName?: string // For branches\n\toriginalInput: string\n\tautoDetected: boolean\n}\n\n/**\n * OpenCommand - Opens workspace in browser or runs CLI tool\n * Priority: Web first, CLI fallback\n */\nexport class OpenCommand {\n\tconstructor(\n\t\tprivate gitWorktreeManager = new GitWorktreeManager(),\n\t\tprivate capabilityDetector = new ProjectCapabilityDetector(),\n\t\tprivate identifierParser = new IdentifierParser(new GitWorktreeManager()),\n\t\tprivate devServerManager = new DevServerManager(),\n\t\tprivate settingsManager = new SettingsManager()\n\t) {}\n\n\tasync execute(input: OpenCommandInput): Promise<void> {\n\t\t// 1. Parse or auto-detect identifier\n\t\tconst parsed = input.identifier\n\t\t\t? await this.parseExplicitInput(input.identifier)\n\t\t\t: await this.autoDetectFromCurrentDirectory()\n\n\t\tlogger.debug(`Parsed input: ${JSON.stringify(parsed)}`)\n\n\t\t// 2. Find worktree path based on identifier\n\t\tconst worktree = await this.findWorktreeForIdentifier(parsed)\n\n\t\tlogger.info(`Found worktree at: ${worktree.path}`)\n\n\t\t// 3. Detect project capabilities\n\t\tconst { capabilities, binEntries } =\n\t\t\tawait this.capabilityDetector.detectCapabilities(worktree.path)\n\n\t\tlogger.debug(`Detected capabilities: ${capabilities.join(', ')}`)\n\n\t\t// 4. Execute based on capabilities (web first, CLI fallback)\n\t\tif (capabilities.includes('web')) {\n\t\t\tawait this.openWebBrowser(worktree)\n\t\t} else if (capabilities.includes('cli')) {\n\t\t\tawait this.runCLITool(worktree.path, binEntries, input.args ?? [])\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`No web or CLI capabilities detected for workspace at ${worktree.path}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Parse explicit identifier input\n\t */\n\tprivate async parseExplicitInput(identifier: string): Promise<ParsedOpenInput> {\n\t\tconst parsed = await this.identifierParser.parseForPatternDetection(identifier)\n\n\t\t// Description type should never reach open command (converted in start)\n\t\tif (parsed.type === 'description') {\n\t\t\tthrow new Error('Description input type is not supported in open command')\n\t\t}\n\n\t\tconst result: ParsedOpenInput = {\n\t\t\ttype: parsed.type,\n\t\t\toriginalInput: parsed.originalInput,\n\t\t\tautoDetected: false,\n\t\t}\n\n\t\tif (parsed.number !== undefined) {\n\t\t\tresult.number = parsed.number\n\t\t}\n\t\tif (parsed.branchName !== undefined) {\n\t\t\tresult.branchName = parsed.branchName\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Auto-detect identifier from current directory\n\t * Same logic as FinishCommand.autoDetectFromCurrentDirectory()\n\t */\n\tprivate async autoDetectFromCurrentDirectory(): Promise<ParsedOpenInput> {\n\t\tconst currentDir = path.basename(process.cwd())\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\tconst prPattern = /_pr_(\\d+)$/\n\t\tconst prMatch = currentDir.match(prPattern)\n\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tlogger.debug(`Auto-detected PR #${prNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'pr',\n\t\t\t\tnumber: prNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Check for issue pattern in directory\n\t\tconst issueNumber = extractIssueNumber(currentDir)\n\n\t\tif (issueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${issueNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: issueNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Fallback: get current branch name\n\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\tif (!currentBranch) {\n\t\t\tthrow new Error(\n\t\t\t\t'Could not auto-detect identifier. Please provide an issue number, PR number, or branch name.\\n' +\n\t\t\t\t\t'Expected directory pattern: feat/issue-XX-description OR worktree with _pr_N suffix'\n\t\t\t)\n\t\t}\n\n\t\t// Try to extract issue from branch name\n\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\tif (branchIssueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: branchIssueNumber,\n\t\t\t\toriginalInput: currentBranch,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: use branch name\n\t\treturn {\n\t\t\ttype: 'branch',\n\t\t\tbranchName: currentBranch,\n\t\t\toriginalInput: currentBranch,\n\t\t\tautoDetected: true,\n\t\t}\n\t}\n\n\t/**\n\t * Find worktree for the given identifier\n\t */\n\tprivate async findWorktreeForIdentifier(parsed: ParsedOpenInput): Promise<GitWorktree> {\n\t\tlet worktree: GitWorktree | null = null\n\n\t\tif (parsed.type === 'issue' && parsed.number !== undefined) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForIssue(parsed.number)\n\t\t} else if (parsed.type === 'pr' && parsed.number !== undefined) {\n\t\t\t// For PRs, ensure the number is numeric (PRs are always numeric per GitHub)\n\t\t\tconst prNumber = typeof parsed.number === 'number' ? parsed.number : Number(parsed.number)\n\t\t\tif (isNaN(prNumber) || !isFinite(prNumber)) {\n\t\t\t\tthrow new Error(`Invalid PR number: ${parsed.number}. PR numbers must be numeric.`)\n\t\t\t}\n\t\t\t// Pass empty string for branch name since we don't know it yet\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForPR(prNumber, '')\n\t\t} else if (parsed.type === 'branch' && parsed.branchName) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForBranch(\n\t\t\t\tparsed.branchName\n\t\t\t)\n\t\t}\n\n\t\tif (!worktree) {\n\t\t\tthrow new Error(\n\t\t\t\t`No worktree found for ${this.formatParsedInput(parsed)}. ` +\n\t\t\t\t\t`Run 'il start ${parsed.originalInput}' to create one.`\n\t\t\t)\n\t\t}\n\n\t\treturn worktree\n\t}\n\n\t/**\n\t * Format parsed input for display\n\t */\n\tprivate formatParsedInput(parsed: ParsedOpenInput): string {\n\t\tconst autoLabel = parsed.autoDetected ? ' (auto-detected)' : ''\n\n\t\tif (parsed.type === 'issue') {\n\t\t\treturn `issue #${parsed.number}${autoLabel}`\n\t\t}\n\t\tif (parsed.type === 'pr') {\n\t\t\treturn `PR #${parsed.number}${autoLabel}`\n\t\t}\n\t\treturn `branch \"${parsed.branchName}\"${autoLabel}`\n\t}\n\n\t/**\n\t * Open web browser with workspace URL\n\t * Auto-starts dev server if not already running\n\t */\n\tprivate async openWebBrowser(worktree: GitWorktree): Promise<void> {\n\t\tconst cliOverrides = extractSettingsOverrides()\n\t\tconst settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\tconst port = await getWorkspacePort({\n\t\t\tworktreePath: worktree.path,\n\t\t\tworktreeBranch: worktree.branch,\n\t\t\tbasePort: settings.capabilities?.web?.basePort,\n\t\t\tcheckEnvFile: true,\n\t\t})\n\n\t\t// Ensure dev server is running on the port\n\t\tconst serverReady = await this.devServerManager.ensureServerRunning(\n\t\t\tworktree.path,\n\t\t\tport\n\t\t)\n\n\t\tif (!serverReady) {\n\t\t\tlogger.warn(\n\t\t\t\t`Dev server failed to start on port ${port}. Opening browser anyway...`\n\t\t\t)\n\t\t}\n\n\t\t// Construct URL and open browser\n\t\tconst url = `http://localhost:${port}`\n\t\tlogger.info(`Opening browser: ${url}`)\n\t\tawait openBrowser(url)\n\t\tlogger.success('Browser opened')\n\t}\n\n\t/**\n\t * Run CLI tool directly from worktree bin path (NO SYMLINKS!)\n\t */\n\tprivate async runCLITool(\n\t\tworktreePath: string,\n\t\tbinEntries: Record<string, string>,\n\t\targs: string[]\n\t): Promise<void> {\n\t\t// Validate binEntries exist\n\t\tif (Object.keys(binEntries).length === 0) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\n\t\t// Get first bin entry (deterministic)\n\t\tconst firstEntry = Object.entries(binEntries)[0]\n\t\tif (!firstEntry) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\t\tconst [binName, binPath] = firstEntry\n\t\tlogger.debug(`Using bin entry: ${binName} -> ${binPath}`)\n\n\t\t// CRITICAL: Construct absolute path (NO SYMLINKS!)\n\t\tconst binFilePath = path.resolve(worktreePath, binPath)\n\t\tlogger.debug(`Resolved bin file path: ${binFilePath}`)\n\n\t\t// Verify file exists\n\t\tif (!(await fs.pathExists(binFilePath))) {\n\t\t\tthrow new Error(\n\t\t\t\t`CLI executable not found: ${binFilePath}\\n` +\n\t\t\t\t\t`Make sure the project is built (run 'il start' first)`\n\t\t\t)\n\t\t}\n\n\t\t// Execute with Node.js\n\t\tlogger.info(`Running CLI: node ${binFilePath} ${args.join(' ')}`)\n\t\tawait execa('node', [binFilePath, ...args], {\n\t\t\tstdio: 'inherit', // Allow interactive CLIs (prompts, colors, etc.)\n\t\t\tcwd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C,EAAE;AAChE,UAAM,MAAM,QAAQ,CAAC,aAAa,GAAG,IAAI,GAAG;AAAA,MAC3C,OAAO;AAAA;AAAA,MACP,KAAK;AAAA;AAAA,MACL,KAAK,QAAQ;AAAA;AAAA,IACd,CAAC;AAAA,EACF;AACD;","names":[]}
|
|
@@ -12,12 +12,30 @@ import {
|
|
|
12
12
|
import "./chunk-VT4PDUYT.js";
|
|
13
13
|
|
|
14
14
|
// src/commands/projects.ts
|
|
15
|
-
import
|
|
15
|
+
import path2 from "path";
|
|
16
16
|
import os from "os";
|
|
17
17
|
import fs from "fs-extra";
|
|
18
|
+
|
|
19
|
+
// src/utils/xplat-utils.ts
|
|
20
|
+
import path from "path";
|
|
21
|
+
function normalizePath(inputPath) {
|
|
22
|
+
const normalized = path.normalize(inputPath);
|
|
23
|
+
if (process.platform === "win32") {
|
|
24
|
+
return normalized.replace(/\\/g, "/").toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
function pathsEqual(path1, path22) {
|
|
29
|
+
if (path1 == null || path22 == null) {
|
|
30
|
+
return path1 === path22;
|
|
31
|
+
}
|
|
32
|
+
return normalizePath(path1) === normalizePath(path22);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/commands/projects.ts
|
|
18
36
|
var ProjectsCommand = class {
|
|
19
37
|
constructor(metadataManager, capabilityDetector) {
|
|
20
|
-
this.projectsDir =
|
|
38
|
+
this.projectsDir = path2.join(os.homedir(), ".config", "iloom-ai", "projects");
|
|
21
39
|
this.metadataManager = metadataManager ?? new MetadataManager();
|
|
22
40
|
this.capabilityDetector = capabilityDetector ?? new ProjectCapabilityDetector();
|
|
23
41
|
}
|
|
@@ -38,7 +56,7 @@ var ProjectsCommand = class {
|
|
|
38
56
|
for (const file of files) {
|
|
39
57
|
if (file.startsWith(".")) continue;
|
|
40
58
|
try {
|
|
41
|
-
const filePath =
|
|
59
|
+
const filePath = path2.join(this.projectsDir, file);
|
|
42
60
|
const content = await fs.readFile(filePath, "utf8");
|
|
43
61
|
const marker = JSON.parse(content);
|
|
44
62
|
if (!marker.projectPath || !marker.projectName) continue;
|
|
@@ -63,17 +81,15 @@ var ProjectsCommand = class {
|
|
|
63
81
|
}
|
|
64
82
|
/**
|
|
65
83
|
* Count active looms for a project
|
|
66
|
-
*
|
|
67
|
-
* or if they share the same parent directory as the project.
|
|
84
|
+
* Uses the metadata's projectPath field to determine project membership.
|
|
68
85
|
* Only counts looms where the worktree is a valid git worktree (.git exists).
|
|
69
86
|
*/
|
|
70
87
|
async countActiveLooms(projectPath, allMetadata) {
|
|
71
88
|
let count = 0;
|
|
72
89
|
for (const meta of allMetadata) {
|
|
73
90
|
if (!meta.worktreePath) continue;
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const isValidWorktree = await fs.pathExists(path.join(meta.worktreePath, ".git"));
|
|
91
|
+
const isProjectLoom = pathsEqual(meta.projectPath, projectPath);
|
|
92
|
+
const isValidWorktree = await fs.pathExists(path2.join(meta.worktreePath, ".git"));
|
|
77
93
|
if (isProjectLoom && isValidWorktree) {
|
|
78
94
|
count++;
|
|
79
95
|
}
|
|
@@ -84,4 +100,4 @@ var ProjectsCommand = class {
|
|
|
84
100
|
export {
|
|
85
101
|
ProjectsCommand
|
|
86
102
|
};
|
|
87
|
-
//# sourceMappingURL=projects-
|
|
103
|
+
//# sourceMappingURL=projects-CTRTTMSK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/projects.ts","../src/utils/xplat-utils.ts"],"sourcesContent":["import path from 'path'\nimport os from 'os'\nimport fs from 'fs-extra'\nimport { getLogger } from '../utils/logger-context.js'\nimport { pathsEqual } from '../utils/xplat-utils.js'\nimport { MetadataManager, type LoomMetadata } from '../lib/MetadataManager.js'\nimport { ProjectCapabilityDetector } from '../lib/ProjectCapabilityDetector.js'\nimport type { ProjectCapability } from '../types/loom.js'\n\n/**\n * Project marker file structure (from FirstRunManager)\n */\ninterface ProjectMarker {\n configuredAt: string\n projectPath: string\n projectName: string\n}\n\n/**\n * Output schema for project\n */\nexport interface ProjectOutput {\n configuredAt: string\n projectPath: string\n projectName: string\n activeLooms: number\n capabilities: ProjectCapability[]\n}\n\n/**\n * ProjectsCommand: List configured iloom projects\n *\n * Returns JSON array of configured projects from ~/.config/iloom-ai/projects/\n * Only includes projects where the directory still exists.\n * Each project includes an activeLooms count.\n */\nexport class ProjectsCommand {\n private readonly projectsDir: string\n private readonly metadataManager: MetadataManager\n private readonly capabilityDetector: ProjectCapabilityDetector\n\n constructor(metadataManager?: MetadataManager, capabilityDetector?: ProjectCapabilityDetector) {\n this.projectsDir = path.join(os.homedir(), '.config', 'iloom-ai', 'projects')\n this.metadataManager = metadataManager ?? new MetadataManager()\n this.capabilityDetector = capabilityDetector ?? new ProjectCapabilityDetector()\n }\n\n /**\n * Execute the projects command\n * @param _options - Options object (json flag accepted but ignored - always returns JSON)\n * @returns Array of project outputs\n */\n async execute(_options?: { json?: boolean }): Promise<ProjectOutput[]> {\n // Options.json is accepted but ignored - always returns structured data\n const results: ProjectOutput[] = []\n const logger = getLogger()\n\n try {\n // Check if projects directory exists\n if (!(await fs.pathExists(this.projectsDir))) {\n return results\n }\n\n // Read all files in projects directory\n const files = await fs.readdir(this.projectsDir)\n\n // Get all loom metadata for active looms lookup\n const allMetadata = await this.metadataManager.listAllMetadata()\n\n for (const file of files) {\n // Skip hidden files (like .DS_Store)\n if (file.startsWith('.')) continue\n\n try {\n const filePath = path.join(this.projectsDir, file)\n const content = await fs.readFile(filePath, 'utf8')\n const marker: ProjectMarker = JSON.parse(content)\n\n // Skip if required fields missing\n if (!marker.projectPath || !marker.projectName) continue\n\n // Filter: only include if directory exists\n if (!(await fs.pathExists(marker.projectPath))) continue\n\n // Count active looms for this project\n const activeLooms = await this.countActiveLooms(marker.projectPath, allMetadata)\n\n // Detect project capabilities\n const { capabilities } = await this.capabilityDetector.detectCapabilities(marker.projectPath)\n\n results.push({\n configuredAt: marker.configuredAt,\n projectPath: marker.projectPath,\n projectName: marker.projectName,\n activeLooms,\n capabilities,\n })\n } catch {\n // Skip invalid files (graceful degradation)\n logger.debug(`Skipping invalid project file: ${file}`)\n }\n }\n } catch (error) {\n // Graceful degradation on read errors\n logger.debug(`Failed to list projects: ${error instanceof Error ? error.message : 'Unknown'}`)\n }\n\n return results\n }\n\n /**\n * Count active looms for a project\n * Uses the metadata's projectPath field to determine project membership.\n * Only counts looms where the worktree is a valid git worktree (.git exists).\n */\n private async countActiveLooms(projectPath: string, allMetadata: LoomMetadata[]): Promise<number> {\n let count = 0\n for (const meta of allMetadata) {\n if (!meta.worktreePath) continue\n // Use metadata's projectPath field for accurate project membership (with cross-platform normalization)\n const isProjectLoom = pathsEqual(meta.projectPath, projectPath)\n // Check for .git (file for worktrees, directory for main repo) to verify it's a valid git worktree\n const isValidWorktree = await fs.pathExists(path.join(meta.worktreePath, '.git'))\n if (isProjectLoom && isValidWorktree) {\n count++\n }\n }\n return count\n }\n}\n","import path from 'path'\n\n/**\n * Normalize a path for cross-platform comparison.\n *\n * On Windows:\n * - Converts backslashes to forward slashes\n * - Lowercases the path (Windows paths are case-insensitive)\n *\n * On Unix:\n * - Normalizes path separators via path.normalize()\n *\n * Use this when comparing paths that may come from different sources\n * (e.g., metadata files, filesystem, user input).\n */\nexport function normalizePath(inputPath: string): string {\n // First normalize using Node's path module (handles . and .. and duplicate separators)\n const normalized = path.normalize(inputPath)\n\n if (process.platform === 'win32') {\n // Windows: convert backslashes to forward slashes and lowercase\n return normalized.replace(/\\\\/g, '/').toLowerCase()\n }\n\n return normalized\n}\n\n/**\n * Compare two paths for equality, handling cross-platform differences.\n */\nexport function pathsEqual(path1: string | null | undefined, path2: string | null | undefined): boolean {\n if (path1 == null || path2 == null) {\n return path1 === path2\n }\n return normalizePath(path1) === normalizePath(path2)\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,WAAU;AACjB,OAAO,QAAQ;AACf,OAAO,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AM,KAAK,iBAAiB,OAAO,aAAa,WAAW;AAG/E,gBAAM,EAAE,aAAa,IAAI,MAAM,KAAK,mBAAmB,mBAAmB,OAAO,WAAW;AAE5F,kBAAQ,KAAK;AAAA,YACX,cAAc,OAAO;AAAA,YACrB,aAAa,OAAO;AAAA,YACpB,aAAa,OAAO;AAAA,YACpB;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH,QAAQ;AAEN,iBAAO,MAAM,kCAAkC,IAAI,EAAE;AAAA,QACvD;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AAEd,aAAO,MAAM,4BAA4B,iBAAiB,QAAQ,MAAM,UAAU,SAAS,EAAE;AAAA,IAC/F;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAc,iBAAiB,aAAqB,aAA8C;AAChG,QAAI,QAAQ;AACZ,eAAW,QAAQ,aAAa;AAC9B,UAAI,CAAC,KAAK,aAAc;AAExB,YAAM,gBAAgB,WAAW,KAAK,aAAa,WAAW;AAE9D,YAAM,kBAAkB,MAAM,GAAG,WAAWA,MAAK,KAAK,KAAK,cAAc,MAAM,CAAC;AAChF,UAAI,iBAAiB,iBAAiB;AACpC;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["path","path2","path"]}
|
|
@@ -20,6 +20,13 @@ Before sending any response, verify it doesn't contain:
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
{{#if PORT}}
|
|
24
|
+
<additional_env>
|
|
25
|
+
Dev Server Port: {{PORT}}
|
|
26
|
+
If you need to access the web server for testing purposes, use localhost:{{PORT}}
|
|
27
|
+
</additional_env>
|
|
28
|
+
{{/if}}
|
|
29
|
+
|
|
23
30
|
## Loom Recap
|
|
24
31
|
|
|
25
32
|
**IMPORTANT: The recap is NOT a work log. It's a knowledge capture system for the USER.**
|
|
@@ -53,8 +60,17 @@ Use these Recap MCP tools:
|
|
|
53
60
|
**IMPORTANT: This loom is using draft PR mode.**
|
|
54
61
|
|
|
55
62
|
- **Read issue details** from Issue #{{ISSUE_NUMBER}} using `mcp__issue_management__get_issue`
|
|
63
|
+
- **Read draft PR details** from PR #{{DRAFT_PR_NUMBER}} using `mcp__issue_management__get_pr`
|
|
56
64
|
- **Write ALL workflow comments** to PR #{{DRAFT_PR_NUMBER}} using `type: "pr"`
|
|
57
65
|
|
|
66
|
+
When calling `mcp__issue_management__get_pr` to read the draft PR:
|
|
67
|
+
```
|
|
68
|
+
{
|
|
69
|
+
number: "{{DRAFT_PR_NUMBER}}",
|
|
70
|
+
includeComments: true
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
58
74
|
When calling `mcp__issue_management__create_comment`:
|
|
59
75
|
```
|
|
60
76
|
{
|
|
@@ -20,6 +20,13 @@ Before sending any response, verify it doesn't contain:
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
{{#if PORT}}
|
|
24
|
+
<additional_env>
|
|
25
|
+
Dev Server Port: {{PORT}}
|
|
26
|
+
If you need to access the web server for testing purposes, use localhost:{{PORT}}
|
|
27
|
+
</additional_env>
|
|
28
|
+
{{/if}}
|
|
29
|
+
|
|
23
30
|
## Loom Recap
|
|
24
31
|
|
|
25
32
|
**IMPORTANT: The recap is NOT a work log. It's a knowledge capture system for the USER.**
|
|
@@ -46,19 +53,37 @@ Use these Recap MCP tools:
|
|
|
46
53
|
|
|
47
54
|
---
|
|
48
55
|
|
|
56
|
+
## Comment Routing: PR Mode
|
|
57
|
+
|
|
58
|
+
- **Read PR details** using `mcp__issue_management__get_pr` with `{ number: "{{PR_NUMBER}}", includeComments: true }`
|
|
59
|
+
- **Write comments** to PR #{{PR_NUMBER}} using `type: "pr"`
|
|
60
|
+
|
|
61
|
+
When calling `mcp__issue_management__create_comment`:
|
|
62
|
+
```
|
|
63
|
+
{
|
|
64
|
+
number: "{{PR_NUMBER}}",
|
|
65
|
+
body: "your comment content",
|
|
66
|
+
type: "pr"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
This ensures PR comments always go to GitHub regardless of the configured issue tracker.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
49
74
|
You are a senior software engineer responsible for well-architected, easy to maintain and understandable code.
|
|
50
75
|
|
|
51
|
-
Please read the Pull Request and all its details using
|
|
52
|
-
|
|
76
|
+
Please read the Pull Request and all its details using the MCP tool:
|
|
77
|
+
`mcp__issue_management__get_pr` with `{ number: "{{PR_NUMBER}}", includeComments: true }`
|
|
53
78
|
|
|
54
|
-
This
|
|
55
|
-
- PR title and description
|
|
79
|
+
This will give you:
|
|
80
|
+
- PR title and description (body)
|
|
56
81
|
- All comments and discussion
|
|
57
|
-
- Commit history and changed files
|
|
58
|
-
- Current state and metadata
|
|
82
|
+
- Commit history (commits) and changed files (files)
|
|
83
|
+
- Current state and branch metadata (headRefName, baseRefName)
|
|
59
84
|
|
|
60
85
|
Also check if the branch name contains an issue number (like issue-123) and if so, read that issue for context:
|
|
61
|
-
|
|
86
|
+
`mcp__issue_management__get_issue` with `{ number: "{{ISSUE_NUMBER}}", includeComments: true }`
|
|
62
87
|
|
|
63
88
|
Since this is an existing PR, the issue may be partially addressed or in an unknown state.
|
|
64
89
|
|
|
@@ -69,12 +94,7 @@ When working with libraries, frameworks, or APIs that you need documentation for
|
|
|
69
94
|
- Working with unfamiliar APIs
|
|
70
95
|
- When you need current documentation that may have changed since your training data
|
|
71
96
|
|
|
72
|
-
After reading both the PR and any referenced issue,
|
|
73
|
-
1. Check if dev server is already running: "lsof -i :{{PORT}}"
|
|
74
|
-
2. If not running, start it: pnpm dev (the PORT environment variable is already set)
|
|
75
|
-
3. If running, you can optionally restart it if your changes require it
|
|
76
|
-
|
|
77
|
-
Then wait for the user to provide guidance on what they would like you to work on next.
|
|
97
|
+
After reading both the PR and any referenced issue, wait for the user to provide guidance on what they would like you to work on next.
|
|
78
98
|
|
|
79
99
|
Remember to:
|
|
80
100
|
- Follow the project's coding conventions and patterns
|
|
@@ -20,6 +20,13 @@ Before sending any response, verify it doesn't contain:
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
{{#if PORT}}
|
|
24
|
+
<additional_env>
|
|
25
|
+
Dev Server Port: {{PORT}}
|
|
26
|
+
If you need to access the web server for testing purposes, use localhost:{{PORT}}
|
|
27
|
+
</additional_env>
|
|
28
|
+
{{/if}}
|
|
29
|
+
|
|
23
30
|
## Loom Recap
|
|
24
31
|
|
|
25
32
|
**IMPORTANT: The recap is NOT a work log. It's a knowledge capture system for the USER.**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BuildRunner,
|
|
4
4
|
MergeManager
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CAXFWFV6.js";
|
|
6
6
|
import "./chunk-7GLZVDPQ.js";
|
|
7
7
|
import {
|
|
8
8
|
installDependencies
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
SettingsManager
|
|
20
20
|
} from "./chunk-WFQ5CLTR.js";
|
|
21
21
|
import "./chunk-VWGKGNJP.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-IGKPPACU.js";
|
|
23
23
|
import "./chunk-6MLEBAYZ.js";
|
|
24
24
|
import {
|
|
25
25
|
logger
|
|
@@ -139,4 +139,4 @@ export {
|
|
|
139
139
|
RebaseCommand,
|
|
140
140
|
WorktreeValidationError
|
|
141
141
|
};
|
|
142
|
-
//# sourceMappingURL=rebase-
|
|
142
|
+
//# sourceMappingURL=rebase-RLEVFHWN.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
DevServerManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ENMTWE74.js";
|
|
5
|
+
import "./chunk-WZYBHD7P.js";
|
|
5
6
|
import {
|
|
6
7
|
getWorkspacePort
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-CFQVOTHO.js";
|
|
8
9
|
import {
|
|
9
10
|
IdentifierParser
|
|
10
11
|
} from "./chunk-5V74K5ZA.js";
|
|
@@ -237,4 +238,4 @@ Make sure the project is built (run 'il start' first)`
|
|
|
237
238
|
export {
|
|
238
239
|
RunCommand
|
|
239
240
|
};
|
|
240
|
-
//# sourceMappingURL=run-
|
|
241
|
+
//# sourceMappingURL=run-QEIS2EH2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/run.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\nimport { execa } from 'execa'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { ProjectCapabilityDetector } from '../lib/ProjectCapabilityDetector.js'\nimport { DevServerManager } from '../lib/DevServerManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\nimport { IdentifierParser } from '../utils/IdentifierParser.js'\nimport { openBrowser } from '../utils/browser.js'\nimport { getWorkspacePort } from '../utils/port.js'\nimport { extractIssueNumber } from '../utils/git.js'\nimport { logger } from '../utils/logger.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport type { GitWorktree } from '../types/worktree.js'\n\nexport interface RunCommandInput {\n\tidentifier?: string\n\targs?: string[]\n}\n\ninterface ParsedRunInput {\n\ttype: 'issue' | 'pr' | 'branch'\n\tnumber?: string | number // For issues and PRs\n\tbranchName?: string // For branches\n\toriginalInput: string\n\tautoDetected: boolean\n}\n\n/**\n * RunCommand - Runs CLI tool or opens workspace in browser\n * Priority: CLI first, Web fallback\n */\nexport class RunCommand {\n\tconstructor(\n\t\tprivate gitWorktreeManager = new GitWorktreeManager(),\n\t\tprivate capabilityDetector = new ProjectCapabilityDetector(),\n\t\tprivate identifierParser = new IdentifierParser(new GitWorktreeManager()),\n\t\tprivate devServerManager = new DevServerManager(),\n\t\tprivate settingsManager = new SettingsManager()\n\t) {}\n\n\tasync execute(input: RunCommandInput): Promise<void> {\n\t\t// 1. Parse or auto-detect identifier\n\t\tconst parsed = input.identifier\n\t\t\t? await this.parseExplicitInput(input.identifier)\n\t\t\t: await this.autoDetectFromCurrentDirectory()\n\n\t\tlogger.debug(`Parsed input: ${JSON.stringify(parsed)}`)\n\n\t\t// 2. Find worktree path based on identifier\n\t\tconst worktree = await this.findWorktreeForIdentifier(parsed)\n\n\t\tlogger.info(`Found worktree at: ${worktree.path}`)\n\n\t\t// 3. Detect project capabilities\n\t\tconst { capabilities, binEntries } =\n\t\t\tawait this.capabilityDetector.detectCapabilities(worktree.path)\n\n\t\tlogger.debug(`Detected capabilities: ${capabilities.join(', ')}`)\n\n\t\t// 4. Execute based on capabilities (CLI first, web fallback)\n\t\tif (capabilities.includes('cli')) {\n\t\t\tawait this.runCLITool(worktree.path, binEntries, input.args ?? [])\n\t\t} else if (capabilities.includes('web')) {\n\t\t\tawait this.openWebBrowser(worktree)\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`No CLI or web capabilities detected for workspace at ${worktree.path}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Parse explicit identifier input\n\t */\n\tprivate async parseExplicitInput(identifier: string): Promise<ParsedRunInput> {\n\t\tconst parsed = await this.identifierParser.parseForPatternDetection(identifier)\n\n\t\t// Description type should never reach run command (converted in start)\n\t\tif (parsed.type === 'description') {\n\t\t\tthrow new Error('Description input type is not supported in run command')\n\t\t}\n\n\t\tconst result: ParsedRunInput = {\n\t\t\ttype: parsed.type,\n\t\t\toriginalInput: parsed.originalInput,\n\t\t\tautoDetected: false,\n\t\t}\n\n\t\tif (parsed.number !== undefined) {\n\t\t\tresult.number = parsed.number\n\t\t}\n\t\tif (parsed.branchName !== undefined) {\n\t\t\tresult.branchName = parsed.branchName\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Auto-detect identifier from current directory\n\t * Same logic as FinishCommand.autoDetectFromCurrentDirectory()\n\t */\n\tprivate async autoDetectFromCurrentDirectory(): Promise<ParsedRunInput> {\n\t\tconst currentDir = path.basename(process.cwd())\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\tconst prPattern = /_pr_(\\d+)$/\n\t\tconst prMatch = currentDir.match(prPattern)\n\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tlogger.debug(`Auto-detected PR #${prNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'pr',\n\t\t\t\tnumber: prNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Check for issue pattern in directory\n\t\tconst issueNumber = extractIssueNumber(currentDir)\n\n\t\tif (issueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${issueNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: issueNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Fallback: get current branch name\n\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\tif (!currentBranch) {\n\t\t\tthrow new Error(\n\t\t\t\t'Could not auto-detect identifier. Please provide an issue number, PR number, or branch name.\\n' +\n\t\t\t\t\t'Expected directory pattern: feat/issue-XX-description OR worktree with _pr_N suffix'\n\t\t\t)\n\t\t}\n\n\t\t// Try to extract issue from branch name\n\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\tif (branchIssueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: branchIssueNumber,\n\t\t\t\toriginalInput: currentBranch,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: use branch name\n\t\treturn {\n\t\t\ttype: 'branch',\n\t\t\tbranchName: currentBranch,\n\t\t\toriginalInput: currentBranch,\n\t\t\tautoDetected: true,\n\t\t}\n\t}\n\n\t/**\n\t * Find worktree for the given identifier\n\t */\n\tprivate async findWorktreeForIdentifier(parsed: ParsedRunInput): Promise<GitWorktree> {\n\t\tlet worktree: GitWorktree | null = null\n\n\t\tif (parsed.type === 'issue' && parsed.number !== undefined) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForIssue(parsed.number)\n\t\t} else if (parsed.type === 'pr' && parsed.number !== undefined) {\n\t\t\t// For PRs, ensure the number is numeric (PRs are always numeric per GitHub)\n\t\t\tconst prNumber = typeof parsed.number === 'number' ? parsed.number : Number(parsed.number)\n\t\t\tif (isNaN(prNumber) || !isFinite(prNumber)) {\n\t\t\t\tthrow new Error(`Invalid PR number: ${parsed.number}. PR numbers must be numeric.`)\n\t\t\t}\n\t\t\t// Pass empty string for branch name since we don't know it yet\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForPR(prNumber, '')\n\t\t} else if (parsed.type === 'branch' && parsed.branchName) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForBranch(\n\t\t\t\tparsed.branchName\n\t\t\t)\n\t\t}\n\n\t\tif (!worktree) {\n\t\t\tthrow new Error(\n\t\t\t\t`No worktree found for ${this.formatParsedInput(parsed)}. ` +\n\t\t\t\t\t`Run 'il start ${parsed.originalInput}' to create one.`\n\t\t\t)\n\t\t}\n\n\t\treturn worktree\n\t}\n\n\t/**\n\t * Format parsed input for display\n\t */\n\tprivate formatParsedInput(parsed: ParsedRunInput): string {\n\t\tconst autoLabel = parsed.autoDetected ? ' (auto-detected)' : ''\n\n\t\tif (parsed.type === 'issue') {\n\t\t\treturn `issue #${parsed.number}${autoLabel}`\n\t\t}\n\t\tif (parsed.type === 'pr') {\n\t\t\treturn `PR #${parsed.number}${autoLabel}`\n\t\t}\n\t\treturn `branch \"${parsed.branchName}\"${autoLabel}`\n\t}\n\n\t/**\n\t * Run CLI tool directly from worktree bin path (NO SYMLINKS!)\n\t */\n\tprivate async runCLITool(\n\t\tworktreePath: string,\n\t\tbinEntries: Record<string, string>,\n\t\targs: string[]\n\t): Promise<void> {\n\t\t// Validate binEntries exist\n\t\tif (Object.keys(binEntries).length === 0) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\n\t\t// Get first bin entry (deterministic)\n\t\tconst firstEntry = Object.entries(binEntries)[0]\n\t\tif (!firstEntry) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\t\tconst [binName, binPath] = firstEntry\n\t\tlogger.debug(`Using bin entry: ${binName} -> ${binPath}`)\n\n\t\t// CRITICAL: Construct absolute path (NO SYMLINKS!)\n\t\tconst binFilePath = path.resolve(worktreePath, binPath)\n\t\tlogger.debug(`Resolved bin file path: ${binFilePath}`)\n\n\t\t// Verify file exists\n\t\tif (!(await fs.pathExists(binFilePath))) {\n\t\t\tthrow new Error(\n\t\t\t\t`CLI executable not found: ${binFilePath}\\n` +\n\t\t\t\t\t`Make sure the project is built (run 'il start' first)`\n\t\t\t)\n\t\t}\n\n\t\t// Execute with Node.js\n\t\tlogger.info(`Running CLI: node ${binFilePath} ${args.join(' ')}`)\n\t\tawait execa('node', [binFilePath, ...args], {\n\t\t\tstdio: 'inherit', // Allow interactive CLIs (prompts, colors, etc.)\n\t\t\tcwd: worktreePath, // Execute in worktree context\n\t\t\tenv: process.env, // Inherit environment\n\t\t})\n\t}\n\n\t/**\n\t * Open web browser with workspace URL\n\t * Auto-starts dev server if not already running\n\t */\n\tprivate async openWebBrowser(worktree: GitWorktree): Promise<void> {\n\t\tconst cliOverrides = extractSettingsOverrides()\n\t\tconst settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\tconst port = await getWorkspacePort({\n\t\t\tworktreePath: worktree.path,\n\t\t\tworktreeBranch: worktree.branch,\n\t\t\tbasePort: settings.capabilities?.web?.basePort,\n\t\t\tcheckEnvFile: true,\n\t\t})\n\n\t\t// Ensure dev server is running on the port\n\t\tconst serverReady = await this.devServerManager.ensureServerRunning(\n\t\t\tworktree.path,\n\t\t\tport\n\t\t)\n\n\t\tif (!serverReady) {\n\t\t\tlogger.warn(\n\t\t\t\t`Dev server failed to start on port ${port}. Opening browser anyway...`\n\t\t\t)\n\t\t}\n\n\t\t// Construct URL and open browser\n\t\tconst url = `http://localhost:${port}`\n\t\tlogger.info(`Opening browser: ${url}`)\n\t\tawait openBrowser(url)\n\t\tlogger.success('Browser opened')\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,aAAa;AA8Bf,IAAM,aAAN,MAAiB;AAAA,EACvB,YACS,qBAAqB,IAAI,mBAAmB,GAC5C,qBAAqB,IAAI,0BAA0B,GACnD,mBAAmB,IAAI,iBAAiB,IAAI,mBAAmB,CAAC,GAChE,mBAAmB,IAAI,iBAAiB,GACxC,kBAAkB,IAAI,gBAAgB,GAC7C;AALO;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAEH,MAAM,QAAQ,OAAuC;AAEpD,UAAM,SAAS,MAAM,aAClB,MAAM,KAAK,mBAAmB,MAAM,UAAU,IAC9C,MAAM,KAAK,+BAA+B;AAE7C,WAAO,MAAM,iBAAiB,KAAK,UAAU,MAAM,CAAC,EAAE;AAGtD,UAAM,WAAW,MAAM,KAAK,0BAA0B,MAAM;AAE5D,WAAO,KAAK,sBAAsB,SAAS,IAAI,EAAE;AAGjD,UAAM,EAAE,cAAc,WAAW,IAChC,MAAM,KAAK,mBAAmB,mBAAmB,SAAS,IAAI;AAE/D,WAAO,MAAM,0BAA0B,aAAa,KAAK,IAAI,CAAC,EAAE;AAGhE,QAAI,aAAa,SAAS,KAAK,GAAG;AACjC,YAAM,KAAK,WAAW,SAAS,MAAM,YAAY,MAAM,QAAQ,CAAC,CAAC;AAAA,IAClE,WAAW,aAAa,SAAS,KAAK,GAAG;AACxC,YAAM,KA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vB,gBAAgB,SAAS;AAAA,MACzB,WAAU,oBAAS,iBAAT,mBAAuB,QAAvB,mBAA4B;AAAA,MACtC,cAAc;AAAA,IACf,CAAC;AAGD,UAAM,cAAc,MAAM,KAAK,iBAAiB;AAAA,MAC/C,SAAS;AAAA,MACT;AAAA,IACD;AAEA,QAAI,CAAC,aAAa;AACjB,aAAO;AAAA,QACN,sCAAsC,IAAI;AAAA,MAC3C;AAAA,IACD;AAGA,UAAM,MAAM,oBAAoB,IAAI;AACpC,WAAO,KAAK,oBAAoB,GAAG,EAAE;AACrC,UAAM,YAAY,GAAG;AACrB,WAAO,QAAQ,gBAAgB;AAAA,EAChC;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/commands/run.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\nimport { execa } from 'execa'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { ProjectCapabilityDetector } from '../lib/ProjectCapabilityDetector.js'\nimport { DevServerManager } from '../lib/DevServerManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\nimport { IdentifierParser } from '../utils/IdentifierParser.js'\nimport { openBrowser } from '../utils/browser.js'\nimport { getWorkspacePort } from '../utils/port.js'\nimport { extractIssueNumber } from '../utils/git.js'\nimport { logger } from '../utils/logger.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport type { GitWorktree } from '../types/worktree.js'\n\nexport interface RunCommandInput {\n\tidentifier?: string\n\targs?: string[]\n}\n\ninterface ParsedRunInput {\n\ttype: 'issue' | 'pr' | 'branch'\n\tnumber?: string | number // For issues and PRs\n\tbranchName?: string // For branches\n\toriginalInput: string\n\tautoDetected: boolean\n}\n\n/**\n * RunCommand - Runs CLI tool or opens workspace in browser\n * Priority: CLI first, Web fallback\n */\nexport class RunCommand {\n\tconstructor(\n\t\tprivate gitWorktreeManager = new GitWorktreeManager(),\n\t\tprivate capabilityDetector = new ProjectCapabilityDetector(),\n\t\tprivate identifierParser = new IdentifierParser(new GitWorktreeManager()),\n\t\tprivate devServerManager = new DevServerManager(),\n\t\tprivate settingsManager = new SettingsManager()\n\t) {}\n\n\tasync execute(input: RunCommandInput): Promise<void> {\n\t\t// 1. Parse or auto-detect identifier\n\t\tconst parsed = input.identifier\n\t\t\t? await this.parseExplicitInput(input.identifier)\n\t\t\t: await this.autoDetectFromCurrentDirectory()\n\n\t\tlogger.debug(`Parsed input: ${JSON.stringify(parsed)}`)\n\n\t\t// 2. Find worktree path based on identifier\n\t\tconst worktree = await this.findWorktreeForIdentifier(parsed)\n\n\t\tlogger.info(`Found worktree at: ${worktree.path}`)\n\n\t\t// 3. Detect project capabilities\n\t\tconst { capabilities, binEntries } =\n\t\t\tawait this.capabilityDetector.detectCapabilities(worktree.path)\n\n\t\tlogger.debug(`Detected capabilities: ${capabilities.join(', ')}`)\n\n\t\t// 4. Execute based on capabilities (CLI first, web fallback)\n\t\tif (capabilities.includes('cli')) {\n\t\t\tawait this.runCLITool(worktree.path, binEntries, input.args ?? [])\n\t\t} else if (capabilities.includes('web')) {\n\t\t\tawait this.openWebBrowser(worktree)\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`No CLI or web capabilities detected for workspace at ${worktree.path}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Parse explicit identifier input\n\t */\n\tprivate async parseExplicitInput(identifier: string): Promise<ParsedRunInput> {\n\t\tconst parsed = await this.identifierParser.parseForPatternDetection(identifier)\n\n\t\t// Description type should never reach run command (converted in start)\n\t\tif (parsed.type === 'description') {\n\t\t\tthrow new Error('Description input type is not supported in run command')\n\t\t}\n\n\t\tconst result: ParsedRunInput = {\n\t\t\ttype: parsed.type,\n\t\t\toriginalInput: parsed.originalInput,\n\t\t\tautoDetected: false,\n\t\t}\n\n\t\tif (parsed.number !== undefined) {\n\t\t\tresult.number = parsed.number\n\t\t}\n\t\tif (parsed.branchName !== undefined) {\n\t\t\tresult.branchName = parsed.branchName\n\t\t}\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Auto-detect identifier from current directory\n\t * Same logic as FinishCommand.autoDetectFromCurrentDirectory()\n\t */\n\tprivate async autoDetectFromCurrentDirectory(): Promise<ParsedRunInput> {\n\t\tconst currentDir = path.basename(process.cwd())\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\tconst prPattern = /_pr_(\\d+)$/\n\t\tconst prMatch = currentDir.match(prPattern)\n\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tlogger.debug(`Auto-detected PR #${prNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'pr',\n\t\t\t\tnumber: prNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Check for issue pattern in directory\n\t\tconst issueNumber = extractIssueNumber(currentDir)\n\n\t\tif (issueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${issueNumber} from directory: ${currentDir}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: issueNumber,\n\t\t\t\toriginalInput: currentDir,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Fallback: get current branch name\n\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\tif (!currentBranch) {\n\t\t\tthrow new Error(\n\t\t\t\t'Could not auto-detect identifier. Please provide an issue number, PR number, or branch name.\\n' +\n\t\t\t\t\t'Expected directory pattern: feat/issue-XX-description OR worktree with _pr_N suffix'\n\t\t\t)\n\t\t}\n\n\t\t// Try to extract issue from branch name\n\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\tif (branchIssueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\t\t\treturn {\n\t\t\t\ttype: 'issue',\n\t\t\t\tnumber: branchIssueNumber,\n\t\t\t\toriginalInput: currentBranch,\n\t\t\t\tautoDetected: true,\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: use branch name\n\t\treturn {\n\t\t\ttype: 'branch',\n\t\t\tbranchName: currentBranch,\n\t\t\toriginalInput: currentBranch,\n\t\t\tautoDetected: true,\n\t\t}\n\t}\n\n\t/**\n\t * Find worktree for the given identifier\n\t */\n\tprivate async findWorktreeForIdentifier(parsed: ParsedRunInput): Promise<GitWorktree> {\n\t\tlet worktree: GitWorktree | null = null\n\n\t\tif (parsed.type === 'issue' && parsed.number !== undefined) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForIssue(parsed.number)\n\t\t} else if (parsed.type === 'pr' && parsed.number !== undefined) {\n\t\t\t// For PRs, ensure the number is numeric (PRs are always numeric per GitHub)\n\t\t\tconst prNumber = typeof parsed.number === 'number' ? parsed.number : Number(parsed.number)\n\t\t\tif (isNaN(prNumber) || !isFinite(prNumber)) {\n\t\t\t\tthrow new Error(`Invalid PR number: ${parsed.number}. PR numbers must be numeric.`)\n\t\t\t}\n\t\t\t// Pass empty string for branch name since we don't know it yet\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForPR(prNumber, '')\n\t\t} else if (parsed.type === 'branch' && parsed.branchName) {\n\t\t\tworktree = await this.gitWorktreeManager.findWorktreeForBranch(\n\t\t\t\tparsed.branchName\n\t\t\t)\n\t\t}\n\n\t\tif (!worktree) {\n\t\t\tthrow new Error(\n\t\t\t\t`No worktree found for ${this.formatParsedInput(parsed)}. ` +\n\t\t\t\t\t`Run 'il start ${parsed.originalInput}' to create one.`\n\t\t\t)\n\t\t}\n\n\t\treturn worktree\n\t}\n\n\t/**\n\t * Format parsed input for display\n\t */\n\tprivate formatParsedInput(parsed: ParsedRunInput): string {\n\t\tconst autoLabel = parsed.autoDetected ? ' (auto-detected)' : ''\n\n\t\tif (parsed.type === 'issue') {\n\t\t\treturn `issue #${parsed.number}${autoLabel}`\n\t\t}\n\t\tif (parsed.type === 'pr') {\n\t\t\treturn `PR #${parsed.number}${autoLabel}`\n\t\t}\n\t\treturn `branch \"${parsed.branchName}\"${autoLabel}`\n\t}\n\n\t/**\n\t * Run CLI tool directly from worktree bin path (NO SYMLINKS!)\n\t */\n\tprivate async runCLITool(\n\t\tworktreePath: string,\n\t\tbinEntries: Record<string, string>,\n\t\targs: string[]\n\t): Promise<void> {\n\t\t// Validate binEntries exist\n\t\tif (Object.keys(binEntries).length === 0) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\n\t\t// Get first bin entry (deterministic)\n\t\tconst firstEntry = Object.entries(binEntries)[0]\n\t\tif (!firstEntry) {\n\t\t\tthrow new Error('No bin entries found in package.json')\n\t\t}\n\t\tconst [binName, binPath] = firstEntry\n\t\tlogger.debug(`Using bin entry: ${binName} -> ${binPath}`)\n\n\t\t// CRITICAL: Construct absolute path (NO SYMLINKS!)\n\t\tconst binFilePath = path.resolve(worktreePath, binPath)\n\t\tlogger.debug(`Resolved bin file path: ${binFilePath}`)\n\n\t\t// Verify file exists\n\t\tif (!(await fs.pathExists(binFilePath))) {\n\t\t\tthrow new Error(\n\t\t\t\t`CLI executable not found: ${binFilePath}\\n` +\n\t\t\t\t\t`Make sure the project is built (run 'il start' first)`\n\t\t\t)\n\t\t}\n\n\t\t// Execute with Node.js\n\t\tlogger.info(`Running CLI: node ${binFilePath} ${args.join(' ')}`)\n\t\tawait execa('node', [binFilePath, ...args], {\n\t\t\tstdio: 'inherit', // Allow interactive CLIs (prompts, colors, etc.)\n\t\t\tcwd: worktreePath, // Execute in worktree context\n\t\t\tenv: process.env, // Inherit environment\n\t\t})\n\t}\n\n\t/**\n\t * Open web browser with workspace URL\n\t * Auto-starts dev server if not already running\n\t */\n\tprivate async openWebBrowser(worktree: GitWorktree): Promise<void> {\n\t\tconst cliOverrides = extractSettingsOverrides()\n\t\tconst settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\tconst port = await getWorkspacePort({\n\t\t\tworktreePath: worktree.path,\n\t\t\tworktreeBranch: worktree.branch,\n\t\t\tbasePort: settings.capabilities?.web?.basePort,\n\t\t\tcheckEnvFile: true,\n\t\t})\n\n\t\t// Ensure dev server is running on the port\n\t\tconst serverReady = await this.devServerManager.ensureServerRunning(\n\t\t\tworktree.path,\n\t\t\tport\n\t\t)\n\n\t\tif (!serverReady) {\n\t\t\tlogger.warn(\n\t\t\t\t`Dev server failed to start on port ${port}. Opening browser anyway...`\n\t\t\t)\n\t\t}\n\n\t\t// Construct URL and open browser\n\t\tconst url = `http://localhost:${port}`\n\t\tlogger.info(`Opening browser: ${url}`)\n\t\tawait openBrowser(url)\n\t\tlogger.success('Browser opened')\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,aAAa;AA8Bf,IAAM,aAAN,MAAiB;AAAA,EACvB,YACS,qBAAqB,IAAI,mBAAmB,GAC5C,qBAAqB,IAAI,0BAA0B,GACnD,mBAAmB,IAAI,iBAAiB,IAAI,mBAAmB,CAAC,GAChE,mBAAmB,IAAI,iBAAiB,GACxC,kBAAkB,IAAI,gBAAgB,GAC7C;AALO;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAEH,MAAM,QAAQ,OAAuC;AAEpD,UAAM,SAAS,MAAM,aAClB,MAAM,KAAK,mBAAmB,MAAM,UAAU,IAC9C,MAAM,KAAK,+BAA+B;AAE7C,WAAO,MAAM,iBAAiB,KAAK,UAAU,MAAM,CAAC,EAAE;AAGtD,UAAM,WAAW,MAAM,KAAK,0BAA0B,MAAM;AAE5D,WAAO,KAAK,sBAAsB,SAAS,IAAI,EAAE;AAGjD,UAAM,EAAE,cAAc,WAAW,IAChC,MAAM,KAAK,mBAAmB,mBAAmB,SAAS,IAAI;AAE/D,WAAO,MAAM,0BAA0B,aAAa,KAAK,IAAI,CAAC,EAAE;AAGhE,QAAI,aAAa,SAAS,KAAK,GAAG;AACjC,YAAM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AM,WAAW,MAAM,KAAK,gBAAgB,aAAa,QAAW,YAAY;AAChF,UAAM,OAAO,MAAM,iBAAiB;AAAA,MACnC,cAAc,SAAS;AAAA,MACvB,gBAAgB,SAAS;AAAA,MACzB,WAAU,oBAAS,iBAAT,mBAAuB,QAAvB,mBAA4B;AAAA,MACtC,cAAc;AAAA,IACf,CAAC;AAGD,UAAM,cAAc,MAAM,KAAK,iBAAiB;AAAA,MAC/C,SAAS;AAAA,MACT;AAAA,IACD;AAEA,QAAI,CAAC,aAAa;AACjB,aAAO;AAAA,QACN,sCAAsC,IAAI;AAAA,MAC3C;AAAA,IACD;AAGA,UAAM,MAAM,oBAAoB,IAAI;AACpC,WAAO,KAAK,oBAAoB,GAAG,EAAE;AACrC,UAAM,YAAY,GAAG;AACrB,WAAO,QAAQ,gBAAgB;AAAA,EAChC;AACD;","names":[]}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
SessionSummaryService
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WT4UGBE2.js";
|
|
5
5
|
import "./chunk-NXMDEL3F.js";
|
|
6
6
|
import {
|
|
7
7
|
GitWorktreeManager
|
|
8
8
|
} from "./chunk-UDRZY65Y.js";
|
|
9
|
-
import
|
|
9
|
+
import {
|
|
10
|
+
PRManager
|
|
11
|
+
} from "./chunk-6YAMWLCP.js";
|
|
12
|
+
import "./chunk-YETJNRQM.js";
|
|
13
|
+
import "./chunk-NPEMVE27.js";
|
|
10
14
|
import "./chunk-HBJITKSZ.js";
|
|
11
15
|
import "./chunk-FXDYIV3K.js";
|
|
12
16
|
import "./chunk-TIYJEEVO.js";
|
|
13
17
|
import {
|
|
14
18
|
extractIssueNumber
|
|
15
19
|
} from "./chunk-ZA575VLF.js";
|
|
16
|
-
import
|
|
20
|
+
import {
|
|
21
|
+
SettingsManager
|
|
22
|
+
} from "./chunk-WFQ5CLTR.js";
|
|
17
23
|
import {
|
|
18
24
|
MetadataManager
|
|
19
25
|
} from "./chunk-VWGKGNJP.js";
|
|
20
26
|
import "./chunk-GCPAZSGV.js";
|
|
21
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-IGKPPACU.js";
|
|
22
28
|
import {
|
|
23
29
|
getLogger
|
|
24
30
|
} from "./chunk-6MLEBAYZ.js";
|
|
@@ -27,10 +33,30 @@ import "./chunk-VT4PDUYT.js";
|
|
|
27
33
|
// src/commands/summary.ts
|
|
28
34
|
import path from "path";
|
|
29
35
|
var SummaryCommand = class {
|
|
30
|
-
constructor(gitWorktreeManager = new GitWorktreeManager(), metadataManager = new MetadataManager(), sessionSummaryService = new SessionSummaryService()) {
|
|
36
|
+
constructor(gitWorktreeManager = new GitWorktreeManager(), metadataManager = new MetadataManager(), sessionSummaryService = new SessionSummaryService(), settingsManager = new SettingsManager()) {
|
|
31
37
|
this.gitWorktreeManager = gitWorktreeManager;
|
|
32
38
|
this.metadataManager = metadataManager;
|
|
33
39
|
this.sessionSummaryService = sessionSummaryService;
|
|
40
|
+
this.settingsManager = settingsManager;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Determine PR number based on merge mode and metadata
|
|
44
|
+
* Returns undefined if should post to issue instead
|
|
45
|
+
*/
|
|
46
|
+
async getPRNumberForPosting(worktreePath, branchName) {
|
|
47
|
+
var _a;
|
|
48
|
+
const settings = await this.settingsManager.loadSettings(worktreePath);
|
|
49
|
+
const mergeMode = ((_a = settings.mergeBehavior) == null ? void 0 : _a.mode) ?? "local";
|
|
50
|
+
if (mergeMode === "github-draft-pr") {
|
|
51
|
+
const metadata = await this.metadataManager.readMetadata(worktreePath);
|
|
52
|
+
return (metadata == null ? void 0 : metadata.draftPrNumber) ?? void 0;
|
|
53
|
+
}
|
|
54
|
+
if (mergeMode === "github-pr") {
|
|
55
|
+
const prManager = new PRManager(settings);
|
|
56
|
+
const existingPR = await prManager.checkForExistingPR(branchName, worktreePath);
|
|
57
|
+
return existingPR == null ? void 0 : existingPR.number;
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
34
60
|
}
|
|
35
61
|
/**
|
|
36
62
|
* Execute the summary command
|
|
@@ -72,10 +98,15 @@ var SummaryCommand = class {
|
|
|
72
98
|
if (parsed.loomType === "branch") {
|
|
73
99
|
logger.debug("Skipping comment posting: branch type looms have no associated issue");
|
|
74
100
|
} else if (parsed.issueNumber !== void 0) {
|
|
101
|
+
const prNumber = await this.getPRNumberForPosting(
|
|
102
|
+
parsed.worktree.path,
|
|
103
|
+
parsed.worktree.branch
|
|
104
|
+
);
|
|
75
105
|
await this.sessionSummaryService.postSummary(
|
|
76
106
|
parsed.issueNumber,
|
|
77
107
|
result.summary,
|
|
78
|
-
parsed.worktree.path
|
|
108
|
+
parsed.worktree.path,
|
|
109
|
+
prNumber
|
|
79
110
|
);
|
|
80
111
|
}
|
|
81
112
|
}
|
|
@@ -249,4 +280,4 @@ Please provide an issue number, PR number, or branch name.`
|
|
|
249
280
|
export {
|
|
250
281
|
SummaryCommand
|
|
251
282
|
};
|
|
252
|
-
//# sourceMappingURL=summary-
|
|
283
|
+
//# sourceMappingURL=summary-MPOOQIOX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/summary.ts"],"sourcesContent":["import path from 'path'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { MetadataManager } from '../lib/MetadataManager.js'\nimport { SessionSummaryService } from '../lib/SessionSummaryService.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\nimport { PRManager } from '../lib/PRManager.js'\nimport { getLogger } from '../utils/logger-context.js'\nimport { extractIssueNumber } from '../utils/git.js'\nimport type { GitWorktree } from '../types/worktree.js'\nimport type { SummaryResult } from '../types/index.js'\n\n/**\n * Options for the summary command\n */\nexport interface SummaryOptions {\n\twithComment?: boolean\n\tjson?: boolean\n}\n\n/**\n * Input for the summary command\n */\nexport interface SummaryCommandInput {\n\tidentifier?: string | undefined\n\toptions: SummaryOptions\n}\n\n/**\n * Parsed input with loom information\n */\ninterface ParsedSummaryInput {\n\tworktree: GitWorktree\n\tloomType: 'issue' | 'pr' | 'branch'\n\tissueNumber?: string | number | undefined\n}\n\n/**\n * SummaryCommand - Generate and optionally post Claude session summaries\n *\n * This command allows generating the session summary without going through\n * the full `il finish` workflow. It can:\n * 1. Generate a summary and print it to stdout\n * 2. Optionally post the summary as a comment (--with-comment flag)\n */\nexport class SummaryCommand {\n\tconstructor(\n\t\tprivate gitWorktreeManager = new GitWorktreeManager(),\n\t\tprivate metadataManager = new MetadataManager(),\n\t\tprivate sessionSummaryService = new SessionSummaryService(),\n\t\tprivate settingsManager = new SettingsManager()\n\t) {}\n\n\t/**\n\t * Determine PR number based on merge mode and metadata\n\t * Returns undefined if should post to issue instead\n\t */\n\tprivate async getPRNumberForPosting(\n\t\tworktreePath: string,\n\t\tbranchName: string\n\t): Promise<number | undefined> {\n\t\tconst settings = await this.settingsManager.loadSettings(worktreePath)\n\t\tconst mergeMode = settings.mergeBehavior?.mode ?? 'local'\n\n\t\tif (mergeMode === 'github-draft-pr') {\n\t\t\tconst metadata = await this.metadataManager.readMetadata(worktreePath)\n\t\t\treturn metadata?.draftPrNumber ?? undefined\n\t\t}\n\n\t\tif (mergeMode === 'github-pr') {\n\t\t\tconst prManager = new PRManager(settings)\n\t\t\tconst existingPR = await prManager.checkForExistingPR(branchName, worktreePath)\n\t\t\treturn existingPR?.number\n\t\t}\n\n\t\treturn undefined // local mode - post to issue\n\t}\n\n\t/**\n\t * Execute the summary command\n\t *\n\t * @param input - Command input containing identifier and options\n\t * @returns SummaryResult when in JSON mode, void otherwise\n\t */\n\tasync execute(input: SummaryCommandInput): Promise<SummaryResult | void> {\n\t\tconst logger = getLogger()\n\n\t\t// 1. Find the loom by identifier (or auto-detect from current directory)\n\t\tconst parsed = input.identifier?.trim()\n\t\t\t? await this.findLoom(input.identifier.trim())\n\t\t\t: await this.autoDetectFromCurrentDirectory()\n\n\t\t// 2. Generate the summary (service handles session ID internally, including deterministic fallback)\n\t\tconst result = await this.sessionSummaryService.generateSummary(\n\t\t\tparsed.worktree.path,\n\t\t\tparsed.worktree.branch,\n\t\t\tparsed.loomType,\n\t\t\tparsed.issueNumber\n\t\t)\n\n\t\t// 4. Apply attribution if --with-comment is used (so output matches what will be posted)\n\t\tlet displaySummary = result.summary\n\t\tif (input.options.withComment && parsed.loomType !== 'branch') {\n\t\t\tdisplaySummary = await this.sessionSummaryService.applyAttribution(\n\t\t\t\tresult.summary,\n\t\t\t\tparsed.worktree.path\n\t\t\t)\n\t\t}\n\n\t\t// 5. In JSON mode, return the structured result\n\t\tif (input.options.json) {\n\t\t\tconst jsonResult: SummaryResult = {\n\t\t\t\tsummary: displaySummary,\n\t\t\t\tsessionId: result.sessionId,\n\t\t\t\tbranchName: parsed.worktree.branch,\n\t\t\t\tloomType: parsed.loomType,\n\t\t\t}\n\t\t\t// Only include issueNumber if defined\n\t\t\tif (parsed.issueNumber !== undefined) {\n\t\t\t\tjsonResult.issueNumber = parsed.issueNumber\n\t\t\t}\n\t\t\treturn jsonResult\n\t\t}\n\n\t\t// 6. Print the summary to stdout (intentionally using console.log for piping/redirection)\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(displaySummary)\n\n\t\t// 7. Optionally post the summary as a comment\n\t\tif (input.options.withComment) {\n\t\t\t// Skip posting for branch type looms (no issue to comment on)\n\t\t\tif (parsed.loomType === 'branch') {\n\t\t\t\tlogger.debug('Skipping comment posting: branch type looms have no associated issue')\n\t\t\t} else if (parsed.issueNumber !== undefined) {\n\t\t\t\t// Determine if we should post to PR instead of issue\n\t\t\t\tconst prNumber = await this.getPRNumberForPosting(\n\t\t\t\t\tparsed.worktree.path,\n\t\t\t\t\tparsed.worktree.branch\n\t\t\t\t)\n\t\t\t\tawait this.sessionSummaryService.postSummary(\n\t\t\t\t\tparsed.issueNumber,\n\t\t\t\t\tresult.summary,\n\t\t\t\t\tparsed.worktree.path,\n\t\t\t\t\tprNumber\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Find a loom by identifier\n\t *\n\t * Supports:\n\t * - Numeric identifiers (issue numbers): \"123\", \"#123\"\n\t * - PR identifiers: \"pr/123\"\n\t * - Branch names: \"my-feature-branch\"\n\t */\n\tprivate async findLoom(identifier: string): Promise<ParsedSummaryInput> {\n\t\t// Remove # prefix if present and trim whitespace\n\t\tconst cleanId = identifier.replace(/^#/, '').trim()\n\n\t\t// Check for PR pattern: pr/123 or PR/123\n\t\tconst prMatch = cleanId.match(/^pr\\/(\\d+)$/i)\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tconst worktree = await this.gitWorktreeManager.findWorktreeForPR(prNumber, '')\n\t\t\tif (worktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(worktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree,\n\t\t\t\t\tloomType: 'pr',\n\t\t\t\t\tissueNumber: metadata?.pr_numbers?.[0] ?? String(prNumber),\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(`No loom found for identifier: ${identifier}`)\n\t\t}\n\n\t\t// Check if input is numeric (issue number)\n\t\tconst numericMatch = cleanId.match(/^(\\d+)$/)\n\t\tif (numericMatch?.[1]) {\n\t\t\tconst issueNumber = parseInt(numericMatch[1], 10)\n\n\t\t\t// Try issue first\n\t\t\tconst issueWorktree = await this.gitWorktreeManager.findWorktreeForIssue(issueNumber)\n\t\t\tif (issueWorktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(issueWorktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree: issueWorktree,\n\t\t\t\t\tloomType: metadata?.issueType ?? 'issue',\n\t\t\t\t\tissueNumber: metadata?.issue_numbers?.[0] ?? String(issueNumber),\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Then try PR\n\t\t\tconst prWorktree = await this.gitWorktreeManager.findWorktreeForPR(issueNumber, '')\n\t\t\tif (prWorktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(prWorktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree: prWorktree,\n\t\t\t\t\tloomType: 'pr',\n\t\t\t\t\tissueNumber: metadata?.pr_numbers?.[0] ?? String(issueNumber),\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new Error(`No loom found for identifier: ${identifier}`)\n\t\t}\n\n\t\t// Check for alphanumeric issue identifier (Linear/Jira style: ABC-123)\n\t\tconst alphanumericMatch = cleanId.match(/^([A-Za-z]+-\\d+)$/)\n\t\tif (alphanumericMatch?.[1]) {\n\t\t\tconst alphanumericId = alphanumericMatch[1]\n\t\t\tconst issueWorktree = await this.gitWorktreeManager.findWorktreeForIssue(alphanumericId)\n\t\t\tif (issueWorktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(issueWorktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree: issueWorktree,\n\t\t\t\t\tloomType: metadata?.issueType ?? 'issue',\n\t\t\t\t\tissueNumber: metadata?.issue_numbers?.[0] ?? alphanumericId,\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(`No loom found for identifier: ${identifier}`)\n\t\t}\n\n\t\t// Treat as branch name\n\t\tconst branchWorktree = await this.gitWorktreeManager.findWorktreeForBranch(cleanId)\n\t\tif (branchWorktree) {\n\t\t\tconst metadata = await this.metadataManager.readMetadata(branchWorktree.path)\n\t\t\tconst loomType = metadata?.issueType ?? 'branch'\n\n\t\t\t// For branch looms, try to get issue number from metadata\n\t\t\tlet issueNumber: string | number | undefined\n\t\t\tif (loomType === 'issue' && metadata?.issue_numbers?.[0]) {\n\t\t\t\tissueNumber = metadata.issue_numbers[0]\n\t\t\t} else if (loomType === 'pr' && metadata?.pr_numbers?.[0]) {\n\t\t\t\tissueNumber = metadata.pr_numbers[0]\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tworktree: branchWorktree,\n\t\t\t\tloomType,\n\t\t\t\tissueNumber,\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`No loom found for identifier: ${identifier}`)\n\t}\n\n\t/**\n\t * Auto-detect loom from current working directory\n\t * Ports logic from FinishCommand.autoDetectFromCurrentDirectory()\n\t *\n\t * Detection strategy:\n\t * 1. Check current directory name for PR pattern (_pr_N suffix)\n\t * 2. Check current directory name for issue pattern (issue-N or -N-)\n\t * 3. Get current branch and check for issue pattern\n\t * 4. Fall back to using current branch as branch loom\n\t */\n\tprivate async autoDetectFromCurrentDirectory(): Promise<ParsedSummaryInput> {\n\t\tconst logger = getLogger()\n\t\tconst currentDir = path.basename(process.cwd())\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\tconst prPattern = /_pr_(\\d+)$/\n\t\tconst prMatch = currentDir.match(prPattern)\n\n\t\tif (prMatch?.[1]) {\n\t\t\tconst prNumber = parseInt(prMatch[1], 10)\n\t\t\tlogger.debug(`Auto-detected PR #${prNumber} from directory: ${currentDir}`)\n\n\t\t\tconst worktree = await this.gitWorktreeManager.findWorktreeForPR(prNumber, '')\n\t\t\tif (worktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(worktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree,\n\t\t\t\t\tloomType: 'pr',\n\t\t\t\t\tissueNumber: metadata?.pr_numbers?.[0] ?? String(prNumber),\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(`No loom found for auto-detected PR #${prNumber}`)\n\t\t}\n\n\t\t// Check for issue pattern in directory name\n\t\tconst issueNumber = extractIssueNumber(currentDir)\n\n\t\tif (issueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${issueNumber} from directory: ${currentDir}`)\n\n\t\t\tconst worktree = await this.gitWorktreeManager.findWorktreeForIssue(issueNumber)\n\t\t\tif (worktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(worktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree,\n\t\t\t\t\tloomType: metadata?.issueType ?? 'issue',\n\t\t\t\t\tissueNumber: metadata?.issue_numbers?.[0] ?? String(issueNumber),\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(`No loom found for auto-detected issue #${issueNumber}`)\n\t\t}\n\n\t\t// Fallback: get current branch name\n\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\tif (!currentBranch) {\n\t\t\tthrow new Error(\n\t\t\t\t'Could not auto-detect loom. Please provide an issue number, PR number, or branch name.\\n' +\n\t\t\t\t'Expected directory pattern: feat/issue-XX-description OR worktree with _pr_N suffix'\n\t\t\t)\n\t\t}\n\n\t\t// Try to extract issue from branch name\n\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\tif (branchIssueNumber !== null) {\n\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\n\t\t\tconst worktree = await this.gitWorktreeManager.findWorktreeForIssue(branchIssueNumber)\n\t\t\tif (worktree) {\n\t\t\t\tconst metadata = await this.metadataManager.readMetadata(worktree.path)\n\t\t\t\treturn {\n\t\t\t\t\tworktree,\n\t\t\t\t\tloomType: metadata?.issueType ?? 'issue',\n\t\t\t\t\tissueNumber: metadata?.issue_numbers?.[0] ?? String(branchIssueNumber),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Last resort: use current branch as branch loom\n\t\tconst branchWorktree = await this.gitWorktreeManager.findWorktreeForBranch(currentBranch)\n\t\tif (branchWorktree) {\n\t\t\tconst metadata = await this.metadataManager.readMetadata(branchWorktree.path)\n\t\t\tconst loomType = metadata?.issueType ?? 'branch'\n\n\t\t\t// For branch looms, try to get issue number from metadata\n\t\t\tlet resolvedIssueNumber: string | number | undefined\n\t\t\tif (loomType === 'issue' && metadata?.issue_numbers?.[0]) {\n\t\t\t\tresolvedIssueNumber = metadata.issue_numbers[0]\n\t\t\t} else if (loomType === 'pr' && metadata?.pr_numbers?.[0]) {\n\t\t\t\tresolvedIssueNumber = metadata.pr_numbers[0]\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tworktree: branchWorktree,\n\t\t\t\tloomType,\n\t\t\t\tissueNumber: resolvedIssueNumber,\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`Could not auto-detect loom from current directory or branch: ${currentBranch}\\n` +\n\t\t\t'Please provide an issue number, PR number, or branch name.'\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AA4CV,IAAM,iBAAN,MAAqB;AAAA,EAC3B,YACS,qBAAqB,IAAI,mBAAmB,GAC5C,kBAAkB,IAAI,gBAAgB,GACtC,wBAAwB,IAAI,sBAAsB,GAClD,kBAAkB,IAAI,gBAAgB,GAC7C;AAJO;AACA;AACA;AACA;AAAA,EACN;AAAA;AAAA;AAAA;AAAA;AAAA,EAMH,MAAc,sBACb,cACA,YAC8B;AA3DhC;AA4DE,UAAM,WAAW,MAAM,KAAK,gBAAgB,aAAa,YAAY;AACrE,UAAM,cAAY,cAAS,kBAAT,mBAAwB,SAAQ;AAElD,QAAI,cAAc,mBAAmB;AACpC,YAAM,WAAW,MAAM,KAAK,gBAAgB,aAAa,YAAY;AACrE,cAAO,qCAAU,kBAAiB;AAAA,IACnC;AAEA,QAAI,cAAc,aAAa;AAC9B,YAAM,YAAY,IAAI,UAAU,QAAQ;AACxC,YAAM,aAAa,MAAM,UAAU,mBAAmB,YAAY,YAAY;AAC9E,aAAO,yCAAY;AAAA,IACpB;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,QAAQ,OAA2D;AAnF1E;AAoFE,UAAM,SAAS,UAAU;AAGzB,UAAM,WAAS,WAAM,eAAN,mBAAkB,UAC9B,MAAM,KAAK,SAAS,MAAM,WAAW,KAAK,CAAC,IAC3C,MAAM,KAAK,+BAA+B;AAG7C,UAAM,SAAS,MAAM,KAAK,s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I;AACJ,UAAI,aAAa,aAAW,0CAAU,kBAAV,mBAA0B,KAAI;AACzD,8BAAsB,SAAS,cAAc,CAAC;AAAA,MAC/C,WAAW,aAAa,UAAQ,0CAAU,eAAV,mBAAuB,KAAI;AAC1D,8BAAsB,SAAS,WAAW,CAAC;AAAA,MAC5C;AAEA,aAAO;AAAA,QACN,UAAU;AAAA,QACV;AAAA,QACA,aAAa;AAAA,MACd;AAAA,IACD;AAEA,UAAM,IAAI;AAAA,MACT,gEAAgE,aAAa;AAAA;AAAA,IAE9E;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ProcessManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WZYBHD7P.js";
|
|
5
|
+
import "./chunk-CFQVOTHO.js";
|
|
5
6
|
import "./chunk-ZA575VLF.js";
|
|
6
7
|
import {
|
|
7
8
|
SettingsManager
|
|
@@ -80,4 +81,4 @@ var TestWebserverCommand = class {
|
|
|
80
81
|
export {
|
|
81
82
|
TestWebserverCommand
|
|
82
83
|
};
|
|
83
|
-
//# sourceMappingURL=test-webserver-
|
|
84
|
+
//# sourceMappingURL=test-webserver-J6SMNLU2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/test-webserver.ts"],"sourcesContent":["import { logger } from '../utils/logger.js'\nimport { ProcessManager } from '../lib/process/ProcessManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\n\nexport interface TestWebserverOptions {\n\tkill?: boolean\n}\n\nexport interface TestWebserverCommandInput {\n\tissueNumber: string | number\n\toptions: TestWebserverOptions\n}\n\n/**\n * Command to test if a web server is running on a workspace port\n * and optionally kill it if detected.\n *\n * This uses the ProcessManager to detect processes on ports and\n * safely terminate web servers when requested.\n */\nexport class TestWebserverCommand {\n\tprivate readonly settingsManager: SettingsManager\n\tprivate processManager: ProcessManager | null\n\n\tconstructor(processManager?: ProcessManager, settingsManager?: SettingsManager) {\n\t\tthis.settingsManager = settingsManager ?? new SettingsManager()\n\t\tthis.processManager = processManager ?? null\n\t}\n\n\t/**\n\t * Get or create ProcessManager with correct basePort from settings\n\t */\n\tprivate async getProcessManager(): Promise<ProcessManager> {\n\t\tif (this.processManager) {\n\t\t\treturn this.processManager\n\t\t}\n\t\tconst settings = await this.settingsManager.loadSettings()\n\t\tconst basePort = settings.capabilities?.web?.basePort ?? 3000\n\t\tthis.processManager = new ProcessManager(basePort)\n\t\treturn this.processManager\n\t}\n\n\t/**\n\t * Main entry point for the test-webserver command\n\t */\n\tpublic async execute(input: TestWebserverCommandInput): Promise<void> {\n\t\tconst { issueNumber, options } = input\n\n\t\t// Validate issue number - test-webserver requires numeric for port calculation\n\t\tif (typeof issueNumber !== 'number' || !Number.isInteger(issueNumber) || issueNumber <= 0) {\n\t\t\tthrow new Error('Issue number must be a positive integer for port calculation')\n\t\t}\n\n\t\t// Get ProcessManager (will load settings to get basePort if needed)\n\t\tconst processManager = await this.getProcessManager()\n\n\t\t// Calculate port from issue number\n\t\tconst port = processManager.calculatePort(issueNumber)\n\t\tlogger.info(`Checking port ${port} (issue #${issueNumber})...`)\n\n\t\t// Detect what's running on the port\n\t\tconst processInfo = await processManager.detectDevServer(port)\n\n\t\tif (!processInfo) {\n\t\t\tlogger.info(`No process found on port ${port}`)\n\t\t\treturn\n\t\t}\n\n\t\t// Report what we found\n\t\tlogger.info(`Found process on port ${port}:`)\n\t\tlogger.info(` PID: ${processInfo.pid}`)\n\t\tlogger.info(` Name: ${processInfo.name}`)\n\t\tlogger.info(` Command: ${processInfo.command}`)\n\n\t\tif (processInfo.isDevServer) {\n\t\t\tlogger.success(`Detected as web server`)\n\t\t} else {\n\t\t\tlogger.warn(`Not detected as web server`)\n\t\t\tlogger.info(`This appears to be a non-web-server process. Skipping for safety.`)\n\t\t}\n\n\t\t// Kill process if requested (and it's a web server)\n\t\tif (options.kill) {\n\t\t\tif (!processInfo.isDevServer) {\n\t\t\t\tlogger.error(`Cannot kill non-web-server process (PID ${processInfo.pid}) for safety reasons`)\n\t\t\t\tlogger.info(`Process must match web server patterns to be killed automatically`)\n\t\t\t\tthrow new Error('Cannot kill non-web-server process')\n\t\t\t}\n\n\t\t\tlogger.info(`Terminating web server (PID ${processInfo.pid})...`)\n\t\t\tconst terminated = await processManager.terminateProcess(processInfo.pid)\n\n\t\t\tif (terminated) {\n\t\t\t\tlogger.success(`Web server terminated successfully`)\n\n\t\t\t\t// Verify port is now free\n\t\t\t\tconst isFree = await processManager.verifyPortFree(port)\n\t\t\t\tif (isFree) {\n\t\t\t\t\tlogger.success(`Port ${port} is now free`)\n\t\t\t\t} else {\n\t\t\t\t\tlogger.warn(`Port ${port} may still be in use (TIME_WAIT state)`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/commands/test-webserver.ts"],"sourcesContent":["import { logger } from '../utils/logger.js'\nimport { ProcessManager } from '../lib/process/ProcessManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\n\nexport interface TestWebserverOptions {\n\tkill?: boolean\n}\n\nexport interface TestWebserverCommandInput {\n\tissueNumber: string | number\n\toptions: TestWebserverOptions\n}\n\n/**\n * Command to test if a web server is running on a workspace port\n * and optionally kill it if detected.\n *\n * This uses the ProcessManager to detect processes on ports and\n * safely terminate web servers when requested.\n */\nexport class TestWebserverCommand {\n\tprivate readonly settingsManager: SettingsManager\n\tprivate processManager: ProcessManager | null\n\n\tconstructor(processManager?: ProcessManager, settingsManager?: SettingsManager) {\n\t\tthis.settingsManager = settingsManager ?? new SettingsManager()\n\t\tthis.processManager = processManager ?? null\n\t}\n\n\t/**\n\t * Get or create ProcessManager with correct basePort from settings\n\t */\n\tprivate async getProcessManager(): Promise<ProcessManager> {\n\t\tif (this.processManager) {\n\t\t\treturn this.processManager\n\t\t}\n\t\tconst settings = await this.settingsManager.loadSettings()\n\t\tconst basePort = settings.capabilities?.web?.basePort ?? 3000\n\t\tthis.processManager = new ProcessManager(basePort)\n\t\treturn this.processManager\n\t}\n\n\t/**\n\t * Main entry point for the test-webserver command\n\t */\n\tpublic async execute(input: TestWebserverCommandInput): Promise<void> {\n\t\tconst { issueNumber, options } = input\n\n\t\t// Validate issue number - test-webserver requires numeric for port calculation\n\t\tif (typeof issueNumber !== 'number' || !Number.isInteger(issueNumber) || issueNumber <= 0) {\n\t\t\tthrow new Error('Issue number must be a positive integer for port calculation')\n\t\t}\n\n\t\t// Get ProcessManager (will load settings to get basePort if needed)\n\t\tconst processManager = await this.getProcessManager()\n\n\t\t// Calculate port from issue number\n\t\tconst port = processManager.calculatePort(issueNumber)\n\t\tlogger.info(`Checking port ${port} (issue #${issueNumber})...`)\n\n\t\t// Detect what's running on the port\n\t\tconst processInfo = await processManager.detectDevServer(port)\n\n\t\tif (!processInfo) {\n\t\t\tlogger.info(`No process found on port ${port}`)\n\t\t\treturn\n\t\t}\n\n\t\t// Report what we found\n\t\tlogger.info(`Found process on port ${port}:`)\n\t\tlogger.info(` PID: ${processInfo.pid}`)\n\t\tlogger.info(` Name: ${processInfo.name}`)\n\t\tlogger.info(` Command: ${processInfo.command}`)\n\n\t\tif (processInfo.isDevServer) {\n\t\t\tlogger.success(`Detected as web server`)\n\t\t} else {\n\t\t\tlogger.warn(`Not detected as web server`)\n\t\t\tlogger.info(`This appears to be a non-web-server process. Skipping for safety.`)\n\t\t}\n\n\t\t// Kill process if requested (and it's a web server)\n\t\tif (options.kill) {\n\t\t\tif (!processInfo.isDevServer) {\n\t\t\t\tlogger.error(`Cannot kill non-web-server process (PID ${processInfo.pid}) for safety reasons`)\n\t\t\t\tlogger.info(`Process must match web server patterns to be killed automatically`)\n\t\t\t\tthrow new Error('Cannot kill non-web-server process')\n\t\t\t}\n\n\t\t\tlogger.info(`Terminating web server (PID ${processInfo.pid})...`)\n\t\t\tconst terminated = await processManager.terminateProcess(processInfo.pid)\n\n\t\t\tif (terminated) {\n\t\t\t\tlogger.success(`Web server terminated successfully`)\n\n\t\t\t\t// Verify port is now free\n\t\t\t\tconst isFree = await processManager.verifyPortFree(port)\n\t\t\t\tif (isFree) {\n\t\t\t\t\tlogger.success(`Port ${port} is now free`)\n\t\t\t\t} else {\n\t\t\t\t\tlogger.warn(`Port ${port} may still be in use (TIME_WAIT state)`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBO,IAAM,uBAAN,MAA2B;AAAA,EAIjC,YAAY,gBAAiC,iBAAmC;AAC/E,SAAK,kBAAkB,mBAAmB,IAAI,gBAAgB;AAC9D,SAAK,iBAAiB,kBAAkB;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,oBAA6C;AAhC5D;AAiCE,QAAI,KAAK,gBAAgB;AACxB,aAAO,KAAK;AAAA,IACb;AACA,UAAM,WAAW,MAAM,KAAK,gBAAgB,aAAa;AACzD,UAAM,aAAW,oBAAS,iBAAT,mBAAuB,QAAvB,mBAA4B,aAAY;AACzD,SAAK,iBAAiB,IAAI,eAAe,QAAQ;AACjD,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,MAAa,QAAQ,OAAiD;AACrE,UAAM,EAAE,aAAa,QAAQ,IAAI;AAGjC,QAAI,OAAO,gBAAgB,YAAY,CAAC,OAAO,UAAU,WAAW,KAAK,eAAe,GAAG;AAC1F,YAAM,IAAI,MAAM,8DAA8D;AAAA,IAC/E;AAGA,UAAM,iBAAiB,MAAM,KAAK,kBAAkB;AAGpD,UAAM,OAAO,eAAe,cAAc,WAAW;AACrD,WAAO,KAAK,iBAAiB,IAAI,YAAY,WAAW,MAAM;AAG9D,UAAM,cAAc,MAAM,eAAe,gBAAgB,IAAI;AAE7D,QAAI,CAAC,aAAa;AACjB,aAAO,KAAK,4BAA4B,IAAI,EAAE;AAC9C;AAAA,IACD;AAGA,WAAO,KAAK,yBAAyB,IAAI,GAAG;AAC5C,WAAO,KAAK,WAAW,YAAY,GAAG,EAAE;AACxC,WAAO,KAAK,YAAY,YAAY,IAAI,EAAE;AAC1C,WAAO,KAAK,eAAe,YAAY,OAAO,EAAE;AAEhD,QAAI,YAAY,aAAa;AAC5B,aAAO,QAAQ,wBAAwB;AAAA,IACxC,OAAO;AACN,aAAO,KAAK,4BAA4B;AACxC,aAAO,KAAK,mEAAmE;AAAA,IAChF;AAGA,QAAI,QAAQ,MAAM;AACjB,UAAI,CAAC,YAAY,aAAa;AAC7B,eAAO,MAAM,2CAA2C,YAAY,GAAG,sBAAsB;AAC7F,eAAO,KAAK,mEAAmE;AAC/E,cAAM,IAAI,MAAM,oCAAoC;AAAA,MACrD;AAEA,aAAO,KAAK,+BAA+B,YAAY,GAAG,MAAM;AAChE,YAAM,aAAa,MAAM,eAAe,iBAAiB,YAAY,GAAG;AAExE,UAAI,YAAY;AACf,eAAO,QAAQ,oCAAoC;AAGnD,cAAM,SAAS,MAAM,eAAe,eAAe,IAAI;AACvD,YAAI,QAAQ;AACX,iBAAO,QAAQ,QAAQ,IAAI,cAAc;AAAA,QAC1C,OAAO;AACN,iBAAO,KAAK,QAAQ,IAAI,wCAAwC;AAAA,QACjE;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iloom/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "Control plane for maintaining alignment between you and Claude Code as you work across multiple issues using isolated environments, visible context, and multi-agent workflows to scale understanding, not just output",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|