@unerr-ai/unerr 0.1.6 → 0.1.7
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.
- package/README.md +70 -194
- package/dist/cli.js +39149 -36991
- package/package.json +9 -2
- package/dist/__tests__/architecture-guard.test.js +0 -122
- package/dist/__tests__/arg-validator.test.js +0 -205
- package/dist/__tests__/ast-extractor.test.js +0 -203
- package/dist/__tests__/auto-bootstrap.test.js +0 -280
- package/dist/__tests__/background-indexer.test.js +0 -228
- package/dist/__tests__/blast-radius-engine.test.js +0 -200
- package/dist/__tests__/bridge-isolation.test.js +0 -37
- package/dist/__tests__/budget-enforcer.test.js +0 -53
- package/dist/__tests__/cfg-test-detection-perf.test.js +0 -82
- package/dist/__tests__/change-narrative.test.js +0 -190
- package/dist/__tests__/check-commit.test.js +0 -258
- package/dist/__tests__/checksum.test.js +0 -34
- package/dist/__tests__/commit-watcher.test.js +0 -154
- package/dist/__tests__/community-detection.test.js +0 -179
- package/dist/__tests__/community-tools.test.js +0 -299
- package/dist/__tests__/components.test.js +0 -449
- package/dist/__tests__/compression-log.test.js +0 -174
- package/dist/__tests__/compression-quality-monitor.test.js +0 -40
- package/dist/__tests__/config-healer.test.js +0 -165
- package/dist/__tests__/context-ledger.test.js +0 -58
- package/dist/__tests__/convention-detector.test.js +0 -99
- package/dist/__tests__/convention-learner.test.js +0 -86
- package/dist/__tests__/correction-detector.test.js +0 -330
- package/dist/__tests__/daemon-autostart-install.test.js +0 -283
- package/dist/__tests__/daemon-bridge.test.js +0 -222
- package/dist/__tests__/daemon-dashboard.test.js +0 -202
- package/dist/__tests__/daemon-registry.test.js +0 -240
- package/dist/__tests__/daemon-supervisor.test.js +0 -318
- package/dist/__tests__/daemon-version-check.test.js +0 -275
- package/dist/__tests__/decision-point-detector.test.js +0 -98
- package/dist/__tests__/deep-link.test.js +0 -143
- package/dist/__tests__/disallowed-tools.test.js +0 -115
- package/dist/__tests__/drift-tracker.test.js +0 -582
- package/dist/__tests__/durability-scorer.test.js +0 -152
- package/dist/__tests__/efficiency-tracker.test.js +0 -65
- package/dist/__tests__/enrich.test.js +0 -144
- package/dist/__tests__/entity-rewind.test.js +0 -248
- package/dist/__tests__/ephemeral.test.js +0 -111
- package/dist/__tests__/exploration-cost.test.js +0 -93
- package/dist/__tests__/fact-generator.test.js +0 -197
- package/dist/__tests__/file-l0-graph.test.js +0 -244
- package/dist/__tests__/file-logger.test.js +0 -82
- package/dist/__tests__/file-outline.test.js +0 -141
- package/dist/__tests__/file-read-protocol.test.js +0 -188
- package/dist/__tests__/format-encoder.test.js +0 -233
- package/dist/__tests__/git-attribution.test.js +0 -259
- package/dist/__tests__/graph-temporal-joiner.test.js +0 -219
- package/dist/__tests__/health-grade-enhanced.test.js +0 -138
- package/dist/__tests__/health-map-data.test.js +0 -173
- package/dist/__tests__/helpers/mcp-harness.js +0 -45
- package/dist/__tests__/helpers/mcp-harness.test.js +0 -68
- package/dist/__tests__/hook-dedup.test.js +0 -112
- package/dist/__tests__/hook-runner.test.js +0 -253
- package/dist/__tests__/indexer-cfg.test.js +0 -185
- package/dist/__tests__/indexer-cross-file.test.js +0 -172
- package/dist/__tests__/indexer-extraction.test.js +0 -245
- package/dist/__tests__/indexer-incremental.test.js +0 -232
- package/dist/__tests__/indexer-language-expansion.test.js +0 -165
- package/dist/__tests__/init-push.test.js +0 -131
- package/dist/__tests__/instruction-writer.test.js +0 -179
- package/dist/__tests__/intelligence-integration.test.js +0 -217
- package/dist/__tests__/intent-correlator.test.js +0 -175
- package/dist/__tests__/intent-detector.test.js +0 -235
- package/dist/__tests__/intent-encoder.test.js +0 -167
- package/dist/__tests__/java-build-tool-detection.test.js +0 -174
- package/dist/__tests__/layer3-sprint-q.test.js +0 -160
- package/dist/__tests__/layer3-sprint-r.test.js +0 -91
- package/dist/__tests__/layer3-sprint-s.test.js +0 -183
- package/dist/__tests__/layer3-sprint-t.test.js +0 -201
- package/dist/__tests__/layer3-sprint-u.test.js +0 -174
- package/dist/__tests__/layer4-sprint-ba2.test.js +0 -354
- package/dist/__tests__/layer4-sprint-ba4.test.js +0 -84
- package/dist/__tests__/layer4-sprint-vs.test.js +0 -105
- package/dist/__tests__/ledger-chains.test.js +0 -162
- package/dist/__tests__/lifecycle-machine.test.js +0 -226
- package/dist/__tests__/local-chat-provider.test.js +0 -170
- package/dist/__tests__/local-convention-detector.test.js +0 -308
- package/dist/__tests__/local-embeddings.test.js +0 -422
- package/dist/__tests__/local-graph.test.js +0 -540
- package/dist/__tests__/local-indexer.test.js +0 -228
- package/dist/__tests__/local-intelligence-l3.test.js +0 -332
- package/dist/__tests__/local-llm.test.js +0 -253
- package/dist/__tests__/local-mode-offline.test.js +0 -187
- package/dist/__tests__/local-mode-stats.test.js +0 -273
- package/dist/__tests__/local-mode-tui.test.js +0 -343
- package/dist/__tests__/local-parse.test.js +0 -199
- package/dist/__tests__/log-tailer.test.js +0 -208
- package/dist/__tests__/loop-breaker.test.js +0 -276
- package/dist/__tests__/loop-miner.test.js +0 -226
- package/dist/__tests__/mcp-config.test.js +0 -126
- package/dist/__tests__/mcp-content-json.test.js +0 -10
- package/dist/__tests__/mcp-envelope.test.js +0 -124
- package/dist/__tests__/metrics-store.test.js +0 -223
- package/dist/__tests__/native-watcher.test.js +0 -191
- package/dist/__tests__/navigation-hooks-agent-aware.test.js +0 -145
- package/dist/__tests__/negative-knowledge.test.js +0 -116
- package/dist/__tests__/network-boundary.test.js +0 -190
- package/dist/__tests__/network-firewall.test.js +0 -112
- package/dist/__tests__/nudge-invariants.test.js +0 -160
- package/dist/__tests__/nudge-v2.test.js +0 -225
- package/dist/__tests__/offline-rewind.test.js +0 -251
- package/dist/__tests__/open-threads.test.js +0 -89
- package/dist/__tests__/output-compressor.test.js +0 -93
- package/dist/__tests__/pending-violations.test.js +0 -112
- package/dist/__tests__/persistence-effectiveness.test.js +0 -143
- package/dist/__tests__/provider-factory.test.js +0 -42
- package/dist/__tests__/providers.test.js +0 -24
- package/dist/__tests__/proxy.test.js +0 -314
- package/dist/__tests__/query-router.test.js +0 -1018
- package/dist/__tests__/reasoning-quality-route.test.js +0 -138
- package/dist/__tests__/redactor.test.js +0 -120
- package/dist/__tests__/resource-monitor.test.js +0 -57
- package/dist/__tests__/response-envelope.test.js +0 -100
- package/dist/__tests__/risk-classifier.test.js +0 -101
- package/dist/__tests__/risk-signal-scope.test.js +0 -75
- package/dist/__tests__/rule-evaluator.test.js +0 -280
- package/dist/__tests__/scip-decoder.test.js +0 -49
- package/dist/__tests__/scip-downloader.test.js +0 -201
- package/dist/__tests__/scip-merger.test.js +0 -103
- package/dist/__tests__/search-index.test.js +0 -422
- package/dist/__tests__/semantic-enrichment.test.js +0 -360
- package/dist/__tests__/session-brief-builder.test.js +0 -187
- package/dist/__tests__/session-context.test.js +0 -221
- package/dist/__tests__/session-continuity.test.js +0 -144
- package/dist/__tests__/session-dedup.test.js +0 -74
- package/dist/__tests__/session-event-wiring.test.js +0 -206
- package/dist/__tests__/session-events.test.js +0 -149
- package/dist/__tests__/session-legend.test.js +0 -20
- package/dist/__tests__/session-persistence.test.js +0 -131
- package/dist/__tests__/session-resume-block.test.js +0 -107
- package/dist/__tests__/session-resume.test.js +0 -97
- package/dist/__tests__/session-summary-writer.test.js +0 -134
- package/dist/__tests__/shadow-ledger.test.js +0 -203
- package/dist/__tests__/shell-classifier.test.js +0 -151
- package/dist/__tests__/shell-compression-floor.test.js +0 -189
- package/dist/__tests__/shell-compression-v2.test.js +0 -339
- package/dist/__tests__/shell-compressor.test.js +0 -35
- package/dist/__tests__/shell-hooks.test.js +0 -128
- package/dist/__tests__/shell-strategies.test.js +0 -644
- package/dist/__tests__/shell-tee.test.js +0 -133
- package/dist/__tests__/signal-dedup.test.js +0 -158
- package/dist/__tests__/signal-reinforcer.test.js +0 -77
- package/dist/__tests__/signal-scorer.test.js +0 -251
- package/dist/__tests__/signal-show-store.test.js +0 -108
- package/dist/__tests__/smart-truncate.test.js +0 -215
- package/dist/__tests__/snapshot-v2.test.js +0 -113
- package/dist/__tests__/sprint-l1-local-mode.test.js +0 -130
- package/dist/__tests__/sprint-l10-boot.test.js +0 -220
- package/dist/__tests__/sprint-l9-offline-commands.test.js +0 -189
- package/dist/__tests__/sprint-q-persistent-context.test.js +0 -198
- package/dist/__tests__/sprint-s1-wiring.test.js +0 -215
- package/dist/__tests__/sprint-s2-wiring.test.js +0 -256
- package/dist/__tests__/sprint-s3-wiring.test.js +0 -195
- package/dist/__tests__/sprint-s4-wiring.test.js +0 -213
- package/dist/__tests__/sprint-s6-hooks.test.js +0 -222
- package/dist/__tests__/sprint-s7-persistent.test.js +0 -263
- package/dist/__tests__/sprint-s8-value.test.js +0 -167
- package/dist/__tests__/sprint-s9-behavioral.test.js +0 -179
- package/dist/__tests__/sprint3-intelligence.test.js +0 -297
- package/dist/__tests__/sprint5-mcp-server.test.js +0 -136
- package/dist/__tests__/startup-display.test.js +0 -302
- package/dist/__tests__/startup-log-file.test.js +0 -97
- package/dist/__tests__/stash-manager.test.js +0 -229
- package/dist/__tests__/state-detector.test.js +0 -92
- package/dist/__tests__/status-dashboard.test.js +0 -142
- package/dist/__tests__/temporal-facts.test.js +0 -292
- package/dist/__tests__/temporal-routes.test.js +0 -142
- package/dist/__tests__/test-detector.test.js +0 -174
- package/dist/__tests__/theme.test.js +0 -72
- package/dist/__tests__/timeline-agents.test.js +0 -122
- package/dist/__tests__/timeline-bootstrap.test.js +0 -176
- package/dist/__tests__/timeline-filters.test.js +0 -193
- package/dist/__tests__/timeline-markers.test.js +0 -151
- package/dist/__tests__/timeline-routes.test.js +0 -156
- package/dist/__tests__/timeline-store.test.js +0 -171
- package/dist/__tests__/token-counter.test.js +0 -86
- package/dist/__tests__/token-estimator.test.js +0 -96
- package/dist/__tests__/token-flow-api.test.js +0 -239
- package/dist/__tests__/token-flow-instrumentation.test.js +0 -437
- package/dist/__tests__/token-flow-persistence.test.js +0 -356
- package/dist/__tests__/token-flow-routes.test.js +0 -199
- package/dist/__tests__/token-flow.test.js +0 -695
- package/dist/__tests__/tool-clusters.test.js +0 -177
- package/dist/__tests__/transport-mux.test.js +0 -283
- package/dist/__tests__/turn-segmenter.test.js +0 -166
- package/dist/__tests__/uninstall.test.js +0 -141
- package/dist/__tests__/warm-start-policy.test.js +0 -271
- package/dist/__tests__/wire-cap-nudge.test.js +0 -77
- package/dist/__tests__/worker-pool.test.js +0 -101
- package/dist/ui/assets/index-7gl3mIuY.css +0 -1
- package/dist/ui/assets/index-CX4FCWGT.js +0 -10
- package/dist/ui/assets/rolldown-runtime-S-ySWqyJ.js +0 -1
- package/dist/ui/assets/vis-network-NIJHUFI3.js +0 -908
- package/dist/ui/fonts/jetbrains-mono-latin-400-normal.woff +0 -0
- package/dist/ui/icon-wordmark.png +0 -0
- package/dist/ui/icon-wordmark.svg +0 -30
- package/dist/ui/icon.png +0 -0
- package/dist/ui/icon.svg +0 -25
- package/dist/ui/index.html +0 -15
- package/dist/ui/prototype-sandbox/index.html +0 -257
- package/dist/ui/screenshots/activity.png +0 -0
- package/dist/ui/screenshots/code-base-intelligence.png +0 -0
- package/dist/ui/screenshots/dashboard.png +0 -0
- package/dist/ui/screenshots/project-memory.png +0 -0
- package/dist/ui/screenshots/reasoning-quality.png +0 -0
- package/dist/ui/screenshots/reasoning-session.png +0 -0
- package/dist/ui/screenshots/token-session.png +0 -0
- package/dist/ui/screenshots/token-trace-main.png +0 -0
- package/dist/ui/screenshots/token-turn.png +0 -0
- package/dist/ui/unerr-wordmark.png +0 -0
- package/dist/ui/unerr-wordmark.svg +0 -9
- package/dist/ui/unerr.png +0 -0
- package/dist/ui/unerr.svg +0 -25
- package/dist/ui/web-app-manifest-192x192.png +0 -0
- package/dist/ui/web-app-manifest-512x512.png +0 -0
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for config-verify.ts (P5.6-ADV-04) — Self-healing MCP configuration.
|
|
3
|
-
*
|
|
4
|
-
* Tests the actual checkIdeConfig and repairIdeConfig functions
|
|
5
|
-
* against real filesystem state to validate detection and repair logic.
|
|
6
|
-
*/
|
|
7
|
-
import * as fs from "node:fs";
|
|
8
|
-
import * as os from "node:os";
|
|
9
|
-
import * as path from "node:path";
|
|
10
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
11
|
-
import { checkIdeConfig, repairIdeConfig } from "../commands/config-verify.js";
|
|
12
|
-
describe("Config Healer (P5.6-ADV-04)", () => {
|
|
13
|
-
let tmpDir;
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
tmpDir = path.join(os.tmpdir(), `test-config-healer-${Date.now()}`);
|
|
16
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
17
|
-
});
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
20
|
-
});
|
|
21
|
-
// ── checkIdeConfig ────────────────────────────────────────────────
|
|
22
|
-
describe("checkIdeConfig", () => {
|
|
23
|
-
it("returns found=false when config file does not exist", () => {
|
|
24
|
-
const result = checkIdeConfig("cursor", path.join(tmpDir, "nonexistent.json"));
|
|
25
|
-
expect(result.found).toBe(false);
|
|
26
|
-
expect(result.configured).toBe(false);
|
|
27
|
-
expect(result.needsMigration).toBe(false);
|
|
28
|
-
expect(result.issues).toHaveLength(1);
|
|
29
|
-
expect(result.issues[0]).toContain("not found");
|
|
30
|
-
});
|
|
31
|
-
it("returns configured=false when mcpServers section is missing", () => {
|
|
32
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
33
|
-
fs.writeFileSync(configPath, JSON.stringify({ someOther: true }));
|
|
34
|
-
const result = checkIdeConfig("cursor", configPath);
|
|
35
|
-
expect(result.found).toBe(true);
|
|
36
|
-
expect(result.configured).toBe(false);
|
|
37
|
-
expect(result.issues[0]).toContain("No mcpServers section");
|
|
38
|
-
});
|
|
39
|
-
it("returns configured=false when unerr key is absent from mcpServers", () => {
|
|
40
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
41
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
42
|
-
mcpServers: { copilot: { command: "npx", args: ["copilot"] } },
|
|
43
|
-
}));
|
|
44
|
-
const result = checkIdeConfig("cursor", configPath);
|
|
45
|
-
expect(result.found).toBe(true);
|
|
46
|
-
expect(result.configured).toBe(false);
|
|
47
|
-
expect(result.issues[0]).toContain("No unerr MCP server configured");
|
|
48
|
-
});
|
|
49
|
-
it("flags remote URL config as needing migration", () => {
|
|
50
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
51
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
52
|
-
mcpServers: {
|
|
53
|
-
unerr: { url: "https://api.unerr.io/mcp/sse" },
|
|
54
|
-
},
|
|
55
|
-
}));
|
|
56
|
-
const result = checkIdeConfig("cursor", configPath);
|
|
57
|
-
expect(result.found).toBe(true);
|
|
58
|
-
expect(result.configured).toBe(true);
|
|
59
|
-
expect(result.needsMigration).toBe(true);
|
|
60
|
-
expect(result.issues[0]).toContain("remote URL");
|
|
61
|
-
expect(result.issues[0]).toContain("local proxy");
|
|
62
|
-
});
|
|
63
|
-
it("passes when using correct local proxy format", () => {
|
|
64
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
65
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
66
|
-
mcpServers: {
|
|
67
|
-
unerr: { command: "unerr", args: ["--mcp"] },
|
|
68
|
-
},
|
|
69
|
-
}));
|
|
70
|
-
const result = checkIdeConfig("cursor", configPath);
|
|
71
|
-
expect(result.found).toBe(true);
|
|
72
|
-
expect(result.configured).toBe(true);
|
|
73
|
-
expect(result.needsMigration).toBe(false);
|
|
74
|
-
expect(result.issues).toHaveLength(0);
|
|
75
|
-
});
|
|
76
|
-
it("flags unexpected config format as needing migration", () => {
|
|
77
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
78
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
79
|
-
mcpServers: {
|
|
80
|
-
unerr: { command: "node", args: ["custom-server.js"] },
|
|
81
|
-
},
|
|
82
|
-
}));
|
|
83
|
-
const result = checkIdeConfig("cursor", configPath);
|
|
84
|
-
expect(result.needsMigration).toBe(true);
|
|
85
|
-
expect(result.issues[0]).toContain("unexpected format");
|
|
86
|
-
});
|
|
87
|
-
it("handles malformed JSON gracefully", () => {
|
|
88
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
89
|
-
fs.writeFileSync(configPath, "{ invalid json !!!");
|
|
90
|
-
const result = checkIdeConfig("cursor", configPath);
|
|
91
|
-
expect(result.found).toBe(true);
|
|
92
|
-
expect(result.configured).toBe(false);
|
|
93
|
-
expect(result.issues[0]).toContain("Failed to parse");
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
// ── repairIdeConfig ───────────────────────────────────────────────
|
|
97
|
-
describe("repairIdeConfig", () => {
|
|
98
|
-
it("creates config file from scratch when none exists", () => {
|
|
99
|
-
const configDir = path.join(tmpDir, ".cursor");
|
|
100
|
-
const configPath = path.join(configDir, "mcp.json");
|
|
101
|
-
expect(fs.existsSync(configPath)).toBe(false);
|
|
102
|
-
const success = repairIdeConfig("cursor", configPath);
|
|
103
|
-
expect(success).toBe(true);
|
|
104
|
-
const written = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
105
|
-
expect(written.mcpServers.unerr?.command).toBe("unerr");
|
|
106
|
-
expect(written.mcpServers.unerr?.args).toContain("--mcp");
|
|
107
|
-
});
|
|
108
|
-
it("preserves existing non-unerr MCP servers during repair", () => {
|
|
109
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
110
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
111
|
-
mcpServers: {
|
|
112
|
-
copilot: { command: "npx", args: ["copilot-mcp"] },
|
|
113
|
-
cody: { url: "http://localhost:4000/mcp" },
|
|
114
|
-
},
|
|
115
|
-
}));
|
|
116
|
-
repairIdeConfig("cursor", configPath);
|
|
117
|
-
const result = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
118
|
-
expect(Object.keys(result.mcpServers)).toHaveLength(3);
|
|
119
|
-
expect(result.mcpServers.copilot).toBeDefined();
|
|
120
|
-
expect(result.mcpServers.cody).toBeDefined();
|
|
121
|
-
expect(result.mcpServers.unerr).toBeDefined();
|
|
122
|
-
});
|
|
123
|
-
it("replaces remote URL config with local proxy config", () => {
|
|
124
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
125
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
126
|
-
mcpServers: {
|
|
127
|
-
unerr: { url: "https://api.unerr.io/mcp/sse" },
|
|
128
|
-
},
|
|
129
|
-
}));
|
|
130
|
-
repairIdeConfig("cursor", configPath);
|
|
131
|
-
const result = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
132
|
-
// Should now be local proxy format, not remote URL
|
|
133
|
-
expect(result.mcpServers.unerr?.command).toBe("unerr");
|
|
134
|
-
expect(result.mcpServers.unerr?.url).toBeUndefined();
|
|
135
|
-
});
|
|
136
|
-
it("creates parent directory if it doesn't exist", () => {
|
|
137
|
-
const deepPath = path.join(tmpDir, "a", "b", "c", "mcp.json");
|
|
138
|
-
const success = repairIdeConfig("cursor", deepPath);
|
|
139
|
-
expect(success).toBe(true);
|
|
140
|
-
expect(fs.existsSync(deepPath)).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
// ── checkIdeConfig + repairIdeConfig integration ──────────────────
|
|
144
|
-
describe("check → repair → re-check cycle", () => {
|
|
145
|
-
it("repair fixes all issues detected by check", () => {
|
|
146
|
-
const configPath = path.join(tmpDir, "mcp.json");
|
|
147
|
-
// Start with broken config
|
|
148
|
-
fs.writeFileSync(configPath, JSON.stringify({
|
|
149
|
-
mcpServers: { other: { url: "http://example.com" } },
|
|
150
|
-
}));
|
|
151
|
-
// Step 1: check — should find issues
|
|
152
|
-
const check1 = checkIdeConfig("cursor", configPath);
|
|
153
|
-
expect(check1.configured).toBe(false);
|
|
154
|
-
expect(check1.issues.length).toBeGreaterThan(0);
|
|
155
|
-
// Step 2: repair
|
|
156
|
-
const repaired = repairIdeConfig("cursor", configPath);
|
|
157
|
-
expect(repaired).toBe(true);
|
|
158
|
-
// Step 3: re-check — should pass
|
|
159
|
-
const check2 = checkIdeConfig("cursor", configPath);
|
|
160
|
-
expect(check2.configured).toBe(true);
|
|
161
|
-
expect(check2.needsMigration).toBe(false);
|
|
162
|
-
expect(check2.issues).toHaveLength(0);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, rmSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
-
import { createContextLedger } from "../tracking/context-ledger.js";
|
|
6
|
-
let tempDir;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
tempDir = join(tmpdir(), `unerr-ctx-ledger-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
9
|
-
mkdirSync(tempDir, { recursive: true });
|
|
10
|
-
});
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
13
|
-
});
|
|
14
|
-
describe("createContextLedger", () => {
|
|
15
|
-
it("initializes with empty state", () => {
|
|
16
|
-
const ledger = createContextLedger(tempDir);
|
|
17
|
-
expect(ledger.getDeliveredCount()).toBe(0);
|
|
18
|
-
});
|
|
19
|
-
it("marks and queries delivered keys", () => {
|
|
20
|
-
const ledger = createContextLedger(tempDir);
|
|
21
|
-
ledger.markDelivered("entity-a", ["blast_radius", "conventions"]);
|
|
22
|
-
expect(ledger.hasDelivered("entity-a", "blast_radius")).toBe(true);
|
|
23
|
-
expect(ledger.hasDelivered("entity-a", "conventions")).toBe(true);
|
|
24
|
-
expect(ledger.hasDelivered("entity-a", "unknown")).toBe(false);
|
|
25
|
-
expect(ledger.hasDelivered("entity-b", "blast_radius")).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
it("persists across sessions (save + load)", () => {
|
|
28
|
-
const ledger1 = createContextLedger(tempDir);
|
|
29
|
-
ledger1.markDelivered("entity-x", ["ctx-1", "ctx-2"]);
|
|
30
|
-
ledger1.save(ledger1.load());
|
|
31
|
-
const delivered = new Map();
|
|
32
|
-
delivered.set("entity-x", new Set(["ctx-1", "ctx-2"]));
|
|
33
|
-
ledger1.save(delivered);
|
|
34
|
-
const ledger2 = createContextLedger(tempDir);
|
|
35
|
-
expect(ledger2.hasDelivered("entity-x", "ctx-1")).toBe(true);
|
|
36
|
-
expect(ledger2.hasDelivered("entity-x", "ctx-2")).toBe(true);
|
|
37
|
-
expect(ledger2.getDeliveredCount()).toBe(2);
|
|
38
|
-
});
|
|
39
|
-
it("tracks delivered count", () => {
|
|
40
|
-
const ledger = createContextLedger(tempDir);
|
|
41
|
-
ledger.markDelivered("e1", ["a", "b"]);
|
|
42
|
-
ledger.markDelivered("e2", ["c"]);
|
|
43
|
-
expect(ledger.getDeliveredCount()).toBe(3);
|
|
44
|
-
});
|
|
45
|
-
it("prune removes old entries", () => {
|
|
46
|
-
const ledger = createContextLedger(tempDir);
|
|
47
|
-
ledger.markDelivered("e1", ["old-key"]);
|
|
48
|
-
const pruned = ledger.prune();
|
|
49
|
-
expect(pruned).toBeGreaterThanOrEqual(0);
|
|
50
|
-
});
|
|
51
|
-
it("handles missing state directory", () => {
|
|
52
|
-
const nonExistent = join(tempDir, "deep", "nested");
|
|
53
|
-
const ledger = createContextLedger(nonExistent);
|
|
54
|
-
expect(ledger.getDeliveredCount()).toBe(0);
|
|
55
|
-
ledger.markDelivered("e1", ["k1"]);
|
|
56
|
-
expect(ledger.getDeliveredCount()).toBe(1);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, rmSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
-
import { detectAllConventions, detectNamingConventions, detectStructureConventions, loadConventions, persistConventions, } from "../intelligence/convention-detector.js";
|
|
6
|
-
import { entityKey } from "../intelligence/indexer/entity-key.js";
|
|
7
|
-
let tempDir;
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
tempDir = join(tmpdir(), `unerr-conv-${Date.now()}`);
|
|
10
|
-
mkdirSync(tempDir, { recursive: true });
|
|
11
|
-
});
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
rmSync(tempDir, { recursive: true, force: true });
|
|
14
|
-
});
|
|
15
|
-
function makeEntity(name, kind, filePath) {
|
|
16
|
-
return {
|
|
17
|
-
key: entityKey(filePath, kind, name, ""),
|
|
18
|
-
kind: kind,
|
|
19
|
-
name,
|
|
20
|
-
file_path: filePath,
|
|
21
|
-
start_line: 1,
|
|
22
|
-
end_line: 5,
|
|
23
|
-
signature: `${name}()`,
|
|
24
|
-
body_hash: "h",
|
|
25
|
-
exported: true,
|
|
26
|
-
parent_key: null,
|
|
27
|
-
language: "typescript",
|
|
28
|
-
is_async: false,
|
|
29
|
-
parameter_count: 0,
|
|
30
|
-
doc: null,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
describe("Convention Detector (O.6-O.10)", () => {
|
|
34
|
-
it("detects naming suffix convention for Services", () => {
|
|
35
|
-
const entities = [
|
|
36
|
-
makeEntity("AuthService", "class", "src/auth.ts"),
|
|
37
|
-
makeEntity("PaymentService", "class", "src/payment.ts"),
|
|
38
|
-
makeEntity("UserService", "class", "src/user.ts"),
|
|
39
|
-
makeEntity("EmailService", "class", "src/email.ts"),
|
|
40
|
-
];
|
|
41
|
-
const conventions = detectNamingConventions(entities);
|
|
42
|
-
const serviceSuffix = conventions.find((c) => c.pattern === "*Service");
|
|
43
|
-
expect(serviceSuffix).toBeDefined();
|
|
44
|
-
expect(serviceSuffix?.confidence).toBeGreaterThan(0.5);
|
|
45
|
-
expect(serviceSuffix?.entityCount).toBeGreaterThanOrEqual(3);
|
|
46
|
-
});
|
|
47
|
-
it("detects naming prefix convention for functions", () => {
|
|
48
|
-
const entities = Array.from({ length: 8 }, (_, i) => makeEntity(`getUser${i}`, "function", `src/f${i}.ts`));
|
|
49
|
-
const conventions = detectNamingConventions(entities);
|
|
50
|
-
const getPrefix = conventions.find((c) => c.pattern === "get*");
|
|
51
|
-
expect(getPrefix).toBeDefined();
|
|
52
|
-
expect(getPrefix?.confidence).toBeGreaterThan(0.4);
|
|
53
|
-
});
|
|
54
|
-
it("detects structural conventions from directory organization", () => {
|
|
55
|
-
const entities = [
|
|
56
|
-
makeEntity("fn1", "function", "src/services/auth.ts"),
|
|
57
|
-
makeEntity("fn2", "function", "src/services/user.ts"),
|
|
58
|
-
makeEntity("fn3", "function", "src/services/payment.ts"),
|
|
59
|
-
makeEntity("fn4", "function", "src/utils/helper.ts"),
|
|
60
|
-
makeEntity("fn5", "function", "src/utils/format.ts"),
|
|
61
|
-
makeEntity("fn6", "function", "src/utils/validate.ts"),
|
|
62
|
-
];
|
|
63
|
-
const conventions = detectStructureConventions(entities);
|
|
64
|
-
expect(conventions.length).toBeGreaterThanOrEqual(0);
|
|
65
|
-
});
|
|
66
|
-
it("produces combined convention report", () => {
|
|
67
|
-
const entities = [
|
|
68
|
-
makeEntity("AuthService", "class", "src/services/auth.ts"),
|
|
69
|
-
makeEntity("UserService", "class", "src/services/user.ts"),
|
|
70
|
-
makeEntity("PayService", "class", "src/services/pay.ts"),
|
|
71
|
-
];
|
|
72
|
-
const edges = [];
|
|
73
|
-
const report = detectAllConventions(entities, edges);
|
|
74
|
-
expect(report.totalEntities).toBe(3);
|
|
75
|
-
expect(report.analyzedAt).toBeTruthy();
|
|
76
|
-
});
|
|
77
|
-
it("persists and loads conventions", () => {
|
|
78
|
-
const entities = [
|
|
79
|
-
makeEntity("AuthService", "class", "src/a.ts"),
|
|
80
|
-
makeEntity("UserService", "class", "src/b.ts"),
|
|
81
|
-
makeEntity("PayService", "class", "src/c.ts"),
|
|
82
|
-
];
|
|
83
|
-
const report = detectAllConventions(entities, []);
|
|
84
|
-
persistConventions(tempDir, report);
|
|
85
|
-
const loaded = loadConventions(tempDir);
|
|
86
|
-
expect(loaded).not.toBeNull();
|
|
87
|
-
expect(loaded?.totalEntities).toBe(3);
|
|
88
|
-
});
|
|
89
|
-
it("returns null for missing conventions file", () => {
|
|
90
|
-
expect(loadConventions(tempDir)).toBeNull();
|
|
91
|
-
});
|
|
92
|
-
it("filters low-confidence conventions", () => {
|
|
93
|
-
const entities = [makeEntity("foo", "function", "src/a.ts")];
|
|
94
|
-
const report = detectAllConventions(entities, []);
|
|
95
|
-
for (const conv of report.conventions) {
|
|
96
|
-
expect(conv.confidence).toBeGreaterThanOrEqual(0.5);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { learnConventions } from "../intelligence/convention-learner.js";
|
|
3
|
-
describe("learnConventions", () => {
|
|
4
|
-
it("detects co-change patterns from repeated file pairs", () => {
|
|
5
|
-
const entries = Array.from({ length: 4 }, (_, i) => ({
|
|
6
|
-
id: `e${i}`,
|
|
7
|
-
ts: new Date(Date.now() - (4 - i) * 60000).toISOString(),
|
|
8
|
-
tool: "sync_local_diff",
|
|
9
|
-
args_summary: { files: ["src/auth.ts", "src/auth.test.ts"] },
|
|
10
|
-
result_summary: {},
|
|
11
|
-
}));
|
|
12
|
-
const conventions = learnConventions(entries);
|
|
13
|
-
const coChange = conventions.find((c) => c.pattern === "co-change");
|
|
14
|
-
expect(coChange).toBeDefined();
|
|
15
|
-
expect(coChange?.observationCount).toBeGreaterThanOrEqual(3);
|
|
16
|
-
});
|
|
17
|
-
it("returns empty for insufficient data", () => {
|
|
18
|
-
const entries = [
|
|
19
|
-
{
|
|
20
|
-
id: "e1",
|
|
21
|
-
ts: "2026-04-30T10:00:00Z",
|
|
22
|
-
tool: "sync_local_diff",
|
|
23
|
-
args_summary: { files: ["a.ts"] },
|
|
24
|
-
result_summary: {},
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
const conventions = learnConventions(entries);
|
|
28
|
-
expect(conventions.filter((c) => c.pattern === "co-change")).toHaveLength(0);
|
|
29
|
-
});
|
|
30
|
-
it("returns empty for non-sync entries", () => {
|
|
31
|
-
const entries = [
|
|
32
|
-
{
|
|
33
|
-
id: "e1",
|
|
34
|
-
ts: "2026-04-30T10:00:00Z",
|
|
35
|
-
tool: "get_function",
|
|
36
|
-
args_summary: { key: "a" },
|
|
37
|
-
result_summary: {},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
id: "e2",
|
|
41
|
-
ts: "2026-04-30T10:01:00Z",
|
|
42
|
-
tool: "get_callers",
|
|
43
|
-
args_summary: { key: "b" },
|
|
44
|
-
result_summary: {},
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
expect(learnConventions(entries)).toHaveLength(0);
|
|
48
|
-
});
|
|
49
|
-
it("detects rename patterns from content changes", () => {
|
|
50
|
-
const entries = [
|
|
51
|
-
{
|
|
52
|
-
id: "e1",
|
|
53
|
-
ts: "2026-04-30T10:00:00Z",
|
|
54
|
-
tool: "sync_local_diff",
|
|
55
|
-
args_summary: {
|
|
56
|
-
files: [
|
|
57
|
-
{
|
|
58
|
-
path: "src/api.ts",
|
|
59
|
-
content: "export function getData() { return fetch('/api'); }",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
result_summary: {},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
id: "e2",
|
|
67
|
-
ts: "2026-04-30T10:01:00Z",
|
|
68
|
-
tool: "sync_local_diff",
|
|
69
|
-
args_summary: {
|
|
70
|
-
files: [
|
|
71
|
-
{
|
|
72
|
-
path: "src/api.ts",
|
|
73
|
-
content: "export function fetchData() { return fetch('/api'); }",
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
result_summary: {},
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
const conventions = learnConventions(entries);
|
|
81
|
-
const rename = conventions.find((c) => c.name.startsWith("Naming:"));
|
|
82
|
-
if (rename) {
|
|
83
|
-
expect(rename.pattern).toContain("fetch");
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|