navada-edge-cli 3.5.7 → 3.5.9

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/lib/agent.js CHANGED
@@ -43,7 +43,7 @@ You also connect to the NAVADA Edge Network (4 nodes via Tailscale VPN):
43
43
  - mcp_call: access 18 MCP tools on the ASUS server
44
44
  - docker_registry: manage the private Docker registry
45
45
  - send_email / generate_image: communications and AI image generation
46
- - founder_info: information about Lee Akpareva, the creator of NAVADA
46
+ - founder_info: ALWAYS use this tool when asked about Lee Akpareva, his career, education, projects, or NAVADA's founder. It has his full CV. Never guess about Lee, always call this tool.
47
47
  When users ask you to DO something — DO IT. Use write_file to create files. Use shell to run commands. Never say "I can't" when you have a tool for it.
48
48
  When asked to generate diagrams — use write_file to create Mermaid (.mmd), SVG, or HTML files. You can also use python_exec with matplotlib/graphviz for complex diagrams.
49
49
  When asked to create, edit, or delete files — use the file tools directly. You are a terminal agent with FULL access.
@@ -342,8 +342,21 @@ const localTools = {
342
342
  },
343
343
 
344
344
  founderInfo: {
345
- description: 'Get information about the NAVADA Edge founder',
346
- execute: () => JSON.stringify(IDENTITY.founder, null, 2),
345
+ description: 'Answer questions about Lee Akpareva, founder of NAVADA Edge, using his full CV and career history',
346
+ execute: (question) => {
347
+ try {
348
+ const knowledgePath = path.join(__dirname, 'knowledge.py');
349
+ const py = process.platform === 'win32' ? 'python' : 'python3';
350
+ const openaiKey = config.get('openaiKey') || process.env.OPENAI_API_KEY || '';
351
+ const output = execFileSync(py, [knowledgePath, question || 'Who is Lee Akpareva?'], {
352
+ timeout: 30000, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
353
+ env: { ...process.env, OPENAI_API_KEY: openaiKey },
354
+ });
355
+ return output.trim();
356
+ } catch (e) {
357
+ return `Error: ${e.stderr?.trim() || e.message}`;
358
+ }
359
+ },
347
360
  },
348
361
  };
349
362
 
@@ -748,7 +761,7 @@ function openAITools() {
748
761
  { name: 'python_pip', description: 'Install a Python package via pip.', parameters: { type: 'object', properties: { package: { type: 'string', description: 'Package name' } }, required: ['package'] } },
749
762
  { name: 'python_script', description: 'Run a Python script file.', parameters: { type: 'object', properties: { path: { type: 'string', description: 'Path to .py file' } }, required: ['path'] } },
750
763
  { name: 'sandbox_run', description: 'Run code in an isolated sandbox with syntax highlighting. Supports javascript, python, typescript.', parameters: { type: 'object', properties: { code: { type: 'string' }, language: { type: 'string', description: 'javascript, python, or typescript' } }, required: ['code'] } },
751
- { name: 'founder_info', description: 'Get information about Lee Akpareva, founder of NAVADA Edge.', parameters: { type: 'object', properties: {} } },
764
+ { name: 'founder_info', description: 'Answer questions about Lee Akpareva (founder of NAVADA Edge) using his full CV and career history. Always use this tool when asked about Lee, his career, experience, education, or projects.', parameters: { type: 'object', properties: { question: { type: 'string', description: 'The question about Lee' } }, required: ['question'] } },
752
765
  ];
753
766
  return defs.map(d => ({ type: 'function', function: d }));
754
767
  }
@@ -1001,8 +1014,8 @@ async function chat(userMessage, conversationHistory = []) {
1001
1014
  },
1002
1015
  {
1003
1016
  name: 'founder_info',
1004
- description: 'Get information about Lee Akpareva, founder of NAVADA Edge Network. Use when asked about the creator, founder, Lee, or who made NAVADA.',
1005
- input_schema: { type: 'object', properties: {} },
1017
+ description: 'Answer questions about Lee Akpareva (founder of NAVADA Edge) using his full CV and career history. Always use this tool when asked about Lee, his career, experience, education, certifications, or projects.',
1018
+ input_schema: { type: 'object', properties: { question: { type: 'string', description: 'The question about Lee' } }, required: ['question'] },
1006
1019
  },
1007
1020
  ];
1008
1021
 
@@ -1081,7 +1094,7 @@ async function executeTool(name, input) {
1081
1094
  displayOutput(result);
1082
1095
  return result.error ? `Error (exit ${result.exitCode}): ${result.error}` : result.output;
1083
1096
  }
1084
- case 'founder_info': return localTools.founderInfo.execute();
1097
+ case 'founder_info': return localTools.founderInfo.execute(input.question);
1085
1098
  default: return `Unknown tool: ${name}`;
1086
1099
  }
1087
1100
  } catch (e) {
@@ -100,10 +100,10 @@ module.exports = function(reg) {
100
100
  console.log(ui.label('User', r.data.name || r.data.userId || 'connected'));
101
101
  console.log('');
102
102
  console.log(ui.dim('You now have access to:'));
103
- console.log(ui.dim(' /status network health'));
104
- console.log(ui.dim(' /doctor test connections'));
105
- console.log(ui.dim(' /offload run tasks 24/7 (coming soon)'));
106
- console.log(ui.dim(' /sessions view running tasks (coming soon)'));
103
+ console.log(ui.dim(' /offload run tasks 24/7 on cloud'));
104
+ console.log(ui.dim(' /sessions view running tasks'));
105
+ console.log(ui.dim(' /attach stream task output'));
106
+ console.log(ui.dim(' /kill stop a task'));
107
107
  validated = true;
108
108
  break;
109
109
  } else if (r.status === 401) {
@@ -4,13 +4,14 @@ const readline = require('readline');
4
4
  const navada = require('navada-edge-sdk');
5
5
  const ui = require('../ui');
6
6
  const config = require('../config');
7
+ const fs = require('fs');
8
+ const path = require('path');
7
9
 
8
10
  function ask(rl, question) {
9
11
  return new Promise(resolve => rl.question(question, resolve));
10
12
  }
11
13
 
12
14
  async function runSetup(fromRepl = false) {
13
- // Create a fresh readline — don't conflict with the REPL
14
15
  const rl = readline.createInterface({
15
16
  input: process.stdin,
16
17
  output: process.stdout,
@@ -18,80 +19,87 @@ async function runSetup(fromRepl = false) {
18
19
  });
19
20
 
20
21
  console.log('');
21
- console.log(ui.box('SETUP', ' Configure your NAVADA Edge CLI.'));
22
+ console.log(ui.box('NAVADA EDGE SETUP', ' Let\'s configure your CLI in under a minute.'));
22
23
  console.log('');
23
24
 
24
- // 1. API Key — the only required thing
25
- console.log(ui.dim(' Your API key powers the AI agent. Accepts:'));
26
- console.log(ui.dim(' - Anthropic key (sk-ant-...)'));
27
- console.log(ui.dim(' - NAVADA Edge API key (nv_edge_...)'));
28
- console.log(ui.dim(' - OpenAI key (sk-...)'));
29
- console.log(ui.dim(' - Or press Enter to skip (limited mode)'));
25
+ // 1. API Key
26
+ console.log(ui.dim(' Add an AI API key for full agent capabilities.'));
27
+ console.log(ui.dim(' Supported: OpenAI (sk-...), Anthropic (sk-ant-...), Gemini (AIza...)'));
28
+ console.log(ui.dim(' Or press Enter to use the free tier (Grok, limited).'));
30
29
  console.log('');
31
30
 
32
31
  const apiKey = await ask(rl, ' API key: ');
33
32
  if (apiKey.trim()) {
34
33
  const key = apiKey.trim();
35
- config.setApiKey(key);
36
- // Auto-detect key type and save to right field
37
34
  if (key.startsWith('sk-ant')) {
38
35
  config.set('anthropicKey', key);
39
- console.log(ui.success('Anthropic key saved — full agent mode enabled'));
40
- } else if (key.startsWith('nv_edge')) {
41
- console.log(ui.success('NAVADA Edge key saved — MCP access enabled'));
36
+ config.setApiKey(key);
37
+ console.log(ui.success('Anthropic key saved. Full agent mode with tool use enabled.'));
38
+ } else if (key.startsWith('AIza')) {
39
+ config.set('geminiKey', key);
40
+ console.log(ui.success('Gemini key saved. Free unlimited access.'));
42
41
  } else if (key.startsWith('sk-')) {
43
42
  config.set('openaiKey', key);
44
- navada.init({ openaiKey: key });
45
- console.log(ui.success('OpenAI key saved'));
43
+ config.setApiKey(key);
44
+ console.log(ui.success('OpenAI key saved. GPT-4o with tool use enabled.'));
45
+ } else if (key.startsWith('nvapi-')) {
46
+ config.set('nvidiaKey', key);
47
+ console.log(ui.success('NVIDIA key saved. Llama, Mistral, DeepSeek enabled.'));
48
+ } else if (key.startsWith('hf_')) {
49
+ config.set('hfToken', key);
50
+ console.log(ui.success('HuggingFace key saved. Qwen Coder enabled.'));
46
51
  } else {
47
- console.log(ui.success('Key saved'));
52
+ config.setApiKey(key);
53
+ console.log(ui.success('Key saved.'));
48
54
  }
49
55
  } else {
50
- console.log(ui.dim('Skipped you can set this later with /login <key>'));
56
+ console.log(ui.dim(' Skipped. Free tier active. Add a key anytime with /login <key>'));
51
57
  }
52
58
  console.log('');
53
59
 
54
- // 2. Node IPs — optional
55
- const configureNodes = await ask(rl, ' Configure network nodes? (y/N): ');
56
- if (configureNodes.trim().toLowerCase() === 'y') {
57
- console.log('');
58
- console.log(ui.dim(' Enter Tailscale IPs for your NAVADA Edge nodes.'));
59
- console.log(ui.dim(' Press Enter to skip any node.'));
60
- console.log('');
61
-
62
- const asusIp = await ask(rl, ' ASUS IP (Production Engine): ');
63
- if (asusIp.trim()) {
64
- config.set('asus', asusIp.trim());
65
- config.set('mcp', `http://${asusIp.trim()}:8811`);
66
- config.set('dashboard', `http://${asusIp.trim()}:7900`);
67
- config.set('registry', `http://${asusIp.trim()}:5000`);
68
- navada.init({
69
- asus: asusIp.trim(),
70
- mcp: `http://${asusIp.trim()}:8811`,
71
- dashboard: `http://${asusIp.trim()}:7900`,
72
- registry: `http://${asusIp.trim()}:5000`,
73
- });
74
- }
75
- const hpIp = await ask(rl, ' HP IP (Database): ');
76
- if (hpIp.trim()) config.set('hp', hpIp.trim());
77
- const ec2Ip = await ask(rl, ' EC2 IP (Monitoring): ');
78
- if (ec2Ip.trim()) {
79
- config.set('ec2', ec2Ip.trim());
80
- config.set('lucas', `http://${ec2Ip.trim()}:8820`);
60
+ // 2. Theme
61
+ const theme = await ask(rl, ' Theme (dark/crow/matrix/light) [dark]: ');
62
+ config.setTheme(theme.trim() || 'dark');
63
+ console.log('');
64
+
65
+ // 3. Create agent.md
66
+ const agentMd = path.join(config.CONFIG_DIR, 'agent.md');
67
+ if (!fs.existsSync(agentMd)) {
68
+ const createAgent = await ask(rl, ' Create agent.md for custom AI personality? (Y/n): ');
69
+ if (createAgent.trim().toLowerCase() !== 'n') {
70
+ if (!fs.existsSync(config.CONFIG_DIR)) fs.mkdirSync(config.CONFIG_DIR, { recursive: true });
71
+ fs.writeFileSync(agentMd, `# My NAVADA Agent
72
+
73
+ ## About Me
74
+ <!-- Tell the agent who you are and what you work on -->
75
+ I am a developer working on...
76
+
77
+ ## Preferences
78
+ <!-- How should the agent behave? -->
79
+ - Be concise and technical
80
+ - Always explain before making changes
81
+ - Prefer TypeScript for new code
82
+
83
+ ## My Stack
84
+ <!-- What tools and tech do you use? -->
85
+ - ...
86
+ `);
87
+ console.log(ui.success('Created ~/.navada/agent.md'));
88
+ console.log(ui.dim(' Edit this file to personalise your agent.'));
81
89
  }
82
- const oracleIp = await ask(rl, ' Oracle IP (Infrastructure): ');
83
- if (oracleIp.trim()) config.set('oracle', oracleIp.trim());
84
- console.log(ui.success('Nodes configured'));
90
+ } else {
91
+ console.log(ui.dim(' agent.md already exists.'));
85
92
  }
86
93
  console.log('');
87
94
 
88
- // 3. Theme
89
- const theme = await ask(rl, ' Theme (dark/crow/matrix/light) [dark]: ');
90
- config.setTheme(theme.trim() || 'dark');
95
+ // 4. Cloud compute (optional)
96
+ console.log(ui.dim(' Want 24/7 cloud compute? Sign up at portal.navada-edge-server.uk'));
97
+ console.log(ui.dim(' Generate an API key, then run: /edge login nv_edge_your_key'));
91
98
  console.log('');
92
99
 
93
- // 4. Done
94
- console.log(ui.box('READY', ` Config saved: ${config.CONFIG_FILE}\n Type naturally to chat, or /help for commands.`));
100
+ // Done
101
+ const pkg = require('../../package.json');
102
+ console.log(ui.box('READY', ` NAVADA Edge CLI v${pkg.version}\n Config: ${config.CONFIG_FILE}\n\n Type naturally to chat, or /help for commands.`));
95
103
  console.log('');
96
104
 
97
105
  rl.close();
@@ -0,0 +1,197 @@
1
+ """
2
+ NAVADA Edge Knowledge Skill — answers questions about Lee Akpareva accurately.
3
+ Called by the CLI agent as a Python subprocess. Uses OpenAI for natural responses
4
+ grounded in factual CV data. No hallucination.
5
+ """
6
+
7
+ import sys
8
+ import json
9
+ import os
10
+
11
+ KNOWLEDGE = """
12
+ LESLIE (LEE) AKPAREVA
13
+ Principal AI Consultant | Program Director | ML Engineer
14
+ Phone: 07935237704 | Email: leeakpareva@hotmail.com | Web: www.navada-lab.space
15
+
16
+ Senior technology leader and practising ML engineer with 17+ years delivering large-scale digital transformation across insurance, finance, healthcare, aviation, logistics, and e-commerce. Combines MBA-level commercial acumen with hands-on AI engineering, training custom models on GPU infrastructure, designing multi-agent architectures, and deploying production-grade systems that drive measurable P&L impact.
17
+
18
+ Equally comfortable presenting ROI cases to C-suite stakeholders and debugging CUDA memory allocation in a GPU terminal. Track record of owning programme budgets up to 5M GBP, leading cross-functional teams of 30+, and translating AI capability into benefits realisation across underwriting, claims, operations, and commercial functions.
19
+
20
+ Engineering workflow runs on Paperspace (paperspace.com) for GPU-accelerated model training and inference, with Railway (railway.com) providing persistent compute for production APIs, scheduled automation, and cron-based orchestration.
21
+
22
+ CORE COMPETENCIES
23
+ Leadership: Programme Governance, Portfolio Management, C-Suite Engagement, Vendor Management, Risk & Compliance
24
+ AI/ML: PyTorch, Hugging Face, LangChain, QLoRA Fine-Tuning, RAG Pipelines, Computer Vision (YOLO), Azure AI Foundry, OpenAI, FastAPI, Docker, CI/CD
25
+ Commercial: P&L Ownership, Benefits Realisation, ROI & NPV Modelling, Cost Optimisation, Investment Prioritisation
26
+
27
+ PROFESSIONAL EXPERIENCE (chronological, most recent first)
28
+
29
+ 1. Principal Azure AI Solution Consultant | Generali UK | November 2024 to Present
30
+ Hired directly by the COO to define and lead AI strategy across the UK business. Sole technical architect and lead developer for enterprise AI, responsible for the full ML lifecycle from model selection through fine-tuning to production deployment.
31
+ - Established the AI Centre of Excellence, defining operating model, governance frameworks, and technical standards for AI delivery on Azure AI Foundry
32
+ - Designed and implemented multi-agent architectures integrating LangChain, Azure OpenAI, and vector databases (PostgreSQL/Pinecone) for production RAG pipelines
33
+ - Led model evaluation and fine-tuning initiatives, executing QLoRA adapter training on Qwen and Llama models using Hugging Face transformers and PEFT on cloud GPU infrastructure
34
+ - Built end-to-end ML training pipelines including dataset curation, hyperparameter optimisation, loss curve analysis, and inference endpoint deployment via FastAPI
35
+ - Trained custom LoRA adapters for domain-specific image generation using Stable Diffusion, supporting brand and marketing use cases
36
+ - Deployed computer vision prototypes using YOLOv8 for document classification and visual inspection workflows
37
+ - Created reusable AI reference architecture now adopted as the blueprint for all new AI initiatives, reducing concept-to-POC time by 60%
38
+ - Delivered AI prototypes for legal, claims, and operations teams, demonstrating measurable reduction in manual review time and improved knowledge retrieval
39
+ - Authored and delivered internal AI enablement programme including workshops, notebooks, and technical guides to upskill 50+ staff on RAG, LLM orchestration, and ML operations
40
+ - Built secure API layers with JWT/OAuth, rate limiting, and Azure Key Vault integration maintaining enterprise compliance and data protection standards
41
+
42
+ 2. Program Director | Informa Markets | October 2023 to September 2024
43
+ Accountable for strategy, P&L, and delivery of two new digital products within the global food portfolio. Led a cross-functional European team of 27 across engineering, data science, product, UX, and operations.
44
+ - Took two digital propositions from concept to launch-ready state
45
+ - Managed programme financials including resource allocation, cost forecasting, and investment trade-off analysis
46
+ - Defined and executed go-to-market strategies for digital product launches across multiple European regions
47
+ - Introduced data-driven decision-making into portfolio management
48
+ - Oversaw regulatory compliance, risk management, and governance across multi-jurisdiction delivery
49
+
50
+ 3. Commercial Program Manager | Farfetch | December 2022 to August 2023
51
+ - Led commercial technology programmes for the luxury fashion marketplace
52
+ - Owned programme financials and benefits tracking, reporting directly to senior leadership
53
+ - Coordinated platform initiatives supporting 2.3B GBP GMV marketplace operations
54
+
55
+ 4. Blockchain Program Manager | DHL Express | May 2022 to December 2022
56
+ - Managed blockchain and emerging technology programmes for the global logistics leader
57
+ - Led cross-functional teams evaluating distributed ledger solutions for supply chain transparency and shipment verification
58
+ - Developed business cases and ROI models for blockchain integration across European operations
59
+
60
+ 5. Product / Project Lead | Shutterstock | November 2021 to May 2022
61
+ 6. DeFi & Blockchain Program Lead | Bumper (DeFi Protocol) | September 2021 to November 2021
62
+ 7. Project Manager | Millbrook Healthcare | March 2021 to May 2021
63
+ 8. Agile Project Consultant | NHSX (NHS Digital) | October 2020 to December 2020
64
+ 9. Project Manager | Springer Nature | March 2020 to October 2020
65
+ 10. Platform Manager | Opus Energy | June 2019 to December 2019
66
+ 11. Digital Project Manager | Centrica (British Gas) | April 2018 to June 2019
67
+ 12. Project Manager | Wesleyan Bank | October 2017 to April 2018
68
+ 13. Manager | Avis Budget Group | October 2016 to October 2017
69
+ 14. Business Program Manager | Wonga | May 2016 to October 2016
70
+ 15. Project Manager | British Airways | November 2015 to April 2016
71
+ 16. Agile PM / Scrum Master | Flybe | May 2015 to November 2015
72
+ 17. Technical Project Manager | Expedia Inc | October 2014 to May 2015
73
+ 18. Project Manager | Powa Technology | April 2014 to October 2014
74
+ 19. Implementation Manager | Polarisoft | August 2013 to April 2014
75
+
76
+ PERSONAL PROJECTS & TECHNICAL RESEARCH
77
+ - Custom LLM Fine-Tuning: Trained domain-specific language models using QLoRA on cloud GPU (NVIDIA A4000). Built 85-example curated datasets, iterated across 3 model versions, resolved base model hallucination through progressive LoRA rank scaling
78
+ - Stable Diffusion LoRA Training: Created custom image generation adapters for brand-consistent AI imagery
79
+ - Computer Vision: Deployed YOLOv8 object detection models with real-time inference. Live: computervisionbylee.streamlit.app
80
+ - RAVEN Terminal: AI-powered code learning platform. Live: raventerminal.xyz
81
+ - Medical AI: Evaluated OpenBioLLM-8B for healthcare automation, clinical triage and drug discovery
82
+ - ALEX: Multi-modal autonomous agent combining cloud GPU inference with Raspberry Pi edge deployment. Live: alexnavada.xyz
83
+ - RAG & Vector Search: Built retrieval-augmented generation pipelines using ChromaDB, LangChain, and sentence-transformers
84
+ - Robotics & IoT: Raspberry Pi-powered robots including PiCrawler spider robot with computer vision, servo calibration, and MediaPipe gesture control
85
+ - Full-Stack AI Applications: End-to-end Next.js, FastAPI, Vercel, and Railway deployments. Portfolio: navada.space
86
+ - GPU ML Lab: Full ML engineering workstation on Paperspace A4000. Publicly shareable: navada-lab.space
87
+ - Hugging Face Contributor: Publishing models and datasets on huggingface.co/Navada25
88
+ - NAVADA Edge Network: Distributed AI home server (4 nodes, 25+ Docker containers, Tailscale VPN mesh)
89
+ - NAVADA Edge SDK + CLI: npm packages for network access (navada-edge-sdk, navada-edge-cli)
90
+ - WorldMonitor: OSINT intelligence dashboard
91
+ - Lucas CTO: Autonomous infrastructure agent on EC2
92
+
93
+ EDUCATION
94
+ - MBA (Master of Business Administration) | Northumbria University | 2016 to 2017
95
+ - MSc Project Management | Northumbria University | 2013 to 2015
96
+ - Fashion Design & Art Direction | Central Saint Martins, UAL | 2020
97
+ - LLB Law (Hons) | Brunel University | 2007 to 2010
98
+
99
+ CERTIFICATIONS
100
+ AI & Cloud: Azure AI Engineer, Azure Data Scientist, AWS Solutions Architect, Google Cloud Associate, Python Expert (Meta), IBM Full Stack Developer
101
+ Blockchain: Certified Blockchain Architect, Smart Contract Developer, DeFi Expert, Cryptocurrency Expert (Blockchain Council)
102
+ Project Management: PRINCE2 Practitioner, Certified Scrum Master, SAFe, ITIL, Project Risk Management (Oxford), Strategic Planning & Foresight (Oxford)
103
+ Security: CISM (Certified Information Security Manager), ISEB Business Analysis, Foundation in Software Testing
104
+
105
+ TECHNICAL STACK
106
+ ML & AI: PyTorch, Hugging Face Transformers, Diffusers, PEFT, TRL, BitsAndBytes, LangChain, CrewAI, OpenAI, Anthropic, YOLO, Whisper, Gradio, Streamlit
107
+ Languages: Python, TypeScript, JavaScript, SQL
108
+ Cloud & DevOps: Azure AI Foundry, AWS, GCP, Docker, Vercel, Railway, Paperspace GPU, GitHub Actions
109
+ Web & API: Next.js, React, FastAPI, Flask, Node.js, Tailwind CSS
110
+ Data: PostgreSQL, ChromaDB, Pinecone, Redis, Oracle, pandas, NumPy, scikit-learn
111
+ Hardware: Raspberry Pi, Arduino, PiCrawler, servo control, MediaPipe, edge deployment
112
+
113
+ REFERENCES
114
+ Nisha Chopra (Mastercard UK), Natasha Berrow (Informa Markets), Abs Oshinowo (Google UK)
115
+ """
116
+
117
+ SYSTEM_PROMPT = """You are an accurate knowledge assistant for NAVADA Edge. You answer questions about Lee Akpareva using ONLY the factual data provided below.
118
+
119
+ Rules:
120
+ - Only state facts from the provided knowledge. Never invent or guess.
121
+ - If the answer is not in the knowledge, say "I don't have that specific detail."
122
+ - Be concise and natural. No markdown formatting, no bold, no headers, no dashes.
123
+ - Speak in third person about Lee unless the question is directed at Lee himself.
124
+
125
+ KNOWLEDGE:
126
+ """ + KNOWLEDGE
127
+
128
+
129
+ def ask(question, api_key=None):
130
+ """Answer a question using OpenAI grounded in Lee's CV data."""
131
+ key = api_key or os.environ.get("OPENAI_API_KEY", "")
132
+ if not key:
133
+ # Fall back to simple keyword search
134
+ return search_local(question)
135
+
136
+ try:
137
+ import urllib.request
138
+ import ssl
139
+
140
+ body = json.dumps({
141
+ "model": "gpt-4o-mini",
142
+ "messages": [
143
+ {"role": "system", "content": SYSTEM_PROMPT},
144
+ {"role": "user", "content": question}
145
+ ],
146
+ "temperature": 0.2,
147
+ "max_tokens": 500
148
+ }).encode()
149
+
150
+ req = urllib.request.Request(
151
+ "https://api.openai.com/v1/chat/completions",
152
+ data=body,
153
+ headers={
154
+ "Content-Type": "application/json",
155
+ "Authorization": f"Bearer {key}"
156
+ }
157
+ )
158
+
159
+ ctx = ssl.create_default_context()
160
+ with urllib.request.urlopen(req, timeout=30, context=ctx) as resp:
161
+ data = json.loads(resp.read())
162
+ return data["choices"][0]["message"]["content"]
163
+ except Exception as e:
164
+ # Fall back to local search on API failure
165
+ return search_local(question)
166
+
167
+
168
+ def search_local(question):
169
+ """Simple keyword search fallback when no API key available."""
170
+ q = question.lower()
171
+ lines = KNOWLEDGE.strip().split("\n")
172
+ matches = []
173
+ for line in lines:
174
+ line = line.strip()
175
+ if not line:
176
+ continue
177
+ words = q.split()
178
+ score = sum(1 for w in words if len(w) > 2 and w in line.lower())
179
+ if score >= 1:
180
+ matches.append((score, line))
181
+
182
+ matches.sort(key=lambda x: -x[0])
183
+ if matches:
184
+ top = [m[1] for m in matches[:8]]
185
+ return "\n".join(top)
186
+ return "I don't have that specific detail about Lee."
187
+
188
+
189
+ if __name__ == "__main__":
190
+ question = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else sys.stdin.read().strip()
191
+ if not question:
192
+ print("Usage: python knowledge.py <question>")
193
+ sys.exit(1)
194
+
195
+ key = os.environ.get("OPENAI_API_KEY", "")
196
+ answer = ask(question, key)
197
+ print(answer)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "navada-edge-cli",
3
- "version": "3.5.7",
3
+ "version": "3.5.9",
4
4
  "description": "Interactive CLI for the NAVADA Edge Network — explore nodes, agents, Cloudflare, AI, Docker, and MCP from your terminal",
5
5
  "main": "lib/cli.js",
6
6
  "bin": {