@gamaze/hicortex 0.3.3 → 0.3.5
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/init.js +64 -20
- package/dist/mcp-server.js +9 -4
- package/dist/uninstall.js +15 -8
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/init.js
CHANGED
|
@@ -73,13 +73,21 @@ async function detect() {
|
|
|
73
73
|
result.ocPlugin = "hicortex" in entries || "hicortex" in installs || "hicortex-memory" in entries;
|
|
74
74
|
}
|
|
75
75
|
catch { /* no OC config */ }
|
|
76
|
-
// Check CC MCP registration
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
// Check CC MCP registration (claude mcp add writes to .claude.json, not settings.json)
|
|
77
|
+
for (const configPath of [
|
|
78
|
+
(0, node_path_1.join)((0, node_os_1.homedir)(), ".claude.json"),
|
|
79
|
+
CC_SETTINGS,
|
|
80
|
+
]) {
|
|
81
|
+
try {
|
|
82
|
+
const raw = (0, node_fs_1.readFileSync)(configPath, "utf-8");
|
|
83
|
+
const settings = JSON.parse(raw);
|
|
84
|
+
if ("hicortex" in (settings?.mcpServers ?? {})) {
|
|
85
|
+
result.ccMcpRegistered = true;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch { /* file doesn't exist */ }
|
|
81
90
|
}
|
|
82
|
-
catch { /* no CC settings */ }
|
|
83
91
|
// Check existing DB
|
|
84
92
|
const canonicalDb = (0, node_path_1.join)(HICORTEX_HOME, "hicortex.db");
|
|
85
93
|
const legacyDb = (0, node_path_1.join)((0, node_os_1.homedir)(), ".openclaw", "data", "hicortex.db");
|
|
@@ -125,26 +133,60 @@ function registerCcMcp(serverUrl) {
|
|
|
125
133
|
function installCcCommands() {
|
|
126
134
|
(0, node_fs_1.mkdirSync)(CC_COMMANDS_DIR, { recursive: true });
|
|
127
135
|
// /learn command
|
|
128
|
-
const learnContent =
|
|
136
|
+
const learnContent = `---
|
|
137
|
+
name: learn
|
|
138
|
+
description: Save an explicit learning/insight to Hicortex long-term memory. Immediate storage, no nightly wait. Use when you discover something worth remembering across sessions.
|
|
139
|
+
argument-hint: <learning to save>
|
|
140
|
+
allowed-tools: mcp__hicortex__hicortex_ingest, mcp__hicortex__hicortex_search, mcp__hicortex__hicortex_context, mcp__hicortex__hicortex_lessons
|
|
141
|
+
---
|
|
129
142
|
|
|
130
|
-
|
|
143
|
+
# Save Learning to Hicortex
|
|
144
|
+
|
|
145
|
+
When invoked with \`/learn <text>\`, store the learning in long-term memory via the Hicortex MCP tool.
|
|
131
146
|
|
|
132
147
|
## Steps
|
|
133
148
|
|
|
134
149
|
1. Parse the text after \`/learn\`
|
|
135
|
-
2. Clean it up into a clear, self-contained statement
|
|
136
|
-
3.
|
|
137
|
-
4.
|
|
138
|
-
|
|
150
|
+
2. Clean it up into a clear, self-contained statement that will make sense months from now
|
|
151
|
+
3. Include the "why" when relevant
|
|
152
|
+
4. Add today's date for temporal context
|
|
153
|
+
5. Call the \`hicortex_ingest\` tool with:
|
|
154
|
+
- \`content\`: The learning text prefixed with "LEARNING: " and suffixed with the date
|
|
139
155
|
- \`project\`: "global" (unless clearly project-specific)
|
|
140
156
|
- \`memory_type\`: "lesson"
|
|
141
|
-
|
|
157
|
+
6. Confirm what was saved (brief, one line)
|
|
158
|
+
|
|
159
|
+
## Example
|
|
160
|
+
|
|
161
|
+
\`/learn z.ai API uses Bearer auth on all endpoints, not x-api-key\`
|
|
162
|
+
|
|
163
|
+
Becomes a call to hicortex_ingest with:
|
|
164
|
+
- content: "LEARNING: z.ai API uses Bearer auth on all three endpoints (paas, coding, anthropic). Not x-api-key. (2026-03-26)"
|
|
165
|
+
- memory_type: "lesson"
|
|
142
166
|
`;
|
|
143
|
-
|
|
167
|
+
const learnPath = (0, node_path_1.join)(CC_COMMANDS_DIR, "learn.md");
|
|
168
|
+
if ((0, node_fs_1.existsSync)(learnPath)) {
|
|
169
|
+
// Check if it's ours (contains hicortex_ingest)
|
|
170
|
+
const existing = (0, node_fs_1.readFileSync)(learnPath, "utf-8");
|
|
171
|
+
if (!existing.includes("hicortex_ingest") && !existing.includes("hicortex")) {
|
|
172
|
+
console.log(` ⚠ Skipping /learn — existing command found (not Hicortex). Won't overwrite.`);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
(0, node_fs_1.writeFileSync)(learnPath, learnContent);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
(0, node_fs_1.writeFileSync)(learnPath, learnContent);
|
|
180
|
+
}
|
|
144
181
|
// /hicortex-activate command
|
|
145
|
-
const activateContent =
|
|
182
|
+
const activateContent = `---
|
|
183
|
+
name: hicortex-activate
|
|
184
|
+
description: Activate a Hicortex license key for unlimited memory. Use after purchasing at hicortex.gamaze.com.
|
|
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
|
|
187
|
+
---
|
|
146
188
|
|
|
147
|
-
|
|
189
|
+
# Activate Hicortex License
|
|
148
190
|
|
|
149
191
|
## If key provided (e.g. /hicortex-activate hctx-abc123)
|
|
150
192
|
|
|
@@ -152,12 +194,14 @@ Write the key to the config file:
|
|
|
152
194
|
|
|
153
195
|
\`\`\`bash
|
|
154
196
|
mkdir -p ~/.hicortex
|
|
155
|
-
|
|
156
|
-
{ "licenseKey": "THE_KEY_HERE" }
|
|
157
|
-
EOF
|
|
197
|
+
echo '{ "licenseKey": "THE_KEY_HERE" }' > ~/.hicortex/config.json
|
|
158
198
|
\`\`\`
|
|
159
199
|
|
|
160
|
-
Then tell the user: "License activated! Hicortex now has unlimited memory. Restart the server to apply
|
|
200
|
+
Then tell the user: "License activated! Hicortex now has unlimited memory. Restart the server to apply."
|
|
201
|
+
|
|
202
|
+
Provide the restart command for their platform:
|
|
203
|
+
- macOS: \`launchctl kickstart -k gui/$(id -u)/com.gamaze.hicortex\`
|
|
204
|
+
- Linux: \`systemctl --user restart hicortex\`
|
|
161
205
|
|
|
162
206
|
## If no key provided
|
|
163
207
|
|
package/dist/mcp-server.js
CHANGED
|
@@ -67,7 +67,12 @@ let db = null;
|
|
|
67
67
|
let llm = null;
|
|
68
68
|
let cancelConsolidation = null;
|
|
69
69
|
let stateDir = "";
|
|
70
|
-
|
|
70
|
+
let VERSION = "0.3.x";
|
|
71
|
+
try {
|
|
72
|
+
const pkg = JSON.parse(require("node:fs").readFileSync(require("node:path").join(__dirname, "..", "package.json"), "utf-8"));
|
|
73
|
+
VERSION = pkg.version;
|
|
74
|
+
}
|
|
75
|
+
catch { /* fallback */ }
|
|
71
76
|
// ---------------------------------------------------------------------------
|
|
72
77
|
// MCP Server setup
|
|
73
78
|
// ---------------------------------------------------------------------------
|
|
@@ -79,7 +84,7 @@ function createMcpServer() {
|
|
|
79
84
|
// -- hicortex_search --
|
|
80
85
|
server.tool("hicortex_search", "Search long-term memory using semantic similarity. Returns the most relevant memories from past sessions.", {
|
|
81
86
|
query: zod_1.z.string().describe("Search query text"),
|
|
82
|
-
limit: zod_1.z.number().optional().describe("Max results (default 5)"),
|
|
87
|
+
limit: zod_1.z.coerce.number().optional().describe("Max results (default 5)"),
|
|
83
88
|
project: zod_1.z.string().optional().describe("Filter by project name"),
|
|
84
89
|
}, async ({ query, limit, project }) => {
|
|
85
90
|
if (!db)
|
|
@@ -95,7 +100,7 @@ function createMcpServer() {
|
|
|
95
100
|
// -- hicortex_context --
|
|
96
101
|
server.tool("hicortex_context", "Get recent context memories, optionally filtered by project. Useful to recall what happened recently.", {
|
|
97
102
|
project: zod_1.z.string().optional().describe("Filter by project name"),
|
|
98
|
-
limit: zod_1.z.number().optional().describe("Max results (default 10)"),
|
|
103
|
+
limit: zod_1.z.coerce.number().optional().describe("Max results (default 10)"),
|
|
99
104
|
}, async ({ project, limit }) => {
|
|
100
105
|
if (!db)
|
|
101
106
|
return { content: [{ type: "text", text: "Hicortex not initialized" }], isError: true };
|
|
@@ -143,7 +148,7 @@ function createMcpServer() {
|
|
|
143
148
|
});
|
|
144
149
|
// -- hicortex_lessons --
|
|
145
150
|
server.tool("hicortex_lessons", "Get actionable lessons learned from past sessions. Auto-generated insights about mistakes to avoid.", {
|
|
146
|
-
days: zod_1.z.number().optional().describe("Look back N days (default 7)"),
|
|
151
|
+
days: zod_1.z.coerce.number().optional().describe("Look back N days (default 7)"),
|
|
147
152
|
project: zod_1.z.string().optional().describe("Filter by project name"),
|
|
148
153
|
}, async ({ days, project }) => {
|
|
149
154
|
if (!db)
|
package/dist/uninstall.js
CHANGED
|
@@ -56,17 +56,24 @@ async function runUninstall() {
|
|
|
56
56
|
}
|
|
57
57
|
catch { /* not installed */ }
|
|
58
58
|
}
|
|
59
|
-
// 2. Remove MCP from CC
|
|
59
|
+
// 2. Remove MCP from CC
|
|
60
60
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
(0, node_child_process_1.execSync)("claude mcp remove hicortex 2>/dev/null", { encoding: "utf-8", stdio: "pipe" });
|
|
62
|
+
console.log(" ✓ Removed MCP server via claude CLI");
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Fallback: remove from settings.json directly
|
|
66
|
+
try {
|
|
67
|
+
const raw = (0, node_fs_1.readFileSync)(CC_SETTINGS, "utf-8");
|
|
68
|
+
const settings = JSON.parse(raw);
|
|
69
|
+
if (settings?.mcpServers?.hicortex) {
|
|
70
|
+
delete settings.mcpServers.hicortex;
|
|
71
|
+
(0, node_fs_1.writeFileSync)(CC_SETTINGS, JSON.stringify(settings, null, 2));
|
|
72
|
+
console.log(" ✓ Removed MCP server from CC settings");
|
|
73
|
+
}
|
|
67
74
|
}
|
|
75
|
+
catch { /* no settings */ }
|
|
68
76
|
}
|
|
69
|
-
catch { /* no settings */ }
|
|
70
77
|
// 3. Remove CC custom commands
|
|
71
78
|
for (const cmd of ["learn.md", "hicortex-activate.md"]) {
|
|
72
79
|
const cmdPath = (0, node_path_1.join)(CC_COMMANDS_DIR, cmd);
|
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.5",
|
|
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.5",
|
|
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": {
|