@claudeink/mcp-server 0.6.0 → 0.6.2

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 +73 -38
  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,17 +78,32 @@ 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);
81
+ const paths = getPaths();
82
+ if (!await fileExists(paths.credentials)) return null;
83
+ return readJson(paths.credentials, null);
84
+ }
85
+ async function saveCredentials(creds) {
86
+ const paths = getPaths();
87
+ await writeJson(paths.credentials, creds, true);
72
88
  }
73
89
  async function getConfig() {
74
- return readJson(PATHS.config, DEFAULT_CONFIG);
90
+ const paths = getPaths();
91
+ const config = await readJson(paths.config, DEFAULT_CONFIG);
92
+ config.workflowDir = getWorkDir();
93
+ return config;
94
+ }
95
+ async function saveConfig(config) {
96
+ const paths = getPaths();
97
+ const current = await readJson(paths.config, DEFAULT_CONFIG);
98
+ await writeJson(paths.config, { ...current, ...config });
75
99
  }
76
100
  async function getTagQueue() {
77
- return readJson(PATHS.tagQueue, DEFAULT_TAG_QUEUE);
101
+ const paths = getPaths();
102
+ return readJson(paths.tagQueue, DEFAULT_TAG_QUEUE);
78
103
  }
79
104
  async function saveTagQueue(queue) {
80
- await writeJson(PATHS.tagQueue, queue);
105
+ const paths = getPaths();
106
+ await writeJson(paths.tagQueue, queue);
81
107
  }
82
108
 
83
109
  // src/lib/sources.ts
@@ -164,8 +190,7 @@ var DEFAULT_STATE = {
164
190
  lastSyncAt: ""
165
191
  };
166
192
  async function getStatePath() {
167
- const config = await getConfig();
168
- const dir = join3(config.workflowDir || process.cwd(), ".claudeink");
193
+ const dir = join3(getWorkDir(), ".claudeink");
169
194
  await mkdir2(dir, { recursive: true });
170
195
  return join3(dir, "state.json");
171
196
  }
@@ -916,7 +941,7 @@ async function syncPull(input) {
916
941
 
917
942
  // src/tools/workflow.ts
918
943
  import { z as z6 } from "zod";
919
- import { cp, mkdir as mkdir6, access as access2, writeFile as writeFile7 } from "fs/promises";
944
+ import { cp, mkdir as mkdir6, access as access2 } from "fs/promises";
920
945
  import { join as join8, dirname } from "path";
921
946
  import { fileURLToPath } from "url";
922
947
  var DEFAULT_API_BASE_URL = "https://app.claudeink.com";
@@ -956,17 +981,25 @@ async function workflowInit(input) {
956
981
  await mkdir6(join8(cwd, dir), { recursive: true });
957
982
  }
958
983
  results.push("\u2705 \u8FD0\u884C\u65F6\u76EE\u5F55\u5DF2\u521B\u5EFA");
959
- const emptyState = {
960
- sources: {},
961
- drafts: {},
962
- published: {},
963
- configs: {},
964
- crawlerSources: {},
965
- writingMasters: {},
966
- lastSyncAt: ""
967
- };
968
- await replaceState(emptyState);
969
- results.push("\u2705 \u672C\u5730\u72B6\u6001\u8868\u5DF2\u521D\u59CB\u5316");
984
+ setWorkDir(cwd);
985
+ await saveConfig({ workflowDir: cwd });
986
+ const statePath = join8(cwd, ".claudeink", "state.json");
987
+ try {
988
+ await access2(statePath);
989
+ results.push("\u23ED\uFE0F \u672C\u5730\u72B6\u6001\u8868\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");
990
+ } catch {
991
+ const emptyState = {
992
+ sources: {},
993
+ drafts: {},
994
+ published: {},
995
+ configs: {},
996
+ crawlerSources: {},
997
+ writingMasters: {},
998
+ lastSyncAt: ""
999
+ };
1000
+ await replaceState(emptyState);
1001
+ results.push("\u2705 \u672C\u5730\u72B6\u6001\u8868\u5DF2\u521D\u59CB\u5316");
1002
+ }
970
1003
  let activated = false;
971
1004
  if (input.licenseKey) {
972
1005
  try {
@@ -978,11 +1011,13 @@ async function workflowInit(input) {
978
1011
  });
979
1012
  const data = await res.json();
980
1013
  if (data.userId) {
981
- await writeFile7(
982
- join8(cwd, ".claudeink", "credentials.json"),
983
- JSON.stringify(data, null, 2),
984
- { mode: 384 }
985
- );
1014
+ await saveCredentials({
1015
+ licenseKey: input.licenseKey,
1016
+ token: data.token,
1017
+ userId: data.userId,
1018
+ plan: data.plan,
1019
+ expiresAt: data.expiresAt
1020
+ });
986
1021
  results.push(`\u2705 License \u6FC0\u6D3B\u6210\u529F\uFF08\u5957\u9910: ${data.plan}\uFF09`);
987
1022
  activated = true;
988
1023
  } else {
@@ -1038,7 +1073,7 @@ async function workflowInit(input) {
1038
1073
  // src/index.ts
1039
1074
  var server = new McpServer({
1040
1075
  name: "ClaudeInk",
1041
- version: "0.6.0"
1076
+ version: "0.6.2"
1042
1077
  });
1043
1078
  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) => {
1044
1079
  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.0",
3
+ "version": "0.6.2",
4
4
  "description": "ClaudeInk MCP Server - 自媒体多平台写作系统的本地 MCP 服务,连接 Claude 与云端后台",
5
5
  "mcpName": "io.github.weekdmond/claudeink",
6
6
  "type": "module",