bluera-knowledge 0.11.5 → 0.11.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.
@@ -4,6 +4,17 @@ import { DependencyUsageAnalyzer } from '../analysis/dependency-usage-analyzer.j
4
4
  import { RepoUrlResolver } from '../analysis/repo-url-resolver.js';
5
5
  import { createServices } from '../services/index.js';
6
6
 
7
+ /**
8
+ * Options passed from CLI global options to plugin command handlers.
9
+ */
10
+ export interface CommandOptions {
11
+ config?: string | undefined;
12
+ dataDir?: string | undefined;
13
+ projectRoot?: string | undefined;
14
+ format?: 'json' | 'table' | 'plain' | undefined;
15
+ quiet?: boolean | undefined;
16
+ }
17
+
7
18
  export async function handleSearch(args: {
8
19
  query: string;
9
20
  stores?: string;
@@ -45,13 +56,19 @@ export async function handleSearch(args: {
45
56
  }
46
57
  }
47
58
 
48
- export async function handleAddRepo(args: {
49
- url: string;
50
- name?: string;
51
- branch?: string;
52
- }): Promise<void> {
53
- // PWD is set by Claude Code to user's project directory
54
- const services = await createServices(undefined, undefined, process.env['PWD']);
59
+ export async function handleAddRepo(
60
+ args: {
61
+ url: string;
62
+ name?: string;
63
+ branch?: string;
64
+ },
65
+ options: CommandOptions = {}
66
+ ): Promise<void> {
67
+ const services = await createServices(
68
+ options.config,
69
+ options.dataDir,
70
+ options.projectRoot ?? process.env['PWD']
71
+ );
55
72
  const storeName = args.name ?? extractRepoName(args.url);
56
73
 
57
74
  console.log(`Cloning ${args.url}...`);
@@ -84,9 +101,15 @@ export async function handleAddRepo(args: {
84
101
  }
85
102
  }
86
103
 
87
- export async function handleAddFolder(args: { path: string; name?: string }): Promise<void> {
88
- // PWD is set by Claude Code to user's project directory
89
- const services = await createServices(undefined, undefined, process.env['PWD']);
104
+ export async function handleAddFolder(
105
+ args: { path: string; name?: string },
106
+ options: CommandOptions = {}
107
+ ): Promise<void> {
108
+ const services = await createServices(
109
+ options.config,
110
+ options.dataDir,
111
+ options.projectRoot ?? process.env['PWD']
112
+ );
90
113
  const { basename } = await import('node:path');
91
114
  const storeName = args.name ?? basename(args.path);
92
115
 
@@ -142,9 +165,12 @@ export async function handleIndex(args: { store: string }): Promise<void> {
142
165
  }
143
166
  }
144
167
 
145
- export async function handleStores(): Promise<void> {
146
- // PWD is set by Claude Code to user's project directory
147
- const services = await createServices(undefined, undefined, process.env['PWD']);
168
+ export async function handleStores(options: CommandOptions = {}): Promise<void> {
169
+ const services = await createServices(
170
+ options.config,
171
+ options.dataDir,
172
+ options.projectRoot ?? process.env['PWD']
173
+ );
148
174
  const stores = await services.store.list();
149
175
 
150
176
  if (stores.length === 0) {
@@ -176,14 +202,13 @@ export async function handleStores(): Promise<void> {
176
202
  }
177
203
  }
178
204
 
179
- export async function handleSuggest(): Promise<void> {
180
- // PWD is set by Claude Code to user's project directory
181
- const projectRoot = process.env['PWD'] ?? process.cwd();
205
+ export async function handleSuggest(options: CommandOptions = {}): Promise<void> {
206
+ const projectRoot = options.projectRoot ?? process.env['PWD'] ?? process.cwd();
182
207
 
183
208
  console.log('Analyzing project dependencies...\n');
184
209
 
185
210
  // Create analyzer instance
186
- const services = await createServices(undefined, undefined, projectRoot);
211
+ const services = await createServices(options.config, options.dataDir, projectRoot);
187
212
  const analyzer = new DependencyUsageAnalyzer();
188
213
  const resolver = new RepoUrlResolver();
189
214
 
@@ -0,0 +1,34 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readFileSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ /**
6
+ * Tests for validate-npm-release.sh script.
7
+ * Ensures the script follows best practices for cross-platform compatibility.
8
+ */
9
+ describe('validate-npm-release.sh', () => {
10
+ const scriptPath = join(process.cwd(), 'scripts/validate-npm-release.sh');
11
+ const scriptContent = readFileSync(scriptPath, 'utf-8');
12
+
13
+ it('does not use hardcoded /tmp paths', () => {
14
+ // Script should use mktemp -d for temporary directories, not hardcoded /tmp
15
+ // This ensures better cross-platform compatibility and avoids path collisions
16
+
17
+ // Check for hardcoded /tmp assignments (excluding comments)
18
+ const lines = scriptContent.split('\n').filter((line) => !line.trim().startsWith('#'));
19
+ const hasHardcodedTmp = lines.some((line) => /=["']?\/tmp\//.test(line));
20
+
21
+ expect(hasHardcodedTmp).toBe(false);
22
+ });
23
+
24
+ it('uses mktemp for temporary directories', () => {
25
+ // Should use mktemp -d for creating temporary directories
26
+ expect(scriptContent).toContain('mktemp -d');
27
+ });
28
+
29
+ it('cleans up temporary directories on exit', () => {
30
+ // Should have a trap to clean up on exit
31
+ expect(scriptContent).toContain('trap');
32
+ expect(scriptContent).toMatch(/rm -rf/);
33
+ });
34
+ });
package/.mcp.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "mcpServers": {
3
- "bluera-knowledge": {
4
- "command": "node",
5
- "args": ["./dist/mcp/server.js"],
6
- "env": {
7
- "PROJECT_ROOT": "${PWD}",
8
- "DATA_DIR": ".bluera/bluera-knowledge/data",
9
- "CONFIG_PATH": ".bluera/bluera-knowledge/config.json"
10
- }
11
- }
12
- }
13
- }
@@ -1,43 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { readFileSync } from 'fs';
3
- import { join } from 'path';
4
-
5
- /**
6
- * Tests to verify .mcp.json is correctly configured for project-level use.
7
- * The MCP server should work when running from the project directory,
8
- * not just when loaded as a Claude Code plugin.
9
- */
10
- describe('MCP Configuration (.mcp.json)', () => {
11
- const configPath = join(process.cwd(), '.mcp.json');
12
- const config = JSON.parse(readFileSync(configPath, 'utf-8'));
13
-
14
- it('does not use CLAUDE_PLUGIN_ROOT (only available in plugin mode)', () => {
15
- const serverConfig = config.mcpServers['bluera-knowledge'];
16
- const argsString = JSON.stringify(serverConfig.args);
17
-
18
- // CLAUDE_PLUGIN_ROOT is only set when running as a Claude Code plugin
19
- // .mcp.json is for project-level config, so it should use relative paths
20
- expect(argsString).not.toContain('CLAUDE_PLUGIN_ROOT');
21
- });
22
-
23
- it('uses relative path for server entry point', () => {
24
- const serverConfig = config.mcpServers['bluera-knowledge'];
25
-
26
- // Should use ./dist/mcp/server.js or similar relative path
27
- expect(serverConfig.args).toContain('./dist/mcp/server.js');
28
- });
29
-
30
- it('sets PROJECT_ROOT environment variable', () => {
31
- const serverConfig = config.mcpServers['bluera-knowledge'];
32
-
33
- // MCP server requires PROJECT_ROOT to function
34
- expect(serverConfig.env).toHaveProperty('PROJECT_ROOT');
35
- });
36
-
37
- it('uses PWD for PROJECT_ROOT', () => {
38
- const serverConfig = config.mcpServers['bluera-knowledge'];
39
-
40
- // PROJECT_ROOT should be set to PWD (current working directory)
41
- expect(serverConfig.env['PROJECT_ROOT']).toBe('${PWD}');
42
- });
43
- });