visualknowledge 0.1.5 → 0.2.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.
@@ -3,6 +3,7 @@
3
3
  'use strict';
4
4
 
5
5
  const { spawn, exec } = require('child_process');
6
+ const fs = require('fs');
6
7
  const net = require('net');
7
8
  const os = require('os');
8
9
  const path = require('path');
@@ -238,14 +239,37 @@ function openBrowser(url) {
238
239
  });
239
240
  }
240
241
 
242
+ // ─── Claude Code Config Loader ─────────────────────────────────
243
+ function loadClaudeEnv() {
244
+ const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
245
+ if (!home) return null;
246
+
247
+ const candidates = [
248
+ path.join(home, '.claude', 'settings.json'),
249
+ ];
250
+
251
+ for (const configPath of candidates) {
252
+ try {
253
+ const raw = fs.readFileSync(configPath, 'utf8');
254
+ const data = JSON.parse(raw);
255
+ if (data && typeof data.env === 'object' && data.env !== null) {
256
+ return { env: data.env, source: configPath };
257
+ }
258
+ } catch (_) {
259
+ // File not found or parse error — skip silently
260
+ }
261
+ }
262
+ return null;
263
+ }
264
+
241
265
  // ─── T008: Python Flask Subprocess Launch ────────────────────
242
- function startServer(pythonCmd, port) {
266
+ function startServer(pythonCmd, port, mergedEnv) {
243
267
  const serverDir = path.resolve(__dirname, '..');
244
268
 
245
269
  const child = spawn(pythonCmd, ['server.py', '--port', String(port)], {
246
270
  cwd: serverDir,
247
271
  stdio: 'inherit',
248
- env: process.env,
272
+ env: mergedEnv,
249
273
  detached: false,
250
274
  });
251
275
 
@@ -327,6 +351,20 @@ async function main() {
327
351
  // Banner
328
352
  banner();
329
353
 
354
+ // Load Claude Code config (if available)
355
+ const claudeConfig = loadClaudeEnv();
356
+ // Claude config as base defaults, process.env always takes precedence
357
+ const mergedEnv = { ...(claudeConfig ? claudeConfig.env : {}), ...process.env };
358
+ if (claudeConfig) {
359
+ const hasKey = mergedEnv.ANTHROPIC_AUTH_TOKEN || mergedEnv.ANTHROPIC_API_KEY;
360
+ console.log(`${OK} Claude Code config loaded${hasKey ? '' : ' (no API key found)'}`);
361
+ } else {
362
+ const hasKey = process.env.ANTHROPIC_AUTH_TOKEN || process.env.ANTHROPIC_API_KEY;
363
+ if (!hasKey) {
364
+ console.log(`${WARN} No API key found (set ANTHROPIC_API_KEY or install Claude Code)`);
365
+ }
366
+ }
367
+
330
368
  // Environment checks (T003-T005)
331
369
  checkNodeVersion();
332
370
  const pythonCmd = await checkPython();
@@ -349,7 +387,7 @@ async function main() {
349
387
 
350
388
  // Start Python server (T008)
351
389
  console.log('\n Starting server...');
352
- const child = startServer(pythonCmd, actualPort);
390
+ const child = startServer(pythonCmd, actualPort, mergedEnv);
353
391
 
354
392
  // Setup graceful shutdown (T016-T018)
355
393
  setupShutdownHandlers(child);
@@ -30,7 +30,7 @@
30
30
  "react-dom/client": "https://esm.sh/react-dom@18.3.1/client",
31
31
  "react/jsx-runtime": "https://esm.sh/react@18.3.1/jsx-runtime",
32
32
  "htm": "https://esm.sh/htm@3.1.1",
33
- "htm/react": "https://esm.sh/htm@3.1.1/react"
33
+ "htm/react": "./src/lib/html.js"
34
34
  }
35
35
  }
36
36
  </script>
@@ -0,0 +1,11 @@
1
+ /**
2
+ * html tagged template - binds htm to React.createElement
3
+ *
4
+ * Ensures a single React instance is used across the entire app.
5
+ * Avoids the dual-React-instance bug when using htm/react from esm.sh.
6
+ */
7
+
8
+ import htm from 'htm';
9
+ import { createElement } from 'react';
10
+
11
+ export const html = htm.bind(createElement);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "visualknowledge",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Interactive AI Chat with Visualization - one-click launch via npx",
5
5
  "bin": {
6
6
  "visualknowledge": "./bin/visualknowledge.js"