@ismaelsoilet/synapsejs 1.8.0 → 1.11.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 (55) hide show
  1. package/README.md +98 -6
  2. package/bin/synapse.ts +291 -241
  3. package/package.json +2 -2
  4. package/src/client/components.tsx +459 -1
  5. package/src/client/context.tsx +23 -3
  6. package/src/client/error-boundary.tsx +59 -0
  7. package/src/client/hooks.ts +100 -1
  8. package/src/client/toast.tsx +219 -0
  9. package/src/client/upload.ts +153 -0
  10. package/src/client.ts +37 -2
  11. package/src/compiler/client-bundler.ts +94 -2
  12. package/src/compiler/context-bench.ts +9 -1
  13. package/src/compiler/contract.ts +31 -4
  14. package/src/compiler/db-schema-generator.ts +39 -8
  15. package/src/compiler/fields-parser.ts +28 -1
  16. package/src/compiler/impact-analyzer.ts +31 -1
  17. package/src/compiler/migration-runner.ts +10 -2
  18. package/src/compiler/optional-coverage.ts +137 -0
  19. package/src/compiler/oracle-runner.ts +18 -4
  20. package/src/compiler/scaffolder.ts +227 -9
  21. package/src/compiler/slice-discovery.ts +8 -1
  22. package/src/compiler/slice-splitter.ts +68 -6
  23. package/src/compiler/slice-templates.ts +234 -10
  24. package/src/compiler/typescript-api.ts +33 -0
  25. package/src/core/action-context.ts +101 -15
  26. package/src/core/config.ts +88 -10
  27. package/src/core/cron-parser.ts +167 -0
  28. package/src/core/database-client.ts +103 -6
  29. package/src/core/index.ts +5 -0
  30. package/src/core/jobs.ts +37 -0
  31. package/src/core/oauth-client.ts +322 -0
  32. package/src/core/path-guard.ts +105 -0
  33. package/src/core/postgres-client.ts +37 -0
  34. package/src/core/postgres-queue.ts +76 -9
  35. package/src/core/query-builder.ts +166 -34
  36. package/src/core/session-context.ts +45 -4
  37. package/src/core/session-token.ts +124 -8
  38. package/src/core/sqlite-client.ts +20 -0
  39. package/src/core/storage.ts +60 -19
  40. package/src/core/topics.ts +84 -0
  41. package/src/core/webhook-signature.ts +151 -0
  42. package/src/index.ts +2 -1
  43. package/src/mcp/server.ts +317 -218
  44. package/src/mcp/tools.ts +329 -0
  45. package/src/project-status.ts +433 -0
  46. package/src/runtime/client-entry.ts +11 -5
  47. package/src/runtime/network-guard.ts +3 -1
  48. package/src/runtime/queue-engine.ts +167 -5
  49. package/src/runtime/rate-limiter.ts +14 -4
  50. package/src/runtime/security-headers.ts +35 -0
  51. package/src/runtime/server.ts +1174 -236
  52. package/src/runtime/uploads.ts +199 -19
  53. package/src/version.ts +9 -2
  54. package/templates/starter/package.json +2 -2
  55. package/templates/starter/tsconfig.json +1 -0
@@ -0,0 +1,329 @@
1
+ /**
2
+ * SynapseJS - Model Context Protocol Tool Inventory
3
+ *
4
+ * The declarative list of tools the MCP server registers: names, descriptions and
5
+ * input schemas, with no runtime dependency. Keeping it here means the count the
6
+ * documentation quotes is derived from the registered list rather than maintained by
7
+ * hand, and `synapse info` can report it without loading the JSON-RPC server.
8
+ */
9
+
10
+ import { PATH_SEGMENT_PATTERN } from '../core/path-guard';
11
+
12
+ export interface McpToolDefinition {
13
+ name: string;
14
+ description: string;
15
+ inputSchema: Record<string, unknown>;
16
+ }
17
+
18
+ export const MCP_TOOLS: McpToolDefinition[] = [
19
+ {
20
+ name: 'synapse_get_repo_map',
21
+ description: 'Get compressed codebase skeleton map (.codebase/repo-map.d.ts) for AI context (<3000 tokens)',
22
+ inputSchema: { type: 'object', properties: {} }
23
+ },
24
+ {
25
+ name: 'synapse_get_db_schema',
26
+ description:
27
+ 'Get the centralized database schema catalog (.codebase/db-schema.d.ts) for AI context and type-safe relational queries',
28
+ inputSchema: { type: 'object', properties: {} }
29
+ },
30
+ {
31
+ name: 'synapse_check',
32
+ description:
33
+ 'Run machine-centric compiler diagnostics, returning exact JSON coordinates (file, line, col, message)',
34
+ inputSchema: {
35
+ type: 'object',
36
+ properties: {
37
+ targetFile: { type: 'string', description: 'Optional specific file to check' }
38
+ }
39
+ }
40
+ },
41
+ {
42
+ name: 'synapse_split',
43
+ description: 'Run slice splitter and leak verification gates to enforce server/client isolation and zero leakage',
44
+ inputSchema: {
45
+ type: 'object',
46
+ properties: {
47
+ targetSlice: { type: 'string', description: 'Optional specific slice name to split' }
48
+ }
49
+ }
50
+ },
51
+ {
52
+ name: 'synapse_run_pbt',
53
+ description: 'Execute Fast-Check Property-Based Testing (PBT) invariant test suite across all slices',
54
+ inputSchema: { type: 'object', properties: {} }
55
+ },
56
+ {
57
+ name: 'synapse_scaffold_slice',
58
+ description:
59
+ 'Scaffold a new fullstack atomic vertical slice with TypeBox, Result, Action, React UI, and PBT oracles',
60
+ inputSchema: {
61
+ type: 'object',
62
+ required: ['domain', 'name'],
63
+ properties: {
64
+ domain: {
65
+ type: 'string',
66
+ pattern: PATH_SEGMENT_PATTERN,
67
+ description: 'Domain name (e.g. billing, customers, orders)'
68
+ },
69
+ name: {
70
+ type: 'string',
71
+ pattern: PATH_SEGMENT_PATTERN,
72
+ description: 'Slice name in kebab-case (e.g. cancel-subscription)'
73
+ },
74
+ template: {
75
+ type: 'string',
76
+ enum: ['create', 'list', 'update', 'delete', 'login', 'oauth-github', 'crud', 'modal-crud'],
77
+ description: 'Optional slice template shape (default: create)'
78
+ },
79
+ fields: {
80
+ type: 'string',
81
+ description:
82
+ 'Optional fields grammar, e.g. "name:string,email:string,status:enum(ACTIVE|INACTIVE),price:number"'
83
+ }
84
+ }
85
+ }
86
+ },
87
+ {
88
+ name: 'synapse_scaffold_domain',
89
+ description:
90
+ 'Scaffold an entire modular domain directory with domain layout (_layout.tsx), initial list slice, and shared module (src/shared/<domain>.ts)',
91
+ inputSchema: {
92
+ type: 'object',
93
+ required: ['domain'],
94
+ properties: {
95
+ domain: {
96
+ type: 'string',
97
+ pattern: PATH_SEGMENT_PATTERN,
98
+ description: 'Domain name (e.g. billing, customers, orders)'
99
+ },
100
+ fields: {
101
+ type: 'string',
102
+ description:
103
+ 'Optional initial fields grammar, e.g. "name:string,email:string,status:enum(ACTIVE|INACTIVE),price:number"'
104
+ }
105
+ }
106
+ }
107
+ },
108
+ {
109
+ name: 'synapse_contract',
110
+ description:
111
+ 'Return the machine contract: slice exports and suffixes, Result and HTTP semantics, session rules, addressing, SSR behavior and the gates to run',
112
+ inputSchema: { type: 'object', properties: {} }
113
+ },
114
+ {
115
+ name: 'synapse_migrate',
116
+ description: 'Auto-discover and apply sliceSchema DDL declarations across slices into the active database',
117
+ inputSchema: { type: 'object', properties: {} }
118
+ },
119
+ {
120
+ name: 'synapse_check_db_drift',
121
+ description:
122
+ 'Inspects live database catalog against sliceSchema DDL contracts, identifying missing tables, missing columns, and orphan tables',
123
+ inputSchema: { type: 'object', properties: {} }
124
+ },
125
+ {
126
+ name: 'synapse_diff_impact',
127
+ description:
128
+ 'Analyzes cross-slice dependencies (Foreign Keys, shared module imports, and table references) to report all slices impacted by a file or table change',
129
+ inputSchema: {
130
+ type: 'object',
131
+ required: ['target'],
132
+ properties: {
133
+ target: {
134
+ type: 'string',
135
+ description: 'Slice file path, slice name, shared module path, or table name'
136
+ }
137
+ }
138
+ }
139
+ },
140
+ {
141
+ name: 'synapse_rollback',
142
+ description: 'Roll back applied sliceSchema migrations by executing their -- down: statements',
143
+ inputSchema: {
144
+ type: 'object',
145
+ properties: {
146
+ targetSlice: { type: 'string', description: 'Optional target slice to rollback' },
147
+ steps: { type: 'number', description: 'Number of recent migrations to rollback (default: 1)' }
148
+ }
149
+ }
150
+ },
151
+ {
152
+ name: 'synapse_test_gate',
153
+ description:
154
+ 'Execute Fast-Check PBT oracles and immediately triage failures with Jev System One semantic test-gate to prevent LLM token waste',
155
+ inputSchema: {
156
+ type: 'object',
157
+ properties: {}
158
+ }
159
+ },
160
+ {
161
+ name: 'synapse_abort_check',
162
+ description:
163
+ 'Evaluate plan and error history with Jev System One to detect doomed trajectories, circular loops, or high-risk refactor dead ends',
164
+ inputSchema: {
165
+ type: 'object',
166
+ required: ['plan', 'history'],
167
+ properties: {
168
+ plan: { type: 'string', description: 'Proposed implementation plan or architectural change' },
169
+ history: { type: 'string', description: 'Recent attempt history, error logs, or failure reasons' }
170
+ }
171
+ }
172
+ },
173
+ {
174
+ name: 'synapse_verify_completion',
175
+ description:
176
+ 'Verify slice implementation and test outputs against acceptance criteria using Jev System One before committing work',
177
+ inputSchema: {
178
+ type: 'object',
179
+ required: ['criteria', 'output'],
180
+ properties: {
181
+ criteria: { type: 'string', description: 'Acceptance criteria or requirement specifications' },
182
+ output: {
183
+ type: 'string',
184
+ description: 'Actual implementation summary, test output, or slice behavior'
185
+ }
186
+ }
187
+ }
188
+ },
189
+ {
190
+ name: 'synapse_reasoning_effort',
191
+ description:
192
+ 'Dynamically modulate agent reasoning effort (Astra-Jev) to low/medium/high based on step context (lowering effort for mechanical commands like split/migrate/skeleton)',
193
+ inputSchema: {
194
+ type: 'object',
195
+ required: ['context'],
196
+ properties: {
197
+ context: {
198
+ type: 'string',
199
+ description: 'Immediate command or task context, e.g. "synapse split", "git commit"'
200
+ },
201
+ provider: {
202
+ type: 'string',
203
+ description: 'Target LLM provider, e.g. "deepseek", "anthropic", "openai"'
204
+ },
205
+ sessionContextTokens: {
206
+ type: 'number',
207
+ description: 'Estimated session context token count to protect prompt cache'
208
+ }
209
+ }
210
+ }
211
+ },
212
+ {
213
+ name: 'synapse_triage_error',
214
+ description:
215
+ 'Triage an arbitrary test failure or execution error log using Jev System One to classify root causes (env_missing vs flaky_transient vs deep_logic) and avoid token waste',
216
+ inputSchema: {
217
+ type: 'object',
218
+ required: ['failureLog'],
219
+ properties: {
220
+ failureLog: {
221
+ type: 'string',
222
+ description: 'Error log, stack trace or terminal output to triage'
223
+ }
224
+ }
225
+ }
226
+ },
227
+ {
228
+ name: 'synapse_route_task',
229
+ description: 'Semantically route a development task to the optimal model/reasoning tier via Jev System One',
230
+ inputSchema: {
231
+ type: 'object',
232
+ required: ['task'],
233
+ properties: {
234
+ task: {
235
+ type: 'string',
236
+ description: 'Description of the coding, refactoring, or diagnostic task'
237
+ }
238
+ }
239
+ }
240
+ },
241
+ {
242
+ name: 'synapse_evaluate_nudge',
243
+ description:
244
+ 'Evaluate whether an agent is prematurely stopping or needs a proactive nudge to continue verification',
245
+ inputSchema: {
246
+ type: 'object',
247
+ required: ['transcriptTail'],
248
+ properties: {
249
+ transcriptTail: {
250
+ type: 'string',
251
+ description: 'Recent transcript steps or conversation history tail'
252
+ }
253
+ }
254
+ }
255
+ },
256
+ {
257
+ name: 'synapse_inspect_routes',
258
+ description:
259
+ 'Inspect all active slice routes, dynamic path parameters, HTTP verbs, caching policies, and registered RPC endpoints as structured JSON for AI context',
260
+ inputSchema: {
261
+ type: 'object',
262
+ properties: {}
263
+ }
264
+ },
265
+ {
266
+ name: 'synapse_test_slice',
267
+ description:
268
+ 'Execute Fast-Check Property-Based Testing (PBT) invariant test suite for one specific targeted slice without running the entire codebase',
269
+ inputSchema: {
270
+ type: 'object',
271
+ required: ['targetSlice'],
272
+ properties: {
273
+ targetSlice: {
274
+ type: 'string',
275
+ description:
276
+ 'Name or key of the slice to run oracles for (e.g. overview, create-item, or inventory/create-item)'
277
+ }
278
+ }
279
+ }
280
+ },
281
+ {
282
+ name: 'synapse_generate_seed',
283
+ description:
284
+ 'Synthesize realistic, valid TypeBox-compliant database seed records using Fast-Check arbitraries directly into the live SQLite/PostgreSQL database',
285
+ inputSchema: {
286
+ type: 'object',
287
+ required: ['targetSlice'],
288
+ properties: {
289
+ targetSlice: {
290
+ type: 'string',
291
+ description: 'Name or key of the slice whose table to seed (e.g. create-item or inventory/create-item)'
292
+ },
293
+ count: {
294
+ type: 'number',
295
+ description: 'Number of seed records to synthesize and insert (default: 5)'
296
+ }
297
+ }
298
+ }
299
+ },
300
+ {
301
+ name: 'synapse_scaffold_component',
302
+ description:
303
+ 'Scaffold interactive client sub-components (with Modal, Drawer, Tabs or Dropdown) ready to be embedded or transcluded via SubSlice',
304
+ inputSchema: {
305
+ type: 'object',
306
+ required: ['domain', 'name', 'componentType'],
307
+ properties: {
308
+ domain: {
309
+ type: 'string',
310
+ pattern: PATH_SEGMENT_PATTERN,
311
+ description: 'Domain name (e.g. billing, inventory, settings)'
312
+ },
313
+ name: {
314
+ type: 'string',
315
+ pattern: PATH_SEGMENT_PATTERN,
316
+ description: 'Component name in kebab-case (e.g. item-details-modal)'
317
+ },
318
+ componentType: {
319
+ type: 'string',
320
+ enum: ['modal', 'drawer', 'tabs', 'dropdown'],
321
+ description: 'Interactive primitive type to scaffold'
322
+ }
323
+ }
324
+ }
325
+ }
326
+ ];
327
+
328
+ /** The registered tool names, in registration order. */
329
+ export const MCP_TOOL_NAMES: string[] = MCP_TOOLS.map((tool) => tool.name);