@gamaze/hicortex 0.3.2 → 0.3.4

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 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
- try {
78
- const raw = (0, node_fs_1.readFileSync)(CC_SETTINGS, "utf-8");
79
- const settings = JSON.parse(raw);
80
- result.ccMcpRegistered = "hicortex" in (settings?.mcpServers ?? {});
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");
@@ -97,44 +105,88 @@ async function detect() {
97
105
  // Actions
98
106
  // ---------------------------------------------------------------------------
99
107
  function registerCcMcp(serverUrl) {
100
- let settings = {};
101
108
  try {
102
- settings = JSON.parse((0, node_fs_1.readFileSync)(CC_SETTINGS, "utf-8"));
109
+ // Use claude CLI to register — it knows the correct config format and location
110
+ (0, node_child_process_1.execSync)(`claude mcp add hicortex --transport sse ${serverUrl}/sse`, { encoding: "utf-8", stdio: "pipe" });
111
+ console.log(` ✓ Registered MCP server via claude CLI`);
112
+ }
113
+ catch (err) {
114
+ // Fallback: write directly to settings.json if claude CLI not available
115
+ const msg = err instanceof Error ? err.message : String(err);
116
+ console.log(` ⚠ claude CLI registration failed (${msg}), writing settings.json directly`);
117
+ let settings = {};
118
+ try {
119
+ settings = JSON.parse((0, node_fs_1.readFileSync)(CC_SETTINGS, "utf-8"));
120
+ }
121
+ catch { /* create new */ }
122
+ if (!settings.mcpServers)
123
+ settings.mcpServers = {};
124
+ settings.mcpServers.hicortex = {
125
+ type: "sse",
126
+ url: `${serverUrl}/sse`,
127
+ };
128
+ (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(CC_SETTINGS), { recursive: true });
129
+ (0, node_fs_1.writeFileSync)(CC_SETTINGS, JSON.stringify(settings, null, 2));
130
+ console.log(` ✓ Registered MCP server in ${CC_SETTINGS}`);
103
131
  }
104
- catch { /* create new */ }
105
- if (!settings.mcpServers)
106
- settings.mcpServers = {};
107
- settings.mcpServers.hicortex = {
108
- type: "http",
109
- url: `${serverUrl}/sse`,
110
- };
111
- (0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(CC_SETTINGS), { recursive: true });
112
- (0, node_fs_1.writeFileSync)(CC_SETTINGS, JSON.stringify(settings, null, 2));
113
- console.log(` ✓ Registered MCP server in ${CC_SETTINGS}`);
114
132
  }
115
133
  function installCcCommands() {
116
134
  (0, node_fs_1.mkdirSync)(CC_COMMANDS_DIR, { recursive: true });
117
135
  // /learn command
118
- const learnContent = `# Save Learning to Hicortex
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
+ ---
142
+
143
+ # Save Learning to Hicortex
119
144
 
120
- When invoked with \`/learn <text>\`, store the learning in long-term memory.
145
+ When invoked with \`/learn <text>\`, store the learning in long-term memory via the Hicortex MCP tool.
121
146
 
122
147
  ## Steps
123
148
 
124
149
  1. Parse the text after \`/learn\`
125
- 2. Clean it up into a clear, self-contained statement
126
- 3. Add today's date
127
- 4. Call the \`hicortex_ingest\` tool with:
128
- - \`content\`: The learning text prefixed with "LEARNING: "
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
129
155
  - \`project\`: "global" (unless clearly project-specific)
130
156
  - \`memory_type\`: "lesson"
131
- 5. Confirm what was saved (brief, one line)
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"
132
166
  `;
133
- (0, node_fs_1.writeFileSync)((0, node_path_1.join)(CC_COMMANDS_DIR, "learn.md"), learnContent);
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
+ }
134
181
  // /hicortex-activate command
135
- const activateContent = `# Activate Hicortex License
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
+ ---
136
188
 
137
- When the user wants to activate their license key:
189
+ # Activate Hicortex License
138
190
 
139
191
  ## If key provided (e.g. /hicortex-activate hctx-abc123)
140
192
 
@@ -142,12 +194,14 @@ Write the key to the config file:
142
194
 
143
195
  \`\`\`bash
144
196
  mkdir -p ~/.hicortex
145
- cat > ~/.hicortex/config.json << 'EOF'
146
- { "licenseKey": "THE_KEY_HERE" }
147
- EOF
197
+ echo '{ "licenseKey": "THE_KEY_HERE" }' > ~/.hicortex/config.json
148
198
  \`\`\`
149
199
 
150
- Then tell the user: "License activated! Hicortex now has unlimited memory. Restart the server to apply: \`launchctl stop com.gamaze.hicortex && launchctl start com.gamaze.hicortex\`"
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\`
151
205
 
152
206
  ## If no key provided
153
207
 
@@ -67,7 +67,12 @@ let db = null;
67
67
  let llm = null;
68
68
  let cancelConsolidation = null;
69
69
  let stateDir = "";
70
- const VERSION = "0.3.0";
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
  // ---------------------------------------------------------------------------
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 settings
59
+ // 2. Remove MCP from CC
60
60
  try {
61
- const raw = (0, node_fs_1.readFileSync)(CC_SETTINGS, "utf-8");
62
- const settings = JSON.parse(raw);
63
- if (settings?.mcpServers?.hicortex) {
64
- delete settings.mcpServers.hicortex;
65
- (0, node_fs_1.writeFileSync)(CC_SETTINGS, JSON.stringify(settings, null, 2));
66
- console.log(" ✓ Removed MCP server from CC settings");
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);
@@ -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.2",
5
+ "version": "0.3.4",
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.2",
3
+ "version": "0.3.4",
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": {