@gamaze/hicortex 0.3.6 → 0.3.7

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
@@ -106,6 +106,11 @@ async function detect() {
106
106
  // ---------------------------------------------------------------------------
107
107
  function registerCcMcp(serverUrl) {
108
108
  try {
109
+ // Remove existing entry first (idempotent — ignore if not found)
110
+ try {
111
+ (0, node_child_process_1.execSync)("claude mcp remove hicortex 2>/dev/null", { encoding: "utf-8", stdio: "pipe" });
112
+ }
113
+ catch { /* not found */ }
109
114
  // Use claude CLI to register — it knows the correct config format and location
110
115
  (0, node_child_process_1.execSync)(`claude mcp add hicortex --transport sse ${serverUrl}/sse`, { encoding: "utf-8", stdio: "pipe" });
111
116
  console.log(` ✓ Registered MCP server via claude CLI`);
@@ -223,21 +228,32 @@ Tell them: "Get a license key at https://hicortex.gamaze.com/ — after purchase
223
228
  (0, node_fs_1.writeFileSync)((0, node_path_1.join)(CC_COMMANDS_DIR, "hicortex-activate.md"), activateContent);
224
229
  console.log(` ✓ Installed /learn and /hicortex-activate commands in ${CC_COMMANDS_DIR}`);
225
230
  }
226
- function getPackageVersion() {
231
+ /**
232
+ * Determine the npm package specifier for the daemon.
233
+ * Uses tag-based resolution so restarts pick up new versions automatically.
234
+ *
235
+ * Checks if the current version matches the npm `latest` tag.
236
+ * If not (e.g. running from @next), uses @gamaze/hicortex@next.
237
+ * If it does match latest, uses bare @gamaze/hicortex.
238
+ */
239
+ function getPackageSpec() {
227
240
  try {
228
- const pkgPath = (0, node_path_1.join)(__dirname, "..", "package.json");
229
- const pkg = JSON.parse((0, node_fs_1.readFileSync)(pkgPath, "utf-8"));
230
- return pkg.version ?? "latest";
231
- }
232
- catch {
233
- return "latest";
241
+ const currentVersion = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, "..", "package.json"), "utf-8")).version;
242
+ const latestVersion = (0, node_child_process_1.execSync)("npm view @gamaze/hicortex version 2>/dev/null", {
243
+ encoding: "utf-8",
244
+ timeout: 5000,
245
+ }).trim();
246
+ if (currentVersion !== latestVersion) {
247
+ return "@gamaze/hicortex@next";
248
+ }
234
249
  }
250
+ catch { /* can't check — default to bare */ }
251
+ return "@gamaze/hicortex";
235
252
  }
236
253
  function installDaemon() {
237
254
  const os = (0, node_os_1.platform)();
238
255
  const npxPath = findNpxPath();
239
- const version = getPackageVersion();
240
- const packageSpec = `@gamaze/hicortex@${version}`;
256
+ const packageSpec = getPackageSpec();
241
257
  if (os === "darwin") {
242
258
  return installLaunchd(npxPath, packageSpec);
243
259
  }
@@ -200,12 +200,10 @@ async function startServer(options = {}) {
200
200
  const stats = (0, db_js_1.getStats)(db, dbPath);
201
201
  console.log(`[hicortex] Ready: ${stats.memories} memories, ${stats.links} links, ` +
202
202
  `${Math.round(stats.db_size_bytes / 1024)} KB`);
203
- // Create MCP server
204
- const mcpServer = createMcpServer();
205
203
  // Express app
206
204
  const app = (0, express_1.default)();
207
205
  app.use(express_1.default.json());
208
- // SSE transport management
206
+ // SSE transport management — each connection gets its own McpServer instance
209
207
  const transports = new Map();
210
208
  // Health endpoint
211
209
  app.get("/health", (_req, res) => {
@@ -219,9 +217,10 @@ async function startServer(options = {}) {
219
217
  llm: `${llmConfig.provider}/${llmConfig.model}`,
220
218
  });
221
219
  });
222
- // SSE endpoint — client connects here to establish MCP session
220
+ // SSE endpoint — each connection gets its own McpServer + transport
223
221
  app.get("/sse", async (req, res) => {
224
222
  const transport = new sse_js_1.SSEServerTransport("/messages", res);
223
+ const mcpServer = createMcpServer();
225
224
  transports.set(transport.sessionId, transport);
226
225
  transport.onclose = () => {
227
226
  transports.delete(transport.sessionId);
@@ -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.6",
5
+ "version": "0.3.7",
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.6",
3
+ "version": "0.3.7",
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": {