@sdsrs/code-graph 0.93.1 → 0.95.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 (30) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/claude-plugin/scripts/auto-update.js +69 -9
  3. package/package.json +8 -7
  4. package/claude-plugin/scripts/adopt.test.js +0 -679
  5. package/claude-plugin/scripts/auto-update.test.js +0 -474
  6. package/claude-plugin/scripts/cg-answer.test.js +0 -309
  7. package/claude-plugin/scripts/claude-config.test.js +0 -58
  8. package/claude-plugin/scripts/covering-tests.test.js +0 -78
  9. package/claude-plugin/scripts/doctor.test.js +0 -215
  10. package/claude-plugin/scripts/find-binary.test.js +0 -246
  11. package/claude-plugin/scripts/hook-fire.test.js +0 -117
  12. package/claude-plugin/scripts/hooks.test.js +0 -230
  13. package/claude-plugin/scripts/incremental-index.test.js +0 -102
  14. package/claude-plugin/scripts/lifecycle.e2e.test.js +0 -179
  15. package/claude-plugin/scripts/lifecycle.test.js +0 -786
  16. package/claude-plugin/scripts/mcp-launcher.test.js +0 -162
  17. package/claude-plugin/scripts/mcp-stub.test.js +0 -207
  18. package/claude-plugin/scripts/post-grep-inject.test.js +0 -531
  19. package/claude-plugin/scripts/pr-impact-comment.test.js +0 -110
  20. package/claude-plugin/scripts/pre-edit-guide.test.js +0 -218
  21. package/claude-plugin/scripts/pre-grep-guide.test.js +0 -1682
  22. package/claude-plugin/scripts/pre-read-guide.test.js +0 -363
  23. package/claude-plugin/scripts/project-detect.test.js +0 -95
  24. package/claude-plugin/scripts/recommendation-log.test.js +0 -79
  25. package/claude-plugin/scripts/session-init.test.js +0 -479
  26. package/claude-plugin/scripts/statusline-composite.test.js +0 -65
  27. package/claude-plugin/scripts/statusline.test.js +0 -235
  28. package/claude-plugin/scripts/tmp-dir.test.js +0 -50
  29. package/claude-plugin/scripts/user-prompt-context.test.js +0 -743
  30. package/claude-plugin/scripts/version-utils.test.js +0 -141
@@ -1,141 +0,0 @@
1
- 'use strict';
2
- const test = require('node:test');
3
- const assert = require('node:assert/strict');
4
- const fs = require('fs');
5
- const os = require('os');
6
- const path = require('path');
7
-
8
- function mkDir(t, prefix) {
9
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
10
- t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
11
- return dir;
12
- }
13
-
14
- // ── readBinaryVersion ──
15
-
16
- test('readBinaryVersion returns version from valid binary', (t) => {
17
- const { readBinaryVersion } = require('./version-utils');
18
- const dir = mkDir(t, 'vu-');
19
- const bin = path.join(dir, 'code-graph-mcp');
20
- fs.writeFileSync(bin, [
21
- '#!/usr/bin/env bash',
22
- 'if [ "$1" = "--version" ]; then',
23
- ' echo "code-graph-mcp 1.2.3"',
24
- ' exit 0',
25
- 'fi',
26
- 'exit 0',
27
- ].join('\n'));
28
- fs.chmodSync(bin, 0o755);
29
- assert.equal(readBinaryVersion(bin), '1.2.3');
30
- });
31
-
32
- test('readBinaryVersion returns null for non-existent binary', () => {
33
- const { readBinaryVersion } = require('./version-utils');
34
- assert.equal(readBinaryVersion('/tmp/does-not-exist-binary'), null);
35
- });
36
-
37
- test('readBinaryVersion returns null for binary with unexpected output', (t) => {
38
- const { readBinaryVersion } = require('./version-utils');
39
- const dir = mkDir(t, 'vu-');
40
- const bin = path.join(dir, 'code-graph-mcp');
41
- fs.writeFileSync(bin, '#!/usr/bin/env bash\necho "something else"');
42
- fs.chmodSync(bin, 0o755);
43
- assert.equal(readBinaryVersion(bin), null);
44
- });
45
-
46
- // ── isDevMode ──
47
-
48
- function makeFakePluginRoot(t, { withCargo = false, withTarget = false, asSymlink = false } = {}) {
49
- const parent = mkDir(t, 'vu-dev-');
50
- const pluginRoot = path.join(parent, 'claude-plugin');
51
- fs.mkdirSync(pluginRoot, { recursive: true });
52
- if (withCargo) fs.writeFileSync(path.join(parent, 'Cargo.toml'), '[package]\nname = "x"\n');
53
- if (withTarget) fs.mkdirSync(path.join(parent, 'target'), { recursive: true });
54
-
55
- if (asSymlink) {
56
- const real = path.join(parent, 'real-plugin');
57
- fs.mkdirSync(real, { recursive: true });
58
- fs.rmSync(pluginRoot, { recursive: true, force: true });
59
- fs.symlinkSync(real, pluginRoot);
60
- }
61
- return pluginRoot;
62
- }
63
-
64
- function withEnv(t, key, value) {
65
- const original = process.env[key];
66
- if (value === undefined) delete process.env[key]; else process.env[key] = value;
67
- t.after(() => {
68
- if (original === undefined) delete process.env[key]; else process.env[key] = original;
69
- });
70
- }
71
-
72
- test('isDevMode returns true in source repo when Cargo.toml AND target/ both exist', (t) => {
73
- const { isDevMode } = require('./version-utils');
74
- withEnv(t, 'CODE_GRAPH_DEV', undefined);
75
- const pluginRoot = makeFakePluginRoot(t, { withCargo: true, withTarget: true });
76
- assert.equal(isDevMode(pluginRoot), true);
77
- });
78
-
79
- test('isDevMode returns false for marketplace clone (Cargo.toml without target/)', (t) => {
80
- const { isDevMode } = require('./version-utils');
81
- withEnv(t, 'CODE_GRAPH_DEV', undefined);
82
- // Marketplace clones the full repo (Cargo.toml is git-tracked) but `target/`
83
- // is gitignored, so a fresh marketplace install has no target/. This is the
84
- // exact misclassification fixed for issue #12.
85
- const pluginRoot = makeFakePluginRoot(t, { withCargo: true, withTarget: false });
86
- assert.equal(isDevMode(pluginRoot), false);
87
- });
88
-
89
- test('isDevMode returns false for fully unrelated install (no Cargo.toml, no target/)', (t) => {
90
- const { isDevMode } = require('./version-utils');
91
- withEnv(t, 'CODE_GRAPH_DEV', undefined);
92
- const pluginRoot = makeFakePluginRoot(t);
93
- assert.equal(isDevMode(pluginRoot), false);
94
- });
95
-
96
- test('isDevMode honors CODE_GRAPH_DEV=1 even when neither Cargo.toml nor target/ exist', (t) => {
97
- const { isDevMode } = require('./version-utils');
98
- withEnv(t, 'CODE_GRAPH_DEV', '1');
99
- const pluginRoot = makeFakePluginRoot(t);
100
- assert.equal(isDevMode(pluginRoot), true);
101
- });
102
-
103
- test('isDevMode returns true when plugin root is a symlink', (t) => {
104
- const { isDevMode } = require('./version-utils');
105
- withEnv(t, 'CODE_GRAPH_DEV', undefined);
106
- const pluginRoot = makeFakePluginRoot(t, { asSymlink: true });
107
- assert.equal(isDevMode(pluginRoot), true);
108
- });
109
-
110
- // ── getNewestMtime ──
111
-
112
- test('getNewestMtime returns 0 for non-existent directory', () => {
113
- const { getNewestMtime } = require('./version-utils');
114
- assert.equal(getNewestMtime('/tmp/no-such-dir-xyz'), 0);
115
- });
116
-
117
- test('getNewestMtime finds newest .rs file mtime', (t) => {
118
- const { getNewestMtime } = require('./version-utils');
119
- const dir = mkDir(t, 'vu-mtime-');
120
- const sub = path.join(dir, 'sub');
121
- fs.mkdirSync(sub);
122
-
123
- const older = path.join(dir, 'old.rs');
124
- const newer = path.join(sub, 'new.rs');
125
- fs.writeFileSync(older, 'fn old() {}');
126
-
127
- fs.writeFileSync(newer, 'fn new() {}');
128
- const futureMs = Date.now() + 1000;
129
- fs.utimesSync(newer, futureMs / 1000, futureMs / 1000);
130
-
131
- const newerMtime = fs.statSync(newer).mtimeMs;
132
- const result = getNewestMtime(dir, '.rs');
133
- assert.equal(result, newerMtime, 'should return exactly the newest file mtime');
134
- });
135
-
136
- test('getNewestMtime ignores non-matching extensions', (t) => {
137
- const { getNewestMtime } = require('./version-utils');
138
- const dir = mkDir(t, 'vu-ext-');
139
- fs.writeFileSync(path.join(dir, 'file.js'), 'hello');
140
- assert.equal(getNewestMtime(dir, '.rs'), 0);
141
- });