eon-memory 1.0.0 → 1.1.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/init.js +305 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eon-memory",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "EON Memory - Persistent AI memory system. Connect Claude Code, Cursor, or VS Code to your memory.",
5
5
  "bin": {
6
6
  "eon-memory": "./bin/eon.js"
package/src/init.js CHANGED
@@ -199,13 +199,318 @@ async function main() {
199
199
  console.log(" Warning: Could not fetch CLAUDE.md template (non-critical).");
200
200
  }
201
201
 
202
+ // Step 5: X-Ethics Hooks Installation (optional)
203
+ console.log("");
204
+ const xEthicsAnswer = await ask(" Install X-Ethics enforcement hooks? (recommended) [Y/n]: ");
205
+ const installXEthics = xEthicsAnswer === "" || xEthicsAnswer.toLowerCase() === "y";
206
+
207
+ if (installXEthics) {
208
+ const hooksDir = path.join(os.homedir(), ".claude", "hooks");
209
+ const settingsPath = path.join(os.homedir(), ".claude", "settings.json");
210
+
211
+ // Create hooks directory
212
+ if (!fs.existsSync(hooksDir)) {
213
+ fs.mkdirSync(hooksDir, { recursive: true });
214
+ }
215
+
216
+ // Hook 1: x_ethics_prompt_check.py
217
+ const promptCheckScript = `#!/usr/bin/env python3
218
+ """UserPromptSubmit hook - X-Ethics enforcement (prompt check)."""
219
+ import json, re, sys, os
220
+
221
+ data = json.load(sys.stdin)
222
+ msg = data.get("user_message", "")
223
+
224
+ TECH_BYPASS = {"kill", "destroy", "attack", "eliminate", "exploit", "trick"}
225
+ EDU_CONTEXT = {"history", "prevent", "defense", "research", "study", "test",
226
+ "debug", "process", "container", "docker", "security", "audit",
227
+ "pentest"}
228
+
229
+ words = set(re.findall(r"\\b\\w+\\b", msg.lower()))
230
+ has_edu = bool(words & EDU_CONTEXT)
231
+
232
+ HARMFUL = r"\\b(kill|murder|bomb|attack|destroy|nuke|assassinate|genocide|massacre|worthless|subhuman|inferior|eliminate|hate)\\b"
233
+ COERCIVE = r"\\b(must obey|no choice|forced to|comply or else)\\b"
234
+ DECEPTIVE = r"\\b(trick|deceive|manipulate|exploit|mislead|hide the truth|cover up)\\b"
235
+
236
+ def check(pattern, text):
237
+ matches = re.findall(pattern, text.lower())
238
+ if not matches:
239
+ return None
240
+ filtered = [m for m in matches if m not in TECH_BYPASS]
241
+ if filtered and not has_edu:
242
+ return filtered[0]
243
+ return None
244
+
245
+ violation = check(HARMFUL, msg) or check(COERCIVE, msg) or check(DECEPTIVE, msg)
246
+
247
+ if violation:
248
+ with open("/tmp/eon_xethics_violation.json", "w") as f:
249
+ json.dump({"violation": violation, "ts": __import__("time").time()}, f)
250
+ print(json.dumps({
251
+ "additionalContext": f"X-Ethics violation detected ('{violation}'). "
252
+ "This request was flagged as potentially harmful. "
253
+ "Please rephrase your request in a constructive way."
254
+ }))
255
+ sys.exit(0)
256
+
257
+ sys.exit(0)
258
+ `;
259
+
260
+ // Hook 2: x_ethics_tool_block.py
261
+ const toolBlockScript = `#!/usr/bin/env python3
262
+ """PreToolUse hook - X-Ethics enforcement (tool block)."""
263
+ import json, sys, os, time
264
+
265
+ data = json.load(sys.stdin)
266
+ tool = data.get("tool_name", "")
267
+
268
+ READONLY = {"Read", "Glob", "Grep", "ToolSearch", "TaskCreate", "TaskUpdate",
269
+ "TaskGet", "TaskList"}
270
+
271
+ if tool in READONLY:
272
+ sys.exit(0)
273
+
274
+ vfile = "/tmp/eon_xethics_violation.json"
275
+ if os.path.exists(vfile):
276
+ try:
277
+ with open(vfile) as f:
278
+ v = json.load(f)
279
+ if time.time() - v.get("ts", 0) < 60:
280
+ print(json.dumps({
281
+ "decision": "block",
282
+ "reason": f"X-Ethics violation active ('{v.get('violation', '?')}'). "
283
+ "Tool use blocked until violation is resolved."
284
+ }))
285
+ sys.exit(0)
286
+ except Exception:
287
+ pass
288
+
289
+ sys.exit(0)
290
+ `;
291
+
292
+ const promptCheckPath = path.join(hooksDir, "x_ethics_prompt_check.py");
293
+ const toolBlockPath = path.join(hooksDir, "x_ethics_tool_block.py");
294
+
295
+ fs.writeFileSync(promptCheckPath, promptCheckScript);
296
+ fs.chmodSync(promptCheckPath, 0o755);
297
+
298
+ fs.writeFileSync(toolBlockPath, toolBlockScript);
299
+ fs.chmodSync(toolBlockPath, 0o755);
300
+
301
+ // Update settings.json - merge hooks
302
+ let settings = {};
303
+ if (fs.existsSync(settingsPath)) {
304
+ try {
305
+ settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
306
+ } catch {
307
+ settings = {};
308
+ }
309
+ }
310
+ if (!settings.hooks) settings.hooks = {};
311
+
312
+ const promptHookEntry = {
313
+ matcher: "",
314
+ hooks: [{ type: "command", command: `python3 ${promptCheckPath}` }],
315
+ };
316
+ const toolHookEntry = {
317
+ matcher: "",
318
+ hooks: [{ type: "command", command: `python3 ${toolBlockPath}` }],
319
+ };
320
+
321
+ if (!settings.hooks.UserPromptSubmit) settings.hooks.UserPromptSubmit = [];
322
+ settings.hooks.UserPromptSubmit.unshift(promptHookEntry);
323
+
324
+ if (!settings.hooks.PreToolUse) settings.hooks.PreToolUse = [];
325
+ settings.hooks.PreToolUse.unshift(toolHookEntry);
326
+
327
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
328
+
329
+ console.log(" Installed: ~/.claude/hooks/x_ethics_prompt_check.py");
330
+ console.log(" Installed: ~/.claude/hooks/x_ethics_tool_block.py");
331
+ console.log(" Updated: ~/.claude/settings.json");
332
+ console.log(" X-Ethics enforcement is now active!\n");
333
+ } else {
334
+ console.log(" Skipped. You can install X-Ethics hooks later.\n");
335
+ }
336
+
337
+ // Step 6: Install AI Agents
338
+ console.log("");
339
+ const agentsAnswer = await ask(" Install AI agents (Jarvis, Memory Manager, X-Ethics Reviewer)? (recommended) [Y/n]: ");
340
+ const installAgents = agentsAnswer === "" || agentsAnswer.toLowerCase() === "y";
341
+
342
+ if (installAgents) {
343
+ const agentsDir = path.join(os.homedir(), ".claude", "agents");
344
+ if (!fs.existsSync(agentsDir)) {
345
+ fs.mkdirSync(agentsDir, { recursive: true });
346
+ }
347
+
348
+ // Jarvis Agent
349
+ const jarvisContent = `---
350
+ name: jarvis
351
+ description: Your AI project orchestrator. Use for complex multi-step tasks, project planning, and coordinating work across files. Jarvis checks your memories first, delegates to specialists, and ensures quality.
352
+ tools: Read, Write, Edit, Bash, Grep, Glob, Agent
353
+ model: opus
354
+ ---
355
+
356
+ # Jarvis — Your Project Orchestrator
357
+
358
+ You are Jarvis, an intelligent project orchestrator. You coordinate complex tasks by breaking them down, checking existing knowledge, and ensuring quality at every step.
359
+
360
+ ## How You Work
361
+
362
+ ### Before EVERY task:
363
+ 1. **Check memories first**: Call \`eon_search\` with relevant keywords to find existing knowledge
364
+ 2. **Check goals**: Call \`eon_goals_list\` to understand current objectives
365
+ 3. **Plan before executing**: For anything touching >2 files, create a plan first
366
+
367
+ ### During work:
368
+ 4. **Delegate when appropriate**: Use sub-agents for specialized tasks
369
+ 5. **Save decisions**: Every significant decision gets saved with \`eon_create\` (category: "decision")
370
+ 6. **Track progress**: Update goals with \`eon_goals_update\` as work progresses
371
+
372
+ ### After EVERY task:
373
+ 7. **Save what was done**: Create a memory summarizing the work (category: "update")
374
+ 8. **Verify**: Run the code, check for errors, confirm it works
375
+ 9. **Report**: Tell the user what was done, what was decided, and what's next
376
+
377
+ ## Memory Quality Rules
378
+
379
+ When creating memories, include ACTIONABLE details:
380
+ - For API work: method, path, parameters, response format, status codes
381
+ - For database work: full schema with types and constraints
382
+ - For components: props, state, dependencies
383
+ - For decisions: WHAT was decided, WHY, and WHAT alternatives were rejected
384
+
385
+ ## Available MCP Tools
386
+
387
+ - \`eon_create\` — Save knowledge (validated with 15 truth tests)
388
+ - \`eon_search\` — Find memories by meaning
389
+ - \`eon_list\` — Browse all memories
390
+ - \`eon_get\` — Get specific memory
391
+ - \`eon_update\` — Update existing memory
392
+ - \`eon_goals_create\` — Create project goals
393
+ - \`eon_goals_list\` — Check goal progress
394
+ - \`eon_goals_update\` — Update goal status
395
+ - \`eon_health\` — System health check
396
+ - \`eon_stats\` — Usage statistics
397
+ `;
398
+
399
+ // Memory Manager Agent
400
+ const memoryManagerContent = `---
401
+ name: memory-manager
402
+ description: Manages EON memories - create, search, update, organize knowledge. Use when you need to save context, find past decisions, or organize project knowledge.
403
+ tools: Read, Grep, Glob
404
+ ---
405
+
406
+ # EON Memory Manager
407
+
408
+ You help manage persistent, validated memories through the EON MCP tools.
409
+
410
+ ## Available MCP Tools
411
+
412
+ ### Save Knowledge
413
+ - \`eon_create\`: Create a new validated memory (title, content, project_id, category)
414
+ - Every create runs 15 truth tests and returns a quality score + X-Ethics alignment score.
415
+
416
+ ### Find Knowledge
417
+ - \`eon_search\`: Semantic search (finds by meaning, not keywords)
418
+ - \`eon_similar\`: Find memories similar to a given one
419
+
420
+ ### Organize
421
+ - \`eon_projects\`: List all projects with memory counts
422
+ - \`eon_list\`: Browse memories with pagination
423
+ - \`eon_get\`: Get a specific memory by ID
424
+ - \`eon_update\`: Update a memory (re-validates after)
425
+ - \`eon_delete\`: Soft delete (recoverable)
426
+
427
+ ### Track Goals
428
+ - \`eon_goals_create\`: Create goals with priority/deadline
429
+ - \`eon_goals_list\`: List goals by status/priority
430
+ - \`eon_goals_update\`: Update progress (0-100%)
431
+
432
+ ## Best Practices
433
+
434
+ 1. **Save decisions**: When the user makes an important decision, save it as category "decision"
435
+ 2. **Save context**: At the start of a project, save the context so future sessions have it
436
+ 3. **Search before creating**: Check if similar knowledge already exists
437
+ 4. **Use projects**: Organize memories by project for cleaner search results
438
+ 5. **Quality matters**: If a memory gets a low quality score, consider improving the content
439
+ `;
440
+
441
+ // X-Ethics Reviewer Agent
442
+ const xEthicsReviewerContent = `---
443
+ name: x-ethics-reviewer
444
+ description: Reviews code and outputs for X-Ethics alignment - checks truth, freedom, grace, and gratitude. Use after code changes or before commits.
445
+ tools: Read, Grep, Glob
446
+ model: sonnet
447
+ ---
448
+
449
+ # X-Ethics Reviewer
450
+
451
+ You review code and text for alignment with the X-Ethics framework.
452
+
453
+ ## What You Check
454
+
455
+ ### 1. Truth (W)
456
+ - Are there hardcoded lies, misleading comments, or false claims?
457
+ - Do error messages accurately describe what happened?
458
+ - Are variable/function names honest about what they do?
459
+
460
+ ### 2. Freedom (F)
461
+ - Does the code respect user autonomy? (no dark patterns, no forced flows)
462
+ - Are users informed about what happens with their data?
463
+ - No coercive UX patterns (guilt-tripping, fake urgency, hidden costs)
464
+
465
+ ### 3. Grace (G)
466
+ - Does the code treat all users with dignity?
467
+ - Error messages are helpful, not blaming
468
+ - Accessible design considerations
469
+
470
+ ### 4. Gratitude (D)
471
+ - Are open-source licenses respected?
472
+ - Are third-party contributions credited?
473
+
474
+ ## Output Format
475
+
476
+ X-Ethics Review
477
+ Score: XX%
478
+
479
+ Truth (W): [PASS/WARN/FAIL] - reason
480
+ Freedom (F): [PASS/WARN/FAIL] - reason
481
+ Grace (G): [PASS/WARN/FAIL] - reason
482
+ Gratitude (D):[PASS/WARN/FAIL] - reason
483
+
484
+ Issues found: N
485
+ Recommendations: [Actionable suggestions]
486
+ `;
487
+
488
+ fs.writeFileSync(path.join(agentsDir, "jarvis.md"), jarvisContent);
489
+ fs.writeFileSync(path.join(agentsDir, "memory-manager.md"), memoryManagerContent);
490
+ fs.writeFileSync(path.join(agentsDir, "x-ethics-reviewer.md"), xEthicsReviewerContent);
491
+
492
+ console.log(" Installed: ~/.claude/agents/jarvis.md");
493
+ console.log(" Installed: ~/.claude/agents/memory-manager.md");
494
+ console.log(" Installed: ~/.claude/agents/x-ethics-reviewer.md");
495
+ console.log(" 3 AI agents are now available!\n");
496
+ } else {
497
+ console.log(" Skipped. You can install agents manually later.\n");
498
+ }
499
+
202
500
  // Done
203
501
  console.log("\n Setup complete!\n");
204
502
  console.log(" Next steps:");
205
503
  console.log(" 1. Open this project in Claude Code or Cursor");
206
504
  console.log(" 2. The EON Memory tools will be available automatically");
207
505
  console.log(" 3. Try: \"Search my memories for...\" or \"Create a memory about...\"\n");
506
+ console.log(" Installed components:");
507
+ console.log(" - MCP Server connection (.mcp.json)");
508
+ console.log(" - Main Prompt (CLAUDE.md)");
509
+ if (installXEthics) console.log(" - X-Ethics enforcement hooks");
510
+ if (installAgents) console.log(" - AI agents (Jarvis, Memory Manager, X-Ethics Reviewer)");
511
+ console.log("");
208
512
  console.log(` Dashboard: ${API_BASE}`);
513
+ console.log(` Best Practices: ${API_BASE}/best-practices`);
209
514
  console.log(` Run 'npx eon-memory status' to check connection.\n`);
210
515
  }
211
516