@sylphx/flow 2.1.3 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +44 -0
  3. package/package.json +79 -73
  4. package/src/commands/flow/execute-v2.ts +37 -29
  5. package/src/commands/flow/prompt.ts +5 -3
  6. package/src/commands/flow/types.ts +0 -2
  7. package/src/commands/flow-command.ts +20 -13
  8. package/src/commands/hook-command.ts +1 -3
  9. package/src/commands/settings/checkbox-config.ts +128 -0
  10. package/src/commands/settings/index.ts +6 -0
  11. package/src/commands/settings-command.ts +84 -156
  12. package/src/config/ai-config.ts +60 -41
  13. package/src/core/agent-loader.ts +11 -6
  14. package/src/core/attach/file-attacher.ts +172 -0
  15. package/src/core/attach/index.ts +5 -0
  16. package/src/core/attach-manager.ts +117 -171
  17. package/src/core/backup-manager.ts +35 -29
  18. package/src/core/cleanup-handler.ts +11 -8
  19. package/src/core/error-handling.ts +23 -30
  20. package/src/core/flow-executor.ts +58 -76
  21. package/src/core/formatting/bytes.ts +2 -4
  22. package/src/core/functional/async.ts +5 -4
  23. package/src/core/functional/error-handler.ts +2 -2
  24. package/src/core/git-stash-manager.ts +21 -10
  25. package/src/core/installers/file-installer.ts +0 -1
  26. package/src/core/installers/mcp-installer.ts +0 -1
  27. package/src/core/project-manager.ts +24 -18
  28. package/src/core/secrets-manager.ts +54 -73
  29. package/src/core/session-manager.ts +20 -22
  30. package/src/core/state-detector.ts +139 -80
  31. package/src/core/template-loader.ts +13 -31
  32. package/src/core/upgrade-manager.ts +122 -69
  33. package/src/index.ts +8 -5
  34. package/src/services/auto-upgrade.ts +1 -1
  35. package/src/services/config-service.ts +41 -29
  36. package/src/services/global-config.ts +3 -3
  37. package/src/services/target-installer.ts +11 -26
  38. package/src/targets/claude-code.ts +35 -81
  39. package/src/targets/opencode.ts +28 -68
  40. package/src/targets/shared/index.ts +7 -0
  41. package/src/targets/shared/mcp-transforms.ts +132 -0
  42. package/src/targets/shared/target-operations.ts +135 -0
  43. package/src/types/cli.types.ts +2 -2
  44. package/src/types/provider.types.ts +1 -7
  45. package/src/types/session.types.ts +11 -11
  46. package/src/types/target.types.ts +3 -1
  47. package/src/types/todo.types.ts +1 -1
  48. package/src/types.ts +1 -1
  49. package/src/utils/__tests__/package-manager-detector.test.ts +6 -6
  50. package/src/utils/agent-enhancer.ts +4 -4
  51. package/src/utils/config/paths.ts +3 -1
  52. package/src/utils/config/target-utils.ts +2 -2
  53. package/src/utils/display/banner.ts +2 -2
  54. package/src/utils/display/notifications.ts +58 -45
  55. package/src/utils/display/status.ts +29 -12
  56. package/src/utils/files/file-operations.ts +1 -1
  57. package/src/utils/files/sync-utils.ts +38 -41
  58. package/src/utils/index.ts +19 -27
  59. package/src/utils/package-manager-detector.ts +15 -5
  60. package/src/utils/security/security.ts +8 -4
  61. package/src/utils/target-selection.ts +6 -8
  62. package/src/utils/version.ts +4 -2
  63. package/src/commands/flow-orchestrator.ts +0 -328
  64. package/src/commands/init-command.ts +0 -92
  65. package/src/commands/init-core.ts +0 -331
  66. package/src/core/agent-manager.ts +0 -174
  67. package/src/core/loop-controller.ts +0 -200
  68. package/src/core/rule-loader.ts +0 -147
  69. package/src/core/rule-manager.ts +0 -240
  70. package/src/services/claude-config-service.ts +0 -252
  71. package/src/services/first-run-setup.ts +0 -220
  72. package/src/services/smart-config-service.ts +0 -269
  73. package/src/types/api.types.ts +0 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @sylphx/flow
2
2
 
3
+ ## 2.1.5 (2025-11-28)
4
+
5
+ ### šŸ› Bug Fixes
6
+
7
+ - **settings:** use MCP_SERVER_REGISTRY instead of hardcoded list ([79fb625](https://github.com/SylphxAI/flow/commit/79fb625c27f58f7f62902314d92c205fdc84a06e))
8
+
9
+ ### ā™»ļø Refactoring
10
+
11
+ - **settings:** extract checkbox configuration handler ([66303bb](https://github.com/SylphxAI/flow/commit/66303bb21a5281e5f358c69b8a6c143f3866fa76))
12
+ - **attach:** extract file attachment pure functions ([5723be3](https://github.com/SylphxAI/flow/commit/5723be3817804228014ceec8de27f267c990fbe8))
13
+ - **targets:** extract shared pure functions for MCP transforms ([0bba2cb](https://github.com/SylphxAI/flow/commit/0bba2cbc4a4233e0d63a78875346a2e9c341d803))
14
+
15
+ ### šŸ”§ Chores
16
+
17
+ - remove dead cursor target references ([bf16f75](https://github.com/SylphxAI/flow/commit/bf16f759ec4705ddf0a763ea0ef6c778c91ccbbe))
18
+
19
+ ## 2.1.4 (2025-11-28)
20
+
21
+ ### ā™»ļø Refactoring
22
+
23
+ - **flow:** eliminate hardcoded target checks with Target interface ([1dc75f9](https://github.com/SylphxAI/flow/commit/1dc75f9d4936b51554b1d09bf8576f832ce131e9))
24
+
25
+ ### šŸ”§ Chores
26
+
27
+ - apply @sylphx/doctor fixes for 100% health score ([ae55969](https://github.com/SylphxAI/flow/commit/ae5596924dab48675ff3100b40f67651e7ebe26f))
28
+ - remove unused api.types.ts re-export file ([ad8f6a6](https://github.com/SylphxAI/flow/commit/ad8f6a6b8dcad75d2c0201f2286e52adccb728c7))
29
+ - remove dead code and unused modules ([6eaa904](https://github.com/SylphxAI/flow/commit/6eaa90438dcb40f9508953e874bf8c04204ae017))
30
+
3
31
  ## 2.1.3
4
32
 
5
33
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @sylphx/flow
2
+
3
+ **One CLI to rule them all.**
4
+
5
+ Unified orchestration layer for Claude Code, OpenCode, Cursor and all AI development tools. Auto-detection, auto-installation, auto-upgrade.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @sylphx/flow
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Run with a prompt
17
+ sylphx-flow "your prompt here"
18
+
19
+ # Configure settings
20
+ sylphx-flow settings
21
+
22
+ # Check status
23
+ sylphx-flow status
24
+ ```
25
+
26
+ ## Features
27
+
28
+ - **Auto-detect** - Automatically detects installed AI CLIs
29
+ - **Auto-install** - Installs missing dependencies on demand
30
+ - **Auto-upgrade** - Upgrades before each session
31
+ - **Unified settings** - One configuration for all tools
32
+ - **MEP system** - Minimal Effective Prompts for optimal context
33
+
34
+ ## Documentation
35
+
36
+ See the [main repository](https://github.com/sylphxltd/flow) for full documentation.
37
+
38
+ ## License
39
+
40
+ MIT License - see [LICENSE](../../LICENSE) file for details.
41
+
42
+ ---
43
+
44
+ Powered by [@sylphx](https://github.com/SylphxAI)
package/package.json CHANGED
@@ -1,75 +1,81 @@
1
1
  {
2
- "name": "@sylphx/flow",
3
- "version": "2.1.3",
4
- "description": "One CLI to rule them all. Unified orchestration layer for Claude Code, OpenCode, Cursor and all AI development tools. Auto-detection, auto-installation, auto-upgrade.",
5
- "type": "module",
6
- "bin": {
7
- "sylphx-flow": "./src/index.ts"
8
- },
9
- "engines": {
10
- "node": ">=18.0.0"
11
- },
12
- "scripts": {
13
- "dev": "bun src/index.ts",
14
- "start": "bun src/index.ts",
15
- "test": "vitest run",
16
- "test:watch": "vitest",
17
- "type-check": "tsc --noEmit",
18
- "prepublishOnly": "echo 'Using assets from packages/flow/assets'"
19
- },
20
- "dependencies": {
21
- "commander": "^14.0.2",
22
- "chalk": "^5.6.2",
23
- "boxen": "^8.0.1",
24
- "gradient-string": "^3.0.0",
25
- "ora": "^9.0.0",
26
- "inquirer": "^12.10.0",
27
- "gray-matter": "^4.0.3",
28
- "yaml": "^2.8.1",
29
- "zod": "^4.1.12",
30
- "debug": "^4.4.3"
31
- },
32
- "devDependencies": {
33
- "@types/node": "^24.9.2",
34
- "typescript": "^5.9.3",
35
- "vitest": "^4.0.6"
36
- },
37
- "publishConfig": {
38
- "access": "public"
39
- },
40
- "files": [
41
- "src",
42
- "assets",
43
- "README.md",
44
- "CHANGELOG.md",
45
- "LOOP_MODE.md",
46
- "UPGRADE.md",
47
- "package.json"
48
- ],
49
- "keywords": [
50
- "ai",
51
- "automation",
52
- "workflow",
53
- "claude-code",
54
- "opencode",
55
- "cursor",
56
- "cli",
57
- "orchestration",
58
- "unified",
59
- "meta-layer",
60
- "developer-tools",
61
- "auto-install",
62
- "auto-upgrade"
63
- ],
64
- "repository": {
65
- "type": "git",
66
- "url": "https://github.com/sylphxltd/flow.git",
67
- "directory": "packages/flow"
68
- },
69
- "bugs": {
70
- "url": "https://github.com/sylphxltd/flow/issues"
71
- },
72
- "homepage": "https://github.com/sylphxltd/flow#readme",
73
- "license": "MIT",
74
- "author": "sylphxltd"
2
+ "name": "@sylphx/flow",
3
+ "version": "2.1.5",
4
+ "description": "One CLI to rule them all. Unified orchestration layer for Claude Code, OpenCode, Cursor and all AI development tools. Auto-detection, auto-installation, auto-upgrade.",
5
+ "type": "module",
6
+ "bin": {
7
+ "sylphx-flow": "./src/index.ts"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "import": "./src/index.ts",
12
+ "types": "./src/index.ts"
13
+ }
14
+ },
15
+ "engines": {
16
+ "node": ">=18.0.0"
17
+ },
18
+ "scripts": {
19
+ "dev": "bun src/index.ts",
20
+ "start": "bun src/index.ts",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest",
23
+ "type-check": "tsc --noEmit",
24
+ "prepublishOnly": "echo 'Using assets from packages/flow/assets'"
25
+ },
26
+ "dependencies": {
27
+ "commander": "^14.0.2",
28
+ "chalk": "^5.6.2",
29
+ "boxen": "^8.0.1",
30
+ "gradient-string": "^3.0.0",
31
+ "ora": "^9.0.0",
32
+ "inquirer": "^12.10.0",
33
+ "gray-matter": "^4.0.3",
34
+ "yaml": "^2.8.1",
35
+ "zod": "^4.1.12",
36
+ "debug": "^4.4.3"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^24.9.2",
40
+ "typescript": "^5.9.3",
41
+ "vitest": "^4.0.6"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "files": [
47
+ "src",
48
+ "assets",
49
+ "README.md",
50
+ "CHANGELOG.md",
51
+ "LOOP_MODE.md",
52
+ "UPGRADE.md",
53
+ "package.json"
54
+ ],
55
+ "keywords": [
56
+ "ai",
57
+ "automation",
58
+ "workflow",
59
+ "claude-code",
60
+ "opencode",
61
+ "cursor",
62
+ "cli",
63
+ "orchestration",
64
+ "unified",
65
+ "meta-layer",
66
+ "developer-tools",
67
+ "auto-install",
68
+ "auto-upgrade"
69
+ ],
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "https://github.com/sylphxltd/flow.git",
73
+ "directory": "packages/flow"
74
+ },
75
+ "bugs": {
76
+ "url": "https://github.com/sylphxltd/flow/issues"
77
+ },
78
+ "homepage": "https://github.com/sylphxltd/flow#readme",
79
+ "license": "MIT",
80
+ "author": "sylphxltd"
75
81
  }
@@ -7,26 +7,22 @@ import chalk from 'chalk';
7
7
  import inquirer from 'inquirer';
8
8
  import { FlowExecutor } from '../../core/flow-executor.js';
9
9
  import { targetManager } from '../../core/target-manager.js';
10
- import { UpgradeManager } from '../../core/upgrade-manager.js';
10
+ import { AutoUpgrade } from '../../services/auto-upgrade.js';
11
+ import { GlobalConfigService } from '../../services/global-config.js';
12
+ import { TargetInstaller } from '../../services/target-installer.js';
13
+ import type { RunCommandOptions } from '../../types.js';
14
+ import { extractAgentInstructions, loadAgentContent } from '../../utils/agent-enhancer.js';
11
15
  import { showWelcome } from '../../utils/display/banner.js';
12
- import { loadAgentContent, extractAgentInstructions } from '../../utils/agent-enhancer.js';
13
16
  import { CLIError } from '../../utils/error-handler.js';
14
- import type { RunCommandOptions } from '../../types.js';
15
- import type { FlowOptions } from './types.js';
16
- import { resolvePrompt } from './prompt.js';
17
- import { GlobalConfigService } from '../../services/global-config.js';
18
17
  import { UserCancelledError } from '../../utils/errors.js';
19
- import { TargetInstaller } from '../../services/target-installer.js';
20
- import { AutoUpgrade } from '../../services/auto-upgrade.js';
21
- import { promptForTargetSelection, ensureTargetInstalled } from '../../utils/target-selection.js';
18
+ import { ensureTargetInstalled, promptForTargetSelection } from '../../utils/target-selection.js';
19
+ import { resolvePrompt } from './prompt.js';
20
+ import type { FlowOptions } from './types.js';
22
21
 
23
22
  /**
24
23
  * Configure provider environment variables
25
24
  */
26
- function configureProviderEnv(
27
- provider: 'kimi' | 'zai',
28
- apiKey: string
29
- ): void {
25
+ function configureProviderEnv(provider: 'kimi' | 'zai', apiKey: string): void {
30
26
  const providerConfig = {
31
27
  kimi: {
32
28
  baseUrl: 'https://api.moonshot.cn/v1',
@@ -46,9 +42,7 @@ function configureProviderEnv(
46
42
  /**
47
43
  * Select and configure provider for Claude Code
48
44
  */
49
- async function selectProvider(
50
- configService: GlobalConfigService
51
- ): Promise<void> {
45
+ async function selectProvider(configService: GlobalConfigService): Promise<void> {
52
46
  try {
53
47
  const providerConfig = await configService.loadProviderConfig();
54
48
  const defaultProvider = providerConfig.claudeCode.defaultProvider;
@@ -95,9 +89,10 @@ async function selectProvider(
95
89
  } else {
96
90
  console.log(chalk.green('āœ“ Using default Claude Code provider\n'));
97
91
  }
98
- } catch (error: any) {
92
+ } catch (error: unknown) {
99
93
  // Handle user cancellation (Ctrl+C)
100
- if (error.name === 'ExitPromptError' || error.message?.includes('force closed')) {
94
+ const err = error as Error & { name?: string };
95
+ if (err.name === 'ExitPromptError' || err.message?.includes('force closed')) {
101
96
  throw new UserCancelledError('Provider selection cancelled');
102
97
  }
103
98
  throw error;
@@ -107,7 +102,7 @@ async function selectProvider(
107
102
  /**
108
103
  * Execute command using target's executeCommand method
109
104
  */
110
- async function executeTargetCommand(
105
+ function executeTargetCommand(
111
106
  targetId: string,
112
107
  systemPrompt: string,
113
108
  userPrompt: string,
@@ -173,7 +168,11 @@ export async function executeFlowV2(
173
168
  );
174
169
 
175
170
  const installation = targetInstaller.getInstallationInfo(selectedTargetId);
176
- const installed = await ensureTargetInstalled(selectedTargetId, targetInstaller, installedTargets);
171
+ const installed = await ensureTargetInstalled(
172
+ selectedTargetId,
173
+ targetInstaller,
174
+ installedTargets
175
+ );
177
176
 
178
177
  if (!installed) {
179
178
  process.exit(1);
@@ -200,7 +199,11 @@ export async function executeFlowV2(
200
199
  );
201
200
 
202
201
  const installation = targetInstaller.getInstallationInfo(selectedTargetId);
203
- const installed = await ensureTargetInstalled(selectedTargetId, targetInstaller, installedTargets);
202
+ const installed = await ensureTargetInstalled(
203
+ selectedTargetId,
204
+ targetInstaller,
205
+ installedTargets
206
+ );
204
207
 
205
208
  if (!installed) {
206
209
  process.exit(1);
@@ -225,7 +228,11 @@ export async function executeFlowV2(
225
228
 
226
229
  if (!installed) {
227
230
  // Installation failed - show error and exit
228
- console.log(chalk.red(`\nāœ— Cannot proceed: ${installation?.name} is not installed and auto-install failed`));
231
+ console.log(
232
+ chalk.red(
233
+ `\nāœ— Cannot proceed: ${installation?.name} is not installed and auto-install failed`
234
+ )
235
+ );
229
236
  console.log(chalk.yellow(' Please either:'));
230
237
  console.log(chalk.cyan(' 1. Install manually (see instructions above)'));
231
238
  console.log(chalk.cyan(' 2. Change default target: sylphx-flow settings\n'));
@@ -242,16 +249,20 @@ export async function executeFlowV2(
242
249
 
243
250
  // Mode info
244
251
  if (options.merge) {
245
- console.log(chalk.cyan('šŸ”— Merge mode: Flow settings will be merged with your existing settings'));
252
+ console.log(
253
+ chalk.cyan('šŸ”— Merge mode: Flow settings will be merged with your existing settings')
254
+ );
246
255
  console.log(chalk.dim(' Settings will be restored after execution\n'));
247
256
  } else {
248
- console.log(chalk.yellow('šŸ”„ Replace mode (default): All settings will use Flow configuration'));
257
+ console.log(
258
+ chalk.yellow('šŸ”„ Replace mode (default): All settings will use Flow configuration')
259
+ );
249
260
  console.log(chalk.dim(' Use --merge to keep your existing settings\n'));
250
261
  }
251
262
 
252
263
  // Create executor
253
264
  const executor = new FlowExecutor();
254
- const projectManager = executor.getProjectManager();
265
+ const _projectManager = executor.getProjectManager();
255
266
 
256
267
  // Step 2: Execute attach mode lifecycle
257
268
  try {
@@ -361,10 +372,7 @@ export async function executeFlowV2(
361
372
  /**
362
373
  * Main flow execution entry point
363
374
  */
364
- export async function executeFlow(
365
- prompt: string | undefined,
366
- options: FlowOptions
367
- ): Promise<void> {
375
+ export async function executeFlow(prompt: string | undefined, options: FlowOptions): Promise<void> {
368
376
  // Resolve prompt (handle file input)
369
377
  const resolvedPrompt = await resolvePrompt(prompt);
370
378
 
@@ -3,8 +3,8 @@
3
3
  * Handle file input (@file.txt) and prompt loading
4
4
  */
5
5
 
6
- import path from 'node:path';
7
6
  import fs from 'node:fs/promises';
7
+ import path from 'node:path';
8
8
  import chalk from 'chalk';
9
9
 
10
10
  /**
@@ -12,7 +12,9 @@ import chalk from 'chalk';
12
12
  * Supports @filename syntax: @prompt.txt or @/path/to/prompt.txt
13
13
  */
14
14
  export async function resolvePrompt(prompt: string | undefined): Promise<string | undefined> {
15
- if (!prompt) return prompt;
15
+ if (!prompt) {
16
+ return prompt;
17
+ }
16
18
 
17
19
  // Check for file input syntax: @filename
18
20
  if (prompt.startsWith('@')) {
@@ -26,7 +28,7 @@ export async function resolvePrompt(prompt: string | undefined): Promise<string
26
28
  const content = await fs.readFile(resolvedPath, 'utf-8');
27
29
  console.log(chalk.dim(` āœ“ Loaded prompt from: ${filePath}\n`));
28
30
  return content.trim();
29
- } catch (error) {
31
+ } catch (_error) {
30
32
  throw new Error(`Failed to read prompt file: ${filePath}`);
31
33
  }
32
34
  }
@@ -2,8 +2,6 @@
2
2
  * Flow Command Types
3
3
  */
4
4
 
5
- import type { RunCommandOptions } from '../../types.js';
6
-
7
5
  export interface FlowOptions {
8
6
  target?: string;
9
7
  verbose?: boolean;
@@ -3,10 +3,10 @@
3
3
  * Entry point for all flow-related CLI commands
4
4
  */
5
5
 
6
- import { Command } from 'commander';
7
- import chalk from 'chalk';
8
- import path from 'node:path';
9
6
  import fs from 'node:fs/promises';
7
+ import path from 'node:path';
8
+ import chalk from 'chalk';
9
+ import { Command } from 'commander';
10
10
  import { StateDetector } from '../core/state-detector.js';
11
11
  import { UpgradeManager } from '../core/upgrade-manager.js';
12
12
  import { showWelcome } from '../utils/display/banner.js';
@@ -30,7 +30,10 @@ export const flowCommand = new Command('flow')
30
30
  .option('--merge', 'Merge Flow settings with existing settings (default: replace all)')
31
31
 
32
32
  // Prompt argument
33
- .argument('[prompt]', 'Prompt to execute with agent (optional, supports @file.txt for file input)')
33
+ .argument(
34
+ '[prompt]',
35
+ 'Prompt to execute with agent (optional, supports @file.txt for file input)'
36
+ )
34
37
 
35
38
  .action(async (prompt, options: FlowOptions) => {
36
39
  await executeFlow(prompt, options);
@@ -41,7 +44,7 @@ export const flowCommand = new Command('flow')
41
44
  */
42
45
  export const setupCommand = new Command('setup')
43
46
  .description('[DEPRECATED] No longer needed - Flow uses automatic attach mode')
44
- .action(async () => {
47
+ .action(() => {
45
48
  console.log(chalk.yellow('āš ļø The "setup" command is deprecated.\n'));
46
49
  console.log(chalk.cyan('Flow now uses automatic attach mode:'));
47
50
  console.log(chalk.dim(' • No installation needed'));
@@ -118,23 +121,23 @@ export const doctorCommand = new Command('doctor')
118
121
  await executeFlow(undefined, { sync: true } as FlowOptions);
119
122
  console.log(chalk.green(' āœ“ å·²äæ®å¤'));
120
123
  }
121
- } else if (!state.initialized) {
124
+ } else if (state.initialized) {
125
+ console.log(chalk.green(' āœ“ é…ē½®ę­£åøø'));
126
+ } else {
122
127
  console.log(chalk.yellow(' ⚠ é”¹ē›®ęœŖåˆå§‹åŒ–'));
123
128
  issuesFound = true;
124
- } else {
125
- console.log(chalk.green(' āœ“ é…ē½®ę­£åøø'));
126
129
  }
127
130
 
128
131
  // Check 3: Components
129
132
  console.log('\nę£€ęŸ„ē»„ä»¶...');
130
133
  Object.entries(state.components).forEach(([name, component]) => {
131
134
  const status = component.installed ? chalk.green('āœ“') : chalk.red('āœ—');
132
- const count = ('count' in component && component.count) ? ` (${component.count})` : '';
135
+ const count = 'count' in component && component.count ? ` (${component.count})` : '';
133
136
  console.log(` ${status} ${name}${count}`);
134
137
  });
135
138
 
136
139
  // Summary
137
- console.log('\n' + chalk.bold('ē»“ęžœ:'));
140
+ console.log(`\n${chalk.bold('ē»“ęžœ:')}`);
138
141
  if (!issuesFound) {
139
142
  console.log(chalk.green('āœ“ ę‰€ęœ‰ę£€ęŸ„é€ščæ‡'));
140
143
  } else if (options.fix) {
@@ -168,16 +171,20 @@ export const upgradeCommand = new Command('upgrade')
168
171
  }
169
172
 
170
173
  if (updates.flowVersion) {
171
- console.log(`Sylphx Flow: ${updates.flowVersion.current} → ${chalk.green(updates.flowVersion.latest)}`);
174
+ console.log(
175
+ `Sylphx Flow: ${updates.flowVersion.current} → ${chalk.green(updates.flowVersion.latest)}`
176
+ );
172
177
  }
173
178
 
174
179
  if (updates.targetVersion) {
175
- console.log(`${updates.targetVersion.current ? 'claude-code' : 'target'}: ${updates.targetVersion.current} → ${chalk.green(updates.targetVersion.latest)}`);
180
+ console.log(
181
+ `${updates.targetVersion.current ? 'claude-code' : 'target'}: ${updates.targetVersion.current} → ${chalk.green(updates.targetVersion.latest)}`
182
+ );
176
183
  }
177
184
 
178
185
  // Check only
179
186
  if (options.check) {
180
- console.log('\n' + chalk.dim('Run without --check to upgrade'));
187
+ console.log(`\n${chalk.dim('Run without --check to upgrade')}`);
181
188
  return;
182
189
  }
183
190
 
@@ -153,9 +153,7 @@ async function sendLinuxNotification(title: string, message: string): Promise<vo
153
153
  try {
154
154
  await execAsync('which notify-send');
155
155
  // Use Flow-themed spiral emoji as icon for Sylphx Flow
156
- await execAsync(
157
- `notify-send -i "šŸŒ€" "${escapeForShell(title)}" "${escapeForShell(message)}"`
158
- );
156
+ await execAsync(`notify-send -i "šŸŒ€" "${escapeForShell(title)}" "${escapeForShell(message)}"`);
159
157
  } catch {
160
158
  // notify-send not available, skip notification silently
161
159
  }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Generic checkbox configuration handler
3
+ * Pure functions for settings UI patterns
4
+ */
5
+
6
+ import chalk from 'chalk';
7
+ import inquirer from 'inquirer';
8
+
9
+ // ============================================================================
10
+ // Types
11
+ // ============================================================================
12
+
13
+ export interface ConfigItem {
14
+ enabled: boolean;
15
+ }
16
+
17
+ export type ConfigMap = Record<string, ConfigItem>;
18
+
19
+ export interface CheckboxConfigOptions<T extends string> {
20
+ /** Section title (e.g., "Agents Configuration") */
21
+ title: string;
22
+ /** Icon for the section (e.g., "šŸ¤–") */
23
+ icon: string;
24
+ /** Prompt message (e.g., "Select agents to enable:") */
25
+ message: string;
26
+ /** Available items with display names */
27
+ available: Record<T, string>;
28
+ /** Current config state */
29
+ current: ConfigMap;
30
+ /** Item type name for confirmation (e.g., "agents", "rules") */
31
+ itemType: string;
32
+ }
33
+
34
+ export interface CheckboxConfigResult<T extends string> {
35
+ selected: T[];
36
+ updated: ConfigMap;
37
+ }
38
+
39
+ // ============================================================================
40
+ // Pure Functions
41
+ // ============================================================================
42
+
43
+ /**
44
+ * Get currently enabled keys from config
45
+ */
46
+ export const getEnabledKeys = (config: ConfigMap): string[] =>
47
+ Object.keys(config).filter((key) => config[key]?.enabled);
48
+
49
+ /**
50
+ * Build checkbox choices from available items
51
+ */
52
+ export const buildChoices = <T extends string>(
53
+ available: Record<T, string>,
54
+ enabledKeys: string[]
55
+ ): Array<{ name: string; value: T; checked: boolean }> =>
56
+ Object.entries(available).map(([key, name]) => ({
57
+ name: name as string,
58
+ value: key as T,
59
+ checked: enabledKeys.includes(key),
60
+ }));
61
+
62
+ /**
63
+ * Update config based on selection
64
+ * Returns new config object (immutable)
65
+ */
66
+ export const updateConfig = <T extends string>(
67
+ available: Record<T, string>,
68
+ selected: T[]
69
+ ): ConfigMap => {
70
+ const updated: ConfigMap = {};
71
+ for (const key of Object.keys(available)) {
72
+ updated[key] = { enabled: selected.includes(key as T) };
73
+ }
74
+ return updated;
75
+ };
76
+
77
+ /**
78
+ * Print section header
79
+ */
80
+ export const printHeader = (icon: string, title: string): void => {
81
+ console.log(chalk.cyan.bold(`\n━━━ ${icon} ${title}\n`));
82
+ };
83
+
84
+ /**
85
+ * Print confirmation message
86
+ */
87
+ export const printConfirmation = (itemType: string, count: number): void => {
88
+ console.log(chalk.green(`\nāœ“ ${itemType} configuration saved`));
89
+ console.log(chalk.dim(` Enabled ${itemType.toLowerCase()}: ${count}`));
90
+ };
91
+
92
+ // ============================================================================
93
+ // Main Handler
94
+ // ============================================================================
95
+
96
+ /**
97
+ * Generic checkbox configuration handler
98
+ * Handles the common pattern of select → update → save
99
+ */
100
+ export const handleCheckboxConfig = async <T extends string>(
101
+ options: CheckboxConfigOptions<T>
102
+ ): Promise<CheckboxConfigResult<T>> => {
103
+ const { title, icon, message, available, current, itemType } = options;
104
+
105
+ // Print header
106
+ printHeader(icon, title);
107
+
108
+ // Get current enabled items
109
+ const enabledKeys = getEnabledKeys(current);
110
+
111
+ // Show checkbox prompt
112
+ const { selected } = await inquirer.prompt([
113
+ {
114
+ type: 'checkbox',
115
+ name: 'selected',
116
+ message,
117
+ choices: buildChoices(available, enabledKeys),
118
+ },
119
+ ]);
120
+
121
+ // Update config
122
+ const updated = updateConfig(available, selected);
123
+
124
+ // Print confirmation
125
+ printConfirmation(itemType, selected.length);
126
+
127
+ return { selected, updated };
128
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Settings utilities
3
+ * Shared handlers for settings UI patterns
4
+ */
5
+
6
+ export * from './checkbox-config.js';