@iloom/cli 0.7.3 → 0.7.5
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 +6 -4
- package/dist/{BranchNamingService-FLPUUFOB.js → BranchNamingService-AO7BPIUJ.js} +2 -2
- package/dist/{ClaudeContextManager-KE5TBZVZ.js → ClaudeContextManager-Y2YJC6BU.js} +4 -4
- package/dist/{ClaudeService-CRSETT3A.js → ClaudeService-NDVFQRKC.js} +3 -3
- package/dist/{LoomLauncher-NL65LSKP.js → LoomLauncher-U2B3VHPC.js} +4 -4
- package/dist/{PRManager-2ABCWXHW.js → PRManager-6ZJZRG5Z.js} +4 -4
- package/dist/README.md +6 -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-FM4KBPVA.js → chunk-3K3WY3BN.js} +2 -118
- package/dist/chunk-3K3WY3BN.js.map +1 -0
- package/dist/{chunk-6TL3BYH6.js → chunk-64HCHVJM.js} +2 -2
- package/dist/{chunk-QQFBMCAH.js → chunk-77VLG2KP.js} +20 -17
- package/dist/chunk-77VLG2KP.js.map +1 -0
- package/dist/{chunk-FEAJR6PN.js → chunk-C7YW5IMS.js} +2 -2
- package/dist/{chunk-DAOS6EC3.js → chunk-CAXFWFV6.js} +5 -3
- package/dist/{chunk-DAOS6EC3.js.map → chunk-CAXFWFV6.js.map} +1 -1
- 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-FP7G7DG3.js → chunk-IGKPPACU.js} +8 -3
- package/dist/chunk-IGKPPACU.js.map +1 -0
- package/dist/{chunk-CNSTXBJ3.js → chunk-KSXA2NOJ.js} +9 -5
- package/dist/chunk-KSXA2NOJ.js.map +1 -0
- package/dist/{chunk-GJMEKEI5.js → chunk-LZBSLO6S.js} +76 -1
- package/dist/chunk-LZBSLO6S.js.map +1 -0
- package/dist/{chunk-YQNSZKKT.js → chunk-NEPH2O4C.js} +8 -4
- package/dist/chunk-NEPH2O4C.js.map +1 -0
- package/dist/{chunk-KVS4XGBQ.js → chunk-O36JLYNW.js} +2 -2
- package/dist/{chunk-C3AKFAIR.js → chunk-Q457PKGH.js} +2 -2
- package/dist/{chunk-EPPPDVHD.js → chunk-TB6475EW.js} +6 -4
- package/dist/chunk-TB6475EW.js.map +1 -0
- package/dist/{chunk-HVQNVRAF.js → chunk-VYKKWU36.js} +96 -3
- package/dist/chunk-VYKKWU36.js.map +1 -0
- package/dist/{chunk-453NC377.js → chunk-WZYBHD7P.js} +3 -106
- package/dist/chunk-WZYBHD7P.js.map +1 -0
- package/dist/chunk-XAMBIVXE.js +121 -0
- package/dist/chunk-XAMBIVXE.js.map +1 -0
- package/dist/{claude-6H36IBHO.js → claude-V4HRPR4Z.js} +2 -2
- package/dist/{cleanup-77U5ATYI.js → cleanup-DB7EFBF3.js} +9 -6
- package/dist/{cleanup-77U5ATYI.js.map → cleanup-DB7EFBF3.js.map} +1 -1
- package/dist/cli.js +104 -156
- package/dist/cli.js.map +1 -1
- package/dist/{commit-ONRXU67O.js → commit-NGMDWWAP.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-K3A4QUSG.js → feedback-ZLAX3BVL.js} +4 -3
- package/dist/{feedback-K3A4QUSG.js.map → feedback-ZLAX3BVL.js.map} +1 -1
- package/dist/{ignite-YUAOJ5PP.js → ignite-HA2OJF6Z.js} +26 -40
- package/dist/ignite-HA2OJF6Z.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/{init-XQQMFDM6.js → init-S6IEGRSX.js} +3 -3
- package/dist/mcp/issue-management-server.js +157 -9
- 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-QYCRF7JG.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-G6L3VAKK.js → summary-2KLNHVTN.js} +4 -4
- 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-CNSTXBJ3.js.map +0 -1
- package/dist/chunk-EPPPDVHD.js.map +0 -1
- package/dist/chunk-FM4KBPVA.js.map +0 -1
- package/dist/chunk-FP7G7DG3.js.map +0 -1
- package/dist/chunk-GJMEKEI5.js.map +0 -1
- package/dist/chunk-HVQNVRAF.js.map +0 -1
- package/dist/chunk-QQFBMCAH.js.map +0 -1
- package/dist/chunk-YQNSZKKT.js.map +0 -1
- package/dist/ignite-YUAOJ5PP.js.map +0 -1
- package/dist/projects-TWY4RT2Z.js.map +0 -1
- /package/dist/{BranchNamingService-FLPUUFOB.js.map → BranchNamingService-AO7BPIUJ.js.map} +0 -0
- /package/dist/{ClaudeContextManager-KE5TBZVZ.js.map → ClaudeContextManager-Y2YJC6BU.js.map} +0 -0
- /package/dist/{ClaudeService-CRSETT3A.js.map → ClaudeService-NDVFQRKC.js.map} +0 -0
- /package/dist/{LoomLauncher-NL65LSKP.js.map → LoomLauncher-U2B3VHPC.js.map} +0 -0
- /package/dist/{PRManager-2ABCWXHW.js.map → PRManager-6ZJZRG5Z.js.map} +0 -0
- /package/dist/{chunk-6TL3BYH6.js.map → chunk-64HCHVJM.js.map} +0 -0
- /package/dist/{chunk-FEAJR6PN.js.map → chunk-C7YW5IMS.js.map} +0 -0
- /package/dist/{chunk-AFRICMSW.js.map → chunk-ENMTWE74.js.map} +0 -0
- /package/dist/{chunk-KVS4XGBQ.js.map → chunk-O36JLYNW.js.map} +0 -0
- /package/dist/{chunk-C3AKFAIR.js.map → chunk-Q457PKGH.js.map} +0 -0
- /package/dist/{claude-6H36IBHO.js.map → claude-V4HRPR4Z.js.map} +0 -0
- /package/dist/{commit-ONRXU67O.js.map → commit-NGMDWWAP.js.map} +0 -0
- /package/dist/{init-XQQMFDM6.js.map → init-S6IEGRSX.js.map} +0 -0
- /package/dist/{rebase-QYCRF7JG.js.map → rebase-RLEVFHWN.js.map} +0 -0
- /package/dist/{summary-G6L3VAKK.js.map → summary-2KLNHVTN.js.map} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
generateIssueManagementMcpConfig
|
|
4
|
+
} from "./chunk-XAMBIVXE.js";
|
|
2
5
|
import {
|
|
3
6
|
openBrowser
|
|
4
7
|
} from "./chunk-YETJNRQM.js";
|
|
@@ -7,7 +10,7 @@ import {
|
|
|
7
10
|
} from "./chunk-ZX3GTM7O.js";
|
|
8
11
|
import {
|
|
9
12
|
launchClaude
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IGKPPACU.js";
|
|
11
14
|
import {
|
|
12
15
|
getLogger
|
|
13
16
|
} from "./chunk-6MLEBAYZ.js";
|
|
@@ -71,7 +74,9 @@ Your response should be the raw markdown that will become the GitHub issue body.
|
|
|
71
74
|
const enhanced = await launchClaude(prompt, {
|
|
72
75
|
headless: true,
|
|
73
76
|
model: "sonnet",
|
|
74
|
-
agents
|
|
77
|
+
agents,
|
|
78
|
+
noSessionPersistence: true
|
|
79
|
+
// Utility operation - don't persist session
|
|
75
80
|
});
|
|
76
81
|
if (enhanced && typeof enhanced === "string") {
|
|
77
82
|
getLogger().success("Description enhanced successfully");
|
|
@@ -127,6 +132,94 @@ Press any key to open issue for editing...`;
|
|
|
127
132
|
await waitForKeypress("Press any key to continue with loom creation...");
|
|
128
133
|
}
|
|
129
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Enhances an existing issue using the issue enhancer agent.
|
|
137
|
+
* This method encapsulates the Claude invocation, MCP config generation,
|
|
138
|
+
* and response parsing for enhancing existing issues.
|
|
139
|
+
*
|
|
140
|
+
* @param issueNumber - The issue number to enhance
|
|
141
|
+
* @param options - Optional enhancement options (author, repo)
|
|
142
|
+
* @returns Result indicating whether enhancement occurred and the comment URL if so
|
|
143
|
+
*/
|
|
144
|
+
async enhanceExistingIssue(issueNumber, options) {
|
|
145
|
+
const { author, repo } = options ?? {};
|
|
146
|
+
const settings = await this.settingsManager.loadSettings();
|
|
147
|
+
const loadedAgents = await this.agentManager.loadAgents(settings);
|
|
148
|
+
const agents = this.agentManager.formatForCli(loadedAgents);
|
|
149
|
+
let mcpConfig;
|
|
150
|
+
let allowedTools;
|
|
151
|
+
let disallowedTools;
|
|
152
|
+
try {
|
|
153
|
+
const provider = this.issueTrackerService.providerName;
|
|
154
|
+
mcpConfig = await generateIssueManagementMcpConfig("issue", repo, provider, settings);
|
|
155
|
+
getLogger().debug("Generated MCP configuration for issue management:", { mcpConfig });
|
|
156
|
+
allowedTools = [
|
|
157
|
+
"mcp__issue_management__get_issue",
|
|
158
|
+
"mcp__issue_management__get_comment",
|
|
159
|
+
"mcp__issue_management__create_comment",
|
|
160
|
+
"mcp__issue_management__update_comment",
|
|
161
|
+
"mcp__issue_management__create_issue"
|
|
162
|
+
];
|
|
163
|
+
disallowedTools = ["Bash(gh api:*)"];
|
|
164
|
+
getLogger().debug("Configured tool filtering for issue workflow", { allowedTools, disallowedTools });
|
|
165
|
+
} catch (error) {
|
|
166
|
+
getLogger().warn(`Failed to generate MCP config: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
167
|
+
}
|
|
168
|
+
const prompt = this.constructEnhancerPrompt(issueNumber, author);
|
|
169
|
+
const response = await launchClaude(prompt, {
|
|
170
|
+
headless: true,
|
|
171
|
+
model: "sonnet",
|
|
172
|
+
agents,
|
|
173
|
+
noSessionPersistence: true,
|
|
174
|
+
// Headless operation - no session persistence needed
|
|
175
|
+
...mcpConfig && { mcpConfig },
|
|
176
|
+
...allowedTools && { allowedTools },
|
|
177
|
+
...disallowedTools && { disallowedTools }
|
|
178
|
+
});
|
|
179
|
+
return this.parseEnhancerResponse(response);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Construct the prompt for the orchestrating Claude instance.
|
|
183
|
+
* This prompt is very clear about expected output format to ensure reliable parsing.
|
|
184
|
+
*/
|
|
185
|
+
constructEnhancerPrompt(issueNumber, author) {
|
|
186
|
+
const authorInstruction = author ? `
|
|
187
|
+
IMPORTANT: When you create your analysis comment, tag @${author} in the "Questions for Reporter" section if you have questions.
|
|
188
|
+
` : "";
|
|
189
|
+
return `Execute @agent-iloom-issue-enhancer ${issueNumber}${authorInstruction}
|
|
190
|
+
|
|
191
|
+
## OUTPUT REQUIREMENTS
|
|
192
|
+
* If the issue was not enhanced, return ONLY: "No enhancement needed"
|
|
193
|
+
* If the issue WAS enhanced, return ONLY: <FULL URL OF THE COMMENT INCLUDING COMMENT ID>
|
|
194
|
+
* If you encounter permission/authentication/access errors, return ONLY: "Permission denied: <specific error description>"
|
|
195
|
+
* IMPORTANT: Return ONLY one of the above - DO NOT include commentary such as "I created a comment at <URL>" or "I examined the issue and found no enhancement was necessary"
|
|
196
|
+
* CONTEXT: Your output is going to be parsed programmatically, so adherence to the output requirements is CRITICAL.`;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Parse the response from the enhancer agent.
|
|
200
|
+
* Returns either { enhanced: false } or { enhanced: true, url: "..." }
|
|
201
|
+
* Throws specific errors for permission issues.
|
|
202
|
+
*/
|
|
203
|
+
parseEnhancerResponse(response) {
|
|
204
|
+
if (!response || typeof response !== "string") {
|
|
205
|
+
throw new Error("No response from enhancer agent");
|
|
206
|
+
}
|
|
207
|
+
const trimmed = response.trim();
|
|
208
|
+
getLogger().debug(`RESPONSE FROM ENHANCER AGENT: '${trimmed}'`);
|
|
209
|
+
if (trimmed.toLowerCase().startsWith("permission denied:")) {
|
|
210
|
+
const errorMessage = trimmed.substring("permission denied:".length).trim();
|
|
211
|
+
throw new Error(`Permission denied: ${errorMessage}`);
|
|
212
|
+
}
|
|
213
|
+
if (trimmed.toLowerCase().includes("no enhancement needed")) {
|
|
214
|
+
return { enhanced: false };
|
|
215
|
+
}
|
|
216
|
+
const urlPattern = /https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+#issuecomment-\d+/;
|
|
217
|
+
const match = trimmed.match(urlPattern);
|
|
218
|
+
if (match) {
|
|
219
|
+
return { enhanced: true, url: match[0] };
|
|
220
|
+
}
|
|
221
|
+
throw new Error(`Unexpected response from enhancer agent: ${trimmed}`);
|
|
222
|
+
}
|
|
130
223
|
};
|
|
131
224
|
|
|
132
225
|
// src/utils/text.ts
|
|
@@ -151,4 +244,4 @@ export {
|
|
|
151
244
|
IssueEnhancementService,
|
|
152
245
|
capitalizeFirstLetter
|
|
153
246
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
247
|
+
//# sourceMappingURL=chunk-VYKKWU36.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/IssueEnhancementService.ts","../src/utils/text.ts"],"sourcesContent":["import type { IssueTracker } from './IssueTracker.js'\nimport type { AgentManager } from './AgentManager.js'\nimport type { SettingsManager } from './SettingsManager.js'\nimport { launchClaude } from '../utils/claude.js'\nimport { openBrowser } from '../utils/browser.js'\nimport { waitForKeypress } from '../utils/prompt.js'\nimport { getLogger } from '../utils/logger-context.js'\nimport { generateIssueManagementMcpConfig } from '../utils/mcp.js'\n\n/**\n * Options for enhancing an existing issue\n */\nexport interface EnhanceExistingIssueOptions {\n\t/** GitHub username of issue author for tagging in questions */\n\tauthor?: string\n\t/** Repository in \"owner/repo\" format */\n\trepo?: string\n}\n\n/**\n * Result of enhancing an existing issue\n */\nexport interface EnhanceExistingIssueResult {\n\t/** Whether the issue was enhanced */\n\tenhanced: boolean\n\t/** URL of the comment if enhancement occurred */\n\turl?: string\n}\n\n/**\n * Service for enhancing and creating issues with AI assistance.\n * Extracts reusable issue enhancement logic from StartCommand.\n */\nexport class IssueEnhancementService {\n\tconstructor(\n\t\tprivate issueTrackerService: IssueTracker,\n\t\tprivate agentManager: AgentManager,\n\t\tprivate settingsManager: SettingsManager\n\t) {\n\t\t// No-op - logger now uses AsyncLocalStorage context\n\t}\n\n\t/**\n\t * Expose issue tracker for provider checks\n\t */\n\tpublic get issueTracker(): IssueTracker {\n\t\treturn this.issueTrackerService\n\t}\n\n\t/**\n\t * Validates that a description meets minimum requirements.\n\t *\n\t * When hasBody is false (default): Strict validation - >30 characters AND >2 spaces\n\t * When hasBody is true: Relaxed validation - only requires non-empty description\n\t *\n\t * @param description - The description text to validate\n\t * @param hasBody - If true, skip strict validation (only require non-empty)\n\t */\n\tpublic validateDescription(description: string, hasBody = false): boolean {\n\t\tconst trimmedDescription = description.trim()\n\n\t\t// When --body is provided, only require non-empty description\n\t\tif (hasBody) {\n\t\t\treturn trimmedDescription.length > 0\n\t\t}\n\n\t\t// Standard validation: >30 chars AND >2 spaces\n\t\tconst spaceCount = (trimmedDescription.match(/ /g) ?? []).length\n\t\treturn trimmedDescription.length > 30 && spaceCount > 2\n\t}\n\n\t/**\n\t * Enhances a description using Claude Code in headless mode.\n\t * Falls back to original description if enhancement fails.\n\t */\n\tpublic async enhanceDescription(description: string): Promise<string> {\n\t\ttry {\n\t\t\tgetLogger().info('Enhancing description with Claude Code. This may take a moment...')\n\n\t\t\t// Load agent configurations\n\t\t\tconst settings = await this.settingsManager.loadSettings()\n\t\t\tconst loadedAgents = await this.agentManager.loadAgents(settings)\n\t\t\tconst agents = this.agentManager.formatForCli(loadedAgents)\n\n\t\t\t// Call Claude in headless mode with issue enhancer agent\n\t\t\tconst prompt = `@agent-iloom-issue-enhancer\n\nTASK: Enhance the following issue description for GitHub.\n\nINPUT:\n${description}\n\nOUTPUT REQUIREMENTS:\n- Return ONLY the enhanced description markdown text\n- NO meta-commentary (no \"Here is...\", \"The enhanced...\", \"I have...\", etc)\n- NO code block markers (\\`\\`\\`)\n- NO conversational framing or acknowledgments\n- NO explanations of your work\n- Start your response immediately with the enhanced content\n\nYour response should be the raw markdown that will become the GitHub issue body.`\n\n\t\t\tconst enhanced = await launchClaude(prompt, {\n\t\t\t\theadless: true,\n\t\t\t\tmodel: 'sonnet',\n\t\t\t\tagents,\n\t\t\t\tnoSessionPersistence: true, // Utility operation - don't persist session\n\t\t\t})\n\n\t\t\tif (enhanced && typeof enhanced === 'string') {\n\t\t\t\tgetLogger().success('Description enhanced successfully')\n\t\t\t\treturn enhanced\n\t\t\t}\n\n\t\t\t// Fallback to original description\n\t\t\tgetLogger().warn('Claude enhancement returned empty result, using original description')\n\t\t\treturn description\n\t\t} catch (error) {\n\t\t\tgetLogger().warn(`Failed to enhance description: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\treturn description\n\t\t}\n\t}\n\n\t/**\n\t * Creates a GitHub issue with title and enhanced body.\n\t * @param originalDescription - Used as the issue title\n\t * @param enhancedDescription - Used as the issue body\n\t * @param repository - Optional repository override (format: \"owner/repo\")\n\t * @param labels - Optional array of label names to add to the issue\n\t * @returns Issue number and URL\n\t */\n\tpublic async createEnhancedIssue(\n\t\toriginalDescription: string,\n\t\tenhancedDescription: string,\n\t\trepository?: string,\n\t\tlabels?: string[]\n\t): Promise<{ number: string | number; url: string }> {\n\t\tgetLogger().info('Creating GitHub issue from description...')\n\n\t\tconst result = await this.issueTrackerService.createIssue(\n\t\t\toriginalDescription, // Use original description as title\n\t\t\tenhancedDescription, // Use enhanced description as body\n\t\t\trepository,\n\t\t\tlabels\n\t\t)\n\n\t\treturn result\n\t}\n\n\t/**\n\t * Waits for user keypress and opens issue in browser for review.\n\t * @param issueNumber - Issue number to open for review\n\t * @param confirm - If true, wait for additional keypress after opening browser before returning\n\t * @param repository - Optional repository to fetch issue from (format: \"owner/repo\")\n\t */\n\tpublic async waitForReviewAndOpen(issueNumber: string | number, confirm = false, repository?: string): Promise<void> {\n\t\t// Check if running in non-interactive environment (CI or no TTY)\n\t\tconst isCI = process.env.CI === 'true'\n\t\tconst isNonInteractive = isCI || !process.stdin.isTTY\n\n\t\tif (isNonInteractive) {\n\t\t\t// In non-interactive environment: Skip all interactive operations\n\t\t\tgetLogger().info(`Running in non-interactive environment - skipping interactive prompts for issue #${issueNumber}`)\n\t\t\treturn\n\t\t}\n\n\t\t// Get issue URL\n\t\tconst issueUrl = await this.issueTrackerService.getIssueUrl(issueNumber, repository)\n\n\t\t// Display message and wait for first keypress\n\t\tconst message = `Created issue #${issueNumber}.\nReview and edit the issue in your browser if needed.\nPress any key to open issue for editing...`\n\t\tawait waitForKeypress(message)\n\n\t\t// Open issue in browser\n\t\tawait openBrowser(issueUrl)\n\n\t\t// If confirmation required, wait for second keypress\n\t\tif (confirm) {\n\t\t\tawait waitForKeypress('Press any key to continue with loom creation...')\n\t\t}\n\t}\n\n\t/**\n\t * Enhances an existing issue using the issue enhancer agent.\n\t * This method encapsulates the Claude invocation, MCP config generation,\n\t * and response parsing for enhancing existing issues.\n\t *\n\t * @param issueNumber - The issue number to enhance\n\t * @param options - Optional enhancement options (author, repo)\n\t * @returns Result indicating whether enhancement occurred and the comment URL if so\n\t */\n\tpublic async enhanceExistingIssue(\n\t\tissueNumber: string | number,\n\t\toptions?: EnhanceExistingIssueOptions\n\t): Promise<EnhanceExistingIssueResult> {\n\t\tconst { author, repo } = options ?? {}\n\n\t\t// Load agent configurations\n\t\tconst settings = await this.settingsManager.loadSettings()\n\t\tconst loadedAgents = await this.agentManager.loadAgents(settings)\n\t\tconst agents = this.agentManager.formatForCli(loadedAgents)\n\n\t\t// Generate MCP config and tool filtering for issue management\n\t\tlet mcpConfig: Record<string, unknown>[] | undefined\n\t\tlet allowedTools: string[] | undefined\n\t\tlet disallowedTools: string[] | undefined\n\n\t\ttry {\n\t\t\tconst provider = this.issueTrackerService.providerName as 'github' | 'linear'\n\t\t\tmcpConfig = await generateIssueManagementMcpConfig('issue', repo, provider, settings)\n\t\t\tgetLogger().debug('Generated MCP configuration for issue management:', { mcpConfig })\n\n\t\t\t// Configure tool filtering for issue workflows\n\t\t\tallowedTools = [\n\t\t\t\t'mcp__issue_management__get_issue',\n\t\t\t\t'mcp__issue_management__get_comment',\n\t\t\t\t'mcp__issue_management__create_comment',\n\t\t\t\t'mcp__issue_management__update_comment',\n\t\t\t\t'mcp__issue_management__create_issue',\n\t\t\t]\n\t\t\tdisallowedTools = ['Bash(gh api:*)']\n\n\t\t\tgetLogger().debug('Configured tool filtering for issue workflow', { allowedTools, disallowedTools })\n\t\t} catch (error) {\n\t\t\t// Log warning but continue without MCP\n\t\t\tgetLogger().warn(`Failed to generate MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Construct prompt for the orchestrating Claude instance\n\t\tconst prompt = this.constructEnhancerPrompt(issueNumber, author)\n\n\t\t// Invoke Claude CLI with enhancer agent\n\t\tconst response = await launchClaude(prompt, {\n\t\t\theadless: true,\n\t\t\tmodel: 'sonnet',\n\t\t\tagents,\n\t\t\tnoSessionPersistence: true, // Headless operation - no session persistence needed\n\t\t\t...(mcpConfig && { mcpConfig }),\n\t\t\t...(allowedTools && { allowedTools }),\n\t\t\t...(disallowedTools && { disallowedTools }),\n\t\t})\n\n\t\t// Parse response to determine outcome\n\t\treturn this.parseEnhancerResponse(response)\n\t}\n\n\t/**\n\t * Construct the prompt for the orchestrating Claude instance.\n\t * This prompt is very clear about expected output format to ensure reliable parsing.\n\t */\n\tprivate constructEnhancerPrompt(issueNumber: string | number, author?: string): string {\n\t\tconst authorInstruction = author\n\t\t\t? `\\nIMPORTANT: When you create your analysis comment, tag @${author} in the \"Questions for Reporter\" section if you have questions.\\n`\n\t\t\t: ''\n\n\t\treturn `Execute @agent-iloom-issue-enhancer ${issueNumber}${authorInstruction}\n\n## OUTPUT REQUIREMENTS\n* If the issue was not enhanced, return ONLY: \"No enhancement needed\"\n* If the issue WAS enhanced, return ONLY: <FULL URL OF THE COMMENT INCLUDING COMMENT ID>\n* If you encounter permission/authentication/access errors, return ONLY: \"Permission denied: <specific error description>\"\n* IMPORTANT: Return ONLY one of the above - DO NOT include commentary such as \"I created a comment at <URL>\" or \"I examined the issue and found no enhancement was necessary\"\n* CONTEXT: Your output is going to be parsed programmatically, so adherence to the output requirements is CRITICAL.`\n\t}\n\n\t/**\n\t * Parse the response from the enhancer agent.\n\t * Returns either { enhanced: false } or { enhanced: true, url: \"...\" }\n\t * Throws specific errors for permission issues.\n\t */\n\tprivate parseEnhancerResponse(response: string | void): EnhanceExistingIssueResult {\n\t\t// Handle empty or void response\n\t\tif (!response || typeof response !== 'string') {\n\t\t\tthrow new Error('No response from enhancer agent')\n\t\t}\n\n\t\tconst trimmed = response.trim()\n\n\t\tgetLogger().debug(`RESPONSE FROM ENHANCER AGENT: '${trimmed}'`)\n\n\t\t// Check for permission denied errors (case-insensitive)\n\t\tif (trimmed.toLowerCase().startsWith('permission denied:')) {\n\t\t\tconst errorMessage = trimmed.substring('permission denied:'.length).trim()\n\t\t\tthrow new Error(`Permission denied: ${errorMessage}`)\n\t\t}\n\n\t\t// Check for \"No enhancement needed\" (case-insensitive)\n\t\tif (trimmed.toLowerCase().includes('no enhancement needed')) {\n\t\t\treturn { enhanced: false }\n\t\t}\n\n\t\t// Check if response looks like a GitHub comment URL\n\t\tconst urlPattern = /https:\\/\\/github\\.com\\/[^/]+\\/[^/]+\\/issues\\/\\d+#issuecomment-\\d+/\n\t\tconst match = trimmed.match(urlPattern)\n\n\t\tif (match) {\n\t\t\treturn { enhanced: true, url: match[0] }\n\t\t}\n\n\t\t// Unexpected response format\n\t\tthrow new Error(`Unexpected response from enhancer agent: ${trimmed}`)\n\t}\n}\n","/**\n * Capitalizes the first letter of a string.\n *\n * Override behavior: If the string starts with a space, it signals the user\n * wants to opt-out of auto-capitalization. In this case, the leading space\n * is stripped and the first letter is NOT capitalized.\n *\n * @param str - The string to process\n * @returns The processed string with first letter capitalized (or original if override)\n */\nexport function capitalizeFirstLetter(str: string): string {\n\t// Handle empty or whitespace-only strings\n\tif (!str || str.length === 0) {\n\t\treturn str\n\t}\n\n\t// Check for space-prefix override: strip leading space and return as-is\n\tif (str.startsWith(' ')) {\n\t\treturn str.slice(1)\n\t}\n\n\t// Find the first character that could be capitalized (a letter)\n\tconst firstChar = str.charAt(0)\n\n\t// If first character is a letter (including unicode), capitalize it\n\t// Check if toUpperCase() produces a different result (indicates it's a letter with case)\n\tconst upperChar = firstChar.toUpperCase()\n\tif (upperChar !== firstChar.toLowerCase() || /\\p{L}/u.test(firstChar)) {\n\t\t// Only capitalize if it actually changes (avoids issues with non-cased scripts)\n\t\tif (upperChar !== firstChar) {\n\t\t\treturn upperChar + str.slice(1)\n\t\t}\n\t}\n\n\t// Non-letter first character or no case transformation available: return unchanged\n\treturn str\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiCO,IAAM,0BAAN,MAA8B;AAAA,EACpC,YACS,qBACA,cACA,iBACP;AAHO;AACA;AACA;AAAA,EAGT;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,eAA6B;AACvC,WAAO,KAAK;AAAA,EACb;AAAA;AAAA;AAAA;AAAA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IACxC;AAGA,UAAM,IAAI,MAAM,4CAA4C,OAAO,EAAE;AAAA,EACtE;AACD;;;ACtSO,SAAS,sBAAsB,KAAqB;AAE1D,MAAI,CAAC,OAAO,IAAI,WAAW,GAAG;AAC7B,WAAO;AAAA,EACR;AAGA,MAAI,IAAI,WAAW,GAAG,GAAG;AACxB,WAAO,IAAI,MAAM,CAAC;AAAA,EACnB;AAGA,QAAM,YAAY,IAAI,OAAO,CAAC;AAI9B,QAAM,YAAY,UAAU,YAAY;AACxC,MAAI,cAAc,UAAU,YAAY,KAAK,WAAC,UAAM,GAAC,EAAC,KAAK,SAAS,GAAG;AAEtE,QAAI,cAAc,WAAW;AAC5B,aAAO,YAAY,IAAI,MAAM,CAAC;AAAA,IAC/B;AAAA,EACD;AAGA,SAAO;AACR;","names":[]}
|
|
@@ -1,107 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
extractPort,
|
|
7
|
-
findEnvFileContainingVariable,
|
|
8
|
-
logger,
|
|
9
|
-
parseEnvFile
|
|
10
|
-
} from "./chunk-VT4PDUYT.js";
|
|
11
|
-
|
|
12
|
-
// src/utils/port.ts
|
|
13
|
-
import { createHash } from "crypto";
|
|
14
|
-
import path from "path";
|
|
15
|
-
import fs from "fs-extra";
|
|
16
|
-
function wrapPort(rawPort, basePort) {
|
|
17
|
-
if (rawPort <= 65535) return rawPort;
|
|
18
|
-
const range = 65535 - basePort;
|
|
19
|
-
return (rawPort - basePort - 1) % range + basePort + 1;
|
|
20
|
-
}
|
|
21
|
-
function extractNumericSuffix(issueId) {
|
|
22
|
-
const match = issueId.match(/[-_]?(\d+)$/);
|
|
23
|
-
const digits = match == null ? void 0 : match[1];
|
|
24
|
-
if (digits === void 0) return null;
|
|
25
|
-
return parseInt(digits, 10);
|
|
26
|
-
}
|
|
27
|
-
function generatePortOffsetFromBranchName(branchName) {
|
|
28
|
-
if (!branchName || branchName.trim().length === 0) {
|
|
29
|
-
throw new Error("Branch name cannot be empty");
|
|
30
|
-
}
|
|
31
|
-
const hash = createHash("sha256").update(branchName).digest("hex");
|
|
32
|
-
const hashPrefix = hash.slice(0, 8);
|
|
33
|
-
const hashAsInt = parseInt(hashPrefix, 16);
|
|
34
|
-
const portOffset = hashAsInt % 999 + 1;
|
|
35
|
-
return portOffset;
|
|
36
|
-
}
|
|
37
|
-
function calculatePortForBranch(branchName, basePort = 3e3) {
|
|
38
|
-
const offset = generatePortOffsetFromBranchName(branchName);
|
|
39
|
-
const port = basePort + offset;
|
|
40
|
-
return wrapPort(port, basePort);
|
|
41
|
-
}
|
|
42
|
-
function calculatePortFromIdentifier(identifier, basePort = 3e3) {
|
|
43
|
-
if (typeof identifier === "number") {
|
|
44
|
-
return wrapPort(basePort + identifier, basePort);
|
|
45
|
-
}
|
|
46
|
-
const numericValue = parseInt(identifier, 10);
|
|
47
|
-
if (!isNaN(numericValue) && String(numericValue) === identifier) {
|
|
48
|
-
return wrapPort(basePort + numericValue, basePort);
|
|
49
|
-
}
|
|
50
|
-
const numericSuffix = extractNumericSuffix(identifier);
|
|
51
|
-
if (numericSuffix !== null) {
|
|
52
|
-
return wrapPort(basePort + numericSuffix, basePort);
|
|
53
|
-
}
|
|
54
|
-
return calculatePortForBranch(`issue-${identifier}`, basePort);
|
|
55
|
-
}
|
|
56
|
-
async function getWorkspacePort(options, dependencies) {
|
|
57
|
-
const basePort = options.basePort ?? 3e3;
|
|
58
|
-
const checkEnvFile = options.checkEnvFile ?? false;
|
|
59
|
-
if (checkEnvFile) {
|
|
60
|
-
const deps = {
|
|
61
|
-
fileExists: (dependencies == null ? void 0 : dependencies.fileExists) ?? ((p) => fs.pathExists(p)),
|
|
62
|
-
readFile: (dependencies == null ? void 0 : dependencies.readFile) ?? ((p) => fs.readFile(p, "utf8"))
|
|
63
|
-
};
|
|
64
|
-
const envFile = await findEnvFileContainingVariable(
|
|
65
|
-
options.worktreePath,
|
|
66
|
-
"PORT",
|
|
67
|
-
async (p) => deps.fileExists(p),
|
|
68
|
-
async (p, varName) => {
|
|
69
|
-
const content = await deps.readFile(p);
|
|
70
|
-
const envMap = parseEnvFile(content);
|
|
71
|
-
return envMap.get(varName) ?? null;
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
if (envFile) {
|
|
75
|
-
const envPath = path.join(options.worktreePath, envFile);
|
|
76
|
-
const envContent = await deps.readFile(envPath);
|
|
77
|
-
const envMap = parseEnvFile(envContent);
|
|
78
|
-
const port2 = extractPort(envMap);
|
|
79
|
-
if (port2) {
|
|
80
|
-
logger.debug(`Using PORT from ${envFile}: ${port2}`);
|
|
81
|
-
return port2;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
logger.debug("PORT not found in any dotenv-flow file, calculating from workspace identifier");
|
|
85
|
-
}
|
|
86
|
-
const dirName = path.basename(options.worktreePath);
|
|
87
|
-
const prPattern = /_pr_(\d+)$/;
|
|
88
|
-
const prMatch = dirName.match(prPattern);
|
|
89
|
-
if (prMatch == null ? void 0 : prMatch[1]) {
|
|
90
|
-
const prNumber = parseInt(prMatch[1], 10);
|
|
91
|
-
const port2 = calculatePortFromIdentifier(prNumber, basePort);
|
|
92
|
-
logger.debug(`Calculated PORT for PR #${prNumber}: ${port2}`);
|
|
93
|
-
return port2;
|
|
94
|
-
}
|
|
95
|
-
const issueId = extractIssueNumber(dirName) ?? extractIssueNumber(options.worktreeBranch);
|
|
96
|
-
if (issueId !== null) {
|
|
97
|
-
const port2 = calculatePortFromIdentifier(issueId, basePort);
|
|
98
|
-
logger.debug(`Calculated PORT for issue ${issueId}: ${port2}`);
|
|
99
|
-
return port2;
|
|
100
|
-
}
|
|
101
|
-
const port = calculatePortForBranch(options.worktreeBranch, basePort);
|
|
102
|
-
logger.debug(`Calculated PORT for branch "${options.worktreeBranch}": ${port}`);
|
|
103
|
-
return port;
|
|
104
|
-
}
|
|
3
|
+
calculatePortFromIdentifier
|
|
4
|
+
} from "./chunk-CFQVOTHO.js";
|
|
105
5
|
|
|
106
6
|
// src/lib/process/ProcessManager.ts
|
|
107
7
|
import { execa } from "execa";
|
|
@@ -277,9 +177,6 @@ var ProcessManager = class {
|
|
|
277
177
|
};
|
|
278
178
|
|
|
279
179
|
export {
|
|
280
|
-
calculatePortForBranch,
|
|
281
|
-
calculatePortFromIdentifier,
|
|
282
|
-
getWorkspacePort,
|
|
283
180
|
ProcessManager
|
|
284
181
|
};
|
|
285
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-WZYBHD7P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/process/ProcessManager.ts"],"sourcesContent":["import { execa } from 'execa'\nimport { setTimeout } from 'timers/promises'\nimport type { ProcessInfo, Platform } from '../../types/process.js'\nimport { calculatePortFromIdentifier } from '../../utils/port.js'\n\n/**\n * Manages process detection and termination across platforms\n * Ports dev server termination logic from bash/merge-and-clean.sh lines 1092-1148\n */\nexport class ProcessManager {\n\tprivate readonly platform: Platform\n\tprivate readonly basePort: number\n\n\tconstructor(basePort: number = 3000) {\n\t\tthis.basePort = basePort\n\t\tthis.platform = this.detectPlatform()\n\t}\n\n\t/**\n\t * Detect current platform\n\t */\n\tprivate detectPlatform(): Platform {\n\t\tswitch (process.platform) {\n\t\t\tcase 'darwin':\n\t\t\t\treturn 'darwin'\n\t\t\tcase 'linux':\n\t\t\t\treturn 'linux'\n\t\t\tcase 'win32':\n\t\t\t\treturn 'win32'\n\t\t\tdefault:\n\t\t\t\treturn 'unsupported'\n\t\t}\n\t}\n\n\t/**\n\t * Detect if a dev server is running on the specified port\n\t * Ports logic from merge-and-clean.sh lines 1107-1123\n\t */\n\tasync detectDevServer(port: number): Promise<ProcessInfo | null> {\n\t\tif (this.platform === 'unsupported') {\n\t\t\tthrow new Error('Process detection not supported on this platform')\n\t\t}\n\n\t\t// Use platform-specific detection\n\t\tif (this.platform === 'win32') {\n\t\t\treturn await this.detectOnPortWindows(port)\n\t\t} else {\n\t\t\treturn await this.detectOnPortUnix(port)\n\t\t}\n\t}\n\n\t/**\n\t * Unix/macOS implementation using lsof\n\t * Ports bash lines 1107-1123\n\t */\n\tprivate async detectOnPortUnix(port: number): Promise<ProcessInfo | null> {\n\t\ttry {\n\t\t\t// Run lsof to find process listening on port (LISTEN only)\n\t\t\tconst result = await execa('lsof', ['-i', `:${port}`, '-P'], {\n\t\t\t\treject: false,\n\t\t\t})\n\n\t\t\t// Filter for LISTEN state only\n\t\t\tconst lines = result.stdout.split('\\n').filter(line => line.includes('LISTEN'))\n\n\t\t\tif (lines.length === 0) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\t// Parse first LISTEN line\n\t\t\tconst firstLine = lines[0]\n\t\t\tif (!firstLine) return null\n\n\t\t\tconst parts = firstLine.split(/\\s+/)\n\t\t\tif (parts.length < 2) return null\n\n\t\t\tconst processName = parts[0] ?? ''\n\t\t\tconst pid = parseInt(parts[1] ?? '', 10)\n\n\t\t\tif (isNaN(pid)) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\t// Get full command line using ps\n\t\t\tconst psResult = await execa('ps', ['-p', pid.toString(), '-o', 'command='], {\n\t\t\t\treject: false,\n\t\t\t})\n\t\t\tconst fullCommand = psResult.stdout.trim()\n\n\t\t\t// Validate if this is a dev server\n\t\t\tconst isDevServer = this.isDevServerProcess(processName, fullCommand)\n\n\t\t\treturn {\n\t\t\t\tpid,\n\t\t\t\tname: processName,\n\t\t\t\tcommand: fullCommand,\n\t\t\t\tport,\n\t\t\t\tisDevServer,\n\t\t\t}\n\t\t} catch {\n\t\t\t// If lsof fails, assume no process on port\n\t\t\treturn null\n\t\t}\n\t}\n\n\t/**\n\t * Windows implementation using netstat and tasklist\n\t */\n\tprivate async detectOnPortWindows(port: number): Promise<ProcessInfo | null> {\n\t\ttry {\n\t\t\t// Use netstat to find PID listening on port\n\t\t\tconst result = await execa('netstat', ['-ano'], { reject: false })\n\t\t\tconst lines = result.stdout.split('\\n')\n\n\t\t\t// Find line with our port and LISTENING state\n\t\t\tconst portLine = lines.find(\n\t\t\t\tline => line.includes(`:${port}`) && line.includes('LISTENING')\n\t\t\t)\n\n\t\t\tif (!portLine) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\t// Extract PID (last column)\n\t\t\tconst parts = portLine.trim().split(/\\s+/)\n\t\t\tconst lastPart = parts[parts.length - 1]\n\t\t\tif (!lastPart) return null\n\n\t\t\tconst pid = parseInt(lastPart, 10)\n\n\t\t\tif (isNaN(pid)) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\t// Get process info using tasklist\n\t\t\tconst taskResult = await execa(\n\t\t\t\t'tasklist',\n\t\t\t\t['/FI', `PID eq ${pid}`, '/FO', 'CSV'],\n\t\t\t\t{\n\t\t\t\t\treject: false,\n\t\t\t\t}\n\t\t\t)\n\n\t\t\t// Parse CSV output\n\t\t\tconst lines2 = taskResult.stdout.split('\\n')\n\t\t\tif (lines2.length < 2) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tconst secondLine = lines2[1]\n\t\t\tif (!secondLine) return null\n\n\t\t\tconst parts2 = secondLine.split(',')\n\t\t\tconst processName = (parts2[0] ?? '').replace(/\"/g, '')\n\n\t\t\t// TODO: Get full command line on Windows (more complex)\n\t\t\tconst fullCommand = processName\n\n\t\t\tconst isDevServer = this.isDevServerProcess(processName, fullCommand)\n\n\t\t\treturn {\n\t\t\t\tpid,\n\t\t\t\tname: processName,\n\t\t\t\tcommand: fullCommand,\n\t\t\t\tport,\n\t\t\t\tisDevServer,\n\t\t\t}\n\t\t} catch {\n\t\t\treturn null\n\t\t}\n\t}\n\n\t/**\n\t * Validate if process is a dev server\n\t * Ports logic from merge-and-clean.sh lines 1121-1123\n\t */\n\tprivate isDevServerProcess(processName: string, command: string): boolean {\n\t\t// Check process name patterns\n\t\tconst devServerNames = /^(node|npm|pnpm|yarn|next|next-server|vite|webpack|dev-server)$/i\n\t\tif (devServerNames.test(processName)) {\n\t\t\t// Additional validation via command line\n\t\t\tconst devServerCommands =\n\t\t\t\t/(next dev|next-server|npm.*dev|pnpm.*dev|yarn.*dev|vite|webpack.*serve|turbo.*dev|dev.*server)/i\n\t\t\treturn devServerCommands.test(command)\n\t\t}\n\n\t\t// Check command line alone\n\t\tconst devServerCommands =\n\t\t\t/(next dev|next-server|npm.*dev|pnpm.*dev|yarn.*dev|vite|webpack.*serve|turbo.*dev|dev.*server)/i\n\t\treturn devServerCommands.test(command)\n\t}\n\n\t/**\n\t * Terminate a process by PID\n\t * Ports logic from merge-and-clean.sh lines 1126-1139\n\t */\n\tasync terminateProcess(pid: number): Promise<boolean> {\n\t\ttry {\n\t\t\tif (this.platform === 'win32') {\n\t\t\t\t// Windows: use taskkill\n\t\t\t\tawait execa('taskkill', ['/PID', pid.toString(), '/F'], { reject: true })\n\t\t\t} else {\n\t\t\t\t// Unix/macOS: use kill -9\n\t\t\t\tprocess.kill(pid, 'SIGKILL')\n\t\t\t}\n\n\t\t\t// Wait briefly for process to die\n\t\t\tawait setTimeout(1000)\n\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to terminate process ${pid}: ${error instanceof Error ? error.message : 'Unknown error'}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Verify that a port is free\n\t * Ports verification logic from merge-and-clean.sh lines 1135-1139\n\t */\n\tasync verifyPortFree(port: number): Promise<boolean> {\n\t\tconst processInfo = await this.detectDevServer(port)\n\t\treturn processInfo === null\n\t}\n\n\t/**\n\t * Calculate dev server port from issue/PR number\n\t * Ports logic from merge-and-clean.sh lines 1093-1098\n\t * Delegates to calculatePortFromIdentifier for the actual calculation.\n\t */\n\tcalculatePort(identifier: string | number): number {\n\t\treturn calculatePortFromIdentifier(identifier, this.basePort)\n\t}\n}\n"],"mappings":";;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAQpB,IAAM,iBAAN,MA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3
|
+
getRepoInfo
|
|
4
|
+
} from "./chunk-GCPAZSGV.js";
|
|
5
|
+
import {
|
|
6
|
+
logger
|
|
7
|
+
} from "./chunk-VT4PDUYT.js";
|
|
8
|
+
|
|
9
|
+
// src/utils/mcp.ts
|
|
10
|
+
import path from "path";
|
|
11
|
+
import os from "os";
|
|
12
|
+
async function generateIssueManagementMcpConfig(contextType, repo, provider = "github", settings, draftPrNumber) {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
const effectiveContextType = draftPrNumber ? "pr" : contextType;
|
|
15
|
+
let envVars = {
|
|
16
|
+
ISSUE_PROVIDER: provider
|
|
17
|
+
};
|
|
18
|
+
if (draftPrNumber) {
|
|
19
|
+
envVars.DRAFT_PR_NUMBER = String(draftPrNumber);
|
|
20
|
+
}
|
|
21
|
+
if (provider === "github") {
|
|
22
|
+
let owner;
|
|
23
|
+
let name;
|
|
24
|
+
if (repo) {
|
|
25
|
+
const parts = repo.split("/");
|
|
26
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
27
|
+
throw new Error(`Invalid repo format: ${repo}. Expected "owner/repo"`);
|
|
28
|
+
}
|
|
29
|
+
owner = parts[0];
|
|
30
|
+
name = parts[1];
|
|
31
|
+
} else {
|
|
32
|
+
const repoInfo = await getRepoInfo();
|
|
33
|
+
owner = repoInfo.owner;
|
|
34
|
+
name = repoInfo.name;
|
|
35
|
+
}
|
|
36
|
+
const githubEventName = effectiveContextType === "issue" ? "issues" : effectiveContextType === "pr" ? "pull_request" : void 0;
|
|
37
|
+
envVars = {
|
|
38
|
+
...envVars,
|
|
39
|
+
REPO_OWNER: owner,
|
|
40
|
+
REPO_NAME: name,
|
|
41
|
+
GITHUB_API_URL: "https://api.github.com/",
|
|
42
|
+
...githubEventName && { GITHUB_EVENT_NAME: githubEventName }
|
|
43
|
+
};
|
|
44
|
+
logger.debug("Generated MCP config for GitHub issue management", {
|
|
45
|
+
provider,
|
|
46
|
+
repoOwner: owner,
|
|
47
|
+
repoName: name,
|
|
48
|
+
contextType: effectiveContextType ?? "auto-detect",
|
|
49
|
+
githubEventName: githubEventName ?? "auto-detect",
|
|
50
|
+
draftPrNumber: draftPrNumber ?? void 0
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
const apiToken = ((_b = (_a = settings == null ? void 0 : settings.issueManagement) == null ? void 0 : _a.linear) == null ? void 0 : _b.apiToken) ?? process.env.LINEAR_API_TOKEN;
|
|
54
|
+
if (apiToken) {
|
|
55
|
+
envVars.LINEAR_API_TOKEN = apiToken;
|
|
56
|
+
}
|
|
57
|
+
const teamKey = ((_d = (_c = settings == null ? void 0 : settings.issueManagement) == null ? void 0 : _c.linear) == null ? void 0 : _d.teamId) ?? process.env.LINEAR_TEAM_KEY;
|
|
58
|
+
if (teamKey) {
|
|
59
|
+
envVars.LINEAR_TEAM_KEY = teamKey;
|
|
60
|
+
}
|
|
61
|
+
logger.debug("Generated MCP config for Linear issue management", {
|
|
62
|
+
provider,
|
|
63
|
+
hasApiToken: !!apiToken,
|
|
64
|
+
hasTeamKey: !!teamKey,
|
|
65
|
+
contextType: contextType ?? "auto-detect"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const mcpServerConfig = {
|
|
69
|
+
mcpServers: {
|
|
70
|
+
issue_management: {
|
|
71
|
+
transport: "stdio",
|
|
72
|
+
command: "node",
|
|
73
|
+
args: [path.join(path.dirname(new globalThis.URL(import.meta.url).pathname), "../dist/mcp/issue-management-server.js")],
|
|
74
|
+
env: envVars
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return [mcpServerConfig];
|
|
79
|
+
}
|
|
80
|
+
function slugifyPath(loomPath) {
|
|
81
|
+
let slug = loomPath.replace(/[/\\]+$/, "");
|
|
82
|
+
slug = slug.replace(/[/\\]/g, "___");
|
|
83
|
+
slug = slug.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
84
|
+
return `${slug}.json`;
|
|
85
|
+
}
|
|
86
|
+
function generateRecapMcpConfig(loomPath, loomMetadata) {
|
|
87
|
+
const recapsDir = path.join(os.homedir(), ".config", "iloom-ai", "recaps");
|
|
88
|
+
const recapFilePath = path.join(recapsDir, slugifyPath(loomPath));
|
|
89
|
+
const envVars = {
|
|
90
|
+
RECAP_FILE_PATH: recapFilePath,
|
|
91
|
+
LOOM_METADATA_JSON: JSON.stringify(loomMetadata)
|
|
92
|
+
};
|
|
93
|
+
logger.debug("Generated MCP config for recap server", {
|
|
94
|
+
loomPath,
|
|
95
|
+
recapFilePath,
|
|
96
|
+
loomMetadataDescription: loomMetadata.description
|
|
97
|
+
});
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
mcpServers: {
|
|
101
|
+
recap: {
|
|
102
|
+
transport: "stdio",
|
|
103
|
+
command: "node",
|
|
104
|
+
args: [
|
|
105
|
+
path.join(
|
|
106
|
+
path.dirname(new globalThis.URL(import.meta.url).pathname),
|
|
107
|
+
"../dist/mcp/recap-server.js"
|
|
108
|
+
)
|
|
109
|
+
],
|
|
110
|
+
env: envVars
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
generateIssueManagementMcpConfig,
|
|
119
|
+
generateRecapMcpConfig
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=chunk-XAMBIVXE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/mcp.ts"],"sourcesContent":["import path from 'path'\nimport os from 'os'\nimport { getRepoInfo } from './github.js'\nimport { logger } from './logger.js'\nimport type { IloomSettings } from '../lib/SettingsManager.js'\nimport type { LoomMetadata } from '../lib/MetadataManager.js'\n\n/**\n * Generate MCP configuration for issue management\n * Uses a single server that can handle both issues and pull requests\n * Returns array of MCP server config objects\n * @param contextType - Optional context type (issue or pr)\n * @param repo - Optional repo in \"owner/repo\" format. If not provided, will auto-detect from git.\n * @param provider - Issue management provider (default: 'github')\n * @param settings - Optional settings to extract Linear API token from\n * @param draftPrNumber - Optional draft PR number for github-draft-pr mode (routes comments to PR)\n */\nexport async function generateIssueManagementMcpConfig(\n\tcontextType?: 'issue' | 'pr',\n\trepo?: string,\n\tprovider: 'github' | 'linear' = 'github',\n\tsettings?: IloomSettings,\n\tdraftPrNumber?: number\n): Promise<Record<string, unknown>[]> {\n\t// When draftPrNumber is provided (github-draft-pr mode), force contextType to 'pr'\n\t// This ensures agents route comments to the draft PR instead of the issue\n\tconst effectiveContextType = draftPrNumber ? 'pr' : contextType\n\n\t// Build provider-specific environment variables\n\tlet envVars: Record<string, string> = {\n\t\tISSUE_PROVIDER: provider,\n\t}\n\n\t// Add draft PR number to env vars if provided\n\tif (draftPrNumber) {\n\t\tenvVars.DRAFT_PR_NUMBER = String(draftPrNumber)\n\t}\n\n\tif (provider === 'github') {\n\t\t// Get repository information for GitHub - either from provided repo string or auto-detect\n\t\tlet owner: string\n\t\tlet name: string\n\n\t\tif (repo) {\n\t\t\tconst parts = repo.split('/')\n\t\t\tif (parts.length !== 2 || !parts[0] || !parts[1]) {\n\t\t\t\tthrow new Error(`Invalid repo format: ${repo}. Expected \"owner/repo\"`)\n\t\t\t}\n\t\t\towner = parts[0]\n\t\t\tname = parts[1]\n\t\t} else {\n\t\t\tconst repoInfo = await getRepoInfo()\n\t\t\towner = repoInfo.owner\n\t\t\tname = repoInfo.name\n\t\t}\n\n\t\t// Map logical types to GitHub's webhook event names (handle GitHub's naming quirk here)\n\t\t// Use effectiveContextType which may be overridden by draftPrNumber\n\t\tconst githubEventName = effectiveContextType === 'issue' ? 'issues' : effectiveContextType === 'pr' ? 'pull_request' : undefined\n\n\t\tenvVars = {\n\t\t\t...envVars,\n\t\t\tREPO_OWNER: owner,\n\t\t\tREPO_NAME: name,\n\t\t\tGITHUB_API_URL: 'https://api.github.com/',\n\t\t\t...(githubEventName && { GITHUB_EVENT_NAME: githubEventName }),\n\t\t}\n\n\t\tlogger.debug('Generated MCP config for GitHub issue management', {\n\t\t\tprovider,\n\t\t\trepoOwner: owner,\n\t\t\trepoName: name,\n\t\t\tcontextType: effectiveContextType ?? 'auto-detect',\n\t\t\tgithubEventName: githubEventName ?? 'auto-detect',\n\t\t\tdraftPrNumber: draftPrNumber ?? undefined,\n\t\t})\n\t} else {\n\t\t// Linear needs API token passed through\n\t\tconst apiToken = settings?.issueManagement?.linear?.apiToken ?? process.env.LINEAR_API_TOKEN\n\n\t\tif (apiToken) {\n\t\t\tenvVars.LINEAR_API_TOKEN = apiToken\n\t\t}\n\n\t\t// Pass through LINEAR_TEAM_KEY from settings (primary) or env var (fallback)\n\t\t// Settings teamId is the preferred source as it's configured via `il init`\n\t\tconst teamKey = settings?.issueManagement?.linear?.teamId ?? process.env.LINEAR_TEAM_KEY\n\t\tif (teamKey) {\n\t\t\tenvVars.LINEAR_TEAM_KEY = teamKey\n\t\t}\n\n\t\tlogger.debug('Generated MCP config for Linear issue management', {\n\t\t\tprovider,\n\t\t\thasApiToken: !!apiToken,\n\t\t\thasTeamKey: !!teamKey,\n\t\t\tcontextType: contextType ?? 'auto-detect',\n\t\t})\n\t}\n\n\t// Generate single MCP server config\n\tconst mcpServerConfig = {\n\t\tmcpServers: {\n\t\t\tissue_management: {\n\t\t\t\ttransport: 'stdio',\n\t\t\t\tcommand: 'node',\n\t\t\t\targs: [path.join(path.dirname(new globalThis.URL(import.meta.url).pathname), '../dist/mcp/issue-management-server.js')],\n\t\t\t\tenv: envVars,\n\t\t\t},\n\t\t},\n\t}\n\n\treturn [mcpServerConfig]\n}\n\n/**\n * Reuse MetadataManager.slugifyPath() algorithm for recap file naming\n *\n * Algorithm:\n * 1. Trim trailing slashes\n * 2. Replace all path separators (/ or \\) with ___ (triple underscore)\n * 3. Replace any other non-alphanumeric characters (except _ and -) with -\n * 4. Append .json\n */\nfunction slugifyPath(loomPath: string): string {\n\tlet slug = loomPath.replace(/[/\\\\]+$/, '')\n\tslug = slug.replace(/[/\\\\]/g, '___')\n\tslug = slug.replace(/[^a-zA-Z0-9_-]/g, '-')\n\treturn `${slug}.json`\n}\n\n/**\n * Generate MCP configuration for recap server\n *\n * The recap server captures session context (goal, decisions, insights, risks, assumptions)\n * for the VS Code Loom Context Panel.\n *\n * @param loomPath - Absolute path to the loom workspace\n * @param loomMetadata - The loom metadata object (will be stringified as JSON)\n */\nexport function generateRecapMcpConfig(\n\tloomPath: string,\n\tloomMetadata: LoomMetadata\n): Record<string, unknown>[] {\n\t// Compute recap file path using slugifyPath algorithm (same as MetadataManager)\n\tconst recapsDir = path.join(os.homedir(), '.config', 'iloom-ai', 'recaps')\n\tconst recapFilePath = path.join(recapsDir, slugifyPath(loomPath))\n\n\t// Pass both env vars:\n\t// - RECAP_FILE_PATH: where to read/write recap data\n\t// - LOOM_METADATA_JSON: stringified loom metadata (parsed by MCP using LoomMetadata type)\n\tconst envVars = {\n\t\tRECAP_FILE_PATH: recapFilePath,\n\t\tLOOM_METADATA_JSON: JSON.stringify(loomMetadata),\n\t}\n\n\tlogger.debug('Generated MCP config for recap server', {\n\t\tloomPath,\n\t\trecapFilePath,\n\t\tloomMetadataDescription: loomMetadata.description,\n\t})\n\n\treturn [\n\t\t{\n\t\t\tmcpServers: {\n\t\t\t\trecap: {\n\t\t\t\t\ttransport: 'stdio',\n\t\t\t\t\tcommand: 'node',\n\t\t\t\t\targs: [\n\t\t\t\t\t\tpath.join(\n\t\t\t\t\t\t\tpath.dirname(new globalThis.URL(import.meta.url).pathname),\n\t\t\t\t\t\t\t'../dist/mcp/recap-server.js'\n\t\t\t\t\t\t),\n\t\t\t\t\t],\n\t\t\t\t\tenv: envVars,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t]\n}"],"mappings":";;;;;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AAgBf,eAAsB,iCACrB,aACA,MACA,WAAgC,UAChC,UACA,eACqC;AAvBtC;AA0BC,QAAM,uBAAuB,gBAAgB,OAAO;AAGpD,MA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launchClaude,
|
|
9
9
|
launchClaudeInNewTerminalWindow
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IGKPPACU.js";
|
|
11
11
|
import "./chunk-6MLEBAYZ.js";
|
|
12
12
|
import "./chunk-VT4PDUYT.js";
|
|
13
13
|
export {
|
|
@@ -19,4 +19,4 @@ export {
|
|
|
19
19
|
launchClaude,
|
|
20
20
|
launchClaudeInNewTerminalWindow
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=claude-
|
|
22
|
+
//# sourceMappingURL=claude-V4HRPR4Z.js.map
|
|
@@ -5,10 +5,11 @@ import {
|
|
|
5
5
|
EnvironmentManager,
|
|
6
6
|
LoomManager,
|
|
7
7
|
ResourceCleanup
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-77VLG2KP.js";
|
|
9
9
|
import {
|
|
10
10
|
ProcessManager
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-WZYBHD7P.js";
|
|
12
|
+
import "./chunk-CFQVOTHO.js";
|
|
12
13
|
import {
|
|
13
14
|
IdentifierParser
|
|
14
15
|
} from "./chunk-5V74K5ZA.js";
|
|
@@ -25,11 +26,13 @@ import {
|
|
|
25
26
|
SettingsManager
|
|
26
27
|
} from "./chunk-WFQ5CLTR.js";
|
|
27
28
|
import "./chunk-VWGKGNJP.js";
|
|
29
|
+
import "./chunk-USJSNHGG.js";
|
|
30
|
+
import "./chunk-GCPAZSGV.js";
|
|
28
31
|
import {
|
|
29
32
|
promptConfirmation
|
|
30
33
|
} from "./chunk-ZX3GTM7O.js";
|
|
31
34
|
import "./chunk-433MOLAU.js";
|
|
32
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-IGKPPACU.js";
|
|
33
36
|
import {
|
|
34
37
|
getLogger
|
|
35
38
|
} from "./chunk-6MLEBAYZ.js";
|
|
@@ -76,9 +79,9 @@ var CleanupCommand = class {
|
|
|
76
79
|
);
|
|
77
80
|
if (!this.loomManager) {
|
|
78
81
|
const { GitHubService } = await import("./GitHubService-O7U4UQ7N.js");
|
|
79
|
-
const { ClaudeContextManager } = await import("./ClaudeContextManager-
|
|
82
|
+
const { ClaudeContextManager } = await import("./ClaudeContextManager-Y2YJC6BU.js");
|
|
80
83
|
const { ProjectCapabilityDetector } = await import("./ProjectCapabilityDetector-IA56AUE6.js");
|
|
81
|
-
const { DefaultBranchNamingService } = await import("./BranchNamingService-
|
|
84
|
+
const { DefaultBranchNamingService } = await import("./BranchNamingService-AO7BPIUJ.js");
|
|
82
85
|
this.loomManager = new LoomManager(
|
|
83
86
|
this.gitWorktreeManager,
|
|
84
87
|
new GitHubService(),
|
|
@@ -481,4 +484,4 @@ var CleanupCommand = class {
|
|
|
481
484
|
export {
|
|
482
485
|
CleanupCommand
|
|
483
486
|
};
|
|
484
|
-
//# sourceMappingURL=cleanup-
|
|
487
|
+
//# sourceMappingURL=cleanup-DB7EFBF3.js.map
|