@hawon/nexus 0.2.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 (37) hide show
  1. package/dist/cli/index.js +44 -71
  2. package/dist/index.js +15 -24
  3. package/dist/mcp/server.js +7 -6
  4. package/package.json +1 -1
  5. package/scripts/benchmark.ts +13 -35
  6. package/src/cli/index.ts +45 -84
  7. package/src/index.ts +17 -27
  8. package/src/mcp/server.ts +8 -7
  9. package/src/memory-engine/index.ts +4 -6
  10. package/src/memory-engine/semantic.ts +38 -11
  11. package/src/promptguard/advanced-rules.ts +122 -5
  12. package/src/promptguard/entropy.ts +21 -2
  13. package/src/promptguard/rules.ts +87 -2
  14. package/src/promptguard/scanner.test.ts +1 -4
  15. package/src/promptguard/scanner.ts +1 -1
  16. package/src/promptguard/semantic.ts +19 -4
  17. package/src/promptguard/token-analysis.ts +17 -5
  18. package/src/review/analyzer.ts +106 -23
  19. package/src/skills/index.ts +11 -27
  20. package/src/testing/health-check.ts +19 -2
  21. package/src/memory-engine/compressor.ts +0 -97
  22. package/src/memory-engine/context-window.ts +0 -113
  23. package/src/memory-engine/store.ts +0 -371
  24. package/src/memory-engine/types.ts +0 -32
  25. package/src/skills/context-engine.ts +0 -863
  26. package/src/skills/extractor.ts +0 -224
  27. package/src/skills/global-context.ts +0 -731
  28. package/src/skills/library.ts +0 -189
  29. package/src/skills/pattern-engine.ts +0 -715
  30. package/src/skills/render-evolved.ts +0 -160
  31. package/src/skills/skill-reconciler.ts +0 -699
  32. package/src/skills/smart-extractor.ts +0 -849
  33. package/src/skills/types.ts +0 -18
  34. package/src/skills/wisdom-extractor.ts +0 -737
  35. package/src/superdev-evolution/index.ts +0 -3
  36. package/src/superdev-evolution/skill-manager.ts +0 -266
  37. 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
- }