@sylphx/flow 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/assets/output-styles/silent.md +141 -8
  3. package/assets/rules/core.md +19 -2
  4. package/package.json +2 -12
  5. package/src/commands/flow/execute.ts +470 -0
  6. package/src/commands/flow/index.ts +11 -0
  7. package/src/commands/flow/prompt.ts +35 -0
  8. package/src/commands/flow/setup.ts +312 -0
  9. package/src/commands/flow/targets.ts +18 -0
  10. package/src/commands/flow/types.ts +47 -0
  11. package/src/commands/flow-command.ts +18 -967
  12. package/src/commands/flow-orchestrator.ts +14 -5
  13. package/src/commands/hook-command.ts +1 -1
  14. package/src/commands/init-core.ts +12 -3
  15. package/src/commands/run-command.ts +1 -1
  16. package/src/config/rules.ts +1 -1
  17. package/src/core/error-handling.ts +1 -1
  18. package/src/core/loop-controller.ts +1 -1
  19. package/src/core/state-detector.ts +1 -1
  20. package/src/core/target-manager.ts +1 -1
  21. package/src/index.ts +1 -1
  22. package/src/shared/files/index.ts +1 -1
  23. package/src/shared/processing/index.ts +1 -1
  24. package/src/targets/claude-code.ts +3 -3
  25. package/src/targets/opencode.ts +3 -3
  26. package/src/utils/agent-enhancer.ts +2 -2
  27. package/src/utils/{mcp-config.ts → config/mcp-config.ts} +4 -4
  28. package/src/utils/{paths.ts → config/paths.ts} +1 -1
  29. package/src/utils/{settings.ts → config/settings.ts} +1 -1
  30. package/src/utils/{target-config.ts → config/target-config.ts} +5 -5
  31. package/src/utils/{target-utils.ts → config/target-utils.ts} +3 -3
  32. package/src/utils/display/banner.ts +25 -0
  33. package/src/utils/display/status.ts +55 -0
  34. package/src/utils/{file-operations.ts → files/file-operations.ts} +2 -2
  35. package/src/utils/files/jsonc.ts +36 -0
  36. package/src/utils/{sync-utils.ts → files/sync-utils.ts} +3 -3
  37. package/src/utils/index.ts +42 -61
  38. package/src/utils/version.ts +47 -0
  39. package/src/components/benchmark-monitor.tsx +0 -331
  40. package/src/components/reindex-progress.tsx +0 -261
  41. package/src/composables/functional/index.ts +0 -14
  42. package/src/composables/functional/useEnvironment.ts +0 -171
  43. package/src/composables/functional/useFileSystem.ts +0 -139
  44. package/src/composables/index.ts +0 -4
  45. package/src/composables/useEnv.ts +0 -13
  46. package/src/composables/useRuntimeConfig.ts +0 -27
  47. package/src/core/ai-sdk.ts +0 -603
  48. package/src/core/app-factory.ts +0 -381
  49. package/src/core/builtin-agents.ts +0 -9
  50. package/src/core/command-system.ts +0 -550
  51. package/src/core/config-system.ts +0 -550
  52. package/src/core/connection-pool.ts +0 -390
  53. package/src/core/di-container.ts +0 -155
  54. package/src/core/headless-display.ts +0 -96
  55. package/src/core/interfaces/index.ts +0 -22
  56. package/src/core/interfaces/repository.interface.ts +0 -91
  57. package/src/core/interfaces/service.interface.ts +0 -133
  58. package/src/core/interfaces.ts +0 -96
  59. package/src/core/result.ts +0 -351
  60. package/src/core/service-config.ts +0 -252
  61. package/src/core/session-service.ts +0 -121
  62. package/src/core/storage-factory.ts +0 -115
  63. package/src/core/stream-handler.ts +0 -288
  64. package/src/core/type-utils.ts +0 -427
  65. package/src/core/unified-storage.ts +0 -456
  66. package/src/core/validation/limit.ts +0 -46
  67. package/src/core/validation/query.ts +0 -20
  68. package/src/db/auto-migrate.ts +0 -322
  69. package/src/db/base-database-client.ts +0 -144
  70. package/src/db/cache-db.ts +0 -218
  71. package/src/db/cache-schema.ts +0 -75
  72. package/src/db/database.ts +0 -70
  73. package/src/db/index.ts +0 -252
  74. package/src/db/memory-db.ts +0 -153
  75. package/src/db/memory-schema.ts +0 -29
  76. package/src/db/schema.ts +0 -289
  77. package/src/db/session-repository.ts +0 -733
  78. package/src/domains/index.ts +0 -6
  79. package/src/domains/utilities/index.ts +0 -6
  80. package/src/domains/utilities/time/index.ts +0 -5
  81. package/src/domains/utilities/time/tools.ts +0 -291
  82. package/src/services/agent-service.ts +0 -273
  83. package/src/services/evaluation-service.ts +0 -271
  84. package/src/services/functional/evaluation-logic.ts +0 -296
  85. package/src/services/functional/file-processor.ts +0 -273
  86. package/src/services/functional/index.ts +0 -12
  87. package/src/services/memory.service.ts +0 -476
  88. package/src/types/api/batch.ts +0 -108
  89. package/src/types/api/errors.ts +0 -118
  90. package/src/types/api/index.ts +0 -55
  91. package/src/types/api/requests.ts +0 -76
  92. package/src/types/api/responses.ts +0 -180
  93. package/src/types/api/websockets.ts +0 -85
  94. package/src/types/benchmark.ts +0 -49
  95. package/src/types/database.types.ts +0 -510
  96. package/src/types/memory-types.ts +0 -63
  97. package/src/utils/advanced-tokenizer.ts +0 -191
  98. package/src/utils/ai-model-fetcher.ts +0 -19
  99. package/src/utils/async-file-operations.ts +0 -516
  100. package/src/utils/audio-player.ts +0 -345
  101. package/src/utils/codebase-helpers.ts +0 -211
  102. package/src/utils/console-ui.ts +0 -79
  103. package/src/utils/database-errors.ts +0 -140
  104. package/src/utils/debug-logger.ts +0 -49
  105. package/src/utils/file-scanner.ts +0 -259
  106. package/src/utils/help.ts +0 -20
  107. package/src/utils/immutable-cache.ts +0 -106
  108. package/src/utils/jsonc.ts +0 -158
  109. package/src/utils/memory-tui.ts +0 -414
  110. package/src/utils/models-dev.ts +0 -91
  111. package/src/utils/parallel-operations.ts +0 -487
  112. package/src/utils/process-manager.ts +0 -155
  113. package/src/utils/prompts.ts +0 -120
  114. package/src/utils/search-tool-builder.ts +0 -214
  115. package/src/utils/session-manager.ts +0 -168
  116. package/src/utils/session-title.ts +0 -87
  117. package/src/utils/simplified-errors.ts +0 -410
  118. package/src/utils/template-engine.ts +0 -94
  119. package/src/utils/test-audio.ts +0 -71
  120. package/src/utils/todo-context.ts +0 -46
  121. package/src/utils/token-counter.ts +0 -288
  122. /package/src/utils/{cli-output.ts → display/cli-output.ts} +0 -0
  123. /package/src/utils/{logger.ts → display/logger.ts} +0 -0
  124. /package/src/utils/{notifications.ts → display/notifications.ts} +0 -0
  125. /package/src/utils/{secret-utils.ts → security/secret-utils.ts} +0 -0
  126. /package/src/utils/{security.ts → security/security.ts} +0 -0
@@ -1,171 +0,0 @@
1
- /**
2
- * Functional composable for environment variables
3
- * Type-safe access to environment with validation
4
- *
5
- * DESIGN RATIONALE:
6
- * - Explicit handling of missing variables
7
- * - Type-safe environment access
8
- * - Validation support
9
- * - Option type for optional values
10
- */
11
-
12
- import type { ConfigError } from '../../core/functional/error-types.js';
13
- import { configError } from '../../core/functional/error-types.js';
14
- import type { Option } from '../../core/functional/option.js';
15
- import { fromNullable } from '../../core/functional/option.js';
16
- import type { Result } from '../../core/functional/result.js';
17
- import { failure, success } from '../../core/functional/result.js';
18
-
19
- /**
20
- * Get environment variable as Option
21
- * Returns Some(value) if exists, None otherwise
22
- */
23
- export const getEnvOpt = (key: string): Option<string> => {
24
- return fromNullable(process.env[key]);
25
- };
26
-
27
- /**
28
- * Get environment variable or default
29
- */
30
- export const getEnvOrElse = (key: string, defaultValue: string): string => {
31
- return process.env[key] || defaultValue;
32
- };
33
-
34
- /**
35
- * Get required environment variable
36
- * Returns Result with error if missing
37
- */
38
- export const getEnvRequired = (key: string): Result<string, ConfigError> => {
39
- const value = process.env[key];
40
-
41
- if (value === undefined || value === '') {
42
- return failure(
43
- configError(`Required environment variable is missing: ${key}`, { configKey: key })
44
- );
45
- }
46
-
47
- return success(value);
48
- };
49
-
50
- /**
51
- * Get multiple required environment variables
52
- * Returns Result with all errors if any are missing
53
- */
54
- export const getEnvRequiredAll = (keys: string[]): Result<Record<string, string>, ConfigError> => {
55
- const missing: string[] = [];
56
- const values: Record<string, string> = {};
57
-
58
- for (const key of keys) {
59
- const value = process.env[key];
60
- if (value === undefined || value === '') {
61
- missing.push(key);
62
- } else {
63
- values[key] = value;
64
- }
65
- }
66
-
67
- if (missing.length > 0) {
68
- return failure(
69
- configError(`Required environment variables are missing: ${missing.join(', ')}`, {
70
- context: { missing },
71
- })
72
- );
73
- }
74
-
75
- return success(values);
76
- };
77
-
78
- /**
79
- * Parse environment variable as number
80
- */
81
- export const getEnvNumber = (key: string): Result<number, ConfigError> => {
82
- const value = process.env[key];
83
-
84
- if (value === undefined || value === '') {
85
- return failure(configError(`Environment variable is missing: ${key}`, { configKey: key }));
86
- }
87
-
88
- const parsed = Number(value);
89
- if (Number.isNaN(parsed)) {
90
- return failure(
91
- configError(`Environment variable is not a valid number: ${key}`, {
92
- configKey: key,
93
- context: { value },
94
- })
95
- );
96
- }
97
-
98
- return success(parsed);
99
- };
100
-
101
- /**
102
- * Parse environment variable as boolean
103
- * Accepts: true, false, 1, 0, yes, no (case insensitive)
104
- */
105
- export const getEnvBoolean = (key: string): Result<boolean, ConfigError> => {
106
- const value = process.env[key]?.toLowerCase();
107
-
108
- if (value === undefined || value === '') {
109
- return failure(configError(`Environment variable is missing: ${key}`, { configKey: key }));
110
- }
111
-
112
- const trueValues = ['true', '1', 'yes'];
113
- const falseValues = ['false', '0', 'no'];
114
-
115
- if (trueValues.includes(value)) {
116
- return success(true);
117
- }
118
-
119
- if (falseValues.includes(value)) {
120
- return success(false);
121
- }
122
-
123
- return failure(
124
- configError(`Environment variable is not a valid boolean: ${key}`, {
125
- configKey: key,
126
- context: { value },
127
- })
128
- );
129
- };
130
-
131
- /**
132
- * Parse environment variable as enum
133
- */
134
- export const getEnvEnum = <T extends string>(
135
- key: string,
136
- allowedValues: readonly T[]
137
- ): Result<T, ConfigError> => {
138
- const value = process.env[key];
139
-
140
- if (value === undefined || value === '') {
141
- return failure(configError(`Environment variable is missing: ${key}`, { configKey: key }));
142
- }
143
-
144
- if (!allowedValues.includes(value as T)) {
145
- return failure(
146
- configError(`Environment variable has invalid value: ${key}`, {
147
- configKey: key,
148
- context: {
149
- value,
150
- allowedValues: allowedValues as unknown as string[],
151
- },
152
- })
153
- );
154
- }
155
-
156
- return success(value as T);
157
- };
158
-
159
- /**
160
- * Get all environment variables
161
- */
162
- export const getAllEnv = (): NodeJS.ProcessEnv => {
163
- return process.env;
164
- };
165
-
166
- /**
167
- * Check if environment variable is set
168
- */
169
- export const hasEnv = (key: string): boolean => {
170
- return key in process.env && process.env[key] !== undefined && process.env[key] !== '';
171
- };
@@ -1,139 +0,0 @@
1
- /**
2
- * Functional composable for file system operations
3
- * Returns Result instead of throwing exceptions
4
- *
5
- * DESIGN RATIONALE:
6
- * - Explicit error handling
7
- * - Composable file operations
8
- * - Type-safe path handling
9
- * - Separation of concerns (pure path operations vs side effects)
10
- */
11
-
12
- import fsPromises from 'node:fs/promises';
13
- import path from 'node:path';
14
- import type { FileSystemError } from '../../core/functional/error-types.js';
15
- import { fileSystemError } from '../../core/functional/error-types.js';
16
- import type { Result } from '../../core/functional/result.js';
17
- import { tryCatchAsync } from '../../core/functional/result.js';
18
-
19
- /**
20
- * Pure path operations (no side effects)
21
- */
22
-
23
- export const joinPath = (...segments: string[]): string => path.join(...segments);
24
-
25
- export const resolvePath = (...segments: string[]): string => path.resolve(...segments);
26
-
27
- export const dirname = (filePath: string): string => path.dirname(filePath);
28
-
29
- export const basename = (filePath: string, ext?: string): string => path.basename(filePath, ext);
30
-
31
- export const extname = (filePath: string): string => path.extname(filePath);
32
-
33
- /**
34
- * File system operations (side effects, return Result)
35
- */
36
-
37
- export const readFile = async (filePath: string): Promise<Result<string, FileSystemError>> => {
38
- return tryCatchAsync(
39
- async () => {
40
- return await fsPromises.readFile(filePath, 'utf-8');
41
- },
42
- (error) =>
43
- fileSystemError(`Failed to read file: ${filePath}`, filePath, 'read', {
44
- cause: error instanceof Error ? error : undefined,
45
- })
46
- );
47
- };
48
-
49
- export const writeFile = async (
50
- filePath: string,
51
- content: string
52
- ): Promise<Result<void, FileSystemError>> => {
53
- return tryCatchAsync(
54
- async () => {
55
- await fsPromises.writeFile(filePath, content, 'utf-8');
56
- },
57
- (error) =>
58
- fileSystemError(`Failed to write file: ${filePath}`, filePath, 'write', {
59
- cause: error instanceof Error ? error : undefined,
60
- })
61
- );
62
- };
63
-
64
- export const deleteFile = async (filePath: string): Promise<Result<void, FileSystemError>> => {
65
- return tryCatchAsync(
66
- async () => {
67
- await fsPromises.unlink(filePath);
68
- },
69
- (error) =>
70
- fileSystemError(`Failed to delete file: ${filePath}`, filePath, 'delete', {
71
- cause: error instanceof Error ? error : undefined,
72
- })
73
- );
74
- };
75
-
76
- export const createDirectory = async (
77
- dirPath: string,
78
- options?: { recursive?: boolean }
79
- ): Promise<Result<void, FileSystemError>> => {
80
- return tryCatchAsync(
81
- async () => {
82
- await fsPromises.mkdir(dirPath, { recursive: options?.recursive ?? true });
83
- },
84
- (error) =>
85
- fileSystemError(`Failed to create directory: ${dirPath}`, dirPath, 'create', {
86
- cause: error instanceof Error ? error : undefined,
87
- })
88
- );
89
- };
90
-
91
- export const pathExists = async (filePath: string): Promise<Result<boolean, FileSystemError>> => {
92
- return tryCatchAsync(
93
- async () => {
94
- try {
95
- await fsPromises.access(filePath);
96
- return true;
97
- } catch {
98
- return false;
99
- }
100
- },
101
- (error) =>
102
- fileSystemError(`Failed to check if path exists: ${filePath}`, filePath, 'stat', {
103
- cause: error instanceof Error ? error : undefined,
104
- })
105
- );
106
- };
107
-
108
- export const readDirectory = async (
109
- dirPath: string
110
- ): Promise<Result<string[], FileSystemError>> => {
111
- return tryCatchAsync(
112
- async () => {
113
- return await fsPromises.readdir(dirPath);
114
- },
115
- (error) =>
116
- fileSystemError(`Failed to read directory: ${dirPath}`, dirPath, 'read', {
117
- cause: error instanceof Error ? error : undefined,
118
- })
119
- );
120
- };
121
-
122
- export const getStats = async (
123
- filePath: string
124
- ): Promise<Result<{ isFile: boolean; isDirectory: boolean; size: number }, FileSystemError>> => {
125
- return tryCatchAsync(
126
- async () => {
127
- const stats = await fsPromises.stat(filePath);
128
- return {
129
- isFile: stats.isFile(),
130
- isDirectory: stats.isDirectory(),
131
- size: stats.size,
132
- };
133
- },
134
- (error) =>
135
- fileSystemError(`Failed to get stats for: ${filePath}`, filePath, 'stat', {
136
- cause: error instanceof Error ? error : undefined,
137
- })
138
- );
139
- };
@@ -1,4 +0,0 @@
1
- // Re-export all composables for easy importing
2
-
3
- export { useEnv, useEnvVar } from './useEnv.js';
4
- export { useIsCI, useIsDebug, useRuntimeConfig } from './useRuntimeConfig.js';
@@ -1,13 +0,0 @@
1
- /**
2
- * Get environment variables with type safety
3
- */
4
- export function useEnv(): NodeJS.ProcessEnv {
5
- return process.env;
6
- }
7
-
8
- /**
9
- * Get specific environment variable with optional default
10
- */
11
- export function useEnvVar(key: string, defaultValue?: string): string | undefined {
12
- return process.env[key] || defaultValue;
13
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Get runtime configuration/state
3
- * This can be extended to include more runtime context
4
- */
5
- export function useRuntimeConfig() {
6
- return {
7
- isDebug: process.env.NODE_ENV === 'development' || process.env.DEBUG === 'true',
8
- isCI: process.env.CI === 'true',
9
- cwd: process.cwd(),
10
- platform: process.platform,
11
- nodeVersion: process.version,
12
- };
13
- }
14
-
15
- /**
16
- * Check if running in CI/CD environment
17
- */
18
- export function useIsCI(): boolean {
19
- return process.env.CI === 'true' || !!process.env.CI || !!process.env.CONTINUOUS_INTEGRATION;
20
- }
21
-
22
- /**
23
- * Check if running in debug mode
24
- */
25
- export function useIsDebug(): boolean {
26
- return process.env.DEBUG === 'true' || process.env.NODE_ENV === 'development';
27
- }