@kioku-memory/cli 0.6.1 → 0.6.2-edge.20261127111942.gcfb34f8
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/NOTICE +4 -0
- package/README.md +14 -6
- package/assets/plugins/zcode/.mcp.json +11 -0
- package/assets/plugins/zcode/.zcode-plugin/plugin.json +12 -0
- package/assets/plugins/zcode/README.md +48 -0
- package/assets/plugins/zcode/bin/kioku +36 -0
- package/assets/plugins/zcode/hooks/forward.mjs +350 -0
- package/assets/plugins/zcode/hooks/hooks.json +44 -0
- package/assets/plugins/zcode/hooks/mcp-stdio.mjs +261 -0
- package/assets/plugins/zcode/lib/command.mjs +158 -0
- package/assets/plugins/zcode/lib/config.mjs +44 -0
- package/assets/plugins/zcode/lib/http.mjs +102 -0
- package/assets/plugins/zcode/lib/kioku.mjs +58 -0
- package/assets/plugins/zcode/lib/lifecycle.mjs +163 -0
- package/assets/plugins/zcode/lib/mcp.mjs +171 -0
- package/assets/plugins/zcode/lib/profile.mjs +100 -0
- package/assets/plugins/zcode/lib/redact.mjs +91 -0
- package/assets/plugins/zcode/lib/run.mjs +406 -0
- package/assets/plugins/zcode/lib/text.mjs +14 -0
- package/assets/plugins/zcode/lib/usage.mjs +2 -0
- package/assets/plugins/zcode/marketplace.json +19 -0
- package/assets/plugins/zcode/package.json +7 -0
- package/assets/plugins/zcode/vitest.config.mjs +5 -0
- package/dist/index.mjs +379 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1223,6 +1223,120 @@ async function statusAgy({ env, cwd }) {
|
|
|
1223
1223
|
memory: "none"
|
|
1224
1224
|
};
|
|
1225
1225
|
}
|
|
1226
|
+
// src/zcode.ts
|
|
1227
|
+
function zcodeHome(env) {
|
|
1228
|
+
if (env.ZCODE_HOME) return env.ZCODE_HOME;
|
|
1229
|
+
if (env.ZCODE_DATA_BASE_DIR) return env.ZCODE_DATA_BASE_DIR;
|
|
1230
|
+
return join(env.HOME || env.USERPROFILE || homedir(), ".zcode");
|
|
1231
|
+
}
|
|
1232
|
+
function zcodeConfigFile(env) {
|
|
1233
|
+
return join(zcodeHome(env), "cli", "config.json");
|
|
1234
|
+
}
|
|
1235
|
+
function bundledZcodeDir() {
|
|
1236
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
1237
|
+
const packaged = resolve(here, "..", "assets", "plugins", "zcode");
|
|
1238
|
+
if (existsSync(packaged)) return packaged;
|
|
1239
|
+
return resolve(here, "..", "..", "..", "plugins", "zcode");
|
|
1240
|
+
}
|
|
1241
|
+
function enabledMapsOf(settings) {
|
|
1242
|
+
const maps = [];
|
|
1243
|
+
const nested = (settings?.plugins)?.enabledPlugins;
|
|
1244
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) maps.push(nested);
|
|
1245
|
+
const top = settings?.enabledPlugins;
|
|
1246
|
+
if (top && typeof top === "object" && !Array.isArray(top)) maps.push(top);
|
|
1247
|
+
return maps;
|
|
1248
|
+
}
|
|
1249
|
+
function hasEnabledInstalledEntry(installed) {
|
|
1250
|
+
if (!installed || typeof installed !== "object") return false;
|
|
1251
|
+
const container = installed.plugins && typeof installed.plugins === "object" && !Array.isArray(installed.plugins) ? installed.plugins : installed;
|
|
1252
|
+
return Object.entries(container).some(([id, value]) => {
|
|
1253
|
+
if (!id.toLowerCase().startsWith("kioku@")) return false;
|
|
1254
|
+
return (Array.isArray(value) ? value : [value]).some((item) => {
|
|
1255
|
+
if (!item || typeof item !== "object") return true;
|
|
1256
|
+
return item.enabled !== false;
|
|
1257
|
+
});
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
async function zcodePluginActive(env) {
|
|
1261
|
+
const { settings } = await readSettings(zcodeConfigFile(env)).catch(() => ({ settings: void 0 }));
|
|
1262
|
+
const maps = enabledMapsOf(settings);
|
|
1263
|
+
if (maps.length) {
|
|
1264
|
+
const entries = maps.flatMap((map) => Object.entries(map).filter(([id]) => id.toLowerCase().startsWith("kioku@")));
|
|
1265
|
+
if (entries.length) return entries.some(([, on]) => on === true);
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
const { settings: installed } = await readSettings(join(zcodeHome(env), "cli", "plugins", "installed_plugins.json")).catch(() => ({ settings: void 0 }));
|
|
1269
|
+
return hasEnabledInstalledEntry(installed);
|
|
1270
|
+
}
|
|
1271
|
+
async function removeManagedZcodeBundleIfUnused(env) {
|
|
1272
|
+
if (await zcodePluginActive(env)) return false;
|
|
1273
|
+
const targetDir = join(profileDir(env), "plugins", "zcode");
|
|
1274
|
+
try {
|
|
1275
|
+
const raw = await readFile(join(targetDir, ".kioku-managed.json"), "utf8");
|
|
1276
|
+
if (JSON.parse(raw)?.managedBy !== "@kioku-memory/cli") return false;
|
|
1277
|
+
} catch {
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1280
|
+
await rm(targetDir, {
|
|
1281
|
+
recursive: true,
|
|
1282
|
+
force: true
|
|
1283
|
+
});
|
|
1284
|
+
return true;
|
|
1285
|
+
}
|
|
1286
|
+
function zcodeInstallHint(env) {
|
|
1287
|
+
const persistent = join(profileDir(env), "plugins", "zcode");
|
|
1288
|
+
if (existsSync(join(persistent, "marketplace.json"))) return `运行 kioku connect zcode 自动启用,或手动运行:\n zcode plugins marketplace add ${plain(/\s/.test(persistent) ? `"${persistent}"` : persistent)}\n zcode plugins install kioku@kioku\n zcode plugins enable kioku@kioku`;
|
|
1289
|
+
return "运行 kioku connect zcode 自动安装并启用插件(或克隆 lonelyman0108/kioku-plugins 后对 plugins/zcode 执行 zcode plugins marketplace add / install / enable)";
|
|
1290
|
+
}
|
|
1291
|
+
async function setupZcode(options, io) {
|
|
1292
|
+
const { env, out } = io;
|
|
1293
|
+
const profile = profileFile("zcode", env);
|
|
1294
|
+
if (options.undo) {
|
|
1295
|
+
if (options.dryRun) {
|
|
1296
|
+
out.write(`${profile}:删掉\n没有写入(--dry-run)\n`);
|
|
1297
|
+
return 0;
|
|
1298
|
+
}
|
|
1299
|
+
if (await removeProfile("zcode", env)) out.write(`已删掉 ${profile}\n`);
|
|
1300
|
+
else out.write(`${profile} 本来就没有\n`);
|
|
1301
|
+
await rm(join(profileDir(env), "zcode-state"), {
|
|
1302
|
+
recursive: true,
|
|
1303
|
+
force: true
|
|
1304
|
+
}).catch(() => {});
|
|
1305
|
+
if (await zcodePluginActive(env)) out.write("插件要另外卸载:zcode plugins uninstall kioku@kioku && zcode plugins marketplace remove kioku\n");
|
|
1306
|
+
else if (await removeManagedZcodeBundleIfUnused(env)) out.write(`已清理托管的 ZCode 插件缓存目录 ${join(profileDir(env), "plugins", "zcode")}\n`);
|
|
1307
|
+
return 0;
|
|
1308
|
+
}
|
|
1309
|
+
const { url, key, saved } = await resolveTarget({
|
|
1310
|
+
id: "zcode",
|
|
1311
|
+
name: "ZCode"
|
|
1312
|
+
}, options, io);
|
|
1313
|
+
const same = Boolean(saved && saved.url === url && saved.key === key);
|
|
1314
|
+
if (same) out.write(`${profile} 不用改\n`);
|
|
1315
|
+
else out.write(`${profile}:写入服务地址与访问密钥(只给本人读写)\n`);
|
|
1316
|
+
if (options.dryRun) {
|
|
1317
|
+
out.write("没有写入(--dry-run)\n");
|
|
1318
|
+
return 0;
|
|
1319
|
+
}
|
|
1320
|
+
if (!same) await writeProfile("zcode", {
|
|
1321
|
+
url,
|
|
1322
|
+
key
|
|
1323
|
+
}, env);
|
|
1324
|
+
out.write("ZCode 已配好,重启 ZCode 或新开会话生效。\n");
|
|
1325
|
+
if (!await zcodePluginActive(env) && io.hints !== false) out.write(`接下来安装并启用插件:${zcodeInstallHint(env)}\n`);
|
|
1326
|
+
return 0;
|
|
1327
|
+
}
|
|
1328
|
+
async function inspectZcode({ env }, { ok, warn, note }) {
|
|
1329
|
+
if (!await readProfile("zcode", env).catch(() => null)) warn("没有 kioku setup zcode 写下的地址与访问密钥,插件不会生效:运行 kioku setup zcode");
|
|
1330
|
+
if (await zcodePluginActive(env)) ok("ZCode 的 kioku 插件已启用");
|
|
1331
|
+
else warn(`ZCode 的 kioku 插件未启用:${zcodeInstallHint(env)}`);
|
|
1332
|
+
note("如在 ZCode 设置里开启了自带工作区记忆,建议关闭以避免与 Kioku 重复记录");
|
|
1333
|
+
}
|
|
1334
|
+
async function statusZcode({ env }) {
|
|
1335
|
+
return {
|
|
1336
|
+
plugin: await zcodePluginActive(env),
|
|
1337
|
+
memory: "none"
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1226
1340
|
// src/codex.ts
|
|
1227
1341
|
const SERVER = "mcp_servers.kioku";
|
|
1228
1342
|
const MARKETPLACE$1 = "lonelyman0108/kioku-plugins";
|
|
@@ -2590,6 +2704,26 @@ const PLATFORMS = {
|
|
|
2590
2704
|
preflight: preflightAgy,
|
|
2591
2705
|
setup: setupAgy,
|
|
2592
2706
|
inspect: inspectAgy
|
|
2707
|
+
},
|
|
2708
|
+
zcode: {
|
|
2709
|
+
name: "ZCode",
|
|
2710
|
+
runtimeFamily: "zcode",
|
|
2711
|
+
command: () => "zcode",
|
|
2712
|
+
home: zcodeHome,
|
|
2713
|
+
status: statusZcode,
|
|
2714
|
+
install: {
|
|
2715
|
+
commands: [
|
|
2716
|
+
"git clone https://github.com/lonelyman0108/kioku-plugins",
|
|
2717
|
+
"zcode plugins marketplace add ./kioku-plugins/plugins/zcode",
|
|
2718
|
+
"zcode plugins install kioku@kioku",
|
|
2719
|
+
"zcode plugins enable kioku@kioku"
|
|
2720
|
+
],
|
|
2721
|
+
after: "重启 ZCode 或新开会话生效(MCP 桥接已随插件内置,地址与访问密钥保存在本机配置)"
|
|
2722
|
+
},
|
|
2723
|
+
detect: (env) => Boolean(env.ZCODE_SESSION_ID || env.ZCODE_PLUGIN_ROOT),
|
|
2724
|
+
readConfig: (env) => readProfile("zcode", env),
|
|
2725
|
+
setup: setupZcode,
|
|
2726
|
+
inspect: inspectZcode
|
|
2593
2727
|
}
|
|
2594
2728
|
};
|
|
2595
2729
|
function platformNames() {
|
|
@@ -5651,7 +5785,8 @@ const UNSUPPORTED_SOURCES = {
|
|
|
5651
5785
|
dsh: "DeepSeek Harness 没有自带的长期记忆",
|
|
5652
5786
|
opencode: "OpenCode 没有自带的长期记忆文件",
|
|
5653
5787
|
gemini: "Gemini CLI 没有自带的独立长期记忆目录",
|
|
5654
|
-
agy: "Antigravity 没有自带的长期记忆文件"
|
|
5788
|
+
agy: "Antigravity 没有自带的长期记忆文件",
|
|
5789
|
+
zcode: "ZCode 没有自带的可迁移长期记忆文件"
|
|
5655
5790
|
};
|
|
5656
5791
|
function sourceNames() {
|
|
5657
5792
|
return Object.keys(SOURCES).join("、");
|
|
@@ -6176,7 +6311,7 @@ async function scanJsonMcp(items, { platform, file, containerKey = "mcpServers",
|
|
|
6176
6311
|
delete nextContainer[name];
|
|
6177
6312
|
if (Object.keys(nextContainer).length) next[containerKey] = nextContainer;
|
|
6178
6313
|
else delete next[containerKey];
|
|
6179
|
-
await safeWrite(file, serialize(next, latest.text), latest.text, { backup: backupAllowed(file, hasJsonSecret(latest.settings), noBackupFiles) });
|
|
6314
|
+
await safeWrite(file, serialize(next, latest.text), latest.text, { backup: backupAllowed(file, hasJsonSecret(latest.settings) || hasInlineSecret(latest.text), noBackupFiles) });
|
|
6180
6315
|
return {
|
|
6181
6316
|
changed: true,
|
|
6182
6317
|
message: `已从 ${plain(file)} 移除 ${containerKey}.${name}`
|
|
@@ -7157,6 +7292,151 @@ async function scanHermesConflicts(items, { env }) {
|
|
|
7157
7292
|
});
|
|
7158
7293
|
}
|
|
7159
7294
|
}
|
|
7295
|
+
const ZCODE_CONFLICT_PLUGINS = [{
|
|
7296
|
+
prefix: "lore@",
|
|
7297
|
+
tool: "lore",
|
|
7298
|
+
toolName: "Lore",
|
|
7299
|
+
marketplace: "lore"
|
|
7300
|
+
}, {
|
|
7301
|
+
prefix: "claude-mem@",
|
|
7302
|
+
tool: "claude-mem",
|
|
7303
|
+
toolName: "Claude-Mem",
|
|
7304
|
+
marketplace: null
|
|
7305
|
+
}];
|
|
7306
|
+
function resolveZcodeBin(env) {
|
|
7307
|
+
if (hasCommand("zcode", env)) return "zcode";
|
|
7308
|
+
const localBin = join(env.HOME || env.USERPROFILE || homedir(), ".local", "bin", "zcode");
|
|
7309
|
+
return hasCommand(localBin, env) ? localBin : null;
|
|
7310
|
+
}
|
|
7311
|
+
function shouldRemoveZcodeMarketplace(pluginId, marketplace) {
|
|
7312
|
+
if (!marketplace) return false;
|
|
7313
|
+
const at = pluginId.lastIndexOf("@");
|
|
7314
|
+
if (at < 0) return false;
|
|
7315
|
+
return pluginId.slice(at + 1).toLowerCase() === marketplace.toLowerCase();
|
|
7316
|
+
}
|
|
7317
|
+
async function scanZcodeConflicts(items, { env }) {
|
|
7318
|
+
const cfgFile = zcodeConfigFile(env);
|
|
7319
|
+
await scanJsonMcp(items, {
|
|
7320
|
+
platform: "zcode",
|
|
7321
|
+
file: cfgFile,
|
|
7322
|
+
containerKey: "mcpServers"
|
|
7323
|
+
});
|
|
7324
|
+
const seenPluginIds = /* @__PURE__ */ new Set();
|
|
7325
|
+
const res = await readJsonSafe(cfgFile);
|
|
7326
|
+
const nestedEnabled = res.ok && res.text !== null ? (res.settings?.plugins)?.enabledPlugins : void 0;
|
|
7327
|
+
const topEnabled = res.ok && res.text !== null ? res.settings?.enabledPlugins : void 0;
|
|
7328
|
+
const enabledMaps = [];
|
|
7329
|
+
if (nestedEnabled && typeof nestedEnabled === "object" && !Array.isArray(nestedEnabled)) enabledMaps.push(nestedEnabled);
|
|
7330
|
+
if (topEnabled && typeof topEnabled === "object" && !Array.isArray(topEnabled)) enabledMaps.push(topEnabled);
|
|
7331
|
+
for (const map of enabledMaps) for (const [pluginId, on] of Object.entries(map)) {
|
|
7332
|
+
const normalizedId = pluginId.toLowerCase();
|
|
7333
|
+
if (on !== true || seenPluginIds.has(normalizedId)) continue;
|
|
7334
|
+
const match = ZCODE_CONFLICT_PLUGINS.find((p) => normalizedId.startsWith(p.prefix));
|
|
7335
|
+
if (!match) continue;
|
|
7336
|
+
seenPluginIds.add(normalizedId);
|
|
7337
|
+
items.push({
|
|
7338
|
+
id: `zcode:${match.tool}:plugin:${pluginId}`,
|
|
7339
|
+
platform: "zcode",
|
|
7340
|
+
tool: match.tool,
|
|
7341
|
+
toolName: match.toolName,
|
|
7342
|
+
kind: "plugin",
|
|
7343
|
+
summary: `插件 ${plain(pluginId)}(${plain(cfgFile)})`,
|
|
7344
|
+
removable: true,
|
|
7345
|
+
remove: async ({ noBackupFiles } = {
|
|
7346
|
+
env: process.env,
|
|
7347
|
+
cwd: process.cwd(),
|
|
7348
|
+
noBackupFiles: /* @__PURE__ */ new Set()
|
|
7349
|
+
}) => {
|
|
7350
|
+
const zcodeBin = resolveZcodeBin(env);
|
|
7351
|
+
if (zcodeBin) {
|
|
7352
|
+
await capture(zcodeBin, [
|
|
7353
|
+
"plugins",
|
|
7354
|
+
"uninstall",
|
|
7355
|
+
pluginId
|
|
7356
|
+
], env, { timeout: 2e4 });
|
|
7357
|
+
if (shouldRemoveZcodeMarketplace(pluginId, match.marketplace)) await capture(zcodeBin, [
|
|
7358
|
+
"plugins",
|
|
7359
|
+
"marketplace",
|
|
7360
|
+
"remove",
|
|
7361
|
+
match.marketplace
|
|
7362
|
+
], env, { timeout: 2e4 });
|
|
7363
|
+
}
|
|
7364
|
+
const latest = await readSettings(cfgFile);
|
|
7365
|
+
const next = { ...latest.settings };
|
|
7366
|
+
let changed = false;
|
|
7367
|
+
const stripMatching = (obj) => {
|
|
7368
|
+
const copy = { ...obj };
|
|
7369
|
+
for (const key of Object.keys(copy)) if (key.toLowerCase() === normalizedId) {
|
|
7370
|
+
delete copy[key];
|
|
7371
|
+
changed = true;
|
|
7372
|
+
}
|
|
7373
|
+
return copy;
|
|
7374
|
+
};
|
|
7375
|
+
if (next.plugins && typeof next.plugins === "object" && !Array.isArray(next.plugins)) {
|
|
7376
|
+
const pluginsObj = { ...next.plugins };
|
|
7377
|
+
const cur = pluginsObj.enabledPlugins;
|
|
7378
|
+
if (cur && typeof cur === "object" && !Array.isArray(cur)) {
|
|
7379
|
+
const nextEnabled = stripMatching(cur);
|
|
7380
|
+
if (Object.keys(nextEnabled).length) pluginsObj.enabledPlugins = nextEnabled;
|
|
7381
|
+
else delete pluginsObj.enabledPlugins;
|
|
7382
|
+
if (Object.keys(pluginsObj).length) next.plugins = pluginsObj;
|
|
7383
|
+
else delete next.plugins;
|
|
7384
|
+
}
|
|
7385
|
+
}
|
|
7386
|
+
if (next.enabledPlugins && typeof next.enabledPlugins === "object" && !Array.isArray(next.enabledPlugins)) {
|
|
7387
|
+
const nextEnabled = stripMatching(next.enabledPlugins);
|
|
7388
|
+
if (Object.keys(nextEnabled).length) next.enabledPlugins = nextEnabled;
|
|
7389
|
+
else delete next.enabledPlugins;
|
|
7390
|
+
}
|
|
7391
|
+
if (changed) await safeWrite(cfgFile, serialize(next, latest.text), latest.text, { backup: backupAllowed(cfgFile, hasJsonSecret(latest.settings) || hasInlineSecret(latest.text), noBackupFiles) });
|
|
7392
|
+
return {
|
|
7393
|
+
changed: true,
|
|
7394
|
+
message: `已卸载 ZCode 插件 ${plain(pluginId)}`
|
|
7395
|
+
};
|
|
7396
|
+
}
|
|
7397
|
+
});
|
|
7398
|
+
}
|
|
7399
|
+
const installedFile = join(zcodeHome(env), "cli", "plugins", "installed_plugins.json");
|
|
7400
|
+
const installedRes = await readJsonSafe(installedFile);
|
|
7401
|
+
if (installedRes.ok && installedRes.text !== null) {
|
|
7402
|
+
const rawPlugins = installedRes.settings?.plugins && typeof installedRes.settings.plugins === "object" && !Array.isArray(installedRes.settings.plugins) ? installedRes.settings.plugins : installedRes.settings;
|
|
7403
|
+
for (const pluginId of Object.keys(rawPlugins ?? {})) {
|
|
7404
|
+
const normalizedId = pluginId.toLowerCase();
|
|
7405
|
+
if (seenPluginIds.has(normalizedId)) continue;
|
|
7406
|
+
const match = ZCODE_CONFLICT_PLUGINS.find((p) => normalizedId.startsWith(p.prefix));
|
|
7407
|
+
if (!match) continue;
|
|
7408
|
+
seenPluginIds.add(normalizedId);
|
|
7409
|
+
const zcodeBin = resolveZcodeBin(env);
|
|
7410
|
+
const hasZcode = zcodeBin !== null;
|
|
7411
|
+
items.push({
|
|
7412
|
+
id: `zcode:${match.tool}:installed:${pluginId}`,
|
|
7413
|
+
platform: "zcode",
|
|
7414
|
+
tool: match.tool,
|
|
7415
|
+
toolName: match.toolName,
|
|
7416
|
+
kind: hasZcode ? "plugin" : "warning",
|
|
7417
|
+
summary: `已安装插件 ${plain(pluginId)}(${plain(installedFile)})`,
|
|
7418
|
+
removable: hasZcode,
|
|
7419
|
+
...hasZcode ? { remove: async () => {
|
|
7420
|
+
if (!(await capture(zcodeBin, [
|
|
7421
|
+
"plugins",
|
|
7422
|
+
"uninstall",
|
|
7423
|
+
pluginId
|
|
7424
|
+
], env, { timeout: 2e4 })).ok) throw new KiokuFailure(`卸载 ZCode 插件 ${plain(pluginId)} 没有成功`);
|
|
7425
|
+
if (shouldRemoveZcodeMarketplace(pluginId, match.marketplace)) await capture(zcodeBin, [
|
|
7426
|
+
"plugins",
|
|
7427
|
+
"marketplace",
|
|
7428
|
+
"remove",
|
|
7429
|
+
match.marketplace
|
|
7430
|
+
], env, { timeout: 2e4 });
|
|
7431
|
+
return {
|
|
7432
|
+
changed: true,
|
|
7433
|
+
message: `已卸载 ZCode 插件 ${plain(pluginId)}`
|
|
7434
|
+
};
|
|
7435
|
+
} } : { hint: `缺少 zcode 命令,手动运行 zcode plugins uninstall ${plain(pluginId)}` }
|
|
7436
|
+
});
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
}
|
|
7160
7440
|
const SCANNERS = {
|
|
7161
7441
|
agy: scanAgyConflicts,
|
|
7162
7442
|
gemini: scanGeminiConflicts,
|
|
@@ -7166,7 +7446,8 @@ const SCANNERS = {
|
|
|
7166
7446
|
openclaw: scanOpenclawConflicts,
|
|
7167
7447
|
pi: scanPiConflicts,
|
|
7168
7448
|
dsh: scanDshConflicts,
|
|
7169
|
-
hermes: scanHermesConflicts
|
|
7449
|
+
hermes: scanHermesConflicts,
|
|
7450
|
+
zcode: scanZcodeConflicts
|
|
7170
7451
|
};
|
|
7171
7452
|
async function scanConflicts(platformId, { env = process.env, cwd = process.cwd() } = {}) {
|
|
7172
7453
|
const fn = SCANNERS[platformId];
|
|
@@ -8069,6 +8350,12 @@ async function detectLegacyPlugin(id, { env, cwd = process.cwd() }) {
|
|
|
8069
8350
|
if (bridge !== null && !bridge.includes("deviceKey")) outdatedPlugin = "重构前的 Hermes 记忆插件";
|
|
8070
8351
|
} else if (id === "openclaw") {
|
|
8071
8352
|
if (await isLegacyNpmPluginDir(join(env.OPENCLAW_HOME || homedir(), ".openclaw", "extensions", "kioku"))) outdatedPlugin = "旧版本 OpenClaw 插件";
|
|
8353
|
+
} else if (id === "zcode") {
|
|
8354
|
+
if (await zcodePluginActive(env)) {
|
|
8355
|
+
const targetDir = join(profileDir(env), "plugins", "zcode");
|
|
8356
|
+
const marker = await readJsonOrNull(join(targetDir, ".kioku-managed.json"));
|
|
8357
|
+
if (marker?.managedBy === "@kioku-memory/cli" && typeof marker.version === "string" && compareSemver(marker.version, CLI_VERSION$1) < 0) outdatedPlugin = `旧版本 ZCode 插件(${plain(marker.version)})`;
|
|
8358
|
+
}
|
|
8072
8359
|
}
|
|
8073
8360
|
const cache = await hasLegacyToolsInCache(id, env);
|
|
8074
8361
|
if (id === "openclaw" && cache.legacy) outdatedPlugin = "包含旧版工具清单的 OpenClaw 插件缓存";
|
|
@@ -8696,6 +8983,17 @@ async function persistentGeminiDir(env) {
|
|
|
8696
8983
|
});
|
|
8697
8984
|
return targetDir;
|
|
8698
8985
|
}
|
|
8986
|
+
async function persistentZcodeDir(env) {
|
|
8987
|
+
const targetDir = join(profileDir(env), "plugins", "zcode");
|
|
8988
|
+
await copyManagedBundle({
|
|
8989
|
+
srcDir: bundledZcodeDir(),
|
|
8990
|
+
targetDir,
|
|
8991
|
+
label: " ZCode 插件",
|
|
8992
|
+
id: "zcode",
|
|
8993
|
+
upgrade: true
|
|
8994
|
+
});
|
|
8995
|
+
return targetDir;
|
|
8996
|
+
}
|
|
8699
8997
|
async function removeManagedAgyPlugin({ env }) {
|
|
8700
8998
|
const targetDir = join(agyHome(env), "plugins", "kioku");
|
|
8701
8999
|
if (!await readManagedMarker(targetDir)) return false;
|
|
@@ -8940,6 +9238,83 @@ async function installPlugin(id, { env, cwd = process.cwd(), upgrade = false })
|
|
|
8940
9238
|
after: platform.install.after
|
|
8941
9239
|
};
|
|
8942
9240
|
}
|
|
9241
|
+
if (id === "zcode") {
|
|
9242
|
+
const bin = resolvePlatformCommand(id, env) ?? platform.command(env);
|
|
9243
|
+
const targetDir = await persistentZcodeDir(env);
|
|
9244
|
+
const safeTarget = plain(targetDir);
|
|
9245
|
+
const manualCommands = [
|
|
9246
|
+
`zcode plugins marketplace add ${/\s/.test(safeTarget) ? `"${safeTarget}"` : safeTarget}`,
|
|
9247
|
+
"zcode plugins install kioku@kioku",
|
|
9248
|
+
"zcode plugins enable kioku@kioku"
|
|
9249
|
+
];
|
|
9250
|
+
if (!hasCommand(bin, env)) return {
|
|
9251
|
+
id,
|
|
9252
|
+
status: "manual",
|
|
9253
|
+
message: "未找到 zcode 命令,手动运行",
|
|
9254
|
+
commands: manualCommands,
|
|
9255
|
+
after: platform.install.after
|
|
9256
|
+
};
|
|
9257
|
+
await capture(bin, [
|
|
9258
|
+
"plugins",
|
|
9259
|
+
"marketplace",
|
|
9260
|
+
"remove",
|
|
9261
|
+
"kioku"
|
|
9262
|
+
], env, { timeout: 3e4 });
|
|
9263
|
+
if (!(await capture(bin, [
|
|
9264
|
+
"plugins",
|
|
9265
|
+
"marketplace",
|
|
9266
|
+
"add",
|
|
9267
|
+
targetDir
|
|
9268
|
+
], env, { timeout: 6e4 })).ok) return {
|
|
9269
|
+
id,
|
|
9270
|
+
status: "manual",
|
|
9271
|
+
message: "未能自动注册 ZCode 插件市场,手动运行",
|
|
9272
|
+
commands: manualCommands,
|
|
9273
|
+
after: platform.install.after
|
|
9274
|
+
};
|
|
9275
|
+
const listed = await capture(bin, ["plugins", "list"], env, { timeout: 3e4 });
|
|
9276
|
+
const alreadyListed = listed.ok && /\bkioku@kioku\b/.test(stripAnsi(listed.stdout));
|
|
9277
|
+
let installedOk = true;
|
|
9278
|
+
if (alreadyListed) {
|
|
9279
|
+
if (!(await capture(bin, [
|
|
9280
|
+
"plugins",
|
|
9281
|
+
"update",
|
|
9282
|
+
"kioku@kioku"
|
|
9283
|
+
], env, { timeout: 6e4 })).ok) {
|
|
9284
|
+
await capture(bin, [
|
|
9285
|
+
"plugins",
|
|
9286
|
+
"uninstall",
|
|
9287
|
+
"kioku@kioku"
|
|
9288
|
+
], env, { timeout: 3e4 });
|
|
9289
|
+
installedOk = (await capture(bin, [
|
|
9290
|
+
"plugins",
|
|
9291
|
+
"install",
|
|
9292
|
+
"kioku@kioku"
|
|
9293
|
+
], env, { timeout: 6e4 })).ok;
|
|
9294
|
+
}
|
|
9295
|
+
} else installedOk = (await capture(bin, [
|
|
9296
|
+
"plugins",
|
|
9297
|
+
"install",
|
|
9298
|
+
"kioku@kioku"
|
|
9299
|
+
], env, { timeout: 6e4 })).ok;
|
|
9300
|
+
const enabled = installedOk ? await capture(bin, [
|
|
9301
|
+
"plugins",
|
|
9302
|
+
"enable",
|
|
9303
|
+
"kioku@kioku"
|
|
9304
|
+
], env, { timeout: 3e4 }) : { ok: false };
|
|
9305
|
+
if (installedOk && enabled.ok) return {
|
|
9306
|
+
id,
|
|
9307
|
+
status: upgrade ? "upgraded" : "installed",
|
|
9308
|
+
message: `${upgrade ? "已更新并启用" : "已安装并启用"} ZCode 插件(${plain(targetDir)})`
|
|
9309
|
+
};
|
|
9310
|
+
return {
|
|
9311
|
+
id,
|
|
9312
|
+
status: "manual",
|
|
9313
|
+
message: "未能自动安装或启用 ZCode 插件,手动运行",
|
|
9314
|
+
commands: manualCommands,
|
|
9315
|
+
after: platform.install.after
|
|
9316
|
+
};
|
|
9317
|
+
}
|
|
8943
9318
|
return {
|
|
8944
9319
|
id,
|
|
8945
9320
|
status: "manual",
|
|
@@ -9578,7 +9953,7 @@ async function disconnectCommand(argv, { env = process.env, out = process.stdout
|
|
|
9578
9953
|
}
|
|
9579
9954
|
const UPGRADE_USAGE = `用法:kioku upgrade [平台…]
|
|
9580
9955
|
|
|
9581
|
-
更新已接入平台的 Kioku 插件(如同步内置 Antigravity / Gemini 插件、调用客户端插件更新命令),
|
|
9956
|
+
更新已接入平台的 Kioku 插件(如同步内置 Antigravity / Gemini / ZCode 插件、调用客户端插件更新命令),
|
|
9582
9957
|
并刷新本机 MCP 工具清单缓存。
|
|
9583
9958
|
|
|
9584
9959
|
[平台…] ${platformNames()};不写时检查并更新所有已接入或已安装插件的平台
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kioku-memory/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2-edge.20261127111942.gcfb34f8",
|
|
4
4
|
"description": "Kioku 的命令行:接入各平台的向导、把凭据交给命令(kioku run)、停用各平台自带的长期记忆(kioku setup)、检查配置(kioku doctor)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/lonelyman0108/kioku-plugins/tree/main/packages/cli",
|