@bonginkan/maria 3.6.2 → 3.6.4
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/bin/maria.cjs +23154 -21792
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +2026 -679
- package/dist/cli.cjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var fs6 = require('fs');
|
|
5
|
+
var path8 = require('path');
|
|
6
6
|
var os2 = require('os');
|
|
7
7
|
var events = require('events');
|
|
8
|
-
var
|
|
8
|
+
var fs8 = require('fs/promises');
|
|
9
9
|
var Stream = require('stream');
|
|
10
10
|
var util = require('util');
|
|
11
11
|
var buffer = require('buffer');
|
|
@@ -15,6 +15,7 @@ var url = require('url');
|
|
|
15
15
|
var https = require('https');
|
|
16
16
|
var zlib = require('zlib');
|
|
17
17
|
var chalk13 = require('chalk');
|
|
18
|
+
var child_process = require('child_process');
|
|
18
19
|
var readline = require('readline');
|
|
19
20
|
var dotenv = require('dotenv');
|
|
20
21
|
var OpenAI = require('openai');
|
|
@@ -50,10 +51,10 @@ function _interopNamespace(e) {
|
|
|
50
51
|
return Object.freeze(n);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
var fs4__namespace = /*#__PURE__*/_interopNamespace(fs4);
|
|
54
|
-
var path6__namespace = /*#__PURE__*/_interopNamespace(path6);
|
|
55
|
-
var os2__namespace = /*#__PURE__*/_interopNamespace(os2);
|
|
56
54
|
var fs6__namespace = /*#__PURE__*/_interopNamespace(fs6);
|
|
55
|
+
var path8__namespace = /*#__PURE__*/_interopNamespace(path8);
|
|
56
|
+
var os2__namespace = /*#__PURE__*/_interopNamespace(os2);
|
|
57
|
+
var fs8__namespace = /*#__PURE__*/_interopNamespace(fs8);
|
|
57
58
|
var Stream__default = /*#__PURE__*/_interopDefault(Stream);
|
|
58
59
|
var http__default = /*#__PURE__*/_interopDefault(http);
|
|
59
60
|
var https__default = /*#__PURE__*/_interopDefault(https);
|
|
@@ -115,8 +116,8 @@ var init_conversation_persistence = __esm({
|
|
|
115
116
|
autoSaveInterval = null;
|
|
116
117
|
pendingWrites = [];
|
|
117
118
|
constructor(maxHistorySize = 100) {
|
|
118
|
-
const configDir =
|
|
119
|
-
this.sessionFile =
|
|
119
|
+
const configDir = path8__namespace.join(os2__namespace.homedir(), ".maria");
|
|
120
|
+
this.sessionFile = path8__namespace.join(configDir, "conversation-history.json");
|
|
120
121
|
this.maxHistorySize = maxHistorySize;
|
|
121
122
|
this.ensureConfigDir();
|
|
122
123
|
this.startAutoSave();
|
|
@@ -126,8 +127,8 @@ var init_conversation_persistence = __esm({
|
|
|
126
127
|
*/
|
|
127
128
|
async ensureConfigDir() {
|
|
128
129
|
try {
|
|
129
|
-
const configDir =
|
|
130
|
-
await
|
|
130
|
+
const configDir = path8__namespace.dirname(this.sessionFile);
|
|
131
|
+
await fs6.promises.mkdir(configDir, { recursive: true });
|
|
131
132
|
} catch (error) {
|
|
132
133
|
console.warn("Failed to create config directory:", error);
|
|
133
134
|
}
|
|
@@ -137,7 +138,7 @@ var init_conversation_persistence = __esm({
|
|
|
137
138
|
*/
|
|
138
139
|
async loadHistory() {
|
|
139
140
|
try {
|
|
140
|
-
const data2 = await
|
|
141
|
+
const data2 = await fs6.promises.readFile(this.sessionFile, "utf-8");
|
|
141
142
|
const session = JSON.parse(data2);
|
|
142
143
|
const messages = session.messages.map((msg) => ({
|
|
143
144
|
...msg,
|
|
@@ -175,7 +176,7 @@ var init_conversation_persistence = __esm({
|
|
|
175
176
|
model: messages[messages.length - 1]?.model
|
|
176
177
|
}
|
|
177
178
|
};
|
|
178
|
-
await
|
|
179
|
+
await fs6.promises.writeFile(this.sessionFile, JSON.stringify(session, null, 2));
|
|
179
180
|
} catch (error) {
|
|
180
181
|
console.warn("Failed to save conversation history:", error);
|
|
181
182
|
}
|
|
@@ -185,7 +186,7 @@ var init_conversation_persistence = __esm({
|
|
|
185
186
|
*/
|
|
186
187
|
async clearHistory() {
|
|
187
188
|
try {
|
|
188
|
-
await
|
|
189
|
+
await fs6.promises.unlink(this.sessionFile);
|
|
189
190
|
} catch (innerError) {
|
|
190
191
|
}
|
|
191
192
|
this.pendingWrites = [];
|
|
@@ -196,7 +197,7 @@ var init_conversation_persistence = __esm({
|
|
|
196
197
|
async getStats() {
|
|
197
198
|
try {
|
|
198
199
|
const messages = await this.loadHistory();
|
|
199
|
-
const stats = await
|
|
200
|
+
const stats = await fs6.promises.stat(this.sessionFile);
|
|
200
201
|
return {
|
|
201
202
|
totalMessages: messages.length,
|
|
202
203
|
oldestMessage: messages[0]?.timestamp,
|
|
@@ -266,7 +267,7 @@ var init_chat_context_service = __esm({
|
|
|
266
267
|
maxTokens: config2?.maxTokens || 128e3,
|
|
267
268
|
compressionThreshold: config2?.compressionThreshold || 0.8,
|
|
268
269
|
summaryTokenLimit: config2?.summaryTokenLimit || 2e3,
|
|
269
|
-
persistPath: config2?.persistPath ||
|
|
270
|
+
persistPath: config2?.persistPath || path8__namespace.join(process.env["HOME"] || "", ".maria", "context")
|
|
270
271
|
};
|
|
271
272
|
this.sessionId = this.generateSessionId();
|
|
272
273
|
}
|
|
@@ -385,8 +386,8 @@ var init_chat_context_service = __esm({
|
|
|
385
386
|
async persistSession() {
|
|
386
387
|
if (!this.config.persistPath) return;
|
|
387
388
|
try {
|
|
388
|
-
await
|
|
389
|
-
const sessionFile =
|
|
389
|
+
await fs8__namespace.mkdir(this.config.persistPath, { recursive: true });
|
|
390
|
+
const sessionFile = path8__namespace.join(
|
|
390
391
|
this.config.persistPath,
|
|
391
392
|
`${this.sessionId}.json`
|
|
392
393
|
);
|
|
@@ -398,7 +399,7 @@ var init_chat_context_service = __esm({
|
|
|
398
399
|
fullHistory: this.fullHistory,
|
|
399
400
|
compressionCount: this.compressionCount
|
|
400
401
|
};
|
|
401
|
-
await
|
|
402
|
+
await fs8__namespace.writeFile(sessionFile, JSON.stringify(sessionData, null, 2));
|
|
402
403
|
this.emit("session-persisted", sessionFile);
|
|
403
404
|
} catch (error) {
|
|
404
405
|
this.emit(
|
|
@@ -1320,10 +1321,9 @@ var init_telemetry_collector = __esm({
|
|
|
1320
1321
|
});
|
|
1321
1322
|
|
|
1322
1323
|
// src/providers/config.ts
|
|
1323
|
-
var
|
|
1324
|
+
var DEFAULT_PROVIDER2, DEFAULT_MODEL2;
|
|
1324
1325
|
var init_config = __esm({
|
|
1325
1326
|
"src/providers/config.ts"() {
|
|
1326
|
-
USE_LEGACY_PROVIDERS2 = process.env.USE_LEGACY_PROVIDERS === "true";
|
|
1327
1327
|
DEFAULT_PROVIDER2 = process.env.MARIA_PROVIDER ?? "openai";
|
|
1328
1328
|
DEFAULT_MODEL2 = process.env.MARIA_MODEL ?? "gpt-4o-mini";
|
|
1329
1329
|
}
|
|
@@ -1402,7 +1402,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
1402
1402
|
return new originalPromise(executor);
|
|
1403
1403
|
}
|
|
1404
1404
|
function promiseResolvedWith(value) {
|
|
1405
|
-
return newPromise((
|
|
1405
|
+
return newPromise((resolve4) => resolve4(value));
|
|
1406
1406
|
}
|
|
1407
1407
|
function promiseRejectedWith(reason) {
|
|
1408
1408
|
return originalPromiseReject(reason);
|
|
@@ -1572,8 +1572,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
1572
1572
|
return new TypeError("Cannot " + name2 + " a stream using a released reader");
|
|
1573
1573
|
}
|
|
1574
1574
|
function defaultReaderClosedPromiseInitialize(reader2) {
|
|
1575
|
-
reader2._closedPromise = newPromise((
|
|
1576
|
-
reader2._closedPromise_resolve =
|
|
1575
|
+
reader2._closedPromise = newPromise((resolve4, reject) => {
|
|
1576
|
+
reader2._closedPromise_resolve = resolve4;
|
|
1577
1577
|
reader2._closedPromise_reject = reject;
|
|
1578
1578
|
});
|
|
1579
1579
|
}
|
|
@@ -1624,11 +1624,11 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
1624
1624
|
throw new TypeError(`${context2} is not a function.`);
|
|
1625
1625
|
}
|
|
1626
1626
|
}
|
|
1627
|
-
function
|
|
1627
|
+
function isObject2(x2) {
|
|
1628
1628
|
return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
|
|
1629
1629
|
}
|
|
1630
1630
|
function assertObject(x2, context2) {
|
|
1631
|
-
if (!
|
|
1631
|
+
if (!isObject2(x2)) {
|
|
1632
1632
|
throw new TypeError(`${context2} is not an object.`);
|
|
1633
1633
|
}
|
|
1634
1634
|
}
|
|
@@ -1747,8 +1747,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
1747
1747
|
}
|
|
1748
1748
|
let resolvePromise;
|
|
1749
1749
|
let rejectPromise;
|
|
1750
|
-
const promise = newPromise((
|
|
1751
|
-
resolvePromise =
|
|
1750
|
+
const promise = newPromise((resolve4, reject) => {
|
|
1751
|
+
resolvePromise = resolve4;
|
|
1752
1752
|
rejectPromise = reject;
|
|
1753
1753
|
});
|
|
1754
1754
|
const readRequest = {
|
|
@@ -1853,8 +1853,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
1853
1853
|
const reader2 = this._reader;
|
|
1854
1854
|
let resolvePromise;
|
|
1855
1855
|
let rejectPromise;
|
|
1856
|
-
const promise = newPromise((
|
|
1857
|
-
resolvePromise =
|
|
1856
|
+
const promise = newPromise((resolve4, reject) => {
|
|
1857
|
+
resolvePromise = resolve4;
|
|
1858
1858
|
rejectPromise = reject;
|
|
1859
1859
|
});
|
|
1860
1860
|
const readRequest = {
|
|
@@ -2873,8 +2873,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2873
2873
|
}
|
|
2874
2874
|
let resolvePromise;
|
|
2875
2875
|
let rejectPromise;
|
|
2876
|
-
const promise = newPromise((
|
|
2877
|
-
resolvePromise =
|
|
2876
|
+
const promise = newPromise((resolve4, reject) => {
|
|
2877
|
+
resolvePromise = resolve4;
|
|
2878
2878
|
rejectPromise = reject;
|
|
2879
2879
|
});
|
|
2880
2880
|
const readIntoRequest = {
|
|
@@ -3186,10 +3186,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3186
3186
|
wasAlreadyErroring = true;
|
|
3187
3187
|
reason = void 0;
|
|
3188
3188
|
}
|
|
3189
|
-
const promise = newPromise((
|
|
3189
|
+
const promise = newPromise((resolve4, reject) => {
|
|
3190
3190
|
stream._pendingAbortRequest = {
|
|
3191
3191
|
_promise: void 0,
|
|
3192
|
-
_resolve:
|
|
3192
|
+
_resolve: resolve4,
|
|
3193
3193
|
_reject: reject,
|
|
3194
3194
|
_reason: reason,
|
|
3195
3195
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -3206,9 +3206,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3206
3206
|
if (state === "closed" || state === "errored") {
|
|
3207
3207
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
3208
3208
|
}
|
|
3209
|
-
const promise = newPromise((
|
|
3209
|
+
const promise = newPromise((resolve4, reject) => {
|
|
3210
3210
|
const closeRequest = {
|
|
3211
|
-
_resolve:
|
|
3211
|
+
_resolve: resolve4,
|
|
3212
3212
|
_reject: reject
|
|
3213
3213
|
};
|
|
3214
3214
|
stream._closeRequest = closeRequest;
|
|
@@ -3221,9 +3221,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3221
3221
|
return promise;
|
|
3222
3222
|
}
|
|
3223
3223
|
function WritableStreamAddWriteRequest(stream) {
|
|
3224
|
-
const promise = newPromise((
|
|
3224
|
+
const promise = newPromise((resolve4, reject) => {
|
|
3225
3225
|
const writeRequest = {
|
|
3226
|
-
_resolve:
|
|
3226
|
+
_resolve: resolve4,
|
|
3227
3227
|
_reject: reject
|
|
3228
3228
|
};
|
|
3229
3229
|
stream._writeRequests.push(writeRequest);
|
|
@@ -3839,8 +3839,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3839
3839
|
return new TypeError("Cannot " + name2 + " a stream using a released writer");
|
|
3840
3840
|
}
|
|
3841
3841
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
3842
|
-
writer._closedPromise = newPromise((
|
|
3843
|
-
writer._closedPromise_resolve =
|
|
3842
|
+
writer._closedPromise = newPromise((resolve4, reject) => {
|
|
3843
|
+
writer._closedPromise_resolve = resolve4;
|
|
3844
3844
|
writer._closedPromise_reject = reject;
|
|
3845
3845
|
writer._closedPromiseState = "pending";
|
|
3846
3846
|
});
|
|
@@ -3876,8 +3876,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3876
3876
|
writer._closedPromiseState = "resolved";
|
|
3877
3877
|
}
|
|
3878
3878
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
3879
|
-
writer._readyPromise = newPromise((
|
|
3880
|
-
writer._readyPromise_resolve =
|
|
3879
|
+
writer._readyPromise = newPromise((resolve4, reject) => {
|
|
3880
|
+
writer._readyPromise_resolve = resolve4;
|
|
3881
3881
|
writer._readyPromise_reject = reject;
|
|
3882
3882
|
});
|
|
3883
3883
|
writer._readyPromiseState = "pending";
|
|
@@ -3964,7 +3964,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3964
3964
|
source._disturbed = true;
|
|
3965
3965
|
let shuttingDown = false;
|
|
3966
3966
|
let currentWrite = promiseResolvedWith(void 0);
|
|
3967
|
-
return newPromise((
|
|
3967
|
+
return newPromise((resolve4, reject) => {
|
|
3968
3968
|
let abortAlgorithm;
|
|
3969
3969
|
if (signal !== void 0) {
|
|
3970
3970
|
abortAlgorithm = () => {
|
|
@@ -4109,7 +4109,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
4109
4109
|
if (isError) {
|
|
4110
4110
|
reject(error);
|
|
4111
4111
|
} else {
|
|
4112
|
-
|
|
4112
|
+
resolve4(void 0);
|
|
4113
4113
|
}
|
|
4114
4114
|
return null;
|
|
4115
4115
|
}
|
|
@@ -4390,8 +4390,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
4390
4390
|
let branch1;
|
|
4391
4391
|
let branch2;
|
|
4392
4392
|
let resolveCancelPromise;
|
|
4393
|
-
const cancelPromise = newPromise((
|
|
4394
|
-
resolveCancelPromise =
|
|
4393
|
+
const cancelPromise = newPromise((resolve4) => {
|
|
4394
|
+
resolveCancelPromise = resolve4;
|
|
4395
4395
|
});
|
|
4396
4396
|
function pullAlgorithm() {
|
|
4397
4397
|
if (reading) {
|
|
@@ -4482,8 +4482,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
4482
4482
|
let branch1;
|
|
4483
4483
|
let branch2;
|
|
4484
4484
|
let resolveCancelPromise;
|
|
4485
|
-
const cancelPromise = newPromise((
|
|
4486
|
-
resolveCancelPromise =
|
|
4485
|
+
const cancelPromise = newPromise((resolve4) => {
|
|
4486
|
+
resolveCancelPromise = resolve4;
|
|
4487
4487
|
});
|
|
4488
4488
|
function forwardReaderError(thisReader) {
|
|
4489
4489
|
uponRejection(thisReader._closedPromise, (r2) => {
|
|
@@ -5263,8 +5263,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
5263
5263
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
5264
5264
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
5265
5265
|
let startPromise_resolve;
|
|
5266
|
-
const startPromise = newPromise((
|
|
5267
|
-
startPromise_resolve =
|
|
5266
|
+
const startPromise = newPromise((resolve4) => {
|
|
5267
|
+
startPromise_resolve = resolve4;
|
|
5268
5268
|
});
|
|
5269
5269
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
5270
5270
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -5357,8 +5357,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
5357
5357
|
if (stream._backpressureChangePromise !== void 0) {
|
|
5358
5358
|
stream._backpressureChangePromise_resolve();
|
|
5359
5359
|
}
|
|
5360
|
-
stream._backpressureChangePromise = newPromise((
|
|
5361
|
-
stream._backpressureChangePromise_resolve =
|
|
5360
|
+
stream._backpressureChangePromise = newPromise((resolve4) => {
|
|
5361
|
+
stream._backpressureChangePromise_resolve = resolve4;
|
|
5362
5362
|
});
|
|
5363
5363
|
stream._backpressure = backpressure;
|
|
5364
5364
|
}
|
|
@@ -5526,8 +5526,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
5526
5526
|
return controller._finishPromise;
|
|
5527
5527
|
}
|
|
5528
5528
|
const readable = stream._readable;
|
|
5529
|
-
controller._finishPromise = newPromise((
|
|
5530
|
-
controller._finishPromise_resolve =
|
|
5529
|
+
controller._finishPromise = newPromise((resolve4, reject) => {
|
|
5530
|
+
controller._finishPromise_resolve = resolve4;
|
|
5531
5531
|
controller._finishPromise_reject = reject;
|
|
5532
5532
|
});
|
|
5533
5533
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -5553,8 +5553,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
5553
5553
|
return controller._finishPromise;
|
|
5554
5554
|
}
|
|
5555
5555
|
const readable = stream._readable;
|
|
5556
|
-
controller._finishPromise = newPromise((
|
|
5557
|
-
controller._finishPromise_resolve =
|
|
5556
|
+
controller._finishPromise = newPromise((resolve4, reject) => {
|
|
5557
|
+
controller._finishPromise_resolve = resolve4;
|
|
5558
5558
|
controller._finishPromise_reject = reject;
|
|
5559
5559
|
});
|
|
5560
5560
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -5584,8 +5584,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
5584
5584
|
return controller._finishPromise;
|
|
5585
5585
|
}
|
|
5586
5586
|
const writable = stream._writable;
|
|
5587
|
-
controller._finishPromise = newPromise((
|
|
5588
|
-
controller._finishPromise_resolve =
|
|
5587
|
+
controller._finishPromise = newPromise((resolve4, reject) => {
|
|
5588
|
+
controller._finishPromise_resolve = resolve4;
|
|
5589
5589
|
controller._finishPromise_reject = reject;
|
|
5590
5590
|
});
|
|
5591
5591
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -6127,23 +6127,23 @@ var init_from = __esm({
|
|
|
6127
6127
|
import_node_domexception = __toESM(require_node_domexception());
|
|
6128
6128
|
init_file();
|
|
6129
6129
|
init_fetch_blob();
|
|
6130
|
-
({ stat } =
|
|
6131
|
-
blobFromSync = (
|
|
6132
|
-
blobFrom = (
|
|
6133
|
-
fileFrom = (
|
|
6134
|
-
fileFromSync = (
|
|
6135
|
-
fromBlob = (stat2,
|
|
6136
|
-
path:
|
|
6130
|
+
({ stat } = fs6.promises);
|
|
6131
|
+
blobFromSync = (path9, type) => fromBlob(fs6.statSync(path9), path9, type);
|
|
6132
|
+
blobFrom = (path9, type) => stat(path9).then((stat2) => fromBlob(stat2, path9, type));
|
|
6133
|
+
fileFrom = (path9, type) => stat(path9).then((stat2) => fromFile(stat2, path9, type));
|
|
6134
|
+
fileFromSync = (path9, type) => fromFile(fs6.statSync(path9), path9, type);
|
|
6135
|
+
fromBlob = (stat2, path9, type = "") => new fetch_blob_default([new BlobDataItem({
|
|
6136
|
+
path: path9,
|
|
6137
6137
|
size: stat2.size,
|
|
6138
6138
|
lastModified: stat2.mtimeMs,
|
|
6139
6139
|
start: 0
|
|
6140
6140
|
})], { type });
|
|
6141
|
-
fromFile = (stat2,
|
|
6142
|
-
path:
|
|
6141
|
+
fromFile = (stat2, path9, type = "") => new file_default([new BlobDataItem({
|
|
6142
|
+
path: path9,
|
|
6143
6143
|
size: stat2.size,
|
|
6144
6144
|
lastModified: stat2.mtimeMs,
|
|
6145
6145
|
start: 0
|
|
6146
|
-
})],
|
|
6146
|
+
})], path8.basename(path9), { type, lastModified: stat2.mtimeMs });
|
|
6147
6147
|
BlobDataItem = class _BlobDataItem {
|
|
6148
6148
|
#path;
|
|
6149
6149
|
#start;
|
|
@@ -6170,7 +6170,7 @@ var init_from = __esm({
|
|
|
6170
6170
|
if (mtimeMs > this.lastModified) {
|
|
6171
6171
|
throw new import_node_domexception.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.", "NotReadableError");
|
|
6172
6172
|
}
|
|
6173
|
-
yield*
|
|
6173
|
+
yield* fs6.createReadStream(this.#path, {
|
|
6174
6174
|
start: this.#start,
|
|
6175
6175
|
end: this.#start + this.size - 1
|
|
6176
6176
|
});
|
|
@@ -7507,7 +7507,7 @@ __export(src_exports, {
|
|
|
7507
7507
|
isRedirect: () => isRedirect
|
|
7508
7508
|
});
|
|
7509
7509
|
async function fetch2(url, options_) {
|
|
7510
|
-
return new Promise((
|
|
7510
|
+
return new Promise((resolve4, reject) => {
|
|
7511
7511
|
const request = new Request(url, options_);
|
|
7512
7512
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
7513
7513
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -7516,7 +7516,7 @@ async function fetch2(url, options_) {
|
|
|
7516
7516
|
if (parsedURL.protocol === "data:") {
|
|
7517
7517
|
const data2 = dist_default(request.url);
|
|
7518
7518
|
const response3 = new Response(data2, { headers: { "Content-Type": data2.typeFull } });
|
|
7519
|
-
|
|
7519
|
+
resolve4(response3);
|
|
7520
7520
|
return;
|
|
7521
7521
|
}
|
|
7522
7522
|
const send = (parsedURL.protocol === "https:" ? https__default.default : http__default.default).request;
|
|
@@ -7638,7 +7638,7 @@ async function fetch2(url, options_) {
|
|
|
7638
7638
|
if (responseReferrerPolicy) {
|
|
7639
7639
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
7640
7640
|
}
|
|
7641
|
-
|
|
7641
|
+
resolve4(fetch2(new Request(locationURL, requestOptions)));
|
|
7642
7642
|
finalize();
|
|
7643
7643
|
return;
|
|
7644
7644
|
}
|
|
@@ -7671,7 +7671,7 @@ async function fetch2(url, options_) {
|
|
|
7671
7671
|
const codings = headers.get("Content-Encoding");
|
|
7672
7672
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
7673
7673
|
response2 = new Response(body, responseOptions);
|
|
7674
|
-
|
|
7674
|
+
resolve4(response2);
|
|
7675
7675
|
return;
|
|
7676
7676
|
}
|
|
7677
7677
|
const zlibOptions = {
|
|
@@ -7685,7 +7685,7 @@ async function fetch2(url, options_) {
|
|
|
7685
7685
|
}
|
|
7686
7686
|
});
|
|
7687
7687
|
response2 = new Response(body, responseOptions);
|
|
7688
|
-
|
|
7688
|
+
resolve4(response2);
|
|
7689
7689
|
return;
|
|
7690
7690
|
}
|
|
7691
7691
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -7709,12 +7709,12 @@ async function fetch2(url, options_) {
|
|
|
7709
7709
|
});
|
|
7710
7710
|
}
|
|
7711
7711
|
response2 = new Response(body, responseOptions);
|
|
7712
|
-
|
|
7712
|
+
resolve4(response2);
|
|
7713
7713
|
});
|
|
7714
7714
|
raw.once("end", () => {
|
|
7715
7715
|
if (!response2) {
|
|
7716
7716
|
response2 = new Response(body, responseOptions);
|
|
7717
|
-
|
|
7717
|
+
resolve4(response2);
|
|
7718
7718
|
}
|
|
7719
7719
|
});
|
|
7720
7720
|
return;
|
|
@@ -7726,11 +7726,11 @@ async function fetch2(url, options_) {
|
|
|
7726
7726
|
}
|
|
7727
7727
|
});
|
|
7728
7728
|
response2 = new Response(body, responseOptions);
|
|
7729
|
-
|
|
7729
|
+
resolve4(response2);
|
|
7730
7730
|
return;
|
|
7731
7731
|
}
|
|
7732
7732
|
response2 = new Response(body, responseOptions);
|
|
7733
|
-
|
|
7733
|
+
resolve4(response2);
|
|
7734
7734
|
});
|
|
7735
7735
|
writeToStream(request_, request).catch(reject);
|
|
7736
7736
|
});
|
|
@@ -7924,7 +7924,7 @@ var init_base_provider = __esm({
|
|
|
7924
7924
|
}
|
|
7925
7925
|
if (attempt < maxRetries - 1) {
|
|
7926
7926
|
const delay = Math.pow(2, attempt) * 1e3;
|
|
7927
|
-
await new Promise((
|
|
7927
|
+
await new Promise((resolve4) => setTimeout(resolve4, delay));
|
|
7928
7928
|
}
|
|
7929
7929
|
}
|
|
7930
7930
|
}
|
|
@@ -8050,6 +8050,29 @@ var init_manager = __esm({
|
|
|
8050
8050
|
getAvailableProviders() {
|
|
8051
8051
|
return Array.from(this.availableProviders);
|
|
8052
8052
|
}
|
|
8053
|
+
/**
|
|
8054
|
+
* Get list of available models (legacy compatibility)
|
|
8055
|
+
*/
|
|
8056
|
+
getAvailableModels() {
|
|
8057
|
+
const models = [];
|
|
8058
|
+
for (const providerId of this.availableProviders) {
|
|
8059
|
+
switch (providerId) {
|
|
8060
|
+
case "openai":
|
|
8061
|
+
models.push("gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo");
|
|
8062
|
+
break;
|
|
8063
|
+
case "anthropic":
|
|
8064
|
+
models.push("claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022");
|
|
8065
|
+
break;
|
|
8066
|
+
case "google":
|
|
8067
|
+
models.push("gemini-2.5-pro", "gemini-2.5-flash");
|
|
8068
|
+
break;
|
|
8069
|
+
case "grok":
|
|
8070
|
+
models.push("grok-4", "grok-beta");
|
|
8071
|
+
break;
|
|
8072
|
+
}
|
|
8073
|
+
}
|
|
8074
|
+
return models;
|
|
8075
|
+
}
|
|
8053
8076
|
/**
|
|
8054
8077
|
* Get comprehensive health status for all providers
|
|
8055
8078
|
*/
|
|
@@ -8295,240 +8318,11 @@ var init_manager = __esm({
|
|
|
8295
8318
|
}
|
|
8296
8319
|
});
|
|
8297
8320
|
|
|
8298
|
-
// src/providers/legacy-adapter.ts
|
|
8299
|
-
var LegacyAIProviderFactory2, ModernToLegacyProviderShim, TemplateProviderShim;
|
|
8300
|
-
var init_legacy_adapter = __esm({
|
|
8301
|
-
"src/providers/legacy-adapter.ts"() {
|
|
8302
|
-
init_manager();
|
|
8303
|
-
LegacyAIProviderFactory2 = class _LegacyAIProviderFactory {
|
|
8304
|
-
static instance;
|
|
8305
|
-
manager;
|
|
8306
|
-
currentProviderType = "template";
|
|
8307
|
-
constructor() {
|
|
8308
|
-
this.manager = new UnifiedAIProviderManager2();
|
|
8309
|
-
}
|
|
8310
|
-
static getInstance() {
|
|
8311
|
-
if (!_LegacyAIProviderFactory.instance) {
|
|
8312
|
-
_LegacyAIProviderFactory.instance = new _LegacyAIProviderFactory();
|
|
8313
|
-
}
|
|
8314
|
-
return _LegacyAIProviderFactory.instance;
|
|
8315
|
-
}
|
|
8316
|
-
/**
|
|
8317
|
-
* Initialize providers from environment (legacy interface)
|
|
8318
|
-
*/
|
|
8319
|
-
async initializeFromEnvironment() {
|
|
8320
|
-
await this.manager.initialize();
|
|
8321
|
-
}
|
|
8322
|
-
/**
|
|
8323
|
-
* Initialize a specific provider (legacy interface)
|
|
8324
|
-
*/
|
|
8325
|
-
async initializeProvider(type, config2) {
|
|
8326
|
-
}
|
|
8327
|
-
/**
|
|
8328
|
-
* Get provider (legacy interface)
|
|
8329
|
-
* Returns a shim that adapts modern provider to legacy interface
|
|
8330
|
-
*/
|
|
8331
|
-
getProvider(type) {
|
|
8332
|
-
const providerType = type || this.currentProviderType;
|
|
8333
|
-
const providerId = this.mapLegacyToModernType(providerType);
|
|
8334
|
-
const modernProvider = this.manager.getProvider(providerId);
|
|
8335
|
-
if (!modernProvider) {
|
|
8336
|
-
if (providerType === "template") {
|
|
8337
|
-
return new TemplateProviderShim();
|
|
8338
|
-
}
|
|
8339
|
-
return void 0;
|
|
8340
|
-
}
|
|
8341
|
-
return new ModernToLegacyProviderShim(modernProvider);
|
|
8342
|
-
}
|
|
8343
|
-
/**
|
|
8344
|
-
* Get active provider (legacy interface)
|
|
8345
|
-
*/
|
|
8346
|
-
async getActiveProvider() {
|
|
8347
|
-
try {
|
|
8348
|
-
const modernProvider = await this.manager.pick();
|
|
8349
|
-
return new ModernToLegacyProviderShim(modernProvider);
|
|
8350
|
-
} catch {
|
|
8351
|
-
return new TemplateProviderShim();
|
|
8352
|
-
}
|
|
8353
|
-
}
|
|
8354
|
-
/**
|
|
8355
|
-
* Set active provider (legacy interface)
|
|
8356
|
-
*/
|
|
8357
|
-
setActiveProvider(type) {
|
|
8358
|
-
this.currentProviderType = type;
|
|
8359
|
-
const providerId = this.mapLegacyToModernType(type);
|
|
8360
|
-
try {
|
|
8361
|
-
this.manager.setActiveProvider(providerId);
|
|
8362
|
-
} catch {
|
|
8363
|
-
}
|
|
8364
|
-
}
|
|
8365
|
-
/**
|
|
8366
|
-
* Get available providers (legacy interface)
|
|
8367
|
-
*/
|
|
8368
|
-
getAvailableProviders() {
|
|
8369
|
-
const modernProviders = this.manager.getAvailableProviders();
|
|
8370
|
-
return modernProviders.map((id) => this.mapModernToLegacyType(id)).filter((type) => type !== null);
|
|
8371
|
-
}
|
|
8372
|
-
/**
|
|
8373
|
-
* Clear providers (legacy interface)
|
|
8374
|
-
*/
|
|
8375
|
-
clearProviders() {
|
|
8376
|
-
this.manager = new UnifiedAIProviderManager2();
|
|
8377
|
-
this.currentProviderType = "template";
|
|
8378
|
-
}
|
|
8379
|
-
/**
|
|
8380
|
-
* Map legacy provider types to modern provider IDs
|
|
8381
|
-
*/
|
|
8382
|
-
mapLegacyToModernType(legacyType) {
|
|
8383
|
-
const mapping = {
|
|
8384
|
-
openai: "openai",
|
|
8385
|
-
anthropic: "anthropic",
|
|
8386
|
-
groq: "groq",
|
|
8387
|
-
ollama: "ollama",
|
|
8388
|
-
template: "openai"
|
|
8389
|
-
// Default fallback
|
|
8390
|
-
};
|
|
8391
|
-
return mapping[legacyType] || "openai";
|
|
8392
|
-
}
|
|
8393
|
-
/**
|
|
8394
|
-
* Map modern provider IDs to legacy provider types
|
|
8395
|
-
*/
|
|
8396
|
-
mapModernToLegacyType(modernId) {
|
|
8397
|
-
const mapping = {
|
|
8398
|
-
openai: "openai",
|
|
8399
|
-
anthropic: "anthropic",
|
|
8400
|
-
google: null,
|
|
8401
|
-
// Not supported in legacy
|
|
8402
|
-
groq: "groq",
|
|
8403
|
-
grok: null,
|
|
8404
|
-
// Not supported in legacy
|
|
8405
|
-
ollama: "ollama",
|
|
8406
|
-
lmstudio: null,
|
|
8407
|
-
// Not supported in legacy
|
|
8408
|
-
vllm: null
|
|
8409
|
-
// Not supported in legacy
|
|
8410
|
-
};
|
|
8411
|
-
return mapping[modernId] || null;
|
|
8412
|
-
}
|
|
8413
|
-
};
|
|
8414
|
-
ModernToLegacyProviderShim = class {
|
|
8415
|
-
constructor(modernProvider) {
|
|
8416
|
-
this.modernProvider = modernProvider;
|
|
8417
|
-
}
|
|
8418
|
-
get name() {
|
|
8419
|
-
return this.modernProvider.name;
|
|
8420
|
-
}
|
|
8421
|
-
async initialize(config2) {
|
|
8422
|
-
}
|
|
8423
|
-
async generateCompletion(request) {
|
|
8424
|
-
const prompt = this.convertMessagesToPrompt(request.messages || []);
|
|
8425
|
-
const modernRequest = {
|
|
8426
|
-
model: request.model,
|
|
8427
|
-
temperature: request.temperature,
|
|
8428
|
-
maxTokens: request.maxTokens,
|
|
8429
|
-
stream: false
|
|
8430
|
-
};
|
|
8431
|
-
const modernResponse = await this.modernProvider.complete(
|
|
8432
|
-
prompt,
|
|
8433
|
-
modernRequest
|
|
8434
|
-
);
|
|
8435
|
-
return {
|
|
8436
|
-
content: modernResponse.content,
|
|
8437
|
-
model: modernResponse.model || request.model || "unknown",
|
|
8438
|
-
usage: modernResponse.usage,
|
|
8439
|
-
finishReason: modernResponse.finishReason
|
|
8440
|
-
};
|
|
8441
|
-
}
|
|
8442
|
-
async streamCompletion(request, onChunk) {
|
|
8443
|
-
const prompt = this.convertMessagesToPrompt(request.messages || []);
|
|
8444
|
-
const modernRequest = {
|
|
8445
|
-
model: request.model,
|
|
8446
|
-
temperature: request.temperature,
|
|
8447
|
-
maxTokens: request.maxTokens,
|
|
8448
|
-
stream: true
|
|
8449
|
-
};
|
|
8450
|
-
const stream = await this.modernProvider.stream(prompt, modernRequest);
|
|
8451
|
-
let fullContent = "";
|
|
8452
|
-
for await (const chunk of stream) {
|
|
8453
|
-
fullContent += chunk.content;
|
|
8454
|
-
onChunk(chunk.content);
|
|
8455
|
-
}
|
|
8456
|
-
return {
|
|
8457
|
-
content: fullContent,
|
|
8458
|
-
model: request.model || "unknown",
|
|
8459
|
-
finishReason: "stop"
|
|
8460
|
-
};
|
|
8461
|
-
}
|
|
8462
|
-
isAvailable() {
|
|
8463
|
-
return true;
|
|
8464
|
-
}
|
|
8465
|
-
getAvailableModels() {
|
|
8466
|
-
return [];
|
|
8467
|
-
}
|
|
8468
|
-
/**
|
|
8469
|
-
* Convert legacy message format to simple prompt
|
|
8470
|
-
*/
|
|
8471
|
-
convertMessagesToPrompt(messages) {
|
|
8472
|
-
return messages.map((msg) => `${msg.role}: ${msg.content}`).join("\n");
|
|
8473
|
-
}
|
|
8474
|
-
};
|
|
8475
|
-
TemplateProviderShim = class {
|
|
8476
|
-
name = "Template Provider";
|
|
8477
|
-
async initialize(_config) {
|
|
8478
|
-
}
|
|
8479
|
-
async generateCompletion(request) {
|
|
8480
|
-
const prompt = request.messages?.map((m2) => m2.content).join(" ") || "No input";
|
|
8481
|
-
const templateResponse = this.generateTemplateResponse(prompt);
|
|
8482
|
-
return {
|
|
8483
|
-
content: templateResponse,
|
|
8484
|
-
model: "template",
|
|
8485
|
-
finishReason: "stop"
|
|
8486
|
-
};
|
|
8487
|
-
}
|
|
8488
|
-
async streamCompletion(request, onChunk) {
|
|
8489
|
-
const response2 = await this.generateCompletion(request);
|
|
8490
|
-
const chunks = this.chunkText(response2.content, 20);
|
|
8491
|
-
for (const chunk of chunks) {
|
|
8492
|
-
onChunk(chunk);
|
|
8493
|
-
await this.delay(50);
|
|
8494
|
-
}
|
|
8495
|
-
return response2;
|
|
8496
|
-
}
|
|
8497
|
-
isAvailable() {
|
|
8498
|
-
return true;
|
|
8499
|
-
}
|
|
8500
|
-
getAvailableModels() {
|
|
8501
|
-
return ["template"];
|
|
8502
|
-
}
|
|
8503
|
-
generateTemplateResponse(prompt) {
|
|
8504
|
-
const responses = [
|
|
8505
|
-
`I understand you're asking about: ${prompt}. Here's a helpful response based on the available information.`,
|
|
8506
|
-
`Regarding "${prompt}" - I can provide some guidance on this topic.`,
|
|
8507
|
-
`Thank you for your question about "${prompt}". Let me help you with that.`
|
|
8508
|
-
];
|
|
8509
|
-
return responses[Math.floor(Math.random() * responses.length)];
|
|
8510
|
-
}
|
|
8511
|
-
chunkText(text, wordsPerChunk) {
|
|
8512
|
-
const words = text.split(" ");
|
|
8513
|
-
const chunks = [];
|
|
8514
|
-
for (let i2 = 0; i2 < words.length; i2 += wordsPerChunk) {
|
|
8515
|
-
chunks.push(words.slice(i2, i2 + wordsPerChunk).join(" ") + " ");
|
|
8516
|
-
}
|
|
8517
|
-
return chunks;
|
|
8518
|
-
}
|
|
8519
|
-
delay(ms) {
|
|
8520
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
8521
|
-
}
|
|
8522
|
-
};
|
|
8523
|
-
}
|
|
8524
|
-
});
|
|
8525
|
-
|
|
8526
8321
|
// src/providers/index.ts
|
|
8527
8322
|
var init_providers = __esm({
|
|
8528
8323
|
"src/providers/index.ts"() {
|
|
8529
8324
|
init_config();
|
|
8530
8325
|
init_manager();
|
|
8531
|
-
init_legacy_adapter();
|
|
8532
8326
|
}
|
|
8533
8327
|
});
|
|
8534
8328
|
|
|
@@ -9370,15 +9164,13 @@ var init_ai_response_service = __esm({
|
|
|
9370
9164
|
_conversationPersistence;
|
|
9371
9165
|
telemetry;
|
|
9372
9166
|
initialized = false;
|
|
9373
|
-
//
|
|
9374
|
-
|
|
9375
|
-
legacyProviderFactory;
|
|
9167
|
+
// V2.0 Provider System (Modern Only)
|
|
9168
|
+
providerManager;
|
|
9376
9169
|
constructor() {
|
|
9377
9170
|
this.chatContext = ChatContextService.getInstance();
|
|
9378
9171
|
this._conversationPersistence = new ConversationPersistence();
|
|
9379
9172
|
this.telemetry = TelemetryCollector.getInstance();
|
|
9380
|
-
this.
|
|
9381
|
-
this.legacyProviderFactory = LegacyAIProviderFactory2.getInstance();
|
|
9173
|
+
this.providerManager = new UnifiedAIProviderManager2();
|
|
9382
9174
|
this.initializeProviders().catch(console.error);
|
|
9383
9175
|
}
|
|
9384
9176
|
/**
|
|
@@ -9388,18 +9180,9 @@ var init_ai_response_service = __esm({
|
|
|
9388
9180
|
async initializeProviders() {
|
|
9389
9181
|
if (this.initialized) return;
|
|
9390
9182
|
try {
|
|
9391
|
-
|
|
9392
|
-
await this.legacyProviderFactory.initializeFromEnvironment();
|
|
9393
|
-
} else {
|
|
9394
|
-
await this.modernProviderManager.initialize();
|
|
9395
|
-
}
|
|
9183
|
+
await this.providerManager.initialize();
|
|
9396
9184
|
this.initialized = true;
|
|
9397
9185
|
} catch (error) {
|
|
9398
|
-
try {
|
|
9399
|
-
await this.legacyProviderFactory.initializeFromEnvironment();
|
|
9400
|
-
this.initialized = true;
|
|
9401
|
-
} catch (fallbackError) {
|
|
9402
|
-
}
|
|
9403
9186
|
}
|
|
9404
9187
|
}
|
|
9405
9188
|
/**
|
|
@@ -9410,14 +9193,10 @@ var init_ai_response_service = __esm({
|
|
|
9410
9193
|
if (!this.initialized) {
|
|
9411
9194
|
await this.initializeProviders();
|
|
9412
9195
|
}
|
|
9413
|
-
|
|
9414
|
-
return this.
|
|
9415
|
-
}
|
|
9416
|
-
|
|
9417
|
-
return await this.modernProviderManager.pick(DEFAULT_PROVIDER2);
|
|
9418
|
-
} catch (error) {
|
|
9419
|
-
return this.legacyProviderFactory.getActiveProvider();
|
|
9420
|
-
}
|
|
9196
|
+
try {
|
|
9197
|
+
return await this.providerManager.pick(DEFAULT_PROVIDER2);
|
|
9198
|
+
} catch (error) {
|
|
9199
|
+
throw new Error(`Provider initialization failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
9421
9200
|
}
|
|
9422
9201
|
}
|
|
9423
9202
|
/**
|
|
@@ -9690,7 +9469,7 @@ I'm here to assist you effectively!`;
|
|
|
9690
9469
|
delay = 80;
|
|
9691
9470
|
}
|
|
9692
9471
|
if (i2 < lines.length - 1) {
|
|
9693
|
-
await new Promise((
|
|
9472
|
+
await new Promise((resolve4) => setTimeout(resolve4, delay));
|
|
9694
9473
|
}
|
|
9695
9474
|
}
|
|
9696
9475
|
}
|
|
@@ -9791,52 +9570,1754 @@ var init_SlashCommandHandler = __esm({
|
|
|
9791
9570
|
const resolvedName = this.aliases.get(name2) || name2;
|
|
9792
9571
|
return this.commands.get(resolvedName);
|
|
9793
9572
|
}
|
|
9794
|
-
/**
|
|
9795
|
-
* Search commands by pattern
|
|
9796
|
-
*/
|
|
9797
|
-
searchCommands(pattern2) {
|
|
9798
|
-
const lowercasePattern = pattern2.toLowerCase();
|
|
9799
|
-
return this.listCommands().filter(
|
|
9800
|
-
(cmd) => cmd.name.toLowerCase().includes(lowercasePattern) || cmd.description.toLowerCase().includes(lowercasePattern)
|
|
9801
|
-
);
|
|
9573
|
+
/**
|
|
9574
|
+
* Search commands by pattern
|
|
9575
|
+
*/
|
|
9576
|
+
searchCommands(pattern2) {
|
|
9577
|
+
const lowercasePattern = pattern2.toLowerCase();
|
|
9578
|
+
return this.listCommands().filter(
|
|
9579
|
+
(cmd) => cmd.name.toLowerCase().includes(lowercasePattern) || cmd.description.toLowerCase().includes(lowercasePattern)
|
|
9580
|
+
);
|
|
9581
|
+
}
|
|
9582
|
+
/**
|
|
9583
|
+
* Get commands by category
|
|
9584
|
+
*/
|
|
9585
|
+
getCommandsByCategory(category) {
|
|
9586
|
+
return this.listCommands().filter((cmd) => cmd.category === category);
|
|
9587
|
+
}
|
|
9588
|
+
/**
|
|
9589
|
+
* Get all categories
|
|
9590
|
+
*/
|
|
9591
|
+
getCategories() {
|
|
9592
|
+
const categories = /* @__PURE__ */ new Set();
|
|
9593
|
+
for (const command of this.commands.values()) {
|
|
9594
|
+
categories.add(command.category);
|
|
9595
|
+
}
|
|
9596
|
+
return Array.from(categories);
|
|
9597
|
+
}
|
|
9598
|
+
/**
|
|
9599
|
+
* Validate command arguments
|
|
9600
|
+
*/
|
|
9601
|
+
validateArgs(commandName, args) {
|
|
9602
|
+
const command = this.getCommand(commandName);
|
|
9603
|
+
if (!command) return false;
|
|
9604
|
+
return true;
|
|
9605
|
+
}
|
|
9606
|
+
/**
|
|
9607
|
+
* Create a helper context for testing
|
|
9608
|
+
*/
|
|
9609
|
+
static createTestContext(deps, overrides) {
|
|
9610
|
+
return {
|
|
9611
|
+
command: "test",
|
|
9612
|
+
args: [],
|
|
9613
|
+
options: {},
|
|
9614
|
+
deps,
|
|
9615
|
+
signal: void 0,
|
|
9616
|
+
...overrides
|
|
9617
|
+
};
|
|
9618
|
+
}
|
|
9619
|
+
};
|
|
9620
|
+
}
|
|
9621
|
+
});
|
|
9622
|
+
var LogLevel, Logger, logger, envLogLevel;
|
|
9623
|
+
var init_logger = __esm({
|
|
9624
|
+
"src/utils/logger.ts"() {
|
|
9625
|
+
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
9626
|
+
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
9627
|
+
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
9628
|
+
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
9629
|
+
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
9630
|
+
LogLevel2[LogLevel2["NONE"] = 4] = "NONE";
|
|
9631
|
+
return LogLevel2;
|
|
9632
|
+
})(LogLevel || {});
|
|
9633
|
+
Logger = class {
|
|
9634
|
+
level = 2 /* WARN */;
|
|
9635
|
+
// Default to WARN to reduce noise
|
|
9636
|
+
prefix = "[MARIA CODE]";
|
|
9637
|
+
setLevel(level) {
|
|
9638
|
+
this.level = level;
|
|
9639
|
+
}
|
|
9640
|
+
debug(...args) {
|
|
9641
|
+
if (this.level <= 0 /* DEBUG */) {
|
|
9642
|
+
console.log(chalk13__default.default.magenta(`${this.prefix} [DEBUG]`), ...args);
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
info(...args) {
|
|
9646
|
+
if (this.level <= 1 /* INFO */) {
|
|
9647
|
+
console.log(chalk13__default.default.bold.magenta(`${this.prefix} [INFO]`), ...args);
|
|
9648
|
+
}
|
|
9649
|
+
}
|
|
9650
|
+
warn(...args) {
|
|
9651
|
+
if (this.level <= 2 /* WARN */) {
|
|
9652
|
+
console.warn(chalk13__default.default.bold.magenta(`${this.prefix} [WARN]`), ...args);
|
|
9653
|
+
}
|
|
9654
|
+
}
|
|
9655
|
+
error(...args) {
|
|
9656
|
+
if (this.level <= 3 /* ERROR */) {
|
|
9657
|
+
console.error(chalk13__default.default.bold.magenta(`${this.prefix} [ERROR]`), ...args);
|
|
9658
|
+
}
|
|
9659
|
+
}
|
|
9660
|
+
success(...args) {
|
|
9661
|
+
if (this.level <= 1 /* INFO */) {
|
|
9662
|
+
console.log(chalk13__default.default.bold.magenta(`${this.prefix} [SUCCESS]`), ...args);
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
task(taskName, status, message) {
|
|
9666
|
+
if (this.level > 1 /* INFO */) {
|
|
9667
|
+
return;
|
|
9668
|
+
}
|
|
9669
|
+
const statusIcons = {
|
|
9670
|
+
start: "\u{1F680}",
|
|
9671
|
+
progress: "\u23F3",
|
|
9672
|
+
complete: "\u2705",
|
|
9673
|
+
error: "\u274C"
|
|
9674
|
+
};
|
|
9675
|
+
const statusColors = {
|
|
9676
|
+
start: chalk13__default.default.bold.magenta,
|
|
9677
|
+
progress: chalk13__default.default.magenta,
|
|
9678
|
+
complete: chalk13__default.default.bold.magenta,
|
|
9679
|
+
error: chalk13__default.default.bold.magenta
|
|
9680
|
+
};
|
|
9681
|
+
const icon = statusIcons[status];
|
|
9682
|
+
const color = statusColors[status];
|
|
9683
|
+
const formattedMessage = message ? `: ${message}` : "";
|
|
9684
|
+
console.log(color(`${this.prefix} ${icon} ${taskName}${formattedMessage}`));
|
|
9685
|
+
}
|
|
9686
|
+
table(data2) {
|
|
9687
|
+
if (this.level > 1 /* INFO */) {
|
|
9688
|
+
return;
|
|
9689
|
+
}
|
|
9690
|
+
console.table(data2);
|
|
9691
|
+
}
|
|
9692
|
+
json(obj, pretty = true) {
|
|
9693
|
+
if (this.level > 0 /* DEBUG */) {
|
|
9694
|
+
return;
|
|
9695
|
+
}
|
|
9696
|
+
console.log(chalk13__default.default.magenta(`${this.prefix} [JSON]`));
|
|
9697
|
+
console.log(pretty ? JSON.stringify(obj, null, 2) : JSON.stringify(obj));
|
|
9698
|
+
}
|
|
9699
|
+
divider() {
|
|
9700
|
+
if (this.level > 1 /* INFO */) {
|
|
9701
|
+
return;
|
|
9702
|
+
}
|
|
9703
|
+
console.log(chalk13__default.default.magenta("\u2500".repeat(60)));
|
|
9704
|
+
}
|
|
9705
|
+
clear() {
|
|
9706
|
+
console.clear();
|
|
9707
|
+
}
|
|
9708
|
+
/**
|
|
9709
|
+
* プログレスバーを表示
|
|
9710
|
+
*/
|
|
9711
|
+
progress(current, total, label) {
|
|
9712
|
+
if (this.level > 1 /* INFO */) {
|
|
9713
|
+
return;
|
|
9714
|
+
}
|
|
9715
|
+
const percentage = Math.round(current / total * 100);
|
|
9716
|
+
const barLength = 30;
|
|
9717
|
+
const filled = Math.round(percentage / 100 * barLength);
|
|
9718
|
+
const empty = barLength - filled;
|
|
9719
|
+
const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
|
|
9720
|
+
const progressText = `${current}/${total}`;
|
|
9721
|
+
const labelText = label ? ` ${label}` : "";
|
|
9722
|
+
process.stdout.write(
|
|
9723
|
+
`\r${chalk13__default.default.bold.magenta(bar)} ${percentage}% ${progressText}${labelText}`
|
|
9724
|
+
);
|
|
9725
|
+
if (current === total) {
|
|
9726
|
+
process.stdout.write("\n");
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
};
|
|
9730
|
+
logger = new Logger();
|
|
9731
|
+
envLogLevel = process.env["MARIA_LOG_LEVEL"]?.toUpperCase();
|
|
9732
|
+
if (envLogLevel && LogLevel[envLogLevel] !== void 0) {
|
|
9733
|
+
logger.setLevel(LogLevel[envLogLevel]);
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
});
|
|
9737
|
+
|
|
9738
|
+
// src/slash-commands/base-command.ts
|
|
9739
|
+
var BaseCommand;
|
|
9740
|
+
var init_base_command = __esm({
|
|
9741
|
+
"src/slash-commands/base-command.ts"() {
|
|
9742
|
+
init_logger();
|
|
9743
|
+
BaseCommand = class {
|
|
9744
|
+
// Optional properties with defaults
|
|
9745
|
+
aliases = [];
|
|
9746
|
+
usage = "";
|
|
9747
|
+
examples = [];
|
|
9748
|
+
permissions;
|
|
9749
|
+
middleware = [];
|
|
9750
|
+
rateLimit;
|
|
9751
|
+
// Metadata with defaults
|
|
9752
|
+
metadata = {
|
|
9753
|
+
version: "1.0.0",
|
|
9754
|
+
author: "MARIA Team",
|
|
9755
|
+
deprecated: false,
|
|
9756
|
+
experimental: false
|
|
9757
|
+
};
|
|
9758
|
+
// Cache for frequently used data
|
|
9759
|
+
cache = /* @__PURE__ */ new Map();
|
|
9760
|
+
/**
|
|
9761
|
+
* Initialize the command (called once when registered)
|
|
9762
|
+
*/
|
|
9763
|
+
async initialize() {
|
|
9764
|
+
logger.debug(`Initializing command: ${this.name}`);
|
|
9765
|
+
}
|
|
9766
|
+
/**
|
|
9767
|
+
* Validate command arguments
|
|
9768
|
+
*/
|
|
9769
|
+
async validate(_args) {
|
|
9770
|
+
return { success: true };
|
|
9771
|
+
}
|
|
9772
|
+
/**
|
|
9773
|
+
* Cleanup resources (called when command is unregistered)
|
|
9774
|
+
*/
|
|
9775
|
+
async cleanup() {
|
|
9776
|
+
this.cache.clear();
|
|
9777
|
+
logger.debug(`Cleanup command: ${this.name}`);
|
|
9778
|
+
}
|
|
9779
|
+
/**
|
|
9780
|
+
* Rollback on error - override for custom rollback logic
|
|
9781
|
+
*/
|
|
9782
|
+
async rollback(_context, error) {
|
|
9783
|
+
logger.error(`Rollback for ${this.name}:`, error);
|
|
9784
|
+
}
|
|
9785
|
+
// Helper methods for subclasses
|
|
9786
|
+
/**
|
|
9787
|
+
* Parse command arguments into structured format
|
|
9788
|
+
*/
|
|
9789
|
+
parseArgs(raw) {
|
|
9790
|
+
const args = {
|
|
9791
|
+
raw,
|
|
9792
|
+
parsed: Record,
|
|
9793
|
+
flags: Record,
|
|
9794
|
+
options: Record
|
|
9795
|
+
};
|
|
9796
|
+
for (let i2 = 0; i2 < raw.length; i2++) {
|
|
9797
|
+
const _arg = raw[i2];
|
|
9798
|
+
if (!_arg) {
|
|
9799
|
+
continue;
|
|
9800
|
+
}
|
|
9801
|
+
if (_arg.startsWith("--")) {
|
|
9802
|
+
const _key = _arg.slice(2);
|
|
9803
|
+
const _nextArg = raw[i2 + 1];
|
|
9804
|
+
if (_nextArg && !_nextArg.startsWith("-")) {
|
|
9805
|
+
args.options[_key] = _nextArg;
|
|
9806
|
+
i2++;
|
|
9807
|
+
} else {
|
|
9808
|
+
args.flags[_key] = true;
|
|
9809
|
+
}
|
|
9810
|
+
} else if (_arg && _arg.startsWith("-") && _arg.length === 2) {
|
|
9811
|
+
args.flags[_arg.slice(1)] = true;
|
|
9812
|
+
} else {
|
|
9813
|
+
if (!args.parsed["positional"]) {
|
|
9814
|
+
args.parsed["positional"] = [];
|
|
9815
|
+
}
|
|
9816
|
+
args.parsed["positional"].push(_arg);
|
|
9817
|
+
}
|
|
9818
|
+
}
|
|
9819
|
+
return args;
|
|
9820
|
+
}
|
|
9821
|
+
/**
|
|
9822
|
+
* Create a success response
|
|
9823
|
+
*/
|
|
9824
|
+
success(message, data2, metadata) {
|
|
9825
|
+
return {
|
|
9826
|
+
success: true,
|
|
9827
|
+
message,
|
|
9828
|
+
data: data2,
|
|
9829
|
+
metadata: {
|
|
9830
|
+
executionTime: Date.now(),
|
|
9831
|
+
commandVersion: this.metadata.version,
|
|
9832
|
+
...metadata
|
|
9833
|
+
}
|
|
9834
|
+
};
|
|
9835
|
+
}
|
|
9836
|
+
/**
|
|
9837
|
+
* Create an error response
|
|
9838
|
+
*/
|
|
9839
|
+
error(message, code, details) {
|
|
9840
|
+
return {
|
|
9841
|
+
success: false,
|
|
9842
|
+
message,
|
|
9843
|
+
data: { code, details },
|
|
9844
|
+
metadata: {
|
|
9845
|
+
executionTime: Date.now(),
|
|
9846
|
+
commandVersion: this.metadata.version
|
|
9847
|
+
}
|
|
9848
|
+
};
|
|
9849
|
+
}
|
|
9850
|
+
/**
|
|
9851
|
+
* Cache data with TTL
|
|
9852
|
+
*/
|
|
9853
|
+
setCache(_key, data2, ttlSeconds = 60) {
|
|
9854
|
+
this.cache.set(_key, {
|
|
9855
|
+
data: data2,
|
|
9856
|
+
expires: Date.now() + ttlSeconds * 1e3
|
|
9857
|
+
});
|
|
9858
|
+
}
|
|
9859
|
+
/**
|
|
9860
|
+
* Get _cached data
|
|
9861
|
+
*/
|
|
9862
|
+
getCache(_key) {
|
|
9863
|
+
const _cached = this.cache.get(_key);
|
|
9864
|
+
if (!_cached) {
|
|
9865
|
+
return null;
|
|
9866
|
+
}
|
|
9867
|
+
if (_cached.expires < Date.now()) {
|
|
9868
|
+
this.cache.delete(_key);
|
|
9869
|
+
return null;
|
|
9870
|
+
}
|
|
9871
|
+
return _cached.data;
|
|
9872
|
+
}
|
|
9873
|
+
/**
|
|
9874
|
+
* Check if user has required permissions
|
|
9875
|
+
*/
|
|
9876
|
+
async checkPermissions(context2) {
|
|
9877
|
+
if (!this.permissions) {
|
|
9878
|
+
return { success: true };
|
|
9879
|
+
}
|
|
9880
|
+
const { requiresAuth, requiresPremium, role } = this.permissions;
|
|
9881
|
+
if (requiresAuth && !context2.user) {
|
|
9882
|
+
return {
|
|
9883
|
+
success: false,
|
|
9884
|
+
error: "Authentication required",
|
|
9885
|
+
suggestions: ["Run /login to authenticate"]
|
|
9886
|
+
};
|
|
9887
|
+
}
|
|
9888
|
+
if (role && context2.user?.role !== role) {
|
|
9889
|
+
return {
|
|
9890
|
+
success: false,
|
|
9891
|
+
error: `Required role: ${role}`,
|
|
9892
|
+
suggestions: [`Contact admin for ${role} access`]
|
|
9893
|
+
};
|
|
9894
|
+
}
|
|
9895
|
+
if (requiresPremium) {
|
|
9896
|
+
logger.warn("Premium check not implemented");
|
|
9897
|
+
}
|
|
9898
|
+
return { success: true };
|
|
9899
|
+
}
|
|
9900
|
+
/**
|
|
9901
|
+
* Format help text for this command
|
|
9902
|
+
*/
|
|
9903
|
+
formatHelp() {
|
|
9904
|
+
const lines = [];
|
|
9905
|
+
lines.push(`\u{1F4D8} ${this.name.toUpperCase()}`);
|
|
9906
|
+
lines.push("\u2500".repeat(40));
|
|
9907
|
+
lines.push(`
|
|
9908
|
+
${this.description}
|
|
9909
|
+
`);
|
|
9910
|
+
if (this.usage) {
|
|
9911
|
+
lines.push("**Usage:**");
|
|
9912
|
+
lines.push(` /${this.name} ${this.usage}
|
|
9913
|
+
`);
|
|
9914
|
+
}
|
|
9915
|
+
if (this.aliases && this.aliases.length > 0) {
|
|
9916
|
+
lines.push("**Aliases:**");
|
|
9917
|
+
lines.push(` ${this.aliases.map((a2) => `/${a2}`).join(", ")}
|
|
9918
|
+
`);
|
|
9919
|
+
}
|
|
9920
|
+
if (this.examples.length > 0) {
|
|
9921
|
+
lines.push("**Examples:**");
|
|
9922
|
+
this.examples.forEach((ex) => {
|
|
9923
|
+
lines.push(` ${ex.input}`);
|
|
9924
|
+
lines.push(` ${ex.description}`);
|
|
9925
|
+
if (ex.output) {
|
|
9926
|
+
lines.push(` \u2192 ${ex.output}`);
|
|
9927
|
+
}
|
|
9928
|
+
});
|
|
9929
|
+
lines.push("");
|
|
9930
|
+
}
|
|
9931
|
+
if (this.permissions) {
|
|
9932
|
+
lines.push("**Requirements:**");
|
|
9933
|
+
if (this.permissions.requiresAuth) {
|
|
9934
|
+
lines.push(" \u2022 Authentication required");
|
|
9935
|
+
}
|
|
9936
|
+
if (this.permissions.role) {
|
|
9937
|
+
lines.push(` \u2022 Role: ${this.permissions.role}`);
|
|
9938
|
+
}
|
|
9939
|
+
if (this.permissions.requiresPremium) {
|
|
9940
|
+
lines.push(" \u2022 Premium subscription");
|
|
9941
|
+
}
|
|
9942
|
+
lines.push("");
|
|
9943
|
+
}
|
|
9944
|
+
if (this.metadata.experimental) {
|
|
9945
|
+
lines.push("\u26A0\uFE0F **Experimental Feature**");
|
|
9946
|
+
}
|
|
9947
|
+
if (this.metadata.deprecated) {
|
|
9948
|
+
lines.push(
|
|
9949
|
+
`\u26A0\uFE0F **Deprecated** - Use ${this.metadata.replacedBy || "alternative"} instead`
|
|
9950
|
+
);
|
|
9951
|
+
}
|
|
9952
|
+
return lines.join("\n");
|
|
9953
|
+
}
|
|
9954
|
+
/**
|
|
9955
|
+
* Log command execution
|
|
9956
|
+
*/
|
|
9957
|
+
logExecution(args, context2, result) {
|
|
9958
|
+
const _logData = {
|
|
9959
|
+
command: this.name,
|
|
9960
|
+
args: args.raw,
|
|
9961
|
+
user: context2.user?.id,
|
|
9962
|
+
success: result.success,
|
|
9963
|
+
executionTime: result.metadata?.executionTime
|
|
9964
|
+
};
|
|
9965
|
+
if (result.success) {
|
|
9966
|
+
logger.info("Command executed", _logData);
|
|
9967
|
+
} else {
|
|
9968
|
+
logger.error("Command failed", { ..._logData, error: result.message });
|
|
9969
|
+
}
|
|
9970
|
+
}
|
|
9971
|
+
};
|
|
9972
|
+
}
|
|
9973
|
+
});
|
|
9974
|
+
|
|
9975
|
+
// src/slash-commands/help/metadata-validator.ts
|
|
9976
|
+
function validateHelpMetadata(container, opts = {}) {
|
|
9977
|
+
const errors = [];
|
|
9978
|
+
const warnings = [];
|
|
9979
|
+
if (!isObject(container)) {
|
|
9980
|
+
return fail("container is not an object");
|
|
9981
|
+
}
|
|
9982
|
+
const c = container;
|
|
9983
|
+
if (!isInt(c.schemaVersion)) errors.push("schemaVersion must be an integer");
|
|
9984
|
+
if (!isISO(c.generatedAt)) errors.push("generatedAt must be ISO-8601 string");
|
|
9985
|
+
if (!Array.isArray(c.commands)) errors.push("commands must be an array");
|
|
9986
|
+
const expected = opts.expectedSchemaVersion;
|
|
9987
|
+
if (expected != null && c.schemaVersion !== expected) {
|
|
9988
|
+
warnings.push(
|
|
9989
|
+
`schemaVersion mismatch: meta=${c.schemaVersion}, expected=${expected}`
|
|
9990
|
+
);
|
|
9991
|
+
}
|
|
9992
|
+
if (errors.length) {
|
|
9993
|
+
return {
|
|
9994
|
+
ok: false,
|
|
9995
|
+
errors,
|
|
9996
|
+
warnings,
|
|
9997
|
+
counts: { commands: 0, categories: 0 }
|
|
9998
|
+
};
|
|
9999
|
+
}
|
|
10000
|
+
const cmds = c.commands;
|
|
10001
|
+
if (cmds.length === 0) errors.push("commands array is empty");
|
|
10002
|
+
const nameSet = /* @__PURE__ */ new Set();
|
|
10003
|
+
const aliasSet = /* @__PURE__ */ new Set();
|
|
10004
|
+
const categorySet = /* @__PURE__ */ new Set();
|
|
10005
|
+
for (const m2 of cmds) {
|
|
10006
|
+
if (!m2 || !isObject(m2)) {
|
|
10007
|
+
errors.push("command entry is not an object");
|
|
10008
|
+
continue;
|
|
10009
|
+
}
|
|
10010
|
+
if (!isString(m2.name) || !m2.name.startsWith("/")) {
|
|
10011
|
+
errors.push(`invalid name: ${JSON.stringify(m2?.name)}`);
|
|
10012
|
+
} else if (nameSet.has(m2.name)) {
|
|
10013
|
+
errors.push(`duplicated name: ${m2.name}`);
|
|
10014
|
+
} else {
|
|
10015
|
+
nameSet.add(m2.name);
|
|
10016
|
+
}
|
|
10017
|
+
if (!isString(m2.category) || !m2.category.trim()) {
|
|
10018
|
+
errors.push(`invalid category for ${m2.name}`);
|
|
10019
|
+
} else {
|
|
10020
|
+
categorySet.add(m2.category);
|
|
10021
|
+
}
|
|
10022
|
+
if (!ALLOWED_LEVEL.includes(m2.level)) {
|
|
10023
|
+
errors.push(`invalid level for ${m2.name}: ${m2.level}`);
|
|
10024
|
+
}
|
|
10025
|
+
if (m2.tags) {
|
|
10026
|
+
for (const t2 of m2.tags) {
|
|
10027
|
+
if (!ALLOWED_TAGS.includes(t2)) {
|
|
10028
|
+
errors.push(`invalid tag "${t2}" on ${m2.name}`);
|
|
10029
|
+
}
|
|
10030
|
+
}
|
|
10031
|
+
}
|
|
10032
|
+
if (m2.usage) {
|
|
10033
|
+
if (m2.usage.count != null && (!isInt(m2.usage.count) || m2.usage.count < 0)) {
|
|
10034
|
+
errors.push(`usage.count must be non-negative int on ${m2.name}`);
|
|
10035
|
+
}
|
|
10036
|
+
if (m2.usage.frequency != null && !(typeof m2.usage.frequency === "number" && m2.usage.frequency >= 0)) {
|
|
10037
|
+
errors.push(`usage.frequency must be non-negative number on ${m2.name}`);
|
|
10038
|
+
}
|
|
10039
|
+
if (m2.usage.lastUsed != null && !isISO(m2.usage.lastUsed)) {
|
|
10040
|
+
errors.push(`usage.lastUsed must be ISO-8601 on ${m2.name}`);
|
|
10041
|
+
}
|
|
10042
|
+
}
|
|
10043
|
+
if (m2.aliases) {
|
|
10044
|
+
for (const a2 of m2.aliases) {
|
|
10045
|
+
if (!isString(a2) || !a2.startsWith("/")) {
|
|
10046
|
+
errors.push(
|
|
10047
|
+
`invalid alias "${a2}" on ${m2.name} (must start with "/")`
|
|
10048
|
+
);
|
|
10049
|
+
continue;
|
|
10050
|
+
}
|
|
10051
|
+
if (nameSet.has(a2)) {
|
|
10052
|
+
errors.push(`alias conflicts with existing name: ${a2} on ${m2.name}`);
|
|
10053
|
+
continue;
|
|
10054
|
+
}
|
|
10055
|
+
if (aliasSet.has(a2)) {
|
|
10056
|
+
errors.push(`duplicated alias across commands: ${a2} on ${m2.name}`);
|
|
10057
|
+
continue;
|
|
10058
|
+
}
|
|
10059
|
+
aliasSet.add(a2);
|
|
10060
|
+
}
|
|
10061
|
+
}
|
|
10062
|
+
}
|
|
10063
|
+
const byName = new Map(cmds.map((m2) => [m2.name, m2]));
|
|
10064
|
+
for (const m2 of cmds) {
|
|
10065
|
+
if (m2.parent) {
|
|
10066
|
+
if (!byName.has(m2.parent)) {
|
|
10067
|
+
errors.push(`parent not found: ${m2.name} \u2192 ${m2.parent}`);
|
|
10068
|
+
}
|
|
10069
|
+
const computedDepth = computeDepth(m2, byName, errors);
|
|
10070
|
+
if (m2.depth != null && m2.depth !== computedDepth) {
|
|
10071
|
+
warnings.push(
|
|
10072
|
+
`depth mismatch on ${m2.name}: meta=${m2.depth} computed=${computedDepth}`
|
|
10073
|
+
);
|
|
10074
|
+
}
|
|
10075
|
+
if (opts.maxDepth != null && computedDepth > opts.maxDepth) {
|
|
10076
|
+
warnings.push(
|
|
10077
|
+
`depth exceeds maxDepth on ${m2.name}: ${computedDepth} > ${opts.maxDepth}`
|
|
10078
|
+
);
|
|
10079
|
+
}
|
|
10080
|
+
if (m2.level === "primary") {
|
|
10081
|
+
warnings.push(`command marked primary but has parent: ${m2.name}`);
|
|
10082
|
+
}
|
|
10083
|
+
} else {
|
|
10084
|
+
if (m2.depth != null && m2.depth !== 0) {
|
|
10085
|
+
warnings.push(`root command depth should be 0 on ${m2.name}`);
|
|
10086
|
+
}
|
|
10087
|
+
}
|
|
10088
|
+
}
|
|
10089
|
+
const seenGlobal = /* @__PURE__ */ new Set();
|
|
10090
|
+
for (const m2 of cmds) {
|
|
10091
|
+
if (seenGlobal.has(m2.name)) continue;
|
|
10092
|
+
const cycle = detectCycle(m2, byName);
|
|
10093
|
+
if (cycle) {
|
|
10094
|
+
errors.push(`cycle detected: ${cycle.join(" -> ")}`);
|
|
10095
|
+
}
|
|
10096
|
+
seenGlobal.add(m2.name);
|
|
10097
|
+
}
|
|
10098
|
+
if (c.stats) {
|
|
10099
|
+
if (c.stats.totalCommands != null && c.stats.totalCommands !== cmds.length) {
|
|
10100
|
+
warnings.push(
|
|
10101
|
+
`stats.totalCommands mismatch: meta=${c.stats.totalCommands} actual=${cmds.length}`
|
|
10102
|
+
);
|
|
10103
|
+
}
|
|
10104
|
+
if (c.stats.totalCategories != null && c.stats.totalCategories !== categorySet.size) {
|
|
10105
|
+
warnings.push(
|
|
10106
|
+
`stats.totalCategories mismatch: meta=${c.stats.totalCategories} actual=${categorySet.size}`
|
|
10107
|
+
);
|
|
10108
|
+
}
|
|
10109
|
+
if (c.stats.lastUpdated && !isISO(c.stats.lastUpdated)) {
|
|
10110
|
+
warnings.push(`stats.lastUpdated must be ISO-8601`);
|
|
10111
|
+
}
|
|
10112
|
+
}
|
|
10113
|
+
return {
|
|
10114
|
+
ok: errors.length === 0,
|
|
10115
|
+
errors,
|
|
10116
|
+
warnings,
|
|
10117
|
+
counts: {
|
|
10118
|
+
commands: cmds.length,
|
|
10119
|
+
categories: categorySet.size
|
|
10120
|
+
}
|
|
10121
|
+
};
|
|
10122
|
+
function fail(msg) {
|
|
10123
|
+
return {
|
|
10124
|
+
ok: false,
|
|
10125
|
+
errors: [msg],
|
|
10126
|
+
warnings: [],
|
|
10127
|
+
counts: { commands: 0, categories: 0 }
|
|
10128
|
+
};
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
function isObject(x2) {
|
|
10132
|
+
return !!x2 && typeof x2 === "object";
|
|
10133
|
+
}
|
|
10134
|
+
function isString(x2) {
|
|
10135
|
+
return typeof x2 === "string";
|
|
10136
|
+
}
|
|
10137
|
+
function isInt(x2) {
|
|
10138
|
+
return typeof x2 === "number" && Number.isInteger(x2);
|
|
10139
|
+
}
|
|
10140
|
+
function isISO(x2) {
|
|
10141
|
+
if (typeof x2 !== "string") return false;
|
|
10142
|
+
const d = new Date(x2);
|
|
10143
|
+
return !Number.isNaN(d.getTime()) && /^\d{4}-\d{2}-\d{2}T/.test(x2);
|
|
10144
|
+
}
|
|
10145
|
+
function computeDepth(node2, byName, errors) {
|
|
10146
|
+
let depth = 0;
|
|
10147
|
+
const visited2 = /* @__PURE__ */ new Set();
|
|
10148
|
+
let cur = node2;
|
|
10149
|
+
while (cur?.parent) {
|
|
10150
|
+
if (visited2.has(cur.name)) {
|
|
10151
|
+
errors.push(`cycle while computing depth at ${cur.name}`);
|
|
10152
|
+
break;
|
|
10153
|
+
}
|
|
10154
|
+
visited2.add(cur.name);
|
|
10155
|
+
const p = byName.get(cur.parent);
|
|
10156
|
+
if (!p) break;
|
|
10157
|
+
depth++;
|
|
10158
|
+
cur = p;
|
|
10159
|
+
if (depth > 1e3) {
|
|
10160
|
+
errors.push(`depth overflow at ${node2.name}`);
|
|
10161
|
+
break;
|
|
10162
|
+
}
|
|
10163
|
+
}
|
|
10164
|
+
return depth;
|
|
10165
|
+
}
|
|
10166
|
+
function detectCycle(start, byName) {
|
|
10167
|
+
const stack = [];
|
|
10168
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
10169
|
+
let cur = start;
|
|
10170
|
+
while (cur) {
|
|
10171
|
+
if (visiting.has(cur.name)) {
|
|
10172
|
+
const idx = stack.indexOf(cur.name);
|
|
10173
|
+
return idx >= 0 ? stack.slice(idx).concat(cur.name) : [cur.name, cur.name];
|
|
10174
|
+
}
|
|
10175
|
+
visiting.add(cur.name);
|
|
10176
|
+
stack.push(cur.name);
|
|
10177
|
+
if (!cur.parent) break;
|
|
10178
|
+
cur = byName.get(cur.parent);
|
|
10179
|
+
}
|
|
10180
|
+
return null;
|
|
10181
|
+
}
|
|
10182
|
+
var ALLOWED_LEVEL, ALLOWED_TAGS;
|
|
10183
|
+
var init_metadata_validator = __esm({
|
|
10184
|
+
"src/slash-commands/help/metadata-validator.ts"() {
|
|
10185
|
+
ALLOWED_LEVEL = ["primary", "secondary", "hidden"];
|
|
10186
|
+
ALLOWED_TAGS = ["core", "advanced", "experimental", "deprecated"];
|
|
10187
|
+
}
|
|
10188
|
+
});
|
|
10189
|
+
var MetadataManager;
|
|
10190
|
+
var init_metadata_manager = __esm({
|
|
10191
|
+
"src/slash-commands/help/metadata-manager.ts"() {
|
|
10192
|
+
init_metadata_validator();
|
|
10193
|
+
MetadataManager = class {
|
|
10194
|
+
cache;
|
|
10195
|
+
cacheTime;
|
|
10196
|
+
CACHE_TTL = 5 * 60 * 1e3;
|
|
10197
|
+
// 5 minutes
|
|
10198
|
+
STALE_WARNING_MS = 7 * 864e5;
|
|
10199
|
+
// 7 days
|
|
10200
|
+
metaPath;
|
|
10201
|
+
constructor(metaPath) {
|
|
10202
|
+
this.metaPath = metaPath ?? path8__namespace.resolve("src/slash-commands/help/command-meta.json");
|
|
10203
|
+
}
|
|
10204
|
+
async load() {
|
|
10205
|
+
if (this.cache && this.cacheTime && Date.now() - this.cacheTime < this.CACHE_TTL) {
|
|
10206
|
+
return this.cache;
|
|
10207
|
+
}
|
|
10208
|
+
try {
|
|
10209
|
+
const meta = await this.loadFromDisk();
|
|
10210
|
+
const validation = validateHelpMetadata(meta, {
|
|
10211
|
+
expectedSchemaVersion: 1
|
|
10212
|
+
});
|
|
10213
|
+
if (!validation.ok) {
|
|
10214
|
+
console.error("[help] Metadata validation failed:", validation.errors);
|
|
10215
|
+
throw new Error("Invalid metadata structure");
|
|
10216
|
+
}
|
|
10217
|
+
if (validation.warnings.length > 0) {
|
|
10218
|
+
for (const warning of validation.warnings) {
|
|
10219
|
+
console.warn(`[help] Warning: ${warning}`);
|
|
10220
|
+
}
|
|
10221
|
+
}
|
|
10222
|
+
const age = Date.now() - new Date(meta.generatedAt).getTime();
|
|
10223
|
+
if (age > this.STALE_WARNING_MS) {
|
|
10224
|
+
console.warn(
|
|
10225
|
+
"[help] Metadata stale (7d+), consider running: npx tsx scripts/generate-help-meta.ts"
|
|
10226
|
+
);
|
|
10227
|
+
this.triggerBackgroundRegeneration();
|
|
10228
|
+
}
|
|
10229
|
+
this.cache = meta;
|
|
10230
|
+
this.cacheTime = Date.now();
|
|
10231
|
+
return meta;
|
|
10232
|
+
} catch (error) {
|
|
10233
|
+
console.error("[help] Failed to load metadata:", error);
|
|
10234
|
+
throw new Error(
|
|
10235
|
+
`Metadata loading failed: ${error instanceof Error ? error.message : error}`
|
|
10236
|
+
);
|
|
10237
|
+
}
|
|
10238
|
+
}
|
|
10239
|
+
async loadFromDisk() {
|
|
10240
|
+
const text = await fs8__namespace.readFile(this.metaPath, "utf8");
|
|
10241
|
+
const data2 = JSON.parse(text);
|
|
10242
|
+
if (Array.isArray(data2)) {
|
|
10243
|
+
return {
|
|
10244
|
+
schemaVersion: 1,
|
|
10245
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10246
|
+
generatorVersion: "legacy",
|
|
10247
|
+
commands: data2,
|
|
10248
|
+
stats: {
|
|
10249
|
+
totalCommands: data2.length,
|
|
10250
|
+
totalCategories: new Set(data2.map((c) => c.category)).size,
|
|
10251
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
10252
|
+
}
|
|
10253
|
+
};
|
|
10254
|
+
}
|
|
10255
|
+
return data2;
|
|
10256
|
+
}
|
|
10257
|
+
hasStaleCache() {
|
|
10258
|
+
return !!this.cache;
|
|
10259
|
+
}
|
|
10260
|
+
getStaleCache() {
|
|
10261
|
+
return this.cache;
|
|
10262
|
+
}
|
|
10263
|
+
triggerBackgroundRegeneration() {
|
|
10264
|
+
try {
|
|
10265
|
+
const child2 = child_process.spawn("npx", ["tsx", "scripts/generate-help-meta.ts"], {
|
|
10266
|
+
detached: true,
|
|
10267
|
+
stdio: "ignore"
|
|
10268
|
+
});
|
|
10269
|
+
child2.unref();
|
|
10270
|
+
console.log("[help] Background metadata regeneration triggered");
|
|
10271
|
+
} catch (error) {
|
|
10272
|
+
console.warn("[help] Failed to trigger background regeneration:", error);
|
|
10273
|
+
}
|
|
10274
|
+
}
|
|
10275
|
+
/**
|
|
10276
|
+
* Build compact JSON for non-TTY output
|
|
10277
|
+
*/
|
|
10278
|
+
buildCompactJson(metas) {
|
|
10279
|
+
const byCat = /* @__PURE__ */ new Map();
|
|
10280
|
+
for (const m2 of metas) {
|
|
10281
|
+
if (m2.level === "hidden") continue;
|
|
10282
|
+
const arr = byCat.get(m2.category) || [];
|
|
10283
|
+
arr.push(m2);
|
|
10284
|
+
byCat.set(m2.category, arr);
|
|
10285
|
+
}
|
|
10286
|
+
const categories = [];
|
|
10287
|
+
for (const [cat, arr] of byCat) {
|
|
10288
|
+
const primaries = arr.filter((x2) => x2.level === "primary" && !x2.parent).sort(
|
|
10289
|
+
(a2, b) => (a2.rank ?? 1e9) - (b.rank ?? 1e9) || a2.name.localeCompare(b.name)
|
|
10290
|
+
);
|
|
10291
|
+
const top = primaries.slice(0, 3).map((p) => ({
|
|
10292
|
+
name: p.name,
|
|
10293
|
+
title: p.title
|
|
10294
|
+
}));
|
|
10295
|
+
const more = Math.max(0, primaries.length - top.length);
|
|
10296
|
+
categories.push({
|
|
10297
|
+
category: cat,
|
|
10298
|
+
total: arr.length,
|
|
10299
|
+
top,
|
|
10300
|
+
more
|
|
10301
|
+
});
|
|
10302
|
+
}
|
|
10303
|
+
categories.sort((a2, b) => a2.category.localeCompare(b.category));
|
|
10304
|
+
return {
|
|
10305
|
+
mode: "compact-json",
|
|
10306
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10307
|
+
categories
|
|
10308
|
+
};
|
|
10309
|
+
}
|
|
10310
|
+
};
|
|
10311
|
+
}
|
|
10312
|
+
});
|
|
10313
|
+
|
|
10314
|
+
// src/slash-commands/help/renderers/compact-renderer.ts
|
|
10315
|
+
function renderCompactHelp(metas, opts = {}) {
|
|
10316
|
+
const {
|
|
10317
|
+
maxPrimaryPerCategory = 3,
|
|
10318
|
+
maxCategories = 16,
|
|
10319
|
+
showAdvanced = false,
|
|
10320
|
+
twoColumnThreshold = 100,
|
|
10321
|
+
categoryOrder,
|
|
10322
|
+
heading = "\u{1F4D6} MARIA Commands (compact \u2022 primary only)"
|
|
10323
|
+
} = opts;
|
|
10324
|
+
const visible = metas.filter((m2) => showAdvanced || m2.level !== "hidden");
|
|
10325
|
+
const byCat = /* @__PURE__ */ new Map();
|
|
10326
|
+
for (const m2 of visible) {
|
|
10327
|
+
const arr = byCat.get(m2.category) || [];
|
|
10328
|
+
arr.push(m2);
|
|
10329
|
+
byCat.set(m2.category, arr);
|
|
10330
|
+
}
|
|
10331
|
+
const compact = Array.from(byCat.entries()).map(([cat, arr]) => {
|
|
10332
|
+
const primary = arr.filter((m2) => m2.level === "primary").sort(sorter2);
|
|
10333
|
+
const total = arr.length;
|
|
10334
|
+
const items = primary.slice(0, maxPrimaryPerCategory);
|
|
10335
|
+
const more = Math.max(0, total - items.length);
|
|
10336
|
+
return { category: cat, items, total, more };
|
|
10337
|
+
});
|
|
10338
|
+
compact.sort(
|
|
10339
|
+
(a2, b) => categoryIndex(a2.category) - categoryIndex(b.category) || a2.category.localeCompare(b.category)
|
|
10340
|
+
);
|
|
10341
|
+
const limitedCompact = compact.slice(0, maxCategories);
|
|
10342
|
+
const remainingCats = compact.length - limitedCompact.length;
|
|
10343
|
+
const width = process.stdout.columns || 80;
|
|
10344
|
+
const twoCol = width >= twoColumnThreshold && compact.length > 6;
|
|
10345
|
+
const colPad = twoCol ? Math.floor(width / 2) : width;
|
|
10346
|
+
const lines = [];
|
|
10347
|
+
lines.push(heading, "");
|
|
10348
|
+
let buffer = [];
|
|
10349
|
+
function flushRow() {
|
|
10350
|
+
if (!twoCol) {
|
|
10351
|
+
lines.push(...buffer);
|
|
10352
|
+
buffer = [];
|
|
10353
|
+
return;
|
|
10354
|
+
}
|
|
10355
|
+
for (let i2 = 0; i2 < buffer.length; i2 += 2) {
|
|
10356
|
+
const left = buffer[i2] ?? "";
|
|
10357
|
+
const right = buffer[i2 + 1] ?? "";
|
|
10358
|
+
const paddedLeft = left.padEnd(colPad - 1, " ");
|
|
10359
|
+
lines.push(paddedLeft + right);
|
|
10360
|
+
}
|
|
10361
|
+
buffer = [];
|
|
10362
|
+
}
|
|
10363
|
+
for (const block of limitedCompact) {
|
|
10364
|
+
const head = formatCategoryHeader(
|
|
10365
|
+
block.category,
|
|
10366
|
+
block.items.length,
|
|
10367
|
+
block.total
|
|
10368
|
+
);
|
|
10369
|
+
const body = [
|
|
10370
|
+
...block.items.map(
|
|
10371
|
+
(it) => ` ${padCmd3(it.name, 20)} ${truncate3(it.title ?? "", colPad - 24)}`
|
|
10372
|
+
),
|
|
10373
|
+
block.more > 0 ? ` +${block.more} more \u2192 /help ${block.category}` : ""
|
|
10374
|
+
].filter(Boolean);
|
|
10375
|
+
const segment = [head, ...body, ""].join("\n");
|
|
10376
|
+
if (twoCol) {
|
|
10377
|
+
buffer.push(segment);
|
|
10378
|
+
if (buffer.length === 2) flushRow();
|
|
10379
|
+
} else {
|
|
10380
|
+
lines.push(segment);
|
|
10381
|
+
}
|
|
10382
|
+
}
|
|
10383
|
+
if (buffer.length) flushRow();
|
|
10384
|
+
const totalCmds = metas.length;
|
|
10385
|
+
const totalCats = byCat.size;
|
|
10386
|
+
const footerLines = [
|
|
10387
|
+
`Tip: /help <category> \u3067\u5C55\u958B, /help --search <kw>, /help --all${showAdvanced ? "" : ", /help --advanced"}`,
|
|
10388
|
+
`Total: ${totalCmds} cmds / ${totalCats} cats (showing ${limitedCompact.length}/${totalCats} categories)`
|
|
10389
|
+
];
|
|
10390
|
+
if (remainingCats > 0) {
|
|
10391
|
+
footerLines.push(
|
|
10392
|
+
`${remainingCats} more categories available with /help --all`
|
|
10393
|
+
);
|
|
10394
|
+
}
|
|
10395
|
+
lines.push(...footerLines);
|
|
10396
|
+
return lines.join("\n");
|
|
10397
|
+
function sorter2(a2, b) {
|
|
10398
|
+
if ((a2.rank ?? 999999) !== (b.rank ?? 999999))
|
|
10399
|
+
return (a2.rank ?? 999999) - (b.rank ?? 999999);
|
|
10400
|
+
return a2.name.localeCompare(b.name);
|
|
10401
|
+
}
|
|
10402
|
+
function categoryIndex(cat) {
|
|
10403
|
+
if (!categoryOrder) return 0;
|
|
10404
|
+
const idx = categoryOrder.indexOf(cat);
|
|
10405
|
+
return idx === -1 ? 9999 : idx;
|
|
10406
|
+
}
|
|
10407
|
+
function formatCategoryHeader(cat, shown, total) {
|
|
10408
|
+
const label = beautifyCategory3(cat);
|
|
10409
|
+
return `${label} (${shown} of ${total})`;
|
|
10410
|
+
}
|
|
10411
|
+
function beautifyCategory3(cat) {
|
|
10412
|
+
const map = {
|
|
10413
|
+
core: "\u{1F4DD} Core",
|
|
10414
|
+
generation: "\u{1F680} Content Generation",
|
|
10415
|
+
analysis: "\u{1F50D} Analysis & Review",
|
|
10416
|
+
quality: "\u{1F6E1}\uFE0F Code Quality",
|
|
10417
|
+
development: "\u2699\uFE0F Development Tools",
|
|
10418
|
+
workflow: "\u{1F504} Workflow Automation",
|
|
10419
|
+
configuration: "\u{1F4CB} Configuration",
|
|
10420
|
+
auth: "\u{1F510} Authentication",
|
|
10421
|
+
media: "\u{1F3A8} Media Generation",
|
|
10422
|
+
integration: "\u{1F517} Integration",
|
|
10423
|
+
system: "\u{1F3E5} System & Diagnostics",
|
|
10424
|
+
optimization: "\u26A1 Performance Optimization",
|
|
10425
|
+
creative: "\u{1F3A8} Creative Tools",
|
|
10426
|
+
implementation: "\u{1F527} Implementation Utilities",
|
|
10427
|
+
evolution: "\u{1F9E0} RL Evolution",
|
|
10428
|
+
ai: "\u{1F916} AI & GPU Operations",
|
|
10429
|
+
monitoring: "\u{1F4CA} Real-time Monitoring",
|
|
10430
|
+
file: "\u{1F4BE} File Operations",
|
|
10431
|
+
"coding-agent": "\u{1F916} AI Coding Agent",
|
|
10432
|
+
business: "\u{1F4BC} Business Operations"
|
|
10433
|
+
};
|
|
10434
|
+
return map[cat] ?? cat.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
10435
|
+
}
|
|
10436
|
+
function padCmd3(cmd, len) {
|
|
10437
|
+
return cmd.padEnd(len, " ");
|
|
10438
|
+
}
|
|
10439
|
+
function truncate3(s2, max) {
|
|
10440
|
+
if (s2.length <= max) return s2;
|
|
10441
|
+
return s2.slice(0, Math.max(0, max - 1)) + "\u2026";
|
|
10442
|
+
}
|
|
10443
|
+
}
|
|
10444
|
+
var init_compact_renderer = __esm({
|
|
10445
|
+
"src/slash-commands/help/renderers/compact-renderer.ts"() {
|
|
10446
|
+
}
|
|
10447
|
+
});
|
|
10448
|
+
|
|
10449
|
+
// src/slash-commands/help/renderers/detail-renderer.ts
|
|
10450
|
+
function sorter(a2, b) {
|
|
10451
|
+
if ((a2.rank ?? 999999) !== (b.rank ?? 999999))
|
|
10452
|
+
return (a2.rank ?? 999999) - (b.rank ?? 999999);
|
|
10453
|
+
return a2.name.localeCompare(b.name);
|
|
10454
|
+
}
|
|
10455
|
+
function beautifyCategory(cat) {
|
|
10456
|
+
const map = {
|
|
10457
|
+
core: "\u{1F4DD} Core",
|
|
10458
|
+
generation: "\u{1F680} Content Generation",
|
|
10459
|
+
analysis: "\u{1F50D} Analysis & Review",
|
|
10460
|
+
quality: "\u{1F6E1}\uFE0F Code Quality",
|
|
10461
|
+
development: "\u2699\uFE0F Development Tools",
|
|
10462
|
+
workflow: "\u{1F504} Workflow Automation",
|
|
10463
|
+
configuration: "\u{1F4CB} Configuration",
|
|
10464
|
+
auth: "\u{1F510} Authentication",
|
|
10465
|
+
media: "\u{1F3A8} Media Generation",
|
|
10466
|
+
integration: "\u{1F517} Integration",
|
|
10467
|
+
system: "\u{1F3E5} System & Diagnostics",
|
|
10468
|
+
optimization: "\u26A1 Performance Optimization",
|
|
10469
|
+
creative: "\u{1F3A8} Creative Tools",
|
|
10470
|
+
implementation: "\u{1F527} Implementation Utilities",
|
|
10471
|
+
evolution: "\u{1F9E0} RL Evolution",
|
|
10472
|
+
ai: "\u{1F916} AI & GPU Operations",
|
|
10473
|
+
monitoring: "\u{1F4CA} Real-time Monitoring",
|
|
10474
|
+
file: "\u{1F4BE} File Operations",
|
|
10475
|
+
"coding-agent": "\u{1F916} AI Coding Agent",
|
|
10476
|
+
business: "\u{1F4BC} Business Operations"
|
|
10477
|
+
};
|
|
10478
|
+
return map[cat] ?? cat.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
10479
|
+
}
|
|
10480
|
+
function padCmd(cmd, len) {
|
|
10481
|
+
return cmd.padEnd(len, " ");
|
|
10482
|
+
}
|
|
10483
|
+
function truncate(s2, max) {
|
|
10484
|
+
if (s2.length <= max) return s2;
|
|
10485
|
+
return s2.slice(0, Math.max(0, max - 1)) + "\u2026";
|
|
10486
|
+
}
|
|
10487
|
+
function formatTags(m2) {
|
|
10488
|
+
if (!m2.tags || m2.tags.length === 0) return "";
|
|
10489
|
+
return " [" + m2.tags.join(",") + "]";
|
|
10490
|
+
}
|
|
10491
|
+
function renderCategoryHelp(metas, category, opts = {}) {
|
|
10492
|
+
const width = opts.width ?? process.stdout.columns ?? 80;
|
|
10493
|
+
const colCmd = Math.min(24, Math.max(16, Math.floor(width * 0.28)));
|
|
10494
|
+
const advanced = !!opts.advanced;
|
|
10495
|
+
let target = metas.filter((m2) => m2.category === category);
|
|
10496
|
+
if (!advanced) target = target.filter((m2) => m2.level !== "hidden");
|
|
10497
|
+
const primary = target.filter((m2) => !m2.parent && m2.level !== "hidden" && m2.level !== "secondary").sort(sorter);
|
|
10498
|
+
const secondaries = target.filter((m2) => m2.parent || m2.level === "secondary").sort(sorter);
|
|
10499
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
10500
|
+
for (const s2 of secondaries) {
|
|
10501
|
+
const p = s2.parent ?? "(misc)";
|
|
10502
|
+
const arr = byParent.get(p) || [];
|
|
10503
|
+
arr.push(s2);
|
|
10504
|
+
byParent.set(p, arr);
|
|
10505
|
+
}
|
|
10506
|
+
const lines = [];
|
|
10507
|
+
lines.push(
|
|
10508
|
+
opts.heading ?? `\u{1F4D6} ${beautifyCategory(category)} \u2014 All Commands`,
|
|
10509
|
+
""
|
|
10510
|
+
);
|
|
10511
|
+
if (primary.length) {
|
|
10512
|
+
lines.push("Primary:");
|
|
10513
|
+
for (const p of primary) {
|
|
10514
|
+
const alias = opts.showAliases && p.aliases?.length ? ` (aka: ${p.aliases.join(", ")})` : "";
|
|
10515
|
+
const tags = formatTags(p);
|
|
10516
|
+
lines.push(
|
|
10517
|
+
` ${padCmd(p.name, colCmd)} ${truncate((p.title ?? "") + alias + tags, width - colCmd - 4)}`
|
|
10518
|
+
);
|
|
10519
|
+
}
|
|
10520
|
+
lines.push("");
|
|
10521
|
+
}
|
|
10522
|
+
const parentsSorted = Array.from(byParent.keys()).sort();
|
|
10523
|
+
for (const parent of parentsSorted) {
|
|
10524
|
+
const children = byParent.get(parent).sort(sorter);
|
|
10525
|
+
const parentHead = parent !== "(misc)" ? parent : "Subcommands";
|
|
10526
|
+
lines.push(`${parentHead}:`);
|
|
10527
|
+
for (const c of children) {
|
|
10528
|
+
const alias = opts.showAliases && c.aliases?.length ? ` (aka: ${c.aliases.join(", ")})` : "";
|
|
10529
|
+
const tags = formatTags(c);
|
|
10530
|
+
lines.push(
|
|
10531
|
+
` ${padCmd(c.name, colCmd)} ${truncate((c.title ?? "") + alias + tags, width - colCmd - 4)}`
|
|
10532
|
+
);
|
|
10533
|
+
}
|
|
10534
|
+
lines.push("");
|
|
10535
|
+
}
|
|
10536
|
+
if (!primary.length && byParent.size === 0) {
|
|
10537
|
+
lines.push("(No commands found in this category)");
|
|
10538
|
+
lines.push("");
|
|
10539
|
+
}
|
|
10540
|
+
lines.push(
|
|
10541
|
+
`Tip: /help --search <kw>, /help --all${advanced ? "" : ", /help --advanced"}`
|
|
10542
|
+
);
|
|
10543
|
+
return lines.join("\n");
|
|
10544
|
+
}
|
|
10545
|
+
function renderSearchHelp(metas, query, opts = {}) {
|
|
10546
|
+
const width = opts.width ?? process.stdout.columns ?? 80;
|
|
10547
|
+
const colCmd = Math.min(24, Math.max(16, Math.floor(width * 0.28)));
|
|
10548
|
+
const advanced = !!opts.advanced;
|
|
10549
|
+
const matchMode = opts.matchMode ?? "any";
|
|
10550
|
+
const q = query.trim().toLowerCase();
|
|
10551
|
+
if (!q) return "Please provide a search keyword.\n";
|
|
10552
|
+
const pool = advanced ? metas : metas.filter((m2) => m2.level !== "hidden");
|
|
10553
|
+
const matches2 = pool.map((m2) => ({ meta: m2, score: fuzzyScore(m2, q, matchMode) })).filter((x2) => x2.score > 0).sort(
|
|
10554
|
+
(a2, b) => b.score - a2.score || (a2.meta.rank ?? 999999) - (b.meta.rank ?? 999999)
|
|
10555
|
+
).slice(0, 50);
|
|
10556
|
+
const lines = [];
|
|
10557
|
+
lines.push(`\u{1F50E} Search: "${query}" (${matches2.length} results)`, "");
|
|
10558
|
+
if (matches2.length === 0) {
|
|
10559
|
+
lines.push(
|
|
10560
|
+
"No matches. Try another keyword or use --match all for stricter matching."
|
|
10561
|
+
);
|
|
10562
|
+
return lines.join("\n");
|
|
10563
|
+
}
|
|
10564
|
+
const byCat = /* @__PURE__ */ new Map();
|
|
10565
|
+
for (const m2 of matches2) {
|
|
10566
|
+
const arr = byCat.get(m2.meta.category) || [];
|
|
10567
|
+
arr.push(m2);
|
|
10568
|
+
byCat.set(m2.meta.category, arr);
|
|
10569
|
+
}
|
|
10570
|
+
const cats = Array.from(byCat.keys()).sort();
|
|
10571
|
+
for (const cat of cats) {
|
|
10572
|
+
lines.push(`${beautifyCategory(cat)}:`);
|
|
10573
|
+
const arr = byCat.get(cat).sort((a2, b) => b.score - a2.score || sorter(a2.meta, b.meta));
|
|
10574
|
+
for (const { meta } of arr) {
|
|
10575
|
+
const alias = opts.showAliases && meta.aliases?.length ? ` (aka: ${meta.aliases.join(", ")})` : "";
|
|
10576
|
+
const tags = formatTags(meta);
|
|
10577
|
+
const badge = meta.level === "secondary" ? "\xB7 " : "";
|
|
10578
|
+
lines.push(
|
|
10579
|
+
` ${badge}${padCmd(meta.name, colCmd)} ${truncate((meta.title ?? "") + alias + tags, width - colCmd - 6)}`
|
|
10580
|
+
);
|
|
10581
|
+
}
|
|
10582
|
+
lines.push("");
|
|
10583
|
+
}
|
|
10584
|
+
lines.push(
|
|
10585
|
+
`Tip: /help <category> \u3067\u8A72\u5F53\u30AB\u30C6\u30B4\u30EA\u3092\u5C55\u958B, /help --all${advanced ? "" : ", /help --advanced"}`
|
|
10586
|
+
);
|
|
10587
|
+
return lines.join("\n");
|
|
10588
|
+
function fuzzyScore(m2, q2, mode) {
|
|
10589
|
+
const tokens = q2.split(/\s+/).filter(Boolean);
|
|
10590
|
+
[
|
|
10591
|
+
m2.name.toLowerCase(),
|
|
10592
|
+
(m2.title ?? "").toLowerCase(),
|
|
10593
|
+
m2.category.toLowerCase(),
|
|
10594
|
+
...(m2.aliases ?? []).map((a2) => a2.toLowerCase())
|
|
10595
|
+
].join(" | ");
|
|
10596
|
+
let totalScore = 0;
|
|
10597
|
+
let matchedTokens = 0;
|
|
10598
|
+
for (const token of tokens) {
|
|
10599
|
+
let tokenScore = 0;
|
|
10600
|
+
if (m2.name.toLowerCase() === token || m2.name.toLowerCase() === "/" + token) {
|
|
10601
|
+
tokenScore = 1e4;
|
|
10602
|
+
} else if (m2.aliases?.some(
|
|
10603
|
+
(a2) => a2.toLowerCase() === token || a2.toLowerCase() === "/" + token
|
|
10604
|
+
)) {
|
|
10605
|
+
tokenScore = 8e3;
|
|
10606
|
+
} else if (m2.name.toLowerCase().startsWith("/" + token)) {
|
|
10607
|
+
tokenScore = 5e3;
|
|
10608
|
+
} else if (m2.name.toLowerCase().includes(token)) {
|
|
10609
|
+
tokenScore = 3e3;
|
|
10610
|
+
} else if (m2.name.split(/[\s\/]+/).some((w) => w.toLowerCase().startsWith(token))) {
|
|
10611
|
+
tokenScore = 2e3;
|
|
10612
|
+
} else if (m2.title?.toLowerCase().includes(token)) {
|
|
10613
|
+
tokenScore = 1e3;
|
|
10614
|
+
} else if (m2.category.toLowerCase().includes(token)) {
|
|
10615
|
+
tokenScore = 500;
|
|
10616
|
+
}
|
|
10617
|
+
if (tokenScore > 0) {
|
|
10618
|
+
matchedTokens++;
|
|
10619
|
+
totalScore += tokenScore;
|
|
10620
|
+
}
|
|
10621
|
+
}
|
|
10622
|
+
if (mode === "all" && matchedTokens < tokens.length) {
|
|
10623
|
+
return 0;
|
|
10624
|
+
}
|
|
10625
|
+
if (mode === "any" && matchedTokens === 0) {
|
|
10626
|
+
return 0;
|
|
10627
|
+
}
|
|
10628
|
+
if (m2.usage?.frequency) {
|
|
10629
|
+
totalScore *= 1 + Math.min(m2.usage.frequency / 100, 2);
|
|
10630
|
+
}
|
|
10631
|
+
if (m2.tags?.includes("deprecated")) totalScore *= 0.5;
|
|
10632
|
+
if (m2.tags?.includes("experimental")) totalScore *= 0.8;
|
|
10633
|
+
return totalScore;
|
|
10634
|
+
}
|
|
10635
|
+
}
|
|
10636
|
+
var init_detail_renderer = __esm({
|
|
10637
|
+
"src/slash-commands/help/renderers/detail-renderer.ts"() {
|
|
10638
|
+
}
|
|
10639
|
+
});
|
|
10640
|
+
|
|
10641
|
+
// src/slash-commands/help/renderers/full-renderer.ts
|
|
10642
|
+
function renderFullHelp(metas, opts = {}) {
|
|
10643
|
+
const {
|
|
10644
|
+
advanced = false,
|
|
10645
|
+
showAliases = false,
|
|
10646
|
+
categoryOrder,
|
|
10647
|
+
heading = "\u{1F4D6} MARIA Commands \u2014 Full Listing"
|
|
10648
|
+
} = opts;
|
|
10649
|
+
const width = opts.width ?? process.stdout.columns ?? 80;
|
|
10650
|
+
const colCmd = Math.min(28, Math.max(16, Math.floor(width * 0.3)));
|
|
10651
|
+
const visible = advanced ? metas : metas.filter((m2) => m2.level !== "hidden");
|
|
10652
|
+
const byCat = /* @__PURE__ */ new Map();
|
|
10653
|
+
for (const m2 of visible) {
|
|
10654
|
+
const arr = byCat.get(m2.category) || [];
|
|
10655
|
+
arr.push(m2);
|
|
10656
|
+
byCat.set(m2.category, arr);
|
|
10657
|
+
}
|
|
10658
|
+
const cats = Array.from(byCat.keys()).sort(
|
|
10659
|
+
(a2, b) => categoryIndex(a2) - categoryIndex(b) || a2.localeCompare(b)
|
|
10660
|
+
);
|
|
10661
|
+
const out = [];
|
|
10662
|
+
out.push(heading, "");
|
|
10663
|
+
for (const cat of cats) {
|
|
10664
|
+
const list = (byCat.get(cat) || []).slice().sort(sorter2);
|
|
10665
|
+
const primaries = list.filter((m2) => m2.level === "primary" && !m2.parent);
|
|
10666
|
+
const secondaries = list.filter((m2) => m2.level !== "primary" || m2.parent);
|
|
10667
|
+
out.push(`${beautifyCategory3(cat)} (${list.length})`, "");
|
|
10668
|
+
if (primaries.length) {
|
|
10669
|
+
out.push("Primary:");
|
|
10670
|
+
for (const p of primaries) {
|
|
10671
|
+
out.push(` ${padCmd3(p.name, colCmd)} ${fmtDesc(p)}`);
|
|
10672
|
+
}
|
|
10673
|
+
out.push("");
|
|
10674
|
+
}
|
|
10675
|
+
if (secondaries.length) {
|
|
10676
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
10677
|
+
for (const s2 of secondaries) {
|
|
10678
|
+
const k = s2.parent ?? "(misc)";
|
|
10679
|
+
const arr = byParent.get(k) || [];
|
|
10680
|
+
arr.push(s2);
|
|
10681
|
+
byParent.set(k, arr);
|
|
10682
|
+
}
|
|
10683
|
+
const parents = Array.from(byParent.keys()).sort();
|
|
10684
|
+
for (const parent of parents) {
|
|
10685
|
+
const label = parent !== "(misc)" ? parent : "Subcommands";
|
|
10686
|
+
out.push(`${label}:`);
|
|
10687
|
+
const children = (byParent.get(parent) || []).slice().sort(sorter2);
|
|
10688
|
+
for (const c of children) {
|
|
10689
|
+
out.push(` ${padCmd3(c.name, colCmd)} ${fmtDesc(c)}`);
|
|
10690
|
+
}
|
|
10691
|
+
out.push("");
|
|
10692
|
+
}
|
|
10693
|
+
}
|
|
10694
|
+
out.push("");
|
|
10695
|
+
}
|
|
10696
|
+
out.push(
|
|
10697
|
+
`Tip: /help <category> \u3067\u30AB\u30C6\u30B4\u30EA\u5225\u3001/help --search <kw> \u3067\u7D5E\u308A\u8FBC\u307F\u3001/help \u3067\u30B3\u30F3\u30D1\u30AF\u30C8\u8868\u793A`,
|
|
10698
|
+
`Total: ${metas.length} commands across ${cats.length} categories${advanced ? " (advanced shown)" : ""}`
|
|
10699
|
+
);
|
|
10700
|
+
return out.join("\n");
|
|
10701
|
+
function sorter2(a2, b) {
|
|
10702
|
+
if ((a2.rank ?? 999999) !== (b.rank ?? 999999))
|
|
10703
|
+
return (a2.rank ?? 999999) - (b.rank ?? 999999);
|
|
10704
|
+
return a2.name.localeCompare(b.name);
|
|
10705
|
+
}
|
|
10706
|
+
function categoryIndex(cat) {
|
|
10707
|
+
if (!categoryOrder) return 0;
|
|
10708
|
+
const i2 = categoryOrder.indexOf(cat);
|
|
10709
|
+
return i2 === -1 ? 9999 : i2;
|
|
10710
|
+
}
|
|
10711
|
+
function beautifyCategory3(cat) {
|
|
10712
|
+
const map = {
|
|
10713
|
+
core: "\u{1F4DD} Core",
|
|
10714
|
+
generation: "\u{1F680} Content Generation",
|
|
10715
|
+
analysis: "\u{1F50D} Analysis & Review",
|
|
10716
|
+
quality: "\u{1F6E1}\uFE0F Code Quality",
|
|
10717
|
+
development: "\u2699\uFE0F Development Tools",
|
|
10718
|
+
workflow: "\u{1F504} Workflow Automation",
|
|
10719
|
+
configuration: "\u{1F4CB} Configuration",
|
|
10720
|
+
auth: "\u{1F510} Authentication",
|
|
10721
|
+
media: "\u{1F3A8} Media Generation",
|
|
10722
|
+
integration: "\u{1F517} Integration",
|
|
10723
|
+
system: "\u{1F3E5} System & Diagnostics",
|
|
10724
|
+
optimization: "\u26A1 Performance Optimization",
|
|
10725
|
+
creative: "\u{1F3A8} Creative Tools",
|
|
10726
|
+
implementation: "\u{1F527} Implementation Utilities",
|
|
10727
|
+
evolution: "\u{1F9E0} RL Evolution",
|
|
10728
|
+
ai: "\u{1F916} AI & GPU Operations",
|
|
10729
|
+
monitoring: "\u{1F4CA} Real-time Monitoring",
|
|
10730
|
+
file: "\u{1F4BE} File Operations",
|
|
10731
|
+
"coding-agent": "\u{1F916} AI Coding Agent",
|
|
10732
|
+
business: "\u{1F4BC} Business Operations"
|
|
10733
|
+
};
|
|
10734
|
+
return map[cat] ?? cat.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
10735
|
+
}
|
|
10736
|
+
function padCmd3(cmd, len) {
|
|
10737
|
+
return cmd.padEnd(len, " ");
|
|
10738
|
+
}
|
|
10739
|
+
function truncate3(s2, max) {
|
|
10740
|
+
if (s2.length <= max) return s2;
|
|
10741
|
+
return s2.slice(0, Math.max(0, max - 1)) + "\u2026";
|
|
10742
|
+
}
|
|
10743
|
+
function fmtDesc(m2) {
|
|
10744
|
+
const alias = showAliases && m2.aliases?.length ? ` (aka: ${m2.aliases.join(", ")})` : "";
|
|
10745
|
+
const tags = m2.tags && m2.tags.length ? ` [${m2.tags.join(",")}]` : "";
|
|
10746
|
+
const text = ((m2.title ?? "") + alias + tags).trim();
|
|
10747
|
+
return truncate3(text, Math.max(8, width - colCmd - 4));
|
|
10748
|
+
}
|
|
10749
|
+
}
|
|
10750
|
+
var init_full_renderer = __esm({
|
|
10751
|
+
"src/slash-commands/help/renderers/full-renderer.ts"() {
|
|
10752
|
+
}
|
|
10753
|
+
});
|
|
10754
|
+
async function runInteractiveHelp(opts = {}) {
|
|
10755
|
+
const metaPath = opts.metaPath ?? path8__namespace.resolve("src/slash-commands/help/command-meta.json");
|
|
10756
|
+
let container;
|
|
10757
|
+
try {
|
|
10758
|
+
const text = await fs8__namespace.readFile(metaPath, "utf8");
|
|
10759
|
+
container = JSON.parse(text);
|
|
10760
|
+
} catch (error) {
|
|
10761
|
+
throw new Error(`Failed to load metadata: ${error}`);
|
|
10762
|
+
}
|
|
10763
|
+
const metas = Array.isArray(container) ? container : container.commands;
|
|
10764
|
+
if (!Array.isArray(metas) || metas.length === 0) {
|
|
10765
|
+
throw new Error("help meta not found or empty");
|
|
10766
|
+
}
|
|
10767
|
+
const state = buildState(
|
|
10768
|
+
metas,
|
|
10769
|
+
!!opts.showAdvancedDefault,
|
|
10770
|
+
opts.heading ?? "\u{1F4D6} MARIA Commands \u2014 Interactive"
|
|
10771
|
+
);
|
|
10772
|
+
const term = new Terminal();
|
|
10773
|
+
try {
|
|
10774
|
+
if (!process.stdout.isTTY || process.env.NO_ALT_SCREEN) {
|
|
10775
|
+
throw new Error("Interactive mode requires TTY with alt screen support");
|
|
10776
|
+
}
|
|
10777
|
+
term.enterAlt();
|
|
10778
|
+
term.hideCursor();
|
|
10779
|
+
term.enableRaw();
|
|
10780
|
+
render(term, state);
|
|
10781
|
+
await loop(term, state);
|
|
10782
|
+
} finally {
|
|
10783
|
+
term.disableRaw();
|
|
10784
|
+
term.showCursor();
|
|
10785
|
+
term.leaveAlt();
|
|
10786
|
+
}
|
|
10787
|
+
}
|
|
10788
|
+
function buildState(metas, showAdvanced, heading) {
|
|
10789
|
+
const width = process.stdout.columns || 80;
|
|
10790
|
+
const height = process.stdout.rows || 24;
|
|
10791
|
+
const visible = showAdvanced ? metas : metas.filter((m2) => m2.level !== "hidden");
|
|
10792
|
+
const byCat = /* @__PURE__ */ new Map();
|
|
10793
|
+
for (const m2 of visible) {
|
|
10794
|
+
const arr = byCat.get(m2.category) || [];
|
|
10795
|
+
arr.push(m2);
|
|
10796
|
+
byCat.set(m2.category, arr);
|
|
10797
|
+
}
|
|
10798
|
+
const blocks = [];
|
|
10799
|
+
for (const [cat, arr] of byCat) {
|
|
10800
|
+
const sorted = arr.slice().sort(sorter2);
|
|
10801
|
+
const primaries = sorted.filter((m2) => m2.level === "primary" && !m2.parent);
|
|
10802
|
+
const secondaries = sorted.filter((m2) => m2.level !== "primary" || m2.parent);
|
|
10803
|
+
blocks.push({
|
|
10804
|
+
key: cat,
|
|
10805
|
+
label: beautifyCategory2(cat),
|
|
10806
|
+
total: sorted.length,
|
|
10807
|
+
primaries,
|
|
10808
|
+
secondaries
|
|
10809
|
+
});
|
|
10810
|
+
}
|
|
10811
|
+
const order = blocks.map((b) => b.key).sort((a2, b) => a2.localeCompare(b));
|
|
10812
|
+
return {
|
|
10813
|
+
heading,
|
|
10814
|
+
width,
|
|
10815
|
+
height,
|
|
10816
|
+
categories: blocks,
|
|
10817
|
+
order,
|
|
10818
|
+
selected: 0,
|
|
10819
|
+
expanded: /* @__PURE__ */ new Set(),
|
|
10820
|
+
scrollTop: 0,
|
|
10821
|
+
showAdvanced
|
|
10822
|
+
};
|
|
10823
|
+
function sorter2(a2, b) {
|
|
10824
|
+
if ((a2.rank ?? 999999) !== (b.rank ?? 999999))
|
|
10825
|
+
return (a2.rank ?? 999999) - (b.rank ?? 999999);
|
|
10826
|
+
return a2.name.localeCompare(b.name);
|
|
10827
|
+
}
|
|
10828
|
+
}
|
|
10829
|
+
function beautifyCategory2(cat) {
|
|
10830
|
+
const map = {
|
|
10831
|
+
core: "\u{1F4DD} Core",
|
|
10832
|
+
generation: "\u{1F680} Content Generation",
|
|
10833
|
+
analysis: "\u{1F50D} Analysis & Review",
|
|
10834
|
+
quality: "\u{1F6E1}\uFE0F Code Quality",
|
|
10835
|
+
development: "\u2699\uFE0F Development Tools",
|
|
10836
|
+
workflow: "\u{1F504} Workflow Automation",
|
|
10837
|
+
configuration: "\u{1F4CB} Configuration",
|
|
10838
|
+
auth: "\u{1F510} Authentication",
|
|
10839
|
+
media: "\u{1F3A8} Media Generation",
|
|
10840
|
+
integration: "\u{1F517} Integration",
|
|
10841
|
+
system: "\u{1F3E5} System & Diagnostics",
|
|
10842
|
+
optimization: "\u26A1 Performance Optimization",
|
|
10843
|
+
creative: "\u{1F3A8} Creative Tools",
|
|
10844
|
+
implementation: "\u{1F527} Implementation Utilities",
|
|
10845
|
+
evolution: "\u{1F9E0} RL Evolution",
|
|
10846
|
+
ai: "\u{1F916} AI & GPU Operations",
|
|
10847
|
+
monitoring: "\u{1F4CA} Real-time Monitoring",
|
|
10848
|
+
file: "\u{1F4BE} File Operations",
|
|
10849
|
+
"coding-agent": "\u{1F916} AI Coding Agent",
|
|
10850
|
+
business: "\u{1F4BC} Business Operations"
|
|
10851
|
+
};
|
|
10852
|
+
return map[cat] ?? cat.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
10853
|
+
}
|
|
10854
|
+
async function loop(term, s2) {
|
|
10855
|
+
let last = 0;
|
|
10856
|
+
const onKey = async (buf) => {
|
|
10857
|
+
const now = Date.now();
|
|
10858
|
+
if (now - last < 25) return;
|
|
10859
|
+
last = now;
|
|
10860
|
+
const str = buf.toString();
|
|
10861
|
+
if (str === KEY.UP) {
|
|
10862
|
+
s2.selected = Math.max(0, s2.selected - 1);
|
|
10863
|
+
ensureVisible(s2);
|
|
10864
|
+
render(term, s2);
|
|
10865
|
+
return;
|
|
10866
|
+
}
|
|
10867
|
+
if (str === KEY.DOWN) {
|
|
10868
|
+
s2.selected = Math.min(s2.order.length - 1, s2.selected + 1);
|
|
10869
|
+
ensureVisible(s2);
|
|
10870
|
+
render(term, s2);
|
|
10871
|
+
return;
|
|
10872
|
+
}
|
|
10873
|
+
if (str === KEY.RIGHT || str === KEY.ENTER) {
|
|
10874
|
+
toggleExpand(s2, true);
|
|
10875
|
+
ensureVisible(s2);
|
|
10876
|
+
render(term, s2);
|
|
10877
|
+
return;
|
|
10878
|
+
}
|
|
10879
|
+
if (str === KEY.LEFT) {
|
|
10880
|
+
toggleExpand(s2, false);
|
|
10881
|
+
ensureVisible(s2);
|
|
10882
|
+
render(term, s2);
|
|
10883
|
+
return;
|
|
10884
|
+
}
|
|
10885
|
+
if (str.toLowerCase() === KEY.A) {
|
|
10886
|
+
s2.showAdvanced = !s2.showAdvanced;
|
|
10887
|
+
render(term, s2);
|
|
10888
|
+
return;
|
|
10889
|
+
}
|
|
10890
|
+
if (str.toLowerCase() === KEY.D) {
|
|
10891
|
+
await showCategoryDetail(term, s2);
|
|
10892
|
+
render(term, s2);
|
|
10893
|
+
return;
|
|
10894
|
+
}
|
|
10895
|
+
if (str.toLowerCase() === KEY.F) {
|
|
10896
|
+
await showFullDetail(term, s2);
|
|
10897
|
+
render(term, s2);
|
|
10898
|
+
return;
|
|
10899
|
+
}
|
|
10900
|
+
if (str === KEY.ESC || str.toLowerCase() === KEY.Q) {
|
|
10901
|
+
term.writeAt(1, 1, "");
|
|
10902
|
+
throw new ExitSignal();
|
|
10903
|
+
}
|
|
10904
|
+
};
|
|
10905
|
+
try {
|
|
10906
|
+
await term.onKey(onKey);
|
|
10907
|
+
} catch (e2) {
|
|
10908
|
+
if (!(e2 instanceof ExitSignal)) throw e2;
|
|
10909
|
+
}
|
|
10910
|
+
}
|
|
10911
|
+
function toggleExpand(s2, open) {
|
|
10912
|
+
const cat = s2.order[s2.selected];
|
|
10913
|
+
if (!cat) return;
|
|
10914
|
+
const isOpen = s2.expanded.has(cat);
|
|
10915
|
+
if (open && !isOpen) s2.expanded.add(cat);
|
|
10916
|
+
if (!open && isOpen) s2.expanded.delete(cat);
|
|
10917
|
+
}
|
|
10918
|
+
function ensureVisible(s2) {
|
|
10919
|
+
materializeLines(s2);
|
|
10920
|
+
const indexLine = findCategoryTopLine(s2, s2.order[s2.selected]);
|
|
10921
|
+
const top = s2.scrollTop;
|
|
10922
|
+
const bottom = s2.scrollTop + (s2.height - 4);
|
|
10923
|
+
if (indexLine < top) s2.scrollTop = indexLine;
|
|
10924
|
+
else if (indexLine > bottom - 3) s2.scrollTop = indexLine - (s2.height - 4) + 3;
|
|
10925
|
+
if (s2.scrollTop < 0) s2.scrollTop = 0;
|
|
10926
|
+
}
|
|
10927
|
+
function render(term, s2) {
|
|
10928
|
+
const lines = materializeLines(s2);
|
|
10929
|
+
const maxLines = s2.height - 2;
|
|
10930
|
+
term.clearAll();
|
|
10931
|
+
term.moveTo(1, 1);
|
|
10932
|
+
term.write(`${s2.heading} ${s2.showAdvanced ? "[ADVANCED: ON]" : ""}`);
|
|
10933
|
+
term.write("\n");
|
|
10934
|
+
const start = s2.scrollTop;
|
|
10935
|
+
const end = Math.min(lines.length, start + maxLines - 2);
|
|
10936
|
+
for (let i2 = start; i2 < end; i2++) {
|
|
10937
|
+
term.write(lines[i2] + "\n");
|
|
10938
|
+
}
|
|
10939
|
+
const footer = "\u2191/\u2193 Move \u2192/Enter Expand \u2190 Collapse [A]dvanced [D]etail [F]ull [Q/Esc] Quit";
|
|
10940
|
+
term.write(truncateWidth(footer, s2.width));
|
|
10941
|
+
}
|
|
10942
|
+
function materializeLines(s2) {
|
|
10943
|
+
const lines = [];
|
|
10944
|
+
const selCat = s2.order[s2.selected];
|
|
10945
|
+
for (const key2 of s2.order) {
|
|
10946
|
+
const block = s2.categories.find((b) => b.key === key2);
|
|
10947
|
+
const isOpen = s2.expanded.has(key2);
|
|
10948
|
+
const isSel = key2 === selCat;
|
|
10949
|
+
const head = `${isOpen ? "\u25BC" : "\u25B6"} ${block.label} (${block.primaries.length + block.secondaries.length})`;
|
|
10950
|
+
lines.push(colorize(isSel, head));
|
|
10951
|
+
if (isOpen) {
|
|
10952
|
+
for (const p of block.primaries) {
|
|
10953
|
+
lines.push(
|
|
10954
|
+
" " + padCmd2(p.name, 24) + " " + truncate2(p.title ?? "", 80)
|
|
10955
|
+
);
|
|
10956
|
+
}
|
|
10957
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
10958
|
+
for (const sc of block.secondaries) {
|
|
10959
|
+
const parent = sc.parent ?? "(misc)";
|
|
10960
|
+
const arr = byParent.get(parent) || [];
|
|
10961
|
+
arr.push(sc);
|
|
10962
|
+
byParent.set(parent, arr);
|
|
10963
|
+
}
|
|
10964
|
+
const parents = Array.from(byParent.keys()).sort();
|
|
10965
|
+
for (const parent of parents) {
|
|
10966
|
+
lines.push(` ${parent !== "(misc)" ? parent : "Subcommands"}:`);
|
|
10967
|
+
const children = (byParent.get(parent) || []).slice().sort(
|
|
10968
|
+
(a2, b) => (a2.rank ?? 999999) - (b.rank ?? 999999) || a2.name.localeCompare(b.name)
|
|
10969
|
+
);
|
|
10970
|
+
for (const c of children) {
|
|
10971
|
+
lines.push(
|
|
10972
|
+
" " + padCmd2(c.name, 24) + " " + truncate2(c.title ?? "", 76)
|
|
10973
|
+
);
|
|
10974
|
+
}
|
|
10975
|
+
}
|
|
10976
|
+
lines.push("");
|
|
10977
|
+
}
|
|
10978
|
+
}
|
|
10979
|
+
return lines;
|
|
10980
|
+
}
|
|
10981
|
+
function findCategoryTopLine(s2, cat, lines) {
|
|
10982
|
+
let cursor = 0;
|
|
10983
|
+
for (const key2 of s2.order) {
|
|
10984
|
+
if (key2 === cat) return cursor;
|
|
10985
|
+
cursor++;
|
|
10986
|
+
const isOpen = s2.expanded.has(key2);
|
|
10987
|
+
if (isOpen) {
|
|
10988
|
+
const b = s2.categories.find((x2) => x2.key === key2);
|
|
10989
|
+
cursor += b.primaries.length;
|
|
10990
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
10991
|
+
for (const sc of b.secondaries) {
|
|
10992
|
+
const parent = sc.parent ?? "(misc)";
|
|
10993
|
+
const arr = byParent.get(parent) || [];
|
|
10994
|
+
arr.push(sc);
|
|
10995
|
+
byParent.set(parent, arr);
|
|
10996
|
+
}
|
|
10997
|
+
cursor += byParent.size;
|
|
10998
|
+
for (const arr of byParent.values()) {
|
|
10999
|
+
cursor += arr.length;
|
|
11000
|
+
}
|
|
11001
|
+
cursor += 1;
|
|
11002
|
+
}
|
|
11003
|
+
}
|
|
11004
|
+
return 0;
|
|
11005
|
+
}
|
|
11006
|
+
function padCmd2(cmd, len) {
|
|
11007
|
+
return cmd.padEnd(len, " ");
|
|
11008
|
+
}
|
|
11009
|
+
function truncate2(s2, max) {
|
|
11010
|
+
if (s2.length <= max) return s2;
|
|
11011
|
+
return s2.slice(0, Math.max(0, max - 1)) + "\u2026";
|
|
11012
|
+
}
|
|
11013
|
+
function truncateWidth(s2, width) {
|
|
11014
|
+
return s2.length <= width ? s2 : s2.slice(0, width - 1) + "\u2026";
|
|
11015
|
+
}
|
|
11016
|
+
function colorize(selected, text) {
|
|
11017
|
+
if (process.env.NO_COLOR) return selected ? `> ${text}` : ` ${text}`;
|
|
11018
|
+
const B = "\x1B[1m", R = "\x1B[0m", C = selected ? "\x1B[36m" : "";
|
|
11019
|
+
return selected ? `${B}${C}> ${text}${R}` : ` ${text}`;
|
|
11020
|
+
}
|
|
11021
|
+
async function showCategoryDetail(term, s2) {
|
|
11022
|
+
const cat = s2.order[s2.selected];
|
|
11023
|
+
if (!cat) return;
|
|
11024
|
+
const metas = s2.showAdvanced ? collectAll(s2, cat) : collectAll(s2, cat).filter((m2) => m2.level !== "hidden");
|
|
11025
|
+
const txt = renderCategoryHelp(metas, cat, {
|
|
11026
|
+
advanced: s2.showAdvanced,
|
|
11027
|
+
showAliases: false,
|
|
11028
|
+
width: s2.width
|
|
11029
|
+
});
|
|
11030
|
+
term.clearAll();
|
|
11031
|
+
term.moveTo(1, 1);
|
|
11032
|
+
term.write(txt + "\n\n");
|
|
11033
|
+
term.write("Press any key to return...");
|
|
11034
|
+
await term.waitKey();
|
|
11035
|
+
}
|
|
11036
|
+
async function showFullDetail(term, s2) {
|
|
11037
|
+
const metas = s2.showAdvanced ? collectAll(s2) : collectAll(s2).filter((m2) => m2.level !== "hidden");
|
|
11038
|
+
const txt = renderFullHelp(metas, {
|
|
11039
|
+
advanced: s2.showAdvanced,
|
|
11040
|
+
showAliases: false,
|
|
11041
|
+
heading: "\u{1F4D6} Full Listing",
|
|
11042
|
+
width: s2.width
|
|
11043
|
+
});
|
|
11044
|
+
term.clearAll();
|
|
11045
|
+
term.moveTo(1, 1);
|
|
11046
|
+
term.write(txt + "\n\n");
|
|
11047
|
+
term.write("Press any key to return...");
|
|
11048
|
+
await term.waitKey();
|
|
11049
|
+
}
|
|
11050
|
+
function collectAll(s2, onlyCat) {
|
|
11051
|
+
const arr = [];
|
|
11052
|
+
for (const key2 of s2.order) {
|
|
11053
|
+
if (onlyCat && key2 !== onlyCat) continue;
|
|
11054
|
+
const b = s2.categories.find((x2) => x2.key === key2);
|
|
11055
|
+
arr.push(...b.primaries, ...b.secondaries);
|
|
11056
|
+
}
|
|
11057
|
+
return arr;
|
|
11058
|
+
}
|
|
11059
|
+
var KEY, ExitSignal, Terminal;
|
|
11060
|
+
var init_interactive_help = __esm({
|
|
11061
|
+
"src/slash-commands/help/interactive-help.ts"() {
|
|
11062
|
+
init_detail_renderer();
|
|
11063
|
+
init_full_renderer();
|
|
11064
|
+
KEY = {
|
|
11065
|
+
UP: "\x1B[A",
|
|
11066
|
+
DOWN: "\x1B[B",
|
|
11067
|
+
RIGHT: "\x1B[C",
|
|
11068
|
+
LEFT: "\x1B[D",
|
|
11069
|
+
ENTER: "\r",
|
|
11070
|
+
ESC: "\x1B",
|
|
11071
|
+
Q: "q",
|
|
11072
|
+
A: "a",
|
|
11073
|
+
D: "d",
|
|
11074
|
+
F: "f"
|
|
11075
|
+
};
|
|
11076
|
+
ExitSignal = class extends Error {
|
|
11077
|
+
};
|
|
11078
|
+
Terminal = class {
|
|
11079
|
+
keyHandler;
|
|
11080
|
+
enterAlt() {
|
|
11081
|
+
this.write("\x1B[?1049h");
|
|
11082
|
+
}
|
|
11083
|
+
leaveAlt() {
|
|
11084
|
+
this.write("\x1B[?1049l");
|
|
11085
|
+
}
|
|
11086
|
+
hideCursor() {
|
|
11087
|
+
this.write("\x1B[?25l");
|
|
11088
|
+
}
|
|
11089
|
+
showCursor() {
|
|
11090
|
+
this.write("\x1B[?25h");
|
|
11091
|
+
}
|
|
11092
|
+
enableRaw() {
|
|
11093
|
+
if (process.stdin.isTTY) {
|
|
11094
|
+
process.stdin.setRawMode(true);
|
|
11095
|
+
process.stdin.resume();
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11098
|
+
disableRaw() {
|
|
11099
|
+
try {
|
|
11100
|
+
if (process.stdin.isTTY) {
|
|
11101
|
+
process.stdin.setRawMode(false);
|
|
11102
|
+
process.stdin.pause();
|
|
11103
|
+
}
|
|
11104
|
+
} catch {
|
|
11105
|
+
}
|
|
11106
|
+
}
|
|
11107
|
+
clearAll() {
|
|
11108
|
+
this.write("\x1B[2J\x1B[H");
|
|
11109
|
+
}
|
|
11110
|
+
moveTo(row, col) {
|
|
11111
|
+
this.write(`\x1B[${row};${col}H`);
|
|
11112
|
+
}
|
|
11113
|
+
write(s2) {
|
|
11114
|
+
process.stdout.write(s2);
|
|
11115
|
+
}
|
|
11116
|
+
writeAt(row, col, s2) {
|
|
11117
|
+
this.moveTo(row, col);
|
|
11118
|
+
this.write(s2);
|
|
11119
|
+
}
|
|
11120
|
+
async onKey(handler) {
|
|
11121
|
+
this.keyHandler = handler;
|
|
11122
|
+
return new Promise((resolve4, reject) => {
|
|
11123
|
+
const onData = (b) => handler(b);
|
|
11124
|
+
const onErr = (e2) => reject(e2);
|
|
11125
|
+
process.stdin.on("data", onData);
|
|
11126
|
+
process.stdin.on("error", onErr);
|
|
11127
|
+
const cleanup = () => {
|
|
11128
|
+
process.stdin.off("data", onData);
|
|
11129
|
+
process.stdin.off("error", onErr);
|
|
11130
|
+
};
|
|
11131
|
+
this._cleanup = cleanup;
|
|
11132
|
+
});
|
|
9802
11133
|
}
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
11134
|
+
async waitKey() {
|
|
11135
|
+
return new Promise((res) => {
|
|
11136
|
+
const handler = (b) => {
|
|
11137
|
+
process.stdin.off("data", handler);
|
|
11138
|
+
res();
|
|
11139
|
+
};
|
|
11140
|
+
process.stdin.on("data", handler);
|
|
11141
|
+
});
|
|
9808
11142
|
}
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
11143
|
+
};
|
|
11144
|
+
}
|
|
11145
|
+
});
|
|
11146
|
+
|
|
11147
|
+
// src/slash-commands/help/HelpCommand.ts
|
|
11148
|
+
var HelpCommandV2;
|
|
11149
|
+
var init_HelpCommand = __esm({
|
|
11150
|
+
"src/slash-commands/help/HelpCommand.ts"() {
|
|
11151
|
+
init_base_command();
|
|
11152
|
+
init_metadata_manager();
|
|
11153
|
+
init_compact_renderer();
|
|
11154
|
+
init_detail_renderer();
|
|
11155
|
+
init_full_renderer();
|
|
11156
|
+
init_interactive_help();
|
|
11157
|
+
HelpCommandV2 = class extends BaseCommand {
|
|
11158
|
+
name = "help";
|
|
11159
|
+
category = "core";
|
|
11160
|
+
description = "Show help information and command list with progressive disclosure";
|
|
11161
|
+
aliases = ["h", "?"];
|
|
11162
|
+
usage = "[<category>] [--search <kw>] [--all] [--advanced] [--interactive] [--json]";
|
|
11163
|
+
examples = [
|
|
11164
|
+
{ input: "/help", description: "Compact view (Top 3 per category)" },
|
|
11165
|
+
{ input: "/help business", description: "Category expansion" },
|
|
11166
|
+
{ input: "/help --search sow", description: "Search across categories" },
|
|
11167
|
+
{ input: "/help --all", description: "Full listing" },
|
|
11168
|
+
{
|
|
11169
|
+
input: "/help --interactive",
|
|
11170
|
+
description: "TUI mode with arrow navigation"
|
|
11171
|
+
},
|
|
11172
|
+
{ input: "/help --json", description: "JSON output for automation" }
|
|
11173
|
+
];
|
|
11174
|
+
metadataManager = new MetadataManager();
|
|
11175
|
+
async execute(args, _context) {
|
|
11176
|
+
const flags = this.parseFlags(args);
|
|
11177
|
+
try {
|
|
11178
|
+
const container = await this.metadataManager.load();
|
|
11179
|
+
const metas = container.commands;
|
|
11180
|
+
const isTTY = !!(process.stdout.isTTY && process.stdin.isTTY);
|
|
11181
|
+
if ((!isTTY || flags.json) && !flags.interactive) {
|
|
11182
|
+
const payload = this.metadataManager.buildCompactJson(metas);
|
|
11183
|
+
return this.success(JSON.stringify(payload, null, 2));
|
|
11184
|
+
}
|
|
11185
|
+
if (flags.interactive) {
|
|
11186
|
+
try {
|
|
11187
|
+
await runInteractiveHelp({
|
|
11188
|
+
showAdvancedDefault: flags.advanced
|
|
11189
|
+
});
|
|
11190
|
+
return this.success("");
|
|
11191
|
+
} catch (error) {
|
|
11192
|
+
if (error.message?.includes("TTY")) {
|
|
11193
|
+
return this.error(
|
|
11194
|
+
"Interactive mode requires a TTY terminal",
|
|
11195
|
+
"HELP_NO_TTY"
|
|
11196
|
+
);
|
|
11197
|
+
}
|
|
11198
|
+
return this.error(
|
|
11199
|
+
"Interactive help failed",
|
|
11200
|
+
"HELP_INTERACTIVE_ERROR",
|
|
11201
|
+
error?.message
|
|
11202
|
+
);
|
|
11203
|
+
}
|
|
11204
|
+
}
|
|
11205
|
+
let output3 = "";
|
|
11206
|
+
if (flags.search) {
|
|
11207
|
+
output3 = renderSearchHelp(metas, flags.search, {
|
|
11208
|
+
advanced: flags.advanced,
|
|
11209
|
+
showAliases: flags.aliases,
|
|
11210
|
+
matchMode: flags.matchMode || "any"
|
|
11211
|
+
});
|
|
11212
|
+
} else if (flags.category) {
|
|
11213
|
+
output3 = renderCategoryHelp(metas, flags.category, {
|
|
11214
|
+
advanced: flags.advanced,
|
|
11215
|
+
showAliases: flags.aliases
|
|
11216
|
+
});
|
|
11217
|
+
} else if (flags.all) {
|
|
11218
|
+
output3 = renderFullHelp(metas, {
|
|
11219
|
+
advanced: flags.advanced,
|
|
11220
|
+
showAliases: flags.aliases,
|
|
11221
|
+
heading: "\u{1F4D6} MARIA Commands \u2014 Full Listing"
|
|
11222
|
+
});
|
|
11223
|
+
} else {
|
|
11224
|
+
output3 = renderCompactHelp(metas, {
|
|
11225
|
+
maxPrimaryPerCategory: 3,
|
|
11226
|
+
showAdvanced: flags.advanced,
|
|
11227
|
+
twoColumnThreshold: 100,
|
|
11228
|
+
heading: "\u{1F4D6} MARIA Commands (compact \u2022 primary only)"
|
|
11229
|
+
});
|
|
11230
|
+
}
|
|
11231
|
+
return this.success(output3);
|
|
11232
|
+
} catch (error) {
|
|
11233
|
+
return this.handleError(error);
|
|
9816
11234
|
}
|
|
9817
|
-
return Array.from(categories);
|
|
9818
11235
|
}
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
const command = this.getCommand(commandName);
|
|
9824
|
-
if (!command) return false;
|
|
9825
|
-
return true;
|
|
9826
|
-
}
|
|
9827
|
-
/**
|
|
9828
|
-
* Create a helper context for testing
|
|
9829
|
-
*/
|
|
9830
|
-
static createTestContext(deps, overrides) {
|
|
11236
|
+
parseFlags(args) {
|
|
11237
|
+
const { parsed, options, flags } = args;
|
|
11238
|
+
const positional = parsed?.positional || [];
|
|
11239
|
+
const category = positional[0] && !positional[0].startsWith("-") ? positional[0] : void 0;
|
|
9831
11240
|
return {
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
11241
|
+
category,
|
|
11242
|
+
search: this.getStringOption(options, "search"),
|
|
11243
|
+
all: this.getBoolFlag(options, flags, "all"),
|
|
11244
|
+
advanced: this.getBoolFlag(options, flags, "advanced"),
|
|
11245
|
+
aliases: this.getBoolFlag(options, flags, "aliases"),
|
|
11246
|
+
interactive: this.getBoolFlag(options, flags, "interactive"),
|
|
11247
|
+
json: this.getBoolFlag(options, flags, "json"),
|
|
11248
|
+
matchMode: this.getStringOption(options, "match") || "any"
|
|
9838
11249
|
};
|
|
9839
11250
|
}
|
|
11251
|
+
getBoolFlag(options, flags, key2) {
|
|
11252
|
+
const optValue = options?.[key2];
|
|
11253
|
+
const flagValue = flags?.[key2];
|
|
11254
|
+
if (typeof optValue === "boolean") return optValue;
|
|
11255
|
+
if (typeof flagValue === "boolean") return flagValue;
|
|
11256
|
+
if (typeof optValue === "string")
|
|
11257
|
+
return optValue === "true" || optValue === "";
|
|
11258
|
+
if (typeof flagValue === "string")
|
|
11259
|
+
return flagValue === "true" || flagValue === "";
|
|
11260
|
+
return !!optValue || !!flagValue;
|
|
11261
|
+
}
|
|
11262
|
+
getStringOption(options, key2) {
|
|
11263
|
+
const value = options?.[key2];
|
|
11264
|
+
return typeof value === "string" ? value : void 0;
|
|
11265
|
+
}
|
|
11266
|
+
handleError(error) {
|
|
11267
|
+
console.error("[help] Command failed:", error);
|
|
11268
|
+
if (this.metadataManager.hasStaleCache()) {
|
|
11269
|
+
console.warn("[help] Using stale cache as fallback");
|
|
11270
|
+
try {
|
|
11271
|
+
const staleContainer = this.metadataManager.getStaleCache();
|
|
11272
|
+
if (staleContainer) {
|
|
11273
|
+
const output3 = renderCompactHelp(staleContainer.commands, {
|
|
11274
|
+
heading: "\u{1F4D6} MARIA Commands (using cached data - may be outdated)"
|
|
11275
|
+
});
|
|
11276
|
+
return this.success(
|
|
11277
|
+
output3 + "\n\n\u26A0\uFE0F Using stale cache. Run: npx tsx scripts/generate-help-meta.ts"
|
|
11278
|
+
);
|
|
11279
|
+
}
|
|
11280
|
+
} catch (fallbackError) {
|
|
11281
|
+
console.error("[help] Stale cache fallback failed:", fallbackError);
|
|
11282
|
+
}
|
|
11283
|
+
}
|
|
11284
|
+
const fallbackHelp = [
|
|
11285
|
+
"\u{1F4D6} MARIA Commands",
|
|
11286
|
+
"",
|
|
11287
|
+
"Help metadata unavailable.",
|
|
11288
|
+
`Reason: ${error?.message || error}`,
|
|
11289
|
+
"",
|
|
11290
|
+
"Try:",
|
|
11291
|
+
" \u2022 npx tsx scripts/generate-help-meta.ts",
|
|
11292
|
+
" \u2022 Check that command-meta.json exists and is valid",
|
|
11293
|
+
"",
|
|
11294
|
+
"For immediate help, use individual command --help flags.",
|
|
11295
|
+
""
|
|
11296
|
+
].join("\n");
|
|
11297
|
+
return this.success(fallbackHelp);
|
|
11298
|
+
}
|
|
11299
|
+
async validate(args) {
|
|
11300
|
+
const flags = this.parseFlags(args);
|
|
11301
|
+
if (flags.search !== void 0 && (flags.search === "" || flags.search.length < 2)) {
|
|
11302
|
+
return {
|
|
11303
|
+
success: false,
|
|
11304
|
+
error: "Search term must be at least 2 characters long"
|
|
11305
|
+
};
|
|
11306
|
+
}
|
|
11307
|
+
if (flags.matchMode && !["any", "all"].includes(flags.matchMode)) {
|
|
11308
|
+
return {
|
|
11309
|
+
success: false,
|
|
11310
|
+
error: 'Match mode must be either "any" or "all"'
|
|
11311
|
+
};
|
|
11312
|
+
}
|
|
11313
|
+
if (flags.interactive && !process.stdout.isTTY) {
|
|
11314
|
+
return {
|
|
11315
|
+
success: false,
|
|
11316
|
+
error: "Interactive mode requires a TTY terminal"
|
|
11317
|
+
};
|
|
11318
|
+
}
|
|
11319
|
+
return { success: true };
|
|
11320
|
+
}
|
|
9840
11321
|
};
|
|
9841
11322
|
}
|
|
9842
11323
|
});
|
|
@@ -9846,6 +11327,7 @@ var LegacySlashCommandAdapter, SlashCommandHandler2;
|
|
|
9846
11327
|
var init_LegacySlashCommandAdapter = __esm({
|
|
9847
11328
|
"src/shared/adapters/LegacySlashCommandAdapter.ts"() {
|
|
9848
11329
|
init_SlashCommandHandler();
|
|
11330
|
+
init_HelpCommand();
|
|
9849
11331
|
LegacySlashCommandAdapter = class _LegacySlashCommandAdapter {
|
|
9850
11332
|
static instance = null;
|
|
9851
11333
|
handler;
|
|
@@ -9857,6 +11339,7 @@ var init_LegacySlashCommandAdapter = __esm({
|
|
|
9857
11339
|
ui: null
|
|
9858
11340
|
};
|
|
9859
11341
|
this.handler = new SlashCommandHandlerV2(deps);
|
|
11342
|
+
this.registerEssentialCommands();
|
|
9860
11343
|
}
|
|
9861
11344
|
/**
|
|
9862
11345
|
* Legacy getInstance method for backward compatibility
|
|
@@ -9916,6 +11399,48 @@ var init_LegacySlashCommandAdapter = __esm({
|
|
|
9916
11399
|
};
|
|
9917
11400
|
this.handler.register(newCommand);
|
|
9918
11401
|
}
|
|
11402
|
+
/**
|
|
11403
|
+
* Register essential commands that should be available in legacy sessions
|
|
11404
|
+
*/
|
|
11405
|
+
registerEssentialCommands() {
|
|
11406
|
+
try {
|
|
11407
|
+
const helpCommand = new HelpCommandV2();
|
|
11408
|
+
const helpCommandV2 = {
|
|
11409
|
+
name: "help",
|
|
11410
|
+
aliases: ["h", "?"],
|
|
11411
|
+
description: helpCommand.description,
|
|
11412
|
+
category: helpCommand.category,
|
|
11413
|
+
execute: async (context2) => {
|
|
11414
|
+
try {
|
|
11415
|
+
const result = await helpCommand.execute({
|
|
11416
|
+
raw: context2.args?.join(" ") || "",
|
|
11417
|
+
parsed: {
|
|
11418
|
+
positional: context2.args || [],
|
|
11419
|
+
named: {},
|
|
11420
|
+
flags: {}
|
|
11421
|
+
},
|
|
11422
|
+
options: {},
|
|
11423
|
+
flags: {}
|
|
11424
|
+
}, context2);
|
|
11425
|
+
return {
|
|
11426
|
+
success: result.success,
|
|
11427
|
+
messages: [{ role: "assistant", content: result.message || result.data || "" }],
|
|
11428
|
+
error: result.error
|
|
11429
|
+
};
|
|
11430
|
+
} catch (error) {
|
|
11431
|
+
return {
|
|
11432
|
+
success: false,
|
|
11433
|
+
error: error instanceof Error ? error.message : "Help command failed",
|
|
11434
|
+
messages: []
|
|
11435
|
+
};
|
|
11436
|
+
}
|
|
11437
|
+
}
|
|
11438
|
+
};
|
|
11439
|
+
this.handler.register(helpCommandV2);
|
|
11440
|
+
} catch (error) {
|
|
11441
|
+
console.warn("Failed to register essential commands:", error);
|
|
11442
|
+
}
|
|
11443
|
+
}
|
|
9919
11444
|
/**
|
|
9920
11445
|
* Get the underlying SlashCommandHandlerV2 instance
|
|
9921
11446
|
*/
|
|
@@ -11222,10 +12747,10 @@ var init_interactive_cli = __esm({
|
|
|
11222
12747
|
this.selectedIndex = 0;
|
|
11223
12748
|
this.isShowingSuggestions = false;
|
|
11224
12749
|
process.stdout.write(prompt);
|
|
11225
|
-
return new Promise((
|
|
12750
|
+
return new Promise((resolve4) => {
|
|
11226
12751
|
const handler = (input4) => {
|
|
11227
12752
|
this.rl.removeListener("line", handler);
|
|
11228
|
-
|
|
12753
|
+
resolve4(input4);
|
|
11229
12754
|
};
|
|
11230
12755
|
this.rl.on("line", handler);
|
|
11231
12756
|
});
|
|
@@ -11260,8 +12785,8 @@ var init_interactive_cli = __esm({
|
|
|
11260
12785
|
}
|
|
11261
12786
|
});
|
|
11262
12787
|
function loadEnvironmentVariables() {
|
|
11263
|
-
const _envPath =
|
|
11264
|
-
if (
|
|
12788
|
+
const _envPath = path8__namespace.join(process.cwd(), ".env");
|
|
12789
|
+
if (fs6__namespace.existsSync(_envPath)) {
|
|
11265
12790
|
const _result = dotenv__namespace.config({ path: _envPath });
|
|
11266
12791
|
if (_result.error) {
|
|
11267
12792
|
console.warn("Error loading .env:", _result.error);
|
|
@@ -11269,8 +12794,8 @@ function loadEnvironmentVariables() {
|
|
|
11269
12794
|
console.log("\u2705 Loaded environment from .env");
|
|
11270
12795
|
}
|
|
11271
12796
|
}
|
|
11272
|
-
const _lmstudioEnvPath =
|
|
11273
|
-
if (
|
|
12797
|
+
const _lmstudioEnvPath = path8__namespace.join(process.cwd(), ".env.lmstudio");
|
|
12798
|
+
if (fs6__namespace.existsSync(_lmstudioEnvPath)) {
|
|
11274
12799
|
const _result = dotenv__namespace.config({ path: _lmstudioEnvPath, override: false });
|
|
11275
12800
|
if (_result.error) {
|
|
11276
12801
|
console.warn("Error loading .env.lmstudio:", _result.error);
|
|
@@ -11301,25 +12826,25 @@ function getPackageJson() {
|
|
|
11301
12826
|
try {
|
|
11302
12827
|
const possiblePaths = [
|
|
11303
12828
|
// When running from built dist/
|
|
11304
|
-
|
|
12829
|
+
path8.join(__dirname, "../../package.json"),
|
|
11305
12830
|
// When running from source
|
|
11306
|
-
|
|
12831
|
+
path8.join(__dirname, "../../../package.json"),
|
|
11307
12832
|
// Current working directory
|
|
11308
|
-
|
|
12833
|
+
path8.join(process.cwd(), "package.json"),
|
|
11309
12834
|
// One level up from current working directory
|
|
11310
|
-
|
|
12835
|
+
path8.join(process.cwd(), "../package.json"),
|
|
11311
12836
|
// For globally installed packages
|
|
11312
|
-
|
|
11313
|
-
|
|
12837
|
+
path8.join(__dirname, "../../../../package.json"),
|
|
12838
|
+
path8.join(__dirname, "../../../../../package.json"),
|
|
11314
12839
|
// npm global install locations
|
|
11315
12840
|
"/usr/local/lib/node_modules/@bonginkan/maria/package.json",
|
|
11316
12841
|
"/usr/lib/node_modules/@bonginkan/maria/package.json",
|
|
11317
12842
|
// User home npm global
|
|
11318
|
-
|
|
12843
|
+
path8.join(
|
|
11319
12844
|
process.env.HOME || "",
|
|
11320
12845
|
".npm-global/lib/node_modules/@bonginkan/maria/package.json"
|
|
11321
12846
|
),
|
|
11322
|
-
|
|
12847
|
+
path8.join(
|
|
11323
12848
|
process.env.HOME || "",
|
|
11324
12849
|
".nvm/versions/node",
|
|
11325
12850
|
process.version,
|
|
@@ -11327,13 +12852,13 @@ function getPackageJson() {
|
|
|
11327
12852
|
)
|
|
11328
12853
|
];
|
|
11329
12854
|
let packageJsonPath = null;
|
|
11330
|
-
for (const
|
|
11331
|
-
if (
|
|
12855
|
+
for (const path9 of possiblePaths) {
|
|
12856
|
+
if (fs6.existsSync(path9)) {
|
|
11332
12857
|
try {
|
|
11333
|
-
const content =
|
|
12858
|
+
const content = fs6.readFileSync(path9, "utf-8");
|
|
11334
12859
|
const parsed = JSON.parse(content);
|
|
11335
12860
|
if (parsed.name === "@bonginkan/maria") {
|
|
11336
|
-
packageJsonPath =
|
|
12861
|
+
packageJsonPath = path9;
|
|
11337
12862
|
break;
|
|
11338
12863
|
}
|
|
11339
12864
|
} catch {
|
|
@@ -11344,7 +12869,7 @@ function getPackageJson() {
|
|
|
11344
12869
|
if (!packageJsonPath) {
|
|
11345
12870
|
throw new Error("package.json not found in any expected location");
|
|
11346
12871
|
}
|
|
11347
|
-
const packageJsonContent =
|
|
12872
|
+
const packageJsonContent = fs6.readFileSync(packageJsonPath, "utf-8");
|
|
11348
12873
|
_cachedPackageJson = JSON.parse(packageJsonContent);
|
|
11349
12874
|
return _cachedPackageJson;
|
|
11350
12875
|
} catch (error) {
|
|
@@ -11359,121 +12884,6 @@ var init_version = __esm({
|
|
|
11359
12884
|
getVersion();
|
|
11360
12885
|
}
|
|
11361
12886
|
});
|
|
11362
|
-
var LogLevel, Logger, logger, envLogLevel;
|
|
11363
|
-
var init_logger = __esm({
|
|
11364
|
-
"src/utils/logger.ts"() {
|
|
11365
|
-
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
11366
|
-
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
11367
|
-
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
11368
|
-
LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
|
|
11369
|
-
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
11370
|
-
LogLevel2[LogLevel2["NONE"] = 4] = "NONE";
|
|
11371
|
-
return LogLevel2;
|
|
11372
|
-
})(LogLevel || {});
|
|
11373
|
-
Logger = class {
|
|
11374
|
-
level = 2 /* WARN */;
|
|
11375
|
-
// Default to WARN to reduce noise
|
|
11376
|
-
prefix = "[MARIA CODE]";
|
|
11377
|
-
setLevel(level) {
|
|
11378
|
-
this.level = level;
|
|
11379
|
-
}
|
|
11380
|
-
debug(...args) {
|
|
11381
|
-
if (this.level <= 0 /* DEBUG */) {
|
|
11382
|
-
console.log(chalk13__default.default.magenta(`${this.prefix} [DEBUG]`), ...args);
|
|
11383
|
-
}
|
|
11384
|
-
}
|
|
11385
|
-
info(...args) {
|
|
11386
|
-
if (this.level <= 1 /* INFO */) {
|
|
11387
|
-
console.log(chalk13__default.default.bold.magenta(`${this.prefix} [INFO]`), ...args);
|
|
11388
|
-
}
|
|
11389
|
-
}
|
|
11390
|
-
warn(...args) {
|
|
11391
|
-
if (this.level <= 2 /* WARN */) {
|
|
11392
|
-
console.warn(chalk13__default.default.bold.magenta(`${this.prefix} [WARN]`), ...args);
|
|
11393
|
-
}
|
|
11394
|
-
}
|
|
11395
|
-
error(...args) {
|
|
11396
|
-
if (this.level <= 3 /* ERROR */) {
|
|
11397
|
-
console.error(chalk13__default.default.bold.magenta(`${this.prefix} [ERROR]`), ...args);
|
|
11398
|
-
}
|
|
11399
|
-
}
|
|
11400
|
-
success(...args) {
|
|
11401
|
-
if (this.level <= 1 /* INFO */) {
|
|
11402
|
-
console.log(chalk13__default.default.bold.magenta(`${this.prefix} [SUCCESS]`), ...args);
|
|
11403
|
-
}
|
|
11404
|
-
}
|
|
11405
|
-
task(taskName, status, message) {
|
|
11406
|
-
if (this.level > 1 /* INFO */) {
|
|
11407
|
-
return;
|
|
11408
|
-
}
|
|
11409
|
-
const statusIcons = {
|
|
11410
|
-
start: "\u{1F680}",
|
|
11411
|
-
progress: "\u23F3",
|
|
11412
|
-
complete: "\u2705",
|
|
11413
|
-
error: "\u274C"
|
|
11414
|
-
};
|
|
11415
|
-
const statusColors = {
|
|
11416
|
-
start: chalk13__default.default.bold.magenta,
|
|
11417
|
-
progress: chalk13__default.default.magenta,
|
|
11418
|
-
complete: chalk13__default.default.bold.magenta,
|
|
11419
|
-
error: chalk13__default.default.bold.magenta
|
|
11420
|
-
};
|
|
11421
|
-
const icon = statusIcons[status];
|
|
11422
|
-
const color = statusColors[status];
|
|
11423
|
-
const formattedMessage = message ? `: ${message}` : "";
|
|
11424
|
-
console.log(color(`${this.prefix} ${icon} ${taskName}${formattedMessage}`));
|
|
11425
|
-
}
|
|
11426
|
-
table(data2) {
|
|
11427
|
-
if (this.level > 1 /* INFO */) {
|
|
11428
|
-
return;
|
|
11429
|
-
}
|
|
11430
|
-
console.table(data2);
|
|
11431
|
-
}
|
|
11432
|
-
json(obj, pretty = true) {
|
|
11433
|
-
if (this.level > 0 /* DEBUG */) {
|
|
11434
|
-
return;
|
|
11435
|
-
}
|
|
11436
|
-
console.log(chalk13__default.default.magenta(`${this.prefix} [JSON]`));
|
|
11437
|
-
console.log(pretty ? JSON.stringify(obj, null, 2) : JSON.stringify(obj));
|
|
11438
|
-
}
|
|
11439
|
-
divider() {
|
|
11440
|
-
if (this.level > 1 /* INFO */) {
|
|
11441
|
-
return;
|
|
11442
|
-
}
|
|
11443
|
-
console.log(chalk13__default.default.magenta("\u2500".repeat(60)));
|
|
11444
|
-
}
|
|
11445
|
-
clear() {
|
|
11446
|
-
console.clear();
|
|
11447
|
-
}
|
|
11448
|
-
/**
|
|
11449
|
-
* プログレスバーを表示
|
|
11450
|
-
*/
|
|
11451
|
-
progress(current, total, label) {
|
|
11452
|
-
if (this.level > 1 /* INFO */) {
|
|
11453
|
-
return;
|
|
11454
|
-
}
|
|
11455
|
-
const percentage = Math.round(current / total * 100);
|
|
11456
|
-
const barLength = 30;
|
|
11457
|
-
const filled = Math.round(percentage / 100 * barLength);
|
|
11458
|
-
const empty = barLength - filled;
|
|
11459
|
-
const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
|
|
11460
|
-
const progressText = `${current}/${total}`;
|
|
11461
|
-
const labelText = label ? ` ${label}` : "";
|
|
11462
|
-
process.stdout.write(
|
|
11463
|
-
`\r${chalk13__default.default.bold.magenta(bar)} ${percentage}% ${progressText}${labelText}`
|
|
11464
|
-
);
|
|
11465
|
-
if (current === total) {
|
|
11466
|
-
process.stdout.write("\n");
|
|
11467
|
-
}
|
|
11468
|
-
}
|
|
11469
|
-
};
|
|
11470
|
-
logger = new Logger();
|
|
11471
|
-
envLogLevel = process.env["MARIA_LOG_LEVEL"]?.toUpperCase();
|
|
11472
|
-
if (envLogLevel && LogLevel[envLogLevel] !== void 0) {
|
|
11473
|
-
logger.setLevel(LogLevel[envLogLevel]);
|
|
11474
|
-
}
|
|
11475
|
-
}
|
|
11476
|
-
});
|
|
11477
12887
|
|
|
11478
12888
|
// src/providers/ai-provider.ts
|
|
11479
12889
|
var BaseAIProvider;
|
|
@@ -12019,7 +13429,7 @@ var init_lmstudio_provider = __esm({
|
|
|
12019
13429
|
throw _error;
|
|
12020
13430
|
}
|
|
12021
13431
|
await new Promise(
|
|
12022
|
-
(
|
|
13432
|
+
(resolve4) => setTimeout(resolve4, this.retryDelay * Math.pow(2, i2))
|
|
12023
13433
|
);
|
|
12024
13434
|
}
|
|
12025
13435
|
}
|
|
@@ -12930,23 +14340,23 @@ var init_default_provider = __esm({
|
|
|
12930
14340
|
function loadConfig() {
|
|
12931
14341
|
let currentDir = process.cwd();
|
|
12932
14342
|
while (currentDir !== "/") {
|
|
12933
|
-
const _configPath =
|
|
12934
|
-
if (
|
|
14343
|
+
const _configPath = path8.join(currentDir, _CONFIG_FILE);
|
|
14344
|
+
if (fs6.existsSync(_configPath)) {
|
|
12935
14345
|
try {
|
|
12936
|
-
const _content =
|
|
14346
|
+
const _content = fs6.readFileSync(_configPath, "utf-8");
|
|
12937
14347
|
return toml.parse(_content);
|
|
12938
14348
|
} catch {
|
|
12939
14349
|
}
|
|
12940
14350
|
}
|
|
12941
|
-
const _parentDir =
|
|
14351
|
+
const _parentDir = path8.join(currentDir, "..");
|
|
12942
14352
|
if (_parentDir === currentDir) {
|
|
12943
14353
|
break;
|
|
12944
14354
|
}
|
|
12945
14355
|
currentDir = _parentDir;
|
|
12946
14356
|
}
|
|
12947
|
-
if (
|
|
14357
|
+
if (fs6.existsSync(_GLOBAL_CONFIG_PATH)) {
|
|
12948
14358
|
try {
|
|
12949
|
-
const _content =
|
|
14359
|
+
const _content = fs6.readFileSync(_GLOBAL_CONFIG_PATH, "utf-8");
|
|
12950
14360
|
return toml.parse(_content);
|
|
12951
14361
|
} catch {
|
|
12952
14362
|
}
|
|
@@ -12987,7 +14397,7 @@ var _CONFIG_FILE, _GLOBAL_CONFIG_PATH;
|
|
|
12987
14397
|
var init_config2 = __esm({
|
|
12988
14398
|
"src/utils/config.ts"() {
|
|
12989
14399
|
_CONFIG_FILE = ".maria-code.toml";
|
|
12990
|
-
_GLOBAL_CONFIG_PATH =
|
|
14400
|
+
_GLOBAL_CONFIG_PATH = path8.join(os2.homedir(), ".maria-code", "_config.toml");
|
|
12991
14401
|
}
|
|
12992
14402
|
});
|
|
12993
14403
|
|
|
@@ -13505,7 +14915,7 @@ Include: function descriptions, parameter explanations, return values, usage exa
|
|
|
13505
14915
|
// Helper methods
|
|
13506
14916
|
async detectFramework() {
|
|
13507
14917
|
try {
|
|
13508
|
-
const _packageJson = await
|
|
14918
|
+
const _packageJson = await fs8__namespace.readFile("package.json", "utf-8");
|
|
13509
14919
|
const _pkg = JSON.parse(_packageJson);
|
|
13510
14920
|
if (_pkg.dependencies?.react || _pkg.devDependencies?.react) {
|
|
13511
14921
|
return "React";
|
|
@@ -13531,7 +14941,7 @@ Include: function descriptions, parameter explanations, return values, usage exa
|
|
|
13531
14941
|
}
|
|
13532
14942
|
async detectProjectType() {
|
|
13533
14943
|
try {
|
|
13534
|
-
const _files = await
|
|
14944
|
+
const _files = await fs8__namespace.readdir(process.cwd());
|
|
13535
14945
|
if (_files.includes("package.json")) {
|
|
13536
14946
|
return "Node.js";
|
|
13537
14947
|
}
|
|
@@ -13554,7 +14964,7 @@ Include: function descriptions, parameter explanations, return values, usage exa
|
|
|
13554
14964
|
async detectTestFramework(_context) {
|
|
13555
14965
|
if (_context.language === "javascript" || _context.language === "typescript") {
|
|
13556
14966
|
try {
|
|
13557
|
-
const _packageJson = await
|
|
14967
|
+
const _packageJson = await fs8__namespace.readFile("package.json", "utf-8");
|
|
13558
14968
|
const _pkg = JSON.parse(_packageJson);
|
|
13559
14969
|
if (_pkg.devDependencies?.jest) {
|
|
13560
14970
|
return "Jest";
|
|
@@ -13601,7 +15011,7 @@ Include: function descriptions, parameter explanations, return values, usage exa
|
|
|
13601
15011
|
};
|
|
13602
15012
|
LanguageDetector = class {
|
|
13603
15013
|
async detectFromFile(_filePath) {
|
|
13604
|
-
const _ext =
|
|
15014
|
+
const _ext = path8__namespace.extname(_filePath).toLowerCase();
|
|
13605
15015
|
const languageMap = {
|
|
13606
15016
|
".js": "javascript",
|
|
13607
15017
|
".jsx": "javascript",
|
|
@@ -14070,21 +15480,21 @@ var init_llm_health_checker = __esm({
|
|
|
14070
15480
|
}
|
|
14071
15481
|
async startLMStudio() {
|
|
14072
15482
|
try {
|
|
14073
|
-
const { spawn } = await import('child_process');
|
|
15483
|
+
const { spawn: spawn2 } = await import('child_process');
|
|
14074
15484
|
const _lmsPath = "/Users/bongin_max/.lmstudio/bin/lms";
|
|
14075
|
-
return new Promise((
|
|
14076
|
-
const _child =
|
|
15485
|
+
return new Promise((resolve4) => {
|
|
15486
|
+
const _child = spawn2(_lmsPath, ["server", "start"], {
|
|
14077
15487
|
stdio: "ignore",
|
|
14078
15488
|
detached: true
|
|
14079
15489
|
});
|
|
14080
15490
|
child.on("_error", () => {
|
|
14081
|
-
|
|
15491
|
+
resolve4(false);
|
|
14082
15492
|
});
|
|
14083
15493
|
_child.on("spawn", () => {
|
|
14084
15494
|
child.unref();
|
|
14085
15495
|
setTimeout(async () => {
|
|
14086
15496
|
const _status = await this.checkService("LM Studio");
|
|
14087
|
-
|
|
15497
|
+
resolve4(_status.isRunning);
|
|
14088
15498
|
}, 3e3);
|
|
14089
15499
|
});
|
|
14090
15500
|
});
|
|
@@ -14098,22 +15508,15 @@ var init_llm_health_checker = __esm({
|
|
|
14098
15508
|
var ProviderSelector;
|
|
14099
15509
|
var init_provider_selector = __esm({
|
|
14100
15510
|
"src/services/provider-selector.ts"() {
|
|
14101
|
-
init_providers();
|
|
14102
15511
|
ProviderSelector = class {
|
|
14103
15512
|
config;
|
|
14104
|
-
|
|
14105
|
-
legacyProviderManager;
|
|
15513
|
+
providerManager;
|
|
14106
15514
|
constructor(_config) {
|
|
14107
15515
|
this.config = _config;
|
|
14108
|
-
this.
|
|
14109
|
-
this.legacyProviderManager = new UnifiedAIProviderManager2(_config);
|
|
15516
|
+
this.providerManager = new UnifiedAIProviderManager();
|
|
14110
15517
|
}
|
|
14111
15518
|
async initialize() {
|
|
14112
|
-
|
|
14113
|
-
await this.legacyProviderManager.initialize();
|
|
14114
|
-
} else {
|
|
14115
|
-
await this.modernProviderManager.initialize();
|
|
14116
|
-
}
|
|
15519
|
+
await this.providerManager.initialize();
|
|
14117
15520
|
}
|
|
14118
15521
|
async selectProvider() {
|
|
14119
15522
|
const providers = await this.getAvailableProviders();
|
|
@@ -17827,12 +19230,12 @@ var init_errors = __esm({
|
|
|
17827
19230
|
});
|
|
17828
19231
|
|
|
17829
19232
|
// src/services/interactive-session/core/SessionManager.ts
|
|
17830
|
-
var
|
|
19233
|
+
var SessionManager;
|
|
17831
19234
|
var init_SessionManager = __esm({
|
|
17832
19235
|
"src/services/interactive-session/core/SessionManager.ts"() {
|
|
17833
19236
|
init_SessionStateMachine();
|
|
17834
19237
|
init_errors();
|
|
17835
|
-
|
|
19238
|
+
SessionManager = class {
|
|
17836
19239
|
constructor(input4, display, command, options = {}) {
|
|
17837
19240
|
this.input = input4;
|
|
17838
19241
|
this.display = display;
|
|
@@ -18077,11 +19480,11 @@ var init_InputController = __esm({
|
|
|
18077
19480
|
try {
|
|
18078
19481
|
this.enableRawMode(true);
|
|
18079
19482
|
await this.installKeypress();
|
|
18080
|
-
const line = await new Promise((
|
|
19483
|
+
const line = await new Promise((resolve4) => {
|
|
18081
19484
|
const onKey = (str, key2) => {
|
|
18082
19485
|
if (key2?.name === "escape" && this.opts.escCancels)
|
|
18083
|
-
return
|
|
18084
|
-
if (key2?.ctrl && key2?.name === "c") return
|
|
19486
|
+
return resolve4(null);
|
|
19487
|
+
if (key2?.ctrl && key2?.name === "c") return resolve4(null);
|
|
18085
19488
|
if (key2?.name === "return" || key2?.name === "enter") {
|
|
18086
19489
|
return;
|
|
18087
19490
|
}
|
|
@@ -18090,7 +19493,7 @@ var init_InputController = __esm({
|
|
|
18090
19493
|
process$1.stdin.on("keypress", onKey);
|
|
18091
19494
|
this.rl.question("", (answer) => {
|
|
18092
19495
|
process$1.stdin.off("keypress", onKey);
|
|
18093
|
-
|
|
19496
|
+
resolve4(answer.trim());
|
|
18094
19497
|
});
|
|
18095
19498
|
});
|
|
18096
19499
|
this.lastSubmitAt = Date.now();
|
|
@@ -18139,11 +19542,11 @@ var init_InputController = __esm({
|
|
|
18139
19542
|
};
|
|
18140
19543
|
}
|
|
18141
19544
|
});
|
|
18142
|
-
var
|
|
19545
|
+
var ReadlineAdapter;
|
|
18143
19546
|
var init_ReadlineAdapter = __esm({
|
|
18144
19547
|
"src/services/interactive-session/adapters/ReadlineAdapter.ts"() {
|
|
18145
19548
|
init_InputController();
|
|
18146
|
-
|
|
19549
|
+
ReadlineAdapter = class {
|
|
18147
19550
|
rl;
|
|
18148
19551
|
inputController;
|
|
18149
19552
|
constructor() {
|
|
@@ -18159,10 +19562,10 @@ var init_ReadlineAdapter = __esm({
|
|
|
18159
19562
|
}
|
|
18160
19563
|
async readline(signal) {
|
|
18161
19564
|
if (signal?.aborted) return null;
|
|
18162
|
-
return new Promise((
|
|
18163
|
-
const abortHandler = () =>
|
|
19565
|
+
return new Promise((resolve4) => {
|
|
19566
|
+
const abortHandler = () => resolve4(null);
|
|
18164
19567
|
signal?.addEventListener("abort", abortHandler, { once: true });
|
|
18165
|
-
this.inputController.readline().then(
|
|
19568
|
+
this.inputController.readline().then(resolve4).catch(() => resolve4(null)).finally(() => {
|
|
18166
19569
|
signal?.removeEventListener("abort", abortHandler);
|
|
18167
19570
|
});
|
|
18168
19571
|
});
|
|
@@ -18188,10 +19591,10 @@ var init_ReadlineAdapter = __esm({
|
|
|
18188
19591
|
};
|
|
18189
19592
|
}
|
|
18190
19593
|
});
|
|
18191
|
-
var
|
|
19594
|
+
var ChalkAdapter;
|
|
18192
19595
|
var init_ChalkAdapter = __esm({
|
|
18193
19596
|
"src/services/interactive-session/adapters/ChalkAdapter.ts"() {
|
|
18194
|
-
|
|
19597
|
+
ChalkAdapter = class {
|
|
18195
19598
|
spinners = /* @__PURE__ */ new Map();
|
|
18196
19599
|
spinnerId = 0;
|
|
18197
19600
|
async showWelcome() {
|
|
@@ -20624,11 +22027,11 @@ var init_ConfigService = __esm({
|
|
|
20624
22027
|
_saveDebounceTimer = null;
|
|
20625
22028
|
_isDirty = false;
|
|
20626
22029
|
constructor(configDir = process.env.MARIA_CONFIG_DIR || "~/.maria") {
|
|
20627
|
-
this._configPath =
|
|
22030
|
+
this._configPath = path8__namespace.join(
|
|
20628
22031
|
this.expandHome(configDir),
|
|
20629
22032
|
"session.config.json"
|
|
20630
22033
|
);
|
|
20631
|
-
this._userConfigPath =
|
|
22034
|
+
this._userConfigPath = path8__namespace.join(
|
|
20632
22035
|
this.expandHome(configDir),
|
|
20633
22036
|
"user.config.json"
|
|
20634
22037
|
);
|
|
@@ -20649,7 +22052,7 @@ var init_ConfigService = __esm({
|
|
|
20649
22052
|
*/
|
|
20650
22053
|
async loadSystemConfig() {
|
|
20651
22054
|
try {
|
|
20652
|
-
const configFile = await
|
|
22055
|
+
const configFile = await fs8__namespace.readFile(this._configPath, "utf-8");
|
|
20653
22056
|
return JSON.parse(configFile);
|
|
20654
22057
|
} catch (error) {
|
|
20655
22058
|
return {};
|
|
@@ -20660,7 +22063,7 @@ var init_ConfigService = __esm({
|
|
|
20660
22063
|
*/
|
|
20661
22064
|
async loadUserConfig() {
|
|
20662
22065
|
try {
|
|
20663
|
-
const configFile = await
|
|
22066
|
+
const configFile = await fs8__namespace.readFile(this._userConfigPath, "utf-8");
|
|
20664
22067
|
return JSON.parse(configFile);
|
|
20665
22068
|
} catch (error) {
|
|
20666
22069
|
return {};
|
|
@@ -20703,8 +22106,8 @@ var init_ConfigService = __esm({
|
|
|
20703
22106
|
/**
|
|
20704
22107
|
* ネストされた設定値の取得
|
|
20705
22108
|
*/
|
|
20706
|
-
getNestedValue(
|
|
20707
|
-
const keys =
|
|
22109
|
+
getNestedValue(path9) {
|
|
22110
|
+
const keys = path9.split(".");
|
|
20708
22111
|
let value = this._config;
|
|
20709
22112
|
for (const key2 of keys) {
|
|
20710
22113
|
if (value && typeof value === "object" && key2 in value) {
|
|
@@ -20734,8 +22137,8 @@ var init_ConfigService = __esm({
|
|
|
20734
22137
|
/**
|
|
20735
22138
|
* ネストされた設定値の更新
|
|
20736
22139
|
*/
|
|
20737
|
-
async setNestedValue(
|
|
20738
|
-
const keys =
|
|
22140
|
+
async setNestedValue(path9, value) {
|
|
22141
|
+
const keys = path9.split(".");
|
|
20739
22142
|
const lastKey = keys.pop();
|
|
20740
22143
|
let target = this._config;
|
|
20741
22144
|
for (const key2 of keys) {
|
|
@@ -20748,7 +22151,7 @@ var init_ConfigService = __esm({
|
|
|
20748
22151
|
target[lastKey] = value;
|
|
20749
22152
|
this.validateConfig();
|
|
20750
22153
|
this.emitChange({
|
|
20751
|
-
path:
|
|
22154
|
+
path: path9,
|
|
20752
22155
|
oldValue,
|
|
20753
22156
|
newValue: value,
|
|
20754
22157
|
timestamp: /* @__PURE__ */ new Date()
|
|
@@ -20762,9 +22165,9 @@ var init_ConfigService = __esm({
|
|
|
20762
22165
|
async save() {
|
|
20763
22166
|
if (!this._isDirty) return;
|
|
20764
22167
|
try {
|
|
20765
|
-
const configDir =
|
|
20766
|
-
await
|
|
20767
|
-
await
|
|
22168
|
+
const configDir = path8__namespace.dirname(this._userConfigPath);
|
|
22169
|
+
await fs8__namespace.mkdir(configDir, { recursive: true });
|
|
22170
|
+
await fs8__namespace.writeFile(
|
|
20768
22171
|
this._userConfigPath,
|
|
20769
22172
|
JSON.stringify(this._config, null, 2),
|
|
20770
22173
|
"utf-8"
|
|
@@ -20793,8 +22196,8 @@ var init_ConfigService = __esm({
|
|
|
20793
22196
|
setupAutoSave() {
|
|
20794
22197
|
process.on("exit", () => {
|
|
20795
22198
|
if (this._isDirty) {
|
|
20796
|
-
const
|
|
20797
|
-
|
|
22199
|
+
const fs9 = __require("fs");
|
|
22200
|
+
fs9.writeFileSync(
|
|
20798
22201
|
this._userConfigPath,
|
|
20799
22202
|
JSON.stringify(this._config, null, 2),
|
|
20800
22203
|
"utf-8"
|
|
@@ -20805,13 +22208,13 @@ var init_ConfigService = __esm({
|
|
|
20805
22208
|
/**
|
|
20806
22209
|
* 変更リスナーの登録
|
|
20807
22210
|
*/
|
|
20808
|
-
onChange(
|
|
20809
|
-
if (!this._listeners.has(
|
|
20810
|
-
this._listeners.set(
|
|
22211
|
+
onChange(path9, listener) {
|
|
22212
|
+
if (!this._listeners.has(path9)) {
|
|
22213
|
+
this._listeners.set(path9, []);
|
|
20811
22214
|
}
|
|
20812
|
-
this._listeners.get(
|
|
22215
|
+
this._listeners.get(path9).push(listener);
|
|
20813
22216
|
return () => {
|
|
20814
|
-
const listeners = this._listeners.get(
|
|
22217
|
+
const listeners = this._listeners.get(path9);
|
|
20815
22218
|
if (listeners) {
|
|
20816
22219
|
const index = listeners.indexOf(listener);
|
|
20817
22220
|
if (index !== -1) {
|
|
@@ -20841,7 +22244,7 @@ var init_ConfigService = __esm({
|
|
|
20841
22244
|
* 設定のエクスポート
|
|
20842
22245
|
*/
|
|
20843
22246
|
async export(filePath) {
|
|
20844
|
-
await
|
|
22247
|
+
await fs8__namespace.writeFile(
|
|
20845
22248
|
filePath,
|
|
20846
22249
|
JSON.stringify(this._config, null, 2),
|
|
20847
22250
|
"utf-8"
|
|
@@ -20851,7 +22254,7 @@ var init_ConfigService = __esm({
|
|
|
20851
22254
|
* 設定のインポート
|
|
20852
22255
|
*/
|
|
20853
22256
|
async import(filePath) {
|
|
20854
|
-
const configFile = await
|
|
22257
|
+
const configFile = await fs8__namespace.readFile(filePath, "utf-8");
|
|
20855
22258
|
const importedConfig = JSON.parse(configFile);
|
|
20856
22259
|
this._config = SessionConfigSchema.parse(importedConfig);
|
|
20857
22260
|
this._isDirty = true;
|
|
@@ -20862,7 +22265,7 @@ var init_ConfigService = __esm({
|
|
|
20862
22265
|
*/
|
|
20863
22266
|
expandHome(filePath) {
|
|
20864
22267
|
if (filePath.startsWith("~/")) {
|
|
20865
|
-
return
|
|
22268
|
+
return path8__namespace.join(process.env.HOME || "", filePath.slice(2));
|
|
20866
22269
|
}
|
|
20867
22270
|
return filePath;
|
|
20868
22271
|
}
|
|
@@ -21300,7 +22703,7 @@ var init_ValidationService = __esm({
|
|
|
21300
22703
|
);
|
|
21301
22704
|
this._schemas.set(
|
|
21302
22705
|
"filePath",
|
|
21303
|
-
zod.z.string().min(1).max(this._config.maxFilePathLength).refine((
|
|
22706
|
+
zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path9) => !this.containsPathTraversal(path9), {
|
|
21304
22707
|
message: "Path traversal detected"
|
|
21305
22708
|
})
|
|
21306
22709
|
);
|
|
@@ -21439,11 +22842,11 @@ var init_ValidationService = __esm({
|
|
|
21439
22842
|
/**
|
|
21440
22843
|
* ファイルパス検証
|
|
21441
22844
|
*/
|
|
21442
|
-
validateFilePath(
|
|
22845
|
+
validateFilePath(path9) {
|
|
21443
22846
|
try {
|
|
21444
22847
|
const schema = this._schemas.get("filePath");
|
|
21445
|
-
const result = schema.parse(
|
|
21446
|
-
if (this.isSystemPath(
|
|
22848
|
+
const result = schema.parse(path9);
|
|
22849
|
+
if (this.isSystemPath(path9)) {
|
|
21447
22850
|
return {
|
|
21448
22851
|
valid: false,
|
|
21449
22852
|
errors: [
|
|
@@ -21589,8 +22992,8 @@ var init_ValidationService = __esm({
|
|
|
21589
22992
|
/**
|
|
21590
22993
|
* パストラバーサルの検出
|
|
21591
22994
|
*/
|
|
21592
|
-
containsPathTraversal(
|
|
21593
|
-
return /\.\.[/\\]/.test(
|
|
22995
|
+
containsPathTraversal(path9) {
|
|
22996
|
+
return /\.\.[/\\]/.test(path9) || path9.includes("..\\") || path9.includes("../");
|
|
21594
22997
|
}
|
|
21595
22998
|
/**
|
|
21596
22999
|
* 危険なコマンドの判定
|
|
@@ -21617,7 +23020,7 @@ var init_ValidationService = __esm({
|
|
|
21617
23020
|
/**
|
|
21618
23021
|
* システムパスの判定
|
|
21619
23022
|
*/
|
|
21620
|
-
isSystemPath(
|
|
23023
|
+
isSystemPath(path9) {
|
|
21621
23024
|
const systemPaths = [
|
|
21622
23025
|
"/etc",
|
|
21623
23026
|
"/sys",
|
|
@@ -21631,7 +23034,7 @@ var init_ValidationService = __esm({
|
|
|
21631
23034
|
"/sbin"
|
|
21632
23035
|
];
|
|
21633
23036
|
return systemPaths.some(
|
|
21634
|
-
(sysPath) =>
|
|
23037
|
+
(sysPath) => path9.toLowerCase().startsWith(sysPath.toLowerCase())
|
|
21635
23038
|
);
|
|
21636
23039
|
}
|
|
21637
23040
|
/**
|
|
@@ -23055,20 +24458,20 @@ var init_ApprovalEngine = __esm({
|
|
|
23055
24458
|
);
|
|
23056
24459
|
this.pendingRequests.set(_request.id, _request);
|
|
23057
24460
|
this.emit("approval-requested", _request);
|
|
23058
|
-
return new Promise((
|
|
24461
|
+
return new Promise((resolve4) => {
|
|
23059
24462
|
if (this.config.autoApprovalTimeout > 0 && _riskAssessment.overallRisk === "low") {
|
|
23060
24463
|
setTimeout(() => {
|
|
23061
24464
|
if (this.pendingRequests.has(_request.id)) {
|
|
23062
24465
|
this.pendingRequests.delete(_request.id);
|
|
23063
24466
|
this.emit("approval-timeout", { requestId: _request.id });
|
|
23064
|
-
|
|
24467
|
+
resolve4(this.createAutoApprovalResponse("Timeout auto-approval"));
|
|
23065
24468
|
}
|
|
23066
24469
|
}, this.config.autoApprovalTimeout);
|
|
23067
24470
|
}
|
|
23068
24471
|
this.once(
|
|
23069
24472
|
`approval-response-${_request.id}`,
|
|
23070
24473
|
(_response) => {
|
|
23071
|
-
|
|
24474
|
+
resolve4(_response);
|
|
23072
24475
|
}
|
|
23073
24476
|
);
|
|
23074
24477
|
});
|
|
@@ -24945,7 +26348,7 @@ var init_DisplayManager = __esm({
|
|
|
24945
26348
|
for (const frame of frames) {
|
|
24946
26349
|
this.clearLine();
|
|
24947
26350
|
this.write(frame);
|
|
24948
|
-
await new Promise((
|
|
26351
|
+
await new Promise((resolve4) => setTimeout(resolve4, intervalMs));
|
|
24949
26352
|
}
|
|
24950
26353
|
this.writeLine();
|
|
24951
26354
|
}
|
|
@@ -26274,8 +27677,8 @@ var init_SessionOrchestrator = __esm({
|
|
|
26274
27677
|
* UIサービスの初期化
|
|
26275
27678
|
*/
|
|
26276
27679
|
async initializeUIServices() {
|
|
26277
|
-
this._readlineAdapter = new
|
|
26278
|
-
this._chalkAdapter = new
|
|
27680
|
+
this._readlineAdapter = new ReadlineAdapter();
|
|
27681
|
+
this._chalkAdapter = new ChalkAdapter();
|
|
26279
27682
|
this._displayManager = new DisplayManager();
|
|
26280
27683
|
this._spinnerManager = SpinnerManager.getInstance();
|
|
26281
27684
|
this._statusDisplay = new StatusDisplay();
|
|
@@ -26354,7 +27757,7 @@ var init_SessionOrchestrator = __esm({
|
|
|
26354
27757
|
if (!this._inputController || !this._displayManager || !this._commandRegistry || !this._stateMachine) {
|
|
26355
27758
|
throw new Error("Required components not initialized");
|
|
26356
27759
|
}
|
|
26357
|
-
this._sessionManager = new
|
|
27760
|
+
this._sessionManager = new SessionManager(
|
|
26358
27761
|
this._inputController,
|
|
26359
27762
|
this._displayManager,
|
|
26360
27763
|
this._commandRegistry,
|
|
@@ -26438,15 +27841,15 @@ var init_SessionOrchestrator = __esm({
|
|
|
26438
27841
|
/**
|
|
26439
27842
|
* 設定の取得
|
|
26440
27843
|
*/
|
|
26441
|
-
getConfig(
|
|
26442
|
-
return this._configService?.getNestedValue(
|
|
27844
|
+
getConfig(path9) {
|
|
27845
|
+
return this._configService?.getNestedValue(path9);
|
|
26443
27846
|
}
|
|
26444
27847
|
/**
|
|
26445
27848
|
* 設定の更新
|
|
26446
27849
|
*/
|
|
26447
|
-
async setConfig(
|
|
27850
|
+
async setConfig(path9, value) {
|
|
26448
27851
|
if (this._configService) {
|
|
26449
|
-
await this._configService.setNestedValue(
|
|
27852
|
+
await this._configService.setNestedValue(path9, value);
|
|
26450
27853
|
}
|
|
26451
27854
|
}
|
|
26452
27855
|
/**
|
|
@@ -26541,91 +27944,11 @@ function createInteractiveSession(maria, config2) {
|
|
|
26541
27944
|
const orchestrator = new SessionOrchestrator(context2, config2);
|
|
26542
27945
|
return new RefactoredInteractiveSession(orchestrator);
|
|
26543
27946
|
}
|
|
26544
|
-
var
|
|
27947
|
+
var RefactoredInteractiveSession;
|
|
26545
27948
|
var init_interactive_session = __esm({
|
|
26546
27949
|
"src/services/interactive-session/index.ts"() {
|
|
26547
27950
|
init_SessionOrchestrator();
|
|
26548
27951
|
init_errors();
|
|
26549
|
-
CommandAdapter = class {
|
|
26550
|
-
constructor(maria) {
|
|
26551
|
-
this.maria = maria;
|
|
26552
|
-
}
|
|
26553
|
-
async execute(command, context2) {
|
|
26554
|
-
try {
|
|
26555
|
-
switch (command) {
|
|
26556
|
-
case "/help":
|
|
26557
|
-
return {
|
|
26558
|
-
ok: true,
|
|
26559
|
-
message: `\u{1F4D6} Available Commands:
|
|
26560
|
-
\u2022 /help - Show this help message
|
|
26561
|
-
\u2022 /clear - Clear the context
|
|
26562
|
-
\u2022 /status - Show system status
|
|
26563
|
-
\u2022 /model - Manage AI models
|
|
26564
|
-
\u2022 /code - Generate code
|
|
26565
|
-
\u2022 /exit - Exit the session`
|
|
26566
|
-
};
|
|
26567
|
-
case "/clear":
|
|
26568
|
-
return {
|
|
26569
|
-
ok: true,
|
|
26570
|
-
message: "\u{1F9F9} Context cleared"
|
|
26571
|
-
};
|
|
26572
|
-
case "/status":
|
|
26573
|
-
return {
|
|
26574
|
-
ok: true,
|
|
26575
|
-
message: "\u2705 System is operational"
|
|
26576
|
-
};
|
|
26577
|
-
default:
|
|
26578
|
-
return {
|
|
26579
|
-
ok: false,
|
|
26580
|
-
message: `Command ${command} is being migrated to the new system`
|
|
26581
|
-
};
|
|
26582
|
-
}
|
|
26583
|
-
} catch (error) {
|
|
26584
|
-
return {
|
|
26585
|
-
ok: false,
|
|
26586
|
-
message: `Error executing command: ${error}`
|
|
26587
|
-
};
|
|
26588
|
-
}
|
|
26589
|
-
}
|
|
26590
|
-
exists(command) {
|
|
26591
|
-
const knownCommands = [
|
|
26592
|
-
"/help",
|
|
26593
|
-
"/clear",
|
|
26594
|
-
"/status",
|
|
26595
|
-
"/model",
|
|
26596
|
-
"/code",
|
|
26597
|
-
"/exit",
|
|
26598
|
-
"/memory",
|
|
26599
|
-
"/test",
|
|
26600
|
-
"/review"
|
|
26601
|
-
];
|
|
26602
|
-
return knownCommands.includes(command.toLowerCase());
|
|
26603
|
-
}
|
|
26604
|
-
getAvailableCommands() {
|
|
26605
|
-
return [
|
|
26606
|
-
"/help",
|
|
26607
|
-
"/clear",
|
|
26608
|
-
"/status",
|
|
26609
|
-
"/model",
|
|
26610
|
-
"/code",
|
|
26611
|
-
"/exit",
|
|
26612
|
-
"/memory",
|
|
26613
|
-
"/test",
|
|
26614
|
-
"/review"
|
|
26615
|
-
];
|
|
26616
|
-
}
|
|
26617
|
-
getHelp(command) {
|
|
26618
|
-
const helpTexts = {
|
|
26619
|
-
"/help": "Show available commands",
|
|
26620
|
-
"/clear": "Clear the conversation context",
|
|
26621
|
-
"/status": "Show system status",
|
|
26622
|
-
"/model": "Select or view AI models",
|
|
26623
|
-
"/code": "Generate code from a description",
|
|
26624
|
-
"/exit": "Exit the session"
|
|
26625
|
-
};
|
|
26626
|
-
return helpTexts[command.toLowerCase()] || null;
|
|
26627
|
-
}
|
|
26628
|
-
};
|
|
26629
27952
|
RefactoredInteractiveSession = class {
|
|
26630
27953
|
orchestrator;
|
|
26631
27954
|
constructor(orchestrator) {
|
|
@@ -26644,20 +27967,13 @@ var init_interactive_session = __esm({
|
|
|
26644
27967
|
getStats() {
|
|
26645
27968
|
return this.orchestrator.getSessionStats();
|
|
26646
27969
|
}
|
|
26647
|
-
getConfig(
|
|
26648
|
-
return this.orchestrator.getConfig(
|
|
27970
|
+
getConfig(path9) {
|
|
27971
|
+
return this.orchestrator.getConfig(path9);
|
|
26649
27972
|
}
|
|
26650
|
-
async setConfig(
|
|
26651
|
-
await this.orchestrator.setConfig(
|
|
27973
|
+
async setConfig(path9, value) {
|
|
27974
|
+
await this.orchestrator.setConfig(path9, value);
|
|
26652
27975
|
}
|
|
26653
27976
|
};
|
|
26654
|
-
({
|
|
26655
|
-
SessionManager,
|
|
26656
|
-
ReadlineAdapter,
|
|
26657
|
-
ChalkAdapter,
|
|
26658
|
-
CommandAdapter,
|
|
26659
|
-
SessionOrchestrator
|
|
26660
|
-
});
|
|
26661
27977
|
}
|
|
26662
27978
|
});
|
|
26663
27979
|
|
|
@@ -26667,7 +27983,7 @@ var init_package = __esm({
|
|
|
26667
27983
|
"package.json"() {
|
|
26668
27984
|
package_default = {
|
|
26669
27985
|
name: "@bonginkan/maria",
|
|
26670
|
-
version: "3.6.
|
|
27986
|
+
version: "3.6.4",
|
|
26671
27987
|
description: "\u{1F680} MARIA v3.6.0 - Premier Enterprise AI Development Platform. Revolutionary multimodal intelligence featuring advanced orchestration, production-grade telemetry, and sophisticated workflow templates. Delivers 93% performance enhancement with real-time TUI monitoring, ML-powered model selection, quantum-resistant security architecture, and comprehensive observability. Battle-tested for enterprise deployment with exceptional reliability.",
|
|
26672
27988
|
keywords: [
|
|
26673
27989
|
"ai",
|
|
@@ -27250,7 +28566,7 @@ async function generateAIResponse(userInput) {
|
|
|
27250
28566
|
}
|
|
27251
28567
|
async function streamAIResponse(userInput) {
|
|
27252
28568
|
const thinkingInterval = startThinkingAnimation();
|
|
27253
|
-
await new Promise((
|
|
28569
|
+
await new Promise((resolve4) => setTimeout(resolve4, 200));
|
|
27254
28570
|
clearInterval(thinkingInterval);
|
|
27255
28571
|
process.stdout.write("\r" + " ".repeat(50) + "\r");
|
|
27256
28572
|
const response2 = await generateAIResponse(userInput);
|
|
@@ -27423,6 +28739,36 @@ async function startInteractiveSession() {
|
|
|
27423
28739
|
// wrapped for reference safety
|
|
27424
28740
|
}))
|
|
27425
28741
|
};
|
|
28742
|
+
if (command === "/help" || command === "help") {
|
|
28743
|
+
console.log(`
|
|
28744
|
+
\u{1F4D6} MARIA Commands (Basic Help)
|
|
28745
|
+
|
|
28746
|
+
\u{1F680} Core Commands:
|
|
28747
|
+
/help - Show this help message
|
|
28748
|
+
/clear - Clear conversation context
|
|
28749
|
+
/exit - Exit MARIA
|
|
28750
|
+
/status - Show system status
|
|
28751
|
+
/config - Show configuration
|
|
28752
|
+
/model - Select AI model
|
|
28753
|
+
|
|
28754
|
+
\u{1F3A8} Generation:
|
|
28755
|
+
/code - Generate/fix code
|
|
28756
|
+
/test - Generate tests
|
|
28757
|
+
/review - Review code
|
|
28758
|
+
|
|
28759
|
+
For full help, run: pnpm build and check documentation.
|
|
28760
|
+
`);
|
|
28761
|
+
continue;
|
|
28762
|
+
}
|
|
28763
|
+
if (command === "/code" || command === "code") {
|
|
28764
|
+
if (args.length === 0) {
|
|
28765
|
+
console.log("\u274C Please provide a code request. Example: /code create a REST API");
|
|
28766
|
+
continue;
|
|
28767
|
+
}
|
|
28768
|
+
console.log("\u{1F680} Processing code request...");
|
|
28769
|
+
console.log("\u26A0\uFE0F Note: /code command functionality is being restored. Please try the legacy command system or check back after further updates.");
|
|
28770
|
+
continue;
|
|
28771
|
+
}
|
|
27426
28772
|
try {
|
|
27427
28773
|
const result = await slashCommandHandler.handleCommand(
|
|
27428
28774
|
command,
|
|
@@ -27510,6 +28856,7 @@ async function startInteractiveSession() {
|
|
|
27510
28856
|
function createCLI2() {
|
|
27511
28857
|
const program2 = new commander.Command();
|
|
27512
28858
|
program2.name("maria").description(`\u{1F680} MARIA v${packageJson.version} - Intelligent AI Assistant`).version(packageJson.version).option("--v3-session", "Use v3 session architecture").option("--no-interactive", "Disable interactive mode for CI/CD").action(async (options) => {
|
|
28859
|
+
loadEnvironmentVariables();
|
|
27513
28860
|
const { displayFinalStartupScreen: displayFinalStartupScreen2 } = await Promise.resolve().then(() => (init_startup_display(), startup_display_exports));
|
|
27514
28861
|
displayFinalStartupScreen2();
|
|
27515
28862
|
const useV3 = options.v3Session || process.env.MARIA_USE_V3_SESSION === "1";
|