@4da/mcp-server 3.2.0 → 4.0.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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -63
  3. package/dist/db.d.ts +27 -2
  4. package/dist/db.d.ts.map +1 -1
  5. package/dist/db.js +104 -1
  6. package/dist/db.js.map +1 -1
  7. package/dist/doctor.d.ts +15 -0
  8. package/dist/doctor.d.ts.map +1 -0
  9. package/dist/doctor.js +98 -0
  10. package/dist/doctor.js.map +1 -0
  11. package/dist/http-transport.d.ts +25 -0
  12. package/dist/http-transport.d.ts.map +1 -0
  13. package/dist/http-transport.js +126 -0
  14. package/dist/http-transport.js.map +1 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +130 -10
  17. package/dist/index.js.map +1 -1
  18. package/dist/llm.d.ts +20 -2
  19. package/dist/llm.d.ts.map +1 -1
  20. package/dist/llm.js +77 -20
  21. package/dist/llm.js.map +1 -1
  22. package/dist/schema-registry.d.ts.map +1 -1
  23. package/dist/schema-registry.js +44 -0
  24. package/dist/schema-registry.js.map +1 -1
  25. package/dist/schemas/agent-memory.json +49 -0
  26. package/dist/schemas/agent-session-brief.json +25 -0
  27. package/dist/schemas/attention-report.json +13 -0
  28. package/dist/schemas/autophagy-status.json +13 -0
  29. package/dist/schemas/compound-advantage.json +14 -0
  30. package/dist/schemas/decision-enforcement.json +22 -0
  31. package/dist/schemas/decision-memory.json +54 -0
  32. package/dist/schemas/decision-windows.json +22 -0
  33. package/dist/schemas/delegation-score.json +18 -0
  34. package/dist/schemas/developer-dna.json +219 -0
  35. package/dist/schemas/export-context.json +17 -0
  36. package/dist/schemas/knowledge-gaps.json +14 -0
  37. package/dist/schemas/project-health.json +13 -0
  38. package/dist/schemas/reverse-mentions.json +13 -0
  39. package/dist/schemas/semantic-shifts.json +17 -0
  40. package/dist/schemas/signal-chains.json +19 -0
  41. package/dist/schemas/tech-radar.json +23 -0
  42. package/dist/setup.d.ts +17 -0
  43. package/dist/setup.d.ts.map +1 -0
  44. package/dist/setup.js +137 -0
  45. package/dist/setup.js.map +1 -0
  46. package/dist/tools/agent-memory.d.ts +94 -0
  47. package/dist/tools/agent-memory.d.ts.map +1 -0
  48. package/dist/tools/agent-memory.js +229 -0
  49. package/dist/tools/agent-memory.js.map +1 -0
  50. package/dist/tools/agent-session-brief.d.ts +44 -0
  51. package/dist/tools/agent-session-brief.d.ts.map +1 -0
  52. package/dist/tools/agent-session-brief.js +178 -0
  53. package/dist/tools/agent-session-brief.js.map +1 -0
  54. package/dist/tools/attention-report.d.ts +6 -5
  55. package/dist/tools/attention-report.d.ts.map +1 -1
  56. package/dist/tools/attention-report.js.map +1 -1
  57. package/dist/tools/autophagy-status.d.ts +25 -0
  58. package/dist/tools/autophagy-status.d.ts.map +1 -0
  59. package/dist/tools/autophagy-status.js +56 -0
  60. package/dist/tools/autophagy-status.js.map +1 -0
  61. package/dist/tools/compound-advantage.d.ts +27 -0
  62. package/dist/tools/compound-advantage.d.ts.map +1 -0
  63. package/dist/tools/compound-advantage.js +76 -0
  64. package/dist/tools/compound-advantage.js.map +1 -0
  65. package/dist/tools/decision-enforcement.d.ts +59 -0
  66. package/dist/tools/decision-enforcement.d.ts.map +1 -0
  67. package/dist/tools/decision-enforcement.js +184 -0
  68. package/dist/tools/decision-enforcement.js.map +1 -0
  69. package/dist/tools/decision-memory.d.ts +130 -0
  70. package/dist/tools/decision-memory.d.ts.map +1 -0
  71. package/dist/tools/decision-memory.js +265 -0
  72. package/dist/tools/decision-memory.js.map +1 -0
  73. package/dist/tools/decision-windows.d.ts +37 -0
  74. package/dist/tools/decision-windows.d.ts.map +1 -0
  75. package/dist/tools/decision-windows.js +67 -0
  76. package/dist/tools/decision-windows.js.map +1 -0
  77. package/dist/tools/delegation-score.d.ts +34 -0
  78. package/dist/tools/delegation-score.d.ts.map +1 -0
  79. package/dist/tools/delegation-score.js +250 -0
  80. package/dist/tools/delegation-score.js.map +1 -0
  81. package/dist/tools/developer-dna.d.ts +79 -0
  82. package/dist/tools/developer-dna.d.ts.map +1 -0
  83. package/dist/tools/developer-dna.js +377 -0
  84. package/dist/tools/developer-dna.js.map +1 -0
  85. package/dist/tools/export-context.d.ts +14 -6
  86. package/dist/tools/export-context.d.ts.map +1 -1
  87. package/dist/tools/export-context.js +13 -13
  88. package/dist/tools/export-context.js.map +1 -1
  89. package/dist/tools/index.d.ts +10 -0
  90. package/dist/tools/index.d.ts.map +1 -1
  91. package/dist/tools/index.js +14 -0
  92. package/dist/tools/index.js.map +1 -1
  93. package/dist/tools/knowledge-gaps.d.ts +11 -1
  94. package/dist/tools/knowledge-gaps.d.ts.map +1 -1
  95. package/dist/tools/knowledge-gaps.js.map +1 -1
  96. package/dist/tools/project-health.d.ts +6 -6
  97. package/dist/tools/project-health.d.ts.map +1 -1
  98. package/dist/tools/project-health.js +1 -1
  99. package/dist/tools/project-health.js.map +1 -1
  100. package/dist/tools/reverse-mentions.d.ts +8 -8
  101. package/dist/tools/reverse-mentions.d.ts.map +1 -1
  102. package/dist/tools/reverse-mentions.js.map +1 -1
  103. package/dist/tools/semantic-shifts.d.ts +17 -1
  104. package/dist/tools/semantic-shifts.d.ts.map +1 -1
  105. package/dist/tools/semantic-shifts.js.map +1 -1
  106. package/dist/tools/signal-chains.d.ts +14 -7
  107. package/dist/tools/signal-chains.d.ts.map +1 -1
  108. package/dist/tools/signal-chains.js.map +1 -1
  109. package/dist/tools/tech-radar.d.ts +38 -0
  110. package/dist/tools/tech-radar.d.ts.map +1 -0
  111. package/dist/tools/tech-radar.js +248 -0
  112. package/dist/tools/tech-radar.js.map +1 -0
  113. package/dist/types.d.ts +109 -0
  114. package/dist/types.d.ts.map +1 -1
  115. package/package.json +26 -14
@@ -0,0 +1,76 @@
1
+ export const compoundAdvantageTool = {
2
+ name: "compound_advantage",
3
+ description: "Get compound advantage score — measures how effectively you leverage 4DA intelligence for time-sensitive decisions. Tracks response rate, lead time, calibration accuracy.",
4
+ inputSchema: {
5
+ type: "object",
6
+ properties: {
7
+ period: {
8
+ type: "string",
9
+ enum: ["weekly", "monthly"],
10
+ description: "Scoring period. Default: weekly",
11
+ default: "weekly",
12
+ },
13
+ },
14
+ },
15
+ };
16
+ export function executeCompoundAdvantage(db, params) {
17
+ const rawDb = db.getRawDb();
18
+ const period = params.period ?? "weekly";
19
+ // Latest two scores for trend computation
20
+ let latestScore = null;
21
+ let previousScore = null;
22
+ try {
23
+ const scores = rawDb.prepare(`SELECT id, period, score, response_rate, avg_lead_time_hours,
24
+ calibration_accuracy, computed_at
25
+ FROM advantage_score WHERE period = ?
26
+ ORDER BY computed_at DESC LIMIT 2`).all(period);
27
+ latestScore = scores[0] ?? null;
28
+ previousScore = scores[1] ?? null;
29
+ }
30
+ catch { /* Table may not exist yet */ }
31
+ // Decision window stats
32
+ let total = 0, acted = 0, expired = 0;
33
+ try {
34
+ const s = rawDb.prepare(`SELECT COUNT(*) as total,
35
+ SUM(CASE WHEN status = 'acted' THEN 1 ELSE 0 END) as acted,
36
+ SUM(CASE WHEN status = 'expired' THEN 1 ELSE 0 END) as expired
37
+ FROM decision_windows`).get();
38
+ if (s) {
39
+ total = s.total;
40
+ acted = s.acted;
41
+ expired = s.expired;
42
+ }
43
+ }
44
+ catch { /* Table may not exist yet */ }
45
+ // Trend
46
+ let trend = "no_data";
47
+ let trendDelta = null;
48
+ if (latestScore && previousScore) {
49
+ trendDelta = latestScore.score - previousScore.score;
50
+ trend = trendDelta > 2 ? "improving" : trendDelta < -2 ? "declining" : "stable";
51
+ }
52
+ else if (latestScore) {
53
+ trend = "baseline";
54
+ }
55
+ return {
56
+ score: latestScore?.score ?? null,
57
+ period,
58
+ components: latestScore ? {
59
+ response_rate: latestScore.response_rate,
60
+ avg_lead_time_hours: latestScore.avg_lead_time_hours,
61
+ calibration_accuracy: latestScore.calibration_accuracy,
62
+ } : null,
63
+ trend: { direction: trend, delta: trendDelta, previous_score: previousScore?.score ?? null },
64
+ decision_windows: {
65
+ total_opened: total,
66
+ total_acted: acted,
67
+ total_expired: expired,
68
+ action_rate: total > 0 ? Math.round((acted / total) * 100) : null,
69
+ },
70
+ computed_at: latestScore?.computed_at ?? null,
71
+ summary: latestScore
72
+ ? `Compound advantage: ${latestScore.score}/100 (${trend}). ${acted}/${total} windows acted on.`
73
+ : "No compound advantage scores computed yet. Scores build as you interact with decision windows and intelligence feeds.",
74
+ };
75
+ }
76
+ //# sourceMappingURL=compound-advantage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compound-advantage.js","sourceRoot":"","sources":["../../src/tools/compound-advantage.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACT,4KAA4K;IAC9K,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;gBAC3B,WAAW,EAAE,iCAAiC;gBAC9C,OAAO,EAAE,QAAQ;aAClB;SACF;KACF;CACF,CAAC;AAEF,MAAM,UAAU,wBAAwB,CAAC,EAAkB,EAAE,MAA+B;IAC1F,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,QAAQ,CAAC;IAEzC,0CAA0C;IAC1C,IAAI,WAAW,GAAoB,IAAI,CAAC;IACxC,IAAI,aAAa,GAAoB,IAAI,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAC1B;;;yCAGmC,CACpC,CAAC,GAAG,CAAC,MAAM,CAAe,CAAC;QAC5B,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAChC,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,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AAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,IAAI,IAAI,EAAE;QAC5F,gBAAgB,EAAE;YAChB,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,KAAK;YAClB,aAAa,EAAE,OAAO;YACtB,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI;SAClE;QACD,WAAW,EAAE,WAAW,EAAE,WAAW,IAAI,IAAI;QAC7C,OAAO,EAAE,WAAW;YAClB,CAAC,CAAC,uBAAuB,WAAW,CAAC,KAAK,SAAS,KAAK,MAAM,KAAK,IAAI,KAAK,oBAAoB;YAChG,CAAC,CAAC,uHAAuH;KAC5H,CAAC;AACJ,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * check_decision_alignment tool
3
+ *
4
+ * The key tool AI agents call BEFORE suggesting major changes.
5
+ * Checks if a technology or pattern aligns with the developer's active decisions.
6
+ * Returns alignment status, relevant decisions, and any conflicts.
7
+ */
8
+ import type { FourDADatabase } from "../db.js";
9
+ export interface CheckDecisionAlignmentParams {
10
+ technology: string;
11
+ pattern?: string;
12
+ context?: string;
13
+ }
14
+ interface RelevantDecision {
15
+ id: number;
16
+ subject: string;
17
+ decision: string;
18
+ rationale: string | null;
19
+ confidence: number;
20
+ relationship: "aligned" | "conflict" | "related";
21
+ }
22
+ interface DecisionConflict {
23
+ decision_id: number;
24
+ subject: string;
25
+ reason: string;
26
+ }
27
+ interface AlignmentResult {
28
+ aligned: boolean;
29
+ technology: string;
30
+ relevant_decisions: RelevantDecision[];
31
+ conflicts: DecisionConflict[];
32
+ confidence: number;
33
+ recommendation: string;
34
+ }
35
+ export declare const checkDecisionAlignmentTool: {
36
+ name: string;
37
+ description: string;
38
+ inputSchema: {
39
+ type: "object";
40
+ properties: {
41
+ technology: {
42
+ type: string;
43
+ description: string;
44
+ };
45
+ pattern: {
46
+ type: string;
47
+ description: string;
48
+ };
49
+ context: {
50
+ type: string;
51
+ description: string;
52
+ };
53
+ };
54
+ required: string[];
55
+ };
56
+ };
57
+ export declare function executeCheckDecisionAlignment(db: FourDADatabase, params: CheckDecisionAlignmentParams): AlignmentResult;
58
+ export {};
59
+ //# sourceMappingURL=decision-enforcement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-enforcement.d.ts","sourceRoot":"","sources":["../../src/tools/decision-enforcement.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAiBD,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;CAClD;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,gBAAgB,EAAE,CAAC;IACvC,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAMD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;CAwBtC,CAAC;AAmFF,wBAAgB,6BAA6B,CAC3C,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,4BAA4B,GACnC,eAAe,CAsHjB"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * check_decision_alignment tool
3
+ *
4
+ * The key tool AI agents call BEFORE suggesting major changes.
5
+ * Checks if a technology or pattern aligns with the developer's active decisions.
6
+ * Returns alignment status, relevant decisions, and any conflicts.
7
+ */
8
+ // ============================================================================
9
+ // Tool Definition
10
+ // ============================================================================
11
+ export const checkDecisionAlignmentTool = {
12
+ name: "check_decision_alignment",
13
+ description: "Check if a technology or pattern aligns with the developer's active decisions. Call BEFORE suggesting major tech changes. Returns alignment status, relevant decisions, and any conflicts.",
14
+ inputSchema: {
15
+ type: "object",
16
+ properties: {
17
+ technology: {
18
+ type: "string",
19
+ description: "Technology name to check (e.g., 'postgresql', 'redis', 'graphql')",
20
+ },
21
+ pattern: {
22
+ type: "string",
23
+ description: "Architecture pattern to check (e.g., 'microservices', 'event-driven')",
24
+ },
25
+ context: {
26
+ type: "string",
27
+ description: "Additional context about the proposed change",
28
+ },
29
+ },
30
+ required: ["technology"],
31
+ },
32
+ };
33
+ // ============================================================================
34
+ // Helpers
35
+ // ============================================================================
36
+ /**
37
+ * Search active decisions matching a given term against subject,
38
+ * context_tags, and alternatives_rejected columns.
39
+ */
40
+ function searchActiveDecisions(rawDb, searchTerm) {
41
+ const pattern = `%${searchTerm.toLowerCase()}%`;
42
+ return rawDb
43
+ .prepare(`SELECT id, decision_type, subject, decision, rationale,
44
+ alternatives_rejected, context_tags, confidence,
45
+ status, superseded_by, created_at, updated_at
46
+ FROM developer_decisions
47
+ WHERE status = 'active'
48
+ AND (LOWER(subject) LIKE ?
49
+ OR LOWER(context_tags) LIKE ?
50
+ OR LOWER(alternatives_rejected) LIKE ?)`)
51
+ .all(pattern, pattern, pattern);
52
+ }
53
+ /**
54
+ * Classify a decision row's relationship to the queried technology.
55
+ */
56
+ function classifyRelationship(row, tech) {
57
+ const techLower = tech.toLowerCase();
58
+ const alts = JSON.parse(row.alternatives_rejected || "[]");
59
+ // If the technology appears in rejected alternatives, it's a conflict
60
+ const isRejected = alts.some((alt) => alt.toLowerCase().includes(techLower));
61
+ if (isRejected) {
62
+ return "conflict";
63
+ }
64
+ // If the technology matches the decision subject, it's aligned
65
+ if (row.subject.toLowerCase().includes(techLower)) {
66
+ return "aligned";
67
+ }
68
+ // Otherwise it's tangentially related
69
+ return "related";
70
+ }
71
+ /**
72
+ * Build a human-readable recommendation string.
73
+ */
74
+ function buildRecommendation(technology, conflicts, relevantCount) {
75
+ if (conflicts.length === 0) {
76
+ if (relevantCount === 0) {
77
+ return `No existing decisions found for '${technology}'. No conflicts detected — proceed with caution.`;
78
+ }
79
+ return `No conflicts found. Proceed with ${technology}.`;
80
+ }
81
+ // Report the first (most relevant) conflict
82
+ const first = conflicts[0];
83
+ return (`CONFLICT: ${technology} was explicitly rejected. ` +
84
+ `Active decision: '${first.subject}' — ${first.reason}`);
85
+ }
86
+ // ============================================================================
87
+ // Execute
88
+ // ============================================================================
89
+ export function executeCheckDecisionAlignment(db, params) {
90
+ const rawDb = db.getRawDb();
91
+ const { technology, pattern, context } = params;
92
+ // Collect all matching decision rows (deduplicated by id)
93
+ const seenIds = new Set();
94
+ const allRows = [];
95
+ try {
96
+ // Primary search: technology name
97
+ const techRows = searchActiveDecisions(rawDb, technology);
98
+ for (const row of techRows) {
99
+ if (!seenIds.has(row.id)) {
100
+ seenIds.add(row.id);
101
+ allRows.push(row);
102
+ }
103
+ }
104
+ // Secondary search: pattern (if provided)
105
+ if (pattern) {
106
+ const patternRows = searchActiveDecisions(rawDb, pattern);
107
+ for (const row of patternRows) {
108
+ if (!seenIds.has(row.id)) {
109
+ seenIds.add(row.id);
110
+ allRows.push(row);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ catch {
116
+ // Table may not exist yet — return a safe default
117
+ return {
118
+ aligned: true,
119
+ technology,
120
+ relevant_decisions: [],
121
+ conflicts: [],
122
+ confidence: 0.5,
123
+ recommendation: `No decision history available. The developer_decisions table may not exist yet. Proceed with ${technology}.`,
124
+ };
125
+ }
126
+ // Classify each row
127
+ const relevantDecisions = [];
128
+ const conflicts = [];
129
+ for (const row of allRows) {
130
+ const relationship = classifyRelationship(row, technology);
131
+ relevantDecisions.push({
132
+ id: row.id,
133
+ subject: row.subject,
134
+ decision: row.decision,
135
+ rationale: row.rationale,
136
+ confidence: row.confidence,
137
+ relationship,
138
+ });
139
+ if (relationship === "conflict") {
140
+ const alts = JSON.parse(row.alternatives_rejected || "[]");
141
+ const rejectedAlt = alts.find((alt) => alt.toLowerCase().includes(technology.toLowerCase()));
142
+ conflicts.push({
143
+ decision_id: row.id,
144
+ subject: row.subject,
145
+ reason: `'${rejectedAlt || technology}' was rejected in favor of '${row.decision}' (rationale: ${row.rationale || "none"})`,
146
+ });
147
+ }
148
+ }
149
+ // If pattern was provided but didn't surface via technology search,
150
+ // also check pattern against decision relationships
151
+ if (pattern) {
152
+ for (const row of allRows) {
153
+ const patternLower = pattern.toLowerCase();
154
+ const alts = JSON.parse(row.alternatives_rejected || "[]");
155
+ const patternRejected = alts.some((alt) => alt.toLowerCase().includes(patternLower));
156
+ if (patternRejected &&
157
+ !conflicts.some((c) => c.decision_id === row.id)) {
158
+ conflicts.push({
159
+ decision_id: row.id,
160
+ subject: row.subject,
161
+ reason: `Pattern '${pattern}' was rejected in favor of '${row.decision}' (rationale: ${row.rationale || "none"})`,
162
+ });
163
+ // Update the relationship for this decision
164
+ const existing = relevantDecisions.find((d) => d.id === row.id);
165
+ if (existing && existing.relationship !== "conflict") {
166
+ existing.relationship = "conflict";
167
+ }
168
+ }
169
+ }
170
+ }
171
+ const maxConfidence = relevantDecisions.length > 0
172
+ ? Math.max(...relevantDecisions.map((d) => d.confidence))
173
+ : 0.5;
174
+ const recommendation = buildRecommendation(technology, conflicts, relevantDecisions.length);
175
+ return {
176
+ aligned: conflicts.length === 0,
177
+ technology,
178
+ relevant_decisions: relevantDecisions,
179
+ conflicts,
180
+ confidence: maxConfidence,
181
+ recommendation,
182
+ };
183
+ }
184
+ //# sourceMappingURL=decision-enforcement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-enforcement.js","sourceRoot":"","sources":["../../src/tools/decision-enforcement.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqDH,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE,0BAA0B;IAChC,WAAW,EACT,4LAA4L;IAC9L,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,mEAAmE;aACtE;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,uEAAuE;aAC1E;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8CAA8C;aAC5D;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;KACzB;CACF,CAAC;AAEF,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;GAGG;AACH,SAAS,qBAAqB,CAC5B,KAA6C,EAC7C,UAAkB;IAElB,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC;IAChD,OAAO,KAAK;SACT,OAAO,CACN;;;;;;;mDAO6C,CAC9C;SACA,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAkB,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAC3B,GAAgB,EAChB,IAAY;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,IAAI,GAAa,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,IAAI,IAAI,CAAC,CAAC;IAErE,sEAAsE;IACtE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CA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,IAAI,CAAC;oBACb,WAAW,EAAE,GAAG,CAAC,EAAE;oBACnB,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,MAAM,EAAE,YAAY,OAAO,+BAA+B,GAAG,CAAC,QAAQ,iBAAiB,GAAG,CAAC,SAAS,IAAI,MAAM,GAAG;iBAClH,CAAC,CAAC;gBAEH,4CAA4C;gBAC5C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;gBAChE,IAAI,QAAQ,IAAI,QAAQ,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;oBACrD,QAAQ,CAAC,YAAY,GAAG,UAAU,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,aAAa,GACjB,iBAAiB,CAAC,MAAM,GAAG,CAAC;QAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QACzD,CAAC,CAAC,GAAG,CAAC;IAEV,MAAM,cAAc,GAAG,mBAAmB,CACxC,UAAU,EACV,SAAS,EACT,iBAAiB,CAAC,MAAM,CACzB,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,MAAM,KAAK,CAAC;QAC/B,UAAU;QACV,kBAAkB,EAAE,iBAAiB;QACrC,SAAS;QACT,UAAU,EAAE,aAAa;QACzB,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * decision_memory tool
3
+ *
4
+ * Manage developer decisions - record, list, check alignment, update, and supersede.
5
+ * Decisions persist and inform signal classification, tech radar, and agent context.
6
+ */
7
+ import type { FourDADatabase } from "../db.js";
8
+ export interface DecisionMemoryParams {
9
+ action: "record" | "list" | "check_alignment" | "update" | "supersede";
10
+ decision_type?: "tech_choice" | "architecture" | "workflow" | "pattern" | "dependency";
11
+ subject?: string;
12
+ decision?: string;
13
+ rationale?: string;
14
+ alternatives_rejected?: string[];
15
+ context_tags?: string[];
16
+ confidence?: number;
17
+ filter_type?: string;
18
+ filter_status?: string;
19
+ limit?: number;
20
+ technology?: string;
21
+ pattern?: string;
22
+ id?: number;
23
+ new_decision?: string;
24
+ new_rationale?: string;
25
+ new_status?: "active" | "superseded" | "reconsidering";
26
+ new_confidence?: number;
27
+ old_id?: number;
28
+ new_id?: number;
29
+ }
30
+ export declare const decisionMemoryTool: {
31
+ name: string;
32
+ description: string;
33
+ inputSchema: {
34
+ type: "object";
35
+ properties: {
36
+ action: {
37
+ type: string;
38
+ enum: string[];
39
+ description: string;
40
+ };
41
+ decision_type: {
42
+ type: string;
43
+ enum: string[];
44
+ description: string;
45
+ };
46
+ subject: {
47
+ type: string;
48
+ description: string;
49
+ };
50
+ decision: {
51
+ type: string;
52
+ description: string;
53
+ };
54
+ rationale: {
55
+ type: string;
56
+ description: string;
57
+ };
58
+ alternatives_rejected: {
59
+ type: string;
60
+ items: {
61
+ type: string;
62
+ };
63
+ description: string;
64
+ };
65
+ context_tags: {
66
+ type: string;
67
+ items: {
68
+ type: string;
69
+ };
70
+ description: string;
71
+ };
72
+ confidence: {
73
+ type: string;
74
+ description: string;
75
+ };
76
+ filter_type: {
77
+ type: string;
78
+ description: string;
79
+ };
80
+ filter_status: {
81
+ type: string;
82
+ description: string;
83
+ };
84
+ limit: {
85
+ type: string;
86
+ description: string;
87
+ };
88
+ technology: {
89
+ type: string;
90
+ description: string;
91
+ };
92
+ pattern: {
93
+ type: string;
94
+ description: string;
95
+ };
96
+ id: {
97
+ type: string;
98
+ description: string;
99
+ };
100
+ new_decision: {
101
+ type: string;
102
+ description: string;
103
+ };
104
+ new_rationale: {
105
+ type: string;
106
+ description: string;
107
+ };
108
+ new_status: {
109
+ type: string;
110
+ enum: string[];
111
+ description: string;
112
+ };
113
+ new_confidence: {
114
+ type: string;
115
+ description: string;
116
+ };
117
+ old_id: {
118
+ type: string;
119
+ description: string;
120
+ };
121
+ new_id: {
122
+ type: string;
123
+ description: string;
124
+ };
125
+ };
126
+ required: string[];
127
+ };
128
+ };
129
+ export declare function executeDecisionMemory(db: FourDADatabase, params: DecisionMemoryParams): object;
130
+ //# sourceMappingURL=decision-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-memory.d.ts","sourceRoot":"","sources":["../../src/tools/decision-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,iBAAiB,GAAG,QAAQ,GAAG,WAAW,CAAC;IAEvE,aAAa,CAAC,EACV,aAAa,GACb,cAAc,GACd,UAAU,GACV,SAAS,GACT,YAAY,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,eAAe,CAAC;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,MAAM,CAAC,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