@danya-ai/cli 0.1.0
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/LICENSE +201 -0
- package/README.md +336 -0
- package/cli-acp.js +82 -0
- package/cli.js +105 -0
- package/dist/REPL-EYUOXCEC.js +42 -0
- package/dist/REPL-EYUOXCEC.js.map +7 -0
- package/dist/acp-S5WNCLMD.js +1372 -0
- package/dist/acp-S5WNCLMD.js.map +7 -0
- package/dist/agentsValidate-RQ2QDGNY.js +373 -0
- package/dist/agentsValidate-RQ2QDGNY.js.map +7 -0
- package/dist/ask-TX526UBD.js +129 -0
- package/dist/ask-TX526UBD.js.map +7 -0
- package/dist/autoUpdater-63RAZ24N.js +17 -0
- package/dist/autoUpdater-63RAZ24N.js.map +7 -0
- package/dist/chunk-2VQWLLDU.js +16 -0
- package/dist/chunk-2VQWLLDU.js.map +7 -0
- package/dist/chunk-4CLHMO4I.js +656 -0
- package/dist/chunk-4CLHMO4I.js.map +7 -0
- package/dist/chunk-4ZNNWJZU.js +5696 -0
- package/dist/chunk-4ZNNWJZU.js.map +7 -0
- package/dist/chunk-66EZC7Y7.js +149 -0
- package/dist/chunk-66EZC7Y7.js.map +7 -0
- package/dist/chunk-6EPQRP3S.js +96 -0
- package/dist/chunk-6EPQRP3S.js.map +7 -0
- package/dist/chunk-77IRSDFR.js +195 -0
- package/dist/chunk-77IRSDFR.js.map +7 -0
- package/dist/chunk-7RZNLBEK.js +136 -0
- package/dist/chunk-7RZNLBEK.js.map +7 -0
- package/dist/chunk-BNBV2FXC.js +19 -0
- package/dist/chunk-BNBV2FXC.js.map +7 -0
- package/dist/chunk-CQCREBDO.js +248 -0
- package/dist/chunk-CQCREBDO.js.map +7 -0
- package/dist/chunk-D77XS6TB.js +74 -0
- package/dist/chunk-D77XS6TB.js.map +7 -0
- package/dist/chunk-DHYBJN3V.js +474 -0
- package/dist/chunk-DHYBJN3V.js.map +7 -0
- package/dist/chunk-DLSLSLTR.js +842 -0
- package/dist/chunk-DLSLSLTR.js.map +7 -0
- package/dist/chunk-ELAE6Z4H.js +514 -0
- package/dist/chunk-ELAE6Z4H.js.map +7 -0
- package/dist/chunk-ELZQD7ZR.js +531 -0
- package/dist/chunk-ELZQD7ZR.js.map +7 -0
- package/dist/chunk-F6DEGMX6.js +31269 -0
- package/dist/chunk-F6DEGMX6.js.map +7 -0
- package/dist/chunk-GDF2AON2.js +124 -0
- package/dist/chunk-GDF2AON2.js.map +7 -0
- package/dist/chunk-H7BGBV4P.js +498 -0
- package/dist/chunk-H7BGBV4P.js.map +7 -0
- package/dist/chunk-HIIHGKXP.js +24 -0
- package/dist/chunk-HIIHGKXP.js.map +7 -0
- package/dist/chunk-HJCCXED7.js +17 -0
- package/dist/chunk-HJCCXED7.js.map +7 -0
- package/dist/chunk-IQ6VZB2Y.js +139 -0
- package/dist/chunk-IQ6VZB2Y.js.map +7 -0
- package/dist/chunk-J4D7AELD.js +518 -0
- package/dist/chunk-J4D7AELD.js.map +7 -0
- package/dist/chunk-JVGG2YQR.js +23 -0
- package/dist/chunk-JVGG2YQR.js.map +7 -0
- package/dist/chunk-LGEK2NV7.js +939 -0
- package/dist/chunk-LGEK2NV7.js.map +7 -0
- package/dist/chunk-LWXT5RGE.js +95 -0
- package/dist/chunk-LWXT5RGE.js.map +7 -0
- package/dist/chunk-M3TKNAUR.js +35 -0
- package/dist/chunk-M3TKNAUR.js.map +7 -0
- package/dist/chunk-MRFO7QO5.js +170 -0
- package/dist/chunk-MRFO7QO5.js.map +7 -0
- package/dist/chunk-MVN3DHQF.js +95 -0
- package/dist/chunk-MVN3DHQF.js.map +7 -0
- package/dist/chunk-O25PXGOC.js +772 -0
- package/dist/chunk-O25PXGOC.js.map +7 -0
- package/dist/chunk-OBGVKM3N.js +1618 -0
- package/dist/chunk-OBGVKM3N.js.map +7 -0
- package/dist/chunk-OV5HJXXQ.js +198 -0
- package/dist/chunk-OV5HJXXQ.js.map +7 -0
- package/dist/chunk-P5VWDMRD.js +249 -0
- package/dist/chunk-P5VWDMRD.js.map +7 -0
- package/dist/chunk-PDSAJX7G.js +49 -0
- package/dist/chunk-PDSAJX7G.js.map +7 -0
- package/dist/chunk-RHNEZOPO.js +739 -0
- package/dist/chunk-RHNEZOPO.js.map +7 -0
- package/dist/chunk-SQGAHZPM.js +3004 -0
- package/dist/chunk-SQGAHZPM.js.map +7 -0
- package/dist/chunk-U7Z4MXY4.js +21 -0
- package/dist/chunk-U7Z4MXY4.js.map +7 -0
- package/dist/chunk-UNCTVIS7.js +146 -0
- package/dist/chunk-UNCTVIS7.js.map +7 -0
- package/dist/chunk-VMEOI6MH.js +1103 -0
- package/dist/chunk-VMEOI6MH.js.map +7 -0
- package/dist/chunk-WAY3DKFO.js +47 -0
- package/dist/chunk-WAY3DKFO.js.map +7 -0
- package/dist/chunk-XEYEKVFT.js +24 -0
- package/dist/chunk-XEYEKVFT.js.map +7 -0
- package/dist/chunk-Y4BQ36T4.js +796 -0
- package/dist/chunk-Y4BQ36T4.js.map +7 -0
- package/dist/chunk-Y5LQPJWK.js +12 -0
- package/dist/chunk-Y5LQPJWK.js.map +7 -0
- package/dist/chunk-YIJWUNWF.js +1260 -0
- package/dist/chunk-YIJWUNWF.js.map +7 -0
- package/dist/chunk-YMIWYEZ7.js +34 -0
- package/dist/chunk-YMIWYEZ7.js.map +7 -0
- package/dist/cli-PQNZWJX4.js +3952 -0
- package/dist/cli-PQNZWJX4.js.map +7 -0
- package/dist/commands-HOBCZ3VQ.js +46 -0
- package/dist/commands-HOBCZ3VQ.js.map +7 -0
- package/dist/config-MLH7ZTFA.js +81 -0
- package/dist/config-MLH7ZTFA.js.map +7 -0
- package/dist/context-FZ6G4J63.js +30 -0
- package/dist/context-FZ6G4J63.js.map +7 -0
- package/dist/costTracker-5WKZXN5S.js +19 -0
- package/dist/costTracker-5WKZXN5S.js.map +7 -0
- package/dist/customCommands-EB4MMZSS.js +25 -0
- package/dist/customCommands-EB4MMZSS.js.map +7 -0
- package/dist/env-VMEIP4EW.js +28 -0
- package/dist/env-VMEIP4EW.js.map +7 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +7 -0
- package/dist/kodeAgentSessionId-WUT74FSH.js +16 -0
- package/dist/kodeAgentSessionId-WUT74FSH.js.map +7 -0
- package/dist/kodeAgentSessionLoad-KR4JSD6D.js +21 -0
- package/dist/kodeAgentSessionLoad-KR4JSD6D.js.map +7 -0
- package/dist/kodeAgentSessionResume-BCD6UV74.js +18 -0
- package/dist/kodeAgentSessionResume-BCD6UV74.js.map +7 -0
- package/dist/kodeAgentStreamJson-EDHHWNNX.js +15 -0
- package/dist/kodeAgentStreamJson-EDHHWNNX.js.map +7 -0
- package/dist/kodeAgentStreamJsonSession-G4RBNZRN.js +133 -0
- package/dist/kodeAgentStreamJsonSession-G4RBNZRN.js.map +7 -0
- package/dist/kodeAgentStructuredStdio-UA5P5UNU.js +11 -0
- package/dist/kodeAgentStructuredStdio-UA5P5UNU.js.map +7 -0
- package/dist/kodeHooks-EHM6GSIQ.js +37 -0
- package/dist/kodeHooks-EHM6GSIQ.js.map +7 -0
- package/dist/llm-SJXCV7DA.js +3138 -0
- package/dist/llm-SJXCV7DA.js.map +7 -0
- package/dist/llmLazy-2QYJVD6K.js +15 -0
- package/dist/llmLazy-2QYJVD6K.js.map +7 -0
- package/dist/loader-LJX77EFL.js +28 -0
- package/dist/loader-LJX77EFL.js.map +7 -0
- package/dist/mcp-DOROSLPN.js +49 -0
- package/dist/mcp-DOROSLPN.js.map +7 -0
- package/dist/mentionProcessor-5UZRHCGH.js +215 -0
- package/dist/mentionProcessor-5UZRHCGH.js.map +7 -0
- package/dist/messages-N5KBI53P.js +65 -0
- package/dist/messages-N5KBI53P.js.map +7 -0
- package/dist/model-HPLBR53R.js +30 -0
- package/dist/model-HPLBR53R.js.map +7 -0
- package/dist/openai-YP4OJYKF.js +29 -0
- package/dist/openai-YP4OJYKF.js.map +7 -0
- package/dist/outputStyles-NNALI5D7.js +28 -0
- package/dist/outputStyles-NNALI5D7.js.map +7 -0
- package/dist/package.json +4 -0
- package/dist/pluginRuntime-JYYI5BSQ.js +220 -0
- package/dist/pluginRuntime-JYYI5BSQ.js.map +7 -0
- package/dist/pluginValidation-JWUFPZUE.js +17 -0
- package/dist/pluginValidation-JWUFPZUE.js.map +7 -0
- package/dist/prompts-B2SS7CWI.js +50 -0
- package/dist/prompts-B2SS7CWI.js.map +7 -0
- package/dist/query-HIK457UU.js +50 -0
- package/dist/query-HIK457UU.js.map +7 -0
- package/dist/responsesStreaming-L2BSN37C.js +10 -0
- package/dist/responsesStreaming-L2BSN37C.js.map +7 -0
- package/dist/ripgrep-GCKI4UTL.js +17 -0
- package/dist/ripgrep-GCKI4UTL.js.map +7 -0
- package/dist/skillMarketplace-PCTUUX46.js +37 -0
- package/dist/skillMarketplace-PCTUUX46.js.map +7 -0
- package/dist/state-XJICGOUA.js +18 -0
- package/dist/state-XJICGOUA.js.map +7 -0
- package/dist/theme-DP7O4SGH.js +14 -0
- package/dist/theme-DP7O4SGH.js.map +7 -0
- package/dist/toolPermissionContext-DHAGUPEW.js +17 -0
- package/dist/toolPermissionContext-DHAGUPEW.js.map +7 -0
- package/dist/toolPermissionSettings-PT65MQIQ.js +18 -0
- package/dist/toolPermissionSettings-PT65MQIQ.js.map +7 -0
- package/dist/tools-BHW37PCF.js +47 -0
- package/dist/tools-BHW37PCF.js.map +7 -0
- package/dist/userInput-XDRYT5TI.js +316 -0
- package/dist/userInput-XDRYT5TI.js.map +7 -0
- package/dist/uuid-QUYJMIUV.js +9 -0
- package/dist/uuid-QUYJMIUV.js.map +7 -0
- package/dist/yoga.wasm +0 -0
- package/package.json +115 -0
- package/scripts/binary-utils.cjs +62 -0
- package/scripts/cli-acp-wrapper.cjs +82 -0
- package/scripts/cli-wrapper.cjs +105 -0
- package/scripts/postinstall.js +144 -0
- package/yoga.wasm +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
emitReminderEvent
|
|
5
|
+
} from "./chunk-J4D7AELD.js";
|
|
6
|
+
import "./chunk-XEYEKVFT.js";
|
|
7
|
+
import {
|
|
8
|
+
getAvailableAgentTypes
|
|
9
|
+
} from "./chunk-RHNEZOPO.js";
|
|
10
|
+
import "./chunk-WAY3DKFO.js";
|
|
11
|
+
import "./chunk-2VQWLLDU.js";
|
|
12
|
+
import {
|
|
13
|
+
debug
|
|
14
|
+
} from "./chunk-Y4BQ36T4.js";
|
|
15
|
+
import {
|
|
16
|
+
getCwd,
|
|
17
|
+
init_log,
|
|
18
|
+
init_state,
|
|
19
|
+
logError
|
|
20
|
+
} from "./chunk-SQGAHZPM.js";
|
|
21
|
+
import "./chunk-UNCTVIS7.js";
|
|
22
|
+
import "./chunk-M3TKNAUR.js";
|
|
23
|
+
|
|
24
|
+
// src/services/context/mentionProcessor.ts
|
|
25
|
+
init_state();
|
|
26
|
+
import { existsSync } from "fs";
|
|
27
|
+
import { resolve } from "path";
|
|
28
|
+
init_log();
|
|
29
|
+
var MentionProcessorService = class _MentionProcessorService {
|
|
30
|
+
static MENTION_PATTERNS = {
|
|
31
|
+
runAgent: /@(run-agent-[\w\-]+)/g,
|
|
32
|
+
agent: /@(agent-[\w\-]+)/g,
|
|
33
|
+
askModel: /@(ask-[\w\-]+)/g,
|
|
34
|
+
file: /@(?:"([^"\n]+)"|'([^'\n]+)'|([a-zA-Z0-9/._~:\\\\-]+))/g
|
|
35
|
+
};
|
|
36
|
+
agentCache = /* @__PURE__ */ new Map();
|
|
37
|
+
lastAgentCheck = 0;
|
|
38
|
+
CACHE_TTL = 6e4;
|
|
39
|
+
async processMentions(input) {
|
|
40
|
+
const result = {
|
|
41
|
+
agents: [],
|
|
42
|
+
files: [],
|
|
43
|
+
hasAgentMentions: false,
|
|
44
|
+
hasFileMentions: false
|
|
45
|
+
};
|
|
46
|
+
try {
|
|
47
|
+
const agentMentions = this.extractAgentMentions(input);
|
|
48
|
+
if (agentMentions.length > 0) {
|
|
49
|
+
await this.refreshAgentCache();
|
|
50
|
+
for (const { mention, agentType, isAskModel } of agentMentions) {
|
|
51
|
+
if (isAskModel || this.agentCache.has(agentType)) {
|
|
52
|
+
result.agents.push({
|
|
53
|
+
type: "agent",
|
|
54
|
+
mention,
|
|
55
|
+
resolved: agentType,
|
|
56
|
+
exists: true,
|
|
57
|
+
metadata: isAskModel ? { type: "ask-model" } : void 0
|
|
58
|
+
});
|
|
59
|
+
result.hasAgentMentions = true;
|
|
60
|
+
this.emitAgentMentionEvent(mention, agentType, isAskModel);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const fileMatches = [
|
|
65
|
+
...input.matchAll(_MentionProcessorService.MENTION_PATTERNS.file)
|
|
66
|
+
];
|
|
67
|
+
const processedAgentMentions = new Set(
|
|
68
|
+
agentMentions.map((am) => am.mention)
|
|
69
|
+
);
|
|
70
|
+
for (const match of fileMatches) {
|
|
71
|
+
const rawMention = match[0]?.slice(1) || "";
|
|
72
|
+
const mention = (match[1] ?? match[2] ?? match[3] ?? "").trim();
|
|
73
|
+
if (mention.startsWith("run-agent-") || mention.startsWith("agent-") || mention.startsWith("ask-") || processedAgentMentions.has(mention)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (!mention) continue;
|
|
77
|
+
const filePath = this.resolveFilePath(
|
|
78
|
+
this.normalizeFileMentionPath(mention)
|
|
79
|
+
);
|
|
80
|
+
if (existsSync(filePath)) {
|
|
81
|
+
result.files.push({
|
|
82
|
+
type: "file",
|
|
83
|
+
mention: rawMention || mention,
|
|
84
|
+
resolved: filePath,
|
|
85
|
+
exists: true
|
|
86
|
+
});
|
|
87
|
+
result.hasFileMentions = true;
|
|
88
|
+
emitReminderEvent("file:mentioned", {
|
|
89
|
+
filePath,
|
|
90
|
+
originalMention: rawMention || mention,
|
|
91
|
+
timestamp: Date.now()
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
logError(error);
|
|
98
|
+
debug.warn("MENTION_PROCESSOR_PROCESS_FAILED", {
|
|
99
|
+
input: input.substring(0, 100) + (input.length > 100 ? "..." : ""),
|
|
100
|
+
error: error instanceof Error ? error.message : error
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
agents: [],
|
|
104
|
+
files: [],
|
|
105
|
+
hasAgentMentions: false,
|
|
106
|
+
hasFileMentions: false
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
resolveFilePath(mention) {
|
|
111
|
+
return resolve(getCwd(), mention);
|
|
112
|
+
}
|
|
113
|
+
normalizeFileMentionPath(mention) {
|
|
114
|
+
return mention.replace(/\\ /g, " ");
|
|
115
|
+
}
|
|
116
|
+
async refreshAgentCache() {
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
if (now - this.lastAgentCheck < this.CACHE_TTL) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const agents = await getAvailableAgentTypes();
|
|
123
|
+
const previousCacheSize = this.agentCache.size;
|
|
124
|
+
this.agentCache.clear();
|
|
125
|
+
for (const agent of agents) {
|
|
126
|
+
this.agentCache.set(agent.agentType, true);
|
|
127
|
+
}
|
|
128
|
+
this.lastAgentCheck = now;
|
|
129
|
+
if (agents.length !== previousCacheSize) {
|
|
130
|
+
debug.info("MENTION_PROCESSOR_CACHE_REFRESHED", {
|
|
131
|
+
agentCount: agents.length,
|
|
132
|
+
previousCacheSize,
|
|
133
|
+
cacheAge: now - this.lastAgentCheck
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
logError(error);
|
|
138
|
+
debug.warn("MENTION_PROCESSOR_CACHE_REFRESH_FAILED", {
|
|
139
|
+
error: error instanceof Error ? error.message : error,
|
|
140
|
+
cacheSize: this.agentCache.size,
|
|
141
|
+
lastRefresh: new Date(this.lastAgentCheck).toISOString()
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
extractAgentMentions(input) {
|
|
146
|
+
const mentions = [];
|
|
147
|
+
const runAgentMatches = [
|
|
148
|
+
...input.matchAll(_MentionProcessorService.MENTION_PATTERNS.runAgent)
|
|
149
|
+
];
|
|
150
|
+
for (const match of runAgentMatches) {
|
|
151
|
+
const mention = match[1];
|
|
152
|
+
const agentType = mention.replace(/^run-agent-/, "");
|
|
153
|
+
mentions.push({ mention, agentType, isAskModel: false });
|
|
154
|
+
}
|
|
155
|
+
const agentMatches = [
|
|
156
|
+
...input.matchAll(_MentionProcessorService.MENTION_PATTERNS.agent)
|
|
157
|
+
];
|
|
158
|
+
for (const match of agentMatches) {
|
|
159
|
+
const mention = match[1];
|
|
160
|
+
const agentType = mention.replace(/^agent-/, "");
|
|
161
|
+
mentions.push({ mention, agentType, isAskModel: false });
|
|
162
|
+
}
|
|
163
|
+
const askModelMatches = [
|
|
164
|
+
...input.matchAll(_MentionProcessorService.MENTION_PATTERNS.askModel)
|
|
165
|
+
];
|
|
166
|
+
for (const match of askModelMatches) {
|
|
167
|
+
const mention = match[1];
|
|
168
|
+
mentions.push({ mention, agentType: mention, isAskModel: true });
|
|
169
|
+
}
|
|
170
|
+
return mentions;
|
|
171
|
+
}
|
|
172
|
+
emitAgentMentionEvent(mention, agentType, isAskModel) {
|
|
173
|
+
try {
|
|
174
|
+
const eventData = {
|
|
175
|
+
originalMention: mention,
|
|
176
|
+
timestamp: Date.now()
|
|
177
|
+
};
|
|
178
|
+
if (isAskModel) {
|
|
179
|
+
emitReminderEvent("ask-model:mentioned", {
|
|
180
|
+
...eventData,
|
|
181
|
+
modelName: mention
|
|
182
|
+
});
|
|
183
|
+
} else {
|
|
184
|
+
emitReminderEvent("agent:mentioned", {
|
|
185
|
+
...eventData,
|
|
186
|
+
agentType
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
debug.info("MENTION_PROCESSOR_EVENT_EMITTED", {
|
|
190
|
+
type: isAskModel ? "ask-model" : "agent",
|
|
191
|
+
mention,
|
|
192
|
+
agentType: isAskModel ? void 0 : agentType
|
|
193
|
+
});
|
|
194
|
+
} catch (error) {
|
|
195
|
+
debug.error("MENTION_PROCESSOR_EVENT_FAILED", {
|
|
196
|
+
mention,
|
|
197
|
+
agentType,
|
|
198
|
+
isAskModel,
|
|
199
|
+
error: error instanceof Error ? error.message : error
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
clearCache() {
|
|
204
|
+
this.agentCache.clear();
|
|
205
|
+
this.lastAgentCheck = 0;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var mentionProcessor = new MentionProcessorService();
|
|
209
|
+
var processMentions = (input) => mentionProcessor.processMentions(input);
|
|
210
|
+
var clearMentionCache = () => mentionProcessor.clearCache();
|
|
211
|
+
export {
|
|
212
|
+
clearMentionCache,
|
|
213
|
+
mentionProcessor,
|
|
214
|
+
processMentions
|
|
215
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/services/context/mentionProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import { emitReminderEvent } from '@services/systemReminder'\r\nimport { getAvailableAgentTypes } from '@utils/agent/loader'\r\nimport { existsSync } from 'fs'\r\nimport { resolve } from 'path'\r\nimport { getCwd } from '@utils/state'\r\nimport { debug as debugLogger } from '@utils/log/debugLogger'\r\nimport { logError } from '@utils/log'\r\n\r\nexport interface MentionContext {\r\n type: 'agent' | 'file'\r\n mention: string\r\n resolved: string\r\n exists: boolean\r\n metadata?: any\r\n}\r\n\r\nexport interface ProcessedMentions {\r\n agents: MentionContext[]\r\n files: MentionContext[]\r\n hasAgentMentions: boolean\r\n hasFileMentions: boolean\r\n}\r\n\r\nclass MentionProcessorService {\r\n private static readonly MENTION_PATTERNS = {\r\n runAgent: /@(run-agent-[\\w\\-]+)/g,\r\n agent: /@(agent-[\\w\\-]+)/g,\r\n askModel: /@(ask-[\\w\\-]+)/g,\r\n file: /@(?:\"([^\"\\n]+)\"|'([^'\\n]+)'|([a-zA-Z0-9/._~:\\\\\\\\-]+))/g,\r\n } as const\r\n\r\n private agentCache: Map<string, boolean> = new Map()\r\n private lastAgentCheck: number = 0\r\n private CACHE_TTL = 60_000\r\n\r\n public async processMentions(input: string): Promise<ProcessedMentions> {\r\n const result: ProcessedMentions = {\r\n agents: [],\r\n files: [],\r\n hasAgentMentions: false,\r\n hasFileMentions: false,\r\n }\r\n\r\n try {\r\n const agentMentions = this.extractAgentMentions(input)\r\n if (agentMentions.length > 0) {\r\n await this.refreshAgentCache()\r\n\r\n for (const { mention, agentType, isAskModel } of agentMentions) {\r\n if (isAskModel || this.agentCache.has(agentType)) {\r\n result.agents.push({\r\n type: 'agent',\r\n mention,\r\n resolved: agentType,\r\n exists: true,\r\n metadata: isAskModel ? { type: 'ask-model' } : undefined,\r\n })\r\n result.hasAgentMentions = true\r\n\r\n this.emitAgentMentionEvent(mention, agentType, isAskModel)\r\n }\r\n }\r\n }\r\n\r\n const fileMatches = [\r\n ...input.matchAll(MentionProcessorService.MENTION_PATTERNS.file),\r\n ]\r\n const processedAgentMentions = new Set(\r\n agentMentions.map(am => am.mention),\r\n )\r\n\r\n for (const match of fileMatches) {\r\n const rawMention = match[0]?.slice(1) || ''\r\n const mention = (match[1] ?? match[2] ?? match[3] ?? '').trim()\r\n\r\n if (\r\n mention.startsWith('run-agent-') ||\r\n mention.startsWith('agent-') ||\r\n mention.startsWith('ask-') ||\r\n processedAgentMentions.has(mention)\r\n ) {\r\n continue\r\n }\r\n\r\n if (!mention) continue\r\n const filePath = this.resolveFilePath(\r\n this.normalizeFileMentionPath(mention),\r\n )\r\n if (existsSync(filePath)) {\r\n result.files.push({\r\n type: 'file',\r\n mention: rawMention || mention,\r\n resolved: filePath,\r\n exists: true,\r\n })\r\n result.hasFileMentions = true\r\n\r\n emitReminderEvent('file:mentioned', {\r\n filePath: filePath,\r\n originalMention: rawMention || mention,\r\n timestamp: Date.now(),\r\n })\r\n }\r\n }\r\n\r\n return result\r\n } catch (error) {\r\n logError(error)\r\n debugLogger.warn('MENTION_PROCESSOR_PROCESS_FAILED', {\r\n input: input.substring(0, 100) + (input.length > 100 ? '...' : ''),\r\n error: error instanceof Error ? error.message : error,\r\n })\r\n\r\n return {\r\n agents: [],\r\n files: [],\r\n hasAgentMentions: false,\r\n hasFileMentions: false,\r\n }\r\n }\r\n }\r\n\r\n private resolveFilePath(mention: string): string {\r\n return resolve(getCwd(), mention)\r\n }\r\n\r\n private normalizeFileMentionPath(mention: string): string {\r\n return mention.replace(/\\\\ /g, ' ')\r\n }\r\n\r\n private async refreshAgentCache(): Promise<void> {\r\n const now = Date.now()\r\n if (now - this.lastAgentCheck < this.CACHE_TTL) {\r\n return\r\n }\r\n\r\n try {\r\n const agents = await getAvailableAgentTypes()\r\n const previousCacheSize = this.agentCache.size\r\n this.agentCache.clear()\r\n\r\n for (const agent of agents) {\r\n this.agentCache.set(agent.agentType, true)\r\n }\r\n\r\n this.lastAgentCheck = now\r\n\r\n if (agents.length !== previousCacheSize) {\r\n debugLogger.info('MENTION_PROCESSOR_CACHE_REFRESHED', {\r\n agentCount: agents.length,\r\n previousCacheSize,\r\n cacheAge: now - this.lastAgentCheck,\r\n })\r\n }\r\n } catch (error) {\r\n logError(error)\r\n debugLogger.warn('MENTION_PROCESSOR_CACHE_REFRESH_FAILED', {\r\n error: error instanceof Error ? error.message : error,\r\n cacheSize: this.agentCache.size,\r\n lastRefresh: new Date(this.lastAgentCheck).toISOString(),\r\n })\r\n }\r\n }\r\n\r\n private extractAgentMentions(\r\n input: string,\r\n ): Array<{ mention: string; agentType: string; isAskModel: boolean }> {\r\n const mentions: Array<{\r\n mention: string\r\n agentType: string\r\n isAskModel: boolean\r\n }> = []\r\n\r\n const runAgentMatches = [\r\n ...input.matchAll(MentionProcessorService.MENTION_PATTERNS.runAgent),\r\n ]\r\n for (const match of runAgentMatches) {\r\n const mention = match[1]\r\n const agentType = mention.replace(/^run-agent-/, '')\r\n mentions.push({ mention, agentType, isAskModel: false })\r\n }\r\n\r\n const agentMatches = [\r\n ...input.matchAll(MentionProcessorService.MENTION_PATTERNS.agent),\r\n ]\r\n for (const match of agentMatches) {\r\n const mention = match[1]\r\n const agentType = mention.replace(/^agent-/, '')\r\n mentions.push({ mention, agentType, isAskModel: false })\r\n }\r\n\r\n const askModelMatches = [\r\n ...input.matchAll(MentionProcessorService.MENTION_PATTERNS.askModel),\r\n ]\r\n for (const match of askModelMatches) {\r\n const mention = match[1]\r\n mentions.push({ mention, agentType: mention, isAskModel: true })\r\n }\r\n\r\n return mentions\r\n }\r\n\r\n private emitAgentMentionEvent(\r\n mention: string,\r\n agentType: string,\r\n isAskModel: boolean,\r\n ): void {\r\n try {\r\n const eventData = {\r\n originalMention: mention,\r\n timestamp: Date.now(),\r\n }\r\n\r\n if (isAskModel) {\r\n emitReminderEvent('ask-model:mentioned', {\r\n ...eventData,\r\n modelName: mention,\r\n })\r\n } else {\r\n emitReminderEvent('agent:mentioned', {\r\n ...eventData,\r\n agentType,\r\n })\r\n }\r\n\r\n debugLogger.info('MENTION_PROCESSOR_EVENT_EMITTED', {\r\n type: isAskModel ? 'ask-model' : 'agent',\r\n mention,\r\n agentType: isAskModel ? undefined : agentType,\r\n })\r\n } catch (error) {\r\n debugLogger.error('MENTION_PROCESSOR_EVENT_FAILED', {\r\n mention,\r\n agentType,\r\n isAskModel,\r\n error: error instanceof Error ? error.message : error,\r\n })\r\n }\r\n }\r\n\r\n public clearCache(): void {\r\n this.agentCache.clear()\r\n this.lastAgentCheck = 0\r\n }\r\n}\r\n\r\nexport const mentionProcessor = new MentionProcessorService()\r\n\r\nexport const processMentions = (input: string) =>\r\n mentionProcessor.processMentions(input)\r\n\r\nexport const clearMentionCache = () => mentionProcessor.clearCache()\r\n"],
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AC;AACvB,eAAS,KAAK,EAAE,SAAS,WAAW,SAAS,YAAY,KAAK,CAAC;AAAA,IACjE;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,sBACN,SACA,WACA,YACM;AACN,QAAI;AACF,YAAM,YAAY;AAAA,QAChB,iBAAiB;AAAA,QACjB,WAAW,KAAK,IAAI;AAAA,MACtB;AAEA,UAAI,YAAY;AACd,0BAAkB,uBAAuB;AAAA,UACvC,GAAG;AAAA,UACH,WAAW;AAAA,QACb,CAAC;AAAA,MACH,OAAO;AACL,0BAAkB,mBAAmB;AAAA,UACnC,GAAG;AAAA,UACH;AAAA,QACF,CAAC;AAAA,MACH;AAEA,YAAY,KAAK,mCAAmC;AAAA,QAClD,MAAM,aAAa,cAAc;AAAA,QACjC;AAAA,QACA,WAAW,aAAa,SAAY;AAAA,MACtC,CAAC;AAAA,IACH,SAAS,OAAO;AACd,YAAY,MAAM,kCAAkC;AAAA,QAClD;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,MAClD,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEO,aAAmB;AACxB,SAAK,WAAW,MAAM;AACtB,SAAK,iBAAiB;AAAA,EACxB;AACF;AAEO,IAAM,mBAAmB,IAAI,wBAAwB;AAErD,IAAM,kBAAkB,CAAC,UAC9B,iBAAiB,gBAAgB,KAAK;AAEjC,IAAM,oBAAoB,MAAM,iBAAiB,WAAW;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
CANCEL_MESSAGE,
|
|
5
|
+
INTERRUPT_MESSAGE,
|
|
6
|
+
INTERRUPT_MESSAGE_FOR_TOOL_USE,
|
|
7
|
+
NO_RESPONSE_REQUESTED,
|
|
8
|
+
REJECTED_PLAN_PREFIX,
|
|
9
|
+
REJECT_MESSAGE,
|
|
10
|
+
REJECT_MESSAGE_WITH_FEEDBACK_PREFIX,
|
|
11
|
+
SYNTHETIC_ASSISTANT_MESSAGES,
|
|
12
|
+
createAssistantAPIErrorMessage,
|
|
13
|
+
createAssistantMessage,
|
|
14
|
+
createProgressMessage,
|
|
15
|
+
createToolResultStopMessage,
|
|
16
|
+
createUserMessage,
|
|
17
|
+
extractTag,
|
|
18
|
+
extractTagFromMessage,
|
|
19
|
+
filterUserTextMessagesForUndo,
|
|
20
|
+
getErroredToolUseMessages,
|
|
21
|
+
getInProgressToolUseIDs,
|
|
22
|
+
getLastAssistantMessageId,
|
|
23
|
+
getToolUseID,
|
|
24
|
+
getUnresolvedToolUseIDs,
|
|
25
|
+
isEmptyMessageText,
|
|
26
|
+
isNotEmptyMessage,
|
|
27
|
+
normalizeContentFromAPI,
|
|
28
|
+
normalizeMessages,
|
|
29
|
+
normalizeMessagesForAPI,
|
|
30
|
+
processUserInput,
|
|
31
|
+
reorderMessages,
|
|
32
|
+
stripSystemMessages
|
|
33
|
+
} from "./chunk-H7BGBV4P.js";
|
|
34
|
+
import "./chunk-M3TKNAUR.js";
|
|
35
|
+
export {
|
|
36
|
+
CANCEL_MESSAGE,
|
|
37
|
+
INTERRUPT_MESSAGE,
|
|
38
|
+
INTERRUPT_MESSAGE_FOR_TOOL_USE,
|
|
39
|
+
NO_RESPONSE_REQUESTED,
|
|
40
|
+
REJECTED_PLAN_PREFIX,
|
|
41
|
+
REJECT_MESSAGE,
|
|
42
|
+
REJECT_MESSAGE_WITH_FEEDBACK_PREFIX,
|
|
43
|
+
SYNTHETIC_ASSISTANT_MESSAGES,
|
|
44
|
+
createAssistantAPIErrorMessage,
|
|
45
|
+
createAssistantMessage,
|
|
46
|
+
createProgressMessage,
|
|
47
|
+
createToolResultStopMessage,
|
|
48
|
+
createUserMessage,
|
|
49
|
+
extractTag,
|
|
50
|
+
extractTagFromMessage,
|
|
51
|
+
filterUserTextMessagesForUndo,
|
|
52
|
+
getErroredToolUseMessages,
|
|
53
|
+
getInProgressToolUseIDs,
|
|
54
|
+
getLastAssistantMessageId,
|
|
55
|
+
getToolUseID,
|
|
56
|
+
getUnresolvedToolUseIDs,
|
|
57
|
+
isEmptyMessageText,
|
|
58
|
+
isNotEmptyMessage,
|
|
59
|
+
normalizeContentFromAPI,
|
|
60
|
+
normalizeMessages,
|
|
61
|
+
normalizeMessagesForAPI,
|
|
62
|
+
processUserInput,
|
|
63
|
+
reorderMessages,
|
|
64
|
+
stripSystemMessages
|
|
65
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ModelManager,
|
|
5
|
+
USE_BEDROCK,
|
|
6
|
+
USE_VERTEX,
|
|
7
|
+
getModelManager,
|
|
8
|
+
getQuickModel,
|
|
9
|
+
getSlowAndCapableModel,
|
|
10
|
+
getVertexRegionForModel,
|
|
11
|
+
isDefaultSlowAndCapableModel,
|
|
12
|
+
reloadModelManager
|
|
13
|
+
} from "./chunk-4CLHMO4I.js";
|
|
14
|
+
import "./chunk-DLSLSLTR.js";
|
|
15
|
+
import "./chunk-HIIHGKXP.js";
|
|
16
|
+
import "./chunk-Y4BQ36T4.js";
|
|
17
|
+
import "./chunk-SQGAHZPM.js";
|
|
18
|
+
import "./chunk-UNCTVIS7.js";
|
|
19
|
+
import "./chunk-M3TKNAUR.js";
|
|
20
|
+
export {
|
|
21
|
+
ModelManager,
|
|
22
|
+
USE_BEDROCK,
|
|
23
|
+
USE_VERTEX,
|
|
24
|
+
getModelManager,
|
|
25
|
+
getQuickModel,
|
|
26
|
+
getSlowAndCapableModel,
|
|
27
|
+
getVertexRegionForModel,
|
|
28
|
+
isDefaultSlowAndCapableModel,
|
|
29
|
+
reloadModelManager
|
|
30
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
applyModelSpecificTransformations,
|
|
5
|
+
callGPT5ResponsesAPI,
|
|
6
|
+
createStreamProcessor,
|
|
7
|
+
fetchCustomModels,
|
|
8
|
+
getCompletionWithProfile,
|
|
9
|
+
getGPT5CompletionWithProfile,
|
|
10
|
+
getModelFeatures,
|
|
11
|
+
streamCompletion
|
|
12
|
+
} from "./chunk-LGEK2NV7.js";
|
|
13
|
+
import "./chunk-XEYEKVFT.js";
|
|
14
|
+
import "./chunk-DLSLSLTR.js";
|
|
15
|
+
import "./chunk-HIIHGKXP.js";
|
|
16
|
+
import "./chunk-Y4BQ36T4.js";
|
|
17
|
+
import "./chunk-SQGAHZPM.js";
|
|
18
|
+
import "./chunk-UNCTVIS7.js";
|
|
19
|
+
import "./chunk-M3TKNAUR.js";
|
|
20
|
+
export {
|
|
21
|
+
applyModelSpecificTransformations,
|
|
22
|
+
callGPT5ResponsesAPI,
|
|
23
|
+
createStreamProcessor,
|
|
24
|
+
fetchCustomModels,
|
|
25
|
+
getCompletionWithProfile,
|
|
26
|
+
getGPT5CompletionWithProfile,
|
|
27
|
+
getModelFeatures,
|
|
28
|
+
streamCompletion
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_OUTPUT_STYLE,
|
|
5
|
+
clearOutputStyleCache,
|
|
6
|
+
getAvailableOutputStyles,
|
|
7
|
+
getCurrentOutputStyle,
|
|
8
|
+
getCurrentOutputStyleDefinition,
|
|
9
|
+
getOutputStyleSystemPromptAdditions,
|
|
10
|
+
resolveOutputStyleName,
|
|
11
|
+
setCurrentOutputStyle
|
|
12
|
+
} from "./chunk-ELAE6Z4H.js";
|
|
13
|
+
import "./chunk-66EZC7Y7.js";
|
|
14
|
+
import "./chunk-WAY3DKFO.js";
|
|
15
|
+
import "./chunk-2VQWLLDU.js";
|
|
16
|
+
import "./chunk-SQGAHZPM.js";
|
|
17
|
+
import "./chunk-UNCTVIS7.js";
|
|
18
|
+
import "./chunk-M3TKNAUR.js";
|
|
19
|
+
export {
|
|
20
|
+
DEFAULT_OUTPUT_STYLE,
|
|
21
|
+
clearOutputStyleCache,
|
|
22
|
+
getAvailableOutputStyles,
|
|
23
|
+
getCurrentOutputStyle,
|
|
24
|
+
getCurrentOutputStyleDefinition,
|
|
25
|
+
getOutputStyleSystemPromptAdditions,
|
|
26
|
+
resolveOutputStyleName,
|
|
27
|
+
setCurrentOutputStyle
|
|
28
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { createRequire as __kodeCreateRequire } from "node:module";
|
|
2
|
+
const require = __kodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
setSessionPlugins
|
|
5
|
+
} from "./chunk-2VQWLLDU.js";
|
|
6
|
+
import {
|
|
7
|
+
getCwd,
|
|
8
|
+
init_state
|
|
9
|
+
} from "./chunk-SQGAHZPM.js";
|
|
10
|
+
import "./chunk-UNCTVIS7.js";
|
|
11
|
+
import "./chunk-M3TKNAUR.js";
|
|
12
|
+
|
|
13
|
+
// src/services/plugins/pluginRuntime.ts
|
|
14
|
+
init_state();
|
|
15
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
16
|
+
import { homedir } from "os";
|
|
17
|
+
import { join, resolve } from "path";
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import { glob as globLib } from "glob";
|
|
20
|
+
var PluginManifestSchema = z.object({
|
|
21
|
+
name: z.string().min(1)
|
|
22
|
+
}).passthrough();
|
|
23
|
+
function expandHome(input) {
|
|
24
|
+
const trimmed = input.trim();
|
|
25
|
+
if (trimmed === "~") return homedir();
|
|
26
|
+
if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
27
|
+
return join(homedir(), trimmed.slice(2));
|
|
28
|
+
}
|
|
29
|
+
return trimmed;
|
|
30
|
+
}
|
|
31
|
+
function isLikelyGlob(value) {
|
|
32
|
+
return /[*?[\]]/.test(value);
|
|
33
|
+
}
|
|
34
|
+
async function expandPluginDirInputs(pluginDirs, baseDir) {
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const raw of pluginDirs) {
|
|
37
|
+
const trimmed = String(raw ?? "").trim();
|
|
38
|
+
if (!trimmed) continue;
|
|
39
|
+
const expanded = expandHome(trimmed);
|
|
40
|
+
const abs = resolve(baseDir, expanded);
|
|
41
|
+
if (isLikelyGlob(trimmed) || isLikelyGlob(expanded)) {
|
|
42
|
+
const patternsToTry = expanded !== trimmed ? [expanded, trimmed] : [trimmed];
|
|
43
|
+
let matched = false;
|
|
44
|
+
for (const pattern of patternsToTry) {
|
|
45
|
+
try {
|
|
46
|
+
const matches = await globLib(pattern, {
|
|
47
|
+
cwd: baseDir,
|
|
48
|
+
absolute: true,
|
|
49
|
+
nodir: false,
|
|
50
|
+
nocase: process.platform === "win32"
|
|
51
|
+
});
|
|
52
|
+
const dirs = matches.filter((match) => {
|
|
53
|
+
try {
|
|
54
|
+
return existsSync(match) && statSync(match).isDirectory();
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (dirs.length > 0) {
|
|
60
|
+
out.push(...dirs);
|
|
61
|
+
matched = true;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (matched) continue;
|
|
68
|
+
}
|
|
69
|
+
out.push(abs);
|
|
70
|
+
}
|
|
71
|
+
const seen = /* @__PURE__ */ new Set();
|
|
72
|
+
const unique = [];
|
|
73
|
+
for (const item of out) {
|
|
74
|
+
const key = item;
|
|
75
|
+
if (seen.has(key)) continue;
|
|
76
|
+
seen.add(key);
|
|
77
|
+
unique.push(item);
|
|
78
|
+
}
|
|
79
|
+
return unique;
|
|
80
|
+
}
|
|
81
|
+
function listIfDir(path) {
|
|
82
|
+
try {
|
|
83
|
+
if (!existsSync(path)) return [];
|
|
84
|
+
if (!statSync(path).isDirectory()) return [];
|
|
85
|
+
return [path];
|
|
86
|
+
} catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function fileIfExists(path) {
|
|
91
|
+
try {
|
|
92
|
+
if (!existsSync(path)) return [];
|
|
93
|
+
if (!statSync(path).isFile()) return [];
|
|
94
|
+
return [path];
|
|
95
|
+
} catch {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function resolveManifestPaths(rootDir, value) {
|
|
100
|
+
const dirs = [];
|
|
101
|
+
const files = [];
|
|
102
|
+
const list = Array.isArray(value) ? value : value ? [value] : [];
|
|
103
|
+
for (const item of list) {
|
|
104
|
+
if (typeof item !== "string") continue;
|
|
105
|
+
const abs = resolve(rootDir, item);
|
|
106
|
+
dirs.push(...listIfDir(abs));
|
|
107
|
+
files.push(...fileIfExists(abs));
|
|
108
|
+
}
|
|
109
|
+
return { dirs, files };
|
|
110
|
+
}
|
|
111
|
+
function loadPluginFromDir(rootDir) {
|
|
112
|
+
const primaryManifestPath = join(rootDir, ".kode-plugin", "plugin.json");
|
|
113
|
+
const legacyManifestPath = join(rootDir, ".claude-plugin", "plugin.json");
|
|
114
|
+
const manifestPath = existsSync(primaryManifestPath) ? primaryManifestPath : legacyManifestPath;
|
|
115
|
+
if (!existsSync(manifestPath)) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Plugin manifest not found (expected .kode-plugin/plugin.json or .claude-plugin/plugin.json)`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
let manifestRaw;
|
|
121
|
+
try {
|
|
122
|
+
manifestRaw = readFileSync(manifestPath, "utf8");
|
|
123
|
+
} catch (err) {
|
|
124
|
+
throw new Error(`Failed to read ${manifestPath}: ${String(err)}`);
|
|
125
|
+
}
|
|
126
|
+
let manifestJson;
|
|
127
|
+
try {
|
|
128
|
+
manifestJson = JSON.parse(manifestRaw);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
throw new Error(`Invalid JSON in ${manifestPath}: ${String(err)}`);
|
|
131
|
+
}
|
|
132
|
+
const parsed = PluginManifestSchema.safeParse(manifestJson);
|
|
133
|
+
if (!parsed.success) {
|
|
134
|
+
throw new Error(
|
|
135
|
+
`Invalid plugin manifest schema in ${manifestPath}: ${parsed.error.message}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
const name = parsed.data.name;
|
|
139
|
+
const manifestCommands = resolveManifestPaths(
|
|
140
|
+
rootDir,
|
|
141
|
+
parsed.data.commands
|
|
142
|
+
);
|
|
143
|
+
const manifestAgents = resolveManifestPaths(
|
|
144
|
+
rootDir,
|
|
145
|
+
parsed.data.agents
|
|
146
|
+
);
|
|
147
|
+
const commandsDirs = [
|
|
148
|
+
...listIfDir(join(rootDir, "commands")),
|
|
149
|
+
...manifestCommands.dirs,
|
|
150
|
+
...manifestCommands.files
|
|
151
|
+
];
|
|
152
|
+
const skillsDirs = [
|
|
153
|
+
...listIfDir(join(rootDir, "skills")),
|
|
154
|
+
...resolveManifestPaths(rootDir, parsed.data.skills).dirs
|
|
155
|
+
];
|
|
156
|
+
const agentsDirs = [
|
|
157
|
+
...listIfDir(join(rootDir, "agents")),
|
|
158
|
+
...manifestAgents.dirs,
|
|
159
|
+
...manifestAgents.files
|
|
160
|
+
];
|
|
161
|
+
const manifestOutputStyles = resolveManifestPaths(
|
|
162
|
+
rootDir,
|
|
163
|
+
parsed.data.outputStyles
|
|
164
|
+
);
|
|
165
|
+
const outputStylesDirs = [
|
|
166
|
+
...listIfDir(join(rootDir, "output-styles")),
|
|
167
|
+
...manifestOutputStyles.dirs,
|
|
168
|
+
...manifestOutputStyles.files
|
|
169
|
+
];
|
|
170
|
+
const standardHook = fileIfExists(join(rootDir, "hooks", "hooks.json"));
|
|
171
|
+
const hookFromManifest = resolveManifestPaths(
|
|
172
|
+
rootDir,
|
|
173
|
+
parsed.data.hooks
|
|
174
|
+
).files;
|
|
175
|
+
const hooksFiles = [...standardHook, ...hookFromManifest];
|
|
176
|
+
const mcpConfigFiles = [
|
|
177
|
+
...fileIfExists(join(rootDir, ".mcp.json")),
|
|
178
|
+
...fileIfExists(join(rootDir, ".mcp.jsonc")),
|
|
179
|
+
...resolveManifestPaths(rootDir, parsed.data.mcpServers).files
|
|
180
|
+
];
|
|
181
|
+
return {
|
|
182
|
+
name,
|
|
183
|
+
rootDir,
|
|
184
|
+
manifestPath,
|
|
185
|
+
manifest: parsed.data,
|
|
186
|
+
commandsDirs,
|
|
187
|
+
skillsDirs,
|
|
188
|
+
agentsDirs,
|
|
189
|
+
hooksFiles,
|
|
190
|
+
outputStylesDirs,
|
|
191
|
+
mcpConfigFiles
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
async function configureSessionPlugins(args) {
|
|
195
|
+
const baseDir = args.baseDir ?? getCwd();
|
|
196
|
+
const dirs = await expandPluginDirInputs(args.pluginDirs ?? [], baseDir);
|
|
197
|
+
const plugins = [];
|
|
198
|
+
const errors = [];
|
|
199
|
+
for (const dir of dirs) {
|
|
200
|
+
try {
|
|
201
|
+
plugins.push(loadPluginFromDir(dir));
|
|
202
|
+
} catch (err) {
|
|
203
|
+
errors.push(err instanceof Error ? err.message : String(err));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
setSessionPlugins(plugins);
|
|
207
|
+
const { reloadCustomCommands } = await import("./customCommands-EB4MMZSS.js");
|
|
208
|
+
reloadCustomCommands();
|
|
209
|
+
const { getCommands } = await import("./commands-HOBCZ3VQ.js");
|
|
210
|
+
getCommands.cache.clear?.();
|
|
211
|
+
const { getClients, getMCPTools } = await import("./mcp-DOROSLPN.js");
|
|
212
|
+
getClients.cache?.clear?.();
|
|
213
|
+
getMCPTools.cache?.clear?.();
|
|
214
|
+
const { clearOutputStyleCache } = await import("./outputStyles-NNALI5D7.js");
|
|
215
|
+
clearOutputStyleCache();
|
|
216
|
+
return { plugins, errors };
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
configureSessionPlugins
|
|
220
|
+
};
|