@iloom/cli 0.3.2 → 0.3.4
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/README.md +3 -3
- package/dist/{BranchNamingService-JYO746H7.js → BranchNamingService-A77VI6AI.js} +2 -2
- package/dist/ClaudeContextManager-BN7RE5ZQ.js +15 -0
- package/dist/ClaudeService-DLYLJUPA.js +14 -0
- package/dist/{GitHubService-UAMH7DMF.js → GitHubService-FZHHBOFG.js} +3 -3
- package/dist/{LoomLauncher-FVZECY3C.js → LoomLauncher-ZV3ZZIBA.js} +23 -20
- package/dist/LoomLauncher-ZV3ZZIBA.js.map +1 -0
- package/dist/{PromptTemplateManager-A52RUAMS.js → PromptTemplateManager-6HH3PVXV.js} +2 -2
- package/dist/README.md +3 -3
- package/dist/{SettingsManager-MTVX57WR.js → SettingsManager-I2LRCW2A.js} +2 -2
- package/dist/{SettingsMigrationManager-AGIIIPDQ.js → SettingsMigrationManager-TJ7UWZG5.js} +3 -3
- package/dist/agents/iloom-issue-complexity-evaluator.md +18 -3
- package/dist/agents/iloom-issue-enhancer.md +1 -1
- package/dist/{chunk-OAP6SASD.js → chunk-2CXREBLZ.js} +2 -2
- package/dist/{chunk-KG343GSG.js → chunk-2IJEMXOB.js} +359 -99
- package/dist/chunk-2IJEMXOB.js.map +1 -0
- package/dist/{chunk-FOV7RRQ2.js → chunk-2MAIX45J.js} +4 -4
- package/dist/{chunk-5NTD4MCZ.js → chunk-5Q3NDNNV.js} +29 -5
- package/dist/chunk-5Q3NDNNV.js.map +1 -0
- package/dist/{chunk-GVICXJHW.js → chunk-5VK4NRSF.js} +2 -2
- package/dist/{chunk-C7ASXK6J.js → chunk-AKUJXDNW.js} +2 -2
- package/dist/{chunk-UCZ24SUE.js → chunk-CDZERT7Z.js} +21 -9
- package/dist/chunk-CDZERT7Z.js.map +1 -0
- package/dist/{chunk-JKXJ7BGL.js → chunk-CE26YH2U.js} +42 -3
- package/dist/chunk-CE26YH2U.js.map +1 -0
- package/dist/{chunk-ZZZWQGTS.js → chunk-CFFQ2Z7A.js} +74 -75
- package/dist/chunk-CFFQ2Z7A.js.map +1 -0
- package/dist/{chunk-FXMLNKLT.js → chunk-DLHA5VQ3.js} +174 -5
- package/dist/chunk-DLHA5VQ3.js.map +1 -0
- package/dist/{chunk-GOG3ZB7O.js → chunk-IFB4Z76W.js} +23 -4
- package/dist/chunk-IFB4Z76W.js.map +1 -0
- package/dist/{chunk-F4ENT6AC.js → chunk-M7JJCX53.js} +2 -2
- package/dist/{chunk-KLBYVHPK.js → chunk-OSCLCMDG.js} +2 -2
- package/dist/{chunk-ZLIHIUDQ.js → chunk-OYF4VIFI.js} +2 -2
- package/dist/{chunk-A2P7NZTB.js → chunk-PGPI5LR4.js} +4 -4
- package/dist/{chunk-WEN5C5DM.js → chunk-RIEO2WML.js} +4 -1
- package/dist/chunk-RIEO2WML.js.map +1 -0
- package/dist/{chunk-UERERX6M.js → chunk-SUOXY5WJ.js} +2 -2
- package/dist/{init-7IIM35LQ.js → chunk-UAN4A3YU.js} +343 -46
- package/dist/chunk-UAN4A3YU.js.map +1 -0
- package/dist/{claude-KIZYXTSG.js → claude-W52VKI6L.js} +2 -2
- package/dist/{cleanup-6WYUD5SN.js → cleanup-H4VXU3C3.js} +12 -12
- package/dist/cli.js +188 -91
- package/dist/cli.js.map +1 -1
- package/dist/{color-ZVALX37U.js → color-F7RU6B6Z.js} +10 -4
- package/dist/{contribute-7YJHZTO7.js → contribute-Y7IQV5QY.js} +4 -4
- package/dist/{feedback-752MGDPG.js → feedback-XTUCKJNT.js} +11 -9
- package/dist/{feedback-752MGDPG.js.map → feedback-XTUCKJNT.js.map} +1 -1
- package/dist/{git-TAFVDB3J.js → git-IYA53VIC.js} +7 -3
- package/dist/{ignite-OAMDUN27.js → ignite-T74RYXCA.js} +19 -71
- package/dist/ignite-T74RYXCA.js.map +1 -0
- package/dist/index.d.ts +52 -8
- package/dist/index.js +132 -84
- package/dist/index.js.map +1 -1
- package/dist/init-4FHTAM3F.js +19 -0
- package/dist/{neon-helpers-5HBYO2VP.js → neon-helpers-77PBPGJ5.js} +3 -3
- package/dist/{open-FCHKQ77R.js → open-UMXANW5S.js} +4 -4
- package/dist/{prompt-7INJ7YRU.js → prompt-QALMYTVC.js} +4 -2
- package/dist/prompt-QALMYTVC.js.map +1 -0
- package/dist/prompts/init-prompt.txt +82 -8
- package/dist/prompts/issue-prompt.txt +18 -11
- package/dist/prompts/regular-prompt.txt +373 -14
- package/dist/{rebase-Q7WXK566.js → rebase-VJ2VKR6R.js} +11 -11
- package/dist/rebase-VJ2VKR6R.js.map +1 -0
- package/dist/{run-SJPM6YRI.js → run-MJYY4PUT.js} +4 -4
- package/dist/schema/settings.schema.json +21 -3
- package/dist/{test-git-DEUE656D.js → test-git-IT5EWQ5C.js} +3 -3
- package/dist/{test-prefix-Y6Z6ZHSF.js → test-prefix-NPWDPUUH.js} +3 -3
- package/package.json +2 -1
- package/dist/ClaudeContextManager-5WPRJIIW.js +0 -15
- package/dist/ClaudeService-Z4KA7QOW.js +0 -14
- package/dist/LoomLauncher-FVZECY3C.js.map +0 -1
- package/dist/chunk-5NTD4MCZ.js.map +0 -1
- package/dist/chunk-FXMLNKLT.js.map +0 -1
- package/dist/chunk-GOG3ZB7O.js.map +0 -1
- package/dist/chunk-JKXJ7BGL.js.map +0 -1
- package/dist/chunk-KG343GSG.js.map +0 -1
- package/dist/chunk-PRE7KTM4.js +0 -302
- package/dist/chunk-PRE7KTM4.js.map +0 -1
- package/dist/chunk-UCZ24SUE.js.map +0 -1
- package/dist/chunk-WEN5C5DM.js.map +0 -1
- package/dist/chunk-ZZZWQGTS.js.map +0 -1
- package/dist/ignite-OAMDUN27.js.map +0 -1
- package/dist/init-7IIM35LQ.js.map +0 -1
- package/dist/rebase-Q7WXK566.js.map +0 -1
- /package/dist/{BranchNamingService-JYO746H7.js.map → BranchNamingService-A77VI6AI.js.map} +0 -0
- /package/dist/{ClaudeContextManager-5WPRJIIW.js.map → ClaudeContextManager-BN7RE5ZQ.js.map} +0 -0
- /package/dist/{ClaudeService-Z4KA7QOW.js.map → ClaudeService-DLYLJUPA.js.map} +0 -0
- /package/dist/{GitHubService-UAMH7DMF.js.map → GitHubService-FZHHBOFG.js.map} +0 -0
- /package/dist/{PromptTemplateManager-A52RUAMS.js.map → PromptTemplateManager-6HH3PVXV.js.map} +0 -0
- /package/dist/{SettingsManager-MTVX57WR.js.map → SettingsManager-I2LRCW2A.js.map} +0 -0
- /package/dist/{SettingsMigrationManager-AGIIIPDQ.js.map → SettingsMigrationManager-TJ7UWZG5.js.map} +0 -0
- /package/dist/{chunk-OAP6SASD.js.map → chunk-2CXREBLZ.js.map} +0 -0
- /package/dist/{chunk-FOV7RRQ2.js.map → chunk-2MAIX45J.js.map} +0 -0
- /package/dist/{chunk-GVICXJHW.js.map → chunk-5VK4NRSF.js.map} +0 -0
- /package/dist/{chunk-C7ASXK6J.js.map → chunk-AKUJXDNW.js.map} +0 -0
- /package/dist/{chunk-F4ENT6AC.js.map → chunk-M7JJCX53.js.map} +0 -0
- /package/dist/{chunk-KLBYVHPK.js.map → chunk-OSCLCMDG.js.map} +0 -0
- /package/dist/{chunk-ZLIHIUDQ.js.map → chunk-OYF4VIFI.js.map} +0 -0
- /package/dist/{chunk-A2P7NZTB.js.map → chunk-PGPI5LR4.js.map} +0 -0
- /package/dist/{chunk-UERERX6M.js.map → chunk-SUOXY5WJ.js.map} +0 -0
- /package/dist/{claude-KIZYXTSG.js.map → claude-W52VKI6L.js.map} +0 -0
- /package/dist/{cleanup-6WYUD5SN.js.map → cleanup-H4VXU3C3.js.map} +0 -0
- /package/dist/{color-ZVALX37U.js.map → color-F7RU6B6Z.js.map} +0 -0
- /package/dist/{contribute-7YJHZTO7.js.map → contribute-Y7IQV5QY.js.map} +0 -0
- /package/dist/{git-TAFVDB3J.js.map → git-IYA53VIC.js.map} +0 -0
- /package/dist/{neon-helpers-5HBYO2VP.js.map → init-4FHTAM3F.js.map} +0 -0
- /package/dist/{prompt-7INJ7YRU.js.map → neon-helpers-77PBPGJ5.js.map} +0 -0
- /package/dist/{open-FCHKQ77R.js.map → open-UMXANW5S.js.map} +0 -0
- /package/dist/{run-SJPM6YRI.js.map → run-MJYY4PUT.js.map} +0 -0
- /package/dist/{test-git-DEUE656D.js.map → test-git-IT5EWQ5C.js.map} +0 -0
- /package/dist/{test-prefix-Y6Z6ZHSF.js.map → test-prefix-NPWDPUUH.js.map} +0 -0
|
@@ -113,12 +113,18 @@ var IloomSettingsSchema = z.object({
|
|
|
113
113
|
remote: z.string().optional()
|
|
114
114
|
}).optional().describe("Merge behavior configuration: local (merge locally) or github-pr (create PR)"),
|
|
115
115
|
ide: z.object({
|
|
116
|
-
type: z.enum(["vscode", "cursor", "webstorm", "sublime", "intellij", "windsurf"]).default("vscode").describe(
|
|
117
|
-
"IDE to launch when starting a loom. Options: vscode (Visual Studio Code), cursor (Cursor AI editor), webstorm (JetBrains WebStorm), sublime (Sublime Text), intellij (JetBrains IntelliJ IDEA), windsurf (Windsurf editor)."
|
|
116
|
+
type: z.enum(["vscode", "cursor", "webstorm", "sublime", "intellij", "windsurf", "antigravity"]).default("vscode").describe(
|
|
117
|
+
"IDE to launch when starting a loom. Options: vscode (Visual Studio Code), cursor (Cursor AI editor), webstorm (JetBrains WebStorm), sublime (Sublime Text), intellij (JetBrains IntelliJ IDEA), windsurf (Windsurf editor), antigravity (Antigravity IDE)."
|
|
118
118
|
)
|
|
119
119
|
}).optional().describe(
|
|
120
|
-
"IDE configuration for workspace launches. Controls which editor opens when you start a loom. Supports VSCode, Cursor, WebStorm, Sublime Text, IntelliJ, and
|
|
121
|
-
)
|
|
120
|
+
"IDE configuration for workspace launches. Controls which editor opens when you start a loom. Supports VSCode, Cursor, WebStorm, Sublime Text, IntelliJ, Windsurf, and Antigravity. Note: Color synchronization (title bar colors) only works with VSCode-compatible editors (vscode, cursor, windsurf, antigravity)."
|
|
121
|
+
),
|
|
122
|
+
colors: z.object({
|
|
123
|
+
terminal: z.boolean().default(true).describe("Apply terminal background colors based on branch name (macOS only)"),
|
|
124
|
+
vscode: z.boolean().default(false).describe(
|
|
125
|
+
"Apply VSCode/Cursor title bar colors based on branch name. Note: This modifies .vscode/settings.json which may be in source control. Default is false for safety; enable via init or explicitly if .vscode is gitignored."
|
|
126
|
+
)
|
|
127
|
+
}).optional().describe("Color synchronization settings for workspace identification")
|
|
122
128
|
});
|
|
123
129
|
var IloomSettingsSchemaNoDefaults = z.object({
|
|
124
130
|
mainBranch: z.string().min(1, "Settings 'mainBranch' cannot be empty").optional().describe("Name of the main/primary branch for the repository"),
|
|
@@ -169,12 +175,18 @@ var IloomSettingsSchemaNoDefaults = z.object({
|
|
|
169
175
|
remote: z.string().optional()
|
|
170
176
|
}).optional().describe("Merge behavior configuration: local (merge locally) or github-pr (create PR)"),
|
|
171
177
|
ide: z.object({
|
|
172
|
-
type: z.enum(["vscode", "cursor", "webstorm", "sublime", "intellij", "windsurf"]).optional().describe(
|
|
173
|
-
"IDE to launch when starting a loom. Options: vscode (Visual Studio Code), cursor (Cursor AI editor), webstorm (JetBrains WebStorm), sublime (Sublime Text), intellij (JetBrains IntelliJ IDEA), windsurf (Windsurf editor)."
|
|
178
|
+
type: z.enum(["vscode", "cursor", "webstorm", "sublime", "intellij", "windsurf", "antigravity"]).optional().describe(
|
|
179
|
+
"IDE to launch when starting a loom. Options: vscode (Visual Studio Code), cursor (Cursor AI editor), webstorm (JetBrains WebStorm), sublime (Sublime Text), intellij (JetBrains IntelliJ IDEA), windsurf (Windsurf editor), antigravity (Antigravity IDE)."
|
|
174
180
|
)
|
|
175
181
|
}).optional().describe(
|
|
176
|
-
"IDE configuration for workspace launches. Controls which editor opens when you start a loom. Supports VSCode, Cursor, WebStorm, Sublime Text, IntelliJ, and
|
|
177
|
-
)
|
|
182
|
+
"IDE configuration for workspace launches. Controls which editor opens when you start a loom. Supports VSCode, Cursor, WebStorm, Sublime Text, IntelliJ, Windsurf, and Antigravity. Note: Color synchronization (title bar colors) only works with VSCode-compatible editors (vscode, cursor, windsurf, antigravity)."
|
|
183
|
+
),
|
|
184
|
+
colors: z.object({
|
|
185
|
+
terminal: z.boolean().optional().describe("Apply terminal background colors based on branch name (macOS only)"),
|
|
186
|
+
vscode: z.boolean().optional().describe(
|
|
187
|
+
"Apply VSCode/Cursor title bar colors based on branch name. Note: This modifies .vscode/settings.json which may be in source control."
|
|
188
|
+
)
|
|
189
|
+
}).optional().describe("Color synchronization settings for workspace identification")
|
|
178
190
|
});
|
|
179
191
|
var SettingsManager = class {
|
|
180
192
|
/**
|
|
@@ -393,4 +405,4 @@ export {
|
|
|
393
405
|
IloomSettingsSchemaNoDefaults,
|
|
394
406
|
SettingsManager
|
|
395
407
|
};
|
|
396
|
-
//# sourceMappingURL=chunk-
|
|
408
|
+
//# sourceMappingURL=chunk-CDZERT7Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/SettingsManager.ts"],"sourcesContent":["import { readFile } from 'fs/promises'\nimport path from 'path'\nimport os from 'os'\nimport { z } from 'zod'\nimport deepmerge from 'deepmerge'\nimport { logger } from '../utils/logger.js'\n\n/**\n * Zod schema for agent settings\n */\nexport const AgentSettingsSchema = z.object({\n\tmodel: z\n\t\t.enum(['sonnet', 'opus', 'haiku'])\n\t\t.optional()\n\t\t.describe('Claude model shorthand: sonnet, opus, or haiku'),\n\t// Future: could add other per-agent overrides\n})\n\n/**\n * Zod schema for workflow permission configuration\n */\nexport const WorkflowPermissionSchema = z.object({\n\tpermissionMode: z\n\t\t.enum(['plan', 'acceptEdits', 'bypassPermissions', 'default'])\n\t\t.optional()\n\t\t.describe('Permission mode for Claude CLI in this workflow type'),\n\tnoVerify: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('Skip pre-commit hooks (--no-verify) when committing during finish workflow'),\n\tstartIde: z\n\t\t.boolean()\n\t\t.default(true)\n\t\t.describe('Launch IDE (code) when starting this workflow type'),\n\tstartDevServer: z\n\t\t.boolean()\n\t\t.default(true)\n\t\t.describe('Launch development server when starting this workflow type'),\n\tstartAiAgent: z\n\t\t.boolean()\n\t\t.default(true)\n\t\t.describe('Launch Claude Code agent when starting this workflow type'),\n\tstartTerminal: z\n\t\t.boolean()\n\t\t.default(false)\n\t\t.describe('Launch terminal window without dev server when starting this workflow type'),\n})\n\n/**\n * Non-defaulting variant for pre-merge validation\n * This prevents Zod from polluting partial settings with default values before merge\n */\nexport const WorkflowPermissionSchemaNoDefaults = z.object({\n\tpermissionMode: z\n\t\t.enum(['plan', 'acceptEdits', 'bypassPermissions', 'default'])\n\t\t.optional()\n\t\t.describe('Permission mode for Claude CLI in this workflow type'),\n\tnoVerify: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('Skip pre-commit hooks (--no-verify) when committing during finish workflow'),\n\tstartIde: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('Launch IDE (code) when starting this workflow type'),\n\tstartDevServer: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('Launch development server when starting this workflow type'),\n\tstartAiAgent: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('Launch Claude Code agent when starting this workflow type'),\n\tstartTerminal: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('Launch terminal window without dev server when starting this workflow type'),\n})\n\n/**\n * Zod schema for workflows settings\n */\nexport const WorkflowsSettingsSchema = z\n\t.object({\n\t\tissue: WorkflowPermissionSchema.optional(),\n\t\tpr: WorkflowPermissionSchema.optional(),\n\t\tregular: WorkflowPermissionSchema.optional(),\n\t})\n\t.optional()\n\n/**\n * Non-defaulting variant for pre-merge validation\n */\nexport const WorkflowsSettingsSchemaNoDefaults = z\n\t.object({\n\t\tissue: WorkflowPermissionSchemaNoDefaults.optional(),\n\t\tpr: WorkflowPermissionSchemaNoDefaults.optional(),\n\t\tregular: WorkflowPermissionSchemaNoDefaults.optional(),\n\t})\n\t.optional()\n\n/**\n * Zod schema for capabilities settings\n */\nexport const CapabilitiesSettingsSchema = z\n\t.object({\n\t\tweb: z\n\t\t\t.object({\n\t\t\t\tbasePort: z\n\t\t\t\t\t.number()\n\t\t\t\t\t.min(1, 'Base port must be >= 1')\n\t\t\t\t\t.max(65535, 'Base port must be <= 65535')\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe('Base port for web workspace port calculations (default: 3000)'),\n\t\t\t})\n\t\t\t.optional(),\n\t\tdatabase: z\n\t\t\t.object({\n\t\t\t\tdatabaseUrlEnvVarName: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.min(1, 'Database URL variable name cannot be empty')\n\t\t\t\t\t.regex(/^[A-Z_][A-Z0-9_]*$/, 'Must be valid env var name (uppercase, underscores)')\n\t\t\t\t\t.optional()\n\t\t\t\t\t.default('DATABASE_URL')\n\t\t\t\t\t.describe('Name of environment variable for database connection URL'),\n\t\t\t})\n\t\t\t.optional(),\n\t})\n\t.optional()\n\n/**\n * Non-defaulting variant for pre-merge validation\n */\nexport const CapabilitiesSettingsSchemaNoDefaults = z\n\t.object({\n\t\tweb: z\n\t\t\t.object({\n\t\t\t\tbasePort: z\n\t\t\t\t\t.number()\n\t\t\t\t\t.min(1, 'Base port must be >= 1')\n\t\t\t\t\t.max(65535, 'Base port must be <= 65535')\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe('Base port for web workspace port calculations (default: 3000)'),\n\t\t\t})\n\t\t\t.optional(),\n\t\tdatabase: z\n\t\t\t.object({\n\t\t\t\tdatabaseUrlEnvVarName: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.min(1, 'Database URL variable name cannot be empty')\n\t\t\t\t\t.regex(/^[A-Z_][A-Z0-9_]*$/, 'Must be valid env var name (uppercase, underscores)')\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe('Name of environment variable for database connection URL'),\n\t\t\t})\n\t\t\t.optional(),\n\t})\n\t.optional()\n\n/**\n * Zod schema for Neon database provider settings\n */\nexport const NeonSettingsSchema = z.object({\n\tprojectId: z\n\t\t.string()\n\t\t.min(1)\n\t\t.regex(/^[a-zA-Z0-9-]+$/, 'Neon project ID must contain only letters, numbers, and hyphens')\n\t\t.describe('Neon project ID found in your project URL (e.g., \"fantastic-fox-3566354\")'),\n\tparentBranch: z\n\t\t.string()\n\t\t.min(1)\n\t\t.describe('Branch from which new database branches are created'),\n})\n\n/**\n * Zod schema for database provider settings\n */\nexport const DatabaseProvidersSettingsSchema = z\n\t.object({\n\t\tneon: NeonSettingsSchema.optional().describe(\n\t\t\t'Neon database configuration. Requires Neon CLI installed and authenticated for database branching.',\n\t\t),\n\t})\n\t.optional()\n\n/**\n * Zod schema for iloom settings\n */\nexport const IloomSettingsSchema = z.object({\n\tmainBranch: z\n\t\t.string()\n\t\t.min(1, \"Settings 'mainBranch' cannot be empty\")\n\t\t.optional()\n\t\t.describe('Name of the main/primary branch for the repository'),\n\tsourceEnvOnStart: z\n\t\t.boolean()\n\t\t.default(false)\n\t\t.describe(\n\t\t\t'Source all dotenv-flow files (.env, .env.local, .env.development, .env.development.local) when launching terminal processes (Claude, dev server, terminal). ' +\n\t\t\t\t'Files are sourced in precedence order so later files override earlier ones. ' +\n\t\t\t\t'NOTE TO AI AGENTS: Before making changes to settings files, YOU MUST OFFER to check .env file compatibility. ' +\n\t\t\t\t'WARNING: Unquoted values in .env files may break sourcing in bash/zsh shells. ' +\n\t\t\t\t'Before enabling, verify ALL your .env.* files do not contain unquoted special characters ' +\n\t\t\t\t'(e.g., database URLs with ?, &, or other shell metacharacters). ' +\n\t\t\t\t'Shell compatibility issues may cause processes to fail or behave unexpectedly.',\n\t\t),\n\tworktreePrefix: z\n\t\t.string()\n\t\t.optional()\n\t\t.refine(\n\t\t\t(val) => {\n\t\t\t\tif (val === undefined) return true // undefined = use default calculation\n\t\t\t\tif (val === '') return true // empty string = no prefix mode\n\n\t\t\t\t// Allowlist: only alphanumeric, hyphens, underscores, and forward slashes\n\t\t\t\tconst allowedChars = /^[a-zA-Z0-9\\-_/]+$/\n\t\t\t\tif (!allowedChars.test(val)) return false\n\n\t\t\t\t// Reject if only special characters (no alphanumeric content)\n\t\t\t\tif (/^[-_/]+$/.test(val)) return false\n\n\t\t\t\t// Check each segment (split by /) contains at least one alphanumeric character\n\t\t\t\tconst segments = val.split('/')\n\t\t\t\tfor (const segment of segments) {\n\t\t\t\t\tif (segment && /^[-_]+$/.test(segment)) {\n\t\t\t\t\t\t// Segment exists but contains only hyphens/underscores\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage:\n\t\t\t\t\t\"worktreePrefix contains invalid characters. Only alphanumeric characters, hyphens (-), underscores (_), and forward slashes (/) are allowed. Use forward slashes for nested directories.\",\n\t\t\t},\n\t\t)\n\t\t.describe(\n\t\t\t'Prefix for worktree directories. Empty string disables prefix. Defaults to <repo-name>-looms if not set.',\n\t\t),\n\tprotectedBranches: z\n\t\t.array(z.string().min(1, 'Protected branch name cannot be empty'))\n\t\t.optional()\n\t\t.describe('List of branches that cannot be deleted (defaults to [mainBranch, \"main\", \"master\", \"develop\"])'),\n\tworkflows: WorkflowsSettingsSchema.describe('Per-workflow-type permission configurations'),\n\tagents: z\n\t\t.record(z.string(), AgentSettingsSchema)\n\t\t.optional()\n\t\t.nullable()\n\t\t.describe(\n\t\t\t'Per-agent configuration overrides. Available agents: ' +\n\t\t\t\t'iloom-issue-analyzer (analyzes issues), ' +\n\t\t\t\t'iloom-issue-planner (creates implementation plans), ' +\n\t\t\t\t'iloom-issue-analyze-and-plan (combined analysis and planning), ' +\n\t\t\t\t'iloom-issue-complexity-evaluator (evaluates complexity), ' +\n\t\t\t\t'iloom-issue-enhancer (enhances issue descriptions), ' +\n\t\t\t\t'iloom-issue-implementer (implements code changes), ' +\n\t\t\t\t'iloom-issue-reviewer (reviews code changes against requirements)',\n\t\t),\n\tcapabilities: CapabilitiesSettingsSchema.describe('Project capability configurations'),\n\tdatabaseProviders: DatabaseProvidersSettingsSchema.describe('Database provider configurations'),\n\tissueManagement: z\n\t\t.object({\n\t\t\tprovider: z.enum(['github', 'linear']).optional().default('github').describe('Issue tracker provider (github, linear)'),\n\t\t\tgithub: z\n\t\t\t\t.object({\n\t\t\t\t\tremote: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.min(1, 'Remote name cannot be empty')\n\t\t\t\t\t\t.describe('Git remote name to use for GitHub operations'),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t\tlinear: z\n\t\t\t\t.object({\n\t\t\t\t\tteamId: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.min(1, 'Team ID cannot be empty')\n\t\t\t\t\t\t.describe('Linear team identifier (e.g., \"ENG\", \"PLAT\")'),\n\t\t\t\t\tbranchFormat: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional()\n\t\t\t\t\t\t.describe('Branch naming template for Linear issues'),\n\t\t\t\t\tapiToken: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional()\n\t\t\t\t\t\t.describe('Linear API token (lin_api_...). SECURITY: Store in settings.local.json only, never commit to source control.'),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional()\n\t\t.describe('Issue management configuration'),\n\tmergeBehavior: z\n\t\t.object({\n\t\t\tmode: z.enum(['local', 'github-pr']).default('local'),\n\t\t\tremote: z.string().optional(),\n\t\t})\n\t\t.optional()\n\t\t.describe('Merge behavior configuration: local (merge locally) or github-pr (create PR)'),\n\tide: z\n\t\t.object({\n\t\t\ttype: z\n\t\t\t\t.enum(['vscode', 'cursor', 'webstorm', 'sublime', 'intellij', 'windsurf', 'antigravity'])\n\t\t\t\t.default('vscode')\n\t\t\t\t.describe(\n\t\t\t\t\t'IDE to launch when starting a loom. Options: vscode (Visual Studio Code), cursor (Cursor AI editor), ' +\n\t\t\t\t\t\t'webstorm (JetBrains WebStorm), sublime (Sublime Text), intellij (JetBrains IntelliJ IDEA), ' +\n\t\t\t\t\t\t'windsurf (Windsurf editor), antigravity (Antigravity IDE).'\n\t\t\t\t),\n\t\t})\n\t\t.optional()\n\t\t.describe(\n\t\t\t'IDE configuration for workspace launches. Controls which editor opens when you start a loom. ' +\n\t\t\t\t'Supports VSCode, Cursor, WebStorm, Sublime Text, IntelliJ, Windsurf, and Antigravity. ' +\n\t\t\t\t'Note: Color synchronization (title bar colors) only works with VSCode-compatible editors (vscode, cursor, windsurf, antigravity).'\n\t\t),\n\tcolors: z\n\t\t.object({\n\t\t\tterminal: z\n\t\t\t\t.boolean()\n\t\t\t\t.default(true)\n\t\t\t\t.describe('Apply terminal background colors based on branch name (macOS only)'),\n\t\t\tvscode: z\n\t\t\t\t.boolean()\n\t\t\t\t.default(false)\n\t\t\t\t.describe(\n\t\t\t\t\t'Apply VSCode/Cursor title bar colors based on branch name. ' +\n\t\t\t\t\t\t'Note: This modifies .vscode/settings.json which may be in source control. ' +\n\t\t\t\t\t\t'Default is false for safety; enable via init or explicitly if .vscode is gitignored.'\n\t\t\t\t),\n\t\t})\n\t\t.optional()\n\t\t.describe('Color synchronization settings for workspace identification'),\n})\n\n/**\n * Non-defaulting variant for pre-merge validation\n * This prevents Zod from polluting partial settings with default values before merge\n */\nexport const IloomSettingsSchemaNoDefaults = z.object({\n\tmainBranch: z\n\t\t.string()\n\t\t.min(1, \"Settings 'mainBranch' cannot be empty\")\n\t\t.optional()\n\t\t.describe('Name of the main/primary branch for the repository'),\n\tsourceEnvOnStart: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'Source all dotenv-flow files (.env, .env.local, .env.development, .env.development.local) when launching terminal processes (Claude, dev server, terminal). ' +\n\t\t\t\t'Files are sourced in precedence order so later files override earlier ones. ' +\n\t\t\t\t'NOTE TO AI AGENTS: Before making changes to settings files, YOU MUST OFFER to check .env compatibility. ' +\n\t\t\t\t'WARNING: Unquoted values in .env files may break sourcing in bash/zsh shells. ' +\n\t\t\t\t'Before enabling, verify ALL your .env.* files do not contain unquoted special characters ' +\n\t\t\t\t'(e.g., database URLs with ?, &, or other shell metacharacters). ' +\n\t\t\t\t'Shell compatibility issues may cause processes to fail or behave unexpectedly.',\n\t\t),\n\tworktreePrefix: z\n\t\t.string()\n\t\t.optional()\n\t\t.refine(\n\t\t\t(val) => {\n\t\t\t\tif (val === undefined) return true // undefined = use default calculation\n\t\t\t\tif (val === '') return true // empty string = no prefix mode\n\n\t\t\t\t// Allowlist: only alphanumeric, hyphens, underscores, and forward slashes\n\t\t\t\tconst allowedChars = /^[a-zA-Z0-9\\-_/]+$/\n\t\t\t\tif (!allowedChars.test(val)) return false\n\n\t\t\t\t// Reject if only special characters (no alphanumeric content)\n\t\t\t\tif (/^[-_/]+$/.test(val)) return false\n\n\t\t\t\t// Check each segment (split by /) contains at least one alphanumeric character\n\t\t\t\tconst segments = val.split('/')\n\t\t\t\tfor (const segment of segments) {\n\t\t\t\t\tif (segment && /^[-_]+$/.test(segment)) {\n\t\t\t\t\t\t// Segment exists but contains only hyphens/underscores\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage:\n\t\t\t\t\t\"worktreePrefix contains invalid characters. Only alphanumeric characters, hyphens (-), underscores (_), and forward slashes (/) are allowed. Use forward slashes for nested directories.\",\n\t\t\t},\n\t\t)\n\t\t.describe(\n\t\t\t'Prefix for worktree directories. Empty string disables prefix. Defaults to <repo-name>-looms if not set.',\n\t\t),\n\tprotectedBranches: z\n\t\t.array(z.string().min(1, 'Protected branch name cannot be empty'))\n\t\t.optional()\n\t\t.describe('List of branches that cannot be deleted (defaults to [mainBranch, \"main\", \"master\", \"develop\"])'),\n\tworkflows: WorkflowsSettingsSchemaNoDefaults.describe('Per-workflow-type permission configurations'),\n\tagents: z\n\t\t.record(z.string(), AgentSettingsSchema)\n\t\t.optional()\n\t\t.nullable()\n\t\t.describe(\n\t\t\t'Per-agent configuration overrides. Available agents: ' +\n\t\t\t\t'iloom-issue-analyzer (analyzes issues), ' +\n\t\t\t\t'iloom-issue-planner (creates implementation plans), ' +\n\t\t\t\t'iloom-issue-analyze-and-plan (combined analysis and planning), ' +\n\t\t\t\t'iloom-issue-complexity-evaluator (evaluates complexity), ' +\n\t\t\t\t'iloom-issue-enhancer (enhances issue descriptions), ' +\n\t\t\t\t'iloom-issue-implementer (implements code changes), ' +\n\t\t\t\t'iloom-issue-reviewer (reviews code changes against requirements)',\n\t\t),\n\tcapabilities: CapabilitiesSettingsSchemaNoDefaults.describe('Project capability configurations'),\n\tdatabaseProviders: DatabaseProvidersSettingsSchema.describe('Database provider configurations'),\n\tissueManagement: z\n\t\t.object({\n\t\t\tprovider: z.enum(['github', 'linear']).optional().describe('Issue tracker provider (github, linear)'),\n\t\t\tgithub: z\n\t\t\t\t.object({\n\t\t\t\t\tremote: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.min(1, 'Remote name cannot be empty')\n\t\t\t\t\t\t.describe('Git remote name to use for GitHub operations'),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t\tlinear: z\n\t\t\t\t.object({\n\t\t\t\t\tteamId: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.min(1, 'Team ID cannot be empty')\n\t\t\t\t\t\t.describe('Linear team identifier (e.g., \"ENG\", \"PLAT\")'),\n\t\t\t\t\tbranchFormat: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional()\n\t\t\t\t\t\t.describe('Branch naming template for Linear issues'),\n\t\t\t\t\tapiToken: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional()\n\t\t\t\t\t\t.describe('Linear API token (lin_api_...). SECURITY: Store in settings.local.json only, never commit to source control.'),\n\t\t\t\t})\n\t\t\t\t.optional(),\n\t\t})\n\t\t.optional()\n\t\t.describe('Issue management configuration'),\n\tmergeBehavior: z\n\t\t.object({\n\t\t\tmode: z.enum(['local', 'github-pr']).optional(),\n\t\t\tremote: z.string().optional(),\n\t\t})\n\t\t.optional()\n\t\t.describe('Merge behavior configuration: local (merge locally) or github-pr (create PR)'),\n\tide: z\n\t\t.object({\n\t\t\ttype: z\n\t\t\t\t.enum(['vscode', 'cursor', 'webstorm', 'sublime', 'intellij', 'windsurf', 'antigravity'])\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t'IDE to launch when starting a loom. Options: vscode (Visual Studio Code), cursor (Cursor AI editor), ' +\n\t\t\t\t\t\t'webstorm (JetBrains WebStorm), sublime (Sublime Text), intellij (JetBrains IntelliJ IDEA), ' +\n\t\t\t\t\t\t'windsurf (Windsurf editor), antigravity (Antigravity IDE).'\n\t\t\t\t),\n\t\t})\n\t\t.optional()\n\t\t.describe(\n\t\t\t'IDE configuration for workspace launches. Controls which editor opens when you start a loom. ' +\n\t\t\t\t'Supports VSCode, Cursor, WebStorm, Sublime Text, IntelliJ, Windsurf, and Antigravity. ' +\n\t\t\t\t'Note: Color synchronization (title bar colors) only works with VSCode-compatible editors (vscode, cursor, windsurf, antigravity).'\n\t\t),\n\tcolors: z\n\t\t.object({\n\t\t\tterminal: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe('Apply terminal background colors based on branch name (macOS only)'),\n\t\t\tvscode: z\n\t\t\t\t.boolean()\n\t\t\t\t.optional()\n\t\t\t\t.describe(\n\t\t\t\t\t'Apply VSCode/Cursor title bar colors based on branch name. ' +\n\t\t\t\t\t\t'Note: This modifies .vscode/settings.json which may be in source control.'\n\t\t\t\t),\n\t\t})\n\t\t.optional()\n\t\t.describe('Color synchronization settings for workspace identification'),\n})\n\n/**\n * TypeScript type for Neon settings derived from Zod schema\n */\nexport type NeonSettings = z.infer<typeof NeonSettingsSchema>\n\n/**\n * TypeScript type for database providers settings derived from Zod schema\n */\nexport type DatabaseProvidersSettings = z.infer<typeof DatabaseProvidersSettingsSchema>\n\n/**\n * TypeScript type for agent settings derived from Zod schema\n */\nexport type AgentSettings = z.infer<typeof AgentSettingsSchema>\n\n/**\n * TypeScript type for workflow permission configuration derived from Zod schema\n */\nexport type WorkflowPermission = z.infer<typeof WorkflowPermissionSchema>\n\n/**\n * TypeScript type for workflows settings derived from Zod schema\n */\nexport type WorkflowsSettings = z.infer<typeof WorkflowsSettingsSchema>\n\n/**\n * TypeScript type for capabilities settings derived from Zod schema\n */\nexport type CapabilitiesSettings = z.infer<typeof CapabilitiesSettingsSchema>\n\n/**\n * TypeScript type for IDE settings derived from Zod schema\n */\nexport type IdeSettings = z.infer<typeof IloomSettingsSchema>['ide']\n\n/**\n * TypeScript type for iloom settings derived from Zod schema\n */\nexport type IloomSettings = z.infer<typeof IloomSettingsSchema>\n\n/**\n * Manages project-level settings from .iloom/settings.json\n */\nexport class SettingsManager {\n\t/**\n\t * Load settings from global, project, and local sources with proper precedence\n\t * Merge hierarchy (lowest to highest priority):\n\t * 1. Global settings (~/.config/iloom-ai/settings.json)\n\t * 2. Project settings (<PROJECT_ROOT>/.iloom/settings.json)\n\t * 3. Local settings (<PROJECT_ROOT>/.iloom/settings.local.json)\n\t * 4. CLI overrides (--set flags)\n\t * Returns empty object if all files don't exist (not an error)\n\t */\n\tasync loadSettings(\n\t\tprojectRoot?: string,\n\t\tcliOverrides?: Partial<IloomSettings>,\n\t): Promise<IloomSettings> {\n\t\tconst root = this.getProjectRoot(projectRoot)\n\n\t\t// Load global settings (lowest priority)\n\t\tconst globalSettings = await this.loadGlobalSettingsFile()\n\t\tconst globalSettingsPath = this.getGlobalSettingsPath()\n\t\tlogger.debug(`🌍 Global settings from ${globalSettingsPath}:`, JSON.stringify(globalSettings, null, 2))\n\n\t\t// Load base settings from settings.json\n\t\tconst baseSettings = await this.loadSettingsFile(root, 'settings.json')\n\t\tconst baseSettingsPath = path.join(root, '.iloom', 'settings.json')\n\t\tlogger.debug(`📄 Base settings from ${baseSettingsPath}:`, JSON.stringify(baseSettings, null, 2))\n\n\t\t// Load local overrides from settings.local.json\n\t\tconst localSettings = await this.loadSettingsFile(root, 'settings.local.json')\n\t\tconst localSettingsPath = path.join(root, '.iloom', 'settings.local.json')\n\t\tlogger.debug(`📄 Local settings from ${localSettingsPath}:`, JSON.stringify(localSettings, null, 2))\n\n\t\t// Deep merge with priority: cliOverrides > localSettings > baseSettings > globalSettings\n\t\tlet merged = this.mergeSettings(this.mergeSettings(globalSettings, baseSettings), localSettings)\n\t\tlogger.debug('🔄 After merging global + base + local settings:', JSON.stringify(merged, null, 2))\n\n\t\tif (cliOverrides && Object.keys(cliOverrides).length > 0) {\n\t\t\tlogger.debug('⚙️ CLI overrides to apply:', JSON.stringify(cliOverrides, null, 2))\n\t\t\tmerged = this.mergeSettings(merged, cliOverrides)\n\t\t\tlogger.debug('🔄 After applying CLI overrides:', JSON.stringify(merged, null, 2))\n\t\t}\n\n\t\t// Validate merged result\n\t\ttry {\n\t\t\tconst finalSettings = IloomSettingsSchema.parse(merged)\n\n\t\t\t// Debug: Log final merged configuration\n\t\t\tthis.logFinalConfiguration(finalSettings)\n\n\t\t\treturn finalSettings\n\t\t} catch (error) {\n\t\t\t// Show all Zod validation errors\n\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\tconst errorMsg = this.formatAllZodErrors(error, '<merged settings>')\n\t\t\t\t// Enhance error message if CLI overrides were applied\n\t\t\t\tif (cliOverrides && Object.keys(cliOverrides).length > 0) {\n\t\t\t\t\tthrow new Error(`${errorMsg.message}\\n\\nNote: CLI overrides were applied. Check your --set arguments.`)\n\t\t\t\t}\n\t\t\t\tthrow errorMsg\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Log the final merged configuration for debugging\n\t */\n\tprivate logFinalConfiguration(settings: IloomSettings): void {\n\t\tlogger.debug('📋 Final merged configuration:', JSON.stringify(settings, null, 2))\n\t}\n\n\t/**\n\t * Load and parse a single settings file\n\t * Returns empty object if file doesn't exist (not an error)\n\t * Uses non-defaulting schema to prevent polluting partial settings with defaults before merge\n\t */\n\tprivate async loadSettingsFile(\n\t\tprojectRoot: string,\n\t\tfilename: string,\n\t): Promise<z.infer<typeof IloomSettingsSchemaNoDefaults>> {\n\t\tconst settingsPath = path.join(projectRoot, '.iloom', filename)\n\n\t\ttry {\n\t\t\tconst content = await readFile(settingsPath, 'utf-8')\n\t\t\tlet parsed: unknown\n\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(content)\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to parse settings file at ${settingsPath}: ${error instanceof Error ? error.message : 'Invalid JSON'}`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Basic type checking - ensure it's an object, but don't validate schema completeness\n\t\t\t// Individual files may be incomplete (e.g., Linear config split between files)\n\t\t\t// Final validation will happen on the merged result in loadSettings()\n\t\t\tif (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Settings validation failed at ${filename}:\\n - root: Expected object, received ${typeof parsed}`\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn parsed as z.infer<typeof IloomSettingsSchemaNoDefaults>\n\t\t} catch (error) {\n\t\t\t// File not found is not an error - return empty settings\n\t\t\tif ((error as { code?: string }).code === 'ENOENT') {\n\t\t\t\tlogger.debug(`No settings file found at ${settingsPath}, using defaults`)\n\t\t\t\treturn {}\n\t\t\t}\n\n\t\t\t// Re-throw parsing errors\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Deep merge two settings objects with priority to override\n\t * Uses deepmerge library with array replacement strategy\n\t */\n\tprivate mergeSettings(\n\t\tbase: Partial<IloomSettings> | z.infer<typeof IloomSettingsSchemaNoDefaults>,\n\t\toverride: Partial<IloomSettings> | z.infer<typeof IloomSettingsSchemaNoDefaults>,\n\t): IloomSettings {\n\t\t// Use deepmerge with array replacement (not concatenation)\n\t\t// Type assertion is safe because the merged result will be validated with IloomSettingsSchema\n\t\t// which applies all the defaults after merging\n\t\treturn deepmerge(base as Record<string, unknown>, override as Record<string, unknown>, {\n\t\t\t// Replace arrays instead of concatenating them\n\t\t\tarrayMerge: (_destinationArray, sourceArray) => sourceArray,\n\t\t}) as IloomSettings\n\t}\n\n\t/**\n\t * Format all Zod validation errors into a single error message\n\t */\n\tprivate formatAllZodErrors(error: z.ZodError, settingsPath: string): Error {\n\t\tconst errorMessages = error.issues.map(issue => {\n\t\t\tconst path = issue.path.length > 0 ? issue.path.join('.') : 'root'\n\t\t\treturn ` - ${path}: ${issue.message}`\n\t\t})\n\n\t\treturn new Error(\n\t\t\t`Settings validation failed at ${settingsPath}:\\n${errorMessages.join('\\n')}`,\n\t\t)\n\t}\n\n\t/**\n\t * Validate settings structure and model names using Zod schema\n\t * This method is kept for testing purposes but uses Zod internally\n\t * @internal - Only used in tests via bracket notation\n\t */\n\t// @ts-expect-error - Used in tests via bracket notation, TypeScript can't detect this usage\n\tprivate validateSettings(settings: IloomSettings): void {\n\t\ttry {\n\t\t\tIloomSettingsSchema.parse(settings)\n\t\t} catch (error) {\n\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\tthrow this.formatAllZodErrors(error, '<validation>')\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/**\n\t * Get project root (defaults to process.cwd())\n\t */\n\tprivate getProjectRoot(projectRoot?: string): string {\n\t\treturn projectRoot ?? process.cwd()\n\t}\n\n\t/**\n\t * Get global config directory path (~/.config/iloom-ai)\n\t */\n\tprivate getGlobalConfigDir(): string {\n\t\treturn path.join(os.homedir(), '.config', 'iloom-ai')\n\t}\n\n\t/**\n\t * Get global settings file path (~/.config/iloom-ai/settings.json)\n\t */\n\tprivate getGlobalSettingsPath(): string {\n\t\treturn path.join(this.getGlobalConfigDir(), 'settings.json')\n\t}\n\n\t/**\n\t * Load and parse global settings file\n\t * Returns empty object if file doesn't exist (not an error)\n\t * Warns but returns empty object on validation/parse errors (graceful degradation)\n\t */\n\tprivate async loadGlobalSettingsFile(): Promise<z.infer<typeof IloomSettingsSchemaNoDefaults>> {\n\t\tconst settingsPath = this.getGlobalSettingsPath()\n\n\t\ttry {\n\t\t\tconst content = await readFile(settingsPath, 'utf-8')\n\t\t\tlet parsed: unknown\n\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(content)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`Failed to parse global settings file at ${settingsPath}: ${error instanceof Error ? error.message : 'Invalid JSON'}. Ignoring global settings.`,\n\t\t\t\t)\n\t\t\t\treturn {}\n\t\t\t}\n\n\t\t\t// Validate with non-defaulting schema\n\t\t\ttry {\n\t\t\t\tconst validated = IloomSettingsSchemaNoDefaults.strict().parse(parsed)\n\t\t\t\treturn validated\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof z.ZodError) {\n\t\t\t\t\tconst errorMsg = this.formatAllZodErrors(error, 'global settings')\n\t\t\t\t\tlogger.warn(`${errorMsg.message}. Ignoring global settings.`)\n\t\t\t\t} else {\n\t\t\t\t\tlogger.warn(`Validation error in global settings: ${error instanceof Error ? error.message : 'Unknown error'}. Ignoring global settings.`)\n\t\t\t\t}\n\t\t\t\treturn {}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// File not found is not an error - return empty settings\n\t\t\tif ((error as { code?: string }).code === 'ENOENT') {\n\t\t\t\tlogger.debug(`No global settings file found at ${settingsPath}`)\n\t\t\t\treturn {}\n\t\t\t}\n\n\t\t\t// Other file system errors - warn and continue\n\t\t\tlogger.warn(`Error reading global settings file at ${settingsPath}: ${error instanceof Error ? error.message : 'Unknown error'}. Ignoring global settings.`)\n\t\t\treturn {}\n\t\t}\n\t}\n\n\t/**\n\t * Get effective protected branches list with mainBranch always included\n\t *\n\t * This method provides a single source of truth for protected branches logic:\n\t * 1. Use configured protectedBranches if provided\n\t * 2. Otherwise use defaults: [mainBranch, 'main', 'master', 'develop']\n\t * 3. ALWAYS ensure mainBranch is included even if user configured custom list\n\t *\n\t * @param projectRoot - Optional project root directory (defaults to process.cwd())\n\t * @returns Array of protected branch names with mainBranch guaranteed to be included\n\t */\n\tasync getProtectedBranches(projectRoot?: string): Promise<string[]> {\n\t\tconst settings = await this.loadSettings(projectRoot)\n\t\tconst mainBranch = settings.mainBranch ?? 'main'\n\n\t\t// Build protected branches list:\n\t\t// 1. Use configured protectedBranches if provided\n\t\t// 2. Otherwise use defaults: [mainBranch, 'main', 'master', 'develop']\n\t\t// 3. ALWAYS ensure mainBranch is included even if user configured custom list\n\t\tlet protectedBranches: string[]\n\t\tif (settings.protectedBranches) {\n\t\t\t// Use configured list but ensure mainBranch is always included\n\t\t\tprotectedBranches = settings.protectedBranches.includes(mainBranch)\n\t\t\t\t? settings.protectedBranches\n\t\t\t\t: [mainBranch, ...settings.protectedBranches]\n\t\t} else {\n\t\t\t// Use defaults with current mainBranch\n\t\t\tprotectedBranches = [mainBranch, 'main', 'master', 'develop']\n\t\t}\n\n\t\treturn protectedBranches\n\t}\n}\n"],"mappings":";;;;;;AAAA,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAS,SAAS;AAClB,OAAO,eAAe;AAMf,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC3C,OAAO,EACL,KAAK,CAAC,UAAU,QAAQ,OAAO,CAAC,EAChC,SAAS,EACT,SAAS,gDAAgD;AAAA;AAE5D,CAAC;AAKM,IAAM,2BAA2B,EAAE,OAAO;AAAA,EAChD,gBAAgB,EACd,KAAK,CAAC,QAAQ,eAAe,qBAAqB,SAAS,CAAC,EAC5D,SAAS,EACT,SAAS,sDAAsD;AAAA,EACjE,UAAU,EACR,QAAQ,EACR,SAAS,EACT,SAAS,4EAA4E;AAAA,EACvF,UAAU,EACR,QAAQ,EACR,QAAQ,IAAI,EACZ,SAAS,oDAAoD;AAAA,EAC/D,gBAAgB,EACd,QAAQ,EACR,QAAQ,IAAI,EACZ,SAAS,4DAA4D;AAAA,EACvE,cAAc,EACZ,QAAQ,EACR,QAAQ,IAAI,EACZ,SAAS,2DAA2D;AAAA,EACtE,eAAe,EACb,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
|
process.stdin.setRawMode(true);
|
|
62
62
|
process.stdin.resume();
|
|
63
63
|
process.stdin.once("data", (chunk) => {
|
|
64
|
+
const key = chunk.toString("utf8");
|
|
64
65
|
process.stdin.setRawMode(false);
|
|
65
66
|
process.stdin.pause();
|
|
67
|
+
if (key === "") {
|
|
68
|
+
process.stdout.write("\n");
|
|
69
|
+
process.exit(130);
|
|
70
|
+
}
|
|
66
71
|
process.stdout.write("\n");
|
|
67
|
-
const key = chunk.toString("utf8");
|
|
68
72
|
resolve(key);
|
|
69
73
|
});
|
|
70
74
|
});
|
|
@@ -72,11 +76,46 @@ async function waitForKeypress(message = "Press any key to continue...") {
|
|
|
72
76
|
function isInteractiveEnvironment() {
|
|
73
77
|
return process.stdin.isTTY === true && process.env.CI !== "true";
|
|
74
78
|
}
|
|
79
|
+
async function promptCommitAction(message) {
|
|
80
|
+
if (!isInteractiveEnvironment()) {
|
|
81
|
+
return "accept";
|
|
82
|
+
}
|
|
83
|
+
process.stdout.write("\n" + "=".repeat(60) + "\n");
|
|
84
|
+
process.stdout.write("COMMIT MESSAGE:\n");
|
|
85
|
+
process.stdout.write("=".repeat(60) + "\n");
|
|
86
|
+
process.stdout.write(message + "\n");
|
|
87
|
+
process.stdout.write("=".repeat(60) + "\n\n");
|
|
88
|
+
const rl = readline.createInterface({
|
|
89
|
+
input: process.stdin,
|
|
90
|
+
output: process.stdout
|
|
91
|
+
});
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
rl.question("[A]ccept as-is, [E]dit in editor, A[b]ort? [A/e/b]: ", (answer) => {
|
|
94
|
+
rl.close();
|
|
95
|
+
const normalized = answer.trim().toLowerCase();
|
|
96
|
+
if (normalized === "" || normalized === "a") {
|
|
97
|
+
resolve("accept");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (normalized === "e") {
|
|
101
|
+
resolve("edit");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (normalized === "b") {
|
|
105
|
+
resolve("abort");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
logger.warn("Invalid input, defaulting to accept", { input: answer });
|
|
109
|
+
resolve("accept");
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
75
113
|
|
|
76
114
|
export {
|
|
77
115
|
promptConfirmation,
|
|
78
116
|
promptInput,
|
|
79
117
|
waitForKeypress,
|
|
80
|
-
isInteractiveEnvironment
|
|
118
|
+
isInteractiveEnvironment,
|
|
119
|
+
promptCommitAction
|
|
81
120
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-CE26YH2U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/prompt.ts"],"sourcesContent":["import * as readline from 'node:readline'\nimport { logger } from './logger.js'\n\n/**\n * Prompt user for confirmation (yes/no)\n * @param message The question to ask the user\n * @param defaultValue Default value if user just presses enter (default: false)\n * @returns Promise<boolean> - true if user confirms, false otherwise\n */\nexport async function promptConfirmation(\n\tmessage: string,\n\tdefaultValue = false\n): Promise<boolean> {\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t})\n\n\tconst suffix = defaultValue ? '[Y/n]' : '[y/N]'\n\tconst fullMessage = `${message} ${suffix}: `\n\n\treturn new Promise((resolve) => {\n\t\trl.question(fullMessage, (answer) => {\n\t\t\trl.close()\n\n\t\t\tconst normalized = answer.trim().toLowerCase()\n\n\t\t\tif (normalized === '') {\n\t\t\t\tresolve(defaultValue)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (normalized === 'y' || normalized === 'yes') {\n\t\t\t\tresolve(true)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (normalized === 'n' || normalized === 'no') {\n\t\t\t\tresolve(false)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Invalid input, use default\n\t\t\tlogger.warn('Invalid input, using default value', {\n\t\t\t\tinput: answer,\n\t\t\t\tdefaultValue,\n\t\t\t})\n\t\t\tresolve(defaultValue)\n\t\t})\n\t})\n}\n\n/**\n * Prompt user for text input\n * @param message The prompt message\n * @param defaultValue Optional default value\n * @returns Promise<string> - the user's input\n */\nexport async function promptInput(\n\tmessage: string,\n\tdefaultValue?: string\n): Promise<string> {\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t})\n\n\tconst suffix = defaultValue ? ` [${defaultValue}]` : ''\n\tconst fullMessage = `${message}${suffix}: `\n\n\treturn new Promise((resolve) => {\n\t\trl.question(fullMessage, (answer) => {\n\t\t\trl.close()\n\n\t\t\tconst trimmed = answer.trim()\n\n\t\t\tif (trimmed === '' && defaultValue !== undefined) {\n\t\t\t\tresolve(defaultValue)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tresolve(trimmed)\n\t\t})\n\t})\n}\n\n/**\n * Wait for the user to press any key\n * @param message Optional message to display (default: \"Press any key to continue...\")\n * @returns Promise<string> - resolves with the key that was pressed\n */\nexport async function waitForKeypress(\n\tmessage = 'Press any key to continue...'\n): Promise<string> {\n\t// Display message first\n\tprocess.stdout.write(message)\n\n\treturn new Promise((resolve) => {\n\t\t// Enable raw mode to capture single keypresses\n\t\tprocess.stdin.setRawMode(true)\n\t\tprocess.stdin.resume()\n\n\t\t// Listen for single data event\n\t\tprocess.stdin.once('data', (chunk: Buffer) => {\n\t\t\tconst key = chunk.toString('utf8')\n\n\t\t\t// Restore normal mode first (cleanup before any exit)\n\t\t\tprocess.stdin.setRawMode(false)\n\t\t\tprocess.stdin.pause()\n\n\t\t\t// Handle Ctrl+C (ETX character \\x03)\n\t\t\tif (key === '\\x03') {\n\t\t\t\tprocess.stdout.write('\\n')\n\t\t\t\tprocess.exit(130) // Standard exit code for SIGINT (128 + 2)\n\t\t\t}\n\n\t\t\t// Add newline after keypress for clean output\n\t\t\tprocess.stdout.write('\\n')\n\t\t\tresolve(key)\n\t\t})\n\t})\n}\n\n/**\n * Check if running in an interactive environment\n * Returns false if CI environment or no TTY\n */\nexport function isInteractiveEnvironment(): boolean {\n\treturn process.stdin.isTTY === true && process.env.CI !== 'true'\n}\n\n// Commit action type for type safety\nexport type CommitAction = 'accept' | 'edit' | 'abort'\n\n/**\n * Display commit message and prompt for action\n * @param message The commit message to display\n * @returns Promise<CommitAction> - 'accept', 'edit', or 'abort'\n */\nexport async function promptCommitAction(message: string): Promise<CommitAction> {\n\t// Check for non-interactive environment first\n\tif (!isInteractiveEnvironment()) {\n\t\treturn 'accept'\n\t}\n\n\t// Display the commit message with clear demarcation\n\tprocess.stdout.write('\\n' + '='.repeat(60) + '\\n')\n\tprocess.stdout.write('COMMIT MESSAGE:\\n')\n\tprocess.stdout.write('='.repeat(60) + '\\n')\n\tprocess.stdout.write(message + '\\n')\n\tprocess.stdout.write('='.repeat(60) + '\\n\\n')\n\n\t// Create readline interface (following existing pattern from promptConfirmation)\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t})\n\n\treturn new Promise((resolve) => {\n\t\trl.question('[A]ccept as-is, [E]dit in editor, A[b]ort? [A/e/b]: ', (answer) => {\n\t\t\trl.close()\n\n\t\t\tconst normalized = answer.trim().toLowerCase()\n\n\t\t\tif (normalized === '' || normalized === 'a') {\n\t\t\t\tresolve('accept')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (normalized === 'e') {\n\t\t\t\tresolve('edit')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (normalized === 'b') {\n\t\t\t\tresolve('abort')\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Invalid input - default to accept\n\t\t\tlogger.warn('Invalid input, defaulting to accept', { input: answer })\n\t\t\tresolve('accept')\n\t\t})\n\t})\n}\n"],"mappings":";;;;;;AAAA,YAAY,cAAc;AAS1B,eAAsB,mBACrB,SACA,eAAe,OACI;AACnB,QAAM,KAAc,yBAAgB;AAAA,IACnC,OAAO,QAAQ;AAAA,IACf,QAAQ,QAAQ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A,EACF,CAAC;AACF;","names":[]}
|
|
@@ -7,88 +7,38 @@ import {
|
|
|
7
7
|
import { createHash } from "crypto";
|
|
8
8
|
function getColorPalette() {
|
|
9
9
|
return [
|
|
10
|
-
|
|
11
|
-
{ r: 220, g: 235, b: 248 },
|
|
10
|
+
{ r: 220, g: 235, b: 255 },
|
|
12
11
|
// 0: Soft blue
|
|
13
|
-
{ r:
|
|
12
|
+
{ r: 255, g: 220, b: 235 },
|
|
14
13
|
// 1: Soft pink
|
|
15
|
-
{ r: 220, g:
|
|
14
|
+
{ r: 220, g: 255, b: 235 },
|
|
16
15
|
// 2: Soft green
|
|
17
|
-
{ r:
|
|
16
|
+
{ r: 255, g: 245, b: 220 },
|
|
18
17
|
// 3: Soft cream
|
|
19
|
-
{ r:
|
|
18
|
+
{ r: 245, g: 220, b: 255 },
|
|
20
19
|
// 4: Soft lavender
|
|
21
|
-
{ r: 220, g:
|
|
20
|
+
{ r: 220, g: 245, b: 255 },
|
|
22
21
|
// 5: Soft cyan
|
|
23
22
|
{ r: 235, g: 235, b: 235 },
|
|
24
23
|
// 6: Soft grey
|
|
25
|
-
{ r:
|
|
26
|
-
// 7: Soft
|
|
27
|
-
{ r:
|
|
28
|
-
// 8: Soft
|
|
29
|
-
{ r:
|
|
30
|
-
// 9: Soft
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// 15: Pale sage
|
|
44
|
-
{ r: 245, g: 250, b: 235 },
|
|
45
|
-
// 16: Pale lemon
|
|
46
|
-
{ r: 245, g: 235, b: 235 },
|
|
47
|
-
// 17: Pale blush
|
|
48
|
-
{ r: 235, g: 235, b: 250 },
|
|
49
|
-
// 18: Pale lavender blue
|
|
50
|
-
{ r: 250, g: 235, b: 235 },
|
|
51
|
-
// 19: Pale coral
|
|
52
|
-
{ r: 235, g: 250, b: 250 },
|
|
53
|
-
// 20: Pale aqua
|
|
54
|
-
{ r: 240, g: 248, b: 255 },
|
|
55
|
-
// 21: Alice blue
|
|
56
|
-
{ r: 255, g: 240, b: 248 },
|
|
57
|
-
// 22: Lavender blush
|
|
58
|
-
{ r: 240, g: 255, b: 248 },
|
|
59
|
-
// 23: Honeydew tint
|
|
60
|
-
{ r: 255, g: 248, b: 240 },
|
|
61
|
-
// 24: Antique white
|
|
62
|
-
{ r: 248, g: 240, b: 255 },
|
|
63
|
-
// 25: Magnolia
|
|
64
|
-
{ r: 240, g: 248, b: 240 },
|
|
65
|
-
// 26: Mint cream tint
|
|
66
|
-
{ r: 248, g: 255, b: 240 },
|
|
67
|
-
// 27: Ivory tint
|
|
68
|
-
{ r: 248, g: 240, b: 240 },
|
|
69
|
-
// 28: Misty rose tint
|
|
70
|
-
{ r: 240, g: 240, b: 255 },
|
|
71
|
-
// 29: Ghost white tint
|
|
72
|
-
{ r: 255, g: 245, b: 238 },
|
|
73
|
-
// 30: Seashell
|
|
74
|
-
{ r: 245, g: 255, b: 250 },
|
|
75
|
-
// 31: Azure mist
|
|
76
|
-
{ r: 250, g: 245, b: 255 },
|
|
77
|
-
// 32: Lilac mist
|
|
78
|
-
{ r: 255, g: 250, b: 245 },
|
|
79
|
-
// 33: Snow peach
|
|
80
|
-
{ r: 238, g: 245, b: 255 },
|
|
81
|
-
// 34: Powder blue
|
|
82
|
-
{ r: 255, g: 238, b: 245 },
|
|
83
|
-
// 35: Pink lace
|
|
84
|
-
{ r: 245, g: 255, b: 238 },
|
|
85
|
-
// 36: Pale lime
|
|
86
|
-
{ r: 238, g: 255, b: 245 },
|
|
87
|
-
// 37: Pale turquoise
|
|
88
|
-
{ r: 245, g: 238, b: 255 },
|
|
89
|
-
// 38: Pale violet
|
|
90
|
-
{ r: 255, g: 245, b: 255 }
|
|
91
|
-
// 39: Pale magenta
|
|
24
|
+
{ r: 255, g: 230, b: 230 },
|
|
25
|
+
// 7: Soft coral
|
|
26
|
+
{ r: 230, g: 255, b: 230 },
|
|
27
|
+
// 8: Soft mint
|
|
28
|
+
{ r: 255, g: 245, b: 230 },
|
|
29
|
+
// 9: Soft peach
|
|
30
|
+
{ r: 220, g: 255, b: 255 },
|
|
31
|
+
// 10: Soft aqua
|
|
32
|
+
{ r: 255, g: 220, b: 255 },
|
|
33
|
+
// 11: Soft magenta
|
|
34
|
+
{ r: 255, g: 255, b: 220 },
|
|
35
|
+
// 12: Soft yellow
|
|
36
|
+
{ r: 235, g: 220, b: 255 },
|
|
37
|
+
// 13: Soft violet
|
|
38
|
+
{ r: 220, g: 255, b: 245 },
|
|
39
|
+
// 14: Soft sea green
|
|
40
|
+
{ r: 255, g: 235, b: 220 }
|
|
41
|
+
// 15: Soft salmon
|
|
92
42
|
];
|
|
93
43
|
}
|
|
94
44
|
function rgbToHex(r, g, b) {
|
|
@@ -128,6 +78,52 @@ function generateColorFromBranchName(branchName) {
|
|
|
128
78
|
index
|
|
129
79
|
};
|
|
130
80
|
}
|
|
81
|
+
function colorDistance(a, b) {
|
|
82
|
+
return Math.sqrt(
|
|
83
|
+
Math.pow(a.r - b.r, 2) + Math.pow(a.g - b.g, 2) + Math.pow(a.b - b.b, 2)
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
var MIN_COLOR_DISTANCE = 20;
|
|
87
|
+
function selectDistinctColor(branchName, usedHexColors) {
|
|
88
|
+
const palette = getColorPalette();
|
|
89
|
+
const hashBasedColor = generateColorFromBranchName(branchName);
|
|
90
|
+
if (usedHexColors.length === 0) {
|
|
91
|
+
return hashBasedColor;
|
|
92
|
+
}
|
|
93
|
+
const usedRgbColors = [];
|
|
94
|
+
for (const hex of usedHexColors) {
|
|
95
|
+
try {
|
|
96
|
+
usedRgbColors.push(hexToRgb(hex));
|
|
97
|
+
} catch {
|
|
98
|
+
logger_default.debug(`[selectDistinctColor] Skipping invalid hex color: ${hex}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (usedRgbColors.length === 0) {
|
|
102
|
+
return hashBasedColor;
|
|
103
|
+
}
|
|
104
|
+
const isTooSimilar = usedRgbColors.some(
|
|
105
|
+
(usedRgb) => colorDistance(hashBasedColor.rgb, usedRgb) < MIN_COLOR_DISTANCE
|
|
106
|
+
);
|
|
107
|
+
if (!isTooSimilar) {
|
|
108
|
+
return hashBasedColor;
|
|
109
|
+
}
|
|
110
|
+
for (let i = 0; i < palette.length; i++) {
|
|
111
|
+
const candidateRgb = palette[i];
|
|
112
|
+
if (!candidateRgb) continue;
|
|
113
|
+
const isDistinct = usedRgbColors.every(
|
|
114
|
+
(usedRgb) => colorDistance(candidateRgb, usedRgb) >= MIN_COLOR_DISTANCE
|
|
115
|
+
);
|
|
116
|
+
if (isDistinct) {
|
|
117
|
+
return {
|
|
118
|
+
rgb: candidateRgb,
|
|
119
|
+
hex: rgbToHex(candidateRgb.r, candidateRgb.g, candidateRgb.b),
|
|
120
|
+
index: i
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
logger_default.debug(`[selectDistinctColor] No distinct color found, falling back to hash-based for ${branchName}`);
|
|
125
|
+
return hashBasedColor;
|
|
126
|
+
}
|
|
131
127
|
function lightenColor(rgb, amount) {
|
|
132
128
|
const clamp = (value) => Math.min(255, Math.max(0, Math.round(value)));
|
|
133
129
|
return {
|
|
@@ -162,8 +158,11 @@ export {
|
|
|
162
158
|
rgbToHex,
|
|
163
159
|
hexToRgb,
|
|
164
160
|
generateColorFromBranchName,
|
|
161
|
+
colorDistance,
|
|
162
|
+
MIN_COLOR_DISTANCE,
|
|
163
|
+
selectDistinctColor,
|
|
165
164
|
lightenColor,
|
|
166
165
|
saturateColor,
|
|
167
166
|
calculateForegroundColor
|
|
168
167
|
};
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
168
|
+
//# sourceMappingURL=chunk-CFFQ2Z7A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/color.ts"],"sourcesContent":["import { createHash } from 'crypto'\nimport logger from './logger'\n\n/**\n * RGB color representation\n */\nexport interface RgbColor {\n\tr: number\n\tg: number\n\tb: number\n}\n\n/**\n * Complete color data with RGB, hex, and palette index\n */\nexport interface ColorData {\n\trgb: RgbColor\n\thex: string\n\tindex: number\n}\n\n/**\n * Get the predefined color palette (16 visually distinct colors)\n * Reduced from 40 colors to ensure minimum euclidean distance >= 30 between all pairs\n * This prevents near-identical colors being assigned to different looms\n *\n * @returns Array of 16 RGB colors\n */\nexport function getColorPalette(): RgbColor[] {\n\treturn [\n\t\t{ r: 220, g: 235, b: 255 }, // 0: Soft blue\n\t\t{ r: 255, g: 220, b: 235 }, // 1: Soft pink\n\t\t{ r: 220, g: 255, b: 235 }, // 2: Soft green\n\t\t{ r: 255, g: 245, b: 220 }, // 3: Soft cream\n\t\t{ r: 245, g: 220, b: 255 }, // 4: Soft lavender\n\t\t{ r: 220, g: 245, b: 255 }, // 5: Soft cyan\n\t\t{ r: 235, g: 235, b: 235 }, // 6: Soft grey\n\t\t{ r: 255, g: 230, b: 230 }, // 7: Soft coral\n\t\t{ r: 230, g: 255, b: 230 }, // 8: Soft mint\n\t\t{ r: 255, g: 245, b: 230 }, // 9: Soft peach\n\t\t{ r: 220, g: 255, b: 255 }, // 10: Soft aqua\n\t\t{ r: 255, g: 220, b: 255 }, // 11: Soft magenta\n\t\t{ r: 255, g: 255, b: 220 }, // 12: Soft yellow\n\t\t{ r: 235, g: 220, b: 255 }, // 13: Soft violet\n\t\t{ r: 220, g: 255, b: 245 }, // 14: Soft sea green\n\t\t{ r: 255, g: 235, b: 220 }, // 15: Soft salmon\n\t]\n}\n\n/**\n * Convert RGB values to hex color format\n *\n * @param r - Red value (0-255)\n * @param g - Green value (0-255)\n * @param b - Blue value (0-255)\n * @returns Hex color string (e.g., \"#dcebf8\")\n * @throws Error if RGB values are out of range\n */\nexport function rgbToHex(r: number, g: number, b: number): string {\n\t// Validate RGB values\n\tif (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {\n\t\tthrow new Error('RGB values must be between 0 and 255')\n\t}\n\n\t// Convert to hex and pad with zeros\n\tconst rHex = r.toString(16).padStart(2, '0')\n\tconst gHex = g.toString(16).padStart(2, '0')\n\tconst bHex = b.toString(16).padStart(2, '0')\n\n\treturn `#${rHex}${gHex}${bHex}`\n}\n\n/**\n * Convert hex color format to RGB values\n *\n * @param hex - Hex color string (with or without # prefix)\n * @returns RGB color object\n * @throws Error if hex format is invalid\n */\nexport function hexToRgb(hex: string): RgbColor {\n\t// Remove # prefix if present\n\tconst cleanHex = hex.startsWith('#') ? hex.slice(1) : hex\n\n\t// Validate format (must be exactly 6 hex characters)\n\tif (cleanHex.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(cleanHex)) {\n\t\tthrow new Error('Invalid hex color format. Expected format: #RRGGBB or RRGGBB')\n\t}\n\n\t// Parse hex values\n\tconst r = parseInt(cleanHex.slice(0, 2), 16)\n\tconst g = parseInt(cleanHex.slice(2, 4), 16)\n\tconst b = parseInt(cleanHex.slice(4, 6), 16)\n\n\treturn { r, g, b }\n}\n\n/**\n * Generate deterministic color from branch name using SHA256 hash\n * Matches the bash implementation in bash/new-branch-workflow.sh\n *\n * @param branchName - Branch name to generate color from\n * @returns ColorData with RGB, hex, and palette index\n */\nexport function generateColorFromBranchName(branchName: string): ColorData {\n\t// Generate SHA256 hash of branch name\n\tconst hash = createHash('sha256').update(branchName).digest('hex')\n\n\t// Take first 8 hex characters and convert to index (0-39)\n\t// Matches bash: local index=$(( 0x$hash % ${#colors[@]} ))\n\tconst hashPrefix = hash.slice(0, 8)\n\tconst palette = getColorPalette()\n\tconst hashAsInt = parseInt(hashPrefix, 16)\n\tconst index = hashAsInt % palette.length\n\tlogger.debug(`[generateColorFromBranchName] Branch name: ${branchName}, Hash: ${hash}, Hash prefix: ${hashPrefix}, Hash as int: ${hashAsInt}, Index: ${index}`)\n\n\t// Get color from palette\n\tconst rgb = palette[index]\n\n\t// This should never happen as index is always in range [0, palette.length)\n\tif (!rgb) {\n\t\tthrow new Error(`Invalid color index: ${index}`)\n\t}\n\n\t// Convert to hex format\n\tconst hex = rgbToHex(rgb.r, rgb.g, rgb.b)\n\n\treturn {\n\t\trgb,\n\t\thex,\n\t\tindex,\n\t}\n}\n\n/**\n * Calculate euclidean distance between two RGB colors\n */\nexport function colorDistance(a: RgbColor, b: RgbColor): number {\n\treturn Math.sqrt(\n\t\tMath.pow(a.r - b.r, 2) +\n\t\tMath.pow(a.g - b.g, 2) +\n\t\tMath.pow(a.b - b.b, 2)\n\t)\n}\n\n/**\n * Minimum distance threshold for colors to be considered \"distinct\"\n * Note: With RGB constrained to 220-255 range (subtle backgrounds),\n * the maximum possible distance between any two colors is ~60.6\n * A threshold of 20 ensures colors are visually distinguishable\n * (vs the original palette minimum of 3.61) while allowing enough\n * palette diversity for typical concurrent loom counts (5-10).\n */\nexport const MIN_COLOR_DISTANCE = 20\n\n/**\n * Select a color for a branch, avoiding colors that are too similar to hex colors in use\n * This function is robust against palette changes since it compares hex colors directly.\n *\n * @param branchName - Branch name to generate base color from\n * @param usedHexColors - Array of hex colors (e.g., \"#dcebff\") already in use by active looms\n * @returns ColorData with the selected color\n */\nexport function selectDistinctColor(branchName: string, usedHexColors: string[]): ColorData {\n\tconst palette = getColorPalette()\n\tconst hashBasedColor = generateColorFromBranchName(branchName)\n\n\t// If no colors in use, return hash-based selection\n\tif (usedHexColors.length === 0) {\n\t\treturn hashBasedColor\n\t}\n\n\t// Convert used hex colors to RGB for distance calculation\n\tconst usedRgbColors: RgbColor[] = []\n\tfor (const hex of usedHexColors) {\n\t\ttry {\n\t\t\tusedRgbColors.push(hexToRgb(hex))\n\t\t} catch {\n\t\t\t// Skip invalid hex colors\n\t\t\tlogger.debug(`[selectDistinctColor] Skipping invalid hex color: ${hex}`)\n\t\t}\n\t}\n\n\t// If all hex colors were invalid, return hash-based selection\n\tif (usedRgbColors.length === 0) {\n\t\treturn hashBasedColor\n\t}\n\n\t// Check if hash-based color is distinct enough from all used colors\n\tconst isTooSimilar = usedRgbColors.some(usedRgb =>\n\t\tcolorDistance(hashBasedColor.rgb, usedRgb) < MIN_COLOR_DISTANCE\n\t)\n\n\tif (!isTooSimilar) {\n\t\treturn hashBasedColor\n\t}\n\n\t// Find the first available color that's distinct from all used colors\n\tfor (let i = 0; i < palette.length; i++) {\n\t\tconst candidateRgb = palette[i]\n\t\tif (!candidateRgb) continue\n\n\t\tconst isDistinct = usedRgbColors.every(usedRgb =>\n\t\t\tcolorDistance(candidateRgb, usedRgb) >= MIN_COLOR_DISTANCE\n\t\t)\n\n\t\tif (isDistinct) {\n\t\t\treturn {\n\t\t\t\trgb: candidateRgb,\n\t\t\t\thex: rgbToHex(candidateRgb.r, candidateRgb.g, candidateRgb.b),\n\t\t\t\tindex: i,\n\t\t\t}\n\t\t}\n\t}\n\n\t// Fallback: all colors too similar, return hash-based (best effort)\n\tlogger.debug(`[selectDistinctColor] No distinct color found, falling back to hash-based for ${branchName}`)\n\treturn hashBasedColor\n}\n\n/**\n * Lighten a color by a given amount\n * Useful for creating slightly lighter variants for hover states\n *\n * @param rgb - RGB color to lighten\n * @param amount - Amount to lighten (0-1, where 0.1 = 10% lighter)\n * @returns Lightened RGB color\n */\nexport function lightenColor(rgb: RgbColor, amount: number): RgbColor {\n\tconst clamp = (value: number): number => Math.min(255, Math.max(0, Math.round(value)))\n\n\treturn {\n\t\tr: clamp(rgb.r + (255 - rgb.r) * amount),\n\t\tg: clamp(rgb.g + (255 - rgb.g) * amount),\n\t\tb: clamp(rgb.b + (255 - rgb.b) * amount),\n\t}\n}\n\n/**\n * Saturate a color by pushing it away from grey towards its dominant hue\n * Makes subtle colors more vivid while maintaining their hue\n *\n * @param rgb - RGB color to saturate\n * @param amount - Amount to saturate (0-1, where 0.4 = 40% more saturated)\n * @returns Saturated RGB color\n */\nexport function saturateColor(rgb: RgbColor, amount: number): RgbColor {\n\tconst clamp = (value: number): number => Math.min(255, Math.max(0, Math.round(value)))\n\n\t// Calculate average (grey point)\n\tconst avg = (rgb.r + rgb.g + rgb.b) / 3\n\n\t// Push each channel away from grey\n\treturn {\n\t\tr: clamp(rgb.r + (rgb.r - avg) * amount),\n\t\tg: clamp(rgb.g + (rgb.g - avg) * amount),\n\t\tb: clamp(rgb.b + (rgb.b - avg) * amount),\n\t}\n}\n\n/**\n * Calculate appropriate foreground color (black or white) for a given background\n * Uses relative luminance formula from WCAG 2.0\n *\n * @param rgb - Background RGB color\n * @returns '#000000' for light backgrounds, '#ffffff' for dark backgrounds\n */\nexport function calculateForegroundColor(rgb: RgbColor): string {\n\t// Convert RGB to relative luminance (WCAG 2.0 formula)\n\tconst toLinear = (channel: number): number => {\n\t\tconst c = channel / 255\n\t\treturn c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4)\n\t}\n\n\tconst r = toLinear(rgb.r)\n\tconst g = toLinear(rgb.g)\n\tconst b = toLinear(rgb.b)\n\n\tconst luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b\n\n\t// Use black text for light backgrounds (luminance > 0.5)\n\t// Use white text for dark backgrounds\n\treturn luminance > 0.5 ? '#000000' : '#ffffff'\n}\n"],"mappings":";;;;;;AAAA,SAAS,kBAAkB;AA4BpB,SAAS,kBAA8B;AAC7C,SAAO;AAAA,IACN,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;AAAA;AAAA,IACzB,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;AAAA;AAAA,IACzB,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;AAAA;AAAA,IACzB,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;AAAA;AAAA,IACzB,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;AAAA;AAAA,IACzB,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;AAAA;AAAA,IACzB,EAAE,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI;A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