koishi-plugin-aka-ai-generator 0.2.0 → 0.2.1
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/lib/index.js +36 -11
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -672,18 +672,40 @@ function apply(ctx, config) {
|
|
|
672
672
|
}
|
|
673
673
|
__name(buildModelMappingIndex, "buildModelMappingIndex");
|
|
674
674
|
function parseStyleCommandModifiers(argv) {
|
|
675
|
-
const
|
|
676
|
-
if (!
|
|
677
|
-
const modifiers = {};
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
675
|
+
const rawArgs = [...argv.args || []].map((arg) => typeof arg === "string" ? arg.trim() : "").filter(Boolean);
|
|
676
|
+
if (!rawArgs.length && !argv.rest) return {};
|
|
677
|
+
const modifiers = { customAdditions: [] };
|
|
678
|
+
const flagCandidates = [];
|
|
679
|
+
let index = 0;
|
|
680
|
+
while (index < rawArgs.length) {
|
|
681
|
+
const token = rawArgs[index];
|
|
682
|
+
if (!token) {
|
|
683
|
+
index++;
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
const lower = token.toLowerCase();
|
|
687
|
+
if (lower.startsWith("-prompt:")) {
|
|
688
|
+
const promptHead = token.substring(token.indexOf(":") + 1);
|
|
689
|
+
const restTokens = rawArgs.slice(index + 1);
|
|
690
|
+
modifiers.customPromptSuffix = [promptHead, ...restTokens].join(" ").trim();
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
693
|
+
if (lower === "-add") {
|
|
694
|
+
index++;
|
|
695
|
+
const additionTokens = [];
|
|
696
|
+
while (index < rawArgs.length && !rawArgs[index].startsWith("-")) {
|
|
697
|
+
additionTokens.push(rawArgs[index]);
|
|
698
|
+
index++;
|
|
699
|
+
}
|
|
700
|
+
if (additionTokens.length) {
|
|
701
|
+
modifiers.customAdditions.push(additionTokens.join(" "));
|
|
702
|
+
}
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
flagCandidates.push(token);
|
|
706
|
+
index++;
|
|
685
707
|
}
|
|
686
|
-
for (const arg of
|
|
708
|
+
for (const arg of flagCandidates) {
|
|
687
709
|
if (!arg.startsWith("-")) continue;
|
|
688
710
|
const key = normalizeSuffix(arg);
|
|
689
711
|
if (!key) continue;
|
|
@@ -1087,6 +1109,9 @@ function apply(ctx, config) {
|
|
|
1087
1109
|
if (modifiers.modelMapping?.promptSuffix) {
|
|
1088
1110
|
promptSegments.push(modifiers.modelMapping.promptSuffix);
|
|
1089
1111
|
}
|
|
1112
|
+
if (modifiers.customAdditions?.length) {
|
|
1113
|
+
promptSegments.push(...modifiers.customAdditions);
|
|
1114
|
+
}
|
|
1090
1115
|
if (modifiers.customPromptSuffix) {
|
|
1091
1116
|
promptSegments.push(modifiers.customPromptSuffix);
|
|
1092
1117
|
}
|