@hawon/nexus 0.1.0 → 0.3.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 (52) hide show
  1. package/README.md +60 -38
  2. package/dist/cli/index.js +76 -145
  3. package/dist/index.js +15 -26
  4. package/dist/mcp/server.js +61 -32
  5. package/package.json +2 -1
  6. package/scripts/auto-skill.sh +54 -0
  7. package/scripts/auto-sync.sh +11 -0
  8. package/scripts/benchmark.ts +444 -0
  9. package/scripts/scan-tool-result.sh +46 -0
  10. package/src/cli/index.ts +79 -172
  11. package/src/index.ts +17 -29
  12. package/src/mcp/server.ts +67 -41
  13. package/src/memory-engine/index.ts +4 -6
  14. package/src/memory-engine/nexus-memory.test.ts +437 -0
  15. package/src/memory-engine/nexus-memory.ts +631 -0
  16. package/src/memory-engine/semantic.ts +380 -0
  17. package/src/parser/parse.ts +1 -21
  18. package/src/promptguard/advanced-rules.ts +129 -12
  19. package/src/promptguard/entropy.ts +21 -2
  20. package/src/promptguard/evolution/auto-update.ts +16 -6
  21. package/src/promptguard/multilingual-rules.ts +68 -0
  22. package/src/promptguard/rules.ts +87 -2
  23. package/src/promptguard/scanner.test.ts +262 -0
  24. package/src/promptguard/scanner.ts +1 -1
  25. package/src/promptguard/semantic.ts +19 -4
  26. package/src/promptguard/token-analysis.ts +17 -5
  27. package/src/review/analyzer.test.ts +279 -0
  28. package/src/review/analyzer.ts +112 -28
  29. package/src/shared/stop-words.ts +21 -0
  30. package/src/skills/index.ts +11 -27
  31. package/src/skills/memory-skill-engine.ts +1044 -0
  32. package/src/testing/health-check.ts +19 -2
  33. package/src/cost/index.ts +0 -3
  34. package/src/cost/tracker.ts +0 -290
  35. package/src/cost/types.ts +0 -34
  36. package/src/memory-engine/compressor.ts +0 -97
  37. package/src/memory-engine/context-window.ts +0 -113
  38. package/src/memory-engine/store.ts +0 -371
  39. package/src/memory-engine/types.ts +0 -32
  40. package/src/skills/context-engine.ts +0 -863
  41. package/src/skills/extractor.ts +0 -224
  42. package/src/skills/global-context.ts +0 -726
  43. package/src/skills/library.ts +0 -189
  44. package/src/skills/pattern-engine.ts +0 -712
  45. package/src/skills/render-evolved.ts +0 -160
  46. package/src/skills/skill-reconciler.ts +0 -703
  47. package/src/skills/smart-extractor.ts +0 -843
  48. package/src/skills/types.ts +0 -18
  49. package/src/skills/wisdom-extractor.ts +0 -737
  50. package/src/superdev-evolution/index.ts +0 -3
  51. package/src/superdev-evolution/skill-manager.ts +0 -266
  52. package/src/superdev-evolution/types.ts +0 -20
@@ -1,160 +0,0 @@
1
- /**
2
- * Renders EvolvedSkill objects into rich Obsidian markdown
3
- * with evolution timeline, drift analysis, and anti-patterns.
4
- */
5
-
6
- import { writeFileSync, mkdirSync, existsSync } from "node:fs";
7
- import { join } from "node:path";
8
- import type { EvolvedSkill, EvolutionEntry, DriftAnalysis } from "./pattern-engine.js";
9
-
10
- export function renderEvolvedSkillMarkdown(skill: EvolvedSkill): string {
11
- const lines: string[] = [];
12
-
13
- // Frontmatter
14
- lines.push("---");
15
- lines.push(`type: evolved-skill`);
16
- lines.push(`id: "${skill.id}"`);
17
- lines.push(`name: "${skill.name}"`);
18
- lines.push(`confidence: ${skill.confidence.toFixed(2)}`);
19
- lines.push(`occurrences: ${skill.occurrences}`);
20
- lines.push(`first_seen: "${skill.firstSeen.slice(0, 10)}"`);
21
- lines.push(`last_seen: "${skill.lastSeen.slice(0, 10)}"`);
22
- lines.push(`tools: [${skill.currentApproach.tools.map((t) => `"${t}"`).join(", ")}]`);
23
- lines.push(`tags: [claude/evolved-skill]`);
24
- lines.push("---");
25
- lines.push("");
26
-
27
- // Title
28
- lines.push(`# ${skill.name}`);
29
- lines.push("");
30
- lines.push(`> ${skill.description}`);
31
- lines.push(`>`);
32
- lines.push(`> **Confidence**: ${(skill.confidence * 100).toFixed(0)}% | **Seen**: ${skill.occurrences}x | **First**: ${skill.firstSeen.slice(0, 10)} | **Last**: ${skill.lastSeen.slice(0, 10)}`);
33
- lines.push("");
34
-
35
- // Current Best Approach
36
- lines.push("## Current Approach");
37
- lines.push("");
38
- if (skill.currentApproach.steps.length > 0) {
39
- for (let i = 0; i < skill.currentApproach.steps.length; i++) {
40
- lines.push(`${i + 1}. \`${skill.currentApproach.steps[i]}\``);
41
- }
42
- } else {
43
- lines.push("_No structured steps recorded._");
44
- }
45
- lines.push("");
46
-
47
- // Evolution Timeline
48
- if (skill.evolution.length > 1) {
49
- lines.push("## Evolution Timeline");
50
- lines.push("");
51
- lines.push("How this skill changed over time:");
52
- lines.push("");
53
-
54
- for (let i = 0; i < skill.evolution.length; i++) {
55
- const entry = skill.evolution[i];
56
- const outcomeEmoji = entry.outcome === "success" ? "✅"
57
- : entry.outcome === "failure" ? "❌"
58
- : entry.outcome === "partial" ? "⚠️" : "❓";
59
-
60
- lines.push(`### ${i + 1}. ${entry.timestamp.slice(0, 10)} ${outcomeEmoji}`);
61
- lines.push("");
62
- lines.push(`**Session**: \`${entry.sessionId.slice(0, 8)}...\``);
63
- lines.push(`**Context**: ${entry.contextSummary || "_no context_"}`);
64
- lines.push("");
65
-
66
- if (entry.approach.length > 0) {
67
- lines.push("**Steps:**");
68
- for (const step of entry.approach.slice(0, 10)) {
69
- lines.push(`- \`${step}\``);
70
- }
71
- lines.push("");
72
- }
73
-
74
- // Drift from previous
75
- if (entry.drift && entry.drift.changes.length > 0) {
76
- lines.push(renderDrift(entry.drift));
77
- lines.push("");
78
- }
79
- }
80
- }
81
-
82
- // Applicable Contexts
83
- if (skill.applicableContexts.length > 0) {
84
- lines.push("## When to Use");
85
- lines.push("");
86
- for (const ctx of skill.applicableContexts) {
87
- lines.push(`- ${ctx}`);
88
- }
89
- lines.push("");
90
- }
91
-
92
- // Anti-Patterns
93
- if (skill.antiPatterns.length > 0) {
94
- lines.push("## Anti-Patterns");
95
- lines.push("");
96
- lines.push("Approaches that didn't work:");
97
- lines.push("");
98
- for (const ap of skill.antiPatterns) {
99
- lines.push(`- ⚠️ ${ap}`);
100
- }
101
- lines.push("");
102
- }
103
-
104
- return lines.join("\n");
105
- }
106
-
107
- function renderDrift(drift: DriftAnalysis): string {
108
- const lines: string[] = [];
109
-
110
- const reasonLabel: Record<string, string> = {
111
- user_correction: "🔄 User corrected the approach",
112
- failure_recovery: "🔧 Previous approach failed, recovered",
113
- optimization: "⚡ Optimized method",
114
- scope_change: "📐 Scope changed",
115
- context_dependent: "🌍 Different context required different approach",
116
- unknown: "❔ Reason unclear",
117
- };
118
-
119
- lines.push(`> **Why it changed**: ${reasonLabel[drift.reason] ?? drift.reason} (confidence: ${(drift.confidence * 100).toFixed(0)}%)`);
120
-
121
- if (drift.changes.length > 0) {
122
- lines.push(">");
123
- for (const change of drift.changes) {
124
- lines.push(`> - **${change.aspect}**: ${change.description}`);
125
- lines.push(`> - Before: \`${change.old.slice(0, 80)}\``);
126
- lines.push(`> - After: \`${change.new.slice(0, 80)}\``);
127
- }
128
- }
129
-
130
- return lines.join("\n");
131
- }
132
-
133
- /**
134
- * Export evolved skills to Obsidian vault.
135
- */
136
- export function exportEvolvedSkills(
137
- skills: EvolvedSkill[],
138
- vaultPath: string,
139
- ): string[] {
140
- const dir = join(vaultPath, "Evolved Skills");
141
- if (!existsSync(dir)) {
142
- mkdirSync(dir, { recursive: true });
143
- }
144
-
145
- const files: string[] = [];
146
-
147
- for (const skill of skills) {
148
- const safeName = skill.name
149
- .replace(/[<>:"/\\|?*#^[\]]/g, "-")
150
- .replace(/-+/g, "-")
151
- .slice(0, 60);
152
-
153
- const filePath = join(dir, `${safeName}.md`);
154
- const markdown = renderEvolvedSkillMarkdown(skill);
155
- writeFileSync(filePath, markdown, "utf-8");
156
- files.push(filePath);
157
- }
158
-
159
- return files;
160
- }