@specforge/mcp 1.5.3 → 1.6.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 (40) hide show
  1. package/dist/lib/format.d.ts +145 -0
  2. package/dist/lib/format.d.ts.map +1 -0
  3. package/dist/lib/format.js +227 -0
  4. package/dist/lib/format.js.map +1 -0
  5. package/dist/lib/index.d.ts +7 -0
  6. package/dist/lib/index.d.ts.map +1 -0
  7. package/dist/lib/index.js +7 -0
  8. package/dist/lib/index.js.map +1 -0
  9. package/dist/lib/response.d.ts +119 -0
  10. package/dist/lib/response.d.ts.map +1 -0
  11. package/dist/lib/response.js +123 -0
  12. package/dist/lib/response.js.map +1 -0
  13. package/dist/patterns/index.d.ts +9 -0
  14. package/dist/patterns/index.d.ts.map +1 -0
  15. package/dist/patterns/index.js +15 -0
  16. package/dist/patterns/index.js.map +1 -0
  17. package/dist/patterns/inheritance.d.ts +193 -0
  18. package/dist/patterns/inheritance.d.ts.map +1 -0
  19. package/dist/patterns/inheritance.js +265 -0
  20. package/dist/patterns/inheritance.js.map +1 -0
  21. package/dist/server.d.ts.map +1 -1
  22. package/dist/server.js +21 -4
  23. package/dist/server.js.map +1 -1
  24. package/dist/tools/index.d.ts +0 -8
  25. package/dist/tools/index.d.ts.map +1 -1
  26. package/dist/tools/index.js +1477 -70
  27. package/dist/tools/index.js.map +1 -1
  28. package/dist/types/index.d.ts +567 -19
  29. package/dist/types/index.d.ts.map +1 -1
  30. package/dist/types/index.js +244 -1
  31. package/dist/types/index.js.map +1 -1
  32. package/dist/validation/index.d.ts +1 -1
  33. package/dist/validation/index.d.ts.map +1 -1
  34. package/dist/validation/index.js +163 -0
  35. package/dist/validation/index.js.map +1 -1
  36. package/dist/validation/ticket-validation.d.ts +162 -0
  37. package/dist/validation/ticket-validation.d.ts.map +1 -0
  38. package/dist/validation/ticket-validation.js +311 -0
  39. package/dist/validation/ticket-validation.js.map +1 -0
  40. package/package.json +6 -5
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Format Utility Module
3
+ *
4
+ * Provides utilities for formatting response data as JSON or TOON format.
5
+ * TOON (Token Optimized Object Notation) is a human-readable format that
6
+ * uses fewer tokens than JSON while maintaining semantic clarity.
7
+ *
8
+ * @see MCI-014-03-format-utility-module
9
+ */
10
+ /**
11
+ * Supported output formats for response data
12
+ */
13
+ export type OutputFormat = 'json' | 'toon';
14
+ /**
15
+ * Format response data as JSON or TOON.
16
+ *
17
+ * JSON format (default) returns the original data object unchanged,
18
+ * allowing the MCP protocol to handle JSON serialization.
19
+ *
20
+ * TOON format returns a human-readable string optimized for token efficiency.
21
+ *
22
+ * @param data - The data to format
23
+ * @param format - Output format ('json' or 'toon'), defaults to 'json'
24
+ * @returns Formatted data - original object for JSON, string for TOON
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // JSON (default) - returns unchanged
29
+ * formatResponse({ id: "123" }) // returns { id: "123" }
30
+ *
31
+ * // TOON - returns formatted string
32
+ * formatResponse({ id: "123" }, 'toon')
33
+ * // returns "id: 123"
34
+ *
35
+ * // Complex objects
36
+ * formatResponse({
37
+ * ticket: { id: "T-001", title: "Task", status: "done" }
38
+ * }, 'toon')
39
+ * // returns:
40
+ * // ticket.id: T-001
41
+ * // ticket.title: Task
42
+ * // ticket.status: done
43
+ * ```
44
+ */
45
+ export declare function formatResponse<T>(data: T, format?: OutputFormat): string | T;
46
+ /**
47
+ * Check if a format string is a valid OutputFormat
48
+ *
49
+ * @param format - Value to check
50
+ * @returns True if format is 'json' or 'toon'
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * isValidFormat('json') // true
55
+ * isValidFormat('toon') // true
56
+ * isValidFormat('xml') // false
57
+ * isValidFormat(null) // false
58
+ * ```
59
+ */
60
+ export declare function isValidFormat(format: unknown): format is OutputFormat;
61
+ /**
62
+ * Extract and validate format from tool arguments
63
+ *
64
+ * Returns the format if valid, otherwise defaults to 'json'.
65
+ *
66
+ * @param args - Tool arguments object
67
+ * @returns Validated OutputFormat, defaults to 'json'
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * getFormatFromArgs({ format: 'toon' }) // 'toon'
72
+ * getFormatFromArgs({ format: 'json' }) // 'json'
73
+ * getFormatFromArgs({}) // 'json'
74
+ * getFormatFromArgs({ format: 'xml' }) // 'json' (invalid, falls back)
75
+ * ```
76
+ */
77
+ export declare function getFormatFromArgs(args: Record<string, unknown>): OutputFormat;
78
+ /**
79
+ * Format an array of items with optional TOON tabular formatting
80
+ *
81
+ * For TOON format, arrays with homogeneous objects can be rendered
82
+ * in a more compact tabular format. This is useful for lists of
83
+ * tickets, epics, etc.
84
+ *
85
+ * @param items - Array of items to format
86
+ * @param format - Output format
87
+ * @returns Formatted items
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * formatArrayResponse([
92
+ * { id: '1', status: 'done' },
93
+ * { id: '2', status: 'todo' }
94
+ * ], 'toon')
95
+ * // Returns:
96
+ * // []:
97
+ * // - id: 1
98
+ * // status: done
99
+ * // - id: 2
100
+ * // status: todo
101
+ * ```
102
+ */
103
+ export declare function formatArrayResponse<T>(items: T[], format?: OutputFormat): string | T[];
104
+ /**
105
+ * Format an error response with consistent structure
106
+ *
107
+ * @param error - Error message or Error object
108
+ * @param code - Optional error code
109
+ * @param format - Output format
110
+ * @returns Formatted error response
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * formatErrorResponse('Not found', 'NOT_FOUND', 'toon')
115
+ * // Returns:
116
+ * // error: Not found
117
+ * // code: NOT_FOUND
118
+ * ```
119
+ */
120
+ export declare function formatErrorResponse(error: string | Error, code?: string, format?: OutputFormat): string | {
121
+ error: string;
122
+ code?: string;
123
+ };
124
+ /**
125
+ * Format a success response with optional data
126
+ *
127
+ * @param message - Success message
128
+ * @param data - Optional additional data
129
+ * @param format - Output format
130
+ * @returns Formatted success response
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * formatSuccessResponse('Created', { id: '123' }, 'toon')
135
+ * // Returns:
136
+ * // success: true
137
+ * // message: Created
138
+ * // id: 123
139
+ * ```
140
+ */
141
+ export declare function formatSuccessResponse<T extends Record<string, unknown>>(message: string, data?: T, format?: OutputFormat): string | {
142
+ success: true;
143
+ message: string;
144
+ } & T;
145
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/lib/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAmE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,GAAG,CAAC,CAcpF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,YAAY,CAErE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,CAM7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,GAAE,YAAqB,GAAG,MAAM,GAAG,CAAC,EAAE,CAE9F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,KAAK,EACrB,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,GAAE,YAAqB,GAC5B,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAO3C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrE,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,CAAC,EACR,MAAM,GAAE,YAAqB,GAC5B,MAAM,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,CAAC,CAGjD"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Format Utility Module
3
+ *
4
+ * Provides utilities for formatting response data as JSON or TOON format.
5
+ * TOON (Token Optimized Object Notation) is a human-readable format that
6
+ * uses fewer tokens than JSON while maintaining semantic clarity.
7
+ *
8
+ * @see MCI-014-03-format-utility-module
9
+ */
10
+ import { encode as toonEncode } from '@toon-format/toon';
11
+ /**
12
+ * Default TOON formatting options optimized for SpecForge data
13
+ *
14
+ * These settings balance readability with token efficiency:
15
+ * - indent: 2 spaces for clean nesting
16
+ * - keyFolding: 'safe' collapses single-key chains (e.g., data.id instead of nested)
17
+ */
18
+ const TOON_OPTIONS = {
19
+ indent: 2,
20
+ keyFolding: 'safe',
21
+ };
22
+ /**
23
+ * Pre-process data for optimal TOON output.
24
+ *
25
+ * This function handles:
26
+ * - Removing undefined values from objects
27
+ * - Recursively processing nested structures
28
+ * - Preserving null values (TOON represents these as ~)
29
+ * - Handling arrays with mixed or complex content
30
+ *
31
+ * @param data - Data to preprocess
32
+ * @returns Preprocessed data ready for TOON encoding
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * preprocessForToon({ a: 1, b: undefined, c: null })
37
+ * // Returns: { a: 1, c: null } (undefined removed, null preserved)
38
+ *
39
+ * preprocessForToon({ nested: { deep: { value: "test" } } })
40
+ * // Returns the same structure, recursively processed
41
+ * ```
42
+ */
43
+ function preprocessForToon(data) {
44
+ // Handle null/undefined at top level
45
+ if (data === null || data === undefined) {
46
+ return data;
47
+ }
48
+ // Handle arrays - recursively process each element
49
+ if (Array.isArray(data)) {
50
+ return data.map(preprocessForToon);
51
+ }
52
+ // Handle objects - filter undefined and recursively process
53
+ if (typeof data === 'object') {
54
+ const result = {};
55
+ for (const [key, value] of Object.entries(data)) {
56
+ // Skip undefined values entirely
57
+ if (value === undefined) {
58
+ continue;
59
+ }
60
+ // Recursively process nested values
61
+ result[key] = preprocessForToon(value);
62
+ }
63
+ return result;
64
+ }
65
+ // Return primitives unchanged
66
+ return data;
67
+ }
68
+ /**
69
+ * Format response data as JSON or TOON.
70
+ *
71
+ * JSON format (default) returns the original data object unchanged,
72
+ * allowing the MCP protocol to handle JSON serialization.
73
+ *
74
+ * TOON format returns a human-readable string optimized for token efficiency.
75
+ *
76
+ * @param data - The data to format
77
+ * @param format - Output format ('json' or 'toon'), defaults to 'json'
78
+ * @returns Formatted data - original object for JSON, string for TOON
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * // JSON (default) - returns unchanged
83
+ * formatResponse({ id: "123" }) // returns { id: "123" }
84
+ *
85
+ * // TOON - returns formatted string
86
+ * formatResponse({ id: "123" }, 'toon')
87
+ * // returns "id: 123"
88
+ *
89
+ * // Complex objects
90
+ * formatResponse({
91
+ * ticket: { id: "T-001", title: "Task", status: "done" }
92
+ * }, 'toon')
93
+ * // returns:
94
+ * // ticket.id: T-001
95
+ * // ticket.title: Task
96
+ * // ticket.status: done
97
+ * ```
98
+ */
99
+ export function formatResponse(data, format = 'json') {
100
+ if (format === 'json') {
101
+ return data;
102
+ }
103
+ try {
104
+ // Preprocess data to handle undefined values and complex structures
105
+ const processed = preprocessForToon(data);
106
+ return toonEncode(processed, TOON_OPTIONS);
107
+ }
108
+ catch (error) {
109
+ // Fallback to JSON on TOON encoding errors
110
+ console.error('TOON formatting failed, falling back to JSON:', error);
111
+ return data;
112
+ }
113
+ }
114
+ /**
115
+ * Check if a format string is a valid OutputFormat
116
+ *
117
+ * @param format - Value to check
118
+ * @returns True if format is 'json' or 'toon'
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * isValidFormat('json') // true
123
+ * isValidFormat('toon') // true
124
+ * isValidFormat('xml') // false
125
+ * isValidFormat(null) // false
126
+ * ```
127
+ */
128
+ export function isValidFormat(format) {
129
+ return format === 'json' || format === 'toon';
130
+ }
131
+ /**
132
+ * Extract and validate format from tool arguments
133
+ *
134
+ * Returns the format if valid, otherwise defaults to 'json'.
135
+ *
136
+ * @param args - Tool arguments object
137
+ * @returns Validated OutputFormat, defaults to 'json'
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * getFormatFromArgs({ format: 'toon' }) // 'toon'
142
+ * getFormatFromArgs({ format: 'json' }) // 'json'
143
+ * getFormatFromArgs({}) // 'json'
144
+ * getFormatFromArgs({ format: 'xml' }) // 'json' (invalid, falls back)
145
+ * ```
146
+ */
147
+ export function getFormatFromArgs(args) {
148
+ const format = args?.format;
149
+ if (isValidFormat(format)) {
150
+ return format;
151
+ }
152
+ return 'json';
153
+ }
154
+ /**
155
+ * Format an array of items with optional TOON tabular formatting
156
+ *
157
+ * For TOON format, arrays with homogeneous objects can be rendered
158
+ * in a more compact tabular format. This is useful for lists of
159
+ * tickets, epics, etc.
160
+ *
161
+ * @param items - Array of items to format
162
+ * @param format - Output format
163
+ * @returns Formatted items
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * formatArrayResponse([
168
+ * { id: '1', status: 'done' },
169
+ * { id: '2', status: 'todo' }
170
+ * ], 'toon')
171
+ * // Returns:
172
+ * // []:
173
+ * // - id: 1
174
+ * // status: done
175
+ * // - id: 2
176
+ * // status: todo
177
+ * ```
178
+ */
179
+ export function formatArrayResponse(items, format = 'json') {
180
+ return formatResponse(items, format);
181
+ }
182
+ /**
183
+ * Format an error response with consistent structure
184
+ *
185
+ * @param error - Error message or Error object
186
+ * @param code - Optional error code
187
+ * @param format - Output format
188
+ * @returns Formatted error response
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * formatErrorResponse('Not found', 'NOT_FOUND', 'toon')
193
+ * // Returns:
194
+ * // error: Not found
195
+ * // code: NOT_FOUND
196
+ * ```
197
+ */
198
+ export function formatErrorResponse(error, code, format = 'json') {
199
+ const errorMessage = error instanceof Error ? error.message : error;
200
+ const response = { error: errorMessage };
201
+ if (code) {
202
+ response.code = code;
203
+ }
204
+ return formatResponse(response, format);
205
+ }
206
+ /**
207
+ * Format a success response with optional data
208
+ *
209
+ * @param message - Success message
210
+ * @param data - Optional additional data
211
+ * @param format - Output format
212
+ * @returns Formatted success response
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * formatSuccessResponse('Created', { id: '123' }, 'toon')
217
+ * // Returns:
218
+ * // success: true
219
+ * // message: Created
220
+ * // id: 123
221
+ * ```
222
+ */
223
+ export function formatSuccessResponse(message, data, format = 'json') {
224
+ const response = { success: true, message, ...data };
225
+ return formatResponse(response, format);
226
+ }
227
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/lib/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,IAAI,UAAU,EAAsB,MAAM,mBAAmB,CAAC;AAO7E;;;;;;GAMG;AACH,MAAM,YAAY,GAAkB;IAClC,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,MAAM;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,iBAAiB,CAAI,IAAO;IACnC,qCAAqC;IACrC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mDAAmD;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAM,CAAC;IAC1C,CAAC;IAED,4DAA4D;IAC5D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,MAAM,GAA4B,EAAE,CAAC;QAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAA+B,CAAC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,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAqB,EACrB,IAAa,EACb,SAAuB,MAAM;IAE7B,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACpE,MAAM,QAAQ,GAAqC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAC3E,IAAI,IAAI,EAAE,CAAC;QACT,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;IACvB,CAAC;IACD,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAe,EACf,IAAQ,EACR,SAAuB,MAAM;IAE7B,MAAM,QAAQ,GAAG,EAAE,OAAO,EAAE,IAAa,EAAE,OAAO,EAAE,GAAG,IAAI,EAA4C,CAAC;IACxG,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Library Utilities
3
+ *
4
+ * Exports shared utility modules for the MCP server.
5
+ */
6
+ export { type OutputFormat, formatResponse, formatArrayResponse, formatErrorResponse, formatSuccessResponse, isValidFormat, getFormatFromArgs, } from './format.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Library Utilities
3
+ *
4
+ * Exports shared utility modules for the MCP server.
5
+ */
6
+ export { formatResponse, formatArrayResponse, formatErrorResponse, formatSuccessResponse, isValidFormat, getFormatFromArgs, } from './format.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Response Mode Utilities
3
+ *
4
+ * Client-side utilities for response mode handling in write operations.
5
+ * Implements MCI-057: Response Modes for Write Operations
6
+ *
7
+ * Response modes control the verbosity of create/update operation responses:
8
+ * - 'full': Complete object (~500 tokens) - default
9
+ * - 'minimal': id, number, title, message (~50 tokens)
10
+ * - 'id-only': id and number only (~20 tokens)
11
+ */
12
+ /**
13
+ * Response mode for write operations
14
+ */
15
+ export type ResponseMode = 'full' | 'minimal' | 'id-only';
16
+ /**
17
+ * Valid response modes
18
+ */
19
+ export declare const RESPONSE_MODES: ResponseMode[];
20
+ /**
21
+ * Minimal response for write operations
22
+ */
23
+ export interface MinimalResponse {
24
+ id: string;
25
+ ticketNumber?: number;
26
+ epicNumber?: number;
27
+ title: string;
28
+ message: string;
29
+ }
30
+ /**
31
+ * ID-only response for write operations
32
+ */
33
+ export interface IdOnlyResponse {
34
+ id: string;
35
+ ticketNumber?: number;
36
+ epicNumber?: number;
37
+ }
38
+ /**
39
+ * Check if a value is a valid response mode
40
+ */
41
+ export declare function isValidResponseMode(value: unknown): value is ResponseMode;
42
+ /**
43
+ * Parse response mode from tool arguments, defaulting to 'full'
44
+ *
45
+ * @param args - Tool arguments object
46
+ * @returns Validated ResponseMode, defaults to 'full'
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * getResponseModeFromArgs({ responseMode: 'minimal' }) // 'minimal'
51
+ * getResponseModeFromArgs({ responseMode: 'id-only' }) // 'id-only'
52
+ * getResponseModeFromArgs({}) // 'full'
53
+ * getResponseModeFromArgs({ responseMode: 'invalid' }) // 'full' (invalid, falls back)
54
+ * ```
55
+ */
56
+ export declare function getResponseModeFromArgs(args: Record<string, unknown>): ResponseMode;
57
+ /**
58
+ * Format a write operation response based on mode.
59
+ *
60
+ * This reduces token usage when full details aren't needed:
61
+ * - 'full': Returns unchanged (~500 tokens)
62
+ * - 'minimal': Returns id, numbers, title, message (~50 tokens)
63
+ * - 'id-only': Returns id and numbers only (~20 tokens)
64
+ *
65
+ * @param entity - Full entity object from API response
66
+ * @param mode - Response mode
67
+ * @param message - Success message for minimal mode
68
+ * @returns Formatted response based on mode
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * // Full mode (default)
73
+ * formatWriteResponse(ticket, 'full', 'Created')
74
+ * // Returns: { id, title, status, description, ... }
75
+ *
76
+ * // Minimal mode
77
+ * formatWriteResponse(ticket, 'minimal', 'Ticket created')
78
+ * // Returns: { id: 'xyz', ticketNumber: 1, title: 'My Ticket', message: 'Ticket created' }
79
+ *
80
+ * // ID-only mode
81
+ * formatWriteResponse(ticket, 'id-only', 'Created')
82
+ * // Returns: { id: 'xyz', ticketNumber: 1 }
83
+ * ```
84
+ */
85
+ export declare function formatWriteResponse<T extends {
86
+ id: string;
87
+ title?: string;
88
+ ticket?: {
89
+ id: string;
90
+ title: string;
91
+ };
92
+ epic?: {
93
+ id: string;
94
+ title: string;
95
+ };
96
+ specification?: {
97
+ id: string;
98
+ title: string;
99
+ };
100
+ }>(entity: T, mode: ResponseMode, message: string): T | MinimalResponse | IdOnlyResponse;
101
+ /**
102
+ * Format multiple write operation responses based on mode.
103
+ *
104
+ * @param entities - Array of entity objects
105
+ * @param mode - Response mode
106
+ * @param message - Success message template for minimal mode
107
+ * @returns Array of formatted responses
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * formatWriteResponses(tickets, 'minimal', 'Ticket created')
112
+ * // Returns: [{ id, ticketNumber, title, message }, ...]
113
+ * ```
114
+ */
115
+ export declare function formatWriteResponses<T extends {
116
+ id: string;
117
+ title?: string;
118
+ }>(entities: T[], mode: ResponseMode, message: string): Array<T | MinimalResponse | IdOnlyResponse>;
119
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/lib/response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EAAmC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,YAAY,CAMd;AAoBD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,mBAAmB,CACjC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,aAAa,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAErK,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,GACd,CAAC,GAAG,eAAe,GAAG,cAAc,CAwBtC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAExC,QAAQ,EAAE,CAAC,EAAE,EACb,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,GACd,KAAK,CAAC,CAAC,GAAG,eAAe,GAAG,cAAc,CAAC,CAE7C"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Response Mode Utilities
3
+ *
4
+ * Client-side utilities for response mode handling in write operations.
5
+ * Implements MCI-057: Response Modes for Write Operations
6
+ *
7
+ * Response modes control the verbosity of create/update operation responses:
8
+ * - 'full': Complete object (~500 tokens) - default
9
+ * - 'minimal': id, number, title, message (~50 tokens)
10
+ * - 'id-only': id and number only (~20 tokens)
11
+ */
12
+ /**
13
+ * Valid response modes
14
+ */
15
+ export const RESPONSE_MODES = ['full', 'minimal', 'id-only'];
16
+ /**
17
+ * Check if a value is a valid response mode
18
+ */
19
+ export function isValidResponseMode(value) {
20
+ return typeof value === 'string' && RESPONSE_MODES.includes(value);
21
+ }
22
+ /**
23
+ * Parse response mode from tool arguments, defaulting to 'full'
24
+ *
25
+ * @param args - Tool arguments object
26
+ * @returns Validated ResponseMode, defaults to 'full'
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * getResponseModeFromArgs({ responseMode: 'minimal' }) // 'minimal'
31
+ * getResponseModeFromArgs({ responseMode: 'id-only' }) // 'id-only'
32
+ * getResponseModeFromArgs({}) // 'full'
33
+ * getResponseModeFromArgs({ responseMode: 'invalid' }) // 'full' (invalid, falls back)
34
+ * ```
35
+ */
36
+ export function getResponseModeFromArgs(args) {
37
+ const mode = args?.responseMode;
38
+ if (isValidResponseMode(mode)) {
39
+ return mode;
40
+ }
41
+ return 'full';
42
+ }
43
+ /**
44
+ * Extract number field from entity result
45
+ */
46
+ function extractNumber(entity) {
47
+ const result = {};
48
+ if (typeof entity.ticketNumber === 'number') {
49
+ result.ticketNumber = entity.ticketNumber;
50
+ }
51
+ if (typeof entity.epicNumber === 'number') {
52
+ result.epicNumber = entity.epicNumber;
53
+ }
54
+ return result;
55
+ }
56
+ /**
57
+ * Format a write operation response based on mode.
58
+ *
59
+ * This reduces token usage when full details aren't needed:
60
+ * - 'full': Returns unchanged (~500 tokens)
61
+ * - 'minimal': Returns id, numbers, title, message (~50 tokens)
62
+ * - 'id-only': Returns id and numbers only (~20 tokens)
63
+ *
64
+ * @param entity - Full entity object from API response
65
+ * @param mode - Response mode
66
+ * @param message - Success message for minimal mode
67
+ * @returns Formatted response based on mode
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * // Full mode (default)
72
+ * formatWriteResponse(ticket, 'full', 'Created')
73
+ * // Returns: { id, title, status, description, ... }
74
+ *
75
+ * // Minimal mode
76
+ * formatWriteResponse(ticket, 'minimal', 'Ticket created')
77
+ * // Returns: { id: 'xyz', ticketNumber: 1, title: 'My Ticket', message: 'Ticket created' }
78
+ *
79
+ * // ID-only mode
80
+ * formatWriteResponse(ticket, 'id-only', 'Created')
81
+ * // Returns: { id: 'xyz', ticketNumber: 1 }
82
+ * ```
83
+ */
84
+ export function formatWriteResponse(entity, mode, message) {
85
+ // Handle nested entity structures (update_ticket returns { ticket: {...} })
86
+ const actualEntity = entity.ticket || entity.epic || entity.specification || entity;
87
+ const entityRecord = actualEntity;
88
+ switch (mode) {
89
+ case 'id-only':
90
+ return {
91
+ id: entityRecord.id,
92
+ ...extractNumber(entityRecord),
93
+ };
94
+ case 'minimal':
95
+ return {
96
+ id: entityRecord.id,
97
+ ...extractNumber(entityRecord),
98
+ title: entityRecord.title || '',
99
+ message,
100
+ };
101
+ case 'full':
102
+ default:
103
+ return entity;
104
+ }
105
+ }
106
+ /**
107
+ * Format multiple write operation responses based on mode.
108
+ *
109
+ * @param entities - Array of entity objects
110
+ * @param mode - Response mode
111
+ * @param message - Success message template for minimal mode
112
+ * @returns Array of formatted responses
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * formatWriteResponses(tickets, 'minimal', 'Ticket created')
117
+ * // Returns: [{ id, ticketNumber, title, message }, ...]
118
+ * ```
119
+ */
120
+ export function formatWriteResponses(entities, mode, message) {
121
+ return entities.map((entity) => formatWriteResponse(entity, mode, message));
122
+ }
123
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/lib/response.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAsB7E;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAqB,CAAC,CAAC;AACrF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAA6B;IAE7B,MAAM,IAAI,GAAG,IAAI,EAAE,YAAY,CAAC;IAChC,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CACpB,MAA+B;IAE/B,MAAM,MAAM,GAAmD,EAAE,CAAC;IAElE,IAAI,OAAO,M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
+ *
4
+ * Exports pattern resolution functions for the SpecForge MCP.
5
+ *
6
+ * @see MCI-030-05-pattern-inheritance-resolver
7
+ */
8
+ export { type ResolvedPatterns, type PatternOverride, type PatternOverrideReport, type PatternResolutionInput, resolvePatterns, resolvePatternsWithCache, getPatternOverrides, flattenCodeStandards, flattenSharedPatterns, invalidatePatternCache, invalidateAllPatternCaches, getPatternCacheSize, } from './inheritance.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/patterns/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE3B,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EAEnB,oBAAoB,EACpB,qBAAqB,EAErB,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}