@becrafter/prompt-manager 0.1.8 → 0.1.9

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.
@@ -1,4 +1,38 @@
1
1
  import { registerSignalHandlers } from '../support/signals.js';
2
+ import { promises as fs } from 'fs';
3
+ import path from 'path';
4
+ import os from 'os';
5
+ import { fileURLToPath } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ // 同步环境配置文件(从 postinstall 脚本移到这里)
11
+ async function syncEnvExample() {
12
+ try {
13
+ const projectRoot = path.resolve(__dirname, '../../..');
14
+ const exampleEnvPath = path.join(projectRoot, 'env.example');
15
+ const homeDir = os.homedir();
16
+ const configRoot = path.join(homeDir, '.prompt-manager');
17
+ const targetEnvPath = path.join(configRoot, '.env');
18
+
19
+ const exampleContent = await fs.readFile(exampleEnvPath, 'utf8');
20
+ await fs.mkdir(configRoot, { recursive: true });
21
+
22
+ try {
23
+ await fs.access(targetEnvPath);
24
+ // 如果用户已经有自定义配置,则不覆盖
25
+ return;
26
+ } catch (error) {
27
+ // 文件不存在,继续写入
28
+ }
29
+
30
+ await fs.writeFile(targetEnvPath, exampleContent, 'utf8');
31
+ console.log(`已将默认环境变量写入 ${targetEnvPath}`);
32
+ } catch (error) {
33
+ // 静默失败,不影响启动
34
+ }
35
+ }
2
36
 
3
37
  // 简单的 CLI 参数解析
4
38
  function parseCLIArgs(args) {
@@ -29,6 +63,9 @@ export async function startCommand(rawArgs, options = {}) {
29
63
  return;
30
64
  }
31
65
 
66
+ // 同步环境配置文件
67
+ await syncEnvExample();
68
+
32
69
  const { startServer, stopServer, getServerState } = await import('../../../packages/server/server.js');
33
70
 
34
71
  registerSignalHandlers(stopServer);
package/env.example CHANGED
@@ -7,7 +7,7 @@ PROMPTS_DIR=$HOME/.prompt-manager/prompts
7
7
 
8
8
  # MCP服务器配置
9
9
  MCP_SERVER_NAME=prompt-manager
10
- MCP_SERVER_VERSION=0.1.8
10
+ MCP_SERVER_VERSION=0.1.9
11
11
 
12
12
  # 日志级别 (error, warn, info, debug)
13
13
  LOG_LEVEL=info
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@becrafter/prompt-manager",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Remote MCP Server for managing prompts",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,7 +38,6 @@
38
38
  "desktop:check": "npm run check:deps && npm run test:module-loading",
39
39
  "desktop:verify": "npm run check:deps && npm run test:module-loading && npm run desktop:dev",
40
40
  "check:deps": "bash scripts/check-dependencies.sh",
41
- "postinstall": "node ./scripts/postinstall.js",
42
41
  "build:core": "npm run build --prefix packages/server",
43
42
  "build:icons": "node ./scripts/build-icons.js",
44
43
  "test": "npm run test:module-loading && npm run test:server && npm run test:server:integration && npm run test:upload",
@@ -121,7 +121,7 @@ export class Config {
121
121
 
122
122
  // 其他配置
123
123
  this.serverName = process.env.MCP_SERVER_NAME || 'prompt-manager';
124
- this.serverVersion = process.env.MCP_SERVER_VERSION || '0.1.8';
124
+ this.serverVersion = process.env.MCP_SERVER_VERSION || '0.1.9';
125
125
  this.logLevel = process.env.LOG_LEVEL || 'info';
126
126
  this.maxPrompts = parseInt(process.env.MAX_PROMPTS) || 1000;
127
127
  this.recursiveScan = process.env.RECURSIVE_SCAN !== 'false'; // 默认启用递归扫描