@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
package/src/db/schema.ts DELETED
@@ -1,289 +0,0 @@
1
- /**
2
- * Drizzle ORM schema for Sylphx Flow
3
- * Type-safe database schema with migrations support
4
- */
5
-
6
- import { index, integer, primaryKey, real, sqliteTable, text } from 'drizzle-orm/sqlite-core';
7
-
8
- // Memory table for persistent storage
9
- export const memory = sqliteTable(
10
- 'memory',
11
- {
12
- key: text('key').notNull(),
13
- namespace: text('namespace').notNull().default('default'),
14
- value: text('value').notNull(),
15
- timestamp: integer('timestamp').notNull(),
16
- created_at: text('created_at').notNull(),
17
- updated_at: text('updated_at').notNull(),
18
- },
19
- (table) => ({
20
- pk: primaryKey({ columns: [table.key, table.namespace] }),
21
- namespaceIdx: index('idx_memory_namespace').on(table.namespace),
22
- timestampIdx: index('idx_memory_timestamp').on(table.timestamp),
23
- keyIdx: index('idx_memory_key').on(table.key),
24
- })
25
- );
26
-
27
- // Codebase files table
28
- export const codebaseFiles = sqliteTable(
29
- 'codebase_files',
30
- {
31
- path: text('path').primaryKey(),
32
- mtime: integer('mtime').notNull(),
33
- hash: text('hash').notNull(),
34
- content: text('content'), // Optional full content
35
- language: text('language'), // Detected programming language
36
- size: integer('size'), // File size in bytes
37
- indexedAt: text('indexed_at').notNull(),
38
- },
39
- (table) => ({
40
- mtimeIdx: index('idx_codebase_files_mtime').on(table.mtime),
41
- hashIdx: index('idx_codebase_files_hash').on(table.hash),
42
- })
43
- );
44
-
45
- // TF-IDF terms table
46
- export const tfidfTerms = sqliteTable(
47
- 'tfidf_terms',
48
- {
49
- filePath: text('file_path')
50
- .notNull()
51
- .references(() => codebaseFiles.path, { onDelete: 'cascade' }),
52
- term: text('term').notNull(),
53
- frequency: real('frequency').notNull(),
54
- },
55
- (table) => ({
56
- termIdx: index('idx_tfidf_terms_term').on(table.term),
57
- fileIdx: index('idx_tfidf_terms_file').on(table.filePath),
58
- })
59
- );
60
-
61
- // TF-IDF documents table (document vectors)
62
- export const tfidfDocuments = sqliteTable('tfidf_documents', {
63
- filePath: text('file_path')
64
- .primaryKey()
65
- .references(() => codebaseFiles.path, { onDelete: 'cascade' }),
66
- magnitude: real('magnitude').notNull(),
67
- termCount: integer('term_count').notNull(),
68
- rawTerms: text('raw_terms').notNull(), // JSON string of Record<string, number>
69
- });
70
-
71
- // IDF values table
72
- export const tfidfIdf = sqliteTable('tfidf_idf', {
73
- term: text('term').primaryKey(),
74
- idfValue: real('idf_value').notNull(),
75
- });
76
-
77
- // Codebase metadata table
78
- export const codebaseMetadata = sqliteTable('codebase_metadata', {
79
- key: text('key').primaryKey(),
80
- value: text('value').notNull(),
81
- });
82
-
83
- // Export types for TypeScript
84
- export type Memory = typeof memory.$inferSelect;
85
- export type NewMemory = typeof memory.$inferInsert;
86
-
87
- export type CodebaseFile = typeof codebaseFiles.$inferSelect;
88
- export type NewCodebaseFile = typeof codebaseFiles.$inferInsert;
89
-
90
- export type TfidfTerm = typeof tfidfTerms.$inferSelect;
91
- export type NewTfidfTerm = typeof tfidfTerms.$inferInsert;
92
-
93
- export type TfidfDocument = typeof tfidfDocuments.$inferSelect;
94
- export type NewTfidfDocument = typeof tfidfDocuments.$inferInsert;
95
-
96
- export type TfidfIdf = typeof tfidfIdf.$inferSelect;
97
- export type NewTfidfIdf = typeof tfidfIdf.$inferInsert;
98
-
99
- export type CodebaseMetadata = typeof codebaseMetadata.$inferSelect;
100
- export type NewCodebaseMetadata = typeof codebaseMetadata.$inferInsert;
101
-
102
- // ============================================
103
- // Session Management Tables
104
- // ============================================
105
-
106
- /**
107
- * Sessions table - Main chat sessions
108
- * Stores session metadata and configuration
109
- */
110
- export const sessions = sqliteTable(
111
- 'sessions',
112
- {
113
- id: text('id').primaryKey(),
114
- title: text('title'),
115
- provider: text('provider').notNull(), // 'anthropic' | 'openai' | 'google' | 'openrouter'
116
- model: text('model').notNull(),
117
- nextTodoId: integer('next_todo_id').notNull().default(1),
118
-
119
- // Note: Streaming state moved to messages table (message-level, not session-level)
120
- // Each message can be in streaming state with isStreaming flag
121
-
122
- created: integer('created').notNull(), // Unix timestamp (ms)
123
- updated: integer('updated').notNull(), // Unix timestamp (ms)
124
- },
125
- (table) => ({
126
- updatedIdx: index('idx_sessions_updated').on(table.updated),
127
- createdIdx: index('idx_sessions_created').on(table.created),
128
- providerIdx: index('idx_sessions_provider').on(table.provider),
129
- titleIdx: index('idx_sessions_title').on(table.title),
130
- })
131
- );
132
-
133
- /**
134
- * Messages table - Chat messages in sessions
135
- * Stores message metadata and role
136
- */
137
- export const messages = sqliteTable(
138
- 'messages',
139
- {
140
- id: text('id').primaryKey(),
141
- sessionId: text('session_id')
142
- .notNull()
143
- .references(() => sessions.id, { onDelete: 'cascade' }),
144
- role: text('role').notNull(), // 'user' | 'assistant'
145
- timestamp: integer('timestamp').notNull(), // Unix timestamp (ms)
146
- ordering: integer('ordering').notNull(), // For display order
147
- finishReason: text('finish_reason'), // 'stop' | 'length' | 'tool-calls' | 'error'
148
- // Message status - unified state for all messages
149
- status: text('status').notNull().default('completed'), // 'active' | 'completed' | 'error' | 'abort'
150
- // Metadata stored as JSON: { cpu?: string, memory?: string }
151
- metadata: text('metadata'), // JSON string
152
- },
153
- (table) => ({
154
- sessionIdx: index('idx_messages_session').on(table.sessionId),
155
- orderingIdx: index('idx_messages_ordering').on(table.sessionId, table.ordering),
156
- timestampIdx: index('idx_messages_timestamp').on(table.timestamp),
157
- statusIdx: index('idx_messages_status').on(table.status),
158
- })
159
- );
160
-
161
- /**
162
- * Message parts table - Content parts of messages
163
- * Stores text, reasoning, tool calls, errors
164
- * Content structure varies by type, stored as JSON
165
- *
166
- * ALL parts have unified status field: 'active' | 'completed' | 'error' | 'abort'
167
- */
168
- export const messageParts = sqliteTable(
169
- 'message_parts',
170
- {
171
- id: text('id').primaryKey(),
172
- messageId: text('message_id')
173
- .notNull()
174
- .references(() => messages.id, { onDelete: 'cascade' }),
175
- ordering: integer('ordering').notNull(), // Order within message
176
- type: text('type').notNull(), // 'text' | 'reasoning' | 'tool' | 'error'
177
- // Content structure (JSON) - ALL parts include status field:
178
- // - text: { type: 'text', content: string, status: 'active' | 'completed' | ... }
179
- // - reasoning: { type: 'reasoning', content: string, status: ..., duration?: number }
180
- // - tool: { type: 'tool', name: string, status: ..., duration?: number, args?: any, result?: any, error?: string }
181
- // - error: { type: 'error', error: string, status: 'completed' }
182
- content: text('content').notNull(), // JSON string
183
- },
184
- (table) => ({
185
- messageIdx: index('idx_message_parts_message').on(table.messageId),
186
- orderingIdx: index('idx_message_parts_ordering').on(table.messageId, table.ordering),
187
- typeIdx: index('idx_message_parts_type').on(table.type),
188
- })
189
- );
190
-
191
- /**
192
- * Message attachments table - File attachments to messages
193
- */
194
- export const messageAttachments = sqliteTable(
195
- 'message_attachments',
196
- {
197
- id: text('id').primaryKey(),
198
- messageId: text('message_id')
199
- .notNull()
200
- .references(() => messages.id, { onDelete: 'cascade' }),
201
- path: text('path').notNull(),
202
- relativePath: text('relative_path').notNull(),
203
- size: integer('size'),
204
- },
205
- (table) => ({
206
- messageIdx: index('idx_message_attachments_message').on(table.messageId),
207
- pathIdx: index('idx_message_attachments_path').on(table.path),
208
- })
209
- );
210
-
211
- /**
212
- * Message usage table - Token usage for messages
213
- * 1:1 relationship with messages (only assistant messages have usage)
214
- */
215
- export const messageUsage = sqliteTable('message_usage', {
216
- messageId: text('message_id')
217
- .primaryKey()
218
- .references(() => messages.id, { onDelete: 'cascade' }),
219
- promptTokens: integer('prompt_tokens').notNull(),
220
- completionTokens: integer('completion_tokens').notNull(),
221
- totalTokens: integer('total_tokens').notNull(),
222
- });
223
-
224
- /**
225
- * Todos table - Per-session todo lists
226
- */
227
- export const todos = sqliteTable(
228
- 'todos',
229
- {
230
- id: integer('id').notNull(), // Per-session ID (not globally unique!)
231
- sessionId: text('session_id')
232
- .notNull()
233
- .references(() => sessions.id, { onDelete: 'cascade' }),
234
- content: text('content').notNull(),
235
- activeForm: text('active_form').notNull(),
236
- status: text('status').notNull(), // 'pending' | 'in_progress' | 'completed'
237
- ordering: integer('ordering').notNull(),
238
- },
239
- (table) => ({
240
- pk: primaryKey({ columns: [table.sessionId, table.id] }),
241
- sessionIdx: index('idx_todos_session').on(table.sessionId),
242
- statusIdx: index('idx_todos_status').on(table.status),
243
- orderingIdx: index('idx_todos_ordering').on(table.sessionId, table.ordering),
244
- })
245
- );
246
-
247
- /**
248
- * Message todo snapshots table - Snapshot of todos at message creation time
249
- * Enables rewind feature - can restore todo state at any point in conversation
250
- */
251
- export const messageTodoSnapshots = sqliteTable(
252
- 'message_todo_snapshots',
253
- {
254
- id: text('id').primaryKey(),
255
- messageId: text('message_id')
256
- .notNull()
257
- .references(() => messages.id, { onDelete: 'cascade' }),
258
- todoId: integer('todo_id').notNull(), // ID from snapshot (not FK!)
259
- content: text('content').notNull(),
260
- activeForm: text('active_form').notNull(),
261
- status: text('status').notNull(),
262
- ordering: integer('ordering').notNull(),
263
- },
264
- (table) => ({
265
- messageIdx: index('idx_message_todo_snapshots_message').on(table.messageId),
266
- })
267
- );
268
-
269
- // Export types for TypeScript
270
- export type Session = typeof sessions.$inferSelect;
271
- export type NewSession = typeof sessions.$inferInsert;
272
-
273
- export type Message = typeof messages.$inferSelect;
274
- export type NewMessage = typeof messages.$inferInsert;
275
-
276
- export type MessagePart = typeof messageParts.$inferSelect;
277
- export type NewMessagePart = typeof messageParts.$inferInsert;
278
-
279
- export type MessageAttachment = typeof messageAttachments.$inferSelect;
280
- export type NewMessageAttachment = typeof messageAttachments.$inferInsert;
281
-
282
- export type MessageUsage = typeof messageUsage.$inferSelect;
283
- export type NewMessageUsage = typeof messageUsage.$inferInsert;
284
-
285
- export type Todo = typeof todos.$inferSelect;
286
- export type NewTodo = typeof todos.$inferInsert;
287
-
288
- export type MessageTodoSnapshot = typeof messageTodoSnapshots.$inferSelect;
289
- export type NewMessageTodoSnapshot = typeof messageTodoSnapshots.$inferInsert;