@jaypie/mcp 0.3.4 → 0.4.0

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 (52) hide show
  1. package/dist/createMcpServer.d.ts +7 -1
  2. package/dist/index.js +22 -2088
  3. package/dist/index.js.map +1 -1
  4. package/dist/suite.js +1197 -7
  5. package/dist/suite.js.map +1 -1
  6. package/package.json +1 -2
  7. package/release-notes/fabric/0.1.3.md +25 -0
  8. package/release-notes/fabric/0.1.4.md +42 -0
  9. package/release-notes/mcp/0.4.0.md +27 -0
  10. package/release-notes/testkit/1.2.15.md +23 -0
  11. package/skills/fabric.md +30 -3
  12. package/dist/aws-B3dW_-bD.js +0 -1202
  13. package/dist/aws-B3dW_-bD.js.map +0 -1
  14. package/prompts/Branch_Management.md +0 -34
  15. package/prompts/Development_Process.md +0 -89
  16. package/prompts/Jaypie_Agent_Rules.md +0 -110
  17. package/prompts/Jaypie_Auth0_Express_Mongoose.md +0 -736
  18. package/prompts/Jaypie_Browser_and_Frontend_Web_Packages.md +0 -18
  19. package/prompts/Jaypie_CDK_Constructs_and_Patterns.md +0 -430
  20. package/prompts/Jaypie_CICD_with_GitHub_Actions.md +0 -371
  21. package/prompts/Jaypie_Commander_CLI_Package.md +0 -166
  22. package/prompts/Jaypie_Core_Errors_and_Logging.md +0 -39
  23. package/prompts/Jaypie_DynamoDB_Package.md +0 -774
  24. package/prompts/Jaypie_Eslint_NPM_Package.md +0 -78
  25. package/prompts/Jaypie_Express_Package.md +0 -630
  26. package/prompts/Jaypie_Fabric_Commander.md +0 -411
  27. package/prompts/Jaypie_Fabric_LLM.md +0 -312
  28. package/prompts/Jaypie_Fabric_Lambda.md +0 -308
  29. package/prompts/Jaypie_Fabric_MCP.md +0 -316
  30. package/prompts/Jaypie_Fabric_Package.md +0 -599
  31. package/prompts/Jaypie_Fabricator.md +0 -617
  32. package/prompts/Jaypie_Ideal_Project_Structure.md +0 -78
  33. package/prompts/Jaypie_Init_CICD_with_GitHub_Actions.md +0 -1186
  34. package/prompts/Jaypie_Init_Express_on_Lambda.md +0 -115
  35. package/prompts/Jaypie_Init_Jaypie_CDK_Package.md +0 -35
  36. package/prompts/Jaypie_Init_Lambda_Package.md +0 -505
  37. package/prompts/Jaypie_Init_Monorepo_Project.md +0 -44
  38. package/prompts/Jaypie_Init_Project_Subpackage.md +0 -65
  39. package/prompts/Jaypie_Legacy_Patterns.md +0 -15
  40. package/prompts/Jaypie_Llm_Calls.md +0 -449
  41. package/prompts/Jaypie_Llm_Tools.md +0 -155
  42. package/prompts/Jaypie_MCP_Package.md +0 -281
  43. package/prompts/Jaypie_Mocks_and_Testkit.md +0 -137
  44. package/prompts/Jaypie_Repokit.md +0 -103
  45. package/prompts/Jaypie_Scrub.md +0 -177
  46. package/prompts/Jaypie_Streaming.md +0 -467
  47. package/prompts/Templates_CDK_Subpackage.md +0 -115
  48. package/prompts/Templates_Express_Subpackage.md +0 -187
  49. package/prompts/Templates_Project_Monorepo.md +0 -326
  50. package/prompts/Templates_Project_Subpackage.md +0 -93
  51. package/prompts/Write_Efficient_Prompt_Guides.md +0 -48
  52. package/prompts/Write_and_Maintain_Engaging_Readme.md +0 -67
@@ -1,599 +0,0 @@
1
- ---
2
- description: Core guide to Jaypie Fabric for type conversion, service handlers, and model types
3
- ---
4
-
5
- # Jaypie Fabric Package
6
-
7
- Jaypie Fabric (`@jaypie/fabric`) provides type conversion utilities, service handler patterns, and model types for consistent input handling across Jaypie applications.
8
-
9
- ## Related Adapter Guides
10
-
11
- Fabric includes adapters for integrating service handlers with various platforms. See these guides for platform-specific integration:
12
-
13
- | Guide | Import | Description |
14
- |-------|--------|-------------|
15
- | [Jaypie_Fabric_Commander.md](Jaypie_Fabric_Commander.md) | `@jaypie/fabric/commander` | Commander.js CLI integration with callbacks |
16
- | [Jaypie_Fabric_Lambda.md](Jaypie_Fabric_Lambda.md) | `@jaypie/fabric/lambda` | AWS Lambda handler wrapping |
17
- | [Jaypie_Fabric_LLM.md](Jaypie_Fabric_LLM.md) | `@jaypie/fabric/llm` | LLM tool creation for `@jaypie/llm` Toolkit |
18
- | [Jaypie_Fabric_MCP.md](Jaypie_Fabric_MCP.md) | `@jaypie/fabric/mcp` | MCP server tool registration |
19
-
20
- ## Installation
21
-
22
- ```bash
23
- npm install @jaypie/fabric
24
- ```
25
-
26
- ## Core Concepts
27
-
28
- ### Design Philosophy
29
-
30
- Fabric follows the "Fabric" philosophy:
31
- - **Smooth, pliable** - Things that feel right should work
32
- - **Catch bad passes** - Invalid inputs throw clear errors
33
-
34
- This means `"true"` works where `true` is expected, `"42"` works where `42` is expected, and invalid conversions fail fast with `BadRequestError`.
35
-
36
- ## fabricService
37
-
38
- Factory function that creates validated service endpoints with automatic type conversion.
39
-
40
- ### Basic Usage
41
-
42
- ```typescript
43
- import { fabricService } from "@jaypie/fabric";
44
-
45
- const divisionHandler = fabricService({
46
- alias: "division",
47
- description: "Divides two numbers",
48
- input: {
49
- numerator: {
50
- type: Number,
51
- default: 12,
52
- description: "Number on top",
53
- },
54
- denominator: {
55
- type: Number,
56
- default: 3,
57
- description: "Number on bottom",
58
- validate: (value) => value !== 0,
59
- },
60
- },
61
- service: ({ numerator, denominator }) => numerator / denominator,
62
- });
63
-
64
- await divisionHandler(); // → 4
65
- await divisionHandler({ numerator: 24 }); // → 8
66
- await divisionHandler({ numerator: "14", denominator: "7" }); // → 2 (converted)
67
- await divisionHandler('{"numerator": "18"}'); // → 6 (JSON parsed)
68
- ```
69
-
70
- ### Handler Properties
71
-
72
- Config properties are attached directly to the handler for introspection:
73
-
74
- ```typescript
75
- const handler = fabricService({
76
- alias: "greet",
77
- description: "Greet a user",
78
- input: { name: { type: String } },
79
- service: ({ name }) => `Hello, ${name}!`,
80
- });
81
-
82
- handler.alias; // "greet"
83
- handler.description; // "Greet a user"
84
- handler.input; // { name: { type: String } }
85
- ```
86
-
87
- ### Input Field Definition
88
-
89
- | Property | Type | Description |
90
- |----------|------|-------------|
91
- | `type` | `ConversionType` | Required. The target type for conversion |
92
- | `default` | `unknown` | Default value if not provided |
93
- | `description` | `string` | Field description (used in CLI help) |
94
- | `required` | `boolean` | Whether field is required (default: true unless default set) |
95
- | `validate` | `function \| RegExp \| array` | Validation after conversion |
96
- | `flag` | `string` | Override long flag name for Commander.js |
97
- | `letter` | `string` | Short switch letter for Commander.js |
98
-
99
- ### Validation-Only Mode
100
-
101
- When no `service` function is provided, the handler returns the processed input:
102
-
103
- ```typescript
104
- const validateUser = fabricService({
105
- input: {
106
- age: { type: Number, validate: (v) => v >= 18 },
107
- email: { type: /^[^@]+@[^@]+\.[^@]+$/ },
108
- role: { type: ["admin", "user", "guest"], default: "user" },
109
- },
110
- });
111
-
112
- await validateUser({ age: "25", email: "bob@example.com" });
113
- // → { age: 25, email: "bob@example.com", role: "user" }
114
- ```
115
-
116
- ### ServiceContext
117
-
118
- Services receive an optional second parameter with context utilities:
119
-
120
- ```typescript
121
- interface ServiceContext {
122
- onError?: (error: unknown) => void | Promise<void>;
123
- onFatal?: (error: unknown) => void | Promise<void>;
124
- sendMessage?: (message: Message) => void | Promise<void>;
125
- }
126
-
127
- const handler = fabricService({
128
- input: { jobId: { type: String } },
129
- service: async ({ jobId }, context) => {
130
- context?.sendMessage?.({ content: `Starting job ${jobId}` });
131
-
132
- // Handle recoverable errors without throwing
133
- try {
134
- await riskyOperation();
135
- } catch (err) {
136
- context?.onError?.(err); // Reports error but continues
137
- }
138
-
139
- // Or report fatal errors explicitly
140
- if (criticalFailure) {
141
- context?.onFatal?.(new Error("Cannot continue"));
142
- }
143
-
144
- return { jobId, status: "complete" };
145
- },
146
- });
147
- ```
148
-
149
- Context callbacks connect to adapter registration:
150
- - `sendMessage` → `onMessage` callback
151
- - `onError` → `onError` callback (recoverable errors)
152
- - `onFatal` → `onFatal` callback (fatal errors)
153
-
154
- **Note:** Any error that escapes the service (is thrown) is treated as fatal and routes to `onFatal`.
155
-
156
- ## Type Conversion
157
-
158
- ### Supported Types
159
-
160
- | Type | Aliases | Description |
161
- |------|---------|-------------|
162
- | `String` | `"string"`, `""` | String conversion |
163
- | `Number` | `"number"` | Number conversion |
164
- | `Boolean` | `"boolean"` | Boolean conversion |
165
- | `Date` | `DateType` | Date conversion (ISO strings, timestamps) |
166
- | `Array` | `"array"`, `[]` | Array conversion |
167
- | `Object` | `"object"`, `{}` | Object conversion |
168
- | `[String]` | `[""]` | Typed array of strings |
169
- | `[Number]` | - | Typed array of numbers |
170
- | `[Boolean]` | - | Typed array of booleans |
171
- | `[Object]` | `[{}]` | Typed array of objects |
172
- | `/regex/` | - | String with regex validation |
173
- | `["a", "b"]` | - | Validated string (must match) |
174
- | `[1, 2, 3]` | - | Validated number (must match) |
175
- | `StatusType` | - | Validated status ("pending", "processing", etc.) |
176
-
177
- ### Conversion Examples
178
-
179
- ```typescript
180
- import { fabric, fabricBoolean, fabricNumber, fabricString } from "@jaypie/fabric";
181
-
182
- // Boolean conversion
183
- fabricBoolean("true"); // → true
184
- fabricBoolean("false"); // → false
185
- fabricBoolean(1); // → true
186
- fabricBoolean(0); // → false
187
-
188
- // Number conversion
189
- fabricNumber("42"); // → 42
190
- fabricNumber("true"); // → 1
191
- fabricNumber("false"); // → 0
192
-
193
- // String conversion
194
- fabricString(true); // → "true"
195
- fabricString(42); // → "42"
196
-
197
- // Array conversion
198
- fabric("1,2,3", [Number]); // → [1, 2, 3]
199
- fabric("a\tb\tc", [String]); // → ["a", "b", "c"]
200
- fabric([1, 2], [String]); // → ["1", "2"]
201
-
202
- // Unwrapping
203
- fabricNumber({ value: "42" }); // → 42
204
- fabricBoolean(["true"]); // → true
205
- fabricNumber('{"value": 5}'); // → 5
206
-
207
- // Date conversion
208
- import { fabricDate, resolveFromDate } from "@jaypie/fabric";
209
-
210
- fabricDate("2026-01-15T10:30:00Z"); // → Date object
211
- fabricDate(1736942400000); // → Date from timestamp
212
- resolveFromDate(new Date(), String); // → ISO string
213
- resolveFromDate(new Date(), Number); // → Unix timestamp (ms)
214
- ```
215
-
216
- ### RegExp Type Shorthand
217
-
218
- A bare RegExp converts to String and validates:
219
-
220
- ```typescript
221
- const handler = fabricService({
222
- input: {
223
- email: { type: /^[^@]+@[^@]+\.[^@]+$/ },
224
- },
225
- service: ({ email }) => email,
226
- });
227
-
228
- await handler({ email: "bob@example.com" }); // ✓
229
- await handler({ email: "invalid" }); // ✗ BadRequestError
230
- ```
231
-
232
- ### Validated Type Shorthand
233
-
234
- Arrays of literals validate against allowed values:
235
-
236
- ```typescript
237
- // String validation
238
- input: {
239
- currency: { type: ["usd", "eur", "gbp"] }, // Must be one of these
240
- pattern: { type: [/^test-/, "special"] }, // Matches regex OR equals "special"
241
- }
242
-
243
- // Number validation
244
- input: {
245
- priority: { type: [1, 2, 3, 4, 5] }, // Must be 1-5
246
- }
247
- ```
248
-
249
- ### StatusType
250
-
251
- A predefined validated string type for common status values:
252
-
253
- ```typescript
254
- import { StatusType, isStatus, STATUS_VALUES } from "@jaypie/fabric";
255
-
256
- // StatusType is: ["canceled", "complete", "error", "pending", "processing", "queued", "sending"]
257
-
258
- const handler = fabricService({
259
- input: {
260
- status: { type: StatusType, default: "pending" },
261
- },
262
- service: ({ status }) => status,
263
- });
264
-
265
- await handler({ status: "processing" }); // ✓
266
- await handler({ status: "invalid" }); // ✗ BadRequestError
267
-
268
- // Type guard
269
- isStatus("pending"); // → true
270
- isStatus("unknown"); // → false
271
- ```
272
-
273
- ## Model Types
274
-
275
- Fabric provides standard model types for consistent data modeling:
276
-
277
- ```typescript
278
- import type {
279
- FabricModel,
280
- FabricModelInput,
281
- FabricModelUpdate,
282
- FabricModelFilter,
283
- FabricHistoryEntry,
284
- FabricJob,
285
- FabricMessage,
286
- FabricProgress,
287
- } from "@jaypie/fabric";
288
- ```
289
-
290
- ### FabricModel (base for all models)
291
-
292
- ```
293
- model: <varies>
294
- id: String (auto)
295
- createdAt: Date (auto)
296
- updatedAt: Date (auto)
297
- history?: [FabricHistoryEntry] (auto)
298
- name?: String
299
- label?: String
300
- abbreviation?: String
301
- alias?: String
302
- xid?: String
303
- description?: String
304
- class?: String
305
- type?: String
306
- content?: String
307
- metadata?: Object
308
- emoji?: String
309
- icon?: String
310
- archivedAt?: Date
311
- deletedAt?: Date
312
- ```
313
-
314
- ### FabricMessage (extends FabricModel)
315
-
316
- ```
317
- model: message
318
- content: String (required)
319
- type?: String (e.g., "assistant", "user", "system")
320
- ```
321
-
322
- ### FabricJob (extends FabricModel)
323
-
324
- ```
325
- model: job
326
- type?: String (e.g., "batch", "realtime", "scheduled")
327
- class?: String (e.g., "evaluation", "export", "import")
328
- status: String (required)
329
- startedAt?: Date
330
- completedAt?: Date
331
- messages?: [FabricMessage]
332
- progress?: FabricProgress (value object, not a model)
333
- ```
334
-
335
- ### FabricProgress (value object)
336
-
337
- FabricProgress is a **value object** (not a model) embedded in FabricJob:
338
-
339
- ```typescript
340
- interface FabricProgress {
341
- elapsedTime?: number;
342
- estimatedTime?: number;
343
- percentageComplete?: number;
344
- nextPercentageCheckpoint?: number;
345
- }
346
- ```
347
-
348
- ### FabricModel Utilities
349
-
350
- Field constants and utility functions for working with models:
351
-
352
- ```typescript
353
- import {
354
- // Field name constants
355
- FABRIC_MODEL_FIELDS, // All field names as constants
356
- FABRIC_MODEL_REQUIRED_FIELDS, // ["createdAt", "id", "model", "updatedAt"]
357
- FABRIC_MODEL_AUTO_FIELDS, // ["createdAt", "history", "id", "updatedAt"]
358
- FABRIC_MODEL_TIMESTAMP_FIELDS, // ["archivedAt", "createdAt", "deletedAt", "updatedAt"]
359
-
360
- // Type guards
361
- isFabricModel, // Check if value is a complete FabricModel
362
- hasFabricModelShape, // Check if value has minimum shape (id + model)
363
-
364
- // Field helpers
365
- isAutoField, // Check if field is auto-generated
366
- isTimestampField, // Check if field is a timestamp
367
-
368
- // Utilities
369
- createFabricModelInput, // Create minimal input with required model
370
- pickFabricModelFields, // Extract only FabricModel fields from object
371
- } from "@jaypie/fabric";
372
-
373
- // Example: Check if a field should be auto-generated
374
- isAutoField("id"); // → true
375
- isAutoField("name"); // → false
376
-
377
- // Example: Extract FabricModel fields from mixed object
378
- const mixed = { id: "123", model: "record", customField: "value" };
379
- pickFabricModelFields(mixed); // → { id: "123", model: "record" }
380
- ```
381
-
382
- ## TypeScript Types
383
-
384
- ```typescript
385
- import type {
386
- // Model types
387
- FabricModel,
388
- FabricModelFilter,
389
- FabricModelInput,
390
- FabricModelUpdate,
391
- FabricHistoryEntry,
392
- FabricJob,
393
- FabricMessage,
394
- FabricProgress,
395
- Status,
396
-
397
- // Message types
398
- Message,
399
- MessageLevel,
400
-
401
- // Conversion types
402
- ArrayElementType,
403
- ConversionType,
404
- CompositeType,
405
- DateConversionType,
406
- RegExpType,
407
- ScalarType,
408
- TypedArrayType,
409
- ValidatedNumberType,
410
- ValidatedStringType,
411
-
412
- // Service handler types
413
- InputFieldDefinition,
414
- ServiceContext,
415
- ServiceFunction,
416
- ServiceConfig,
417
- Service,
418
- ValidateFunction,
419
- } from "@jaypie/fabric";
420
- ```
421
-
422
- ### Message Type
423
-
424
- Standard message structure for callbacks and notifications:
425
-
426
- ```typescript
427
- type MessageLevel = "trace" | "debug" | "info" | "warn" | "error";
428
-
429
- interface Message {
430
- content: string;
431
- level?: MessageLevel; // Defaults to "info" if not specified
432
- }
433
- ```
434
-
435
- ## Exports
436
-
437
- ### Main Export (`@jaypie/fabric`)
438
-
439
- ```typescript
440
- // FabricModel utilities
441
- export {
442
- FABRIC_MODEL_AUTO_FIELDS,
443
- FABRIC_MODEL_FIELDS,
444
- FABRIC_MODEL_REQUIRED_FIELDS,
445
- FABRIC_MODEL_TIMESTAMP_FIELDS,
446
- createFabricModelInput,
447
- hasFabricModelShape,
448
- isAutoField,
449
- isFabricModel,
450
- isTimestampField,
451
- pickFabricModelFields,
452
- } from "./models/base.js";
453
-
454
- // Resolution functions
455
- export {
456
- fabric,
457
- fabricArray,
458
- fabricBoolean,
459
- fabricNumber,
460
- fabricObject,
461
- fabricString,
462
- resolveFromArray,
463
- resolveFromObject,
464
- } from "./resolve.js";
465
-
466
- // Date resolution
467
- export {
468
- fabricDate,
469
- DateType,
470
- isDateType,
471
- isValidDate,
472
- resolveFromDate,
473
- } from "./resolve-date.js";
474
-
475
- // Status type
476
- export { isStatus, STATUS_VALUES, StatusType } from "./status.js";
477
-
478
- // Service Handler
479
- export { fabricService } from "./service.js";
480
-
481
- // LLM adapter (re-exported, no optional deps)
482
- export * as llm from "./llm/index.js";
483
-
484
- // Note: Other adapters have optional dependencies and must be imported directly:
485
- // import { fabricCommand } from "@jaypie/fabric/commander";
486
- // import { fabricLambda } from "@jaypie/fabric/lambda";
487
- // import { fabricMcp } from "@jaypie/fabric/mcp";
488
-
489
- // Version
490
- export const FABRIC_VERSION: string;
491
- ```
492
-
493
- ## Error Handling
494
-
495
- Invalid conversions throw `BadRequestError` from `@jaypie/errors`:
496
-
497
- ```typescript
498
- import { BadRequestError } from "@jaypie/errors";
499
-
500
- // These throw BadRequestError:
501
- await handler({ numerator: "not-a-number" }); // Cannot convert to Number
502
- await handler({ priority: 10 }); // Validation fails (not in [1,2,3,4,5])
503
- await handler({}); // Missing required field
504
- ```
505
-
506
- ## ServiceSuite
507
-
508
- ServiceSuite groups fabricService instances for discovery, metadata export, and direct execution. Useful for exposing services through MCP or other interfaces.
509
-
510
- ### Creating a ServiceSuite
511
-
512
- ```typescript
513
- import { createServiceSuite, fabricService } from "@jaypie/fabric";
514
-
515
- const suite = createServiceSuite({
516
- name: "myapp",
517
- version: "1.0.0",
518
- });
519
- ```
520
-
521
- ### Registering Services
522
-
523
- ```typescript
524
- const greetService = fabricService({
525
- alias: "greet",
526
- description: "Greet a user",
527
- input: {
528
- name: { type: String, required: true, description: "User's name" },
529
- },
530
- service: ({ name }) => `Hello, ${name}!`,
531
- });
532
-
533
- const echoService = fabricService({
534
- alias: "echo",
535
- description: "Echo input back",
536
- input: {
537
- message: { type: String, default: "Hello", description: "Message to echo" },
538
- },
539
- service: ({ message }) => message,
540
- });
541
-
542
- suite.register(greetService, "utils");
543
- suite.register(echoService, "utils");
544
- ```
545
-
546
- ### Suite Properties and Methods
547
-
548
- ```typescript
549
- // Properties
550
- suite.name; // "myapp"
551
- suite.version; // "1.0.0"
552
- suite.categories; // ["utils"] - sorted array of registered categories
553
- suite.services; // Array of ServiceMeta for all registered services
554
-
555
- // Methods
556
- suite.getService("greet"); // ServiceMeta | undefined
557
- suite.getServicesByCategory("utils"); // ServiceMeta[]
558
- await suite.execute("greet", { name: "Alice" }); // "Hello, Alice!"
559
- ```
560
-
561
- ### ServiceMeta Structure
562
-
563
- ```typescript
564
- interface ServiceMeta {
565
- name: string; // Service alias
566
- description: string; // Service description
567
- category: string; // Category from registration
568
- inputs: ServiceInput[]; // Input parameter definitions
569
- executable?: boolean; // True if service can run with no inputs
570
- }
571
-
572
- interface ServiceInput {
573
- name: string;
574
- type: string; // "string", "number", "boolean", "object", "array"
575
- required: boolean;
576
- description: string;
577
- enum?: string[]; // For validated string/number types
578
- }
579
- ```
580
-
581
- ### TypeScript Types
582
-
583
- ```typescript
584
- import type {
585
- CreateServiceSuiteConfig,
586
- ServiceInput,
587
- ServiceMeta,
588
- ServiceSuite,
589
- } from "@jaypie/fabric";
590
- ```
591
-
592
- ## Integration with Other Packages
593
-
594
- Fabric is designed to be consumed by:
595
- - **`@jaypie/lambda`** - Lambda handler input processing
596
- - **`@jaypie/express`** - Express route input validation
597
- - **`@jaypie/llm`** - LLM tool parameter conversion via the llm adapter
598
- - **`@jaypie/mcp`** - MCP server tool registration via the mcp adapter
599
- - **CLI packages** - Commander.js integration via the commander adapter