stellavault 0.4.4 → 0.5.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 (265) hide show
  1. package/README.md +52 -16
  2. package/SECURITY.md +50 -0
  3. package/dist/stellavault.js +8968 -0
  4. package/package.json +70 -33
  5. package/.env.example +0 -12
  6. package/CHANGELOG.md +0 -106
  7. package/CLAUDE.md +0 -42
  8. package/CONTRIBUTING.md +0 -65
  9. package/index.html +0 -509
  10. package/packages/cli/bin/ekh.js +0 -2
  11. package/packages/cli/bin/stellavault.js +0 -2
  12. package/packages/cli/dist/commands/adr-cmd.d.ts +0 -7
  13. package/packages/cli/dist/commands/adr-cmd.js +0 -45
  14. package/packages/cli/dist/commands/ask-cmd.d.ts +0 -5
  15. package/packages/cli/dist/commands/ask-cmd.js +0 -36
  16. package/packages/cli/dist/commands/autopilot-cmd.d.ts +0 -4
  17. package/packages/cli/dist/commands/autopilot-cmd.js +0 -76
  18. package/packages/cli/dist/commands/brief-cmd.d.ts +0 -2
  19. package/packages/cli/dist/commands/brief-cmd.js +0 -82
  20. package/packages/cli/dist/commands/capture-cmd.d.ts +0 -7
  21. package/packages/cli/dist/commands/capture-cmd.js +0 -31
  22. package/packages/cli/dist/commands/card-cmd.d.ts +0 -4
  23. package/packages/cli/dist/commands/card-cmd.js +0 -26
  24. package/packages/cli/dist/commands/clip-cmd.d.ts +0 -4
  25. package/packages/cli/dist/commands/clip-cmd.js +0 -151
  26. package/packages/cli/dist/commands/cloud-cmd.d.ts +0 -4
  27. package/packages/cli/dist/commands/cloud-cmd.js +0 -64
  28. package/packages/cli/dist/commands/compile-cmd.d.ts +0 -6
  29. package/packages/cli/dist/commands/compile-cmd.js +0 -30
  30. package/packages/cli/dist/commands/contradictions-cmd.d.ts +0 -2
  31. package/packages/cli/dist/commands/contradictions-cmd.js +0 -34
  32. package/packages/cli/dist/commands/decay-cmd.d.ts +0 -2
  33. package/packages/cli/dist/commands/decay-cmd.js +0 -48
  34. package/packages/cli/dist/commands/digest-cmd.d.ts +0 -5
  35. package/packages/cli/dist/commands/digest-cmd.js +0 -136
  36. package/packages/cli/dist/commands/draft-cmd.d.ts +0 -6
  37. package/packages/cli/dist/commands/draft-cmd.js +0 -110
  38. package/packages/cli/dist/commands/duplicates-cmd.d.ts +0 -4
  39. package/packages/cli/dist/commands/duplicates-cmd.js +0 -30
  40. package/packages/cli/dist/commands/federate-cmd.d.ts +0 -5
  41. package/packages/cli/dist/commands/federate-cmd.js +0 -247
  42. package/packages/cli/dist/commands/fleeting-cmd.d.ts +0 -4
  43. package/packages/cli/dist/commands/fleeting-cmd.js +0 -45
  44. package/packages/cli/dist/commands/flush-cmd.d.ts +0 -2
  45. package/packages/cli/dist/commands/flush-cmd.js +0 -58
  46. package/packages/cli/dist/commands/gaps-cmd.d.ts +0 -2
  47. package/packages/cli/dist/commands/gaps-cmd.js +0 -33
  48. package/packages/cli/dist/commands/graph-cmd.d.ts +0 -2
  49. package/packages/cli/dist/commands/graph-cmd.js +0 -89
  50. package/packages/cli/dist/commands/index-cmd.d.ts +0 -2
  51. package/packages/cli/dist/commands/index-cmd.js +0 -57
  52. package/packages/cli/dist/commands/ingest-cmd.d.ts +0 -9
  53. package/packages/cli/dist/commands/ingest-cmd.js +0 -195
  54. package/packages/cli/dist/commands/init-cmd.d.ts +0 -2
  55. package/packages/cli/dist/commands/init-cmd.js +0 -161
  56. package/packages/cli/dist/commands/learn-cmd.d.ts +0 -2
  57. package/packages/cli/dist/commands/learn-cmd.js +0 -48
  58. package/packages/cli/dist/commands/lint-cmd.d.ts +0 -2
  59. package/packages/cli/dist/commands/lint-cmd.js +0 -61
  60. package/packages/cli/dist/commands/pack-cmd.d.ts +0 -15
  61. package/packages/cli/dist/commands/pack-cmd.js +0 -93
  62. package/packages/cli/dist/commands/review-cmd.d.ts +0 -4
  63. package/packages/cli/dist/commands/review-cmd.js +0 -107
  64. package/packages/cli/dist/commands/search-cmd.d.ts +0 -4
  65. package/packages/cli/dist/commands/search-cmd.js +0 -38
  66. package/packages/cli/dist/commands/serve-cmd.d.ts +0 -2
  67. package/packages/cli/dist/commands/serve-cmd.js +0 -14
  68. package/packages/cli/dist/commands/session-cmd.d.ts +0 -7
  69. package/packages/cli/dist/commands/session-cmd.js +0 -95
  70. package/packages/cli/dist/commands/status-cmd.d.ts +0 -2
  71. package/packages/cli/dist/commands/status-cmd.js +0 -33
  72. package/packages/cli/dist/commands/sync-cmd.d.ts +0 -5
  73. package/packages/cli/dist/commands/sync-cmd.js +0 -62
  74. package/packages/cli/dist/commands/vault-cmd.d.ts +0 -10
  75. package/packages/cli/dist/commands/vault-cmd.js +0 -54
  76. package/packages/cli/dist/index.d.ts +0 -2
  77. package/packages/cli/dist/index.js +0 -233
  78. package/packages/cli/package.json +0 -24
  79. package/packages/core/dist/api/dashboard.d.ts +0 -3
  80. package/packages/core/dist/api/dashboard.js +0 -135
  81. package/packages/core/dist/api/graph-data.d.ts +0 -11
  82. package/packages/core/dist/api/graph-data.js +0 -255
  83. package/packages/core/dist/api/pwa.d.ts +0 -3
  84. package/packages/core/dist/api/pwa.js +0 -77
  85. package/packages/core/dist/api/server.d.ts +0 -16
  86. package/packages/core/dist/api/server.js +0 -1122
  87. package/packages/core/dist/capture/voice.d.ts +0 -24
  88. package/packages/core/dist/capture/voice.js +0 -135
  89. package/packages/core/dist/cloud/index.d.ts +0 -3
  90. package/packages/core/dist/cloud/index.js +0 -2
  91. package/packages/core/dist/cloud/sync.d.ts +0 -29
  92. package/packages/core/dist/cloud/sync.js +0 -137
  93. package/packages/core/dist/config.d.ts +0 -35
  94. package/packages/core/dist/config.js +0 -63
  95. package/packages/core/dist/federation/credits.d.ts +0 -26
  96. package/packages/core/dist/federation/credits.js +0 -56
  97. package/packages/core/dist/federation/identity.d.ts +0 -14
  98. package/packages/core/dist/federation/identity.js +0 -74
  99. package/packages/core/dist/federation/index.d.ts +0 -7
  100. package/packages/core/dist/federation/index.js +0 -5
  101. package/packages/core/dist/federation/node.d.ts +0 -31
  102. package/packages/core/dist/federation/node.js +0 -216
  103. package/packages/core/dist/federation/privacy.d.ts +0 -8
  104. package/packages/core/dist/federation/privacy.js +0 -40
  105. package/packages/core/dist/federation/reputation.d.ts +0 -37
  106. package/packages/core/dist/federation/reputation.js +0 -139
  107. package/packages/core/dist/federation/search.d.ts +0 -19
  108. package/packages/core/dist/federation/search.js +0 -101
  109. package/packages/core/dist/federation/sharing.d.ts +0 -72
  110. package/packages/core/dist/federation/sharing.js +0 -246
  111. package/packages/core/dist/federation/trust.d.ts +0 -15
  112. package/packages/core/dist/federation/trust.js +0 -60
  113. package/packages/core/dist/federation/types.d.ts +0 -40
  114. package/packages/core/dist/federation/types.js +0 -3
  115. package/packages/core/dist/i18n/index.d.ts +0 -6
  116. package/packages/core/dist/i18n/index.js +0 -81
  117. package/packages/core/dist/i18n/note-strings.d.ts +0 -5
  118. package/packages/core/dist/i18n/note-strings.js +0 -94
  119. package/packages/core/dist/index.d.ts +0 -123
  120. package/packages/core/dist/index.js +0 -74
  121. package/packages/core/dist/indexer/chunker.d.ts +0 -14
  122. package/packages/core/dist/indexer/chunker.js +0 -148
  123. package/packages/core/dist/indexer/embedder.d.ts +0 -8
  124. package/packages/core/dist/indexer/embedder.js +0 -3
  125. package/packages/core/dist/indexer/index.d.ts +0 -28
  126. package/packages/core/dist/indexer/index.js +0 -74
  127. package/packages/core/dist/indexer/local-embedder.d.ts +0 -3
  128. package/packages/core/dist/indexer/local-embedder.js +0 -29
  129. package/packages/core/dist/indexer/scanner.d.ts +0 -11
  130. package/packages/core/dist/indexer/scanner.js +0 -148
  131. package/packages/core/dist/indexer/watcher.d.ts +0 -19
  132. package/packages/core/dist/indexer/watcher.js +0 -49
  133. package/packages/core/dist/intelligence/ask-engine.d.ts +0 -24
  134. package/packages/core/dist/intelligence/ask-engine.js +0 -142
  135. package/packages/core/dist/intelligence/auto-linker.d.ts +0 -19
  136. package/packages/core/dist/intelligence/auto-linker.js +0 -126
  137. package/packages/core/dist/intelligence/code-linker.d.ts +0 -20
  138. package/packages/core/dist/intelligence/code-linker.js +0 -88
  139. package/packages/core/dist/intelligence/contradiction-detector.d.ts +0 -20
  140. package/packages/core/dist/intelligence/contradiction-detector.js +0 -115
  141. package/packages/core/dist/intelligence/decay-engine.d.ts +0 -27
  142. package/packages/core/dist/intelligence/decay-engine.js +0 -190
  143. package/packages/core/dist/intelligence/draft-generator.d.ts +0 -25
  144. package/packages/core/dist/intelligence/draft-generator.js +0 -277
  145. package/packages/core/dist/intelligence/duplicate-detector.d.ts +0 -20
  146. package/packages/core/dist/intelligence/duplicate-detector.js +0 -55
  147. package/packages/core/dist/intelligence/file-extractors.d.ts +0 -13
  148. package/packages/core/dist/intelligence/file-extractors.js +0 -155
  149. package/packages/core/dist/intelligence/fsrs.d.ts +0 -43
  150. package/packages/core/dist/intelligence/fsrs.js +0 -70
  151. package/packages/core/dist/intelligence/gap-detector.d.ts +0 -25
  152. package/packages/core/dist/intelligence/gap-detector.js +0 -78
  153. package/packages/core/dist/intelligence/ingest-pipeline.d.ts +0 -32
  154. package/packages/core/dist/intelligence/ingest-pipeline.js +0 -245
  155. package/packages/core/dist/intelligence/knowledge-lint.d.ts +0 -27
  156. package/packages/core/dist/intelligence/knowledge-lint.js +0 -132
  157. package/packages/core/dist/intelligence/learning-path.d.ts +0 -31
  158. package/packages/core/dist/intelligence/learning-path.js +0 -53
  159. package/packages/core/dist/intelligence/notifications.d.ts +0 -31
  160. package/packages/core/dist/intelligence/notifications.js +0 -65
  161. package/packages/core/dist/intelligence/predictive-gaps.d.ts +0 -14
  162. package/packages/core/dist/intelligence/predictive-gaps.js +0 -74
  163. package/packages/core/dist/intelligence/semantic-versioning.d.ts +0 -37
  164. package/packages/core/dist/intelligence/semantic-versioning.js +0 -68
  165. package/packages/core/dist/intelligence/types.d.ts +0 -28
  166. package/packages/core/dist/intelligence/types.js +0 -3
  167. package/packages/core/dist/intelligence/wiki-compiler.d.ts +0 -30
  168. package/packages/core/dist/intelligence/wiki-compiler.js +0 -222
  169. package/packages/core/dist/intelligence/youtube-extractor.d.ts +0 -29
  170. package/packages/core/dist/intelligence/youtube-extractor.js +0 -321
  171. package/packages/core/dist/intelligence/zettelkasten.d.ts +0 -59
  172. package/packages/core/dist/intelligence/zettelkasten.js +0 -234
  173. package/packages/core/dist/mcp/custom-tools.d.ts +0 -29
  174. package/packages/core/dist/mcp/custom-tools.js +0 -70
  175. package/packages/core/dist/mcp/index.d.ts +0 -2
  176. package/packages/core/dist/mcp/index.js +0 -2
  177. package/packages/core/dist/mcp/server.d.ts +0 -51
  178. package/packages/core/dist/mcp/server.js +0 -174
  179. package/packages/core/dist/mcp/tools/agentic-graph.d.ts +0 -93
  180. package/packages/core/dist/mcp/tools/agentic-graph.js +0 -116
  181. package/packages/core/dist/mcp/tools/ask.d.ts +0 -29
  182. package/packages/core/dist/mcp/tools/ask.js +0 -43
  183. package/packages/core/dist/mcp/tools/brief.d.ts +0 -31
  184. package/packages/core/dist/mcp/tools/brief.js +0 -39
  185. package/packages/core/dist/mcp/tools/decay.d.ts +0 -33
  186. package/packages/core/dist/mcp/tools/decay.js +0 -32
  187. package/packages/core/dist/mcp/tools/decision-journal.d.ts +0 -78
  188. package/packages/core/dist/mcp/tools/decision-journal.js +0 -79
  189. package/packages/core/dist/mcp/tools/detect-gaps.d.ts +0 -24
  190. package/packages/core/dist/mcp/tools/detect-gaps.js +0 -47
  191. package/packages/core/dist/mcp/tools/export.d.ts +0 -29
  192. package/packages/core/dist/mcp/tools/export.js +0 -60
  193. package/packages/core/dist/mcp/tools/federated-search.d.ts +0 -29
  194. package/packages/core/dist/mcp/tools/federated-search.js +0 -36
  195. package/packages/core/dist/mcp/tools/generate-claude-md.d.ts +0 -35
  196. package/packages/core/dist/mcp/tools/generate-claude-md.js +0 -107
  197. package/packages/core/dist/mcp/tools/generate-draft.d.ts +0 -34
  198. package/packages/core/dist/mcp/tools/generate-draft.js +0 -120
  199. package/packages/core/dist/mcp/tools/get-document.d.ts +0 -35
  200. package/packages/core/dist/mcp/tools/get-document.js +0 -25
  201. package/packages/core/dist/mcp/tools/get-evolution.d.ts +0 -28
  202. package/packages/core/dist/mcp/tools/get-evolution.js +0 -70
  203. package/packages/core/dist/mcp/tools/get-related.d.ts +0 -32
  204. package/packages/core/dist/mcp/tools/get-related.js +0 -33
  205. package/packages/core/dist/mcp/tools/learning-path.d.ts +0 -23
  206. package/packages/core/dist/mcp/tools/learning-path.js +0 -45
  207. package/packages/core/dist/mcp/tools/link-code.d.ts +0 -34
  208. package/packages/core/dist/mcp/tools/link-code.js +0 -44
  209. package/packages/core/dist/mcp/tools/list-topics.d.ts +0 -15
  210. package/packages/core/dist/mcp/tools/list-topics.js +0 -18
  211. package/packages/core/dist/mcp/tools/search.d.ts +0 -39
  212. package/packages/core/dist/mcp/tools/search.js +0 -29
  213. package/packages/core/dist/mcp/tools/snapshot.d.ts +0 -47
  214. package/packages/core/dist/mcp/tools/snapshot.js +0 -84
  215. package/packages/core/dist/multi-vault/index.d.ts +0 -26
  216. package/packages/core/dist/multi-vault/index.js +0 -80
  217. package/packages/core/dist/pack/creator.d.ts +0 -21
  218. package/packages/core/dist/pack/creator.js +0 -105
  219. package/packages/core/dist/pack/exporter.d.ts +0 -4
  220. package/packages/core/dist/pack/exporter.js +0 -18
  221. package/packages/core/dist/pack/importer.d.ts +0 -10
  222. package/packages/core/dist/pack/importer.js +0 -55
  223. package/packages/core/dist/pack/index.d.ts +0 -6
  224. package/packages/core/dist/pack/index.js +0 -5
  225. package/packages/core/dist/pack/marketplace.d.ts +0 -14
  226. package/packages/core/dist/pack/marketplace.js +0 -90
  227. package/packages/core/dist/pack/pii-masker.d.ts +0 -7
  228. package/packages/core/dist/pack/pii-masker.js +0 -29
  229. package/packages/core/dist/pack/types.d.ts +0 -36
  230. package/packages/core/dist/pack/types.js +0 -3
  231. package/packages/core/dist/plugins/index.d.ts +0 -35
  232. package/packages/core/dist/plugins/index.js +0 -57
  233. package/packages/core/dist/plugins/webhooks.d.ts +0 -30
  234. package/packages/core/dist/plugins/webhooks.js +0 -79
  235. package/packages/core/dist/search/adaptive.d.ts +0 -16
  236. package/packages/core/dist/search/adaptive.js +0 -67
  237. package/packages/core/dist/search/bm25.d.ts +0 -4
  238. package/packages/core/dist/search/bm25.js +0 -10
  239. package/packages/core/dist/search/index.d.ts +0 -15
  240. package/packages/core/dist/search/index.js +0 -64
  241. package/packages/core/dist/search/rrf.d.ts +0 -7
  242. package/packages/core/dist/search/rrf.js +0 -21
  243. package/packages/core/dist/search/semantic.d.ts +0 -5
  244. package/packages/core/dist/search/semantic.js +0 -6
  245. package/packages/core/dist/store/index.d.ts +0 -3
  246. package/packages/core/dist/store/index.js +0 -2
  247. package/packages/core/dist/store/sqlite-vec.d.ts +0 -6
  248. package/packages/core/dist/store/sqlite-vec.js +0 -251
  249. package/packages/core/dist/store/types.d.ts +0 -20
  250. package/packages/core/dist/store/types.js +0 -3
  251. package/packages/core/dist/team/index.d.ts +0 -25
  252. package/packages/core/dist/team/index.js +0 -97
  253. package/packages/core/dist/types/chunk.d.ts +0 -23
  254. package/packages/core/dist/types/chunk.js +0 -3
  255. package/packages/core/dist/types/document.d.ts +0 -23
  256. package/packages/core/dist/types/document.js +0 -3
  257. package/packages/core/dist/types/graph.d.ts +0 -39
  258. package/packages/core/dist/types/graph.js +0 -3
  259. package/packages/core/dist/types/index.d.ts +0 -5
  260. package/packages/core/dist/types/index.js +0 -2
  261. package/packages/core/dist/types/search.d.ts +0 -39
  262. package/packages/core/dist/types/search.js +0 -3
  263. package/packages/core/dist/utils/retry.d.ts +0 -25
  264. package/packages/core/dist/utils/retry.js +0 -59
  265. package/packages/core/package.json +0 -67
@@ -1,70 +0,0 @@
1
- // Custom MCP Tool Builder (F-A16)
2
- // Load YAML/JSON tool definitions without coding
3
- import { readFileSync, existsSync, readdirSync } from 'node:fs';
4
- import { join } from 'node:path';
5
- export function loadCustomTools(toolsDir, searchEngine) {
6
- if (!existsSync(toolsDir))
7
- return [];
8
- const tools = [];
9
- const files = readdirSync(toolsDir).filter(f => f.endsWith('.json') || f.endsWith('.yaml') || f.endsWith('.yml'));
10
- for (const file of files) {
11
- try {
12
- const raw = readFileSync(join(toolsDir, file), 'utf-8');
13
- let def;
14
- if (file.endsWith('.json')) {
15
- def = JSON.parse(raw);
16
- }
17
- else {
18
- // Simple YAML parser for basic key:value format
19
- def = parseSimpleYaml(raw);
20
- }
21
- if (!def.name || !def.description || !def.query_template)
22
- continue;
23
- // Extract template variables ({{var}})
24
- const vars = [...def.query_template.matchAll(/\{\{(\w+)\}\}/g)].map(m => m[1]);
25
- tools.push({
26
- name: def.name,
27
- description: def.description,
28
- inputSchema: {
29
- type: 'object',
30
- properties: Object.fromEntries(vars.map(v => [v, { type: 'string', description: `Value for ${v}` }])),
31
- required: vars,
32
- },
33
- handler: async (args) => {
34
- let query = def.query_template;
35
- for (const [key, val] of Object.entries(args)) {
36
- query = query.replace(`{{${key}}}`, String(val));
37
- }
38
- const results = await searchEngine.search({ query, limit: def.limit ?? 5 });
39
- const format = def.output_format ?? 'snippets';
40
- let text;
41
- if (format === 'titles') {
42
- text = results.map(r => `- ${r.document.title}`).join('\n');
43
- }
44
- else if (format === 'full') {
45
- text = results.map(r => `## ${r.document.title}\n\n${r.document.content.slice(0, 1000)}`).join('\n\n---\n\n');
46
- }
47
- else {
48
- text = results.map(r => `**${r.document.title}** (${Math.round(r.score * 100)}%)\n${r.chunk.content.slice(0, 200)}...`).join('\n\n');
49
- }
50
- return { content: [{ type: 'text', text: text || 'No results found.' }] };
51
- },
52
- });
53
- }
54
- catch {
55
- // Skip invalid tool files
56
- }
57
- }
58
- return tools;
59
- }
60
- function parseSimpleYaml(raw) {
61
- const result = {};
62
- for (const line of raw.split('\n')) {
63
- const match = line.match(/^(\w[\w_]*)\s*:\s*(.+)$/);
64
- if (match) {
65
- result[match[1]] = match[2].replace(/^["']|["']$/g, '').trim();
66
- }
67
- }
68
- return result;
69
- }
70
- //# sourceMappingURL=custom-tools.js.map
@@ -1,2 +0,0 @@
1
- export { createMcpServer, type McpServerOptions } from './server.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +0,0 @@
1
- export { createMcpServer } from './server.js';
2
- //# sourceMappingURL=index.js.map
@@ -1,51 +0,0 @@
1
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
- import type { VectorStore } from '../store/types.js';
3
- import type { SearchEngine } from '../search/index.js';
4
- import type { Embedder } from '../indexer/embedder.js';
5
- import type { DecayEngine } from '../intelligence/decay-engine.js';
6
- export interface McpServerOptions {
7
- store: VectorStore;
8
- searchEngine: SearchEngine;
9
- embedder?: Embedder;
10
- vaultPath?: string;
11
- decayEngine?: DecayEngine;
12
- }
13
- export declare function createMcpServer(options: McpServerOptions): {
14
- startStdio(): Promise<void>;
15
- startHttp(port?: number): Promise<void>;
16
- server: Server<{
17
- method: string;
18
- params?: {
19
- [x: string]: unknown;
20
- _meta?: {
21
- [x: string]: unknown;
22
- progressToken?: string | number | undefined;
23
- "io.modelcontextprotocol/related-task"?: {
24
- taskId: string;
25
- } | undefined;
26
- } | undefined;
27
- } | undefined;
28
- }, {
29
- method: string;
30
- params?: {
31
- [x: string]: unknown;
32
- _meta?: {
33
- [x: string]: unknown;
34
- progressToken?: string | number | undefined;
35
- "io.modelcontextprotocol/related-task"?: {
36
- taskId: string;
37
- } | undefined;
38
- } | undefined;
39
- } | undefined;
40
- }, {
41
- [x: string]: unknown;
42
- _meta?: {
43
- [x: string]: unknown;
44
- progressToken?: string | number | undefined;
45
- "io.modelcontextprotocol/related-task"?: {
46
- taskId: string;
47
- } | undefined;
48
- } | undefined;
49
- }>;
50
- };
51
- //# sourceMappingURL=server.d.ts.map
@@ -1,174 +0,0 @@
1
- // Design Ref: §4.1 — MCP Server (stdio + SSE)
2
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
- import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
5
- import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
6
- import { searchToolDef, handleSearch } from './tools/search.js';
7
- import { getDocumentToolDef, handleGetDocument } from './tools/get-document.js';
8
- import { listTopicsToolDef, handleListTopics } from './tools/list-topics.js';
9
- import { getRelatedToolDef, handleGetRelated } from './tools/get-related.js';
10
- import { generateClaudeMdToolDef, handleGenerateClaudeMd } from './tools/generate-claude-md.js';
11
- import { createSnapshotToolDef, loadSnapshotToolDef, handleCreateSnapshot, handleLoadSnapshot } from './tools/snapshot.js';
12
- import { logDecisionToolDef, findDecisionsToolDef, handleLogDecision, handleFindDecisions } from './tools/decision-journal.js';
13
- import { exportToolDef, handleExport } from './tools/export.js';
14
- import { getDecayStatusToolDef, handleGetDecayStatus } from './tools/decay.js';
15
- import { getMorningBriefToolDef, handleGetMorningBrief } from './tools/brief.js';
16
- import { createLearningPathTool } from './tools/learning-path.js';
17
- import { createDetectGapsTool } from './tools/detect-gaps.js';
18
- import { createGetEvolutionTool } from './tools/get-evolution.js';
19
- import { createLinkCodeTool } from './tools/link-code.js';
20
- import { createAskTool } from './tools/ask.js';
21
- import { createGenerateDraftTool } from './tools/generate-draft.js';
22
- import { createAgenticGraphTools } from './tools/agentic-graph.js';
23
- export function createMcpServer(options) {
24
- const { store, searchEngine, embedder, vaultPath = '', decayEngine } = options;
25
- const learningPathTool = createLearningPathTool(store);
26
- const detectGapsTool = createDetectGapsTool(store);
27
- const getEvolutionTool = createGetEvolutionTool(store);
28
- const linkCodeTool = createLinkCodeTool(searchEngine);
29
- const askTool = createAskTool(searchEngine, vaultPath);
30
- const generateDraftTool = createGenerateDraftTool(searchEngine, vaultPath);
31
- const agenticTools = embedder ? createAgenticGraphTools(store, embedder, vaultPath) : [];
32
- const server = new Server({ name: 'stellavault', version: '0.2.0' }, { capabilities: { tools: {} } });
33
- // List tools
34
- server.setRequestHandler(ListToolsRequestSchema, async () => ({
35
- tools: [
36
- searchToolDef, getDocumentToolDef, listTopicsToolDef, getRelatedToolDef,
37
- generateClaudeMdToolDef, createSnapshotToolDef, loadSnapshotToolDef,
38
- logDecisionToolDef, findDecisionsToolDef, exportToolDef,
39
- ...(decayEngine ? [getDecayStatusToolDef, getMorningBriefToolDef] : []),
40
- { name: learningPathTool.name, description: learningPathTool.description, inputSchema: learningPathTool.inputSchema },
41
- { name: detectGapsTool.name, description: detectGapsTool.description, inputSchema: detectGapsTool.inputSchema },
42
- { name: getEvolutionTool.name, description: getEvolutionTool.description, inputSchema: getEvolutionTool.inputSchema },
43
- { name: linkCodeTool.name, description: linkCodeTool.description, inputSchema: linkCodeTool.inputSchema },
44
- { name: askTool.name, description: askTool.description, inputSchema: askTool.inputSchema },
45
- { name: generateDraftTool.name, description: generateDraftTool.description, inputSchema: generateDraftTool.inputSchema },
46
- ...agenticTools.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),
47
- ],
48
- }));
49
- // Call tool
50
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
51
- const { name, arguments: args } = request.params;
52
- try {
53
- let result;
54
- switch (name) {
55
- case 'search':
56
- result = await handleSearch(searchEngine, args);
57
- // MCP 검색 이벤트 기록
58
- if (decayEngine && result && typeof result === 'object' && 'results' in result) {
59
- const now = new Date().toISOString();
60
- for (const r of result.results ?? []) {
61
- if (r.documentId)
62
- decayEngine.recordAccess({ documentId: r.documentId, type: 'mcp_query', timestamp: now }).catch(() => { });
63
- }
64
- }
65
- break;
66
- case 'get-document':
67
- result = await handleGetDocument(store, args);
68
- // MCP 문서 조회 이벤트 기록
69
- if (decayEngine && result && typeof result === 'object' && 'id' in result) {
70
- decayEngine.recordAccess({ documentId: result.id, type: 'mcp_query', timestamp: new Date().toISOString() }).catch(() => { });
71
- }
72
- break;
73
- case 'list-topics':
74
- result = await handleListTopics(store);
75
- break;
76
- case 'get-related':
77
- result = await handleGetRelated(store, searchEngine, args);
78
- break;
79
- case 'generate-claude-md':
80
- result = await handleGenerateClaudeMd(searchEngine, store, args);
81
- break;
82
- case 'create-snapshot':
83
- result = await handleCreateSnapshot(searchEngine, args);
84
- break;
85
- case 'load-snapshot':
86
- result = await handleLoadSnapshot(args);
87
- break;
88
- case 'log-decision':
89
- result = await handleLogDecision(vaultPath, args);
90
- break;
91
- case 'find-decisions':
92
- result = await handleFindDecisions(vaultPath, args);
93
- break;
94
- case 'export':
95
- result = await handleExport(store, args);
96
- break;
97
- case 'get-decay-status':
98
- if (!decayEngine) {
99
- result = { error: 'Decay engine not available' };
100
- break;
101
- }
102
- result = await handleGetDecayStatus(decayEngine, args);
103
- break;
104
- case 'get-morning-brief':
105
- if (!decayEngine) {
106
- result = { error: 'Decay engine not available' };
107
- break;
108
- }
109
- result = await handleGetMorningBrief(decayEngine, store);
110
- break;
111
- case 'get-learning-path':
112
- result = await learningPathTool.handler(args);
113
- return result;
114
- case 'detect-gaps':
115
- result = await detectGapsTool.handler(args);
116
- return result;
117
- case 'get-evolution':
118
- result = await getEvolutionTool.handler(args);
119
- return result;
120
- case 'link-code':
121
- result = await linkCodeTool.handler(args);
122
- return result;
123
- case 'ask':
124
- result = await askTool.handler(args);
125
- return result;
126
- case 'generate-draft':
127
- result = await generateDraftTool.handler(args);
128
- return result;
129
- default:
130
- {
131
- // Agentic graph tools (create-knowledge-node, create-knowledge-link)
132
- const agenticTool = agenticTools.find(t => t.name === name);
133
- if (agenticTool) {
134
- result = await agenticTool.handler(args);
135
- return result;
136
- }
137
- }
138
- return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
139
- }
140
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
141
- }
142
- catch (err) {
143
- const msg = err instanceof Error ? err.message : String(err);
144
- return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
145
- }
146
- });
147
- return {
148
- async startStdio() {
149
- const transport = new StdioServerTransport();
150
- await server.connect(transport);
151
- },
152
- async startHttp(port = 3334) {
153
- const { createServer } = await import('node:http');
154
- const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => `sv-${Date.now()}` });
155
- await server.connect(transport);
156
- const httpServer = createServer(async (req, res) => {
157
- res.setHeader('Access-Control-Allow-Origin', '*');
158
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
159
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
160
- if (req.method === 'OPTIONS') {
161
- res.writeHead(204);
162
- res.end();
163
- return;
164
- }
165
- await transport.handleRequest(req, res);
166
- });
167
- httpServer.listen(port, '127.0.0.1', () => {
168
- console.error(`🔌 MCP HTTP server running at http://127.0.0.1:${port}/mcp`);
169
- });
170
- },
171
- server,
172
- };
173
- }
174
- //# sourceMappingURL=server.js.map
@@ -1,93 +0,0 @@
1
- import type { VectorStore } from '../../store/types.js';
2
- import type { Embedder } from '../../indexer/embedder.js';
3
- export declare function createAgenticGraphTools(store: VectorStore, embedder: Embedder, vaultPath: string): ({
4
- name: string;
5
- description: string;
6
- inputSchema: {
7
- type: "object";
8
- properties: {
9
- title: {
10
- type: string;
11
- description: string;
12
- };
13
- content: {
14
- type: string;
15
- description: string;
16
- };
17
- tags: {
18
- type: string;
19
- items: {
20
- type: string;
21
- };
22
- description: string;
23
- };
24
- type: {
25
- type: string;
26
- description: string;
27
- };
28
- folder: {
29
- type: string;
30
- description: string;
31
- };
32
- autoLink: {
33
- type: string;
34
- description: string;
35
- };
36
- sourceTitle?: undefined;
37
- targetTitle?: undefined;
38
- context?: undefined;
39
- };
40
- required: string[];
41
- };
42
- handler(args: {
43
- title: string;
44
- content: string;
45
- tags?: string[];
46
- type?: string;
47
- folder?: string;
48
- autoLink?: boolean;
49
- }): Promise<{
50
- content: {
51
- type: "text";
52
- text: string;
53
- }[];
54
- }>;
55
- } | {
56
- name: string;
57
- description: string;
58
- inputSchema: {
59
- type: "object";
60
- properties: {
61
- sourceTitle: {
62
- type: string;
63
- description: string;
64
- };
65
- targetTitle: {
66
- type: string;
67
- description: string;
68
- };
69
- context: {
70
- type: string;
71
- description: string;
72
- };
73
- title?: undefined;
74
- content?: undefined;
75
- tags?: undefined;
76
- type?: undefined;
77
- folder?: undefined;
78
- autoLink?: undefined;
79
- };
80
- required: string[];
81
- };
82
- handler(args: {
83
- sourceTitle: string;
84
- targetTitle: string;
85
- context?: string;
86
- }): Promise<{
87
- content: {
88
- type: "text";
89
- text: string;
90
- }[];
91
- }>;
92
- })[];
93
- //# sourceMappingURL=agentic-graph.d.ts.map
@@ -1,116 +0,0 @@
1
- // Agentic Graph Construction (P3-F23)
2
- // AI가 MCP 세션 중 실시간으로 그래프 노드/엣지 생성
3
- import { writeFileSync, mkdirSync } from 'node:fs';
4
- import { join } from 'node:path';
5
- export function createAgenticGraphTools(store, embedder, vaultPath) {
6
- return [
7
- {
8
- name: 'create-knowledge-node',
9
- description: 'Create a wiki-quality knowledge note in the vault. Auto-finds related documents, generates backlinks, and adds concept tags. The note is saved with proper frontmatter and cross-references.',
10
- inputSchema: {
11
- type: 'object',
12
- properties: {
13
- title: { type: 'string', description: 'Note title' },
14
- content: { type: 'string', description: 'Note content (markdown)' },
15
- tags: { type: 'array', items: { type: 'string' }, description: 'Tags for categorization' },
16
- type: { type: 'string', description: 'Note type: note, decision, insight, summary, wiki' },
17
- folder: { type: 'string', description: 'Vault subfolder (default: 01_Knowledge)' },
18
- autoLink: { type: 'boolean', description: 'Auto-discover and add links to related notes (default: true)' },
19
- },
20
- required: ['title', 'content'],
21
- },
22
- async handler(args) {
23
- const { title, content, tags = [], type = 'note', folder = '01_Knowledge', autoLink = true } = args;
24
- // 관련 문서 자동 탐색
25
- let relatedSection = '';
26
- if (autoLink) {
27
- try {
28
- const docs = await store.getAllDocuments();
29
- const titleWords = title.toLowerCase().split(/\s+/).filter(w => w.length > 3);
30
- const related = docs
31
- .filter(d => {
32
- const dTitle = d.title.toLowerCase();
33
- return titleWords.some(w => dTitle.includes(w)) ||
34
- tags.some(t => d.tags.includes(t));
35
- })
36
- .slice(0, 5);
37
- if (related.length > 0) {
38
- relatedSection = '\n\n## Related Notes\n' +
39
- related.map(r => `- [[${r.title}]]`).join('\n') +
40
- '\n';
41
- }
42
- }
43
- catch { /* skip auto-link on error */ }
44
- }
45
- // frontmatter 생성
46
- const date = new Date().toISOString().slice(0, 10);
47
- const fm = [
48
- '---',
49
- `title: "${title}"`,
50
- `type: ${type}`,
51
- `source: agent`,
52
- `tags: [${tags.map(t => `"${t}"`).join(', ')}]`,
53
- `created: ${date}`,
54
- `auto_generated: true`,
55
- '---',
56
- ].join('\n');
57
- const fullContent = `${fm}\n\n# ${title}\n\n${content}${relatedSection}`;
58
- // vault에 파일 저장 (path traversal 방지)
59
- const safeTitle = title.replace(/[<>:"/\\|?*]/g, '').replace(/\s+/g, ' ').trim().slice(0, 80);
60
- const dir = join(vaultPath, folder);
61
- const filePath = join(dir, `${safeTitle}.md`);
62
- const resolvedPath = require('node:path').resolve(filePath);
63
- const resolvedVault = require('node:path').resolve(vaultPath);
64
- if (!resolvedPath.startsWith(resolvedVault)) {
65
- return { content: [{ type: 'text', text: 'Error: invalid folder path.' }] };
66
- }
67
- mkdirSync(dir, { recursive: true });
68
- writeFileSync(filePath, fullContent, 'utf-8');
69
- const relatedCount = relatedSection ? relatedSection.split('\n').filter(l => l.startsWith('- ')).length : 0;
70
- return {
71
- content: [{
72
- type: 'text',
73
- text: `Created wiki-quality note: "${title}" at ${folder}/${safeTitle}.md\nTags: ${tags.join(', ') || 'none'}\nType: ${type}\nAuto-linked: ${relatedCount} related notes\n\nThe note will appear in the graph after next index.`,
74
- }],
75
- };
76
- },
77
- },
78
- {
79
- name: 'create-knowledge-link',
80
- description: 'Create a link between two existing notes by adding a wiki-link reference. Strengthens connections in the knowledge graph.',
81
- inputSchema: {
82
- type: 'object',
83
- properties: {
84
- sourceTitle: { type: 'string', description: 'Title of the source note' },
85
- targetTitle: { type: 'string', description: 'Title of the target note to link to' },
86
- context: { type: 'string', description: 'Why these notes are related (added as a comment)' },
87
- },
88
- required: ['sourceTitle', 'targetTitle'],
89
- },
90
- async handler(args) {
91
- const docs = await store.getAllDocuments();
92
- const source = docs.find(d => d.title.toLowerCase().includes(args.sourceTitle.toLowerCase()));
93
- if (!source) {
94
- return { content: [{ type: 'text', text: `Source note "${args.sourceTitle}" not found.` }] };
95
- }
96
- // 소스 노트에 링크 추가
97
- const { readFileSync } = await import('node:fs');
98
- const fullPath = join(vaultPath, source.filePath);
99
- let existing = '';
100
- try {
101
- existing = readFileSync(fullPath, 'utf-8');
102
- }
103
- catch { /* new file */ }
104
- const linkSection = `\n\n## Related\n\n- [[${args.targetTitle}]]${args.context ? ` — ${args.context}` : ''}\n`;
105
- writeFileSync(fullPath, existing + linkSection, 'utf-8');
106
- return {
107
- content: [{
108
- type: 'text',
109
- text: `Linked "${source.title}" → "${args.targetTitle}"${args.context ? ` (${args.context})` : ''}`,
110
- }],
111
- };
112
- },
113
- },
114
- ];
115
- }
116
- //# sourceMappingURL=agentic-graph.js.map
@@ -1,29 +0,0 @@
1
- import type { SearchEngine } from '../../search/index.js';
2
- export declare function createAskTool(searchEngine: SearchEngine, vaultPath: string): {
3
- name: string;
4
- description: string;
5
- inputSchema: {
6
- type: "object";
7
- properties: {
8
- question: {
9
- type: "string";
10
- description: string;
11
- };
12
- save: {
13
- type: "boolean";
14
- description: string;
15
- };
16
- };
17
- required: readonly ["question"];
18
- };
19
- handler: (args: {
20
- question: string;
21
- save?: boolean;
22
- }) => Promise<{
23
- content: {
24
- type: "text";
25
- text: string;
26
- }[];
27
- }>;
28
- };
29
- //# sourceMappingURL=ask.d.ts.map
@@ -1,43 +0,0 @@
1
- // MCP Tool: ask — Q&A with auto-filing to vault
2
- import { askVault } from '../../intelligence/ask-engine.js';
3
- export function createAskTool(searchEngine, vaultPath) {
4
- return {
5
- name: 'ask',
6
- description: 'Ask a question about your knowledge base. Searches vault using hybrid AI search (BM25 + vector + RRF), returns structured results with sources. Use the results to compose your own AI-powered answer. Optionally saves as a new note.',
7
- inputSchema: {
8
- type: 'object',
9
- properties: {
10
- question: {
11
- type: 'string',
12
- description: 'The question to ask about your knowledge',
13
- },
14
- save: {
15
- type: 'boolean',
16
- description: 'Save the answer as a new note in the vault (default: false)',
17
- },
18
- },
19
- required: ['question'],
20
- },
21
- handler: async (args) => {
22
- const result = await askVault(searchEngine, args.question, {
23
- limit: 10,
24
- save: args.save ?? false,
25
- vaultPath,
26
- });
27
- const sourceList = result.sources.slice(0, 5).map((s, i) => `${i + 1}. **${s.title}** (score: ${s.score})\n > ${s.snippet.slice(0, 120)}...`).join('\n');
28
- const text = [
29
- result.answer,
30
- '',
31
- '---',
32
- `### Sources (${result.sources.length} documents)`,
33
- sourceList,
34
- '',
35
- result.savedTo ? `Saved to: ${result.savedTo}` : '',
36
- ].filter(Boolean).join('\n');
37
- return {
38
- content: [{ type: 'text', text }],
39
- };
40
- },
41
- };
42
- }
43
- //# sourceMappingURL=ask.js.map
@@ -1,31 +0,0 @@
1
- import type { DecayEngine } from '../../intelligence/decay-engine.js';
2
- import type { VectorStore } from '../../store/types.js';
3
- export declare const getMorningBriefToolDef: {
4
- name: string;
5
- description: string;
6
- inputSchema: {
7
- type: "object";
8
- properties: {};
9
- };
10
- };
11
- export declare function handleGetMorningBrief(decayEngine: DecayEngine, store: VectorStore): Promise<{
12
- greeting: string;
13
- summary: {
14
- totalDocs: number;
15
- averageR: number;
16
- decaying: number;
17
- critical: number;
18
- };
19
- reviewSuggestions: {
20
- title: string;
21
- retrievability: number;
22
- daysSinceAccess: number;
23
- }[];
24
- unhealthyClusters: {
25
- label: string;
26
- avgR: number;
27
- count: number;
28
- }[];
29
- tip: string;
30
- }>;
31
- //# sourceMappingURL=brief.d.ts.map
@@ -1,39 +0,0 @@
1
- // MCP tool: get-morning-brief — Claude 세션 시작 시 자동 브리핑
2
- export const getMorningBriefToolDef = {
3
- name: 'get-morning-brief',
4
- description: '오늘의 지식 브리핑을 제공합니다. 감쇠 상태, 리뷰 대상, 최근 활동을 요약합니다. 세션 시작 시 호출하면 유용합니다.',
5
- inputSchema: {
6
- type: 'object',
7
- properties: {},
8
- },
9
- };
10
- export async function handleGetMorningBrief(decayEngine, store) {
11
- const stats = await store.getStats();
12
- const report = await decayEngine.computeAll();
13
- const reviewList = report.topDecaying.slice(0, 5).map(d => ({
14
- title: d.title,
15
- retrievability: Math.round(d.retrievability * 100) / 100,
16
- daysSinceAccess: d.daysSinceAccess,
17
- }));
18
- const unhealthyClusters = report.clusterHealth
19
- .filter(c => c.avgR < 0.6)
20
- .slice(0, 3)
21
- .map(c => ({ label: c.label, avgR: c.avgR, count: c.count }));
22
- return {
23
- greeting: `📚 ${stats.documentCount}개 노트, 전체 건강도 R=${report.averageR}`,
24
- summary: {
25
- totalDocs: stats.documentCount,
26
- averageR: report.averageR,
27
- decaying: report.decayingCount,
28
- critical: report.criticalCount,
29
- },
30
- reviewSuggestions: reviewList,
31
- unhealthyClusters,
32
- tip: report.criticalCount > 0
33
- ? `⚠️ ${report.criticalCount}개 노트가 위험 수준입니다. 'stellavault review'로 리뷰하세요.`
34
- : report.decayingCount > 0
35
- ? `📋 ${report.decayingCount}개 노트가 감쇠 중입니다.`
36
- : '✨ 모든 지식이 건강합니다!',
37
- };
38
- }
39
- //# sourceMappingURL=brief.js.map