@sylphx/flow 1.7.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 (131) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/assets/agents/coder.md +72 -119
  3. package/assets/agents/orchestrator.md +26 -90
  4. package/assets/agents/reviewer.md +76 -47
  5. package/assets/agents/writer.md +82 -63
  6. package/assets/output-styles/silent.md +141 -8
  7. package/assets/rules/code-standards.md +9 -33
  8. package/assets/rules/core.md +67 -59
  9. package/package.json +2 -12
  10. package/src/commands/flow/execute.ts +470 -0
  11. package/src/commands/flow/index.ts +11 -0
  12. package/src/commands/flow/prompt.ts +35 -0
  13. package/src/commands/flow/setup.ts +312 -0
  14. package/src/commands/flow/targets.ts +18 -0
  15. package/src/commands/flow/types.ts +47 -0
  16. package/src/commands/flow-command.ts +18 -967
  17. package/src/commands/flow-orchestrator.ts +14 -5
  18. package/src/commands/hook-command.ts +1 -1
  19. package/src/commands/init-core.ts +12 -3
  20. package/src/commands/run-command.ts +1 -1
  21. package/src/config/rules.ts +1 -1
  22. package/src/core/error-handling.ts +1 -1
  23. package/src/core/loop-controller.ts +1 -1
  24. package/src/core/state-detector.ts +1 -1
  25. package/src/core/target-manager.ts +1 -1
  26. package/src/index.ts +1 -1
  27. package/src/shared/files/index.ts +1 -1
  28. package/src/shared/processing/index.ts +1 -1
  29. package/src/targets/claude-code.ts +3 -3
  30. package/src/targets/opencode.ts +3 -3
  31. package/src/utils/agent-enhancer.ts +2 -2
  32. package/src/utils/{mcp-config.ts → config/mcp-config.ts} +4 -4
  33. package/src/utils/{paths.ts → config/paths.ts} +1 -1
  34. package/src/utils/{settings.ts → config/settings.ts} +1 -1
  35. package/src/utils/{target-config.ts → config/target-config.ts} +5 -5
  36. package/src/utils/{target-utils.ts → config/target-utils.ts} +3 -3
  37. package/src/utils/display/banner.ts +25 -0
  38. package/src/utils/display/status.ts +55 -0
  39. package/src/utils/{file-operations.ts → files/file-operations.ts} +2 -2
  40. package/src/utils/files/jsonc.ts +36 -0
  41. package/src/utils/{sync-utils.ts → files/sync-utils.ts} +3 -3
  42. package/src/utils/index.ts +42 -61
  43. package/src/utils/version.ts +47 -0
  44. package/src/components/benchmark-monitor.tsx +0 -331
  45. package/src/components/reindex-progress.tsx +0 -261
  46. package/src/composables/functional/index.ts +0 -14
  47. package/src/composables/functional/useEnvironment.ts +0 -171
  48. package/src/composables/functional/useFileSystem.ts +0 -139
  49. package/src/composables/index.ts +0 -4
  50. package/src/composables/useEnv.ts +0 -13
  51. package/src/composables/useRuntimeConfig.ts +0 -27
  52. package/src/core/ai-sdk.ts +0 -603
  53. package/src/core/app-factory.ts +0 -381
  54. package/src/core/builtin-agents.ts +0 -9
  55. package/src/core/command-system.ts +0 -550
  56. package/src/core/config-system.ts +0 -550
  57. package/src/core/connection-pool.ts +0 -390
  58. package/src/core/di-container.ts +0 -155
  59. package/src/core/headless-display.ts +0 -96
  60. package/src/core/interfaces/index.ts +0 -22
  61. package/src/core/interfaces/repository.interface.ts +0 -91
  62. package/src/core/interfaces/service.interface.ts +0 -133
  63. package/src/core/interfaces.ts +0 -96
  64. package/src/core/result.ts +0 -351
  65. package/src/core/service-config.ts +0 -252
  66. package/src/core/session-service.ts +0 -121
  67. package/src/core/storage-factory.ts +0 -115
  68. package/src/core/stream-handler.ts +0 -288
  69. package/src/core/type-utils.ts +0 -427
  70. package/src/core/unified-storage.ts +0 -456
  71. package/src/core/validation/limit.ts +0 -46
  72. package/src/core/validation/query.ts +0 -20
  73. package/src/db/auto-migrate.ts +0 -322
  74. package/src/db/base-database-client.ts +0 -144
  75. package/src/db/cache-db.ts +0 -218
  76. package/src/db/cache-schema.ts +0 -75
  77. package/src/db/database.ts +0 -70
  78. package/src/db/index.ts +0 -252
  79. package/src/db/memory-db.ts +0 -153
  80. package/src/db/memory-schema.ts +0 -29
  81. package/src/db/schema.ts +0 -289
  82. package/src/db/session-repository.ts +0 -733
  83. package/src/domains/index.ts +0 -6
  84. package/src/domains/utilities/index.ts +0 -6
  85. package/src/domains/utilities/time/index.ts +0 -5
  86. package/src/domains/utilities/time/tools.ts +0 -291
  87. package/src/services/agent-service.ts +0 -273
  88. package/src/services/evaluation-service.ts +0 -271
  89. package/src/services/functional/evaluation-logic.ts +0 -296
  90. package/src/services/functional/file-processor.ts +0 -273
  91. package/src/services/functional/index.ts +0 -12
  92. package/src/services/memory.service.ts +0 -476
  93. package/src/types/api/batch.ts +0 -108
  94. package/src/types/api/errors.ts +0 -118
  95. package/src/types/api/index.ts +0 -55
  96. package/src/types/api/requests.ts +0 -76
  97. package/src/types/api/responses.ts +0 -180
  98. package/src/types/api/websockets.ts +0 -85
  99. package/src/types/benchmark.ts +0 -49
  100. package/src/types/database.types.ts +0 -510
  101. package/src/types/memory-types.ts +0 -63
  102. package/src/utils/advanced-tokenizer.ts +0 -191
  103. package/src/utils/ai-model-fetcher.ts +0 -19
  104. package/src/utils/async-file-operations.ts +0 -516
  105. package/src/utils/audio-player.ts +0 -345
  106. package/src/utils/codebase-helpers.ts +0 -211
  107. package/src/utils/console-ui.ts +0 -79
  108. package/src/utils/database-errors.ts +0 -140
  109. package/src/utils/debug-logger.ts +0 -49
  110. package/src/utils/file-scanner.ts +0 -259
  111. package/src/utils/help.ts +0 -20
  112. package/src/utils/immutable-cache.ts +0 -106
  113. package/src/utils/jsonc.ts +0 -158
  114. package/src/utils/memory-tui.ts +0 -414
  115. package/src/utils/models-dev.ts +0 -91
  116. package/src/utils/parallel-operations.ts +0 -487
  117. package/src/utils/process-manager.ts +0 -155
  118. package/src/utils/prompts.ts +0 -120
  119. package/src/utils/search-tool-builder.ts +0 -214
  120. package/src/utils/session-manager.ts +0 -168
  121. package/src/utils/session-title.ts +0 -87
  122. package/src/utils/simplified-errors.ts +0 -410
  123. package/src/utils/template-engine.ts +0 -94
  124. package/src/utils/test-audio.ts +0 -71
  125. package/src/utils/todo-context.ts +0 -46
  126. package/src/utils/token-counter.ts +0 -288
  127. /package/src/utils/{cli-output.ts → display/cli-output.ts} +0 -0
  128. /package/src/utils/{logger.ts → display/logger.ts} +0 -0
  129. /package/src/utils/{notifications.ts → display/notifications.ts} +0 -0
  130. /package/src/utils/{secret-utils.ts → security/secret-utils.ts} +0 -0
  131. /package/src/utils/{security.ts → security/security.ts} +0 -0
@@ -1,381 +0,0 @@
1
- /**
2
- * Application Factory - 應用工廠
3
- * Feature-first, composable, functional architecture
4
- */
5
-
6
- import type { CommandOptions } from '../types/cli.types.js';
7
- import { setupGlobalErrorHandlers } from './error-handling.js';
8
- import { logger } from '../utils/logger.js';
9
-
10
- /**
11
- * Application interface
12
- */
13
- export interface Application {
14
- name: string;
15
- version: string;
16
- start(options?: CommandOptions): Promise<void>;
17
- stop(): Promise<void>;
18
- isRunning(): boolean;
19
- }
20
-
21
- /**
22
- * Application configuration
23
- */
24
- export interface AppConfig {
25
- name: string;
26
- version: string;
27
- description?: string;
28
- commands?: Map<string, CommandHandler>;
29
- middleware?: Middleware[];
30
- plugins?: Plugin[];
31
- }
32
-
33
- /**
34
- * Command handler
35
- */
36
- export type CommandHandler = (options: CommandOptions) => Promise<void>;
37
-
38
- /**
39
- * Middleware interface
40
- */
41
- export interface Middleware {
42
- name: string;
43
- before?: (options: CommandOptions) => Promise<void>;
44
- after?: (result: unknown, options: CommandOptions) => Promise<void>;
45
- onError?: (error: Error, options: CommandOptions) => Promise<void>;
46
- }
47
-
48
- /**
49
- * Plugin interface
50
- */
51
- export interface Plugin {
52
- name: string;
53
- version: string;
54
- install(app: Application): Promise<void>;
55
- uninstall?(app: Application): Promise<void>;
56
- }
57
-
58
- /**
59
- * Base application implementation
60
- */
61
- export class BaseApplication implements Application {
62
- public readonly name: string;
63
- public readonly version: string;
64
- private running = false;
65
- private commands = new Map<string, CommandHandler>();
66
- private middleware: Middleware[] = [];
67
- private plugins = new Set<Plugin>();
68
-
69
- constructor(config: AppConfig) {
70
- this.name = config.name;
71
- this.version = config.version;
72
-
73
- // Setup global error handling
74
- setupGlobalErrorHandlers();
75
-
76
- // Register commands
77
- if (config.commands) {
78
- for (const [name, handler] of config.commands) {
79
- this.commands.set(name, handler);
80
- }
81
- }
82
-
83
- // Register middleware
84
- if (config.middleware) {
85
- this.middleware.push(...config.middleware);
86
- }
87
-
88
- // Install plugins
89
- if (config.plugins) {
90
- for (const plugin of config.plugins) {
91
- void this.installPlugin(plugin);
92
- }
93
- }
94
-
95
- logger.info('Application initialized', {
96
- name: this.name,
97
- version: this.version,
98
- commands: this.commands.size,
99
- middleware: this.middleware.length,
100
- plugins: config.plugins?.length || 0,
101
- });
102
- }
103
-
104
- async start(options?: CommandOptions): Promise<void> {
105
- if (this.running) {
106
- logger.warn('Application is already running');
107
- return;
108
- }
109
-
110
- logger.info('Starting application', { options });
111
-
112
- try {
113
- // Execute before middleware
114
- for (const middleware of this.middleware) {
115
- if (middleware.before && options) {
116
- await middleware.before(options);
117
- }
118
- }
119
-
120
- // Execute command if specified
121
- if (options?.command && this.commands.has(options.command)) {
122
- const handler = this.commands.get(options.command)!;
123
- await handler(options);
124
- }
125
-
126
- this.running = true;
127
- logger.info('Application started successfully');
128
-
129
- } catch (error) {
130
- // Execute error middleware
131
- for (const middleware of this.middleware) {
132
- if (middleware.onError && options) {
133
- await middleware.onError(error instanceof Error ? error : new Error(String(error)), options);
134
- }
135
- }
136
- throw error;
137
- }
138
- }
139
-
140
- async stop(): Promise<void> {
141
- if (!this.running) {
142
- logger.warn('Application is not running');
143
- return;
144
- }
145
-
146
- logger.info('Stopping application');
147
-
148
- // Uninstall plugins
149
- for (const plugin of this.plugins) {
150
- if (plugin.uninstall) {
151
- await plugin.uninstall(this);
152
- }
153
- }
154
-
155
- this.running = false;
156
- logger.info('Application stopped');
157
- }
158
-
159
- isRunning(): boolean {
160
- return this.running;
161
- }
162
-
163
- registerCommand(name: string, handler: CommandHandler): void {
164
- this.commands.set(name, handler);
165
- logger.debug('Command registered', { name });
166
- }
167
-
168
- unregisterCommand(name: string): boolean {
169
- const result = this.commands.delete(name);
170
- if (result) {
171
- logger.debug('Command unregistered', { name });
172
- }
173
- return result;
174
- }
175
-
176
- addMiddleware(middleware: Middleware): void {
177
- this.middleware.push(middleware);
178
- logger.debug('Middleware added', { name: middleware.name });
179
- }
180
-
181
- removeMiddleware(name: string): boolean {
182
- const index = this.middleware.findIndex(m => m.name === name);
183
- if (index > -1) {
184
- this.middleware.splice(index, 1);
185
- logger.debug('Middleware removed', { name });
186
- return true;
187
- }
188
- return false;
189
- }
190
-
191
- async installPlugin(plugin: Plugin): Promise<void> {
192
- if (this.plugins.has(plugin)) {
193
- logger.warn('Plugin already installed', { name: plugin.name });
194
- return;
195
- }
196
-
197
- await plugin.install(this);
198
- this.plugins.add(plugin);
199
- logger.info('Plugin installed', { name: plugin.name, version: plugin.version });
200
- }
201
-
202
- async uninstallPlugin(plugin: Plugin): Promise<void> {
203
- if (!this.plugins.has(plugin)) {
204
- logger.warn('Plugin not installed', { name: plugin.name });
205
- return;
206
- }
207
-
208
- if (plugin.uninstall) {
209
- await plugin.uninstall(this);
210
- }
211
- this.plugins.delete(plugin);
212
- logger.info('Plugin uninstalled', { name: plugin.name });
213
- }
214
-
215
- getCommands(): string[] {
216
- return Array.from(this.commands.keys());
217
- }
218
-
219
- getMiddleware(): string[] {
220
- return this.middleware.map(m => m.name);
221
- }
222
-
223
- getPlugins(): Array<{ name: string; version: string }> {
224
- return Array.from(this.plugins).map(p => ({ name: p.name, version: p.version }));
225
- }
226
- }
227
-
228
- /**
229
- * Built-in middleware - moved before factory to fix hoisting
230
- */
231
-
232
- const loggingMiddleware: Middleware = {
233
- name: 'logging',
234
- before: async (options: CommandOptions) => {
235
- logger.debug('Executing command', { command: options.command, options });
236
- },
237
- after: async (result, options: CommandOptions) => {
238
- logger.debug('Command completed', { command: options.command, result });
239
- },
240
- onError: async (error, options: CommandOptions) => {
241
- logger.error('Command failed', { command: options.command, error: error.message });
242
- },
243
- };
244
-
245
- const validationMiddleware: Middleware = {
246
- name: 'validation',
247
- before: async (options: CommandOptions) => {
248
- // Basic validation
249
- if (options.command && typeof options.command !== 'string') {
250
- throw new Error('Command must be a string');
251
- }
252
-
253
- if (options.concurrency && (typeof options.concurrency !== 'number' || options.concurrency < 1)) {
254
- throw new Error('Concurrency must be a positive number');
255
- }
256
-
257
- if (options.delay && (typeof options.delay !== 'number' || options.delay < 0)) {
258
- throw new Error('Delay must be a non-negative number');
259
- }
260
- },
261
- };
262
-
263
- const corsMiddleware: Middleware = {
264
- name: 'cors',
265
- before: async (options: CommandOptions) => {
266
- // CORS headers would be set here for web applications
267
- logger.debug('CORS middleware applied');
268
- },
269
- };
270
-
271
- /**
272
- * Application factory
273
- */
274
- export class ApplicationFactory {
275
- private static defaultConfig: Partial<AppConfig> = {
276
- middleware: [
277
- loggingMiddleware,
278
- validationMiddleware,
279
- ],
280
- };
281
-
282
- static create(config: AppConfig): Application {
283
- const finalConfig = {
284
- ...this.defaultConfig,
285
- ...config,
286
- };
287
-
288
- return new BaseApplication(finalConfig);
289
- }
290
-
291
- static createCLIApp(config: Omit<AppConfig, 'name' | 'version'> & {
292
- name: string;
293
- version: string;
294
- }): Application {
295
- return this.create({
296
- ...config,
297
- commands: config.commands || new Map(),
298
- });
299
- }
300
-
301
- static createWebApp(config: Omit<AppConfig, 'name' | 'version'> & {
302
- name: string;
303
- version: string;
304
- }): Application {
305
- return this.create({
306
- ...config,
307
- middleware: [
308
- loggingMiddleware,
309
- validationMiddleware,
310
- corsMiddleware,
311
- ],
312
- ...config,
313
- });
314
- }
315
- }
316
-
317
- /**
318
- * Common plugins
319
- */
320
-
321
- export const LoggingPlugin: Plugin = {
322
- name: 'logging',
323
- version: '1.0.0',
324
- async install(app: Application): Promise<void> {
325
- logger.info('Logging plugin installed');
326
- // Additional logging setup could go here
327
- },
328
- };
329
-
330
- export const StoragePlugin: Plugin = {
331
- name: 'storage',
332
- version: '1.0.0',
333
- async install(app: Application): Promise<void> {
334
- // Initialize storage systems
335
- logger.info('Storage plugin installed');
336
- },
337
- };
338
-
339
- export const CachePlugin: Plugin = {
340
- name: 'cache',
341
- version: '1.0.0',
342
- async install(app: Application): Promise<void> {
343
- // Initialize cache systems
344
- logger.info('Cache plugin installed');
345
- },
346
- };
347
-
348
- /**
349
- * Utility functions
350
- */
351
-
352
- export const CommandUtils = {
353
- registerCommands(app: Application, commands: Record<string, CommandHandler>): void {
354
- for (const [name, handler] of Object.entries(commands)) {
355
- app.registerCommand(name, handler);
356
- }
357
- },
358
-
359
- createCommandHandler(
360
- handler: (options: CommandOptions) => Promise<void>,
361
- options?: {
362
- name?: string;
363
- description?: string;
364
- validate?: (options: CommandOptions) => boolean;
365
- transform?: (options: CommandOptions) => CommandOptions;
366
- }
367
- ): CommandHandler {
368
- return async (opts: CommandOptions): Promise<void> => {
369
- // Validate
370
- if (options?.validate && !options.validate(opts)) {
371
- throw new Error(`Validation failed for command: ${options.name || 'unknown'}`);
372
- }
373
-
374
- // Transform
375
- const finalOpts = options?.transform ? options.transform(opts) : opts;
376
-
377
- // Execute
378
- await handler(finalOpts);
379
- };
380
- },
381
- } as const;
@@ -1,9 +0,0 @@
1
- /**
2
- * Agent Constants
3
- * Default agent ID for fallback purposes
4
- */
5
-
6
- /**
7
- * Default agent ID (must match an agent in assets/agents/)
8
- */
9
- export const DEFAULT_AGENT_ID = 'coder';