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.
Files changed (2) hide show
  1. package/lib/index.js +36 -11
  2. 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 allArgs = [...argv.args || []].map((arg) => typeof arg === "string" ? arg.trim() : "").filter(Boolean);
676
- if (!allArgs.length && !argv.rest) return {};
677
- const modifiers = {};
678
- let remainingArgs = [...allArgs];
679
- const promptIndex = remainingArgs.findIndex((arg) => arg.toLowerCase().startsWith("-prompt:"));
680
- if (promptIndex >= 0) {
681
- const [promptToken, ...afterPrompt] = remainingArgs.slice(promptIndex);
682
- const promptHead = promptToken.substring(promptToken.indexOf(":") + 1);
683
- modifiers.customPromptSuffix = [promptHead, ...afterPrompt].join(" ").trim();
684
- remainingArgs = remainingArgs.slice(0, promptIndex);
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 remainingArgs) {
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-aka-ai-generator",
3
3
  "description": "自用AI生成插件(GPTGod & Yunwu)",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [