@hippo-memo/cli 1.0.3 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hippo-memo/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "hippo": "./dist/index.js"
package/src/api/server.ts CHANGED
@@ -1,4 +1,5 @@
1
- import path, { join } from "node:path";
1
+ import { dirname, join } from "node:path";
2
+ import { fileURLToPath } from "node:url";
2
3
  import type { MemoryStore } from "@hippo-memo/core";
3
4
  import { serve } from "@hono/node-server";
4
5
  import { serveStatic } from "@hono/node-server/serve-static";
@@ -7,7 +8,8 @@ import { setupApiRoutes } from "./router";
7
8
 
8
9
  export function createServer(store: MemoryStore) {
9
10
  const app = new Hono();
10
- const webDist = process.env.WEB_DIST || join(__dirname, "../../dist");
11
+ const currentDir = dirname(fileURLToPath(import.meta.url));
12
+ const webDist = process.env.WEB_DIST || currentDir;
11
13
  setupApiRoutes(app, store);
12
14
  app.get("/*", serveStatic({ root: webDist }));
13
15
  app.get("*", serveStatic({ path: join(webDist, "index.html") }));
@@ -7,22 +7,21 @@ import {
7
7
  writeFile
8
8
  } from "node:fs/promises";
9
9
  import { EOL } from "node:os";
10
- import { join } from "node:path";
10
+ import { dirname, join } from "node:path";
11
+ import { fileURLToPath } from "node:url";
11
12
  import { createConfig, createStore } from "@hippo-memo/core";
12
13
  import { MEMORY_DIR_NAME } from "@hippo-memo/shared";
13
14
  import prompts from "prompts";
14
15
 
15
- const __dirname = import.meta.dirname;
16
- const TEMPLATE_DIR = join(__dirname, "../../template/system");
17
- const MCP_AGENTS_TEMPLATE_PATH = join(
18
- __dirname,
19
- "../../template/mcp/AGENTS.md"
20
- );
16
+ const currentDir = dirname(fileURLToPath(import.meta.url));
17
+ const TEMPLATE_DIR = join(currentDir, "./template/system");
18
+ const MCP_AGENTS_TEMPLATE_PATH = join(currentDir, "./template/mcp/AGENTS.md");
21
19
  const SKILL_AGENTS_TEMPLATE_PATH = join(
22
- __dirname,
23
- "../../template/skill/AGENTS.md"
20
+ currentDir,
21
+ "./template/skill/AGENTS.md"
24
22
  );
25
- const SKILL_TEMPLATE_DIR = join(__dirname, "../../template/skill");
23
+
24
+ const SKILL_TEMPLATE_DIR = join(currentDir, "./template/skill");
26
25
 
27
26
  const TEMPLATE_URIS = {
28
27
  agent: "system://agent",
@@ -137,6 +136,11 @@ async function handleAgentsAndClaudeFiles(
137
136
  initial: true
138
137
  });
139
138
 
139
+ if (response.inject === undefined) {
140
+ // 用户按下 Ctrl+C 取消
141
+ process.exit(0);
142
+ }
143
+
140
144
  if (response.inject) {
141
145
  await injectToTopOfFile(claudePath, agentsContent);
142
146
  } else {
@@ -159,6 +163,11 @@ async function handleAgentsAndClaudeFiles(
159
163
  initial: true
160
164
  });
161
165
 
166
+ if (response.inject === undefined) {
167
+ // 用户按下 Ctrl+C 取消
168
+ process.exit(0);
169
+ }
170
+
162
171
  if (response.inject) {
163
172
  await injectToTopOfFile(agentsPath, agentsContent);
164
173
  } else {
@@ -212,6 +221,11 @@ async function copySkillTemplates(directory: string): Promise<void> {
212
221
  initial: false
213
222
  });
214
223
 
224
+ if (response.overwrite === undefined) {
225
+ // 用户按下 Ctrl+C 取消
226
+ process.exit(0);
227
+ }
228
+
215
229
  if (!response.overwrite) {
216
230
  console.log(`› Skipped: ${skill}`);
217
231
  continue;
@@ -249,7 +263,12 @@ async function askInitMode(): Promise<InitMode> {
249
263
  initial: 1
250
264
  });
251
265
 
252
- return (response.mode as InitMode) || "skill";
266
+ if (!response.mode) {
267
+ // 用户取消输入(Ctrl+C 或 Esc)
268
+ process.exit(0);
269
+ }
270
+
271
+ return response.mode as InitMode;
253
272
  }
254
273
 
255
274
  export async function init(directory: string): Promise<void> {