@sylphx/flow 1.8.0 → 1.8.2

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 +72 -0
  2. package/assets/output-styles/silent.md +145 -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,273 +0,0 @@
1
- /**
2
- * Functional file processing service
3
- * Pure file transformations separated from I/O
4
- *
5
- * DESIGN RATIONALE:
6
- * - Pure transformation functions
7
- * - Composable processing pipeline
8
- * - Side effects (I/O) explicit and isolated
9
- * - Testable without file system
10
- */
11
-
12
- import type { FileSystemError } from '../../core/functional/error-types.js';
13
- import { fileSystemError } from '../../core/functional/error-types.js';
14
- import type { Result } from '../../core/functional/result.js';
15
- import { all, failure, success } from '../../core/functional/result.js';
16
-
17
- /**
18
- * Domain types
19
- */
20
-
21
- export interface FileContent {
22
- path: string;
23
- content: string;
24
- metadata?: Record<string, unknown>;
25
- }
26
-
27
- export interface ProcessedFile {
28
- originalPath: string;
29
- processedContent: string;
30
- metadata: Record<string, unknown>;
31
- }
32
-
33
- export type FileTransform = (content: string) => string;
34
- export type FileValidator = (content: string) => Result<string, FileSystemError>;
35
-
36
- /**
37
- * Pure transformation functions
38
- */
39
-
40
- /**
41
- * Trim whitespace from content
42
- */
43
- export const trimContent: FileTransform = (content: string): string => {
44
- return content.trim();
45
- };
46
-
47
- /**
48
- * Normalize line endings to \n
49
- */
50
- export const normalizeLineEndings: FileTransform = (content: string): string => {
51
- return content.replace(/\r\n/g, '\n');
52
- };
53
-
54
- /**
55
- * Remove trailing whitespace from each line
56
- */
57
- export const removeTrailingWhitespace: FileTransform = (content: string): string => {
58
- return content
59
- .split('\n')
60
- .map((line) => line.trimEnd())
61
- .join('\n');
62
- };
63
-
64
- /**
65
- * Ensure file ends with newline
66
- */
67
- export const ensureTrailingNewline: FileTransform = (content: string): string => {
68
- if (!content.endsWith('\n')) {
69
- return `${content}\n`;
70
- }
71
- return content;
72
- };
73
-
74
- /**
75
- * Remove consecutive blank lines (keep max 1)
76
- */
77
- export const collapseBlankLines: FileTransform = (content: string): string => {
78
- return content.replace(/\n\n\n+/g, '\n\n');
79
- };
80
-
81
- /**
82
- * Apply multiple transforms in sequence
83
- */
84
- export const composeTransforms = (...transforms: FileTransform[]): FileTransform => {
85
- return (content: string) => transforms.reduce((acc, transform) => transform(acc), content);
86
- };
87
-
88
- /**
89
- * Standard cleanup pipeline
90
- */
91
- export const standardCleanup: FileTransform = composeTransforms(
92
- normalizeLineEndings,
93
- removeTrailingWhitespace,
94
- collapseBlankLines,
95
- ensureTrailingNewline
96
- );
97
-
98
- /**
99
- * Validation functions
100
- */
101
-
102
- /**
103
- * Validate content is not empty
104
- */
105
- export const validateNotEmpty: FileValidator = (
106
- content: string
107
- ): Result<string, FileSystemError> => {
108
- if (content.trim().length === 0) {
109
- return failure(fileSystemError('File content is empty', '', 'read'));
110
- }
111
- return success(content);
112
- };
113
-
114
- /**
115
- * Validate content size
116
- */
117
- export const validateSize =
118
- (maxBytes: number): FileValidator =>
119
- (content: string): Result<string, FileSystemError> => {
120
- const bytes = Buffer.byteLength(content, 'utf-8');
121
- if (bytes > maxBytes) {
122
- return failure(
123
- fileSystemError(`File content exceeds maximum size: ${bytes} > ${maxBytes}`, '', 'read', {
124
- context: { bytes, maxBytes },
125
- })
126
- );
127
- }
128
- return success(content);
129
- };
130
-
131
- /**
132
- * Validate content matches pattern
133
- */
134
- export const validatePattern =
135
- (pattern: RegExp, message: string): FileValidator =>
136
- (content: string): Result<string, FileSystemError> => {
137
- if (!pattern.test(content)) {
138
- return failure(fileSystemError(message, '', 'read'));
139
- }
140
- return success(content);
141
- };
142
-
143
- /**
144
- * Compose validators
145
- */
146
- export const composeValidators =
147
- (...validators: FileValidator[]): FileValidator =>
148
- (content: string): Result<string, FileSystemError> => {
149
- for (const validator of validators) {
150
- const result = validator(content);
151
- if (result._tag === 'Failure') {
152
- return result;
153
- }
154
- }
155
- return success(content);
156
- };
157
-
158
- /**
159
- * File processing operations
160
- */
161
-
162
- /**
163
- * Process a single file (pure transformation)
164
- */
165
- export const processFileContent = (
166
- file: FileContent,
167
- transform: FileTransform,
168
- validator?: FileValidator
169
- ): Result<ProcessedFile, FileSystemError> => {
170
- // Validate if validator provided
171
- if (validator) {
172
- const validationResult = validator(file.content);
173
- if (validationResult._tag === 'Failure') {
174
- return validationResult;
175
- }
176
- }
177
-
178
- // Apply transformation
179
- const processedContent = transform(file.content);
180
-
181
- return success({
182
- originalPath: file.path,
183
- processedContent,
184
- metadata: {
185
- ...file.metadata,
186
- processed: true,
187
- originalLength: file.content.length,
188
- processedLength: processedContent.length,
189
- },
190
- });
191
- };
192
-
193
- /**
194
- * Process multiple files
195
- */
196
- export const processFiles = (
197
- files: FileContent[],
198
- transform: FileTransform,
199
- validator?: FileValidator
200
- ): Result<ProcessedFile[], FileSystemError> => {
201
- const results = files.map((file) => processFileContent(file, transform, validator));
202
-
203
- return all(results);
204
- };
205
-
206
- /**
207
- * Filter files by extension (pure)
208
- */
209
- export const filterByExtension =
210
- (extensions: string[]) =>
211
- (files: FileContent[]): FileContent[] => {
212
- return files.filter((file) => {
213
- const ext = file.path.split('.').pop()?.toLowerCase();
214
- return ext && extensions.includes(ext);
215
- });
216
- };
217
-
218
- /**
219
- * Filter files by pattern (pure)
220
- */
221
- export const filterByPattern =
222
- (pattern: RegExp) =>
223
- (files: FileContent[]): FileContent[] => {
224
- return files.filter((file) => pattern.test(file.path));
225
- };
226
-
227
- /**
228
- * Sort files by path (pure)
229
- */
230
- export const sortByPath = (files: FileContent[]): FileContent[] => {
231
- return [...files].sort((a, b) => a.path.localeCompare(b.path));
232
- };
233
-
234
- /**
235
- * Group files by directory (pure)
236
- */
237
- export const groupByDirectory = (files: FileContent[]): Record<string, FileContent[]> => {
238
- return files.reduce(
239
- (acc, file) => {
240
- const dir = file.path.split('/').slice(0, -1).join('/') || '.';
241
- if (!acc[dir]) {
242
- acc[dir] = [];
243
- }
244
- acc[dir].push(file);
245
- return acc;
246
- },
247
- {} as Record<string, FileContent[]>
248
- );
249
- };
250
-
251
- /**
252
- * Extract metadata from content (pure)
253
- */
254
- export const extractMetadata =
255
- (extractor: (content: string) => Record<string, unknown>) =>
256
- (file: FileContent): FileContent => {
257
- return {
258
- ...file,
259
- metadata: {
260
- ...file.metadata,
261
- ...extractor(file.content),
262
- },
263
- };
264
- };
265
-
266
- /**
267
- * Building block for file processing pipelines
268
- */
269
- export const createFileProcessor = (transform: FileTransform, validator?: FileValidator) => {
270
- return (files: FileContent[]): Result<ProcessedFile[], FileSystemError> => {
271
- return processFiles(files, transform, validator);
272
- };
273
- };
@@ -1,12 +0,0 @@
1
- /**
2
- * Functional services
3
- * Business logic as composable pure functions
4
- *
5
- * DESIGN RATIONALE:
6
- * - Services as collections of pure functions
7
- * - Side effects isolated to service boundaries
8
- * - Composable through functional patterns
9
- * - Testable without mocking
10
- */
11
-
12
- export * from './file-processor.js';