@plumpslabs/kuma 2.3.20 → 2.3.23

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 (39) hide show
  1. package/README.md +18 -0
  2. package/dist/index.js +10316 -380
  3. package/package.json +2 -2
  4. package/packages/ide/studio/dist/index.js +90 -9
  5. package/packages/ide/studio/public/index.html +528 -233
  6. package/dist/agentDetector-YOWQVJFR.js +0 -186
  7. package/dist/chunk-3BRBJZ7P.js +0 -1055
  8. package/dist/chunk-3OHYYXYN.js +0 -71
  9. package/dist/chunk-ABKE45T4.js +0 -1264
  10. package/dist/chunk-E2KFPEBT.js +0 -183
  11. package/dist/chunk-FKRSI5U5.js +0 -282
  12. package/dist/chunk-GFLSAXAH.js +0 -155
  13. package/dist/chunk-L7F67KUP.js +0 -172
  14. package/dist/chunk-LVKOGXLC.js +0 -658
  15. package/dist/chunk-PRUTTZBS.js +0 -1113
  16. package/dist/contextDigest-QB5XHPXE.js +0 -177
  17. package/dist/domainRules-QLPAQASB.js +0 -20
  18. package/dist/init-PL4XL662.js +0 -15
  19. package/dist/kumaAstValidator-CNM7FHYA.js +0 -150
  20. package/dist/kumaCheckpoint-J2LDQMEO.js +0 -207
  21. package/dist/kumaCodeScanner-J6B2EHGI.js +0 -563
  22. package/dist/kumaContractEngine-KX27T4N7.js +0 -305
  23. package/dist/kumaDb-4XZ5S2LH.js +0 -65
  24. package/dist/kumaDriftDetector-TOORILSZ.js +0 -237
  25. package/dist/kumaGotchas-XRGFFBTA.js +0 -151
  26. package/dist/kumaGraph-UMXZNGYF.js +0 -44
  27. package/dist/kumaMemory-FBJMV77G.js +0 -16
  28. package/dist/kumaMiner-XJETL7TL.js +0 -176
  29. package/dist/kumaPolicyEngine-2QDJDLM7.js +0 -311
  30. package/dist/kumaProgressiveContext-MWEDRXOH.js +0 -231
  31. package/dist/kumaSearch-PV4QTKE7.js +0 -321
  32. package/dist/kumaTrajectory-7NOAVNG2.js +0 -460
  33. package/dist/kumaVerifier-6YEGC77M.js +0 -265
  34. package/dist/kumaVisualize-264OEBGJ.js +0 -264
  35. package/dist/pathValidator-V4DC6U6Z.js +0 -22
  36. package/dist/safetyAudit-O45SPNTS.js +0 -12
  37. package/dist/safetyScore-TMMRD2MV.js +0 -333
  38. package/dist/sessionMemory-YPKVIOMV.js +0 -6
  39. package/dist/skillGenerator-PWEJKZNX.js +0 -304
@@ -1,172 +0,0 @@
1
- import {
2
- sessionMemory
3
- } from "./chunk-LVKOGXLC.js";
4
- import {
5
- getProjectRoot
6
- } from "./chunk-E2KFPEBT.js";
7
-
8
- // src/engine/kumaMemory.ts
9
- import fs from "fs";
10
- import path from "path";
11
- var MEMORY_DIR = ".kuma/memories";
12
- function scoreMemoryRelevance(context, limit = 5) {
13
- const results = [];
14
- const kumaDir = path.join(getProjectRoot(), MEMORY_DIR);
15
- if (!fs.existsSync(kumaDir)) return [];
16
- const terms = context.toLowerCase().split(/\s+/).filter((w) => w.length > 3);
17
- if (terms.length === 0) return [];
18
- try {
19
- const files = fs.readdirSync(kumaDir).filter((f) => f.endsWith(".md"));
20
- for (const file of files) {
21
- try {
22
- const content = fs.readFileSync(path.join(kumaDir, file), "utf-8");
23
- const lower = content.toLowerCase();
24
- let matchCount = 0;
25
- for (const term of terms) {
26
- if (lower.includes(term)) matchCount++;
27
- }
28
- const score = Math.round(matchCount / terms.length * 100);
29
- if (score > 0) {
30
- const topic = file.replace(/\.md$/, "");
31
- const firstLine = content.split("\n").slice(0, 3).join(" ").substring(0, 150);
32
- results.push({
33
- topic,
34
- content: firstLine,
35
- score,
36
- reason: `${matchCount}/${terms.length} terms matched`
37
- });
38
- }
39
- } catch {
40
- }
41
- }
42
- } catch {
43
- }
44
- return results.sort((a, b) => b.score - a.score).slice(0, limit);
45
- }
46
- function formatScoredMemories(memories, context) {
47
- if (memories.length === 0) return "";
48
- const lines = [
49
- `\u{1F9E0} **Relevant Memories** (for "${context.substring(0, 40)}")`,
50
- "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
51
- ];
52
- for (const m of memories) {
53
- const bar = "\u2588".repeat(Math.round(m.score / 10)) + "\u2591".repeat(Math.round(10 - m.score / 10));
54
- lines.push(` **${m.topic}** \u2014 ${bar} ${m.score}%`);
55
- lines.push(` ${m.content.substring(0, 100)}`);
56
- lines.push(` \u{1F4A1} ${m.reason}`);
57
- lines.push("");
58
- }
59
- return lines.join("\n");
60
- }
61
- function recordDecision(decision) {
62
- try {
63
- const entry = [
64
- "",
65
- `## ${decision.title}`,
66
- `- **Date:** ${decision.timestamp || (/* @__PURE__ */ new Date()).toISOString()}`,
67
- `- **Context:** ${decision.context}`,
68
- `- **Options:** ${decision.options.join(", ")}`,
69
- `- **Rationale:** ${decision.rationale}`,
70
- `- **Outcome:** ${decision.outcome}`,
71
- ""
72
- ].join("\n");
73
- const existing = sessionMemory.getMemoryContent("decisions");
74
- sessionMemory.writeMemory("decisions", existing + entry);
75
- sessionMemory.recordToolCall("kuma_decision", { title: decision.title });
76
- recordDecisionToGraph(decision).catch(() => {
77
- });
78
- return `\u2705 Decision "${decision.title}" recorded.`;
79
- } catch (err) {
80
- return `Error recording decision: ${err}`;
81
- }
82
- }
83
- async function recordDecisionToGraph(decision) {
84
- try {
85
- const { upsertNode, addEdge } = await import("./kumaGraph-UMXZNGYF.js");
86
- const decisionId = `decision::${decision.title.replace(/[^a-zA-Z0-9_\-\s]/g, "").trim().replace(/\s+/g, "-")}`;
87
- await upsertNode({
88
- id: decisionId,
89
- type: "variable",
90
- name: `ADR: ${decision.title.substring(0, 80)}`,
91
- metadata: {
92
- type: "architectural-decision",
93
- context: decision.context.substring(0, 200),
94
- rationale: decision.rationale.substring(0, 200),
95
- outcome: decision.outcome,
96
- timestamp: decision.timestamp
97
- }
98
- });
99
- const filePathMatches = decision.context.matchAll(/["']?([\w./-]+\.\w+)["']?/g);
100
- for (const match of filePathMatches) {
101
- const possiblePath = match[1];
102
- if (possiblePath.includes("/") && (possiblePath.endsWith(".ts") || possiblePath.endsWith(".js") || possiblePath.endsWith(".json") || possiblePath.endsWith(".md"))) {
103
- try {
104
- const fileId = `file::${possiblePath}`;
105
- await upsertNode({ id: fileId, type: "file", name: possiblePath });
106
- await addEdge({ sourceId: decisionId, targetId: fileId, type: "depends_on", metadata: { reason: "adr-context" } });
107
- } catch {
108
- }
109
- }
110
- }
111
- if (decision.outcome && decision.outcome !== "implemented") {
112
- try {
113
- const outcomeId = `decision-outcome::${decision.outcome.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase()}`;
114
- await upsertNode({ id: outcomeId, type: "variable", name: `Outcome: ${decision.outcome.substring(0, 60)}` });
115
- await addEdge({ sourceId: decisionId, targetId: outcomeId, type: "depends_on" });
116
- } catch {
117
- }
118
- }
119
- } catch {
120
- }
121
- }
122
- var decisionCooldown = 0;
123
- function shouldRecordDecision() {
124
- const history = sessionMemory.getToolCallHistory(30);
125
- const edits = history.filter((c) => c.toolName === "precise_diff_editor");
126
- if (edits.length > decisionCooldown + 10 && edits.length >= 10) {
127
- decisionCooldown = edits.length;
128
- return {
129
- worth: true,
130
- title: `Significant edits (${edits.length} changes)`
131
- };
132
- }
133
- return { worth: false };
134
- }
135
- function getProactiveMemories() {
136
- const summary = sessionMemory.getSummary();
137
- const goal = summary.currentGoal || "";
138
- const modifiedFiles = summary.modifiedFiles || [];
139
- const context = [goal, ...modifiedFiles.map((f) => f.filePath || "")].join(" ");
140
- if (!context.trim()) return "";
141
- const memories = scoreMemoryRelevance(context, 3);
142
- return formatScoredMemories(memories, goal || "current context");
143
- }
144
- function formatDecisionTemplate() {
145
- return [
146
- "\u{1F4DD} **Decision Recording Template**",
147
- "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",
148
- "",
149
- "Use kuma_decision({ action: 'record', ... }) to log important decisions:",
150
- "",
151
- "```",
152
- "kuma_decision({",
153
- " action: 'record',",
154
- " title: 'Why Redis instead of in-memory cache',",
155
- " context: 'Need stateless auth for mobile clients',",
156
- " options: ['Redis', 'In-memory', 'Database'],",
157
- " rationale: 'Latency <10ms with persistence required',",
158
- " outcome: 'Redis chosen'",
159
- "})",
160
- "```",
161
- "",
162
- "\u{1F4A1} Call kuma_decision({ action: 'suggest' }) to check if now is a good time to record."
163
- ].join("\n");
164
- }
165
-
166
- export {
167
- scoreMemoryRelevance,
168
- recordDecision,
169
- shouldRecordDecision,
170
- getProactiveMemories,
171
- formatDecisionTemplate
172
- };