@iloom/cli 0.12.0 → 0.12.1
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 +1 -1
- package/dist/README.md +1 -1
- package/dist/{chunk-IS46GQRA.js → chunk-DY6MUWQW.js} +5 -5
- package/dist/chunk-DY6MUWQW.js.map +1 -0
- package/dist/{chunk-PDG74IJT.js → chunk-UVXB6O24.js} +8 -27
- package/dist/chunk-UVXB6O24.js.map +1 -0
- package/dist/{chunk-JD3K2344.js → chunk-Y2MVSEJK.js} +31 -1
- package/dist/chunk-Y2MVSEJK.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/{feedback-I6ZEHEUB.js → feedback-RFWGB4I5.js} +2 -2
- package/dist/{ignite-XZFYRVRJ.js → ignite-X2NNTNUN.js} +3 -3
- package/dist/{init-A6WRP77L.js → init-LWU2M53W.js} +2 -2
- package/dist/{plan-PL3ZB32J.js → plan-5S6355GF.js} +27 -38
- package/dist/plan-5S6355GF.js.map +1 -0
- package/dist/prompts/plan-prompt.txt +31 -6
- package/package.json +1 -1
- package/dist/chunk-IS46GQRA.js.map +0 -1
- package/dist/chunk-JD3K2344.js.map +0 -1
- package/dist/chunk-PDG74IJT.js.map +0 -1
- package/dist/plan-PL3ZB32J.js.map +0 -1
- /package/dist/{feedback-I6ZEHEUB.js.map → feedback-RFWGB4I5.js.map} +0 -0
- /package/dist/{ignite-XZFYRVRJ.js.map → ignite-X2NNTNUN.js.map} +0 -0
- /package/dist/{init-A6WRP77L.js.map → init-LWU2M53W.js.map} +0 -0
package/LICENSE
CHANGED
|
@@ -20,7 +20,7 @@ it within your organization. What is prohibited is redistributing or offering
|
|
|
20
20
|
access to this software (in original or modified form) as part of something
|
|
21
21
|
you sell or provide to others.
|
|
22
22
|
|
|
23
|
-
Change Date: 2030-03-
|
|
23
|
+
Change Date: 2030-03-11
|
|
24
24
|
Change License: Apache License 2.0
|
|
25
25
|
|
|
26
26
|
For clarity, on or after the Change Date, the Licensed Work will
|
package/README.md
CHANGED
|
@@ -880,7 +880,7 @@ License & Name
|
|
|
880
880
|
|
|
881
881
|
* ❌ You cannot resell iloom itself as a product or SaaS.
|
|
882
882
|
|
|
883
|
-
* Converts to Apache 2.0 on 2030-03-
|
|
883
|
+
* Converts to Apache 2.0 on 2030-03-11.
|
|
884
884
|
|
|
885
885
|
|
|
886
886
|
See [LICENSE](https://raw.githubusercontent.com/iloom-ai/iloom-cli/main/LICENSE) for complete terms.
|
package/dist/README.md
CHANGED
|
@@ -880,7 +880,7 @@ License & Name
|
|
|
880
880
|
|
|
881
881
|
* ❌ You cannot resell iloom itself as a product or SaaS.
|
|
882
882
|
|
|
883
|
-
* Converts to Apache 2.0 on 2030-03-
|
|
883
|
+
* Converts to Apache 2.0 on 2030-03-11.
|
|
884
884
|
|
|
885
885
|
|
|
886
886
|
See [LICENSE](https://raw.githubusercontent.com/iloom-ai/iloom-cli/main/LICENSE) for complete terms.
|
|
@@ -148,7 +148,7 @@ async function launchFirstRunSetup() {
|
|
|
148
148
|
logger.info("");
|
|
149
149
|
logger.info("iloom will now launch an interactive configuration session with Claude.");
|
|
150
150
|
await waitForKeypress("Press any key to start configuration...");
|
|
151
|
-
const { InitCommand } = await import("./init-
|
|
151
|
+
const { InitCommand } = await import("./init-LWU2M53W.js");
|
|
152
152
|
const initCommand = new InitCommand();
|
|
153
153
|
await initCommand.execute(
|
|
154
154
|
"Help me configure iloom settings for this project. This is my first time using iloom here. Note: Your iloom command will execute once we are done with configuration changes."
|
|
@@ -248,7 +248,7 @@ var StartCommand = class {
|
|
|
248
248
|
}
|
|
249
249
|
const loomManager = await this.initializeLoomManager();
|
|
250
250
|
let parentLoom = await this.detectParentLoom(loomManager);
|
|
251
|
-
const parsed = await this.parseInput(input.identifier, repo);
|
|
251
|
+
const parsed = await this.parseInput(input.identifier, repo, input.options);
|
|
252
252
|
await this.validateInput(parsed, repo);
|
|
253
253
|
if (parentLoom) {
|
|
254
254
|
const parentDisplay = parentLoom.type === "issue" ? `issue #${parentLoom.identifier}` : parentLoom.type === "pr" ? `PR #${parentLoom.identifier}` : `branch ${parentLoom.identifier}`;
|
|
@@ -457,14 +457,14 @@ var StartCommand = class {
|
|
|
457
457
|
/**
|
|
458
458
|
* Parse input to determine type and extract relevant data
|
|
459
459
|
*/
|
|
460
|
-
async parseInput(identifier, repo) {
|
|
460
|
+
async parseInput(identifier, repo, options) {
|
|
461
461
|
const hasLeadingSpace = identifier.startsWith(" ");
|
|
462
462
|
const trimmedIdentifier = identifier.trim();
|
|
463
463
|
if (!trimmedIdentifier) {
|
|
464
464
|
throw new Error("Missing required argument: identifier");
|
|
465
465
|
}
|
|
466
466
|
const spaceCount = (trimmedIdentifier.match(/ /g) ?? []).length;
|
|
467
|
-
if (trimmedIdentifier.length > 15 && spaceCount >= 1) {
|
|
467
|
+
if (trimmedIdentifier.length > 15 && spaceCount >= 1 || (options == null ? void 0 : options.body) && spaceCount >= 1) {
|
|
468
468
|
return {
|
|
469
469
|
type: "description",
|
|
470
470
|
originalInput: hasLeadingSpace ? " " + trimmedIdentifier : trimmedIdentifier
|
|
@@ -672,4 +672,4 @@ export {
|
|
|
672
672
|
launchFirstRunSetup,
|
|
673
673
|
StartCommand
|
|
674
674
|
};
|
|
675
|
-
//# sourceMappingURL=chunk-
|
|
675
|
+
//# sourceMappingURL=chunk-DY6MUWQW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/first-run-setup.ts","../src/commands/start.ts"],"sourcesContent":["import { existsSync } from 'fs'\nimport { readFile } from 'fs/promises'\nimport path from 'path'\nimport chalk from 'chalk'\nimport { logger } from './logger.js'\nimport { FirstRunManager } from './FirstRunManager.js'\nimport { getRepoRoot } from './git.js'\nimport { promptConfirmation, waitForKeypress } from './prompt.js'\n\n/**\n * Get the project root path for first-run tracking\n * Uses git repo root if available, otherwise falls back to cwd\n * This ensures consistent path resolution regardless of where the CLI is run from\n */\nasync function getProjectRoot(): Promise<string> {\n\tconst repoRoot = await getRepoRoot()\n\tif (repoRoot) {\n\t\tlogger.debug(`getProjectRoot: Using git repo root: ${repoRoot}`)\n\t\treturn repoRoot\n\t}\n\tconst cwd = process.cwd()\n\tlogger.debug(`getProjectRoot: Not in git repo, using cwd: ${cwd}`)\n\treturn cwd\n}\n\n/**\n * Check if project needs first-run setup\n * Returns true if:\n * 1. Project is not tracked as configured globally AND\n * 2. .iloom directory is missing or settings files are empty\n *\n * Uses git repo root for path resolution to ensure consistent behavior\n * regardless of whether the CLI is run from a subdirectory or worktree\n */\nexport async function needsFirstRunSetup(): Promise<boolean> {\n\tconst projectRoot = await getProjectRoot()\n\tconst firstRunManager = new FirstRunManager()\n\n\t// Check if project is tracked as configured globally\n\tconst isConfigured = await firstRunManager.isProjectConfigured(projectRoot)\n\tif (isConfigured) {\n\t\tlogger.debug('needsFirstRunSetup: Project is tracked as configured globally')\n\t\treturn false\n\t}\n\n\tconst iloomDir = path.join(projectRoot, '.iloom')\n\n\t// Check if .iloom directory exists\n\tif (!existsSync(iloomDir)) {\n\t\treturn true\n\t}\n\n\t// Check if either settings file has meaningful content\n\tconst settingsPath = path.join(iloomDir, 'settings.json')\n\tconst settingsLocalPath = path.join(iloomDir, 'settings.local.json')\n\n\tconst hasSettings = await hasNonEmptySettings(settingsPath)\n\tconst hasLocalSettings = await hasNonEmptySettings(settingsLocalPath)\n\n\treturn !hasSettings && !hasLocalSettings\n}\n\nasync function hasNonEmptySettings(filePath: string): Promise<boolean> {\n\tif (!existsSync(filePath)) return false\n\ttry {\n\t\tconst content = await readFile(filePath, 'utf-8')\n\t\tconst parsed = JSON.parse(content)\n\t\treturn Object.keys(parsed).length > 0\n\t} catch {\n\t\treturn false\n\t}\n}\n\n/**\n * Display default configuration values in a formatted box\n */\nfunction displayDefaultsBox(): void {\n\tlogger.info(chalk.bold('Default Configuration:'))\n\tlogger.info('')\n\tlogger.info(` ${chalk.cyan('Main Branch:')} main`)\n\tlogger.info(` ${chalk.cyan('IDE:')} vscode`)\n\tlogger.info(` ${chalk.cyan('Issue Tracker:')} GitHub Issues`)\n\tlogger.info(` ${chalk.cyan('Merge Mode:')} local ${chalk.dim('(merge locally)')}`)\n\tlogger.info(` ${chalk.cyan('Base Port:')} 3000`)\n}\n\n/**\n * Launch interactive first-run setup via InitCommand\n * Shows defaults first, allows quick acceptance or full wizard\n */\nexport async function launchFirstRunSetup(): Promise<void> {\n\tlogger.info('First-time project setup detected.')\n\tlogger.info('')\n\n\t// Display the defaults\n\tdisplayDefaultsBox()\n\n\tlogger.info('')\n\n\t// Import prompt utility\n\n\t// Ask if defaults are OK (default to Yes)\n\tconst acceptDefaults = await promptConfirmation(\n\t\t'Are these defaults OK?',\n\t\ttrue // default to true, so Enter accepts\n\t)\n\n\tif (acceptDefaults) {\n\t\t// User accepted defaults - just mark as configured\n\t\tconst projectRoot = await getProjectRoot()\n\t\tconst firstRunManager = new FirstRunManager()\n\t\tawait firstRunManager.markProjectAsConfigured(projectRoot)\n\t\tlogger.info(chalk.green('Configuration complete! Using defaults.'))\n\t\tlogger.info('You can run `il init` anytime to customize settings.')\n\t\treturn\n\t}\n\n\t// User declined - launch full wizard\n\tlogger.info('')\n\tlogger.info('iloom will now launch an interactive configuration session with Claude.')\n\n\tawait waitForKeypress('Press any key to start configuration...')\n\n\tconst { InitCommand } = await import('../commands/init.js')\n\tconst initCommand = new InitCommand()\n\tawait initCommand.execute(\n\t\t'Help me configure iloom settings for this project. This is my first time using iloom here. Note: Your iloom command will execute once we are done with configuration changes.'\n\t)\n\t// Note: InitCommand.execute() now handles markProjectAsConfigured() internally\n\t// when the guided init completes successfully\n\n\tlogger.info('Configuration complete! Continuing with your original command...')\n}\n","import path from 'path'\nimport { getLogger } from '../utils/logger-context.js'\nimport type { IssueTracker } from '../lib/IssueTracker.js'\nimport { GitHubService } from '../lib/GitHubService.js'\nimport { LoomManager } from '../lib/LoomManager.js'\nimport { DefaultBranchNamingService } from '../lib/BranchNamingService.js'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { EnvironmentManager } from '../lib/EnvironmentManager.js'\nimport { ClaudeContextManager } from '../lib/ClaudeContextManager.js'\nimport { ProjectCapabilityDetector } from '../lib/ProjectCapabilityDetector.js'\nimport { CLIIsolationManager } from '../lib/CLIIsolationManager.js'\nimport { SettingsManager } from '../lib/SettingsManager.js'\nimport { AgentManager } from '../lib/AgentManager.js'\nimport { DatabaseManager } from '../lib/DatabaseManager.js'\nimport { findMainWorktreePathWithSettings } from '../utils/git.js'\nimport { matchIssueIdentifier } from '../utils/IdentifierParser.js'\nimport { loadEnvIntoProcess } from '../utils/env.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport { createNeonProviderFromSettings } from '../utils/neon-helpers.js'\nimport { getConfiguredRepoFromSettings, hasMultipleRemotes } from '../utils/remote.js'\nimport { capitalizeFirstLetter } from '../utils/text.js'\nimport type { StartOptions, StartResult } from '../types/index.js'\nimport { fetchChildIssues, fetchChildIssueDetails } from '../utils/list-children.js'\nimport { buildDependencyMap } from '../utils/dependency-map.js'\nimport { IssueTrackerFactory } from '../lib/IssueTrackerFactory.js'\nimport { launchFirstRunSetup, needsFirstRunSetup } from '../utils/first-run-setup.js'\nimport { isInteractiveEnvironment, promptConfirmation } from '../utils/prompt.js'\nimport { TelemetryService } from '../lib/TelemetryService.js'\nimport type { LoomCreatedProperties } from '../types/telemetry.js'\nimport { resolveRecapFilePath, readRecapFile, writeRecapFile } from '../utils/mcp.js'\n\nexport interface StartCommandInput {\n\tidentifier: string\n\toptions: StartOptions\n}\n\nexport interface ParsedInput {\n\ttype: 'issue' | 'pr' | 'branch' | 'description' | 'epic'\n\tnumber?: string | number\n\tbranchName?: string\n\toriginalInput: string\n}\n\nexport class StartCommand {\n\tprivate issueTracker: IssueTracker\n\tprivate loomManager: LoomManager | null = null\n\tprivate settingsManager: SettingsManager\n\tprivate providedLoomManager: LoomManager | undefined\n\tprivate githubService: GitHubService | null = null\n\n\tconstructor(\n\t\tissueTracker: IssueTracker,\n\t\tloomManager?: LoomManager,\n\t\t_agentManager?: AgentManager, // Kept for API compatibility\n\t\tsettingsManager?: SettingsManager\n\t) {\n\t\tthis.issueTracker = issueTracker\n\t\tthis.settingsManager = settingsManager ?? new SettingsManager()\n\t\t// Store provided LoomManager for testing, but don't initialize yet\n\t\tthis.providedLoomManager = loomManager\n\n\t\t// Load environment variables first\n\t\tconst envResult = loadEnvIntoProcess()\n\t\tif (envResult.error) {\n\t\t\tgetLogger().debug(`Environment loading warning: ${envResult.error.message}`)\n\t\t}\n\t\tif (envResult.parsed) {\n\t\t\tgetLogger().debug(`Loaded ${Object.keys(envResult.parsed).length} environment variables`)\n\t\t}\n\t}\n\n\t/**\n\t * Get or create a GitHubService instance for PR operations\n\t * Used when the configured issue tracker doesn't support PRs (e.g., Linear)\n\t */\n\tprivate getGitHubService(): GitHubService {\n\t\tthis.githubService ??= new GitHubService()\n\t\treturn this.githubService\n\t}\n\n\t/**\n\t * Initialize LoomManager with the main worktree path\n\t * Uses lazy initialization to ensure we have the correct path\n\t */\n\tprivate async initializeLoomManager(): Promise<LoomManager> {\n\t\tif (this.loomManager) {\n\t\t\treturn this.loomManager\n\t\t}\n\n\t\tif (this.providedLoomManager) {\n\t\t\tthis.loomManager = this.providedLoomManager\n\t\t\treturn this.loomManager\n\t\t}\n\n\t\t// Find main worktree path\n\t\tconst mainWorktreePath = await findMainWorktreePathWithSettings()\n\n\t\t// Load settings to get database configuration\n\t\tconst settings = await this.settingsManager.loadSettings()\n\n\t\t// Create DatabaseManager with NeonProvider and EnvironmentManager\n\t\tconst environmentManager = new EnvironmentManager()\n\t\tconst neonProvider = createNeonProviderFromSettings(settings)\n\t\tconst databaseUrlEnvVarName = settings.capabilities?.database?.databaseUrlEnvVarName ?? 'DATABASE_URL'\n\n\t\tconst databaseManager = new DatabaseManager(neonProvider, environmentManager, databaseUrlEnvVarName)\n\n\t\t// Create BranchNamingService (defaults to Claude-based strategy)\n\t\tconst branchNaming = new DefaultBranchNamingService({ useClaude: true })\n\n\t\tthis.loomManager = new LoomManager(\n\t\t\tnew GitWorktreeManager(mainWorktreePath),\n\t\t\tthis.issueTracker,\n\t\t\tbranchNaming, // Add branch naming service\n\t\t\tenvironmentManager, // Reuse same instance\n\t\t\tnew ClaudeContextManager(),\n\t\t\tnew ProjectCapabilityDetector(),\n\t\t\tnew CLIIsolationManager(),\n\t\t\tthis.settingsManager, // Use same instance with CLI overrides\n\t\t\tdatabaseManager // Add database manager\n\t\t)\n\n\t\treturn this.loomManager\n\t}\n\n\t/**\n\t * Main entry point for the start command\n\t */\n\tpublic async execute(input: StartCommandInput): Promise<StartResult | void> {\n\t\tconst isJsonMode = input.options.json === true\n\n\t\t// Handle --create-only flag: disable all launch components\n\t\tif (input.options.createOnly) {\n\t\t\tinput.options.claude = false\n\t\t\tinput.options.code = false\n\t\t\tinput.options.devServer = false\n\t\t\tinput.options.terminal = false\n\t\t}\n\n\t\ttry {\n\t\t\t// Step 0: Load settings and get configured repo for GitHub operations\n\t\t\tconst initialSettings = await this.settingsManager.loadSettings()\n\n\t\t\t// Skip first-run setup in JSON mode\n\t\t\tif (!isJsonMode && (process.env.FORCE_FIRST_TIME_SETUP === \"true\" || await needsFirstRunSetup())) {\n\t\t\t\tawait launchFirstRunSetup()\n\t\t\t\t// Reload settings and recreate issueTracker if provider changed during setup\n\t\t\t\tconst newSettings = await this.settingsManager.loadSettings()\n\t\t\t\tconst newProvider = newSettings.issueManagement?.provider ?? 'github'\n\t\t\t\tif (newProvider !== this.issueTracker.providerName) {\n\t\t\t\t\tgetLogger().debug(`Reinitializing issue tracker: provider changed to \"${newProvider}\"`)\n\t\t\t\t\tthis.issueTracker = IssueTrackerFactory.create(newSettings)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet repo: string | undefined\n\n\t\t\t// Only get repo if we have multiple remotes (prehook already validated config)\n\t\t\tif (this.issueTracker.providerName === 'github' && (await hasMultipleRemotes())) {\n\t\t\t\t// Only relevant for GitHub - Linear doesn't use repo info\n\t\t\t\trepo = await getConfiguredRepoFromSettings(initialSettings)\n\t\t\t\tgetLogger().info(`Using GitHub repository: ${repo}`)\n\t\t\t}\n\n\t\t\t// Step 0.5: Initialize LoomManager with main worktree path\n\t\t\tconst loomManager = await this.initializeLoomManager()\n\n\t\t\t// Step 0.6: Detect if running from inside an existing loom (for nested loom support)\n\t\t\tlet parentLoom = await this.detectParentLoom(loomManager)\n\n\t\t\t// Step 1: Parse and validate input (pass repo to methods)\n\t\t\tconst parsed = await this.parseInput(input.identifier, repo, input.options)\n\n\t\t\t// Step 2: Validate based on type\n\t\t\tawait this.validateInput(parsed, repo)\n\n\t\t\t// Step 2.4: Handle child loom decision\n\t\t\tif (parentLoom) {\n\n\t\t\t\t// Format display message based on parent type\n\t\t\t\tconst parentDisplay = parentLoom.type === 'issue'\n\t\t\t\t\t? `issue #${parentLoom.identifier}`\n\t\t\t\t\t: parentLoom.type === 'pr'\n\t\t\t\t\t? `PR #${parentLoom.identifier}`\n\t\t\t\t\t: `branch ${parentLoom.identifier}`\n\n\t\t\t\t// Check for explicit flag first\n\t\t\t\tif (input.options.childLoom === true) {\n\t\t\t\t\t// --child-loom flag: force child loom (no prompt)\n\t\t\t\t\tgetLogger().info(`Creating as child loom of ${parentDisplay} (--child-loom flag)`)\n\t\t\t\t} else if (input.options.childLoom === false) {\n\t\t\t\t\t// --no-child-loom flag: force independent (no prompt)\n\t\t\t\t\tparentLoom = null\n\t\t\t\t\tgetLogger().info('Creating as independent loom (--no-child-loom flag)')\n\t\t\t\t} else {\n\t\t\t\t\t// No flag: use existing behavior (prompt or error if non-interactive)\n\t\t\t\t\t// JSON mode requires explicit flag\n\t\t\t\t\tif (isJsonMode) {\n\t\t\t\t\t\tthrow new Error('JSON mode requires explicit --child-loom or --no-child-loom flag when running from inside a loom')\n\t\t\t\t\t}\n\t\t\t\t\tlet createAsChild = true // Default for non-interactive\n\t\t\t\t\tif (isInteractiveEnvironment()) {\n\t\t\t\t\t\tcreateAsChild = await promptConfirmation(\n\t\t\t\t\t\t\t`You are not in your main worktree. Create as a child loom of ${parentDisplay}?`,\n\t\t\t\t\t\t\ttrue // Default yes\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error('Non-interactive environment detected, use either --child-loom or --no-child-loom to specify behavior')\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!createAsChild) {\n\t\t\t\t\t\tparentLoom = null // User declined, proceed as normal loom\n\t\t\t\t\t\tgetLogger().info('Creating as independent loom')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (input.options.childLoom === true) {\n\t\t\t\t// --child-loom flag but not in a parent loom - ignore silently (per requirements)\n\t\t\t\tgetLogger().debug('--child-loom flag provided but not running from inside an existing loom (ignored)')\n\t\t\t}\n\t\t\t// Note: --no-child-loom when no parent is a no-op (already independent)\n\n\t\t\t// Step 2.5: Handle description input - create issue\n\t\t\tif (parsed.type === 'description') {\n\t\t\t\tgetLogger().info('Creating issue from description...')\n\t\t\t\t// Apply first-letter capitalization to title and body\n\t\t\t\tconst title = capitalizeFirstLetter(parsed.originalInput)\n\t\t\t\tconst body = input.options.body ? capitalizeFirstLetter(input.options.body) : \"\"\n\t\t\t\tconst result = await this.issueTracker.createIssue(\n\t\t\t\t\ttitle, // Use capitalized description as title\n\t\t\t\t\tbody // Use capitalized body or empty\n\t\t\t\t)\n\t\t\t\tgetLogger().success(`Created issue #${result.number}: ${result.url}`)\n\t\t\t\t// Update parsed to be an issue type with the new number\n\t\t\t\tparsed.type = 'issue'\n\t\t\t\tparsed.number = result.number\n\t\t\t}\n\n\t\t\t// Step 2.6: Detect epic (issue with child issues) and handle --epic/--no-epic flags\n\t\t\tlet childIssueNumbers: string[] = []\n\t\t\tlet childIssues: Array<{ number: string; title: string; body: string; url: string }> = []\n\t\t\tlet dependencyMap: Record<string, string[]> = {}\n\n\t\t\tif (parsed.type === 'issue' && parsed.number) {\n\t\t\t\tconst settings = await this.settingsManager.loadSettings()\n\t\t\t\tconst epicIssueTracker = IssueTrackerFactory.create(settings)\n\t\t\t\tlet children: Awaited<ReturnType<typeof fetchChildIssues>> = []\n\t\t\t\ttry {\n\t\t\t\t\tchildren = await fetchChildIssues(String(parsed.number), epicIssueTracker, repo)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tgetLogger().warn(`Failed to check for child issues: ${error instanceof Error ? error.message : 'Unknown error'}. Proceeding as normal loom.`)\n\t\t\t\t}\n\n\t\t\t\tif (children.length > 0) {\n\t\t\t\t\tchildIssueNumbers = children.map(c => c.id)\n\t\t\t\t\tlet createAsEpic = false\n\n\t\t\t\t\tif (input.options.epic === true) {\n\t\t\t\t\t\t// --epic flag: force epic mode (no prompt)\n\t\t\t\t\t\tcreateAsEpic = true\n\t\t\t\t\t\tgetLogger().info(`Creating as epic loom with ${children.length} child issue(s) (--epic flag)`)\n\t\t\t\t\t} else if (input.options.epic === false) {\n\t\t\t\t\t\t// --no-epic flag: proceed as normal loom (no prompt)\n\t\t\t\t\t\tcreateAsEpic = false\n\t\t\t\t\t\tgetLogger().info('Creating as normal loom (--no-epic flag)')\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No flag: prompt or error\n\t\t\t\t\t\tif (isJsonMode) {\n\t\t\t\t\t\t\tthrow new Error('JSON mode requires explicit --epic or --no-epic flag when issue has child issues')\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (isInteractiveEnvironment()) {\n\t\t\t\t\t\t\tcreateAsEpic = await promptConfirmation(\n\t\t\t\t\t\t\t\t`This issue has ${children.length} child issue(s). Create as epic loom?`,\n\t\t\t\t\t\t\t\ttrue // Default yes\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new Error('Non-interactive environment detected, use either --epic or --no-epic to specify behavior')\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (createAsEpic) {\n\t\t\t\t\t\tparsed.type = 'epic'\n\n\t\t\t\t\t\t// Fetch rich child issue details and dependency map for epic metadata\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst [details, depMap] = await Promise.all([\n\t\t\t\t\t\t\t\tfetchChildIssueDetails(String(parsed.number), epicIssueTracker, repo),\n\t\t\t\t\t\t\t\tbuildDependencyMap(childIssueNumbers, settings, repo),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t\tchildIssues = details ?? []\n\t\t\t\t\t\t\tdependencyMap = depMap ?? {}\n\t\t\t\t\t\t\tgetLogger().info(`Fetched ${childIssues.length} child issue details and dependency map`)\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t// Revert to issue type since child data fetch failed\n\t\t\t\t\t\t\t// il spin needs child data to enter swarm mode, so an epic without it would be broken\n\t\t\t\t\t\t\tparsed.type = 'issue'\n\t\t\t\t\t\t\tchildIssueNumbers = []\n\t\t\t\t\t\t\tgetLogger().warn(`Failed to fetch epic child data, reverting to normal loom: ${error instanceof Error ? error.message : String(error)}`)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Not creating as epic, clear child issue numbers\n\t\t\t\t\t\tchildIssueNumbers = []\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// --epic or --no-epic flags are silently ignored when there are no child issues\n\t\t\t}\n\n\t\t\t// Step 2.7: Confirm bypassPermissions mode if applicable\n\t\t\t// Only prompt in interactive mode when Claude is enabled.\n\t\t\t// Skip when: --no-claude (Claude won't launch now), JSON mode (non-interactive).\n\t\t\t// The explicit --one-shot=bypassPermissions flag is sufficient intent.\n\t\t\t// The warning is shown again when Claude launches via 'il spin'.\n\t\t\tif (input.options.oneShot === 'bypassPermissions' && input.options.claude !== false && !isJsonMode) {\n\t\t\t\tconst confirmed = await promptConfirmation(\n\t\t\t\t\t'WARNING: bypassPermissions mode will allow Claude to execute all tool calls without confirmation. ' +\n\t\t\t\t\t'This can be dangerous. Do you want to proceed?'\n\t\t\t\t)\n\t\t\t\tif (!confirmed) {\n\t\t\t\t\tgetLogger().info('Operation cancelled by user')\n\t\t\t\t\tprocess.exit(0)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step 2.8: Load workflow-specific settings with CLI overrides\n\t\t\tconst cliOverrides = extractSettingsOverrides()\n\t\t\tconst settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\t\tconst workflowType = parsed.type === 'branch' ? 'regular' : parsed.type === 'epic' ? 'issue' : parsed.type\n\t\t\tconst workflowConfig = settings.workflows?.[workflowType]\n\n\t\t\t// Step 2.9: Extract raw --set arguments and executable path for forwarding to spin\n\t\t\tconst { extractRawSetArguments, getExecutablePath } = await import('../utils/cli-overrides.js')\n\t\t\tconst setArguments = extractRawSetArguments()\n\t\t\tconst executablePath = getExecutablePath()\n\n\t\t\t// Step 3: Log success and create loom\n\t\t\tgetLogger().info(`Validated input: ${this.formatParsedInput(parsed)}`)\n\n\t\t\t// Step 4: Create loom using LoomManager\n\t\t\tconst identifier =\n\t\t\t\tparsed.type === 'branch'\n\t\t\t\t\t? parsed.branchName ?? ''\n\t\t\t\t\t: parsed.number ?? 0\n\n\t\t\t// Apply configuration precedence: CLI flags > workflow config > defaults (true)\n\t\t\tconst enableClaude = input.options.claude ?? workflowConfig?.startAiAgent ?? true\n\t\t\tconst enableCode = input.options.code ?? workflowConfig?.startIde ?? true\n\t\t\tconst enableDevServer = input.options.devServer ?? workflowConfig?.startDevServer ?? true\n\t\t\tconst enableTerminal = input.options.terminal ?? workflowConfig?.startTerminal ?? false\n\n\t\t\tgetLogger().debug('Final workflow config values:', {\n\t\t\t\tenableClaude,\n\t\t\t\tenableCode,\n\t\t\t\tenableDevServer,\n\t\t\t\tenableTerminal,\n\t\t\t})\n\n\t\t\tconst loom = await loomManager.createIloom({\n\t\t\t\ttype: parsed.type,\n\t\t\t\tidentifier,\n\t\t\t\toriginalInput: parsed.originalInput,\n\t\t\t\t...(parentLoom && { parentLoom }),\n\t\t\t\toptions: {\n\t\t\t\t\tenableClaude,\n\t\t\t\t\tenableCode,\n\t\t\t\t\tenableDevServer,\n\t\t\t\t\tenableTerminal,\n\t\t\t\t\t...(input.options.oneShot && { oneShot: input.options.oneShot }),\n\t\t\t\t\t...(input.options.complexity && { complexity: input.options.complexity }),\n\t\t\t\t\t...(setArguments.length > 0 && { setArguments }),\n\t\t\t\t\t...(executablePath && { executablePath }),\n\t\t\t\t\t...(childIssueNumbers.length > 0 && { childIssueNumbers }),\n\t\t\t\t\t...(childIssues.length > 0 && { childIssues }),\n\t\t\t\t\t...(Object.keys(dependencyMap).length > 0 && { dependencyMap }),\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tgetLogger().success(`Created loom: ${loom.id} at ${loom.path}`)\n\n\t\t\t// Set recap complexity if overridden via CLI flag\n\t\t\tif (input.options.complexity) {\n\t\t\t\ttry {\n\t\t\t\t\tconst recapFilePath = resolveRecapFilePath(loom.path)\n\t\t\t\t\tconst recap = await readRecapFile(recapFilePath)\n\t\t\t\t\trecap.complexity = { level: input.options.complexity, reason: 'Overridden via CLI flag', timestamp: new Date().toISOString() }\n\t\t\t\t\tawait writeRecapFile(recapFilePath, recap)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tgetLogger().debug(`Failed to set recap complexity: ${error instanceof Error ? error.message : error}`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Track loom.created telemetry event\n\t\t\ttry {\n\t\t\t\tconst oneShotMap: Record<string, LoomCreatedProperties['one_shot_mode']> = {\n\t\t\t\t\tnoReview: 'skip-reviews',\n\t\t\t\t\tbypassPermissions: 'yolo',\n\t\t\t\t}\n\t\t\t\tTelemetryService.getInstance().track('loom.created', {\n\t\t\t\t\tsource_type: parsed.type === 'epic' ? 'issue' : parsed.type as LoomCreatedProperties['source_type'],\n\t\t\t\t\ttracker: this.issueTracker.providerName,\n\t\t\t\t\tis_child_loom: !!parentLoom,\n\t\t\t\t\tone_shot_mode: oneShotMap[input.options.oneShot ?? ''] ?? 'default',\n\t\t\t\t\tcomplexity_override: !!input.options.complexity,\n\t\t\t\t\tcreate_only: !!input.options.createOnly,\n\t\t\t\t})\n\t\t\t} catch (error: unknown) {\n\t\t\t\tgetLogger().debug(`Failed to track loom.created telemetry: ${error instanceof Error ? error.message : String(error)}`)\n\t\t\t}\n\n\t\t\tgetLogger().info(` Branch: ${loom.branch}`)\n\t\t\t// Only show port for web projects\n\t\t\tif (loom.capabilities?.includes('web')) {\n\t\t\t\tgetLogger().info(` Port: ${loom.port}`)\n\t\t\t}\n\t\t\tif (loom.issueData?.title) {\n\t\t\t\tgetLogger().info(` Title: ${loom.issueData.title}`)\n\t\t\t}\n\t\t\tif (parsed.type === 'epic') {\n\t\t\t\tgetLogger().info(` Epic: yes (${childIssueNumbers.length} child issue(s))`)\n\t\t\t}\n\n\t\t\t// Return StartResult in JSON mode\n\t\t\tif (isJsonMode) {\n\t\t\t\treturn {\n\t\t\t\t\tid: loom.id,\n\t\t\t\t\tpath: loom.path,\n\t\t\t\t\tbranch: loom.branch,\n\t\t\t\t\ttype: parsed.type,\n\t\t\t\t\tidentifier: loom.identifier,\n\t\t\t\t\t...(loom.port !== undefined && { port: loom.port }),\n\t\t\t\t\t...(loom.issueData?.title && { title: loom.issueData.title }),\n\t\t\t\t\t...(loom.capabilities && { capabilities: loom.capabilities }),\n\t\t\t\t\t...(childIssueNumbers.length > 0 && { childIssueNumbers }),\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tgetLogger().error(`${error.message}`)\n\t\t\t} else {\n\t\t\t\tgetLogger().error('An unknown error occurred')\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Parse input to determine type and extract relevant data\n\t */\n\tprivate async parseInput(identifier: string, repo?: string, options?: StartOptions): Promise<ParsedInput> {\n\t\t// Check if user wants to skip capitalization by prefixing with space\n\t\t// We preserve this for description types so capitalizeFirstLetter() can handle it\n\t\tconst hasLeadingSpace = identifier.startsWith(' ')\n\n\t\t// Handle empty input\n\t\tconst trimmedIdentifier = identifier.trim()\n\t\tif (!trimmedIdentifier) {\n\t\t\tthrow new Error('Missing required argument: identifier')\n\t\t}\n\n\t\t// Check for description: >15 chars AND has spaces (likely a natural language description)\n\t\t// Also treat as description if --body is provided with a multi-word input,\n\t\t// since the VS Code extension passes short titles with a --body flag for new issue creation\n\t\tconst spaceCount = (trimmedIdentifier.match(/ /g) ?? []).length\n\t\tif ((trimmedIdentifier.length > 15 && spaceCount >= 1) || (options?.body && spaceCount >= 1)) {\n\t\t\t// Preserve leading space if present so capitalizeFirstLetter() can detect the override\n\t\t\treturn {\n\t\t\t\ttype: 'description',\n\t\t\t\toriginalInput: hasLeadingSpace ? ' ' + trimmedIdentifier : trimmedIdentifier,\n\t\t\t}\n\t\t}\n\n\t\t// Check for PR-specific formats: pr/123, PR-123, PR/123, Pr-123 (case-insensitive)\n\t\tconst prPattern = /^pr[/-](\\d+)$/i\n\t\tconst prMatch = trimmedIdentifier.match(prPattern)\n\t\tif (prMatch?.[1]) {\n\t\t\treturn {\n\t\t\t\ttype: 'pr',\n\t\t\t\tnumber: parseInt(prMatch[1], 10),\n\t\t\t\toriginalInput: trimmedIdentifier,\n\t\t\t}\n\t\t}\n\n\t\t// Check for issue identifier patterns using shared utility\n\t\t// - Project key pattern: ENG-123 (requires at least 2 letters before dash)\n\t\t// - Numeric pattern: #123 or 123 (GitHub format)\n\t\tconst identifierMatch = matchIssueIdentifier(trimmedIdentifier)\n\n\t\tif (identifierMatch.type === 'project-key' && identifierMatch.identifier) {\n\t\t\t// Use IssueTracker to validate it exists\n\t\t\tconst detection = await this.issueTracker.detectInputType(\n\t\t\t\ttrimmedIdentifier,\n\t\t\t\trepo\n\t\t\t)\n\n\t\t\tif (detection.type === 'issue' && detection.identifier) {\n\t\t\t\treturn {\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tnumber: detection.identifier, // Keep as string for project key identifiers\n\t\t\t\t\toriginalInput: trimmedIdentifier,\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Project key identifier format matched but not found\n\t\t\tthrow new Error(\n\t\t\t\t`Could not find issue matching identifier ${identifierMatch.identifier}`\n\t\t\t)\n\t\t}\n\n\t\t// Check for numeric pattern (could be issue or PR)\n\t\tif (identifierMatch.type === 'numeric' && identifierMatch.identifier) {\n\t\t\tconst number = parseInt(identifierMatch.identifier, 10)\n\n\t\t\t// If issue tracker supports PRs, use it for detection\n\t\t\tif (this.issueTracker.supportsPullRequests) {\n\t\t\t\tconst detection = await this.issueTracker.detectInputType(\n\t\t\t\t\ttrimmedIdentifier,\n\t\t\t\t\trepo\n\t\t\t\t)\n\n\t\t\t\tif (detection.type === 'pr') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'pr',\n\t\t\t\t\t\tnumber: detection.identifier ? parseInt(detection.identifier, 10) : number,\n\t\t\t\t\t\toriginalInput: trimmedIdentifier,\n\t\t\t\t\t}\n\t\t\t\t} else if (detection.type === 'issue') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\tnumber: detection.identifier ? parseInt(detection.identifier, 10) : number,\n\t\t\t\t\t\toriginalInput: trimmedIdentifier,\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Could not find issue or PR #${number}`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Issue tracker doesn't support PRs (e.g., Linear, Jira)\n\t\t\t\t// Check GitHub first for PR, then fall back to issue tracker for issues\n\t\t\t\tconst githubService = this.getGitHubService()\n\t\t\t\tconst detection = await githubService.detectInputType(trimmedIdentifier, repo)\n\n\t\t\t\tif (detection.type === 'pr') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'pr',\n\t\t\t\t\t\tnumber: detection.identifier ? parseInt(detection.identifier, 10) : number,\n\t\t\t\t\t\toriginalInput: trimmedIdentifier,\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Not a GitHub PR - try the configured issue tracker\n\t\t\t\t\t// This allows future trackers with numeric IDs to work naturally\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\tnumber,\n\t\t\t\t\t\toriginalInput: trimmedIdentifier,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Treat as branch name\n\t\treturn {\n\t\t\ttype: 'branch',\n\t\t\tbranchName: trimmedIdentifier,\n\t\t\toriginalInput: trimmedIdentifier,\n\t\t}\n\t}\n\n\t/**\n\t * Validate the parsed input based on its type\n\t */\n\tprivate async validateInput(parsed: ParsedInput, repo?: string): Promise<void> {\n\t\tswitch (parsed.type) {\n\t\t\tcase 'pr': {\n\t\t\t\tif (!parsed.number) {\n\t\t\t\t\tthrow new Error('Invalid PR number')\n\t\t\t\t}\n\n\t\t\t\t// Determine which service to use for PR operations\n\t\t\t\tif (this.issueTracker.supportsPullRequests && this.issueTracker.fetchPR && this.issueTracker.validatePRState) {\n\t\t\t\t\t// Use issue tracker for PR operations (e.g., GitHub)\n\t\t\t\t\tconst pr = await this.issueTracker.fetchPR(parsed.number, repo)\n\t\t\t\t\tawait this.issueTracker.validatePRState(pr)\n\t\t\t\t} else {\n\t\t\t\t\t// Use GitHubService for PR operations when issue tracker doesn't support PRs (e.g., Linear)\n\t\t\t\t\tconst githubService = this.getGitHubService()\n\t\t\t\t\tconst pr = await githubService.fetchPR(parsed.number as number, repo)\n\t\t\t\t\tawait githubService.validatePRState(pr)\n\t\t\t\t}\n\t\t\t\tgetLogger().debug(`Validated PR #${parsed.number}`)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase 'issue': {\n\t\t\t\tif (!parsed.number) {\n\t\t\t\t\tthrow new Error('Invalid issue number')\n\t\t\t\t}\n\t\t\t\t// Fetch and validate issue state\n\t\t\t\tconst issue = await this.issueTracker.fetchIssue(parsed.number, repo)\n\t\t\t\tawait this.issueTracker.validateIssueState(issue)\n\t\t\t\tgetLogger().debug(`Validated issue #${parsed.number}`)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase 'branch': {\n\t\t\t\tif (!parsed.branchName) {\n\t\t\t\t\tthrow new Error('Invalid branch name')\n\t\t\t\t}\n\t\t\t\t// Validate branch name characters (from bash script line 586)\n\t\t\t\tif (!this.isValidBranchName(parsed.branchName)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Invalid branch name. Use only letters, numbers, hyphens, underscores, and slashes'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tgetLogger().debug(`Validated branch name: ${parsed.branchName}`)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tcase 'description': {\n\t\t\t\t// Description inputs are valid - they will be converted to issues\n\t\t\t\tgetLogger().debug('Detected description input', {\n\t\t\t\t\tlength: parsed.originalInput.length\n\t\t\t\t})\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tconst unknownType = parsed as { type: string }\n\t\t\t\tthrow new Error(`Unknown input type: ${unknownType.type}`)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Validate branch name format\n\t */\n\tprivate isValidBranchName(branch: string): boolean {\n\t\t// Pattern from bash script line 586\n\t\treturn /^[a-zA-Z0-9/_-]+$/.test(branch)\n\t}\n\n\t/**\n\t * Format parsed input for display\n\t */\n\tprivate formatParsedInput(parsed: ParsedInput): string {\n\t\tswitch (parsed.type) {\n\t\t\tcase 'pr':\n\t\t\t\treturn `PR #${parsed.number}`\n\t\t\tcase 'issue':\n\t\t\t\treturn `Issue #${parsed.number}`\n\t\t\tcase 'epic':\n\t\t\t\treturn `Epic #${parsed.number}`\n\t\t\tcase 'branch':\n\t\t\t\treturn `Branch '${parsed.branchName}'`\n\t\t\tcase 'description':\n\t\t\t\treturn `Description: ${parsed.originalInput.slice(0, 50)}...`\n\t\t\tdefault:\n\t\t\t\treturn 'Unknown input'\n\t\t}\n\t}\n\n\t/**\n\t * Detect if running from inside an existing loom worktree\n\t * Returns parent loom info if detected, null otherwise\n\t */\n\tprivate async detectParentLoom(loomManager: LoomManager): Promise<{\n\t\ttype: 'issue' | 'pr' | 'branch' | 'epic'\n\t\tidentifier: string | number\n\t\tbranchName: string\n\t\tworktreePath: string\n\t\tdatabaseBranch?: string\n\t} | null> {\n\t\ttry {\n\t\t\tconst cwd = process.cwd()\n\t\t\tconst looms = await loomManager.listLooms()\n\n\t\t\tif (!looms) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\t// Get main worktree path to exclude it from valid parents\n\t\t\tconst mainWorktreePath = await findMainWorktreePathWithSettings()\n\n\t\t\t// Find loom containing current directory\n\t\t\t// Fix #2: Add path.sep check to prevent false positives (e.g., issue-123 vs issue-1234)\n\t\t\t// Exclude main worktree from being a valid parent\n\t\t\tconst parentLoom = looms.find(loom => {\n\t\t\t\t// Skip main worktree - it shouldn't be a parent for child looms\n\t\t\t\tif (loom.path === mainWorktreePath) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\t// Either exact match OR cwd starts with loom.path followed by path separator\n\t\t\t\treturn cwd === loom.path || cwd.startsWith(loom.path + path.sep)\n\t\t\t})\n\t\t\tif (!parentLoom) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\tgetLogger().debug(`Detected parent loom: ${parentLoom.type} ${parentLoom.identifier} at ${parentLoom.path}`)\n\n\t\t\tconst result: {\n\t\t\t\ttype: 'issue' | 'pr' | 'branch' | 'epic'\n\t\t\t\tidentifier: string | number\n\t\t\t\tbranchName: string\n\t\t\t\tworktreePath: string\n\t\t\t\tdatabaseBranch?: string\n\t\t\t} = {\n\t\t\t\ttype: parentLoom.type,\n\t\t\t\tidentifier: parentLoom.identifier,\n\t\t\t\tbranchName: parentLoom.branch,\n\t\t\t\tworktreePath: parentLoom.path,\n\t\t\t}\n\n\t\t\t// Only include databaseBranch if it exists (exactOptionalPropertyTypes compatibility)\n\t\t\tif (parentLoom.databaseBranch) {\n\t\t\t\tresult.databaseBranch = parentLoom.databaseBranch\n\t\t\t}\n\n\t\t\t// Try to get database branch from parent's .env file via reverse lookup\n\t\t\tif (!result.databaseBranch) {\n\t\t\t\tconst databaseBranch = await loomManager.getDatabaseBranchForLoom(parentLoom.path)\n\t\t\t\tif (databaseBranch) {\n\t\t\t\t\tresult.databaseBranch = databaseBranch\n\t\t\t\t\tgetLogger().debug(`Detected parent database branch: ${databaseBranch}`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result\n\t\t} catch (error) {\n\t\t\t// If detection fails for any reason, just return null (don't break the start workflow)\n\t\t\tgetLogger().debug(`Failed to detect parent loom: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\treturn null\n\t\t}\n\t}\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,OAAO,WAAW;AAWlB,eAAe,iBAAkC;AAChD,QAAM,WAAW,MAAM,YAAY;AACnC,MAAI,UAAU;AACb,WAAO,MAAM,wCAAwC,QAAQ,EAAE;AAC/D,WAAO;AAAA,EACR;AACA,QAAM,MAAM,QAAQ,IAAI;AACxB,SAAO,MAAM,+CAA+C,GAAG,EAAE;AACjE,SAAO;AACR;AAWA,eAAsB,qBAAuC;AAC5D,QAAM,cAAc,MAAM,eAAe;AACzC,QAAM,kBAAkB,IAAI,gBAAgB;AAG5C,QAAM,eAAe,MAAM,gBAAgB,oBAAoB,WAAW;AAC1E,MAAI,cAAc;AACjB,WAAO,MAAM,+DAA+D;AAC5E,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,KAAK,KAAK,aAAa,QAAQ;AAGhD,MAAI,CAAC,WAAW,QAAQ,GAAG;AAC1B,WAAO;AAAA,EACR;AAGA,QAAM,eAAe,KAAK,KAAK,UAAU,eAAe;AACxD,QAAM,oBAAoB,KAAK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AACnB,iBAAO,iBAAiB;AACxB,oBAAU,EAAE,MAAM,oCAAoC,cAAc,EAAE;AAAA,QACvE;AAAA,MACD;AAEA,aAAO;AAAA,IACR,SAAS,OAAO;AAEf,gBAAU,EAAE,MAAM,iCAAiC,iBAAiB,QAAQ,MAAM,UAAU,eAAe,EAAE;AAC7G,aAAO;AAAA,IACR;AAAA,EACD;AAED;","names":["path","settings","path"]}
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./chunk-CQHHEW2M.js";
|
|
26
26
|
import {
|
|
27
27
|
AgentManager
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-Y2MVSEJK.js";
|
|
29
29
|
import {
|
|
30
30
|
IssueManagementProviderFactory
|
|
31
31
|
} from "./chunk-R7DGN73N.js";
|
|
@@ -992,26 +992,12 @@ var IgniteCommand = class {
|
|
|
992
992
|
agentOverrides: Object.keys(this.settings.agents)
|
|
993
993
|
});
|
|
994
994
|
}
|
|
995
|
-
|
|
995
|
+
agents = await this.agentManager.loadAndPrepare(
|
|
996
996
|
this.settings,
|
|
997
997
|
variables,
|
|
998
|
-
["*.md", "!iloom-framework-detector.md"]
|
|
998
|
+
["*.md", "!iloom-framework-detector.md"],
|
|
999
|
+
path5.join(context.workspacePath, ".claude", "agents")
|
|
999
1000
|
);
|
|
1000
|
-
if (process.platform === "darwin") {
|
|
1001
|
-
agents = this.agentManager.formatForCli(loadedAgents);
|
|
1002
|
-
logger.debug("Loaded agent configurations for CLI", {
|
|
1003
|
-
agentCount: Object.keys(agents).length,
|
|
1004
|
-
agentNames: Object.keys(agents)
|
|
1005
|
-
});
|
|
1006
|
-
} else {
|
|
1007
|
-
const agentsDir = path5.join(context.workspacePath, ".claude", "agents");
|
|
1008
|
-
const rendered = await this.agentManager.renderAgentsToDisk(loadedAgents, agentsDir);
|
|
1009
|
-
logger.debug("Rendered agent files to disk for auto-discovery", {
|
|
1010
|
-
agentCount: rendered.length,
|
|
1011
|
-
agentNames: rendered,
|
|
1012
|
-
targetDir: agentsDir
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
1001
|
} catch (error) {
|
|
1016
1002
|
logger.warn(`Failed to load agents: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1017
1003
|
}
|
|
@@ -1491,17 +1477,12 @@ var IgniteCommand = class {
|
|
|
1491
1477
|
logger.info(` Pending child issues: ${pendingChildIssues.length}`);
|
|
1492
1478
|
let agents;
|
|
1493
1479
|
try {
|
|
1494
|
-
|
|
1480
|
+
agents = await this.agentManager.loadAndPrepare(
|
|
1495
1481
|
settings,
|
|
1496
1482
|
variables,
|
|
1497
|
-
["*.md", "!iloom-framework-detector.md"]
|
|
1483
|
+
["*.md", "!iloom-framework-detector.md"],
|
|
1484
|
+
path5.join(epicWorktreePath, ".claude", "agents")
|
|
1498
1485
|
);
|
|
1499
|
-
if (process.platform === "darwin") {
|
|
1500
|
-
agents = this.agentManager.formatForCli(loadedAgents);
|
|
1501
|
-
} else {
|
|
1502
|
-
const agentsDir = path5.join(epicWorktreePath, ".claude", "agents");
|
|
1503
|
-
await this.agentManager.renderAgentsToDisk(loadedAgents, agentsDir);
|
|
1504
|
-
}
|
|
1505
1486
|
} catch (error) {
|
|
1506
1487
|
logger.warn(`Failed to load agents: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1507
1488
|
}
|
|
@@ -1634,4 +1615,4 @@ export {
|
|
|
1634
1615
|
WorktreeValidationError,
|
|
1635
1616
|
IgniteCommand
|
|
1636
1617
|
};
|
|
1637
|
-
//# sourceMappingURL=chunk-
|
|
1618
|
+
//# sourceMappingURL=chunk-UVXB6O24.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ignite.ts","../src/lib/ClaudeHookManager.ts","../src/lib/SwarmSetupService.ts","../src/utils/language-detector.ts","../src/utils/system-prompt-writer.ts"],"sourcesContent":["import path from 'path'\nimport fs from 'fs-extra'\nimport { logger, createStderrLogger } from '../utils/logger.js'\nimport { withLogger } from '../utils/logger-context.js'\nimport { ClaudeWorkflowOptions } from '../lib/ClaudeService.js'\nimport { GitWorktreeManager } from '../lib/GitWorktreeManager.js'\nimport { launchClaude, ClaudeCliOptions } from '../utils/claude.js'\nimport { PromptTemplateManager, TemplateVariables, buildReviewTemplateVariables } from '../lib/PromptTemplateManager.js'\nimport { generateIssueManagementMcpConfig, generateRecapMcpConfig, generateAndWriteMcpConfigFile, resolveRecapFilePath, readRecapFile, writeRecapFile } from '../utils/mcp.js'\nimport { AgentManager } from '../lib/AgentManager.js'\nimport { IssueTrackerFactory } from '../lib/IssueTrackerFactory.js'\nimport { SettingsManager, type IloomSettings } from '../lib/SettingsManager.js'\nimport { MetadataManager } from '../lib/MetadataManager.js'\nimport { extractSettingsOverrides } from '../utils/cli-overrides.js'\nimport { FirstRunManager } from '../utils/FirstRunManager.js'\nimport { extractIssueNumber, isValidGitRepo, getWorktreeRoot, findMainWorktreePathWithSettings, generateWorktreePath } from '../utils/git.js'\nimport { getWorkspacePort } from '../utils/port.js'\nimport { readFile } from 'fs/promises'\nimport { ClaudeHookManager } from '../lib/ClaudeHookManager.js'\nimport type { OneShotMode, ComplexityOverride } from '../types/index.js'\nimport { fetchChildIssueDetails } from '../utils/list-children.js'\nimport { buildDependencyMap } from '../utils/dependency-map.js'\nimport { SwarmSetupService } from '../lib/SwarmSetupService.js'\nimport type { LoomMetadata } from '../lib/MetadataManager.js'\nimport { TelemetryService } from '../lib/TelemetryService.js'\nimport { detectProjectLanguage } from '../utils/language-detector.js'\nimport { prepareSystemPromptForPlatform } from '../utils/system-prompt-writer.js'\nimport { preAcceptClaudeTrust } from '../utils/claude-trust.js'\n\n/**\n * Error thrown when the spin command is run from an invalid location\n */\nexport class WorktreeValidationError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly suggestion: string\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'WorktreeValidationError'\n\t}\n}\n\n/**\n * IgniteCommand: Auto-detect workspace context and launch Claude\n *\n * This command:\n * 1. Auto-detects context from current directory and git branch\n * 2. Loads appropriate prompt template with variable substitution\n * 3. Launches Claude with existing agent system (NO changes to agent loading)\n * 4. Executes in current terminal (not opening a new window)\n *\n * CRITICAL: This command works with agents exactly as they currently function.\n * NO modifications to agent loading mechanisms.\n */\nexport class IgniteCommand {\n\tprivate templateManager: PromptTemplateManager\n\tprivate gitWorktreeManager: GitWorktreeManager\n\tprivate agentManager: AgentManager\n\tprivate settingsManager: SettingsManager\n\tprivate firstRunManager: FirstRunManager\n\tprivate hookManager: ClaudeHookManager\n\tprivate settings?: IloomSettings\n\n\tconstructor(\n\t\ttemplateManager?: PromptTemplateManager,\n\t\tgitWorktreeManager?: GitWorktreeManager,\n\t\tagentManager?: AgentManager,\n\t\tsettingsManager?: SettingsManager,\n\t\tfirstRunManager?: FirstRunManager,\n\t\thookManager?: ClaudeHookManager\n\t) {\n\t\tthis.templateManager = templateManager ?? new PromptTemplateManager()\n\t\tthis.gitWorktreeManager = gitWorktreeManager ?? new GitWorktreeManager()\n\t\tthis.agentManager = agentManager ?? new AgentManager()\n\t\tthis.settingsManager = settingsManager ?? new SettingsManager()\n\t\tthis.firstRunManager = firstRunManager ?? new FirstRunManager('spin')\n\t\tthis.hookManager = hookManager ?? new ClaudeHookManager()\n\t}\n\n\t/**\n\t * Validate that we're not running from the main worktree\n\t * @param workspacePath - Optional explicit workspace path; defaults to process.cwd()\n\t * @throws WorktreeValidationError if running from main worktree\n\t */\n\tprivate async validateNotMainWorktree(workspacePath?: string): Promise<void> {\n\t\tconst currentDir = workspacePath ?? process.cwd()\n\n\t\t// Step 1: Check if we're in a git repository at all\n\t\tconst isGitRepo = await isValidGitRepo(currentDir)\n\t\tif (!isGitRepo) {\n\t\t\t// Not a git repo - let detectWorkspaceContext handle this gracefully\n\t\t\treturn\n\t\t}\n\n\t\t// Step 2: Get the worktree root (handles subdirectories)\n\t\tconst worktreeRoot = await getWorktreeRoot(currentDir)\n\t\tif (!worktreeRoot) {\n\t\t\t// Could not determine root - let detectWorkspaceContext handle this\n\t\t\treturn\n\t\t}\n\n\t\t// Step 3: Check if this path is a registered git worktree\n\t\tconst worktrees = await this.gitWorktreeManager.listWorktrees()\n\t\tconst currentWorktree = worktrees.find(wt => wt.path === worktreeRoot)\n\n\t\tif (!currentWorktree) {\n\t\t\t// Not a registered worktree - let detectWorkspaceContext handle this\n\t\t\treturn\n\t\t}\n\n\t\t// Step 4: Check if this is the main worktree\n\t\tconst isMain = await this.gitWorktreeManager.isMainWorktree(currentWorktree, this.settingsManager)\n\t\tif (isMain) {\n\t\t\tthrow new WorktreeValidationError(\n\t\t\t\t'You cannot run the command from the main worktree.',\n\t\t\t\t\"Navigate to a feature worktree created by 'il start <issue>' and run 'il spin' from there.\"\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Print mode options for headless/CI execution\n\t */\n\tpublic printOptions: {\n\t\tprint?: boolean\n\t\toutputFormat?: 'json' | 'stream-json' | 'text'\n\t\tverbose?: boolean\n\t\tjson?: boolean // --json flag: output final JSON object\n\t\tjsonStream?: boolean // --json-stream flag: stream JSONL to stdout\n\t} | undefined\n\n\t/**\n\t * Main entry point for spin command\n\t * @param oneShot - One-shot automation mode\n\t * @param printOptions - Print mode options for headless/CI execution\n\t * @param skipCleanup - Skip cleanup after execution\n\t * @param workspacePath - Optional explicit workspace path for programmatic invocation (avoids process.chdir())\n\t * @param complexity - Override complexity evaluation (session-only, takes priority over metadata)\n\t */\n\tasync execute(oneShot?: OneShotMode, printOptions?: {\n\t\tprint?: boolean\n\t\toutputFormat?: 'json' | 'stream-json' | 'text'\n\t\tverbose?: boolean\n\t\tjson?: boolean\n\t\tjsonStream?: boolean\n\t}, skipCleanup?: boolean, workspacePath?: string, complexity?: ComplexityOverride): Promise<void> {\n\t\tthis.printOptions = printOptions\n\n\t\t// Wrap execution in stderr logger for JSON modes to keep stdout clean\n\t\tconst isJsonMode = (this.printOptions?.json ?? false) || (this.printOptions?.jsonStream ?? false)\n\t\tif (isJsonMode) {\n\t\t\tconst jsonLogger = createStderrLogger()\n\t\t\treturn withLogger(jsonLogger, () => this.executeInternal(oneShot, skipCleanup, workspacePath, complexity))\n\t\t}\n\n\t\treturn this.executeInternal(oneShot, skipCleanup, workspacePath, complexity)\n\t}\n\n\t/**\n\t * Internal execution method (separated for withLogger wrapping)\n\t */\n\tprivate async executeInternal(oneShot?: OneShotMode, skipCleanup?: boolean, workspacePath?: string, complexity?: ComplexityOverride): Promise<void> {\n\t\t// Set ILOOM=1 so hooks know this is an iloom session\n\t\t// This is inherited by the Claude child process\n\t\tprocess.env.ILOOM = '1'\n\n\t\t// Validate we're not in the main worktree first\n\t\ttry {\n\t\t\tawait this.validateNotMainWorktree(workspacePath)\n\t\t} catch (error) {\n\t\t\tif (error instanceof WorktreeValidationError) {\n\t\t\t\tlogger.error(error.message)\n\t\t\t\tlogger.info(error.suggestion)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\n\t\ttry {\n\t\t\tlogger.info('🚀 Your loom is spinning up, please wait...')\n\n\t\t\t// Step 0.5: Check if this is first-time user\n\t\t\tconst isFirstRun = await this.firstRunManager.isFirstRun()\n\t\t\tif (isFirstRun) {\n\t\t\t\tlogger.success('Welcome to iloom! Preparing first-time experience...')\n\t\t\t}\n\n\t\t\t// Step 0.6: Install Claude hooks for VSCode integration (idempotent, quick)\n\t\t\tawait this.hookManager.installHooks()\n\n\t\t\t// Step 1: Auto-detect workspace context\n\t\t\tconst context = await this.detectWorkspaceContext(workspacePath)\n\n\t\t\tlogger.debug('Auto-detected workspace context', { context })\n\n\t\t\t// Inform user what context was detected\n\t\t\tthis.logDetectedContext(context)\n\n\t\t\tlogger.info('📝 Loading prompt template and preparing Claude...')\n\n\t\t\t// Step 2: Read metadata early to get draftPrNumber and draftPrUrl for templates and MCP config\n\t\t\tconst metadataManager = new MetadataManager()\n\t\t\tconst metadata = await metadataManager.readMetadata(context.workspacePath)\n\t\t\tconst draftPrNumber = metadata?.draftPrNumber ?? undefined\n\t\t\t// Extract draft PR URL from prUrls map if available\n\t\t\tconst draftPrUrl = draftPrNumber && metadata?.prUrls?.[String(draftPrNumber)]\n\t\t\t\t? metadata.prUrls[String(draftPrNumber)]\n\t\t\t\t: undefined\n\n\t\t\t// Step 2.0.3: Prevent il spin in child worktrees of epic looms\n\t\t\t// Child issues managed by a swarm orchestrator must not launch independent agents.\n\t\t\t// Exception: child epics (issueType === 'epic') need il spin for their own swarm.\n\t\t\tif (metadata?.parentLoom?.type === 'epic' && metadata.issueType !== 'epic') {\n\t\t\t\tthrow new WorktreeValidationError(\n\t\t\t\t\t'Cannot run il spin in a child worktree of an epic loom. The swarm orchestrator manages agent execution for these issues.',\n\t\t\t\t\t'Run il spin from the parent epic worktree instead to launch the swarm orchestrator.'\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Step 2.0.4: Determine effective oneShot mode\n\t\t\t// If print mode is enabled, force noReview to skip interactive reviews\n\t\t\t// If oneShot is provided (any value including 'default'), use it\n\t\t\t// If oneShot is undefined (not passed), use metadata or fallback to 'default'\n\t\t\t// Note: metadata?.oneShot can be null (for legacy looms), so we need double nullish coalescing\n\t\t\tconst storedOneShot = metadata?.oneShot ?? 'default'\n\t\t\tconst isHeadlessForOneShot = this.printOptions?.print ?? false\n\t\t\tconst effectiveOneShot: OneShotMode = isHeadlessForOneShot ? 'noReview' : (oneShot ?? storedOneShot)\n\n\t\t\t// Determine effective complexity override\n\t\t\t// CLI flag takes priority over loom metadata\n\t\t\tconst effectiveComplexity = complexity ?? metadata?.complexity ?? undefined\n\n\t\t\t// Set recap complexity if overridden and not already set\n\t\t\tif (effectiveComplexity) {\n\t\t\t\ttry {\n\t\t\t\t\tconst recapFilePath = resolveRecapFilePath(context.workspacePath)\n\t\t\t\t\tconst recap = await readRecapFile(recapFilePath)\n\t\t\t\t\tif (!recap.complexity) {\n\t\t\t\t\t\trecap.complexity = { level: effectiveComplexity, reason: 'Overridden via CLI flag', timestamp: new Date().toISOString() }\n\t\t\t\t\t\tawait writeRecapFile(recapFilePath, recap)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.debug(`Failed to set recap complexity: ${error instanceof Error ? error.message : error}`)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step 2.0.5: Load settings early if not cached (needed for port calculation)\n\t\t\tif (!this.settings) {\n\t\t\t\tconst cliOverrides = extractSettingsOverrides()\n\t\t\t\tthis.settings = await this.settingsManager.loadSettings(undefined, cliOverrides)\n\t\t\t}\n\n\t\t\t// Step 2.0.5.1: Track session.started telemetry\n\t\t\ttry {\n\t\t\t\tconst hasNeon = !!this.settings?.databaseProviders?.neon\n\t\t\t\tconst language = await detectProjectLanguage(context.workspacePath)\n\t\t\t\tTelemetryService.getInstance().track('session.started', {\n\t\t\t\t\thas_neon: hasNeon,\n\t\t\t\t\tlanguage,\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tlogger.debug(`Telemetry session.started tracking failed: ${error instanceof Error ? error.message : error}`)\n\t\t\t}\n\n\t\t\t// Step 2.0.6: Calculate port for web-capable looms\n\t\t\tif (metadata?.capabilities?.includes('web') && context.branchName) {\n\t\t\t\tconst basePort = this.settings?.capabilities?.web?.basePort ?? 3000\n\t\t\t\tcontext.port = await getWorkspacePort({\n\t\t\t\t\tbasePort,\n\t\t\t\t\tworktreePath: context.workspacePath,\n\t\t\t\t\tworktreeBranch: context.branchName,\n\t\t\t\t})\n\t\t\t\tlogger.info(`🌐 Development server port: ${context.port}`)\n\t\t\t}\n\n\t\t\t// Step 2.1: Fetch and persist epic child data if this is an epic loom\n\t\t\t// Detection: check for childIssues already stored (re-spin of an epic)\n\t\t\t// or check for 'epic' issueType once issue #624 adds it\n\t\t\tconst isEpicLoom = metadata && metadata.issue_numbers.length > 0\n\t\t\t\t&& ((metadata.childIssues?.length ?? 0) > 0 || metadata.issueType === 'epic')\n\t\t\tif (isEpicLoom && this.settings) {\n\t\t\t\tawait this.fetchAndStoreEpicChildData(metadataManager, metadata, context.workspacePath, this.settings)\n\t\t\t}\n\n\t\t\t// Step 2.1.1: If this is an epic loom, enter swarm mode\n\t\t\tif (isEpicLoom && this.settings) {\n\t\t\t\t// Re-read metadata to get freshly persisted child data\n\t\t\t\tconst freshMetadata = await metadataManager.readMetadata(context.workspacePath)\n\t\t\t\tif (freshMetadata && freshMetadata.childIssues.length > 0) {\n\t\t\t\t\tawait this.executeSwarmMode(\n\t\t\t\t\t\tfreshMetadata,\n\t\t\t\t\t\tcontext.workspacePath,\n\t\t\t\t\t\tcontext.branchName ?? '',\n\t\t\t\t\t\tmetadataManager,\n\t\t\t\t\t\tskipCleanup,\n\t\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Step 2.2: Get prompt template with variable substitution\n\t\t\tconst variables = this.buildTemplateVariables(context, effectiveOneShot, draftPrNumber, draftPrUrl, effectiveComplexity)\n\n\t\t\t// Step 2.5: Add first-time user context if needed\n\t\t\tif (isFirstRun) {\n\t\t\t\tvariables.FIRST_TIME_USER = true\n\t\t\t\tvariables.README_CONTENT = await this.loadReadmeContent()\n\t\t\t\tvariables.SETTINGS_SCHEMA_CONTENT = await this.loadSettingsSchemaContent()\n\t\t\t}\n\n\t\t\tconst systemInstructions = await this.templateManager.getPrompt(context.type, variables)\n\n\t\t\t// User prompt to trigger the workflow (includes one-shot bypass instructions if needed)\n\t\t\tconst userPrompt = this.buildUserPrompt(effectiveOneShot)\n\n\t\t\t// Step 3: Determine model and permission mode based on workflow type\n\t\t\tconst model = this.settingsManager.getSpinModel(this.settings)\n\t\t\tlet permissionMode = this.getPermissionModeForWorkflow(context.type)\n\n\t\t\t// Override permission mode if bypassPermissions oneShot mode\n\t\t\tif (effectiveOneShot === 'bypassPermissions') {\n\t\t\t\tpermissionMode = 'bypassPermissions'\n\t\t\t}\n\n\t\t\t// Display warning if bypassPermissions is used\n\t\t\tif (permissionMode === 'bypassPermissions') {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t'⚠️ WARNING: Using bypassPermissions mode - Claude will execute all tool calls without confirmation. ' +\n\t\t\t\t\t\t'This can be dangerous. Use with caution.'\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Step 4: Build Claude CLI options\n\t\t\t// Session ID must come from loom metadata - no fallback generation\n\t\t\tconst sessionId = metadata?.sessionId\n\t\t\tif (!sessionId) {\n\t\t\t\tthrow new Error('No session ID found in loom metadata. This loom may need to be recreated with `il start`.')\n\t\t\t}\n\t\t\tlogger.debug('Using session ID from metadata', { sessionId })\n\n\t\t\t// Determine if we're in print/headless mode\n\t\t\tconst isHeadless = this.printOptions?.print ?? false\n\n\t\t\tconst claudeOptions: ClaudeCliOptions = {\n\t\t\t\theadless: isHeadless,\n\t\t\t\taddDir: context.workspacePath,\n\t\t\t\tsessionId, // Enable Claude Code session resume\n\t\t\t}\n\n\t\t\t// Add optional model if present\n\t\t\tif (model !== undefined) {\n\t\t\t\tclaudeOptions.model = model\n\t\t\t}\n\n\t\t\t// Add permission mode if not default\n\t\t\t// When print mode is enabled, force bypassPermissions for autonomous execution\n\t\t\tif (isHeadless) {\n\t\t\t\tpermissionMode = 'bypassPermissions'\n\t\t\t}\n\t\t\tif (permissionMode !== undefined && permissionMode !== 'default') {\n\t\t\t\tclaudeOptions.permissionMode = permissionMode\n\t\t\t}\n\n\t\t\t// Add output format and verbose options if provided (print mode only)\n\t\t\tif (this.printOptions?.outputFormat !== undefined) {\n\t\t\t\tclaudeOptions.outputFormat = this.printOptions.outputFormat\n\t\t\t}\n\t\t\tif (this.printOptions?.verbose !== undefined) {\n\t\t\t\tclaudeOptions.verbose = this.printOptions.verbose\n\t\t\t}\n\n\t\t\t// Add JSON mode if specified (requires print mode)\n\t\t\tif (this.printOptions?.json) {\n\t\t\t\tclaudeOptions.jsonMode = 'json'\n\t\t\t\tclaudeOptions.outputFormat = 'stream-json' // Force stream-json for parsing\n\t\t\t} else if (this.printOptions?.jsonStream) {\n\t\t\t\tclaudeOptions.jsonMode = 'stream'\n\t\t\t\tclaudeOptions.outputFormat = 'stream-json' // Force stream-json for streaming\n\t\t\t}\n\n\t\t\t// Add optional branch name for context\n\t\t\tif (context.branchName !== undefined) {\n\t\t\t\tclaudeOptions.branchName = context.branchName\n\t\t\t}\n\n\t\t\t// Step 4.5: Generate MCP config and tool filtering for issue/PR workflows\n\t\t\tlet mcpConfig: Record<string, unknown>[] | undefined\n\t\t\tlet allowedTools: string[] | undefined\n\t\t\tlet disallowedTools: string[] | undefined\n\n\t\t\tif (context.type === 'issue' || context.type === 'pr') {\n\t\t\t\ttry {\n\t\t\t\t\tconst provider = this.settings ? IssueTrackerFactory.getProviderName(this.settings) : 'github'\n\t\t\t\t\t// Pass draftPrNumber to route comments to PR when in draft-pr mode\n\t\t\t\t\tmcpConfig = await generateIssueManagementMcpConfig(context.type, undefined, provider, this.settings, draftPrNumber)\n\t\t\t\t\tlogger.debug('Generated MCP configuration for issue management', { provider, draftPrNumber })\n\n\t\t\t\t\t// Configure tool filtering for issue/PR workflows\n\t\t\t\t\t// Note: set_goal is only allowed for PR workflow (user's purpose unclear)\n\t\t\t\t\t// For issue workflow, the issue title provides context so set_goal is not needed\n\t\t\t\t\tconst baseTools = [\n\t\t\t\t\t\t'mcp__issue_management__get_issue',\n\t\t\t\t\t\t'mcp__issue_management__get_comment',\n\t\t\t\t\t\t'mcp__issue_management__create_comment',\n\t\t\t\t\t\t'mcp__issue_management__update_comment',\n\t\t\t\t\t\t'mcp__issue_management__create_issue',\n\t\t\t\t\t\t'mcp__issue_management__close_issue',\n\t\t\t\t\t\t'mcp__issue_management__reopen_issue',\n\t\t\t\t\t\t'mcp__issue_management__edit_issue',\n\t\t\t\t\t\t'mcp__recap__add_entry',\n\t\t\t\t\t\t'mcp__recap__get_recap',\n\t\t\t\t\t\t'mcp__recap__add_artifact',\n\t\t\t\t\t\t'mcp__recap__set_complexity',\n\t\t\t\t\t\t'mcp__recap__set_loom_state',\n\t\t\t\t\t\t'mcp__recap__get_loom_state'\n\t\t\t\t\t]\n\t\t\t\t\tallowedTools = context.type === 'pr'\n\t\t\t\t\t\t? [...baseTools, 'mcp__issue_management__get_pr', 'mcp__issue_management__get_review_comments', 'mcp__recap__set_goal']\n\t\t\t\t\t\t: baseTools\n\t\t\t\t\tdisallowedTools = context.type === 'pr'\n\t\t\t\t\t\t? ['Bash(gh issue comment:*)']\n\t\t\t\t\t\t: ['Bash(gh api:*)', 'Bash(gh issue comment:*)']\n\n\t\t\t\t\tlogger.debug('Configured tool filtering for issue/PR workflow', { allowedTools, disallowedTools })\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Log warning but continue without MCP\n\t\t\t\t\tlogger.warn(`Failed to generate MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Regular/branch workflow - allow recap tools (including set_goal since no issue/PR context)\n\t\t\t\tallowedTools = [\n\t\t\t\t\t'mcp__recap__set_goal',\n\t\t\t\t\t'mcp__recap__add_entry',\n\t\t\t\t\t'mcp__recap__get_recap',\n\t\t\t\t\t'mcp__recap__set_complexity',\n\t\t\t\t\t'mcp__recap__set_loom_state',\n\t\t\t\t\t'mcp__recap__get_loom_state',\n\t\t\t\t]\n\t\t\t\tlogger.debug('Configured tool filtering for regular workflow', { allowedTools })\n\t\t\t}\n\n\t\t\t// Step 4.5.1: Generate recap MCP config (always added for all workflow types)\n\t\t\t// Reuses metadata already read in Step 2\n\t\t\ttry {\n\t\t\t\tif (!metadata) {\n\t\t\t\t\tthrow new Error('No loom metadata found for this workspace')\n\t\t\t\t}\n\t\t\t\tconst recapMcpConfig = generateRecapMcpConfig(context.workspacePath, metadata)\n\t\t\t\tif (mcpConfig) {\n\t\t\t\t\tmcpConfig.push(...recapMcpConfig)\n\t\t\t\t} else {\n\t\t\t\t\tmcpConfig = recapMcpConfig\n\t\t\t\t}\n\t\t\t\tlogger.debug('Generated MCP configuration for recap server')\n\t\t\t} catch (error) {\n\t\t\t\t// Log warning but continue without recap MCP\n\t\t\t\tlogger.warn(`Failed to generate recap MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t}\n\n\t\t\t// Step 4.6: Load agent configurations using cached settings\n\t\t\tlet agents: Record<string, unknown> | undefined\n\t\t\ttry {\n\t\t\t\tif (this.settings?.agents && Object.keys(this.settings.agents).length > 0) {\n\t\t\t\t\tlogger.debug('Loaded project settings', {\n\t\t\t\t\t\tagentOverrides: Object.keys(this.settings.agents),\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\t// Exclude init-only agents (e.g., framework-detector which is only for il init)\n\t\t\t\tagents = await this.agentManager.loadAndPrepare(\n\t\t\t\t\tthis.settings,\n\t\t\t\t\tvariables,\n\t\t\t\t\t['*.md', '!iloom-framework-detector.md'],\n\t\t\t\t\tpath.join(context.workspacePath, '.claude', 'agents')\n\t\t\t\t)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.warn(`Failed to load agents: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t}\n\n\t\t\tlogger.debug('Launching Claude in current terminal', {\n\t\t\t\ttype: context.type,\n\t\t\t\tmodel,\n\t\t\t\tpermissionMode,\n\t\t\t\tworkspacePath: context.workspacePath,\n\t\t\t\thasMcpConfig: !!mcpConfig,\n\t\t\t})\n\n\t\t\t// Pre-accept Claude Code trust for this worktree path\n\t\t\ttry {\n\t\t\t\tawait preAcceptClaudeTrust(context.workspacePath)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.warn(`Failed to pre-accept Claude trust: ${error instanceof Error ? error.message : String(error)}`)\n\t\t\t}\n\n\t\t\tlogger.info(isHeadless ? '✨ Launching Claude in headless mode...' : '✨ Launching Claude in current terminal...')\n\n\t\t\t// Prepare system prompt by writing to file\n\t\t\tconst systemPromptConfig = await prepareSystemPromptForPlatform(\n\t\t\t\tsystemInstructions,\n\t\t\t\tcontext.workspacePath,\n\t\t\t)\n\n\t\t\t// Step 5: Launch Claude with system instructions file and user prompt\n\t\t\tconst claudeResult = await launchClaude(userPrompt, {\n\t\t\t\t...claudeOptions,\n\t\t\t\tappendSystemPromptFile: systemPromptConfig.appendSystemPromptFile,\n\t\t\t\t...(mcpConfig && { mcpConfig }),\n\t\t\t\t...(allowedTools && { allowedTools }),\n\t\t\t\t...(disallowedTools && { disallowedTools }),\n\t\t\t\t...(agents && { agents }),\n\t\t\t})\n\n\t\t\t// Output final JSON for --json mode (--json-stream already streamed to stdout)\n\t\t\tif (this.printOptions?.json) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(JSON.stringify({\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\toutput: claudeResult ?? ''\n\t\t\t\t}))\n\t\t\t}\n\n\t\t\t// Step 6: Mark as run after successful launch\n\t\t\tif (isFirstRun) {\n\t\t\t\tawait this.firstRunManager.markAsRun()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\t\t\t// Output error as JSON for --json mode\n\t\t\tif (this.printOptions?.json) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(JSON.stringify({\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: errorMessage\n\t\t\t\t}))\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Log user-friendly information about detected context\n\t */\n\tprivate logDetectedContext(context: ClaudeWorkflowOptions): void {\n\t\tif (context.type === 'issue') {\n\t\t\tlogger.info(`🎯 Detected issue workflow: Issue #${context.issueNumber}`)\n\t\t} else if (context.type === 'pr') {\n\t\t\tlogger.info(`🔄 Detected PR workflow: PR #${context.prNumber}`)\n\t\t} else {\n\t\t\tlogger.info('🌟 Detected regular workflow')\n\t\t}\n\n\t\tif (context.branchName) {\n\t\t\tlogger.info(`🌿 Working on branch: ${context.branchName}`)\n\t\t}\n\n\t\tif (context.port) {\n\t\t\tlogger.info(`🌐 Development server port: ${context.port}`)\n\t\t}\n\t}\n\n\t/**\n\t * Build template variables from context\n\t */\n\tprivate buildTemplateVariables(\n\t\tcontext: ClaudeWorkflowOptions,\n\t\toneShot: OneShotMode,\n\t\tdraftPrNumber?: number,\n\t\tdraftPrUrl?: string,\n\t\tcomplexity?: ComplexityOverride\n\t): TemplateVariables {\n\t\tconst variables: TemplateVariables = {\n\t\t\tWORKSPACE_PATH: context.workspacePath,\n\t\t}\n\n\t\tif (context.issueNumber !== undefined) {\n\t\t\tvariables.ISSUE_NUMBER = context.issueNumber\n\t\t}\n\n\t\tif (context.prNumber !== undefined) {\n\t\t\tvariables.PR_NUMBER = context.prNumber\n\t\t}\n\n\t\tif (context.title !== undefined) {\n\t\t\tif (context.type === 'issue') {\n\t\t\t\tvariables.ISSUE_TITLE = context.title\n\t\t\t} else if (context.type === 'pr') {\n\t\t\t\tvariables.PR_TITLE = context.title\n\t\t\t}\n\t\t}\n\n\t\tif (context.port !== undefined) {\n\t\t\tvariables.PORT = context.port\n\t\t}\n\n\t\t// Set ONE_SHOT_MODE or INTERACTIVE_MODE flag for template conditional sections\n\t\tif (oneShot === 'noReview' || oneShot === 'bypassPermissions') {\n\t\t\tvariables.ONE_SHOT_MODE = true\n\t\t} else {\n\t\t\tvariables.INTERACTIVE_MODE = true\n\t\t}\n\n\t\t// Set review configuration variables (code reviewer + artifact reviewer + per-agent flags)\n\t\tObject.assign(variables, buildReviewTemplateVariables(false, this.settings?.agents))\n\n\t\t// Set complexity override if provided (CLI flag or loom metadata)\n\t\tif (complexity) {\n\t\t\tvariables.COMPLEXITY_OVERRIDE = complexity\n\t\t}\n\n\t\t// Set draft PR mode flags (mutually exclusive)\n\t\t// When draftPrNumber is set, we're in draft-pr mode\n\t\tif (draftPrNumber !== undefined) {\n\t\t\tvariables.DRAFT_PR_MODE = true\n\t\t\tvariables.DRAFT_PR_NUMBER = draftPrNumber\n\t\t\tif (draftPrUrl) {\n\t\t\t\tvariables.DRAFT_PR_URL = draftPrUrl\n\t\t\t}\n\t\t\t// Set AUTO_COMMIT_PUSH when in draft PR mode and not explicitly disabled\n\t\t\t// Default is true (enabled) for draft PR mode\n\t\t\tconst autoCommitPushEnabled = this.settings?.mergeBehavior?.autoCommitPush !== false\n\t\t\tvariables.AUTO_COMMIT_PUSH = autoCommitPushEnabled\n\t\t\t// Set GIT_REMOTE from settings or default to 'origin'\n\t\t\tconst remote = this.settings?.mergeBehavior?.remote ?? 'origin'\n\t\t\tif (!/^[a-zA-Z0-9_-]+$/.test(remote)) {\n\t\t\t\tthrow new Error(`Invalid git remote name: \"${remote}\". Remote names can only contain alphanumeric characters, underscores, and hyphens.`)\n\t\t\t}\n\t\t\tvariables.GIT_REMOTE = remote\n\t\t} else if (context.type === 'regular') {\n\t\t\t// Branch mode without draft PR\n\t\t\tvariables.STANDARD_BRANCH_MODE = true\n\t\t} else {\n\t\t\t// Issue/PR mode without draft PR\n\t\t\tvariables.STANDARD_ISSUE_MODE = true\n\t\t}\n\n\t\t// Detect VS Code mode\n\t\tconst isVscodeMode = process.env.ILOOM_VSCODE === '1'\n\t\tvariables.IS_VSCODE_MODE = isVscodeMode\n\n\t\treturn variables\n\t}\n\n\t/**\n\t * Get the appropriate permission mode for a workflow type\n\t * Same logic as ClaudeService.getPermissionModeForWorkflow()\n\t */\n\tprivate getPermissionModeForWorkflow(\n\t\ttype: 'issue' | 'pr' | 'regular'\n\t): ClaudeCliOptions['permissionMode'] {\n\t\t// Check settings for configured permission mode\n\t\tif (this.settings?.workflows) {\n\t\t\tconst workflowConfig =\n\t\t\t\ttype === 'issue'\n\t\t\t\t\t? this.settings.workflows.issue\n\t\t\t\t\t: type === 'pr'\n\t\t\t\t\t\t? this.settings.workflows.pr\n\t\t\t\t\t\t: this.settings.workflows.regular\n\n\t\t\tif (workflowConfig?.permissionMode) {\n\t\t\t\treturn workflowConfig.permissionMode\n\t\t\t}\n\t\t}\n\n\t\t// Fall back to current defaults\n\t\tif (type === 'issue') {\n\t\t\treturn 'acceptEdits'\n\t\t}\n\t\t// For PR and regular workflows, use default permissions\n\t\treturn 'default'\n\t}\n\n\t/**\n\t * Auto-detect workspace context from current directory and git branch\n\t *\n\t * Detection priority:\n\t * 1. Directory name patterns (_pr_N, issue-N)\n\t * 2. Git branch name patterns\n\t * 3. Fallback to 'regular' workflow\n\t *\n\t * This leverages the same logic as FinishCommand.autoDetectFromCurrentDirectory()\n\t */\n\tprivate async detectWorkspaceContext(workspacePath?: string): Promise<ClaudeWorkflowOptions> {\n\t\tconst workspacePath_ = workspacePath ?? process.cwd()\n\t\tconst currentDir = path.basename(workspacePath_)\n\n\t\t// Check for PR worktree pattern: _pr_N suffix\n\t\t// Pattern: /.*_pr_(\\d+)$/\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\treturn this.buildContextForPR(prNumber, workspacePath_)\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\treturn this.buildContextForIssue(issueNumber, workspacePath_)\n\t\t}\n\n\t\t// Fallback: Try to extract from git branch name\n\t\ttry {\n\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\tconst currentBranch = repoInfo.currentBranch\n\n\t\t\tif (currentBranch) {\n\t\t\t\t// Try to extract issue from branch name\n\t\t\t\tconst branchIssueNumber = extractIssueNumber(currentBranch)\n\t\t\t\tif (branchIssueNumber !== null) {\n\t\t\t\t\tlogger.debug(`Auto-detected issue #${branchIssueNumber} from branch: ${currentBranch}`)\n\n\t\t\t\t\treturn this.buildContextForIssue(branchIssueNumber, workspacePath_, currentBranch)\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Git command failed - not a git repo or other git error\n\t\t\tlogger.debug('Could not detect from git branch', { error })\n\t\t}\n\n\t\t// Last resort: use regular workflow\n\t\tlogger.debug('No specific context detected, using regular workflow')\n\t\treturn this.buildContextForRegular(workspacePath_)\n\t}\n\n\t/**\n\t * Build context for issue workflow\n\t */\n\tprivate async buildContextForIssue(\n\t\tissueNumber: string | number,\n\t\tworkspacePath: string,\n\t\tbranchName?: string\n\t): Promise<ClaudeWorkflowOptions> {\n\t\t// Get branch name if not provided\n\t\tif (!branchName) {\n\t\t\ttry {\n\t\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\t\tbranchName = repoInfo.currentBranch ?? undefined\n\t\t\t} catch {\n\t\t\t\t// Ignore git errors\n\t\t\t}\n\t\t}\n\n\t\tconst context: ClaudeWorkflowOptions = {\n\t\t\ttype: 'issue',\n\t\t\tissueNumber,\n\t\t\tworkspacePath,\n\t\t\theadless: false, // Interactive mode\n\t\t}\n\n\t\tif (branchName !== undefined) {\n\t\t\tcontext.branchName = branchName\n\t\t}\n\n\t\treturn context\n\t}\n\n\t/**\n\t * Build context for PR workflow\n\t */\n\tprivate async buildContextForPR(\n\t\tprNumber: number,\n\t\tworkspacePath: string\n\t): Promise<ClaudeWorkflowOptions> {\n\t\t// Get branch name\n\t\tlet branchName: string | undefined\n\t\ttry {\n\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\tbranchName = repoInfo.currentBranch ?? undefined\n\t\t} catch {\n\t\t\t// Ignore git errors\n\t\t}\n\n\t\tconst context: ClaudeWorkflowOptions = {\n\t\t\ttype: 'pr',\n\t\t\tprNumber,\n\t\t\tworkspacePath,\n\t\t\theadless: false, // Interactive mode\n\t\t}\n\n\t\tif (branchName !== undefined) {\n\t\t\tcontext.branchName = branchName\n\t\t}\n\n\t\treturn context\n\t}\n\n\t/**\n\t * Build context for regular workflow\n\t */\n\tprivate async buildContextForRegular(workspacePath: string): Promise<ClaudeWorkflowOptions> {\n\t\t// Get branch name\n\t\tlet branchName: string | undefined\n\t\ttry {\n\t\t\tconst repoInfo = await this.gitWorktreeManager.getRepoInfo()\n\t\t\tbranchName = repoInfo.currentBranch ?? undefined\n\t\t} catch {\n\t\t\t// Ignore git errors\n\t\t}\n\n\t\tconst context: ClaudeWorkflowOptions = {\n\t\t\ttype: 'regular',\n\t\t\tworkspacePath,\n\t\t\theadless: false, // Interactive mode\n\t\t}\n\n\t\tif (branchName !== undefined) {\n\t\t\tcontext.branchName = branchName\n\t\t}\n\n\t\treturn context\n\t}\n\n\n\t/**\n\t * Fetch and store epic child issue data and dependency map in metadata\n\t *\n\t * Called during spin setup for epic looms. Fetches child issue details\n\t * and dependency relationships from the issue tracker, then persists\n\t * them in the loom metadata for use by the orchestrator.\n\t */\n\tprivate async fetchAndStoreEpicChildData(\n\t\tmetadataManager: MetadataManager,\n\t\tmetadata: import('../lib/MetadataManager.js').LoomMetadata,\n\t\tworktreePath: string,\n\t\tsettings: import('../lib/SettingsManager.js').IloomSettings,\n\t): Promise<void> {\n\t\tconst parentIssueNumber = metadata.issue_numbers[0]\n\t\tif (!parentIssueNumber) return\n\n\t\tlogger.info('Fetching child issue data for epic...')\n\n\t\ttry {\n\t\t\tconst issueTracker = IssueTrackerFactory.create(settings)\n\n\t\t\t// Fetch child issue details and build dependency map in parallel\n\t\t\tconst childIssueDetails = await fetchChildIssueDetails(\n\t\t\t\tparentIssueNumber, issueTracker\n\t\t\t)\n\n\t\t\tif (childIssueDetails.length === 0) {\n\t\t\t\tlogger.debug('No child issues found for epic')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Extract raw IDs for dependency map building (strip prefixes)\n\t\t\tconst childIds = childIssueDetails.map((child) => child.number.replace(/^#/, ''))\n\n\t\t\tconst dependencyMap = await buildDependencyMap(childIds, settings)\n\n\t\t\t// Persist to metadata\n\t\t\tawait metadataManager.updateMetadata(worktreePath, {\n\t\t\t\tchildIssues: childIssueDetails,\n\t\t\t\tdependencyMap,\n\t\t\t})\n\n\t\t\tlogger.info(`Stored ${childIssueDetails.length} child issues and dependency map in metadata`)\n\t\t} catch (error) {\n\t\t\t// Non-fatal: epic can still spin without child data\n\t\t\tlogger.warn(`Failed to fetch epic child data: ${error instanceof Error ? error.message : String(error)}`)\n\t\t}\n\t}\n\n\t/**\n\t * Execute swarm mode for an epic loom.\n\t *\n\t * Creates child worktrees, renders swarm agents/skill, builds the\n\t * orchestrator prompt, and launches Claude with agent teams enabled.\n\t */\n\tprivate async executeSwarmMode(\n\t\tmetadata: LoomMetadata,\n\t\tepicWorktreePath: string,\n\t\tepicBranch: string,\n\t\tmetadataManager: MetadataManager,\n\t\tskipCleanup?: boolean,\n\t): Promise<void> {\n\t\tif (!this.settings) {\n\t\t\tthrow new Error('Settings not loaded. Cannot enter swarm mode.')\n\t\t}\n\t\tconst settings = this.settings\n\t\tconst epicIssueNumber = metadata.issue_numbers[0]\n\t\tif (!epicIssueNumber) {\n\t\t\tthrow new Error('Epic loom has no issue number in metadata')\n\t\t}\n\n\t\tlogger.info('Epic loom detected - entering swarm mode...')\n\n\t\t// Determine main worktree path and issue tracker provider\n\t\tconst mainWorktreePath = await findMainWorktreePathWithSettings()\n\t\tconst providerName = IssueTrackerFactory.getProviderName(settings)\n\n\t\t// Create SwarmSetupService\n\t\tconst swarmSetup = new SwarmSetupService(\n\t\t\tthis.gitWorktreeManager,\n\t\t\tmetadataManager,\n\t\t\tthis.agentManager,\n\t\t\tthis.settingsManager,\n\t\t\tthis.templateManager,\n\t\t)\n\n\t\t// Generate and write per-loom MCP config file for the epic worktree\n\t\ttry {\n\t\t\tconst epicMcpConfigPath = await generateAndWriteMcpConfigFile(\n\t\t\t\tepicWorktreePath,\n\t\t\t\tmetadata,\n\t\t\t\tproviderName as 'github' | 'linear' | 'jira',\n\t\t\t\tsettings,\n\t\t\t)\n\t\t\tawait metadataManager.updateMetadata(epicWorktreePath, { mcpConfigPath: epicMcpConfigPath })\n\n\t\t\t// Write MCP config path to .claude/iloom-swarm-mcp-config-path for worker discovery\n\t\t\tconst epicClaudeDir = path.join(epicWorktreePath, '.claude')\n\t\t\tawait fs.ensureDir(epicClaudeDir)\n\t\t\tawait fs.writeFile(\n\t\t\t\tpath.join(epicClaudeDir, 'iloom-swarm-mcp-config-path'),\n\t\t\t\tepicMcpConfigPath,\n\t\t\t\t'utf-8',\n\t\t\t)\n\n\t\t\tlogger.debug('Wrote MCP config for epic loom', { epicMcpConfigPath })\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to write MCP config for epic loom: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Build MCP configs for the orchestrator's own launchClaude call\n\t\tconst mcpConfigs: Record<string, unknown>[] = []\n\n\t\t// Issue management MCP\n\t\ttry {\n\t\t\tconst issueMcpConfigs = await generateIssueManagementMcpConfig(\n\t\t\t\t'issue',\n\t\t\t\tundefined,\n\t\t\t\tproviderName as 'github' | 'linear' | 'jira',\n\t\t\t\tsettings,\n\t\t\t)\n\t\t\tmcpConfigs.push(...issueMcpConfigs)\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to generate issue management MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Recap MCP for the epic loom\n\t\ttry {\n\t\t\tconst recapMcpConfigs = generateRecapMcpConfig(epicWorktreePath, metadata)\n\t\t\tmcpConfigs.push(...recapMcpConfigs)\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to generate recap MCP config: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Filter out children that are already done (finished looms may have metadata\n\t\t// in the \"looms/finished\" directory, not just in active worktree metadata)\n\t\tconst finishedMetadata = await metadataManager.listFinishedMetadata()\n\t\tconst finishedByIssueNumber = new Map<string, LoomMetadata>()\n\t\tfor (const meta of finishedMetadata) {\n\t\t\t// Only consider finished metadata from the same project to avoid\n\t\t\t// cross-project collisions (issue numbers are not globally unique)\n\t\t\tif (meta.projectPath && meta.projectPath !== mainWorktreePath) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const issueNum of meta.issue_numbers) {\n\t\t\t\t// listFinishedMetadata returns newest first; preserve the newest entry\n\t\t\t\tif (!finishedByIssueNumber.has(issueNum)) {\n\t\t\t\t\tfinishedByIssueNumber.set(issueNum, meta)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst pendingChildIssues: typeof metadata.childIssues = []\n\t\tconst skippedChildren: Array<{ number: string; state: string }> = []\n\n\t\tfor (const child of metadata.childIssues) {\n\t\t\tconst rawId = child.number.replace(/^#/, '')\n\t\t\tconst safeId = rawId.replace(/[^a-zA-Z0-9-_]/g, '-')\n\t\t\tconst childBranch = `issue/${safeId}`\n\t\t\tconst childWorktreePath = generateWorktreePath(childBranch, mainWorktreePath)\n\n\t\t\t// Check active worktree metadata first, then fall back to finished metadata\n\t\t\tconst childMeta = await metadataManager.readMetadata(childWorktreePath)\n\t\t\t\t?? finishedByIssueNumber.get(rawId) ?? null\n\n\t\t\tif (childMeta?.state === 'done') {\n\t\t\t\tskippedChildren.push({ number: child.number, state: childMeta.state })\n\t\t\t} else {\n\t\t\t\tpendingChildIssues.push(child)\n\t\t\t}\n\t\t}\n\n\t\tif (skippedChildren.length > 0) {\n\t\t\tfor (const skipped of skippedChildren) {\n\t\t\t\tlogger.info(`Skipping child ${skipped.number} (state: ${skipped.state})`)\n\t\t\t}\n\t\t}\n\n\t\t// Run swarm setup (renders agents, worker agent, and wave verifier to epic worktree)\n\t\tawait swarmSetup.setupSwarm(\n\t\t\tepicBranch,\n\t\t\tepicWorktreePath,\n\t\t)\n\n\t\t// Build template variables for orchestrator prompt\n\t\tconst childIssuesData = pendingChildIssues\n\t\t\t.map((ci) => {\n\t\t\t\tconst rawId = ci.number.replace(/^#/, '')\n\t\t\t\tconst safeId = rawId.replace(/[^a-zA-Z0-9-_]/g, '-')\n\t\t\t\tconst branchName = `issue/${safeId}`\n\t\t\t\tconst worktreePath = generateWorktreePath(branchName, mainWorktreePath)\n\t\t\t\treturn {\n\t\t\t\t\tnumber: rawId,\n\t\t\t\t\ttitle: ci.title,\n\t\t\t\t\tbody: ci.body,\n\t\t\t\t\tworktreePath,\n\t\t\t\t\tbranchName,\n\t\t\t\t}\n\t\t\t})\n\n\t\t// Pre-create metadata and recap files for each child worktree.\n\t\t// On main, SwarmSetupService created worktrees + metadata together.\n\t\t// Now the orchestrator creates worktrees via `git worktree add`, but\n\t\t// metadata and recap files are still needed for set_loom_state and recap tracking.\n\t\tfor (const child of childIssuesData) {\n\t\t\ttry {\n\t\t\t\tawait metadataManager.writeMetadata(child.worktreePath, {\n\t\t\t\t\tdescription: child.title,\n\t\t\t\t\tbranchName: child.branchName,\n\t\t\t\t\tworktreePath: child.worktreePath,\n\t\t\t\t\tissueType: 'issue',\n\t\t\t\t\tissue_numbers: [child.number],\n\t\t\t\t\tpr_numbers: [],\n\t\t\t\t\tissueTracker: metadata.issueTracker ?? 'github',\n\t\t\t\t\tcolorHex: '#808080',\n\t\t\t\t\tsessionId: '',\n\t\t\t\t\tprojectPath: mainWorktreePath,\n\t\t\t\t\tissueUrls: {},\n\t\t\t\t\tprUrls: {},\n\t\t\t\t\tcapabilities: [],\n\t\t\t\t\tstate: 'pending',\n\t\t\t\t\tparentLoom: {\n\t\t\t\t\t\ttype: 'epic',\n\t\t\t\t\t\tidentifier: epicIssueNumber,\n\t\t\t\t\t\tbranchName: epicBranch,\n\t\t\t\t\t\tworktreePath: epicWorktreePath,\n\t\t\t\t\t},\n\t\t\t\t})\n\n\t\t\t\tconst recapFilePath = resolveRecapFilePath(child.worktreePath)\n\t\t\t\tawait writeRecapFile(recapFilePath, { goal: child.title })\n\t\t\t} catch (error) {\n\t\t\t\tlogger.warn(`Failed to pre-create metadata/recap for child #${child.number}: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t\t}\n\t\t}\n\n\t\t// Get metadata file path for the orchestrator prompt template\n\t\tconst epicMetadataPath = metadataManager.getMetadataFilePath(epicWorktreePath)\n\n\t\t// Determine issue prefix for commit message trailers\n\t\tconst issuePrefix = providerName === 'github' ? '#' : ''\n\n\t\t// Post-swarm review defaults to true (matches SpinAgentSettingsSchema default)\n\t\tconst postSwarmReview = settings.spin?.postSwarmReview !== false\n\n\t\t// Reuse existing swarm team name from metadata, or generate a new one\n\t\tlet swarmTeamName = metadata.swarmTeamName\n\t\tif (!swarmTeamName) {\n\t\t\tconst projectSlug = path.basename(mainWorktreePath).replace(/[^a-zA-Z0-9_-]/g, '-')\n\t\t\tswarmTeamName = `swarm-${projectSlug}-${epicIssueNumber}-${Date.now()}`\n\t\t\tawait metadataManager.updateMetadata(epicWorktreePath, { swarmTeamName })\n\t\t}\n\n\t\tconst variables: TemplateVariables = {\n\t\t\tEPIC_ISSUE_NUMBER: epicIssueNumber,\n\t\t\tSWARM_TEAM_NAME: swarmTeamName,\n\t\t\tEPIC_WORKTREE_PATH: epicWorktreePath,\n\t\t\tEPIC_METADATA_PATH: epicMetadataPath,\n\t\t\tCHILD_ISSUES: JSON.stringify(childIssuesData, null, 2),\n\t\t\tDEPENDENCY_MAP: JSON.stringify(metadata.dependencyMap, null, 2),\n\t\t\tISSUE_PREFIX: issuePrefix,\n\t\t\t...(skipCleanup && { NO_CLEANUP: true }),\n\t\t\t...(postSwarmReview && { POST_SWARM_REVIEW: true }),\n\t\t}\n\n\t\t// Set draft PR mode flags for swarm orchestrator (same logic as buildTemplateVariables)\n\t\tconst draftPrNumber = metadata.draftPrNumber ?? undefined\n\t\tif (draftPrNumber !== undefined) {\n\t\t\tvariables.DRAFT_PR_MODE = true\n\t\t\tvariables.DRAFT_PR_NUMBER = draftPrNumber\n\t\t\tconst draftPrUrl = metadata.prUrls?.[String(draftPrNumber)]\n\t\t\tif (draftPrUrl) {\n\t\t\t\tvariables.DRAFT_PR_URL = draftPrUrl\n\t\t\t}\n\t\t\tconst autoCommitPushEnabled = settings.mergeBehavior?.autoCommitPush !== false\n\t\t\tvariables.AUTO_COMMIT_PUSH = autoCommitPushEnabled\n\t\t\tconst remote = settings.mergeBehavior?.remote ?? 'origin'\n\t\t\tif (!/^[a-zA-Z0-9_-]+$/.test(remote)) {\n\t\t\t\tthrow new Error(`Invalid git remote name: \"${remote}\". Remote names can only contain alphanumeric characters, underscores, and hyphens.`)\n\t\t\t}\n\t\t\tvariables.GIT_REMOTE = remote\n\t\t}\n\n\t\tconst orchestratorPrompt = await this.templateManager.getPrompt('swarm-orchestrator', variables)\n\n\t\t// Build allowed tools\n\t\tconst allowedTools = [\n\t\t\t'mcp__issue_management__get_issue',\n\t\t\t'mcp__issue_management__get_comment',\n\t\t\t'mcp__issue_management__create_comment',\n\t\t\t'mcp__issue_management__update_comment',\n\t\t\t'mcp__issue_management__create_issue',\n\t\t\t'mcp__issue_management__close_issue',\n\t\t\t'mcp__issue_management__reopen_issue',\n\t\t\t'mcp__issue_management__edit_issue',\n\t\t\t'mcp__recap__add_entry',\n\t\t\t'mcp__recap__get_recap',\n\t\t\t'mcp__recap__add_artifact',\n\t\t\t'mcp__recap__set_complexity',\n\t\t\t'mcp__recap__set_loom_state',\n\t\t\t'mcp__recap__get_loom_state',\n\t\t]\n\n\t\t// Launch Claude with agent teams enabled\n\t\tconst model = this.settingsManager.getSpinModel(settings, 'swarm')\n\n\t\tlogger.info('Launching swarm orchestrator...')\n\t\tlogger.info(` Model: ${model ?? 'default'}`)\n\t\tlogger.info(` Permission mode: bypassPermissions`)\n\t\tlogger.info(` Agent teams: enabled`)\n\t\tlogger.info(` Pending child issues: ${pendingChildIssues.length}`)\n\n\t\t// Load agents for the orchestrator\n\t\tlet agents: Record<string, unknown> | undefined\n\t\ttry {\n\t\t\tagents = await this.agentManager.loadAndPrepare(\n\t\t\t\tsettings,\n\t\t\t\tvariables,\n\t\t\t\t['*.md', '!iloom-framework-detector.md'],\n\t\t\t\tpath.join(epicWorktreePath, '.claude', 'agents')\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tlogger.warn(`Failed to load agents: ${error instanceof Error ? error.message : 'Unknown error'}`)\n\t\t}\n\n\t\t// Track swarm.started before launching orchestrator\n\t\tconst swarmStartTime = Date.now()\n\t\ttry {\n\t\t\tTelemetryService.getInstance().track('swarm.started', {\n\t\t\t\tchild_count: pendingChildIssues.length,\n\t\t\t\ttracker: providerName,\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tlogger.debug(`Telemetry swarm.started tracking failed: ${error instanceof Error ? error.message : error}`)\n\t\t}\n\n\t\t// Prepare orchestrator prompt by writing to file\n\t\tconst orchestratorPromptConfig = await prepareSystemPromptForPlatform(\n\t\t\torchestratorPrompt,\n\t\t\tepicWorktreePath,\n\t\t)\n\n\t\tconst swarmUserPrompt = `You are the swarm orchestrator for epic #${epicIssueNumber}. Begin by reading your system prompt instructions and executing the workflow.`\n\n\t\t// Set env vars directly on process.env so they propagate to Claude Code\n\t\t// and its child processes (execa's env option doesn't reliably pass them)\n\t\tprocess.env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS = '1'\n\t\tprocess.env.ILOOM_SWARM = '1'\n\t\tprocess.env.ENABLE_TOOL_SEARCH = 'auto:30'\n\t\tprocess.env.CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING = '1'\n\t\tprocess.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY = '1'\n\t\tprocess.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = '1'\n\t\tprocess.env.CLAUDE_CODE_EFFORT_LEVEL = 'medium'\n\n\t\tawait launchClaude(swarmUserPrompt, {\n\t\t\tmodel,\n\t\t\tpermissionMode: 'bypassPermissions',\n\t\t\taddDir: epicWorktreePath,\n\t\t\theadless: false,\n\t\t\t...(metadata.sessionId && { sessionId: metadata.sessionId }),\n\t\t\tappendSystemPromptFile: orchestratorPromptConfig.appendSystemPromptFile,\n\t\t\tmcpConfig: mcpConfigs,\n\t\t\tallowedTools,\n\t\t\t...(agents && { agents }),\n\t\t})\n\n\t\t// Track swarm child completions and overall completion\n\t\ttry {\n\t\t\tconst swarmEndTime = Date.now()\n\t\t\tlet succeeded = 0\n\t\t\tlet failed = 0\n\n\t\t\tfor (const child of pendingChildIssues) {\n\t\t\t\tconst rawId = child.number.replace(/^#/, '')\n\t\t\t\tconst safeId = rawId.replace(/[^a-zA-Z0-9-_]/g, '-')\n\t\t\t\tconst childBranch = `issue/${safeId}`\n\t\t\t\tconst childWorktreePath = generateWorktreePath(childBranch, mainWorktreePath)\n\t\t\t\tconst childMeta = await metadataManager.readMetadata(childWorktreePath)\n\t\t\t\tconst isSuccess = childMeta?.state === 'done'\n\t\t\t\tif (isSuccess) {\n\t\t\t\t\tsucceeded++\n\t\t\t\t} else {\n\t\t\t\t\tfailed++\n\t\t\t\t}\n\n\t\t\t\tconst parsed = childMeta?.created_at ? Date.parse(childMeta.created_at) : NaN\n\t\t\t\tconst childCreatedAt = Number.isNaN(parsed) ? swarmStartTime : parsed\n\t\t\t\tconst childDuration = Math.max(0, Math.round((swarmEndTime - childCreatedAt) / 60000))\n\n\t\t\t\tTelemetryService.getInstance().track('swarm.child_completed', {\n\t\t\t\t\tsuccess: isSuccess,\n\t\t\t\t\tduration_minutes: childDuration,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tTelemetryService.getInstance().track('swarm.completed', {\n\t\t\t\ttotal_children: pendingChildIssues.length,\n\t\t\t\tsucceeded,\n\t\t\t\tfailed,\n\t\t\t\tduration_minutes: Math.round((swarmEndTime - swarmStartTime) / 60000),\n\t\t\t})\n\t\t} catch (error) {\n\t\t\tlogger.debug(`Telemetry swarm completion tracking failed: ${error instanceof Error ? error.message : error}`)\n\t\t}\n\t}\n\n\t/**\n\t * Build user prompt based on one-shot mode\n\t */\n\tprivate buildUserPrompt(oneShot: OneShotMode = 'default'): string {\n\t\t// For one-shot modes, add bypass instructions to override template approval requirements\n\t\tif (oneShot === 'noReview' || oneShot === 'bypassPermissions') {\n\t\t\treturn 'Guide the user through the iloom workflow! The user has requested you move through the workflow without awaiting confirmation. This supersedes any other guidance.'\n\t\t}\n\n\t\t// Default mode: simple \"Go!\" prompt\n\t\treturn 'Guide the user through the iloom workflow!'\n\t}\n\n\t/**\n\t * Load README.md content for first-time users\n\t * Walks up from dist directory to find README.md in project root\n\t */\n\tprivate async loadReadmeContent(): Promise<string> {\n\t\ttry {\n\t\t\t// Walk up from current file location to find README.md\n\t\t\t// Use same pattern as PromptTemplateManager for finding files\n\t\t\tlet currentDir = path.dirname(new URL(import.meta.url).pathname)\n\n\t\t\t// Walk up to find README.md\n\t\t\twhile (currentDir !== path.dirname(currentDir)) {\n\t\t\t\tconst readmePath = path.join(currentDir, 'README.md')\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await readFile(readmePath, 'utf-8')\n\t\t\t\t\tlogger.debug('Loaded README.md for first-time user', { readmePath })\n\t\t\t\t\treturn content\n\t\t\t\t} catch {\n\t\t\t\t\tcurrentDir = path.dirname(currentDir)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug('README.md not found, returning empty string')\n\t\t\treturn ''\n\t\t} catch (error) {\n\t\t\t// Graceful degradation - return empty string on error\n\t\t\tlogger.debug(`Failed to load README.md: ${error}`)\n\t\t\treturn ''\n\t\t}\n\t}\n\n\t/**\n\t * Load settings schema content for first-time users\n\t * Walks up from dist directory to find .iloom/README.md\n\t */\n\tprivate async loadSettingsSchemaContent(): Promise<string> {\n\t\ttry {\n\t\t\t// Walk up from current file location to find .iloom/README.md\n\t\t\tlet currentDir = path.dirname(new URL(import.meta.url).pathname)\n\n\t\t\t// Walk up to find .iloom/README.md\n\t\t\twhile (currentDir !== path.dirname(currentDir)) {\n\t\t\t\tconst schemaPath = path.join(currentDir, '.iloom', 'README.md')\n\t\t\t\ttry {\n\t\t\t\t\tconst content = await readFile(schemaPath, 'utf-8')\n\t\t\t\t\tlogger.debug('Loaded .iloom/README.md for first-time user', { schemaPath })\n\t\t\t\t\treturn content\n\t\t\t\t} catch {\n\t\t\t\t\tcurrentDir = path.dirname(currentDir)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlogger.debug('.iloom/README.md not found, returning empty string')\n\t\t\treturn ''\n\t\t} catch (error) {\n\t\t\t// Graceful degradation - return empty string on error\n\t\t\tlogger.debug(`Failed to load .iloom/README.md: ${error}`)\n\t\t\treturn ''\n\t\t}\n\t}\n}\n","import os from 'os'\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { parse, modify, applyEdits, ParseError } from 'jsonc-parser'\nimport { fileURLToPath } from 'url'\nimport { accessSync } from 'fs'\nimport { logger } from '../utils/logger.js'\n\n/**\n * Hook configuration for a single event\n */\ninterface HookEntry {\n\ttype: 'command'\n\tcommand: string\n\ttimeout?: number\n}\n\n/**\n * Hook event configuration\n */\ninterface HookEventConfig {\n\tmatcher?: string\n\thooks: HookEntry[]\n}\n\n/**\n * Claude settings.json structure (partial)\n */\ninterface ClaudeSettings {\n\thooks?: Record<string, HookEventConfig[]>\n\t[key: string]: unknown\n}\n\n/**\n * Manages installation of Claude Code hooks to ~/.claude/\n *\n * Hooks enable real-time monitoring of Claude session state\n * via Unix socket communication with the iloom-vscode extension.\n */\nexport class ClaudeHookManager {\n\tprivate claudeDir: string\n\tprivate hooksDir: string\n\tprivate settingsPath: string\n\tprivate templateDir: string\n\n\tconstructor() {\n\t\t// Initialize paths using os.homedir()\n\t\tthis.claudeDir = path.join(os.homedir(), '.claude')\n\t\tthis.hooksDir = path.join(this.claudeDir, 'hooks')\n\t\tthis.settingsPath = path.join(this.claudeDir, 'settings.json')\n\n\t\t// Find templates relative to the package installation\n\t\t// Same pattern as PromptTemplateManager\n\t\tconst currentFileUrl = import.meta.url\n\t\tconst currentFilePath = fileURLToPath(currentFileUrl)\n\t\tconst distDir = path.dirname(currentFilePath)\n\n\t\t// Walk up to find the hooks template directory\n\t\tlet templateDir = path.join(distDir, 'hooks')\n\t\tlet currentDir = distDir\n\n\t\twhile (currentDir !== path.dirname(currentDir)) {\n\t\t\tconst candidatePath = path.join(currentDir, 'hooks')\n\t\t\ttry {\n\t\t\t\taccessSync(candidatePath)\n\t\t\t\ttemplateDir = candidatePath\n\t\t\t\tbreak\n\t\t\t} catch {\n\t\t\t\tcurrentDir = path.dirname(currentDir)\n\t\t\t}\n\t\t}\n\n\t\tthis.templateDir = templateDir\n\t\tlogger.debug('ClaudeHookManager initialized', {\n\t\t\tclaudeDir: this.claudeDir,\n\t\t\thooksDir: this.hooksDir,\n\t\t\tsettingsPath: this.settingsPath,\n\t\t\ttemplateDir: this.templateDir\n\t\t})\n\t}\n\n\t/**\n\t * Install Claude hooks for VSCode integration\n\t *\n\t * This is idempotent - safe to call on every spin.\n\t * Installs hook script to ~/.claude/hooks/ and merges\n\t * hook configuration into ~/.claude/settings.json\n\t */\n\tasync installHooks(): Promise<void> {\n\t\ttry {\n\t\t\t// 1. Create ~/.claude/hooks if missing\n\t\t\tawait fs.ensureDir(this.hooksDir)\n\n\t\t\t// 2. Install hook script from bundled templates\n\t\t\tawait this.installHookScript()\n\n\t\t\t// 3. Merge hook config into settings.json\n\t\t\tawait this.mergeHookConfig()\n\n\t\t\tlogger.debug('Claude hooks installed successfully')\n\t\t} catch (error) {\n\t\t\t// Log warning but don't fail - hooks are optional enhancement\n\t\t\tlogger.warn(\n\t\t\t\t`Failed to install Claude hooks: ${error instanceof Error ? error.message : 'Unknown error'}`\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Check if hooks are already installed\n\t */\n\tasync isHooksInstalled(): Promise<boolean> {\n\t\ttry {\n\t\t\t// Check if hook script exists\n\t\t\tconst hookScriptPath = path.join(this.hooksDir, 'iloom-hook.js')\n\t\t\tif (!(await fs.pathExists(hookScriptPath))) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Check if settings.json has our hooks\n\t\t\tif (!(await fs.pathExists(this.settingsPath))) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tconst content = await fs.readFile(this.settingsPath, 'utf8')\n\t\t\tconst errors: ParseError[] = []\n\t\t\tconst settings = parse(content, errors, { allowTrailingComma: true }) as ClaudeSettings\n\n\t\t\tif (errors.length > 0 || !settings?.hooks) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Check if our hooks are registered (check for SessionStart as indicator)\n\t\t\treturn Array.isArray(settings.hooks.SessionStart)\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Install the hook script from bundled templates\n\t * Skips write if destination already has identical content\n\t */\n\tprivate async installHookScript(): Promise<void> {\n\t\tconst sourcePath = path.join(this.templateDir, 'iloom-hook.js')\n\t\tconst destPath = path.join(this.hooksDir, 'iloom-hook.js')\n\n\t\t// Check if source template exists\n\t\tif (!(await fs.pathExists(sourcePath))) {\n\t\t\tthrow new Error(`Hook template not found at ${sourcePath}`)\n\t\t}\n\n\t\t// Skip if destination exists and content matches\n\t\tif (await fs.pathExists(destPath)) {\n\t\t\tconst [sourceContent, destContent] = await Promise.all([\n\t\t\t\tfs.readFile(sourcePath, 'utf8'),\n\t\t\t\tfs.readFile(destPath, 'utf8')\n\t\t\t])\n\t\t\tif (sourceContent === destContent) {\n\t\t\t\tlogger.debug('Hook script already up to date, skipping')\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// Copy hook script (only when content differs or doesn't exist)\n\t\tawait fs.copyFile(sourcePath, destPath)\n\t\tlogger.debug('Hook script installed', { sourcePath, destPath })\n\t}\n\n\t/**\n\t * Merge hook configuration into settings.json\n\t * Preserves existing user hooks and comments\n\t */\n\tprivate async mergeHookConfig(): Promise<void> {\n\t\t// Ensure ~/.claude directory exists\n\t\tawait fs.ensureDir(this.claudeDir)\n\n\t\t// Read existing settings (or create empty)\n\t\tlet existingContent = '{}'\n\t\tlet existingSettings: ClaudeSettings = {}\n\n\t\tif (await fs.pathExists(this.settingsPath)) {\n\t\t\texistingContent = await fs.readFile(this.settingsPath, 'utf8')\n\t\t\tconst errors: ParseError[] = []\n\t\t\texistingSettings = parse(existingContent, errors, { allowTrailingComma: true }) as ClaudeSettings\n\n\t\t\tif (errors.length > 0) {\n\t\t\t\tlogger.warn('Existing settings.json has parse errors, will attempt to merge anyway')\n\t\t\t}\n\t\t}\n\n\t\t// Get our hook configuration\n\t\tconst ourHooks = this.getHookConfig()\n\n\t\t// Merge hooks - preserve user's existing hooks on same events\n\t\tconst mergedHooks: Record<string, HookEventConfig[]> = { ...(existingSettings.hooks ?? {}) }\n\t\tlet hooksAdded = false\n\n\t\tfor (const [eventName, eventConfigs] of Object.entries(ourHooks)) {\n\t\t\tconst existing = mergedHooks[eventName] ?? []\n\n\t\t\t// Check if our hook is already registered\n\t\t\tconst ourConfig = eventConfigs[0]\n\t\t\tconst ourCommand = ourConfig?.hooks?.[0]?.command\n\t\t\tconst existingConfigIndex = existing.findIndex(\n\t\t\t\t(config) => config.hooks?.some((h) => h.command === ourCommand)\n\t\t\t)\n\n\t\t\tif (existingConfigIndex === -1) {\n\t\t\t\t// Add our hook config to the event\n\t\t\t\tmergedHooks[eventName] = [...existing, ...eventConfigs]\n\t\t\t\thooksAdded = true\n\t\t\t} else {\n\t\t\t\t// Hook is already registered - check if we need to update the matcher\n\t\t\t\tconst existingConfig = existing[existingConfigIndex]\n\t\t\t\tconst ourMatcher = ourConfig?.matcher\n\n\t\t\t\t// Update matcher if our config has one and existing doesn't match\n\t\t\t\tif (existingConfig && ourMatcher !== undefined && existingConfig.matcher !== ourMatcher) {\n\t\t\t\t\texisting[existingConfigIndex] = {\n\t\t\t\t\t\t...existingConfig,\n\t\t\t\t\t\tmatcher: ourMatcher\n\t\t\t\t\t}\n\t\t\t\t\thooksAdded = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Skip write if no new hooks were added\n\t\tif (!hooksAdded) {\n\t\t\tlogger.debug('All hooks already registered, skipping settings.json update')\n\t\t\treturn\n\t\t}\n\n\t\t// Write updated settings\n\t\tlet content: string\n\n\t\t// Check if existing content has comments\n\t\tif (existingContent.includes('//') || existingContent.includes('/*')) {\n\t\t\t// Use jsonc-parser to preserve comments\n\t\t\tlet modifiedContent = existingContent\n\t\t\tconst edits = modify(modifiedContent, ['hooks'], mergedHooks, {})\n\t\t\tcontent = applyEdits(modifiedContent, edits)\n\t\t} else {\n\t\t\t// No comments - use JSON.stringify\n\t\t\tconst updatedSettings: ClaudeSettings = {\n\t\t\t\t...existingSettings,\n\t\t\t\thooks: mergedHooks\n\t\t\t}\n\t\t\tcontent = JSON.stringify(updatedSettings, null, 2) + '\\n'\n\t\t}\n\n\t\t// Write atomically using temp file + rename\n\t\tconst tempPath = `${this.settingsPath}.tmp`\n\t\tawait fs.writeFile(tempPath, content, 'utf8')\n\t\tawait fs.rename(tempPath, this.settingsPath)\n\n\t\tlogger.debug('Hook configuration merged into settings.json')\n\t}\n\n\t/**\n\t * Get the hook configuration to register\n\t *\n\t * Each event maps to a hook that runs iloom-hook.js\n\t */\n\tprivate getHookConfig(): Record<string, HookEventConfig[]> {\n\t\tconst hookCommand = `node ${path.join(this.hooksDir, 'iloom-hook.js')}`\n\n\t\treturn {\n\t\t\tNotification: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tStop: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tSubagentStop: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tPermissionRequest: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand, timeout: 86400 }] }\n\t\t\t],\n\t\t\tPreToolUse: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tPostToolUse: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tSessionStart: [\n\t\t\t\t{ matcher: '*', hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tSessionEnd: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t],\n\t\t\tUserPromptSubmit: [\n\t\t\t\t{ hooks: [{ type: 'command', command: hookCommand }] }\n\t\t\t]\n\t\t}\n\t}\n}\n","import path from 'path'\nimport fs from 'fs-extra'\nimport { GitWorktreeManager } from './GitWorktreeManager.js'\nimport { MetadataManager, type WriteMetadataInput, type SwarmState } from './MetadataManager.js'\nimport { AgentManager } from './AgentManager.js'\nimport { SettingsManager, type IloomSettings } from './SettingsManager.js'\nimport { PromptTemplateManager, buildReviewTemplateVariables, type TemplateVariables } from './PromptTemplateManager.js'\nimport { IssueTrackerFactory } from './IssueTrackerFactory.js'\nimport { IssueManagementProviderFactory } from '../mcp/IssueManagementProviderFactory.js'\nimport { getLogger } from '../utils/logger-context.js'\nimport { preAcceptClaudeTrust } from '../utils/claude-trust.js'\nimport { installDependencies } from '../utils/package-manager.js'\nimport { generateWorktreePath } from '../utils/git.js'\nimport { generateAndWriteMcpConfigFile } from '../utils/mcp.js'\n\n/**\n * Result of the swarm setup process\n */\nexport interface SwarmSetupResult {\n\tepicWorktreePath: string\n\tepicBranch: string\n\tskillsRendered: string[]\n\trenderedAgents: string[]\n\tworkerAgentRendered: boolean\n\tverifierAgentRendered: boolean\n}\n\n/**\n * Child issue data as stored in epic metadata\n */\nexport interface SwarmChildIssue {\n\tnumber: string // Prefixed: \"#123\" for GitHub, \"ENG-123\" for Linear\n\ttitle: string\n\tbody: string\n\turl: string\n}\n\n/**\n * SwarmSetupService handles the creation of child worktrees\n * for swarm mode, plus rendering swarm-mode agents and skill files.\n *\n * Called from the spin command (ignite.ts) when an epic loom is detected.\n * The epic worktree already exists (created by `il start`).\n */\nexport class SwarmSetupService {\n\tconstructor(\n\t\tprivate gitWorktree: GitWorktreeManager,\n\t\tprivate metadataManager: MetadataManager,\n\t\tprivate agentManager: AgentManager,\n\t\tprivate settingsManager: SettingsManager,\n\t\tprivate templateManager: PromptTemplateManager,\n\t) {}\n\n\t/**\n\t * Create child worktrees for each child issue, branched off the epic branch.\n\t * Writes iloom-metadata.json for each child with state: 'pending' and parentLoom.\n\t * Generates and writes per-loom MCP config file for each child.\n\t *\n\t * Uses standard iloom naming conventions via generateWorktreePath().\n\t *\n\t * @param childIssues - Array of child issues from epic metadata\n\t * @param epicBranch - The epic branch name (base branch for children)\n\t * @param epicWorktreePath - Path to the epic worktree\n\t * @param mainWorktreePath - Path to the main worktree (project root)\n\t * @param epicIssueNumber - The parent epic issue number\n\t * @param issueTrackerName - The issue tracker provider name (e.g., 'github')\n\t * @param settings - Optional settings for MCP config generation\n\t * @returns Array of results for each child worktree creation\n\t */\n\tasync createChildWorktrees(\n\t\tchildIssues: SwarmChildIssue[],\n\t\tepicBranch: string,\n\t\tepicWorktreePath: string,\n\t\tmainWorktreePath: string,\n\t\tepicIssueNumber: string | number,\n\t\tissueTrackerName: string,\n\t\tsettings?: IloomSettings,\n\t): Promise<Array<{\n\t\tissueId: string\n\t\tworktreePath: string\n\t\tbranch: string\n\t\tsuccess: boolean\n\t\terror?: string\n\t}>> {\n\t\treturn Promise.all(childIssues.map(async (child) => {\n\t\t\ttry {\n\t\t\t\t// Strip prefix from child number (e.g., \"#123\" -> \"123\", \"ENG-123\" stays as-is for branch naming)\n\t\t\t\tconst rawId = child.number.replace(/^#/, '')\n\n\t\t\t\t// Sanitize ID for safe git branch naming (replace non-alphanumeric except - and _ with -)\n\t\t\t\tconst safeId = rawId.replace(/[^a-zA-Z0-9-_]/g, '-')\n\n\t\t\t\t// Use standard iloom branch naming: issue/<id> pattern\n\t\t\t\tconst childBranch = `issue/${safeId}`\n\n\t\t\t\t// Use standard iloom worktree path generation\n\t\t\t\tconst childWorktreePath = generateWorktreePath(\n\t\t\t\t\tchildBranch,\n\t\t\t\t\tmainWorktreePath,\n\t\t\t\t)\n\n\t\t\t\tgetLogger().info(`Creating child worktree for ${child.number}: ${childWorktreePath}...`)\n\n\t\t\t\tawait this.gitWorktree.createWorktree({\n\t\t\t\t\tpath: childWorktreePath,\n\t\t\t\t\tbranch: childBranch,\n\t\t\t\t\tcreateBranch: true,\n\t\t\t\t\tbaseBranch: epicBranch,\n\t\t\t\t})\n\n\t\t\t\t// Pre-accept Claude Code trust for child worktree\n\t\t\t\ttry {\n\t\t\t\t\tawait preAcceptClaudeTrust(childWorktreePath)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tgetLogger().warn(`Failed to pre-accept Claude trust for child worktree: ${error instanceof Error ? error.message : String(error)}`)\n\t\t\t\t}\n\n\t\t\t\t// Write metadata with state: 'pending' and parentLoom\n\t\t\t\tconst metadataInput: WriteMetadataInput = {\n\t\t\t\t\tdescription: child.title,\n\t\t\t\t\tbranchName: childBranch,\n\t\t\t\t\tworktreePath: childWorktreePath,\n\t\t\t\t\tissueType: 'issue',\n\t\t\t\t\tissue_numbers: [rawId],\n\t\t\t\t\tpr_numbers: [],\n\t\t\t\t\tissueTracker: issueTrackerName,\n\t\t\t\t\tcolorHex: '#808080',\n\t\t\t\t\tsessionId: '', // No session - not launching Claude directly\n\t\t\t\t\tprojectPath: mainWorktreePath,\n\t\t\t\t\tissueUrls: { [rawId]: child.url },\n\t\t\t\t\tprUrls: {},\n\t\t\t\t\tcapabilities: [],\n\t\t\t\t\tstate: 'pending' as SwarmState,\n\t\t\t\t\tparentLoom: {\n\t\t\t\t\t\ttype: 'epic',\n\t\t\t\t\t\tidentifier: epicIssueNumber,\n\t\t\t\t\t\tbranchName: epicBranch,\n\t\t\t\t\t\tworktreePath: epicWorktreePath,\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait this.metadataManager.writeMetadata(childWorktreePath, metadataInput)\n\t\t\t\t} catch (metaError) {\n\t\t\t\t\t// Clean up the worktree to avoid zombie worktrees without metadata\n\t\t\t\t\tgetLogger().warn(`Metadata write failed for ${child.number}, cleaning up worktree...`)\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.gitWorktree.removeWorktree(childWorktreePath, { force: true })\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tgetLogger().debug(`Could not clean up worktree at ${childWorktreePath}`)\n\t\t\t\t\t}\n\t\t\t\t\tthrow metaError\n\t\t\t\t}\n\n\t\t\t\t// Generate and write per-loom MCP config file\n\t\t\t\ttry {\n\t\t\t\t\tconst childMetadata = await this.metadataManager.readMetadata(childWorktreePath)\n\t\t\t\t\tif (childMetadata) {\n\t\t\t\t\t\tconst providerName = IssueTrackerFactory.getProviderName(\n\t\t\t\t\t\t\tsettings ?? await this.settingsManager.loadSettings(),\n\t\t\t\t\t\t) as 'github' | 'linear' | 'jira'\n\t\t\t\t\t\tconst mcpConfigPath = await generateAndWriteMcpConfigFile(\n\t\t\t\t\t\t\tchildWorktreePath,\n\t\t\t\t\t\t\tchildMetadata,\n\t\t\t\t\t\t\tproviderName,\n\t\t\t\t\t\t\tsettings,\n\t\t\t\t\t\t)\n\t\t\t\t\t\tawait this.metadataManager.updateMetadata(childWorktreePath, { mcpConfigPath })\n\n\t\t\t\t\t\t// Write MCP config path to .claude/iloom-swarm-mcp-config-path for worker discovery\n\t\t\t\t\t\tconst claudeDir = path.join(childWorktreePath, '.claude')\n\t\t\t\t\t\tawait fs.ensureDir(claudeDir)\n\t\t\t\t\t\tawait fs.writeFile(\n\t\t\t\t\t\t\tpath.join(claudeDir, 'iloom-swarm-mcp-config-path'),\n\t\t\t\t\t\t\tmcpConfigPath,\n\t\t\t\t\t\t\t'utf-8',\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tgetLogger().debug(`Wrote MCP config for ${child.number}: ${mcpConfigPath}`)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Non-fatal: child can still work without MCP config\n\t\t\t\t\tgetLogger().warn(\n\t\t\t\t\t\t`Failed to write MCP config for child ${child.number}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\t// Install dependencies in the child worktree\n\t\t\t\ttry {\n\t\t\t\t\tawait installDependencies(childWorktreePath, true, true)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tgetLogger().warn(\n\t\t\t\t\t\t`Failed to install dependencies in child worktree ${child.number}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tgetLogger().success(`Created child worktree for ${child.number}`)\n\t\t\t\treturn {\n\t\t\t\t\tissueId: rawId,\n\t\t\t\t\tworktreePath: childWorktreePath,\n\t\t\t\t\tbranch: childBranch,\n\t\t\t\t\tsuccess: true,\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconst rawId = child.number.replace(/^#/, '')\n\t\t\t\tconst errorMessage = error instanceof Error ? error.message : 'Unknown error'\n\t\t\t\tgetLogger().warn(`Failed to create child worktree for ${child.number}: ${errorMessage}`)\n\t\t\t\treturn {\n\t\t\t\t\tissueId: rawId,\n\t\t\t\t\tworktreePath: '',\n\t\t\t\t\tbranch: '',\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: errorMessage,\n\t\t\t\t}\n\t\t\t}\n\t\t}))\n\t}\n\n\t/**\n\t * Render swarm-mode agent templates as custom agent files AND thin skill wrappers.\n\t *\n\t * For each phase agent, two files are written:\n\t * 1. Agent file at `.claude/agents/iloom-swarm-<phase>.md` - contains frontmatter\n\t * (name, description, model) and the full agent prompt as body.\n\t * 2. Thin skill wrapper at `.claude/skills/iloom-swarm-<phase>/SKILL.md` - contains\n\t * frontmatter with `agent: iloom-swarm-<phase>` and a minimal body.\n\t *\n\t * Skills are auto-discovered by Claude Code and invoked via /skill-name syntax.\n\t * The agent file carries the real prompt; the skill just delegates to it.\n\t */\n\tasync renderSwarmAgents(epicWorktreePath: string): Promise<{\n\t\trenderedSkills: string[]\n\t\trenderedAgents: string[]\n\t}> {\n\t\tconst claudeSkillsDir = path.join(epicWorktreePath, '.claude', 'skills')\n\t\tconst claudeAgentsDir = path.join(epicWorktreePath, '.claude', 'agents')\n\t\tawait fs.ensureDir(claudeSkillsDir)\n\t\tawait fs.ensureDir(claudeAgentsDir)\n\n\t\tconst settings = await this.settingsManager.loadSettings()\n\n\t\tconst templateVariables: TemplateVariables = {\n\t\t\tSWARM_MODE: true,\n\t\t\tEPIC_WORKTREE_PATH: epicWorktreePath,\n\t\t}\n\n\t\tconst agents = await this.agentManager.loadAgents(settings, templateVariables)\n\n\t\t// Default swarmModel map for \"Balanced\" mode. All swarm phase agents are\n\t\t// listed explicitly so that swarm mode never accidentally inherits a\n\t\t// non-swarm model override. User-configured swarmModel values always\n\t\t// take precedence.\n\t\tconst defaultSwarmModels: Record<string, 'sonnet' | 'opus' | 'haiku'> = {\n\t\t\t'iloom-issue-analyzer': 'opus',\n\t\t\t'iloom-issue-analyze-and-plan': 'opus',\n\t\t\t'iloom-issue-planner': 'sonnet',\n\t\t\t'iloom-issue-implementer': 'sonnet',\n\t\t\t'iloom-issue-enhancer': 'sonnet',\n\t\t\t'iloom-code-reviewer': 'sonnet',\n\t\t\t'iloom-issue-complexity-evaluator': 'haiku',\n\t\t}\n\n\t\t// Apply per-agent swarmModel overrides (user-configured takes precedence over defaults)\n\t\tfor (const [agentName, agentConfig] of Object.entries(agents)) {\n\t\t\tconst userSwarmModel = settings?.agents?.[agentName]?.swarmModel\n\t\t\tif (userSwarmModel) {\n\t\t\t\tagents[agentName] = { ...agentConfig, model: userSwarmModel }\n\t\t\t} else if (defaultSwarmModels[agentName]) {\n\t\t\t\tagents[agentName] = { ...agentConfig, model: defaultSwarmModels[agentName] }\n\t\t\t}\n\t\t}\n\n\t\tconst renderedSkills: string[] = []\n\t\tconst renderedAgents: string[] = []\n\n\t\t// Agents that are rendered as standalone custom agent types (with frontmatter\n\t\t// in .claude/agents/) rather than as skills. These are skipped here\n\t\t// and rendered separately with their own dedicated methods.\n\t\tconst standaloneAgents = new Set(['iloom-wave-verifier'])\n\n\t\tfor (const [agentName, agentConfig] of Object.entries(agents)) {\n\t\t\tif (standaloneAgents.has(agentName)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Compute agent/skill name: iloom-swarm-<phase>\n\t\t\tconst swarmName = agentName.startsWith('iloom-')\n\t\t\t\t? `iloom-swarm-${agentName.slice('iloom-'.length)}`\n\t\t\t\t: `iloom-swarm-${agentName}`\n\n\t\t\t// 1. Write agent file to .claude/agents/<swarmName>.md\n\t\t\tconst agentFrontmatter = [\n\t\t\t\t'---',\n\t\t\t\t`name: ${swarmName}`,\n\t\t\t\t`description: ${agentConfig.description}`,\n\t\t\t\t`model: ${agentConfig.model}`,\n\t\t\t\t'---',\n\t\t\t].join('\\n')\n\n\t\t\tconst agentContent = `${agentFrontmatter}\\n\\n${agentConfig.prompt}\\n`\n\t\t\tawait fs.writeFile(path.join(claudeAgentsDir, `${swarmName}.md`), agentContent, 'utf-8')\n\t\t\trenderedAgents.push(swarmName)\n\t\t\tgetLogger().debug(`Rendered swarm agent: ${swarmName}`)\n\n\t\t\t// 2. Write thin skill wrapper to .claude/skills/<swarmName>/SKILL.md\n\t\t\tconst skillDir = path.join(claudeSkillsDir, swarmName)\n\t\t\tawait fs.ensureDir(skillDir)\n\n\t\t\tconst skillFrontmatter = [\n\t\t\t\t'---',\n\t\t\t\t`name: ${swarmName}`,\n\t\t\t\t`description: ${agentConfig.description}`,\n\t\t\t\t`model: ${agentConfig.model}`,\n\t\t\t\t'context: fork',\n\t\t\t\t`agent: ${swarmName}`,\n\t\t\t\t'---',\n\t\t\t].join('\\n')\n\n\t\t\tconst skillContent = `${skillFrontmatter}\\n\\nProceed via your system prompt.\\n`\n\t\t\tawait fs.writeFile(path.join(skillDir, 'SKILL.md'), skillContent, 'utf-8')\n\t\t\trenderedSkills.push(swarmName)\n\t\t\tgetLogger().debug(`Rendered swarm skill wrapper: ${swarmName}`)\n\t\t}\n\n\t\tgetLogger().success(`Rendered ${renderedAgents.length} swarm agents and ${renderedSkills.length} skill wrappers`)\n\t\treturn { renderedSkills, renderedAgents }\n\t}\n\n\t/**\n\t * Render the swarm worker agent file to the epic worktree's .claude/agents/ directory.\n\t *\n\t * This creates an agent file at `.claude/agents/iloom-swarm-worker.md` containing\n\t * the full iloom workflow instructions (rendered from issue-prompt.txt with SWARM_MODE=true).\n\t * The orchestrator spawns children with `subagent_type: \"iloom-swarm-worker\"` so these\n\t * instructions become the agent's system prompt (high authority), rather than arriving\n\t * as a skill invocation (low authority user message).\n\t *\n\t * The agent file is shared across all children. Issue-specific context (number, title,\n\t * worktree path, body) is provided per-child via the Task prompt from the orchestrator.\n\t */\n\tasync renderSwarmWorkerAgent(\n\t\tepicWorktreePath: string,\n\t): Promise<boolean> {\n\t\tconst agentsDir = path.join(epicWorktreePath, '.claude', 'agents')\n\t\tconst agentOutputPath = path.join(agentsDir, 'iloom-swarm-worker.md')\n\n\t\tawait fs.ensureDir(agentsDir)\n\n\t\ttry {\n\t\t\t// Load settings for review configuration and issue prefix\n\t\t\tconst settings = await this.settingsManager.loadSettings()\n\t\t\tconst providerType = settings?.issueManagement?.provider ?? 'github'\n\t\t\tconst issuePrefix = IssueManagementProviderFactory.create(providerType, settings ?? undefined).issuePrefix\n\n\t\t\t// Build template variables for swarm worker agent rendering\n\t\t\tconst variables: TemplateVariables = {\n\t\t\t\tSWARM_MODE: true,\n\t\t\t\tONE_SHOT_MODE: true,\n\t\t\t\tCOMPLEXITY_OVERRIDE: 'simple',\n\t\t\t\tEPIC_WORKTREE_PATH: epicWorktreePath,\n\t\t\t\tISSUE_PREFIX: issuePrefix,\n\t\t\t\t...buildReviewTemplateVariables(true, settings?.agents),\n\t\t\t}\n\n\t\t\t// Render issue prompt template with swarm variables\n\t\t\tconst agentBody = await this.templateManager.getPrompt('issue', variables)\n\n\t\t\t// Build the agent file with frontmatter\n\t\t\tconst workerModel = settings?.agents?.['iloom-swarm-worker']?.model ?? 'sonnet'\n\n\t\t\tconst frontmatter = [\n\t\t\t\t'---',\n\t\t\t\t'name: iloom-swarm-worker',\n\t\t\t\t'description: Swarm worker agent that implements a child issue following the full iloom workflow.',\n\t\t\t\t`model: ${workerModel}`,\n\t\t\t\t'---',\n\t\t\t].join('\\n')\n\n\t\t\tconst content = `${frontmatter}\\n\\n${agentBody}\\n`\n\n\t\t\tawait fs.writeFile(agentOutputPath, content, 'utf-8')\n\t\t\tgetLogger().success(`Rendered swarm worker agent to ${agentOutputPath}`)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\t// Intentional graceful degradation: setupSwarm reports workerAgentRendered=false\n\t\t\t// in its result rather than aborting the entire swarm setup.\n\t\t\tgetLogger().warn(\n\t\t\t\t`Failed to render swarm worker agent: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Render the wave verifier agent file to the epic worktree's .claude/agents/ directory.\n\t *\n\t * This creates an agent file at `.claude/agents/iloom-swarm-wave-verifier.md` WITH frontmatter,\n\t * making it available as a custom agent type via `subagent_type: \"iloom-swarm-wave-verifier\"`.\n\t * Unlike phase agents (which are appended as system prompts), the wave verifier is a standalone\n\t * agent that the orchestrator spawns directly for verification child issues.\n\t */\n\tasync renderSwarmWaveVerifierAgent(epicWorktreePath: string): Promise<boolean> {\n\t\tconst agentsDir = path.join(epicWorktreePath, '.claude', 'agents')\n\t\tconst agentOutputPath = path.join(agentsDir, 'iloom-swarm-wave-verifier.md')\n\n\t\tawait fs.ensureDir(agentsDir)\n\n\t\ttry {\n\t\t\tconst settings = await this.settingsManager.loadSettings()\n\n\t\t\t// Load agents to get the wave verifier template (rendered with template variables)\n\t\t\tconst templateVariables: TemplateVariables = {\n\t\t\t\tSWARM_MODE: true,\n\t\t\t\tEPIC_WORKTREE_PATH: epicWorktreePath,\n\t\t\t}\n\n\t\t\tconst agents = await this.agentManager.loadAgents(settings, templateVariables, ['iloom-wave-verifier.md'])\n\t\t\tconst verifierConfig = agents['iloom-wave-verifier']\n\n\t\t\tif (!verifierConfig) {\n\t\t\t\tgetLogger().debug('No wave verifier agent template found — skipping')\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// Get model from settings or use the template's declared model\n\t\t\tconst verifierModel = settings?.agents?.['iloom-wave-verifier']?.model ?? verifierConfig.model ?? 'sonnet'\n\n\t\t\t// Build the agent file WITH frontmatter (standalone custom agent type)\n\t\t\tconst frontmatter = [\n\t\t\t\t'---',\n\t\t\t\t'name: iloom-swarm-wave-verifier',\n\t\t\t\t`description: ${verifierConfig.description ?? 'Wave verification agent that checks must-have criteria after each swarm wave.'}`,\n\t\t\t\t`model: ${verifierModel}`,\n\t\t\t\t...(verifierConfig.tools ? [`tools: ${verifierConfig.tools.join(', ')}`] : []),\n\t\t\t\t'---',\n\t\t\t].join('\\n')\n\n\t\t\tconst content = `${frontmatter}\\n\\n${verifierConfig.prompt}\\n`\n\n\t\t\tawait fs.writeFile(agentOutputPath, content, 'utf-8')\n\t\t\tgetLogger().success(`Rendered wave verifier agent to ${agentOutputPath}`)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\tgetLogger().warn(\n\t\t\t\t`Failed to render wave verifier agent: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/**\n\t * Copy .claude/agents/ and .claude/skills/ from the epic worktree to each child worktree.\n\t *\n\t * Child workers need local access to agent files (used as custom agent types) and\n\t * skill files (invoked via /skill-name). Without this copy, child worktrees lack\n\t * the rendered files since they only exist in the epic worktree after rendering.\n\t */\n\tasync copyAgentsAndSkillsToChildWorktrees(\n\t\tepicWorktreePath: string,\n\t\tchildWorktrees: Array<{\n\t\t\tissueId: string\n\t\t\tworktreePath: string\n\t\t\tbranch: string\n\t\t\tsuccess: boolean\n\t\t\terror?: string\n\t\t}>,\n\t): Promise<void> {\n\t\tconst agentsSourceDir = path.join(epicWorktreePath, '.claude', 'agents')\n\t\tconst skillsSourceDir = path.join(epicWorktreePath, '.claude', 'skills')\n\n\t\tconst agentsExist = await fs.pathExists(agentsSourceDir)\n\t\tconst skillsExist = await fs.pathExists(skillsSourceDir)\n\n\t\tif (!agentsExist && !skillsExist) {\n\t\t\tgetLogger().warn('No .claude/agents/ or .claude/skills/ directory in epic worktree to copy')\n\t\t\treturn\n\t\t}\n\n\t\tconst successfulChildren = childWorktrees.filter((c) => c.success)\n\n\t\tawait Promise.all(successfulChildren.map(async (child) => {\n\t\t\ttry {\n\t\t\t\tif (agentsExist) {\n\t\t\t\t\tconst targetAgentsDir = path.join(child.worktreePath, '.claude', 'agents')\n\t\t\t\t\tawait fs.copy(agentsSourceDir, targetAgentsDir, { overwrite: true })\n\t\t\t\t\tgetLogger().debug(`Copied .claude/agents/ to ${child.worktreePath}`)\n\t\t\t\t}\n\t\t\t\tif (skillsExist) {\n\t\t\t\t\tconst targetSkillsDir = path.join(child.worktreePath, '.claude', 'skills')\n\t\t\t\t\tawait fs.copy(skillsSourceDir, targetSkillsDir, { overwrite: true })\n\t\t\t\t\tgetLogger().debug(`Copied .claude/skills/ to ${child.worktreePath}`)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Non-fatal: worker can fall back to epic worktree path\n\t\t\t\tgetLogger().warn(\n\t\t\t\t\t`Failed to copy agents/skills to child worktree ${child.issueId}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}))\n\n\t\tgetLogger().success(`Copied agents and skills to ${successfulChildren.length} child worktrees`)\n\t}\n\n\t/**\n\t * Run the full swarm setup: render agents, worker agent, and wave verifier.\n\t *\n\t * The epic worktree already exists (created by `il start`).\n\t * Child worktrees are created on-the-fly by the orchestrator as issues become unblocked.\n\t */\n\tasync setupSwarm(\n\t\tepicBranch: string,\n\t\tepicWorktreePath: string,\n\t): Promise<SwarmSetupResult> {\n\t\t// 1. Render swarm agents and skill wrappers to epic worktree\n\t\tconst { renderedSkills: skillsRendered, renderedAgents } =\n\t\t\tawait this.renderSwarmAgents(epicWorktreePath)\n\n\t\t// 2. Render the swarm worker agent file\n\t\tconst workerAgentRendered = await this.renderSwarmWorkerAgent(epicWorktreePath)\n\n\t\t// 3. Render the wave verifier agent file (standalone custom agent type with frontmatter)\n\t\tconst verifierAgentRendered = await this.renderSwarmWaveVerifierAgent(epicWorktreePath)\n\n\t\tgetLogger().success('Swarm setup complete: agents and skills rendered')\n\n\t\treturn {\n\t\t\tepicWorktreePath,\n\t\t\tepicBranch,\n\t\t\tskillsRendered,\n\t\t\trenderedAgents,\n\t\t\tworkerAgentRendered,\n\t\t\tverifierAgentRendered,\n\t\t}\n\t}\n}\n","import fs from 'fs-extra'\nimport path from 'path'\nimport fg from 'fast-glob'\n\n/**\n * Detect the primary programming language of a project by checking for common project files.\n * Checks are performed in priority order; the first match wins.\n * All errors are caught and return 'unknown' — this function is non-blocking.\n */\nexport async function detectProjectLanguage(projectPath: string): Promise<string> {\n try {\n // 1. package.json → check for 'typescript' in deps/devDeps → 'typescript' or 'javascript'\n const packageJsonPath = path.join(projectPath, 'package.json')\n if (await fs.pathExists(packageJsonPath)) {\n try {\n const pkg = await fs.readJson(packageJsonPath) as {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n }\n const allDeps = { ...pkg.dependencies, ...pkg.devDependencies }\n return 'typescript' in allDeps ? 'typescript' : 'javascript'\n } catch {\n return 'javascript'\n }\n }\n\n // 2. Cargo.toml → 'rust'\n if (await fs.pathExists(path.join(projectPath, 'Cargo.toml'))) {\n return 'rust'\n }\n\n // 3. go.mod → 'go'\n if (await fs.pathExists(path.join(projectPath, 'go.mod'))) {\n return 'go'\n }\n\n // 4. pyproject.toml | setup.py | requirements.txt → 'python'\n for (const file of ['pyproject.toml', 'setup.py', 'requirements.txt']) {\n if (await fs.pathExists(path.join(projectPath, file))) {\n return 'python'\n }\n }\n\n // 5. Gemfile → 'ruby'\n if (await fs.pathExists(path.join(projectPath, 'Gemfile'))) {\n return 'ruby'\n }\n\n // 6. pom.xml | build.gradle | build.gradle.kts → 'java'\n for (const file of ['pom.xml', 'build.gradle', 'build.gradle.kts']) {\n if (await fs.pathExists(path.join(projectPath, file))) {\n return 'java'\n }\n }\n\n // 7. *.csproj via glob → 'csharp'\n const csprojFiles = await fg('*.csproj', { cwd: projectPath, dot: false })\n if (csprojFiles.length > 0) {\n return 'csharp'\n }\n\n // 8. Default\n return 'unknown'\n } catch {\n return 'unknown'\n }\n}\n","import path from 'path'\nimport os from 'os'\nimport crypto from 'crypto'\nimport fs from 'fs-extra'\n\n/**\n * Result of preparing the system prompt.\n * Always uses file-based delivery via --append-system-prompt-file.\n */\nexport interface SystemPromptConfig {\n\t/** Path to the file containing the system prompt */\n\tappendSystemPromptFile: string\n}\n\n/**\n * Prepare the system prompt by writing it to a file.\n *\n * Writes the prompt to a temp directory with a unique filename derived\n * from the workspace path, and returns the file path for use with\n * `--append-system-prompt-file`.\n *\n * The file is written to os.tmpdir() instead of inside the workspace\n * to avoid polluting the repo with untracked files.\n */\nexport async function prepareSystemPromptForPlatform(\n\tsystemPrompt: string,\n\tworkspacePath: string,\n): Promise<SystemPromptConfig> {\n\tconst hash = crypto.createHash('sha256').update(workspacePath).digest('hex').slice(0, 12)\n\tconst promptFilePath = path.join(os.tmpdir(), `iloom-system-prompt-${hash}.md`)\n\n\tawait fs.writeFile(promptFilePath, systemPrompt, 'utf-8')\n\n\treturn { appendSystemPromptFile: promptFilePath }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,WAAU;AACjB,OAAOC,SAAQ;AAgBf,SAAS,gBAAgB;;;ACjBzB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,OAAO,QAAQ,kBAA8B;AACtD,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAkCpB,IAAM,oBAAN,MAAwB;AAAA,EAM9B,cAAc;AAEb,SAAK,YAAY,KAAK,KAAK,GAAG,QAAQ,GAAG,SAAS;AAClD,SAAK,WAAW,KAAK,KAAK,KAAK,WAAW,OAAO;AACjD,SAAK,eAAe,KAAK,KAAK,K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A,QACR,QAAQ;AACP,uBAAaA,MAAK,QAAQ,UAAU;AAAA,QACrC;AAAA,MACD;AAEA,aAAO,MAAM,6CAA6C;AAC1D,aAAO;AAAA,IACR,SAAS,OAAO;AAEf,aAAO,MAAM,6BAA6B,KAAK,EAAE;AACjD,aAAO;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,4BAA6C;AAC1D,QAAI;AAEH,UAAI,aAAaA,MAAK,QAAQ,IAAI,IAAI,YAAY,GAAG,EAAE,QAAQ;AAG/D,aAAO,eAAeA,MAAK,QAAQ,UAAU,GAAG;AAC/C,cAAM,aAAaA,MAAK,KAAK,YAAY,UAAU,WAAW;AAC9D,YAAI;AACH,gBAAM,UAAU,MAAM,SAAS,YAAY,OAAO;AAClD,iBAAO,MAAM,+CAA+C,EAAE,WAAW,CAAC;AAC1E,iBAAO;AAAA,QACR,QAAQ;AACP,uBAAaA,MAAK,QAAQ,UAAU;AAAA,QACrC;AAAA,MACD;AAEA,aAAO,MAAM,oDAAoD;AACjE,aAAO;AAAA,IACR,SAAS,OAAO;AAEf,aAAO,MAAM,oCAAoC,KAAK,EAAE;AACxD,aAAO;AAAA,IACR;AAAA,EACD;AACD;","names":["path","fs","_a","path","fs","path","fs","fs","path","path","os","fs","path","fs"]}
|
|
@@ -270,6 +270,36 @@ var AgentManager = class {
|
|
|
270
270
|
formatForCli(agents) {
|
|
271
271
|
return agents;
|
|
272
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Load agents and prepare them for the current platform.
|
|
275
|
+
* On macOS, returns agents formatted for the --agents CLI flag.
|
|
276
|
+
* On Linux/Windows, renders agents to disk for auto-discovery and returns undefined.
|
|
277
|
+
*
|
|
278
|
+
* @param settings - Project settings for model overrides
|
|
279
|
+
* @param templateVariables - Variables to substitute in agent prompts
|
|
280
|
+
* @param patterns - Glob patterns for which agent files to load
|
|
281
|
+
* @param targetDir - Directory for disk rendering (Linux/Windows). Defaults to cwd/.claude/agents/
|
|
282
|
+
* @returns Agents object for CLI flag (macOS) or undefined (Linux/Windows, agents on disk)
|
|
283
|
+
*/
|
|
284
|
+
async loadAndPrepare(settings, templateVariables, patterns, targetDir) {
|
|
285
|
+
const loadedAgents = await this.loadAgents(settings, templateVariables, patterns);
|
|
286
|
+
if (process.platform === "darwin") {
|
|
287
|
+
const agents = this.formatForCli(loadedAgents);
|
|
288
|
+
logger.debug("Loaded agent configurations for CLI", {
|
|
289
|
+
agentCount: Object.keys(agents).length,
|
|
290
|
+
agentNames: Object.keys(agents)
|
|
291
|
+
});
|
|
292
|
+
return agents;
|
|
293
|
+
}
|
|
294
|
+
const dir = targetDir ?? path.join(process.cwd(), ".claude", "agents");
|
|
295
|
+
const rendered = await this.renderAgentsToDisk(loadedAgents, dir);
|
|
296
|
+
logger.debug("Rendered agent files to disk for auto-discovery", {
|
|
297
|
+
agentCount: rendered.length,
|
|
298
|
+
agentNames: rendered,
|
|
299
|
+
targetDir: dir
|
|
300
|
+
});
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
273
303
|
/**
|
|
274
304
|
* Render loaded agents to disk as markdown files with YAML frontmatter.
|
|
275
305
|
* Claude Code auto-discovers agents from .claude/agents/ directory.
|
|
@@ -304,4 +334,4 @@ var AgentManager = class {
|
|
|
304
334
|
export {
|
|
305
335
|
AgentManager
|
|
306
336
|
};
|
|
307
|
-
//# sourceMappingURL=chunk-
|
|
337
|
+
//# sourceMappingURL=chunk-Y2MVSEJK.js.map
|