mioku 0.9.0 → 0.9.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.
- package/dist/cli.cjs +2 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +58 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import * as fs$2 from "node:fs";
|
|
3
|
+
import * as path$3 from "node:path";
|
|
4
|
+
import * as fs$6 from "fs/promises";
|
|
5
|
+
import * as fs$5 from "fs/promises";
|
|
2
6
|
import * as fs$4 from "fs/promises";
|
|
3
7
|
import * as fs$3 from "fs/promises";
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
8
|
+
import * as path$7 from "path";
|
|
9
|
+
import * as path$6 from "path";
|
|
6
10
|
import * as path$5 from "path";
|
|
7
11
|
import * as path$4 from "path";
|
|
8
|
-
import * as path$3 from "path";
|
|
9
12
|
import * as path$2 from "path";
|
|
10
13
|
import * as path$1 from "path";
|
|
11
|
-
import * as
|
|
12
|
-
import * as fs from "fs";
|
|
14
|
+
import * as fs$1 from "fs";
|
|
13
15
|
import { existsSync, mkdirSync } from "fs";
|
|
14
16
|
|
|
15
17
|
//#region rolldown:runtime
|
|
@@ -41,7 +43,7 @@ const logger = {
|
|
|
41
43
|
const DEFAULT_RUNTIME_PLUGINS_DIR = ".mioku/plugins";
|
|
42
44
|
async function pathExists$3(filePath) {
|
|
43
45
|
try {
|
|
44
|
-
await fs$
|
|
46
|
+
await fs$6.access(filePath);
|
|
45
47
|
return true;
|
|
46
48
|
} catch {
|
|
47
49
|
return false;
|
|
@@ -50,41 +52,41 @@ async function pathExists$3(filePath) {
|
|
|
50
52
|
async function removeIfBrokenSymlink(entryPath) {
|
|
51
53
|
let stat;
|
|
52
54
|
try {
|
|
53
|
-
stat = await fs$
|
|
55
|
+
stat = await fs$6.lstat(entryPath);
|
|
54
56
|
} catch {
|
|
55
57
|
return "removed";
|
|
56
58
|
}
|
|
57
59
|
if (!stat.isSymbolicLink()) return "blocked";
|
|
58
60
|
try {
|
|
59
|
-
await fs$
|
|
61
|
+
await fs$6.realpath(entryPath);
|
|
60
62
|
return "ok";
|
|
61
63
|
} catch {
|
|
62
|
-
await fs$
|
|
64
|
+
await fs$6.rm(entryPath, { force: true });
|
|
63
65
|
logger.warn(`[plugin-linker] Removed broken plugin link: ${entryPath}`);
|
|
64
66
|
return "removed";
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
function relativeSymlinkTarget(linkPath, targetPath) {
|
|
68
|
-
const relativePath = path$
|
|
70
|
+
const relativePath = path$7.relative(path$7.dirname(linkPath), targetPath);
|
|
69
71
|
return relativePath || ".";
|
|
70
72
|
}
|
|
71
73
|
async function ensurePluginLink(runtimePluginsDir, metadata) {
|
|
72
|
-
const linkPath = path$
|
|
74
|
+
const linkPath = path$7.join(runtimePluginsDir, metadata.name);
|
|
73
75
|
const targetPath = metadata.path;
|
|
74
76
|
let stat;
|
|
75
77
|
try {
|
|
76
|
-
stat = await fs$
|
|
78
|
+
stat = await fs$6.lstat(linkPath);
|
|
77
79
|
} catch {
|
|
78
80
|
stat = null;
|
|
79
81
|
}
|
|
80
82
|
if (stat?.isSymbolicLink()) try {
|
|
81
|
-
const currentTarget = await fs$
|
|
82
|
-
const expectedTarget = await fs$
|
|
83
|
+
const currentTarget = await fs$6.realpath(linkPath);
|
|
84
|
+
const expectedTarget = await fs$6.realpath(targetPath);
|
|
83
85
|
if (currentTarget === expectedTarget) return true;
|
|
84
|
-
await fs$
|
|
86
|
+
await fs$6.rm(linkPath, { force: true });
|
|
85
87
|
logger.info(`[plugin-linker] Rebuilding plugin link: ${metadata.name}`);
|
|
86
88
|
} catch {
|
|
87
|
-
await fs$
|
|
89
|
+
await fs$6.rm(linkPath, { force: true });
|
|
88
90
|
logger.warn(`[plugin-linker] Removed broken plugin link: ${linkPath}`);
|
|
89
91
|
}
|
|
90
92
|
else if (stat) {
|
|
@@ -95,20 +97,20 @@ async function ensurePluginLink(runtimePluginsDir, metadata) {
|
|
|
95
97
|
logger.warn(`[plugin-linker] Plugin target missing, skip linking ${metadata.name}: ${targetPath}`);
|
|
96
98
|
return false;
|
|
97
99
|
}
|
|
98
|
-
if (process.platform === "win32") await fs$
|
|
99
|
-
else await fs$
|
|
100
|
+
if (process.platform === "win32") await fs$6.symlink(targetPath, linkPath, "junction");
|
|
101
|
+
else await fs$6.symlink(relativeSymlinkTarget(linkPath, targetPath), linkPath, "dir");
|
|
100
102
|
return true;
|
|
101
103
|
}
|
|
102
|
-
async function prepareRuntimePluginLinks(plugins, runtimePluginsDir = path$
|
|
103
|
-
await fs$
|
|
104
|
+
async function prepareRuntimePluginLinks(plugins, runtimePluginsDir = path$7.resolve(process.cwd(), DEFAULT_RUNTIME_PLUGINS_DIR)) {
|
|
105
|
+
await fs$6.mkdir(runtimePluginsDir, { recursive: true });
|
|
104
106
|
const discoveredNames = new Set(plugins.map((plugin) => plugin.name));
|
|
105
|
-
const entries = await fs$
|
|
107
|
+
const entries = await fs$6.readdir(runtimePluginsDir, { withFileTypes: true });
|
|
106
108
|
for (const entry of entries) {
|
|
107
|
-
const entryPath = path$
|
|
109
|
+
const entryPath = path$7.join(runtimePluginsDir, entry.name);
|
|
108
110
|
const symlinkState = await removeIfBrokenSymlink(entryPath);
|
|
109
111
|
if (symlinkState !== "ok") continue;
|
|
110
112
|
if (entry.isSymbolicLink() && !discoveredNames.has(entry.name)) {
|
|
111
|
-
await fs$
|
|
113
|
+
await fs$6.rm(entryPath, { force: true });
|
|
112
114
|
logger.info(`[plugin-linker] Removed stale plugin link: ${entry.name}`);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
@@ -122,7 +124,7 @@ async function prepareRuntimePluginLinks(plugins, runtimePluginsDir = path$5.res
|
|
|
122
124
|
const PLUGIN_MANAGER_SYMBOL = Symbol.for("mioku.plugin-manager");
|
|
123
125
|
async function pathExists$2(filePath) {
|
|
124
126
|
try {
|
|
125
|
-
await fs$
|
|
127
|
+
await fs$5.access(filePath);
|
|
126
128
|
return true;
|
|
127
129
|
} catch {
|
|
128
130
|
return false;
|
|
@@ -142,7 +144,7 @@ var PluginManager = class PluginManager {
|
|
|
142
144
|
}
|
|
143
145
|
async discoverPlugins(miokuConfig = {}) {
|
|
144
146
|
const configuredPluginsDir = miokuConfig.plugins_dir;
|
|
145
|
-
const pluginsDir = configuredPluginsDir && configuredPluginsDir !== DEFAULT_RUNTIME_PLUGINS_DIR ? path$
|
|
147
|
+
const pluginsDir = configuredPluginsDir && configuredPluginsDir !== DEFAULT_RUNTIME_PLUGINS_DIR ? path$6.resolve(process.cwd(), configuredPluginsDir) : path$6.resolve(process.cwd(), "plugins");
|
|
146
148
|
this.pluginMetadata.clear();
|
|
147
149
|
if (!await pathExists$2(pluginsDir)) mkdirSync(pluginsDir, { recursive: true });
|
|
148
150
|
const discovered = [];
|
|
@@ -158,9 +160,9 @@ var PluginManager = class PluginManager {
|
|
|
158
160
|
async discoverFromDir(pluginsDir) {
|
|
159
161
|
const discovered = [];
|
|
160
162
|
try {
|
|
161
|
-
const entries = await fs$
|
|
163
|
+
const entries = await fs$5.readdir(pluginsDir, { withFileTypes: true });
|
|
162
164
|
for (const entry of entries) {
|
|
163
|
-
const pluginPath = path$
|
|
165
|
+
const pluginPath = path$6.join(pluginsDir, entry.name);
|
|
164
166
|
const metadataPath = await this.resolveDirectoryPath(pluginPath);
|
|
165
167
|
if (!metadataPath) continue;
|
|
166
168
|
const metadata = await this.loadPluginMetadata(entry.name, pluginPath);
|
|
@@ -176,14 +178,14 @@ var PluginManager = class PluginManager {
|
|
|
176
178
|
}
|
|
177
179
|
async discoverFromNodeModules() {
|
|
178
180
|
const discovered = [];
|
|
179
|
-
const nodeModulesPath = path$
|
|
181
|
+
const nodeModulesPath = path$6.resolve(process.cwd(), "node_modules");
|
|
180
182
|
if (!await pathExists$2(nodeModulesPath)) return discovered;
|
|
181
183
|
try {
|
|
182
|
-
const entries = await fs$
|
|
184
|
+
const entries = await fs$5.readdir(nodeModulesPath, { withFileTypes: true });
|
|
183
185
|
for (const entry of entries) {
|
|
184
186
|
if (!entry.name.startsWith("mioku-plugin-")) continue;
|
|
185
187
|
const pluginName = entry.name.replace(/^mioku-plugin-/, "");
|
|
186
|
-
const pluginPath = path$
|
|
188
|
+
const pluginPath = path$6.join(nodeModulesPath, entry.name);
|
|
187
189
|
const metadata = await this.loadPluginMetadata(pluginName, pluginPath);
|
|
188
190
|
if (metadata) {
|
|
189
191
|
discovered.push(metadata);
|
|
@@ -197,7 +199,7 @@ var PluginManager = class PluginManager {
|
|
|
197
199
|
}
|
|
198
200
|
async resolveDirectoryPath(entryPath) {
|
|
199
201
|
try {
|
|
200
|
-
const stat = await fs$
|
|
202
|
+
const stat = await fs$5.stat(entryPath);
|
|
201
203
|
return stat.isDirectory() ? entryPath : null;
|
|
202
204
|
} catch {
|
|
203
205
|
return null;
|
|
@@ -206,12 +208,12 @@ var PluginManager = class PluginManager {
|
|
|
206
208
|
async loadPluginMetadata(name, pluginPath) {
|
|
207
209
|
let resolvedPath = pluginPath;
|
|
208
210
|
try {
|
|
209
|
-
resolvedPath = await fs$
|
|
211
|
+
resolvedPath = await fs$5.realpath(pluginPath);
|
|
210
212
|
} catch {}
|
|
211
|
-
const packageJsonPath = path$
|
|
213
|
+
const packageJsonPath = path$6.join(resolvedPath, "package.json");
|
|
212
214
|
let packageJson = null;
|
|
213
215
|
try {
|
|
214
|
-
const content = await fs$
|
|
216
|
+
const content = await fs$5.readFile(packageJsonPath, "utf-8");
|
|
215
217
|
packageJson = JSON.parse(content);
|
|
216
218
|
} catch {}
|
|
217
219
|
const metadata = {
|
|
@@ -246,7 +248,7 @@ var plugin_manager_default = PluginManager.getInstance();
|
|
|
246
248
|
const SERVICE_MANAGER_SYMBOL = Symbol.for("mioku.service-manager");
|
|
247
249
|
async function pathExists$1(filePath) {
|
|
248
250
|
try {
|
|
249
|
-
await fs$
|
|
251
|
+
await fs$4.access(filePath);
|
|
250
252
|
return true;
|
|
251
253
|
} catch {
|
|
252
254
|
return false;
|
|
@@ -265,8 +267,8 @@ var ServiceManager = class ServiceManager {
|
|
|
265
267
|
return g[SERVICE_MANAGER_SYMBOL];
|
|
266
268
|
}
|
|
267
269
|
async discoverServices(miokuConfig = {}) {
|
|
268
|
-
if (miokuConfig.services_dir) this.servicesDir = path$
|
|
269
|
-
else this.servicesDir = path$
|
|
270
|
+
if (miokuConfig.services_dir) this.servicesDir = path$5.resolve(process.cwd(), miokuConfig.services_dir);
|
|
271
|
+
else this.servicesDir = path$5.resolve(process.cwd(), "services");
|
|
270
272
|
const discovered = [];
|
|
271
273
|
this.serviceMetadata.clear();
|
|
272
274
|
if (existsSync(this.servicesDir)) {
|
|
@@ -280,10 +282,10 @@ var ServiceManager = class ServiceManager {
|
|
|
280
282
|
async discoverFromDir(servicesDir) {
|
|
281
283
|
const discovered = [];
|
|
282
284
|
try {
|
|
283
|
-
const entries = await fs$
|
|
285
|
+
const entries = await fs$4.readdir(servicesDir, { withFileTypes: true });
|
|
284
286
|
for (const entry of entries) {
|
|
285
287
|
if (!entry.isDirectory()) continue;
|
|
286
|
-
const servicePath = path$
|
|
288
|
+
const servicePath = path$5.join(servicesDir, entry.name);
|
|
287
289
|
const metadata = await this.loadServiceMetadata(entry.name, servicePath);
|
|
288
290
|
if (metadata) {
|
|
289
291
|
discovered.push(metadata);
|
|
@@ -298,12 +300,12 @@ var ServiceManager = class ServiceManager {
|
|
|
298
300
|
async loadServiceMetadata(name, servicePath) {
|
|
299
301
|
let resolvedPath = servicePath;
|
|
300
302
|
try {
|
|
301
|
-
resolvedPath = await fs$
|
|
303
|
+
resolvedPath = await fs$4.realpath(servicePath);
|
|
302
304
|
} catch {}
|
|
303
|
-
const packageJsonPath = path$
|
|
305
|
+
const packageJsonPath = path$5.join(resolvedPath, "package.json");
|
|
304
306
|
if (!await pathExists$1(packageJsonPath)) return null;
|
|
305
307
|
try {
|
|
306
|
-
const packageJson = JSON.parse(await fs$
|
|
308
|
+
const packageJson = JSON.parse(await fs$4.readFile(packageJsonPath, "utf-8"));
|
|
307
309
|
const metadata = {
|
|
308
310
|
name,
|
|
309
311
|
version: packageJson.version || "0.0.0",
|
|
@@ -324,14 +326,14 @@ var ServiceManager = class ServiceManager {
|
|
|
324
326
|
await this.discoverFromNodeModules();
|
|
325
327
|
}
|
|
326
328
|
async discoverFromNodeModules() {
|
|
327
|
-
const nodeModulesPath = path$
|
|
329
|
+
const nodeModulesPath = path$5.resolve(process.cwd(), "node_modules");
|
|
328
330
|
if (!await pathExists$1(nodeModulesPath)) return;
|
|
329
331
|
try {
|
|
330
|
-
const entries = await fs$
|
|
332
|
+
const entries = await fs$4.readdir(nodeModulesPath, { withFileTypes: true });
|
|
331
333
|
for (const entry of entries) {
|
|
332
334
|
if (!entry.name.startsWith("mioku-service-")) continue;
|
|
333
335
|
const serviceName = entry.name.replace(/^mioku-service-/, "");
|
|
334
|
-
const servicePath = path$
|
|
336
|
+
const servicePath = path$5.join(nodeModulesPath, entry.name);
|
|
335
337
|
const metadata = await this.loadServiceMetadata(serviceName, servicePath);
|
|
336
338
|
if (metadata) this.serviceMetadata.set(serviceName, metadata);
|
|
337
339
|
}
|
|
@@ -351,8 +353,8 @@ var ServiceManager = class ServiceManager {
|
|
|
351
353
|
}
|
|
352
354
|
async loadService(metadata, ctx) {
|
|
353
355
|
try {
|
|
354
|
-
const indexPath = path$
|
|
355
|
-
const indexJsPath = path$
|
|
356
|
+
const indexPath = path$5.join(metadata.path, "index.ts");
|
|
357
|
+
const indexJsPath = path$5.join(metadata.path, "index.js");
|
|
356
358
|
const indexExists = await pathExists$1(indexPath);
|
|
357
359
|
const indexJsExists = await pathExists$1(indexJsPath);
|
|
358
360
|
const entryPoint = indexExists ? indexPath : indexJsPath;
|
|
@@ -404,7 +406,7 @@ var service_manager_default = ServiceManager.getInstance();
|
|
|
404
406
|
//#region src/core/plugin-artifact-registry.ts
|
|
405
407
|
async function pathExists(filePath) {
|
|
406
408
|
try {
|
|
407
|
-
await fs$
|
|
409
|
+
await fs$3.access(filePath);
|
|
408
410
|
return true;
|
|
409
411
|
} catch {
|
|
410
412
|
return false;
|
|
@@ -430,9 +432,9 @@ function extractSkills(moduleExports) {
|
|
|
430
432
|
return [];
|
|
431
433
|
}
|
|
432
434
|
async function resolveSkillsEntry(pluginPath) {
|
|
433
|
-
const tsPath = path$
|
|
435
|
+
const tsPath = path$4.join(pluginPath, "skills.ts");
|
|
434
436
|
if (await pathExists(tsPath)) return tsPath;
|
|
435
|
-
const jsPath = path$
|
|
437
|
+
const jsPath = path$4.join(pluginPath, "skills.js");
|
|
436
438
|
if (await pathExists(jsPath)) return jsPath;
|
|
437
439
|
return null;
|
|
438
440
|
}
|
|
@@ -462,7 +464,7 @@ async function registerPluginArtifacts(ctx) {
|
|
|
462
464
|
const moduleExports = await import(toImportPath(skillsEntry));
|
|
463
465
|
const skills = extractSkills(moduleExports);
|
|
464
466
|
if (skills.length === 0) {
|
|
465
|
-
logger.warn(`[plugin-artifacts] Plugin ${metadata.name} has ${path$
|
|
467
|
+
logger.warn(`[plugin-artifacts] Plugin ${metadata.name} has ${path$4.basename(skillsEntry)} but exported no valid skill`);
|
|
466
468
|
continue;
|
|
467
469
|
}
|
|
468
470
|
for (const skill of skills) {
|
|
@@ -476,6 +478,55 @@ async function registerPluginArtifacts(ctx) {
|
|
|
476
478
|
logger.info(`[plugin-artifacts] Registered ${skillCount} skill(s)`);
|
|
477
479
|
}
|
|
478
480
|
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/core/service-config.ts
|
|
483
|
+
const SERVICE_CONFIG_ROOT = "service";
|
|
484
|
+
function resolveConfigDir(serviceName) {
|
|
485
|
+
return path$3.join(process.cwd(), "config", SERVICE_CONFIG_ROOT, serviceName);
|
|
486
|
+
}
|
|
487
|
+
function resolveConfigPath(serviceName, configName) {
|
|
488
|
+
return path$3.join(resolveConfigDir(serviceName), `${configName}.json`);
|
|
489
|
+
}
|
|
490
|
+
function ensureDir(serviceName) {
|
|
491
|
+
const dir = resolveConfigDir(serviceName);
|
|
492
|
+
if (!fs$2.existsSync(dir)) fs$2.mkdirSync(dir, { recursive: true });
|
|
493
|
+
}
|
|
494
|
+
function registerServiceConfig(serviceName, configName, defaults) {
|
|
495
|
+
ensureDir(serviceName);
|
|
496
|
+
const configPath = resolveConfigPath(serviceName, configName);
|
|
497
|
+
if (!fs$2.existsSync(configPath)) fs$2.writeFileSync(configPath, JSON.stringify(defaults, null, 2), "utf-8");
|
|
498
|
+
}
|
|
499
|
+
function getServiceConfig(serviceName, configName) {
|
|
500
|
+
const configPath = resolveConfigPath(serviceName, configName);
|
|
501
|
+
try {
|
|
502
|
+
if (fs$2.existsSync(configPath)) return JSON.parse(fs$2.readFileSync(configPath, "utf-8"));
|
|
503
|
+
} catch {}
|
|
504
|
+
return {};
|
|
505
|
+
}
|
|
506
|
+
function updateServiceConfig(serviceName, configName, value) {
|
|
507
|
+
ensureDir(serviceName);
|
|
508
|
+
fs$2.writeFileSync(resolveConfigPath(serviceName, configName), JSON.stringify(value, null, 2), "utf-8");
|
|
509
|
+
}
|
|
510
|
+
function getServiceConfigs(serviceName) {
|
|
511
|
+
const dir = resolveConfigDir(serviceName);
|
|
512
|
+
if (!fs$2.existsSync(dir)) return {};
|
|
513
|
+
const result = {};
|
|
514
|
+
const files = fs$2.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
515
|
+
for (const file of files) {
|
|
516
|
+
const filePath = path$3.join(dir, file);
|
|
517
|
+
try {
|
|
518
|
+
result[path$3.basename(file, ".json")] = JSON.parse(fs$2.readFileSync(filePath, "utf-8"));
|
|
519
|
+
} catch {}
|
|
520
|
+
}
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
523
|
+
function deleteServiceConfig(serviceName, configName) {
|
|
524
|
+
const configPath = resolveConfigPath(serviceName, configName);
|
|
525
|
+
if (!fs$2.existsSync(configPath)) return false;
|
|
526
|
+
fs$2.unlinkSync(configPath);
|
|
527
|
+
return true;
|
|
528
|
+
}
|
|
529
|
+
|
|
479
530
|
//#endregion
|
|
480
531
|
//#region src/service-types.ts
|
|
481
532
|
const TOOL_RESULT_FOLLOWUP_KEY = "__miokuFollowup";
|
|
@@ -487,7 +538,7 @@ const TOOL_RESULT_FOLLOWUP_KEY = "__miokuFollowup";
|
|
|
487
538
|
* Returns: {cwd}/data/{pluginName}
|
|
488
539
|
*/
|
|
489
540
|
function getPluginDataDir(pluginName) {
|
|
490
|
-
const dataDir = path$
|
|
541
|
+
const dataDir = path$2.join(process.cwd(), "data", pluginName);
|
|
491
542
|
return dataDir;
|
|
492
543
|
}
|
|
493
544
|
/**
|
|
@@ -495,7 +546,7 @@ function getPluginDataDir(pluginName) {
|
|
|
495
546
|
* Returns: {cwd}/data/{serviceName}
|
|
496
547
|
*/
|
|
497
548
|
function getServiceDataDir(serviceName) {
|
|
498
|
-
const dataDir = path$
|
|
549
|
+
const dataDir = path$2.join(process.cwd(), "data", serviceName);
|
|
499
550
|
return dataDir;
|
|
500
551
|
}
|
|
501
552
|
/**
|
|
@@ -503,22 +554,22 @@ function getServiceDataDir(serviceName) {
|
|
|
503
554
|
* Returns: {cwd}/data
|
|
504
555
|
*/
|
|
505
556
|
function getDataDir() {
|
|
506
|
-
return path$
|
|
557
|
+
return path$2.join(process.cwd(), "data");
|
|
507
558
|
}
|
|
508
559
|
/**
|
|
509
560
|
* Get the config directory for a plugin
|
|
510
561
|
* Returns: {cwd}/config/{pluginName}
|
|
511
562
|
*/
|
|
512
563
|
function getPluginConfigDir(pluginName) {
|
|
513
|
-
const configDir = path$
|
|
564
|
+
const configDir = path$2.join(process.cwd(), "config", pluginName);
|
|
514
565
|
return configDir;
|
|
515
566
|
}
|
|
516
567
|
/**
|
|
517
568
|
* Get the config directory for a service
|
|
518
|
-
* Returns: {cwd}/config/{serviceName}
|
|
569
|
+
* Returns: {cwd}/config/service/{serviceName}
|
|
519
570
|
*/
|
|
520
571
|
function getServiceConfigDir(serviceName) {
|
|
521
|
-
const configDir = path$
|
|
572
|
+
const configDir = path$2.join(process.cwd(), "config", "service", serviceName);
|
|
522
573
|
return configDir;
|
|
523
574
|
}
|
|
524
575
|
/**
|
|
@@ -526,7 +577,7 @@ function getServiceConfigDir(serviceName) {
|
|
|
526
577
|
* Returns: {cwd}/config
|
|
527
578
|
*/
|
|
528
579
|
function getConfigDir() {
|
|
529
|
-
return path$
|
|
580
|
+
return path$2.join(process.cwd(), "config");
|
|
530
581
|
}
|
|
531
582
|
/**
|
|
532
583
|
* Ensure a directory exists, creating it if necessary
|
|
@@ -576,10 +627,10 @@ async function start(options = {}) {
|
|
|
576
627
|
if (cwd) process.chdir(cwd);
|
|
577
628
|
const { start: startMioki, logger: logger$1, botConfig } = await import("mioki");
|
|
578
629
|
setMiokuLogger(logger$1);
|
|
579
|
-
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
630
|
+
const packageJsonPath = path$1.join(process.cwd(), "package.json");
|
|
580
631
|
let miokuConfig = {};
|
|
581
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
582
|
-
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
632
|
+
if (fs$1.existsSync(packageJsonPath)) {
|
|
633
|
+
const pkg = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
|
|
583
634
|
miokuConfig = pkg.mioki || {};
|
|
584
635
|
}
|
|
585
636
|
logger$1.info("こんにちは..");
|
|
@@ -595,7 +646,7 @@ async function start(options = {}) {
|
|
|
595
646
|
logger$1.info("O.o Miku 正在翻找插件..");
|
|
596
647
|
const discoveredPlugins = await plugin_manager_default.discoverPlugins(miokuConfig);
|
|
597
648
|
logger$1.info(`O.o 共发现 ${discoveredPlugins.length} 个插件: ${discoveredPlugins.map((p) => p.name).join(", ")}`);
|
|
598
|
-
const runtimePluginsDir = path.resolve(process.cwd(), DEFAULT_RUNTIME_PLUGINS_DIR);
|
|
649
|
+
const runtimePluginsDir = path$1.resolve(process.cwd(), DEFAULT_RUNTIME_PLUGINS_DIR);
|
|
599
650
|
const linkedPluginNames = await prepareRuntimePluginLinks(discoveredPlugins, runtimePluginsDir);
|
|
600
651
|
botConfig.plugins_dir = DEFAULT_RUNTIME_PLUGINS_DIR;
|
|
601
652
|
logger$1.info("o.O Miku 正在翻找服务..");
|
|
@@ -612,5 +663,5 @@ async function start(options = {}) {
|
|
|
612
663
|
const version = "1.0.0";
|
|
613
664
|
|
|
614
665
|
//#endregion
|
|
615
|
-
export { TOOL_RESULT_FOLLOWUP_KEY, definePlugin, ensureDataDir, getConfigDir, getDataDir, getPluginConfigDir, getPluginDataDir, getPluginRuntimeState, getServiceConfigDir, getServiceDataDir, plugin_manager_default as pluginManager, registerPluginArtifacts, resetPluginRuntimeState, service_manager_default as serviceManager, setPluginRuntimeState, start, version };
|
|
666
|
+
export { TOOL_RESULT_FOLLOWUP_KEY, definePlugin, deleteServiceConfig, ensureDataDir, getConfigDir, getDataDir, getPluginConfigDir, getPluginDataDir, getPluginRuntimeState, getServiceConfig, getServiceConfigDir, getServiceConfigs, getServiceDataDir, plugin_manager_default as pluginManager, registerPluginArtifacts, registerServiceConfig, resetPluginRuntimeState, service_manager_default as serviceManager, setPluginRuntimeState, start, updateServiceConfig, version };
|
|
616
667
|
//# sourceMappingURL=index.js.map
|