@gamaze/hicortex 0.3.4 → 0.3.6
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/dist/index.js +2 -40
- package/dist/init.js +19 -6
- package/dist/mcp-server.js +6 -3
- package/dist/seed-lesson.d.ts +7 -0
- package/dist/seed-lesson.js +76 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,6 +48,7 @@ const node_fs_1 = require("node:fs");
|
|
|
48
48
|
const node_os_1 = require("node:os");
|
|
49
49
|
const embedder_js_1 = require("./embedder.js");
|
|
50
50
|
const storage = __importStar(require("./storage.js"));
|
|
51
|
+
const seed_lesson_js_1 = require("./seed-lesson.js");
|
|
51
52
|
const retrieval = __importStar(require("./retrieval.js"));
|
|
52
53
|
const distiller_js_1 = require("./distiller.js");
|
|
53
54
|
const consolidate_js_1 = require("./consolidate.js");
|
|
@@ -92,7 +93,7 @@ exports.default = {
|
|
|
92
93
|
const consolidateHour = config.consolidateHour ?? 2;
|
|
93
94
|
cancelConsolidation = (0, consolidate_js_1.scheduleConsolidation)(db, llm, embedder_js_1.embed, consolidateHour);
|
|
94
95
|
// Seed the bootstrap lesson on first run
|
|
95
|
-
await injectSeedLesson(db, log);
|
|
96
|
+
await (0, seed_lesson_js_1.injectSeedLesson)(db, log);
|
|
96
97
|
// Auto-add tools to tools.allow if using a restrictive profile
|
|
97
98
|
ensureToolsAllowed(log);
|
|
98
99
|
// Log stats
|
|
@@ -501,45 +502,6 @@ function ensureToolsAllowed(log) {
|
|
|
501
502
|
// Non-fatal
|
|
502
503
|
}
|
|
503
504
|
}
|
|
504
|
-
// ---------------------------------------------------------------------------
|
|
505
|
-
// Seed lesson — injected on first run, teaches the agent to self-improve
|
|
506
|
-
// ---------------------------------------------------------------------------
|
|
507
|
-
const SEED_LESSON = `## Lesson: 1% Daily Self-Improvement
|
|
508
|
-
|
|
509
|
-
Self-improvement protocol: Review your sessions daily. Scan for mistakes, gaps, user corrections, and friction. Identify 1-2 issues maximum. Apply one targeted fix to your instruction files (AGENT.md, IDENTITY.md, TOOLS.md, SOUL.md, or CLAUDE.md). Never overcorrect — feedback is guidance, not emergency. One fix per issue. Never rewrite entire systems. Before changing something, ask: is this a real pattern or am I reacting to noise?
|
|
510
|
-
|
|
511
|
-
The flywheel: Sessions → Hicortex captures → Nightly consolidation → Lessons generated → Lessons injected into your context → You apply one fix → Better sessions tomorrow.
|
|
512
|
-
|
|
513
|
-
Use hicortex_lessons to check for new insights. If a lesson has high confidence, apply it. If medium, observe for one more day. If nothing needs fixing today, skip — that's fine.
|
|
514
|
-
|
|
515
|
-
**Severity:** critical
|
|
516
|
-
**Confidence:** high
|
|
517
|
-
**Generated:** seed-lesson`;
|
|
518
|
-
async function injectSeedLesson(database, log) {
|
|
519
|
-
try {
|
|
520
|
-
// Check if seed lesson already exists (match on unique content)
|
|
521
|
-
const existing = storage.getLessons(database, 365);
|
|
522
|
-
const hasSeed = existing.some((l) => l.content.includes("1% Daily Self-Improvement") ||
|
|
523
|
-
l.source_agent === "hicortex/seed");
|
|
524
|
-
if (hasSeed)
|
|
525
|
-
return;
|
|
526
|
-
// Embed and store
|
|
527
|
-
const embedding = await (0, embedder_js_1.embed)(SEED_LESSON);
|
|
528
|
-
storage.insertMemory(database, SEED_LESSON, embedding, {
|
|
529
|
-
sourceAgent: "hicortex/seed",
|
|
530
|
-
project: "global",
|
|
531
|
-
memoryType: "lesson",
|
|
532
|
-
baseStrength: 0.95,
|
|
533
|
-
privacy: "WORK",
|
|
534
|
-
});
|
|
535
|
-
log("[hicortex] Seed lesson injected: Daily Self-Improvement Protocol");
|
|
536
|
-
}
|
|
537
|
-
catch (err) {
|
|
538
|
-
// Non-fatal — log but don't crash the plugin
|
|
539
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
540
|
-
log(`[hicortex] Warning: could not inject seed lesson: ${msg}`);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
505
|
function formatToolResults(results) {
|
|
544
506
|
if (results.length === 0) {
|
|
545
507
|
return {
|
package/dist/init.js
CHANGED
|
@@ -183,25 +183,38 @@ Becomes a call to hicortex_ingest with:
|
|
|
183
183
|
name: hicortex-activate
|
|
184
184
|
description: Activate a Hicortex license key for unlimited memory. Use after purchasing at hicortex.gamaze.com.
|
|
185
185
|
argument-hint: <license-key>
|
|
186
|
-
allowed-tools: Bash(mkdir:*), Bash(echo:*), mcp__hicortex__hicortex_ingest, mcp__hicortex__hicortex_search, mcp__hicortex__hicortex_context, mcp__hicortex__hicortex_lessons
|
|
186
|
+
allowed-tools: Bash(mkdir:*), Bash(echo:*), Bash(launchctl:*), Bash(systemctl:*), Bash(curl:*), mcp__hicortex__hicortex_ingest, mcp__hicortex__hicortex_search, mcp__hicortex__hicortex_context, mcp__hicortex__hicortex_lessons
|
|
187
187
|
---
|
|
188
188
|
|
|
189
189
|
# Activate Hicortex License
|
|
190
190
|
|
|
191
191
|
## If key provided (e.g. /hicortex-activate hctx-abc123)
|
|
192
192
|
|
|
193
|
-
Write the key to the config file:
|
|
193
|
+
1. Write the key to the config file:
|
|
194
194
|
|
|
195
195
|
\`\`\`bash
|
|
196
196
|
mkdir -p ~/.hicortex
|
|
197
197
|
echo '{ "licenseKey": "THE_KEY_HERE" }' > ~/.hicortex/config.json
|
|
198
198
|
\`\`\`
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
2. Restart the server to apply:
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
On macOS:
|
|
203
|
+
\`\`\`bash
|
|
204
|
+
launchctl kickstart -k gui/$(id -u)/com.gamaze.hicortex
|
|
205
|
+
\`\`\`
|
|
206
|
+
|
|
207
|
+
On Linux:
|
|
208
|
+
\`\`\`bash
|
|
209
|
+
systemctl --user restart hicortex
|
|
210
|
+
\`\`\`
|
|
211
|
+
|
|
212
|
+
3. Verify the server is back:
|
|
213
|
+
\`\`\`bash
|
|
214
|
+
curl -s http://127.0.0.1:8787/health
|
|
215
|
+
\`\`\`
|
|
216
|
+
|
|
217
|
+
4. Tell the user: "License activated! Hicortex now has unlimited memory."
|
|
205
218
|
|
|
206
219
|
## If no key provided
|
|
207
220
|
|
package/dist/mcp-server.js
CHANGED
|
@@ -60,6 +60,7 @@ const embedder_js_1 = require("./embedder.js");
|
|
|
60
60
|
const storage = __importStar(require("./storage.js"));
|
|
61
61
|
const retrieval = __importStar(require("./retrieval.js"));
|
|
62
62
|
const consolidate_js_1 = require("./consolidate.js");
|
|
63
|
+
const seed_lesson_js_1 = require("./seed-lesson.js");
|
|
63
64
|
// ---------------------------------------------------------------------------
|
|
64
65
|
// Server state
|
|
65
66
|
// ---------------------------------------------------------------------------
|
|
@@ -84,7 +85,7 @@ function createMcpServer() {
|
|
|
84
85
|
// -- hicortex_search --
|
|
85
86
|
server.tool("hicortex_search", "Search long-term memory using semantic similarity. Returns the most relevant memories from past sessions.", {
|
|
86
87
|
query: zod_1.z.string().describe("Search query text"),
|
|
87
|
-
limit: zod_1.z.number().optional().describe("Max results (default 5)"),
|
|
88
|
+
limit: zod_1.z.coerce.number().optional().describe("Max results (default 5)"),
|
|
88
89
|
project: zod_1.z.string().optional().describe("Filter by project name"),
|
|
89
90
|
}, async ({ query, limit, project }) => {
|
|
90
91
|
if (!db)
|
|
@@ -100,7 +101,7 @@ function createMcpServer() {
|
|
|
100
101
|
// -- hicortex_context --
|
|
101
102
|
server.tool("hicortex_context", "Get recent context memories, optionally filtered by project. Useful to recall what happened recently.", {
|
|
102
103
|
project: zod_1.z.string().optional().describe("Filter by project name"),
|
|
103
|
-
limit: zod_1.z.number().optional().describe("Max results (default 10)"),
|
|
104
|
+
limit: zod_1.z.coerce.number().optional().describe("Max results (default 10)"),
|
|
104
105
|
}, async ({ project, limit }) => {
|
|
105
106
|
if (!db)
|
|
106
107
|
return { content: [{ type: "text", text: "Hicortex not initialized" }], isError: true };
|
|
@@ -148,7 +149,7 @@ function createMcpServer() {
|
|
|
148
149
|
});
|
|
149
150
|
// -- hicortex_lessons --
|
|
150
151
|
server.tool("hicortex_lessons", "Get actionable lessons learned from past sessions. Auto-generated insights about mistakes to avoid.", {
|
|
151
|
-
days: zod_1.z.number().optional().describe("Look back N days (default 7)"),
|
|
152
|
+
days: zod_1.z.coerce.number().optional().describe("Look back N days (default 7)"),
|
|
152
153
|
project: zod_1.z.string().optional().describe("Filter by project name"),
|
|
153
154
|
}, async ({ days, project }) => {
|
|
154
155
|
if (!db)
|
|
@@ -193,6 +194,8 @@ async function startServer(options = {}) {
|
|
|
193
194
|
// Schedule nightly consolidation
|
|
194
195
|
const consolidateHour = options.consolidateHour ?? 2;
|
|
195
196
|
cancelConsolidation = (0, consolidate_js_1.scheduleConsolidation)(db, llm, embedder_js_1.embed, consolidateHour);
|
|
197
|
+
// Seed lesson on first run
|
|
198
|
+
await (0, seed_lesson_js_1.injectSeedLesson)(db);
|
|
196
199
|
// Stats
|
|
197
200
|
const stats = (0, db_js_1.getStats)(db, dbPath);
|
|
198
201
|
console.log(`[hicortex] Ready: ${stats.memories} memories, ${stats.links} links, ` +
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seed lesson — injected on first run, teaches agents to self-improve.
|
|
3
|
+
* Shared between OC plugin and CC MCP server.
|
|
4
|
+
*/
|
|
5
|
+
import type Database from "better-sqlite3";
|
|
6
|
+
export declare const SEED_LESSON = "## Lesson: 1% Daily Self-Improvement\n\nSelf-improvement protocol: Review your sessions daily. Scan for mistakes, gaps, user corrections, and friction. Identify 1-2 issues maximum. Apply one targeted fix to your instruction files (AGENT.md, IDENTITY.md, TOOLS.md, SOUL.md, or CLAUDE.md). Never overcorrect \u2014 feedback is guidance, not emergency. One fix per issue. Never rewrite entire systems. Before changing something, ask: is this a real pattern or am I reacting to noise?\n\nThe flywheel: Sessions \u2192 Hicortex captures \u2192 Nightly consolidation \u2192 Lessons generated \u2192 Lessons injected into your context \u2192 You apply one fix \u2192 Better sessions tomorrow.\n\nUse hicortex_lessons to check for new insights. If a lesson has high confidence, apply it. If medium, observe for one more day. If nothing needs fixing today, skip \u2014 that's fine.\n\n**Severity:** critical\n**Confidence:** high\n**Generated:** seed-lesson";
|
|
7
|
+
export declare function injectSeedLesson(database: Database.Database, log?: (msg: string) => void): Promise<void>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Seed lesson — injected on first run, teaches agents to self-improve.
|
|
4
|
+
* Shared between OC plugin and CC MCP server.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.SEED_LESSON = void 0;
|
|
41
|
+
exports.injectSeedLesson = injectSeedLesson;
|
|
42
|
+
const embedder_js_1 = require("./embedder.js");
|
|
43
|
+
const storage = __importStar(require("./storage.js"));
|
|
44
|
+
exports.SEED_LESSON = `## Lesson: 1% Daily Self-Improvement
|
|
45
|
+
|
|
46
|
+
Self-improvement protocol: Review your sessions daily. Scan for mistakes, gaps, user corrections, and friction. Identify 1-2 issues maximum. Apply one targeted fix to your instruction files (AGENT.md, IDENTITY.md, TOOLS.md, SOUL.md, or CLAUDE.md). Never overcorrect — feedback is guidance, not emergency. One fix per issue. Never rewrite entire systems. Before changing something, ask: is this a real pattern or am I reacting to noise?
|
|
47
|
+
|
|
48
|
+
The flywheel: Sessions → Hicortex captures → Nightly consolidation → Lessons generated → Lessons injected into your context → You apply one fix → Better sessions tomorrow.
|
|
49
|
+
|
|
50
|
+
Use hicortex_lessons to check for new insights. If a lesson has high confidence, apply it. If medium, observe for one more day. If nothing needs fixing today, skip — that's fine.
|
|
51
|
+
|
|
52
|
+
**Severity:** critical
|
|
53
|
+
**Confidence:** high
|
|
54
|
+
**Generated:** seed-lesson`;
|
|
55
|
+
async function injectSeedLesson(database, log = console.log) {
|
|
56
|
+
try {
|
|
57
|
+
const existing = storage.getLessons(database, 365);
|
|
58
|
+
const hasSeed = existing.some((l) => l.content.includes("1% Daily Self-Improvement") ||
|
|
59
|
+
l.source_agent === "hicortex/seed");
|
|
60
|
+
if (hasSeed)
|
|
61
|
+
return;
|
|
62
|
+
const embedding = await (0, embedder_js_1.embed)(exports.SEED_LESSON);
|
|
63
|
+
storage.insertMemory(database, exports.SEED_LESSON, embedding, {
|
|
64
|
+
sourceAgent: "hicortex/seed",
|
|
65
|
+
project: "global",
|
|
66
|
+
memoryType: "lesson",
|
|
67
|
+
baseStrength: 0.95,
|
|
68
|
+
privacy: "WORK",
|
|
69
|
+
});
|
|
70
|
+
log("[hicortex] Seed lesson injected: Daily Self-Improvement Protocol");
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
74
|
+
log(`[hicortex] Warning: could not inject seed lesson: ${msg}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "hicortex",
|
|
3
3
|
"name": "Hicortex — Long-term Memory That Learns",
|
|
4
4
|
"description": "Your agents remember past decisions, avoid repeated mistakes, and get smarter every day. Nightly reflection generates actionable lessons that automatically update agent behavior.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.6",
|
|
6
6
|
"kind": "lifecycle",
|
|
7
7
|
"skills": ["./skills/hicortex-memory", "./skills/hicortex-learn", "./skills/hicortex-activate"],
|
|
8
8
|
"configSchema": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamaze/hicortex",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Human-like memory for self-improving AI agents. Automatic capturing, nightly reflection, and cross-agent learning. Works with Claude Code and OpenClaw.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|