@ai-dossier/mcp-server 1.0.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 (50) hide show
  1. package/README.md +379 -0
  2. package/dist/index.d.ts +8 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +332 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/parsers/signatureVerifier.d.ts +10 -0
  7. package/dist/parsers/signatureVerifier.d.ts.map +1 -0
  8. package/dist/parsers/signatureVerifier.js +85 -0
  9. package/dist/parsers/signatureVerifier.js.map +1 -0
  10. package/dist/resources/concept.d.ts +7 -0
  11. package/dist/resources/concept.d.ts.map +1 -0
  12. package/dist/resources/concept.js +11 -0
  13. package/dist/resources/concept.js.map +1 -0
  14. package/dist/resources/protocol.d.ts +7 -0
  15. package/dist/resources/protocol.d.ts.map +1 -0
  16. package/dist/resources/protocol.js +11 -0
  17. package/dist/resources/protocol.js.map +1 -0
  18. package/dist/resources/security.d.ts +7 -0
  19. package/dist/resources/security.d.ts.map +1 -0
  20. package/dist/resources/security.js +11 -0
  21. package/dist/resources/security.js.map +1 -0
  22. package/dist/tools/listDossiers.d.ts +19 -0
  23. package/dist/tools/listDossiers.d.ts.map +1 -0
  24. package/dist/tools/listDossiers.js +104 -0
  25. package/dist/tools/listDossiers.js.map +1 -0
  26. package/dist/tools/readDossier.d.ts +27 -0
  27. package/dist/tools/readDossier.d.ts.map +1 -0
  28. package/dist/tools/readDossier.js +46 -0
  29. package/dist/tools/readDossier.js.map +1 -0
  30. package/dist/tools/verifyDossier.d.ts +15 -0
  31. package/dist/tools/verifyDossier.d.ts.map +1 -0
  32. package/dist/tools/verifyDossier.js +107 -0
  33. package/dist/tools/verifyDossier.js.map +1 -0
  34. package/dist/utils/errors.d.ts +35 -0
  35. package/dist/utils/errors.d.ts.map +1 -0
  36. package/dist/utils/errors.js +68 -0
  37. package/dist/utils/errors.js.map +1 -0
  38. package/dist/utils/logger.d.ts +31 -0
  39. package/dist/utils/logger.d.ts.map +1 -0
  40. package/dist/utils/logger.js +58 -0
  41. package/dist/utils/logger.js.map +1 -0
  42. package/dist/utils/resourceLoader.d.ts +20 -0
  43. package/dist/utils/resourceLoader.d.ts.map +1 -0
  44. package/dist/utils/resourceLoader.js +46 -0
  45. package/dist/utils/resourceLoader.js.map +1 -0
  46. package/dist/utils/response.d.ts +17 -0
  47. package/dist/utils/response.d.ts.map +1 -0
  48. package/dist/utils/response.js +22 -0
  49. package/dist/utils/response.js.map +1 -0
  50. package/package.json +45 -0
package/dist/index.js ADDED
@@ -0,0 +1,332 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Dossier MCP Server
5
+ * Model Context Protocol server for dossier automation standard
6
+ * Enables LLMs to discover, verify, and execute dossiers securely
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const core_1 = require("@ai-dossier/core");
10
+ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
11
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
12
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
13
+ const concept_js_1 = require("./resources/concept.js");
14
+ const protocol_js_1 = require("./resources/protocol.js");
15
+ const security_js_1 = require("./resources/security.js");
16
+ const listDossiers_js_1 = require("./tools/listDossiers.js");
17
+ const readDossier_js_1 = require("./tools/readDossier.js");
18
+ const verifyDossier_js_1 = require("./tools/verifyDossier.js");
19
+ const logger_js_1 = require("./utils/logger.js");
20
+ const response_js_1 = require("./utils/response.js");
21
+ // Create MCP server instance
22
+ const server = new index_js_1.Server({
23
+ name: '@ai-dossier/mcp-server',
24
+ version: '1.0.0',
25
+ }, {
26
+ capabilities: {
27
+ tools: {},
28
+ resources: {},
29
+ prompts: {},
30
+ },
31
+ });
32
+ // Register tools
33
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
34
+ logger_js_1.logger.debug('Listing tools');
35
+ return {
36
+ tools: [
37
+ {
38
+ name: 'verify_dossier',
39
+ description: '🔒 Security verification - Verify integrity (checksum) and authenticity (signature) of a dossier. Returns ALLOW/WARN/BLOCK recommendation.',
40
+ inputSchema: {
41
+ type: 'object',
42
+ properties: {
43
+ path: {
44
+ type: 'string',
45
+ description: 'Path to dossier file (.ds.md)',
46
+ },
47
+ trusted_keys_path: {
48
+ type: 'string',
49
+ description: 'Path to trusted-keys.txt (default: ~/.dossier/trusted-keys.txt)',
50
+ },
51
+ },
52
+ required: ['path'],
53
+ },
54
+ },
55
+ {
56
+ name: 'read_dossier',
57
+ description: 'Read and parse a dossier file. Returns metadata and content. Should be called AFTER verify_dossier passes.',
58
+ inputSchema: {
59
+ type: 'object',
60
+ properties: {
61
+ path: {
62
+ type: 'string',
63
+ description: 'Path to dossier file (.ds.md)',
64
+ },
65
+ },
66
+ required: ['path'],
67
+ },
68
+ },
69
+ {
70
+ name: 'list_dossiers',
71
+ description: 'Discover available dossiers in a directory. Scans for *.ds.md files and returns metadata.',
72
+ inputSchema: {
73
+ type: 'object',
74
+ properties: {
75
+ path: {
76
+ type: 'string',
77
+ description: 'Directory to search (default: current working directory)',
78
+ },
79
+ recursive: {
80
+ type: 'boolean',
81
+ description: 'Search subdirectories recursively (default: true)',
82
+ },
83
+ },
84
+ },
85
+ },
86
+ ],
87
+ };
88
+ });
89
+ // Handle tool calls
90
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
91
+ const { name, arguments: args } = request.params;
92
+ logger_js_1.logger.info('Tool call received', { tool: name, arguments: args });
93
+ try {
94
+ switch (name) {
95
+ case 'verify_dossier': {
96
+ const result = await (0, verifyDossier_js_1.verifyDossier)(args);
97
+ return (0, response_js_1.createToolResponse)(result);
98
+ }
99
+ case 'read_dossier': {
100
+ const result = (0, readDossier_js_1.readDossier)(args);
101
+ return (0, response_js_1.createToolResponse)(result);
102
+ }
103
+ case 'list_dossiers': {
104
+ const result = (0, listDossiers_js_1.listDossiers)(args);
105
+ return (0, response_js_1.createToolResponse)(result);
106
+ }
107
+ default:
108
+ throw new Error(`Unknown tool: ${name}`);
109
+ }
110
+ }
111
+ catch (error) {
112
+ logger_js_1.logger.error('Tool execution error', {
113
+ tool: name,
114
+ error: (0, core_1.getErrorMessage)(error),
115
+ stack: (0, core_1.getErrorStack)(error),
116
+ });
117
+ return (0, response_js_1.createToolResponse)({ error: { message: (0, core_1.getErrorMessage)(error), tool: name } }, true);
118
+ }
119
+ });
120
+ // Register resources
121
+ server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => {
122
+ logger_js_1.logger.debug('Listing resources');
123
+ return {
124
+ resources: [
125
+ {
126
+ uri: 'dossier://protocol',
127
+ name: 'Dossier Execution Protocol',
128
+ description: 'How to execute dossiers safely and effectively',
129
+ mimeType: 'text/markdown',
130
+ },
131
+ {
132
+ uri: 'dossier://security',
133
+ name: 'Security Architecture',
134
+ description: 'Security model, signing, verification, and trust management',
135
+ mimeType: 'text/markdown',
136
+ },
137
+ {
138
+ uri: 'dossier://concept',
139
+ name: 'Dossier Concept',
140
+ description: 'Introduction to dossiers - what they are and why to use them',
141
+ mimeType: 'text/markdown',
142
+ },
143
+ ],
144
+ };
145
+ });
146
+ // Handle resource reads
147
+ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
148
+ const { uri } = request.params;
149
+ logger_js_1.logger.info('Resource read requested', { uri });
150
+ try {
151
+ let content;
152
+ switch (uri) {
153
+ case 'dossier://protocol':
154
+ content = (0, protocol_js_1.getProtocolResource)();
155
+ break;
156
+ case 'dossier://security':
157
+ content = (0, security_js_1.getSecurityResource)();
158
+ break;
159
+ case 'dossier://concept':
160
+ content = (0, concept_js_1.getConceptResource)();
161
+ break;
162
+ default:
163
+ throw new Error(`Unknown resource: ${uri}`);
164
+ }
165
+ return {
166
+ contents: [
167
+ {
168
+ uri,
169
+ mimeType: 'text/markdown',
170
+ text: content,
171
+ },
172
+ ],
173
+ };
174
+ }
175
+ catch (error) {
176
+ logger_js_1.logger.error('Resource read error', {
177
+ uri,
178
+ error: (0, core_1.getErrorMessage)(error),
179
+ stack: (0, core_1.getErrorStack)(error),
180
+ });
181
+ throw error;
182
+ }
183
+ });
184
+ // Register prompts
185
+ server.setRequestHandler(types_js_1.ListPromptsRequestSchema, async () => {
186
+ logger_js_1.logger.debug('Listing prompts');
187
+ return {
188
+ prompts: [
189
+ {
190
+ name: 'execute-dossier',
191
+ description: 'Run a dossier with verification and protocol',
192
+ arguments: [
193
+ {
194
+ name: 'dossier_path',
195
+ description: 'Path or URL to the dossier file',
196
+ required: true,
197
+ },
198
+ ],
199
+ },
200
+ {
201
+ name: 'create-dossier',
202
+ description: 'Author a new dossier with proper structure',
203
+ arguments: [
204
+ {
205
+ name: 'title',
206
+ description: 'Title for the new dossier',
207
+ required: true,
208
+ },
209
+ {
210
+ name: 'category',
211
+ description: 'Category (e.g., devops, authoring)',
212
+ required: false,
213
+ },
214
+ {
215
+ name: 'risk_level',
216
+ description: 'Risk level: low, medium, high, critical',
217
+ required: false,
218
+ },
219
+ ],
220
+ },
221
+ ],
222
+ };
223
+ });
224
+ // Handle prompt requests
225
+ server.setRequestHandler(types_js_1.GetPromptRequestSchema, async (request) => {
226
+ const { name, arguments: args } = request.params;
227
+ logger_js_1.logger.info('Prompt requested', { prompt: name, arguments: args });
228
+ switch (name) {
229
+ case 'execute-dossier': {
230
+ const dossierPath = args?.dossier_path;
231
+ if (!dossierPath) {
232
+ throw new Error('dossier_path argument is required');
233
+ }
234
+ return {
235
+ messages: [
236
+ {
237
+ role: 'user',
238
+ content: {
239
+ type: 'text',
240
+ text: `Execute the dossier at: ${dossierPath}
241
+
242
+ Follow the Dossier Execution Protocol:
243
+
244
+ 1. **VERIFY** - Run \`dossier verify ${dossierPath}\` to check integrity and signature
245
+ - If verification fails, STOP and report the issue
246
+ - If signature is from untrusted source, ask user whether to proceed
247
+
248
+ 2. **READ** - Use the read_dossier tool to get the dossier content
249
+
250
+ 3. **EXECUTE** - Follow the instructions in the dossier body
251
+ - Respect any risk_level warnings
252
+ - Ask for confirmation before destructive operations
253
+ - Report progress as you complete each step
254
+
255
+ 4. **REPORT** - Summarize what was accomplished`,
256
+ },
257
+ },
258
+ ],
259
+ };
260
+ }
261
+ case 'create-dossier': {
262
+ const title = args?.title;
263
+ if (!title) {
264
+ throw new Error('title argument is required');
265
+ }
266
+ const category = args?.category;
267
+ const riskLevel = args?.risk_level;
268
+ const filename = `${title.toLowerCase().replace(/\s+/g, '-')}.ds.md`;
269
+ return {
270
+ messages: [
271
+ {
272
+ role: 'user',
273
+ content: {
274
+ type: 'text',
275
+ text: `Create a new dossier: "${title}"
276
+ ${category ? `Category: ${category}` : ''}
277
+ ${riskLevel ? `Risk level: ${riskLevel}` : ''}
278
+ Suggested filename: ${filename}
279
+
280
+ **Instructions**: Execute the meta-dossier at:
281
+ https://raw.githubusercontent.com/imboard-ai/ai-dossier/main/examples/authoring/create-dossier.ds.md
282
+
283
+ This meta-dossier contains the official template and authoring instructions.
284
+ Follow its guidance to create "${title}" with proper structure.`,
285
+ },
286
+ },
287
+ ],
288
+ };
289
+ }
290
+ default:
291
+ throw new Error(`Unknown prompt: ${name}`);
292
+ }
293
+ });
294
+ // Start server
295
+ async function main() {
296
+ try {
297
+ const transport = new stdio_js_1.StdioServerTransport();
298
+ await server.connect(transport);
299
+ logger_js_1.logger.info('Dossier MCP Server started', {
300
+ name: '@ai-dossier/mcp-server',
301
+ version: '1.0.0',
302
+ transport: 'stdio',
303
+ });
304
+ // Keep process alive
305
+ process.stdin.resume();
306
+ }
307
+ catch (error) {
308
+ logger_js_1.logger.error('Failed to start server', {
309
+ error: (0, core_1.getErrorMessage)(error),
310
+ stack: (0, core_1.getErrorStack)(error),
311
+ });
312
+ process.exit(1);
313
+ }
314
+ }
315
+ // Handle graceful shutdown
316
+ process.on('SIGINT', () => {
317
+ logger_js_1.logger.info('Received SIGINT, shutting down gracefully');
318
+ process.exit(0);
319
+ });
320
+ process.on('SIGTERM', () => {
321
+ logger_js_1.logger.info('Received SIGTERM, shutting down gracefully');
322
+ process.exit(0);
323
+ });
324
+ // Run server
325
+ main().catch((error) => {
326
+ logger_js_1.logger.error('Fatal error', {
327
+ error: (0, core_1.getErrorMessage)(error),
328
+ stack: (0, core_1.getErrorStack)(error),
329
+ });
330
+ process.exit(1);
331
+ });
332
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;;AAEH,2CAAkE;AAClE,wEAAmE;AACnE,wEAAiF;AACjF,iEAO4C;AAC5C,uDAA4D;AAC5D,yDAA8D;AAC9D,yDAA8D;AAC9D,6DAA+E;AAC/E,2DAA4E;AAC5E,+DAAkF;AAClF,iDAA2C;AAC3C,qDAAyD;AAEzD,6BAA6B;AAC7B,MAAM,MAAM,GAAG,IAAI,iBAAM,CACvB;IACE,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;KACZ;CACF,CACF,CAAC;AAEF,iBAAiB;AACjB,MAAM,CAAC,iBAAiB,CAAC,iCAAsB,EAAE,KAAK,IAAI,EAAE;IAC1D,kBAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC9B,OAAO;QACL,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EACT,4IAA4I;gBAC9I,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,+BAA+B;yBAC7C;wBACD,iBAAiB,EAAE;4BACjB,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,iEAAiE;yBAC/E;qBACF;oBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;iBACnB;aACF;YACD;gBACE,IA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AC,MAAM,EAAE,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kBAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE;YACrC,KAAK,EAAE,IAAA,sBAAe,EAAC,KAAK,CAAC;YAC7B,KAAK,EAAE,IAAA,oBAAa,EAAC,KAAK,CAAC;SAC5B,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,2BAA2B;AAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,kBAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,kBAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,aAAa;AACb,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,kBAAM,CAAC,KAAK,CAAC,aAAa,EAAE;QAC1B,KAAK,EAAE,IAAA,sBAAe,EAAC,KAAK,CAAC;QAC7B,KAAK,EAAE,IAAA,oBAAa,EAAC,KAAK,CAAC;KAC5B,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Signature verification for dossier authenticity
3
+ * Uses the unified verifier module
4
+ */
5
+ import { type AuthenticityResult, type DossierFrontmatter } from '@ai-dossier/core';
6
+ /**
7
+ * Verify dossier authenticity (signature + trust)
8
+ */
9
+ export declare function verifyAuthenticity(body: string, frontmatter: DossierFrontmatter, trustedKeysPath?: string): Promise<AuthenticityResult>;
10
+ //# sourceMappingURL=signatureVerifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatureVerifier.d.ts","sourceRoot":"","sources":["../../src/parsers/signatureVerifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAIxB,MAAM,kBAAkB,CAAC;AAG1B;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,kBAAkB,EAC/B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC,CA0E7B"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * Signature verification for dossier authenticity
4
+ * Uses the unified verifier module
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.verifyAuthenticity = verifyAuthenticity;
8
+ const core_1 = require("@ai-dossier/core");
9
+ const logger_1 = require("../utils/logger");
10
+ /**
11
+ * Verify dossier authenticity (signature + trust)
12
+ */
13
+ async function verifyAuthenticity(body, frontmatter, trustedKeysPath) {
14
+ const signature = frontmatter.signature;
15
+ // No signature present
16
+ if (!signature) {
17
+ logger_1.logger.info('No signature found in dossier');
18
+ return {
19
+ status: 'unsigned',
20
+ message: 'No signature found - authenticity cannot be verified',
21
+ isTrusted: false,
22
+ };
23
+ }
24
+ // Load trusted keys
25
+ const trustedKeys = (0, core_1.loadTrustedKeys)(trustedKeysPath);
26
+ const isTrusted = trustedKeys.has(signature.public_key || signature.key_id);
27
+ const trustedAs = isTrusted
28
+ ? trustedKeys.get(signature.public_key || signature.key_id)
29
+ : undefined;
30
+ // Verify signature
31
+ try {
32
+ const isValid = await (0, core_1.verifySignature)(body, signature);
33
+ if (!isValid) {
34
+ logger_1.logger.error('SIGNATURE VERIFICATION FAILED');
35
+ return {
36
+ status: 'invalid',
37
+ message: 'SIGNATURE VERIFICATION FAILED',
38
+ signer: signature.signed_by,
39
+ keyId: signature.key_id,
40
+ publicKey: signature.public_key,
41
+ isTrusted,
42
+ trustedAs,
43
+ };
44
+ }
45
+ // Signature is valid - check if trusted
46
+ if (isTrusted) {
47
+ logger_1.logger.info('Verified signature from TRUSTED source', { trustedAs });
48
+ return {
49
+ status: 'verified',
50
+ message: `Verified signature from trusted source: ${trustedAs}`,
51
+ signer: signature.signed_by,
52
+ keyId: signature.key_id,
53
+ publicKey: signature.public_key,
54
+ isTrusted: true,
55
+ trustedAs,
56
+ };
57
+ }
58
+ else {
59
+ logger_1.logger.warn('Valid signature but key is NOT in trusted list');
60
+ return {
61
+ status: 'signed_unknown',
62
+ message: 'Valid signature but key is not in trusted list',
63
+ signer: signature.signed_by,
64
+ keyId: signature.key_id,
65
+ publicKey: signature.public_key,
66
+ isTrusted: false,
67
+ };
68
+ }
69
+ }
70
+ catch (err) {
71
+ logger_1.logger.error('Signature verification error', {
72
+ error: (0, core_1.getErrorMessage)(err),
73
+ });
74
+ return {
75
+ status: 'error',
76
+ message: `Verification error: ${(0, core_1.getErrorMessage)(err)}`,
77
+ signer: signature.signed_by,
78
+ keyId: signature.key_id,
79
+ publicKey: signature.public_key,
80
+ isTrusted,
81
+ trustedAs,
82
+ };
83
+ }
84
+ }
85
+ //# sourceMappingURL=signatureVerifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatureVerifier.js","sourceRoot":"","sources":["../../src/parsers/signatureVerifier.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAcH,gDA8EC;AA1FD,2CAM0B;AAC1B,4CAAyC;AAEzC;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,IAAY,EACZ,WAA+B,EAC/B,eAAwB;IAExB,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IAExC,uBAAuB;IACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,eAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QAC7C,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,sDAAsD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C;YAC9D,OAAO;gBACL,MAAM,EAAE,gBAAgB;gBACxB,OAAO,EAAE,gDAAgD;gBACzD,MAAM,EAAE,SAAS,CAAC,SAAS;gBAC3B,KAAK,EAAE,SAAS,CAAC,MAAM;gBACvB,SAAS,EAAE,SAAS,CAAC,UAAU;gBAC/B,SAAS,EAAE,KAAK;aACjB,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,eAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE;YAC3C,KAAK,EAAE,IAAA,sBAAe,EAAC,GAAG,CAAC;SAC5B,CAAC,CAAC;QACH,OAAO;YACL,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,uBAAuB,IAAA,sBAAe,EAAC,GAAG,CAAC,EAAE;YACtD,MAAM,EAAE,SAAS,CAAC,SAAS;YAC3B,KAAK,EAAE,SAAS,CAAC,MAAM;YACvB,SAAS,EAAE,SAAS,CAAC,UAAU;YAC/B,SAAS;YACT,SAAS;SACV,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * dossier://concept resource
3
+ * Provides an introduction to the dossier concept (condensed README.md)
4
+ */
5
+ /** Get condensed concept/introduction from README.md */
6
+ export declare const getConceptResource: () => string;
7
+ //# sourceMappingURL=concept.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concept.d.ts","sourceRoot":"","sources":["../../src/resources/concept.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,cAA+C,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * dossier://concept resource
4
+ * Provides an introduction to the dossier concept (condensed README.md)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getConceptResource = void 0;
8
+ const resourceLoader_1 = require("../utils/resourceLoader");
9
+ /** Get condensed concept/introduction from README.md */
10
+ exports.getConceptResource = (0, resourceLoader_1.createResourceLoader)('README.md', 'concept');
11
+ //# sourceMappingURL=concept.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concept.js","sourceRoot":"","sources":["../../src/resources/concept.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA+D;AAE/D,wDAAwD;AAC3C,QAAA,kBAAkB,GAAG,IAAA,qCAAoB,EAAC,WAAW,EAAE,SAAS,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * dossier://protocol resource
3
+ * Provides the Dossier Execution Protocol to LLM context
4
+ */
5
+ /** Get PROTOCOL.md content */
6
+ export declare const getProtocolResource: () => string;
7
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/resources/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,8BAA8B;AAC9B,eAAO,MAAM,mBAAmB,cAAkD,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * dossier://protocol resource
4
+ * Provides the Dossier Execution Protocol to LLM context
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getProtocolResource = void 0;
8
+ const resourceLoader_1 = require("../utils/resourceLoader");
9
+ /** Get PROTOCOL.md content */
10
+ exports.getProtocolResource = (0, resourceLoader_1.createResourceLoader)('PROTOCOL.md', 'protocol');
11
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/resources/protocol.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA+D;AAE/D,8BAA8B;AACjB,QAAA,mBAAmB,GAAG,IAAA,qCAAoB,EAAC,aAAa,EAAE,UAAU,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * dossier://security resource
3
+ * Provides the Security Architecture documentation to LLM context
4
+ */
5
+ /** Get security/ARCHITECTURE.md content */
6
+ export declare const getSecurityResource: () => string;
7
+ //# sourceMappingURL=security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/resources/security.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,2CAA2C;AAC3C,eAAO,MAAM,mBAAmB,cAA+D,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * dossier://security resource
4
+ * Provides the Security Architecture documentation to LLM context
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getSecurityResource = void 0;
8
+ const resourceLoader_1 = require("../utils/resourceLoader");
9
+ /** Get security/ARCHITECTURE.md content */
10
+ exports.getSecurityResource = (0, resourceLoader_1.createResourceLoader)('security/ARCHITECTURE.md', 'security');
11
+ //# sourceMappingURL=security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/resources/security.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA+D;AAE/D,2CAA2C;AAC9B,QAAA,mBAAmB,GAAG,IAAA,qCAAoB,EAAC,0BAA0B,EAAE,UAAU,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * list_dossiers tool - Discover dossiers in a directory
3
+ * Scans for *.ds.md files and returns metadata
4
+ */
5
+ import { type DossierListItem } from '@ai-dossier/core';
6
+ export interface ListDossiersInput {
7
+ path?: string;
8
+ recursive?: boolean;
9
+ }
10
+ export interface ListDossiersOutput {
11
+ dossiers: DossierListItem[];
12
+ scannedPath: string;
13
+ count: number;
14
+ }
15
+ /**
16
+ * List all dossiers in a directory
17
+ */
18
+ export declare function listDossiers(input: ListDossiersInput): ListDossiersOutput;
19
+ //# sourceMappingURL=listDossiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listDossiers.d.ts","sourceRoot":"","sources":["../../src/tools/listDossiers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,eAAe,EAAqC,MAAM,kBAAkB,CAAC;AAG3F,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAyCD;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,CA4DzE"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ /**
3
+ * list_dossiers tool - Discover dossiers in a directory
4
+ * Scans for *.ds.md files and returns metadata
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.listDossiers = listDossiers;
8
+ const node_fs_1 = require("node:fs");
9
+ const node_path_1 = require("node:path");
10
+ const core_1 = require("@ai-dossier/core");
11
+ const logger_1 = require("../utils/logger");
12
+ /**
13
+ * Recursively find all .ds.md files in a directory
14
+ */
15
+ function findDossierFiles(dir, basePath, recursive) {
16
+ const files = [];
17
+ try {
18
+ const entries = (0, node_fs_1.readdirSync)(dir);
19
+ for (const entry of entries) {
20
+ const fullPath = (0, node_path_1.join)(dir, entry);
21
+ try {
22
+ const stat = (0, node_fs_1.statSync)(fullPath);
23
+ if (stat.isDirectory()) {
24
+ // Skip node_modules, .git, etc.
25
+ if (entry.startsWith('.') || entry === 'node_modules' || entry === 'dist') {
26
+ continue;
27
+ }
28
+ if (recursive) {
29
+ files.push(...findDossierFiles(fullPath, basePath, recursive));
30
+ }
31
+ }
32
+ else if (stat.isFile() && entry.endsWith('.ds.md')) {
33
+ files.push(fullPath);
34
+ }
35
+ }
36
+ catch (err) {
37
+ // Skip files we can't stat (permission errors, etc.)
38
+ logger_1.logger.warn('Could not stat file', { path: fullPath, error: (0, core_1.getErrorMessage)(err) });
39
+ }
40
+ }
41
+ }
42
+ catch (err) {
43
+ logger_1.logger.error('Could not read directory', { dir, error: (0, core_1.getErrorMessage)(err) });
44
+ }
45
+ return files;
46
+ }
47
+ /**
48
+ * List all dossiers in a directory
49
+ */
50
+ function listDossiers(input) {
51
+ const searchPath = input.path || process.cwd();
52
+ const recursive = input.recursive !== false; // default true
53
+ // Validate path stays within the current working directory
54
+ const resolvedPath = (0, node_path_1.resolve)(searchPath);
55
+ const cwd = process.cwd();
56
+ if (!resolvedPath.startsWith(`${cwd}/`) && resolvedPath !== cwd) {
57
+ throw new Error(`Access denied: path "${searchPath}" is outside the working directory`);
58
+ }
59
+ logger_1.logger.info('Scanning for dossiers', { searchPath, recursive });
60
+ const dossierFiles = findDossierFiles(searchPath, searchPath, recursive);
61
+ const dossiers = [];
62
+ for (const filePath of dossierFiles) {
63
+ try {
64
+ const parsed = (0, core_1.parseDossierFile)(filePath);
65
+ const { frontmatter } = parsed;
66
+ // Extract name from filename (without .ds.md)
67
+ const fileName = filePath.split('/').pop();
68
+ if (!fileName)
69
+ continue;
70
+ const name = fileName.replace('.ds.md', '');
71
+ dossiers.push({
72
+ name,
73
+ path: (0, node_path_1.relative)(searchPath, filePath),
74
+ version: frontmatter.version,
75
+ protocol: frontmatter.protocol_version,
76
+ status: frontmatter.status,
77
+ objective: frontmatter.objective,
78
+ riskLevel: frontmatter.risk_level,
79
+ });
80
+ logger_1.logger.debug('Found dossier', {
81
+ name,
82
+ path: filePath,
83
+ title: frontmatter.title,
84
+ });
85
+ }
86
+ catch (err) {
87
+ logger_1.logger.warn('Could not parse dossier file', {
88
+ path: filePath,
89
+ error: (0, core_1.getErrorMessage)(err),
90
+ });
91
+ }
92
+ }
93
+ logger_1.logger.info('Dossier scan completed', {
94
+ searchPath,
95
+ count: dossiers.length,
96
+ foundFiles: dossierFiles.length,
97
+ });
98
+ return {
99
+ dossiers,
100
+ scannedPath: searchPath,
101
+ count: dossiers.length,
102
+ };
103
+ }
104
+ //# sourceMappingURL=listDossiers.js.map