@4da/mcp-server 4.5.0 → 4.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 (155) hide show
  1. package/README.md +61 -81
  2. package/dist/db.d.ts +12 -1
  3. package/dist/db.d.ts.map +1 -1
  4. package/dist/db.js +71 -8
  5. package/dist/db.js.map +1 -1
  6. package/dist/index.d.ts +9 -14
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +12 -17
  9. package/dist/index.js.map +1 -1
  10. package/dist/schema-registry.d.ts +4 -2
  11. package/dist/schema-registry.d.ts.map +1 -1
  12. package/dist/schema-registry.js +55 -235
  13. package/dist/schema-registry.js.map +1 -1
  14. package/dist/tool-dispatch.d.ts +1 -7
  15. package/dist/tool-dispatch.d.ts.map +1 -1
  16. package/dist/tool-dispatch.js +14 -48
  17. package/dist/tool-dispatch.js.map +1 -1
  18. package/dist/tools/index.d.ts +13 -42
  19. package/dist/tools/index.d.ts.map +1 -1
  20. package/dist/tools/index.js +18 -54
  21. package/dist/tools/index.js.map +1 -1
  22. package/dist/tools/what-should-i-know.d.ts +4 -12
  23. package/dist/tools/what-should-i-know.d.ts.map +1 -1
  24. package/dist/tools/what-should-i-know.js +11 -102
  25. package/dist/tools/what-should-i-know.js.map +1 -1
  26. package/package.json +2 -2
  27. package/dist/schemas/agent-feedback-stats.json +0 -14
  28. package/dist/schemas/agent-session-brief.json +0 -25
  29. package/dist/schemas/attention-report.json +0 -13
  30. package/dist/schemas/autophagy-status.json +0 -13
  31. package/dist/schemas/compound-advantage.json +0 -14
  32. package/dist/schemas/config-validator.json +0 -18
  33. package/dist/schemas/context-analysis.json +0 -25
  34. package/dist/schemas/daily-briefing.json +0 -34
  35. package/dist/schemas/decision-windows.json +0 -22
  36. package/dist/schemas/delegation-score.json +0 -18
  37. package/dist/schemas/explain-relevance.json +0 -19
  38. package/dist/schemas/export-context.json +0 -17
  39. package/dist/schemas/llm-status.json +0 -13
  40. package/dist/schemas/preemption-feed.json +0 -18
  41. package/dist/schemas/project-health.json +0 -13
  42. package/dist/schemas/record-agent-feedback.json +0 -28
  43. package/dist/schemas/reverse-mentions.json +0 -13
  44. package/dist/schemas/score-autopsy.json +0 -30
  45. package/dist/schemas/semantic-shifts.json +0 -17
  46. package/dist/schemas/signal-chains.json +0 -19
  47. package/dist/schemas/source-health.json +0 -17
  48. package/dist/schemas/tech-radar.json +0 -23
  49. package/dist/schemas/topic-connections.json +0 -34
  50. package/dist/schemas/trend-analysis.json +0 -29
  51. package/dist/schemas/trust-summary.json +0 -13
  52. package/dist/tools/agent-feedback-stats.d.ts +0 -30
  53. package/dist/tools/agent-feedback-stats.d.ts.map +0 -1
  54. package/dist/tools/agent-feedback-stats.js +0 -41
  55. package/dist/tools/agent-feedback-stats.js.map +0 -1
  56. package/dist/tools/agent-session-brief.d.ts +0 -44
  57. package/dist/tools/agent-session-brief.d.ts.map +0 -1
  58. package/dist/tools/agent-session-brief.js +0 -179
  59. package/dist/tools/agent-session-brief.js.map +0 -1
  60. package/dist/tools/attention-report.d.ts +0 -40
  61. package/dist/tools/attention-report.d.ts.map +0 -1
  62. package/dist/tools/attention-report.js +0 -73
  63. package/dist/tools/attention-report.js.map +0 -1
  64. package/dist/tools/autophagy-status.d.ts +0 -25
  65. package/dist/tools/autophagy-status.d.ts.map +0 -1
  66. package/dist/tools/autophagy-status.js +0 -56
  67. package/dist/tools/autophagy-status.js.map +0 -1
  68. package/dist/tools/compound-advantage.d.ts +0 -30
  69. package/dist/tools/compound-advantage.d.ts.map +0 -1
  70. package/dist/tools/compound-advantage.js +0 -133
  71. package/dist/tools/compound-advantage.js.map +0 -1
  72. package/dist/tools/config-validator.d.ts +0 -59
  73. package/dist/tools/config-validator.d.ts.map +0 -1
  74. package/dist/tools/config-validator.js +0 -417
  75. package/dist/tools/config-validator.js.map +0 -1
  76. package/dist/tools/context-analysis.d.ts +0 -108
  77. package/dist/tools/context-analysis.d.ts.map +0 -1
  78. package/dist/tools/context-analysis.js +0 -301
  79. package/dist/tools/context-analysis.js.map +0 -1
  80. package/dist/tools/daily-briefing.d.ts +0 -103
  81. package/dist/tools/daily-briefing.d.ts.map +0 -1
  82. package/dist/tools/daily-briefing.js +0 -294
  83. package/dist/tools/daily-briefing.js.map +0 -1
  84. package/dist/tools/decision-windows.d.ts +0 -37
  85. package/dist/tools/decision-windows.d.ts.map +0 -1
  86. package/dist/tools/decision-windows.js +0 -67
  87. package/dist/tools/decision-windows.js.map +0 -1
  88. package/dist/tools/delegation-score.d.ts +0 -34
  89. package/dist/tools/delegation-score.d.ts.map +0 -1
  90. package/dist/tools/delegation-score.js +0 -260
  91. package/dist/tools/delegation-score.js.map +0 -1
  92. package/dist/tools/explain-relevance.d.ts +0 -36
  93. package/dist/tools/explain-relevance.d.ts.map +0 -1
  94. package/dist/tools/explain-relevance.js +0 -51
  95. package/dist/tools/explain-relevance.js.map +0 -1
  96. package/dist/tools/export-context.d.ts +0 -60
  97. package/dist/tools/export-context.d.ts.map +0 -1
  98. package/dist/tools/export-context.js +0 -179
  99. package/dist/tools/export-context.js.map +0 -1
  100. package/dist/tools/llm-status.d.ts +0 -45
  101. package/dist/tools/llm-status.d.ts.map +0 -1
  102. package/dist/tools/llm-status.js +0 -93
  103. package/dist/tools/llm-status.js.map +0 -1
  104. package/dist/tools/muse-context.d.ts +0 -195
  105. package/dist/tools/muse-context.d.ts.map +0 -1
  106. package/dist/tools/muse-context.js +0 -284
  107. package/dist/tools/muse-context.js.map +0 -1
  108. package/dist/tools/preemption-feed.d.ts +0 -55
  109. package/dist/tools/preemption-feed.d.ts.map +0 -1
  110. package/dist/tools/preemption-feed.js +0 -124
  111. package/dist/tools/preemption-feed.js.map +0 -1
  112. package/dist/tools/project-health.d.ts +0 -53
  113. package/dist/tools/project-health.d.ts.map +0 -1
  114. package/dist/tools/project-health.js +0 -122
  115. package/dist/tools/project-health.js.map +0 -1
  116. package/dist/tools/record-agent-feedback.d.ts +0 -46
  117. package/dist/tools/record-agent-feedback.d.ts.map +0 -1
  118. package/dist/tools/record-agent-feedback.js +0 -71
  119. package/dist/tools/record-agent-feedback.js.map +0 -1
  120. package/dist/tools/reverse-mentions.d.ts +0 -38
  121. package/dist/tools/reverse-mentions.d.ts.map +0 -1
  122. package/dist/tools/reverse-mentions.js +0 -75
  123. package/dist/tools/reverse-mentions.js.map +0 -1
  124. package/dist/tools/score-autopsy.d.ts +0 -93
  125. package/dist/tools/score-autopsy.d.ts.map +0 -1
  126. package/dist/tools/score-autopsy.js +0 -295
  127. package/dist/tools/score-autopsy.js.map +0 -1
  128. package/dist/tools/semantic-shifts.d.ts +0 -53
  129. package/dist/tools/semantic-shifts.d.ts.map +0 -1
  130. package/dist/tools/semantic-shifts.js +0 -74
  131. package/dist/tools/semantic-shifts.js.map +0 -1
  132. package/dist/tools/signal-chains.d.ts +0 -52
  133. package/dist/tools/signal-chains.d.ts.map +0 -1
  134. package/dist/tools/signal-chains.js +0 -63
  135. package/dist/tools/signal-chains.js.map +0 -1
  136. package/dist/tools/source-health.d.ts +0 -64
  137. package/dist/tools/source-health.d.ts.map +0 -1
  138. package/dist/tools/source-health.js +0 -205
  139. package/dist/tools/source-health.js.map +0 -1
  140. package/dist/tools/tech-radar.d.ts +0 -38
  141. package/dist/tools/tech-radar.d.ts.map +0 -1
  142. package/dist/tools/tech-radar.js +0 -249
  143. package/dist/tools/tech-radar.js.map +0 -1
  144. package/dist/tools/topic-connections.d.ts +0 -112
  145. package/dist/tools/topic-connections.d.ts.map +0 -1
  146. package/dist/tools/topic-connections.js +0 -319
  147. package/dist/tools/topic-connections.js.map +0 -1
  148. package/dist/tools/trend-analysis.d.ts +0 -105
  149. package/dist/tools/trend-analysis.d.ts.map +0 -1
  150. package/dist/tools/trend-analysis.js +0 -296
  151. package/dist/tools/trend-analysis.js.map +0 -1
  152. package/dist/tools/trust-summary.d.ts +0 -38
  153. package/dist/tools/trust-summary.d.ts.map +0 -1
  154. package/dist/tools/trust-summary.js +0 -89
  155. package/dist/tools/trust-summary.js.map +0 -1
@@ -1,295 +0,0 @@
1
- // SPDX-License-Identifier: FSL-1.1-Apache-2.0
2
- /**
3
- * Score Autopsy Tool
4
- *
5
- * Deep forensic analysis of why content scored the way it did.
6
- * This is a SUPERPOWER - it reveals the complete scoring breakdown.
7
- *
8
- * With synthesize=true, uses LLM to explain whether the score makes sense.
9
- */
10
- import { getLLMConfig, canSynthesize, synthesize, SYNTHESIS_PROMPTS } from "../llm.js";
11
- import { createScoreAutopsyCompact } from "../output-manager.js";
12
- export const scoreAutopsyTool = {
13
- name: "score_autopsy",
14
- description: `Perform a complete forensic analysis of why an item scored the way it did.
15
-
16
- With synthesize=true (recommended), uses AI to explain whether the score seems correct.
17
-
18
- Returns:
19
- - Component-by-component score breakdown
20
- - Matching context (interests, tech, topics)
21
- - Comparison with similar items
22
- - Recommendations for improving relevance
23
- - AI analysis (when enabled)
24
-
25
- Use this when you need to understand or debug relevance scores.`,
26
- inputSchema: {
27
- type: "object",
28
- properties: {
29
- item_id: {
30
- type: "number",
31
- description: "The item ID to analyze",
32
- },
33
- source_type: {
34
- type: "string",
35
- description: "Source type (e.g., 'hackernews', 'arxiv')",
36
- },
37
- compare_count: {
38
- type: "number",
39
- description: "Number of similar items to compare (default: 5)",
40
- },
41
- synthesize: {
42
- type: "boolean",
43
- description: "Use AI to analyze if the score makes sense (default: true if LLM configured)",
44
- },
45
- compact: {
46
- type: "boolean",
47
- description: "Return compact result with file reference (default: true for ~80% token reduction)",
48
- },
49
- },
50
- required: ["item_id", "source_type"],
51
- },
52
- };
53
- export async function executeScoreAutopsy(db, params) {
54
- const { item_id, source_type, compare_count = 5 } = params;
55
- const useCompact = params.compact !== false; // Default to compact=true
56
- // Check LLM availability
57
- const dbInstance = db.db;
58
- const llmConfig = getLLMConfig(dbInstance);
59
- const shouldSynthesize = params.synthesize ?? canSynthesize(llmConfig);
60
- // Get the item
61
- const item = db.getSourceItem(item_id, source_type);
62
- if (!item) {
63
- return {
64
- error: `Item ${item_id} of type ${source_type} not found`,
65
- suggestion: "Use get_relevant_content to find valid item IDs first.",
66
- };
67
- }
68
- // Get full context
69
- const context = db.getUserContext(true, true);
70
- // Get detailed explanation
71
- const explanation = db.explainRelevance(item_id, source_type);
72
- if (!explanation) {
73
- return {
74
- error: `Failed to compute relevance explanation for item ${item_id}`,
75
- suggestion: "The item may not have been scored yet. Try a different item.",
76
- };
77
- }
78
- // Calculate age
79
- const createdAt = new Date(item.created_at.replace(" ", "T") + "Z");
80
- const ageHours = Math.round((Date.now() - createdAt.getTime()) / (1000 * 60 * 60));
81
- // Build component breakdown
82
- const components = [
83
- {
84
- name: "Interest Match",
85
- raw_value: explanation.matching_context.matching_interests.length > 0 ? 0.8 : 0,
86
- weight: 0.30,
87
- contribution: explanation.score_breakdown.static_match_score * 0.5,
88
- explanation: explanation.matching_context.matching_interests.length > 0
89
- ? `Matches interests: ${explanation.matching_context.matching_interests.join(", ")}`
90
- : "No direct interest matches",
91
- },
92
- {
93
- name: "Tech Stack Match",
94
- raw_value: explanation.matching_context.matching_tech.length > 0 ? 0.7 : 0,
95
- weight: 0.20,
96
- contribution: explanation.matching_context.matching_tech.length * 0.2,
97
- explanation: explanation.matching_context.matching_tech.length > 0
98
- ? `Matches tech: ${explanation.matching_context.matching_tech.join(", ")}`
99
- : "No tech stack matches",
100
- },
101
- {
102
- name: "Active Topics (ACE)",
103
- raw_value: explanation.score_breakdown.ace_match_score,
104
- weight: 0.15,
105
- contribution: explanation.score_breakdown.ace_match_score,
106
- explanation: explanation.matching_context.matching_topics.length > 0
107
- ? `Recent work topics: ${explanation.matching_context.matching_topics.join(", ")}`
108
- : "No active topic matches",
109
- },
110
- {
111
- name: "Learned Affinities",
112
- raw_value: explanation.score_breakdown.learned_affinity_score,
113
- weight: 0.15,
114
- contribution: explanation.score_breakdown.learned_affinity_score,
115
- explanation: explanation.matching_context.matching_affinities.length > 0
116
- ? `Learned preferences: ${explanation.matching_context.matching_affinities.join(", ")}`
117
- : "No learned affinity matches",
118
- },
119
- {
120
- name: "Recency Boost",
121
- raw_value: ageHours < 24 ? 0.9 : ageHours < 72 ? 0.6 : 0.3,
122
- weight: 0.10,
123
- contribution: ageHours < 24 ? 0.09 : ageHours < 72 ? 0.06 : 0.03,
124
- explanation: ageHours < 24
125
- ? `Fresh content (${ageHours}h old)`
126
- : `Older content (${Math.round(ageHours / 24)}d old)`,
127
- },
128
- {
129
- name: "Anti-Penalty",
130
- raw_value: -explanation.score_breakdown.anti_penalty,
131
- weight: 1.0,
132
- contribution: -explanation.score_breakdown.anti_penalty,
133
- explanation: explanation.score_breakdown.anti_penalty > 0
134
- ? "Score reduced due to exclusions or anti-topics"
135
- : "No penalties applied",
136
- },
137
- ];
138
- // Get similar items for comparison
139
- const similarItems = getSimilarItems(db, item, source_type, compare_count);
140
- // Generate recommendations
141
- const recommendations = generateRecommendations(explanation.score_breakdown, explanation.matching_context, context, item);
142
- // Generate narrative explanation
143
- const narrative = generateNarrative(item, explanation.score_breakdown.final_score, explanation.matching_context, ageHours);
144
- const result = {
145
- item: {
146
- id: item.id,
147
- title: item.title,
148
- url: item.url,
149
- source_type: item.source_type,
150
- created_at: item.created_at,
151
- age_hours: ageHours,
152
- },
153
- final_score: explanation.score_breakdown.final_score,
154
- components,
155
- matching_context: {
156
- interests: explanation.matching_context.matching_interests,
157
- tech_stack: explanation.matching_context.matching_tech,
158
- active_topics: explanation.matching_context.matching_topics,
159
- learned_affinities: explanation.matching_context.matching_affinities,
160
- exclusions_hit: explanation.score_breakdown.anti_penalty > 0
161
- ? ["Exclusion or anti-topic triggered"]
162
- : [],
163
- },
164
- similar_items: similarItems,
165
- recommendations,
166
- narrative,
167
- };
168
- // AI Analysis - the actual superpower
169
- if (shouldSynthesize && canSynthesize(llmConfig)) {
170
- try {
171
- const autopsyData = {
172
- item: { title: item.title, content: item.content?.substring(0, 500) },
173
- final_score: result.final_score,
174
- components: result.components,
175
- matching_context: result.matching_context,
176
- };
177
- const contextData = {
178
- interests: context.interests.slice(0, 10),
179
- tech_stack: context.tech_stack,
180
- role: context.role,
181
- };
182
- const synthesis = await synthesize(llmConfig, {
183
- system: SYNTHESIS_PROMPTS.scoreAutopsy.system,
184
- prompt: SYNTHESIS_PROMPTS.scoreAutopsy.buildPrompt(autopsyData, contextData),
185
- max_tokens: 350,
186
- complexity: SYNTHESIS_PROMPTS.scoreAutopsy.complexity,
187
- });
188
- // Parse the synthesis to extract structured assessment
189
- const text = synthesis.synthesis.toLowerCase();
190
- let scoreAssessment = "uncertain";
191
- if (text.includes("too high") || text.includes("overscored") || text.includes("inflated")) {
192
- scoreAssessment = "too_high";
193
- }
194
- else if (text.includes("too low") || text.includes("underscored") || text.includes("should be higher")) {
195
- scoreAssessment = "too_low";
196
- }
197
- else if (text.includes("makes sense") || text.includes("accurate") || text.includes("correct") || text.includes("appropriate")) {
198
- scoreAssessment = "accurate";
199
- }
200
- result.ai_analysis = {
201
- verdict: synthesis.synthesis,
202
- score_assessment: scoreAssessment,
203
- reasoning: synthesis.synthesis.split("\n")[0] || "",
204
- suggested_action: recommendations[0] || "No specific action needed",
205
- model_used: synthesis.model_used,
206
- };
207
- }
208
- catch (error) {
209
- console.error("AI analysis failed:", error);
210
- }
211
- }
212
- // Return compact or full result based on parameter
213
- if (useCompact) {
214
- return createScoreAutopsyCompact(result);
215
- }
216
- return result;
217
- }
218
- function getSimilarItems(db, item, sourceType, count) {
219
- // Get recent items from same source to compare
220
- const recentItems = db.getRelevantContent(0, sourceType, count * 2, 168); // Last week
221
- return recentItems
222
- .filter((ri) => ri.id !== item.id)
223
- .slice(0, count)
224
- .map((ri) => {
225
- const scoreDiff = ri.relevance_score - db.explainRelevance(item.id, sourceType).score_breakdown.final_score;
226
- return {
227
- id: ri.id,
228
- title: ri.title,
229
- score: ri.relevance_score,
230
- score_difference: Math.round(scoreDiff * 100) / 100,
231
- key_difference: scoreDiff > 0
232
- ? "Higher: likely more keyword matches"
233
- : "Lower: fewer context matches",
234
- };
235
- });
236
- }
237
- function generateRecommendations(scores, matching, context, item) {
238
- const recommendations = [];
239
- // Low interest match
240
- if (matching.matching_interests.length === 0 && scores.static_match_score < 0.2) {
241
- // Extract potential keywords from item
242
- const words = item.title.toLowerCase().split(/\s+/).filter(w => w.length > 4);
243
- const topWord = words[0] || "this topic";
244
- recommendations.push(`Add "${topWord}" as an explicit interest to boost similar content`);
245
- }
246
- // Low tech match
247
- if (matching.matching_tech.length === 0 && context.tech_stack.length > 0) {
248
- recommendations.push("Item doesn't mention your tech stack - relevance may improve if content aligns with: " +
249
- context.tech_stack.slice(0, 3).join(", "));
250
- }
251
- // Low ACE match
252
- if (scores.ace_match_score < 0.05) {
253
- recommendations.push("No recent work context matches - ensure ACE is scanning your active projects");
254
- }
255
- // Low learned score
256
- if (scores.learned_affinity_score < 0.05) {
257
- recommendations.push("Give feedback on similar items to help 4DA learn your preferences");
258
- }
259
- // General recommendation if score is decent
260
- if (recommendations.length === 0) {
261
- recommendations.push("Score looks healthy - continue providing feedback to refine");
262
- }
263
- return recommendations;
264
- }
265
- function generateNarrative(item, score, matching, ageHours) {
266
- const parts = [];
267
- // Score assessment
268
- if (score >= 0.8) {
269
- parts.push(`"${item.title}" is highly relevant to you (${Math.round(score * 100)}% match).`);
270
- }
271
- else if (score >= 0.5) {
272
- parts.push(`"${item.title}" has moderate relevance (${Math.round(score * 100)}% match).`);
273
- }
274
- else {
275
- parts.push(`"${item.title}" has low relevance (${Math.round(score * 100)}% match).`);
276
- }
277
- // Why
278
- const matches = [
279
- ...matching.matching_interests.map(i => `interest "${i}"`),
280
- ...matching.matching_tech.map(t => `tech "${t}"`),
281
- ...matching.matching_topics.map(t => `recent work on "${t}"`),
282
- ];
283
- if (matches.length > 0) {
284
- parts.push(`It matches your ${matches.slice(0, 2).join(" and ")}.`);
285
- }
286
- else {
287
- parts.push("No strong matches to your declared interests or recent work.");
288
- }
289
- // Recency
290
- if (ageHours < 24) {
291
- parts.push("The freshness boost helps (published within 24 hours).");
292
- }
293
- return parts.join(" ");
294
- }
295
- //# sourceMappingURL=score-autopsy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"score-autopsy.js","sourceRoot":"","sources":["../../src/tools/score-autopsy.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAgD,MAAM,sBAAsB,CAAC;AAE/G,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE;;;;;;;;;;;gEAWiD;IAC9D,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wBAAwB;aACtC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2CAA2C;aACzD;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iDAAiD;aAC/D;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8EAA8E;aAC5F;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,oFAAoF;aAClG;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;KACrC;CACF,CAAC;AAyDF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,EAAkB,EAClB,MAA0B;IAE1B,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,0BAA0B;IAEvE,yBAAyB;IACzB,MAAM,UAAU,GAAI,EAAgG,CAAC,EAAE,CAAC;IACxH,MAAM,SAAS,GA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AAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC;KAC9D,CAAC;IAEF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,mBAAmB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IAC7E,CAAC;IAED,UAAU;IACV,IAAI,QAAQ,GAAG,EAAE,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
@@ -1,53 +0,0 @@
1
- /**
2
- * semantic_shifts tool
3
- *
4
- * Detect how topic narratives shift over time.
5
- */
6
- import type { FourDADatabase } from "../db.js";
7
- export interface SemanticShiftsParams {
8
- period_days?: number;
9
- min_magnitude?: number;
10
- }
11
- export declare const semanticShiftsTool: {
12
- name: string;
13
- description: string;
14
- inputSchema: {
15
- type: "object";
16
- properties: {
17
- period_days: {
18
- type: string;
19
- description: string;
20
- default: number;
21
- };
22
- min_magnitude: {
23
- type: string;
24
- description: string;
25
- default: number;
26
- };
27
- };
28
- };
29
- };
30
- export interface CentroidSnapshot {
31
- data: {
32
- drift_magnitude?: number;
33
- direction?: string;
34
- [key: string]: unknown;
35
- };
36
- created_at: string;
37
- }
38
- export interface SemanticShift {
39
- topic: string;
40
- drift_magnitude: number;
41
- direction: string;
42
- period: string;
43
- snapshots: number;
44
- detected_at: string;
45
- }
46
- export declare function executeSemanticShifts(db: FourDADatabase, params: SemanticShiftsParams): {
47
- shifts: SemanticShift[];
48
- total: number;
49
- period_days: number;
50
- topics_tracked: number;
51
- summary: string;
52
- };
53
- //# sourceMappingURL=semantic-shifts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"semantic-shifts.d.ts","sourceRoot":"","sources":["../../src/tools/semantic-shifts.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;CAkB9B,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC/E,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,oBAAoB;;;;;;EAuD7B"}
@@ -1,74 +0,0 @@
1
- // SPDX-License-Identifier: FSL-1.1-Apache-2.0
2
- /**
3
- * semantic_shifts tool
4
- *
5
- * Detect how topic narratives shift over time.
6
- */
7
- export const semanticShiftsTool = {
8
- name: "semantic_shifts",
9
- description: `Detect narrative shifts in topics you follow. Instead of "new post about X", see "the conversation about X shifted from A to B."`,
10
- inputSchema: {
11
- type: "object",
12
- properties: {
13
- period_days: {
14
- type: "number",
15
- description: "Look-back period in days. Default: 7",
16
- default: 7,
17
- },
18
- min_magnitude: {
19
- type: "number",
20
- description: "Minimum drift magnitude (0-1). Default: 0.1",
21
- default: 0.1,
22
- },
23
- },
24
- },
25
- };
26
- export function executeSemanticShifts(db, params) {
27
- const rawDb = db.getRawDb();
28
- const periodDays = params.period_days || 7;
29
- const rows = rawDb
30
- .prepare(`SELECT id, subject, data, created_at
31
- FROM temporal_events
32
- WHERE event_type = 'topic_centroid'
33
- AND created_at >= datetime('now', '-' || ? || ' days')
34
- ORDER BY created_at DESC`)
35
- .all(periodDays);
36
- // Group centroids by subject (topic)
37
- const byTopic = new Map();
38
- for (const row of rows) {
39
- const existing = byTopic.get(row.subject) || [];
40
- existing.push({
41
- data: JSON.parse(row.data),
42
- created_at: row.created_at,
43
- });
44
- byTopic.set(row.subject, existing);
45
- }
46
- // Detect shifts where we have at least 2 snapshots
47
- const shifts = [];
48
- for (const [topic, snapshots] of byTopic) {
49
- if (snapshots.length < 2)
50
- continue;
51
- const latest = snapshots[0];
52
- const earliest = snapshots[snapshots.length - 1];
53
- const magnitude = latest.data.drift_magnitude || 0;
54
- if (magnitude >= (params.min_magnitude || 0.1)) {
55
- shifts.push({
56
- topic,
57
- drift_magnitude: magnitude,
58
- direction: latest.data.direction || "unknown",
59
- period: `last ${periodDays} days`,
60
- snapshots: snapshots.length,
61
- detected_at: latest.created_at,
62
- });
63
- }
64
- }
65
- shifts.sort((a, b) => b.drift_magnitude - a.drift_magnitude);
66
- return {
67
- shifts,
68
- total: shifts.length,
69
- period_days: periodDays,
70
- topics_tracked: byTopic.size,
71
- summary: `${shifts.length} narrative shift${shifts.length !== 1 ? "s" : ""} detected across ${byTopic.size} topics`,
72
- };
73
- }
74
- //# sourceMappingURL=semantic-shifts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"semantic-shifts.js","sourceRoot":"","sources":["../../src/tools/semantic-shifts.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C;;;;GAIG;AAUH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,kIAAkI;IAC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MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEjD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,CAAC;QACnD,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,GAAG,CAAC,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK;gBACL,eAAe,EAAE,SAAS;gBAC1B,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS;gBAC7C,MAAM,EAAE,QAAQ,UAAU,OAAO;gBACjC,SAAS,EAAE,SAAS,CAAC,MAAM;gBAC3B,WAAW,EAAE,MAAM,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;IAE7D,OAAO;QACL,MAAM;QACN,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,WAAW,EAAE,UAAU;QACvB,cAAc,EAAE,OAAO,CAAC,IAAI;QAC5B,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,mBAAmB,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,oBAAoB,OAAO,CAAC,IAAI,SAAS;KACpH,CAAC;AACJ,CAAC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * signal_chains tool
3
- *
4
- * Get active signal chains - connected signals that form causal narratives over time.
5
- */
6
- import type { FourDADatabase } from "../db.js";
7
- export interface SignalChainsParams {
8
- resolution?: string;
9
- min_priority?: string;
10
- }
11
- export declare const signalChainsTool: {
12
- name: string;
13
- description: string;
14
- inputSchema: {
15
- type: "object";
16
- properties: {
17
- resolution: {
18
- type: string;
19
- enum: string[];
20
- description: string;
21
- default: string;
22
- };
23
- min_priority: {
24
- type: string;
25
- enum: string[];
26
- description: string;
27
- default: string;
28
- };
29
- };
30
- };
31
- };
32
- export interface ChainData {
33
- chain_name?: string;
34
- links?: unknown[];
35
- overall_priority?: string;
36
- resolution?: string;
37
- suggested_action?: string;
38
- }
39
- export declare function executeSignalChains(db: FourDADatabase, params: SignalChainsParams): {
40
- chains: {
41
- id: number;
42
- chain_name: string;
43
- links: unknown[];
44
- overall_priority: string;
45
- resolution: string;
46
- suggested_action: string;
47
- created_at: string;
48
- }[];
49
- total: number;
50
- summary: string;
51
- };
52
- //# sourceMappingURL=signal-chains.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signal-chains.d.ts","sourceRoot":"","sources":["../../src/tools/signal-chains.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;CAoB5B,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,kBAAkB;;;;;;;;;;;;EA2C3B"}
@@ -1,63 +0,0 @@
1
- // SPDX-License-Identifier: FSL-1.1-Apache-2.0
2
- /**
3
- * signal_chains tool
4
- *
5
- * Get active signal chains - connected signals that form causal narratives over time.
6
- */
7
- export const signalChainsTool = {
8
- name: "signal_chains",
9
- description: `Get active signal chains - connected signals that form causal narratives over time. E.g., "CVE found Monday + your dep uses it Tuesday + patch released today = act now."`,
10
- inputSchema: {
11
- type: "object",
12
- properties: {
13
- resolution: {
14
- type: "string",
15
- enum: ["open", "resolved", "expired", "all"],
16
- description: "Filter by chain resolution status. Default: open",
17
- default: "open",
18
- },
19
- min_priority: {
20
- type: "string",
21
- enum: ["critical", "high", "medium", "low"],
22
- description: "Minimum chain priority to include. Default: low",
23
- default: "low",
24
- },
25
- },
26
- },
27
- };
28
- export function executeSignalChains(db, params) {
29
- const rawDb = db.getRawDb();
30
- const resolution = params.resolution || "open";
31
- let query = `SELECT id, event_type, subject, data, created_at
32
- FROM temporal_events
33
- WHERE event_type = 'signal_chain'`;
34
- const queryParams = [];
35
- if (resolution !== "all") {
36
- query += ` AND json_extract(data, '$.resolution') = ?`;
37
- queryParams.push(resolution);
38
- }
39
- query += " ORDER BY created_at DESC LIMIT 50";
40
- const rows = rawDb.prepare(query).all(...queryParams);
41
- const chains = rows.map((row) => {
42
- const data = JSON.parse(row.data);
43
- return {
44
- id: row.id,
45
- chain_name: data.chain_name || row.subject,
46
- links: data.links || [],
47
- overall_priority: data.overall_priority || "medium",
48
- resolution: data.resolution || "open",
49
- suggested_action: data.suggested_action || "",
50
- created_at: row.created_at,
51
- };
52
- });
53
- // Filter by priority
54
- const priorityOrder = { critical: 4, high: 3, medium: 2, low: 1 };
55
- const minLevel = priorityOrder[params.min_priority || "low"] || 1;
56
- const filtered = chains.filter((c) => (priorityOrder[c.overall_priority] || 0) >= minLevel);
57
- return {
58
- chains: filtered,
59
- total: filtered.length,
60
- summary: `${filtered.length} signal chain${filtered.length !== 1 ? "s" : ""} (${resolution})`,
61
- };
62
- }
63
- //# sourceMappingURL=signal-chains.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signal-chains.js","sourceRoot":"","sources":["../../src/tools/signal-chains.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C;;;;GAIG;AAUH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B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U,IAAI,GAAG,CAAC,OAAO;YAC1C,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;YACvB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,QAAQ;YACnD,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,MAAM;YACrC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,EAAE;YAC7C,UAAU,EAAE,GAAG,CAAC,UAAU;SAC3B,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,qBAAqB;IACrB,MAAM,aAAa,GAA2B,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IAC1F,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC5B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,QAAQ,CAC5D,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,QAAQ,CAAC,MAAM;QACtB,OAAO,EAAE,GAAG,QAAQ,CAAC,MAAM,gBAAgB,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,GAAG;KAC9F,CAAC;AACJ,CAAC"}
@@ -1,64 +0,0 @@
1
- /**
2
- * Source Health Tool
3
- *
4
- * Diagnose source fetching, parsing, and data flow issues.
5
- * This is a SUPERPOWER - it reveals pipeline problems before they become mysteries.
6
- */
7
- import type { FourDADatabase } from "../db.js";
8
- export declare const sourceHealthTool: {
9
- name: string;
10
- description: string;
11
- inputSchema: {
12
- type: string;
13
- properties: {
14
- source: {
15
- type: string;
16
- description: string;
17
- };
18
- hours: {
19
- type: string;
20
- description: string;
21
- };
22
- };
23
- };
24
- };
25
- export interface SourceHealthParams {
26
- source?: string;
27
- hours?: number;
28
- }
29
- interface SourceStatus {
30
- source: string;
31
- status: "healthy" | "degraded" | "failing" | "unknown";
32
- last_item_at: string | null;
33
- hours_since_last: number | null;
34
- items_24h: number;
35
- items_7d: number;
36
- avg_items_per_day: number;
37
- quality_metrics: {
38
- has_url_rate: number;
39
- has_content_rate: number;
40
- avg_content_length: number;
41
- };
42
- issues: string[];
43
- recommendations: string[];
44
- }
45
- interface SourceHealthResult {
46
- analysis_period: {
47
- start: string;
48
- end: string;
49
- hours: number;
50
- };
51
- overall_status: "healthy" | "degraded" | "critical";
52
- sources: SourceStatus[];
53
- summary: {
54
- total_sources: number;
55
- healthy: number;
56
- degraded: number;
57
- failing: number;
58
- total_items_24h: number;
59
- };
60
- global_recommendations: string[];
61
- }
62
- export declare function executeSourceHealth(db: FourDADatabase, params: SourceHealthParams): SourceHealthResult;
63
- export {};
64
- //# sourceMappingURL=source-health.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-health.d.ts","sourceRoot":"","sources":["../../src/tools/source-health.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;CAwB5B,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;IACvD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC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