@claudeink/mcp-server 0.6.1 → 0.6.3

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.
Files changed (2) hide show
  1. package/dist/index.js +67 -45
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,20 +12,30 @@ import { join as join4 } from "path";
12
12
  // src/lib/config.ts
13
13
  import { readFile, writeFile, mkdir, chmod, access } from "fs/promises";
14
14
  import { join } from "path";
15
- import { homedir } from "os";
16
- var CLAUDEINK_DIR = join(homedir(), ".claudeink");
17
- var PATHS = {
18
- credentials: join(CLAUDEINK_DIR, "credentials.json"),
19
- config: join(CLAUDEINK_DIR, "config.json"),
20
- syncState: join(CLAUDEINK_DIR, "sync-state.json"),
21
- tagQueue: join(CLAUDEINK_DIR, "tag-queue.json"),
22
- crawlSchedules: join(CLAUDEINK_DIR, "crawl-schedules.json"),
23
- logs: join(CLAUDEINK_DIR, "logs")
24
- };
15
+ var _workDirCache = null;
16
+ function setWorkDir(dir) {
17
+ _workDirCache = dir;
18
+ }
19
+ function getWorkDir() {
20
+ return _workDirCache || process.env.CLAUDEINK_WORK_DIR || process.cwd();
21
+ }
22
+ function getClaudeinkDir() {
23
+ return join(getWorkDir(), ".claudeink");
24
+ }
25
+ function getPaths() {
26
+ const dir = getClaudeinkDir();
27
+ return {
28
+ credentials: join(dir, "credentials.json"),
29
+ config: join(dir, "config.json"),
30
+ syncState: join(dir, "sync-state.json"),
31
+ tagQueue: join(dir, "tag-queue.json"),
32
+ crawlSchedules: join(dir, "crawl-schedules.json"),
33
+ logs: join(dir, "logs")
34
+ };
35
+ }
25
36
  var DEFAULT_CONFIG = {
26
37
  apiBaseUrl: "https://app.claudeink.com",
27
38
  syncIntervalMs: 3e5,
28
- // 5 minutes
29
39
  heartbeatIntervalMs: 3e5,
30
40
  maxTagQueueBatch: 20,
31
41
  workflowDir: ""
@@ -40,8 +50,9 @@ var DEFAULT_TAG_QUEUE = {
40
50
  }
41
51
  };
42
52
  async function ensureDir() {
43
- await mkdir(CLAUDEINK_DIR, { recursive: true });
44
- await mkdir(PATHS.logs, { recursive: true });
53
+ const paths = getPaths();
54
+ await mkdir(getClaudeinkDir(), { recursive: true });
55
+ await mkdir(paths.logs, { recursive: true });
45
56
  }
46
57
  async function fileExists(path) {
47
58
  try {
@@ -67,24 +78,23 @@ async function writeJson(path, data, secure = false) {
67
78
  }
68
79
  }
69
80
  async function getCredentials() {
70
- if (!await fileExists(PATHS.credentials)) return null;
71
- return readJson(PATHS.credentials, null);
72
- }
73
- async function saveCredentials(creds) {
74
- await writeJson(PATHS.credentials, creds, true);
81
+ const paths = getPaths();
82
+ if (!await fileExists(paths.credentials)) return null;
83
+ return readJson(paths.credentials, null);
75
84
  }
76
85
  async function getConfig() {
77
- return readJson(PATHS.config, DEFAULT_CONFIG);
78
- }
79
- async function saveConfig(config) {
80
- const current = await getConfig();
81
- await writeJson(PATHS.config, { ...current, ...config });
86
+ const paths = getPaths();
87
+ const config = await readJson(paths.config, DEFAULT_CONFIG);
88
+ config.workflowDir = getWorkDir();
89
+ return config;
82
90
  }
83
91
  async function getTagQueue() {
84
- return readJson(PATHS.tagQueue, DEFAULT_TAG_QUEUE);
92
+ const paths = getPaths();
93
+ return readJson(paths.tagQueue, DEFAULT_TAG_QUEUE);
85
94
  }
86
95
  async function saveTagQueue(queue) {
87
- await writeJson(PATHS.tagQueue, queue);
96
+ const paths = getPaths();
97
+ await writeJson(paths.tagQueue, queue);
88
98
  }
89
99
 
90
100
  // src/lib/sources.ts
@@ -171,8 +181,7 @@ var DEFAULT_STATE = {
171
181
  lastSyncAt: ""
172
182
  };
173
183
  async function getStatePath() {
174
- const config = await getConfig();
175
- const dir = join3(config.workflowDir || process.cwd(), ".claudeink");
184
+ const dir = join3(getWorkDir(), ".claudeink");
176
185
  await mkdir2(dir, { recursive: true });
177
186
  return join3(dir, "state.json");
178
187
  }
@@ -923,7 +932,7 @@ async function syncPull(input) {
923
932
 
924
933
  // src/tools/workflow.ts
925
934
  import { z as z6 } from "zod";
926
- import { cp, mkdir as mkdir6, access as access2 } from "fs/promises";
935
+ import { cp, mkdir as mkdir6, access as access2, writeFile as writeFile7 } from "fs/promises";
927
936
  import { join as join8, dirname } from "path";
928
937
  import { fileURLToPath } from "url";
929
938
  var DEFAULT_API_BASE_URL = "https://app.claudeink.com";
@@ -938,6 +947,7 @@ async function workflowInit(input) {
938
947
  const cwd = input.workDir;
939
948
  const results = [];
940
949
  try {
950
+ setWorkDir(cwd);
941
951
  const items = ["CLAUDE.md", "base-rules.md", "platforms", "accounts", "tools"];
942
952
  for (const item of items) {
943
953
  const src = join8(WORKFLOW_SRC, item);
@@ -950,24 +960,33 @@ async function workflowInit(input) {
950
960
  results.push(`\u2705 ${item}`);
951
961
  }
952
962
  }
963
+ const claudeinkDir = join8(cwd, ".claudeink");
953
964
  const dirs = [
954
965
  "sources/articles",
955
966
  "sources/video-transcripts",
956
967
  "sources/notes",
957
968
  "sources/data",
958
969
  "sources/daily",
959
- "templates",
960
- ".claudeink"
970
+ "templates"
961
971
  ];
962
972
  for (const dir of dirs) {
963
973
  await mkdir6(join8(cwd, dir), { recursive: true });
964
974
  }
975
+ await mkdir6(claudeinkDir, { recursive: true });
965
976
  results.push("\u2705 \u8FD0\u884C\u65F6\u76EE\u5F55\u5DF2\u521B\u5EFA");
966
- await saveConfig({ workflowDir: cwd });
967
- const statePath = join8(cwd, ".claudeink", "state.json");
977
+ const configPath = join8(claudeinkDir, "config.json");
978
+ const statePath = join8(claudeinkDir, "state.json");
979
+ await writeFile7(configPath, JSON.stringify({
980
+ apiBaseUrl: DEFAULT_API_BASE_URL,
981
+ syncIntervalMs: 3e5,
982
+ heartbeatIntervalMs: 3e5,
983
+ maxTagQueueBatch: 20,
984
+ workflowDir: cwd
985
+ }, null, 2), "utf-8");
986
+ results.push("\u2705 config.json");
968
987
  try {
969
988
  await access2(statePath);
970
- results.push("\u23ED\uFE0F \u672C\u5730\u72B6\u6001\u8868\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");
989
+ results.push("\u23ED\uFE0F state.json \u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");
971
990
  } catch {
972
991
  const emptyState = {
973
992
  sources: {},
@@ -978,8 +997,8 @@ async function workflowInit(input) {
978
997
  writingMasters: {},
979
998
  lastSyncAt: ""
980
999
  };
981
- await replaceState(emptyState);
982
- results.push("\u2705 \u672C\u5730\u72B6\u6001\u8868\u5DF2\u521D\u59CB\u5316");
1000
+ await writeFile7(statePath, JSON.stringify(emptyState, null, 2), "utf-8");
1001
+ results.push("\u2705 state.json");
983
1002
  }
984
1003
  let activated = false;
985
1004
  if (input.licenseKey) {
@@ -992,13 +1011,17 @@ async function workflowInit(input) {
992
1011
  });
993
1012
  const data = await res.json();
994
1013
  if (data.userId) {
995
- await saveCredentials({
996
- licenseKey: input.licenseKey,
997
- token: data.token,
998
- userId: data.userId,
999
- plan: data.plan,
1000
- expiresAt: data.expiresAt
1001
- });
1014
+ await writeFile7(
1015
+ join8(claudeinkDir, "credentials.json"),
1016
+ JSON.stringify({
1017
+ licenseKey: input.licenseKey,
1018
+ token: data.token,
1019
+ userId: data.userId,
1020
+ plan: data.plan,
1021
+ expiresAt: data.expiresAt
1022
+ }, null, 2),
1023
+ { mode: 384 }
1024
+ );
1002
1025
  results.push(`\u2705 License \u6FC0\u6D3B\u6210\u529F\uFF08\u5957\u9910: ${data.plan}\uFF09`);
1003
1026
  activated = true;
1004
1027
  } else {
@@ -1039,8 +1062,7 @@ async function workflowInit(input) {
1039
1062
  "",
1040
1063
  "\u{1F3AF} \u4E0B\u4E00\u6B65\uFF1A",
1041
1064
  "1. \u8BFB\u53D6 CLAUDE.md \u4E86\u89E3\u4E09\u5C42\u914D\u7F6E\u67B6\u6784",
1042
- "2. \u4F7F\u7528 /\u65B0\u5EFA\u8D26\u53F7 \u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u5A92\u4F53\u8D26\u53F7",
1043
- "3. \u4F7F\u7528 /\u7F16\u5199 \u5F00\u59CB\u5185\u5BB9\u521B\u4F5C"
1065
+ "2. \u5F00\u59CB\u5185\u5BB9\u521B\u4F5C"
1044
1066
  ].join("\n")
1045
1067
  };
1046
1068
  } catch (err) {
@@ -1054,7 +1076,7 @@ async function workflowInit(input) {
1054
1076
  // src/index.ts
1055
1077
  var server = new McpServer({
1056
1078
  name: "ClaudeInk",
1057
- version: "0.6.1"
1079
+ version: "0.6.3"
1058
1080
  });
1059
1081
  server.tool("workflow.init", "\u521D\u59CB\u5316\u5199\u4F5C\u5DE5\u4F5C\u6D41\uFF08\u91CA\u653E\u4E09\u5C42\u914D\u7F6E + \u6FC0\u6D3B License + \u81EA\u52A8\u540C\u6B65\u4E91\u7AEF\u914D\u7F6E\uFF09", workflowInitSchema.shape, async (input) => {
1060
1082
  const result = await workflowInit(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudeink/mcp-server",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "ClaudeInk MCP Server - 自媒体多平台写作系统的本地 MCP 服务,连接 Claude 与云端后台",
5
5
  "mcpName": "io.github.weekdmond/claudeink",
6
6
  "type": "module",