koishi-plugin-aka-ai-generator 0.2.2 → 0.2.3

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 +26 -11
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -672,15 +672,23 @@ function apply(ctx, config) {
672
672
  }
673
673
  __name(buildModelMappingIndex, "buildModelMappingIndex");
674
674
  function parseStyleCommandModifiers(argv, imgParam) {
675
- const argsList = [...argv.args || []].map((arg) => typeof arg === "string" ? arg.trim() : "").filter(Boolean);
676
- const restStr = typeof argv.rest === "string" ? argv.rest.trim() : "";
677
- if (restStr) {
678
- const restParts = restStr.split(/\s+/).filter(Boolean);
679
- argsList.push(...restParts);
680
- }
681
- if (imgParam && typeof imgParam === "string" && !imgParam.startsWith("http") && !imgParam.startsWith("data:")) {
682
- const imgParts = imgParam.split(/\s+/).filter(Boolean);
683
- argsList.push(...imgParts);
675
+ const session = argv.session;
676
+ let rawText = "";
677
+ if (session?.content) {
678
+ const elements = import_koishi.h.parse(session.content);
679
+ rawText = import_koishi.h.select(elements, "text").map((e) => e.attrs.content).join(" ");
680
+ }
681
+ const argsList = rawText ? rawText.split(/\s+/).filter(Boolean) : [...argv.args || []].map((arg) => typeof arg === "string" ? arg.trim() : "").filter(Boolean);
682
+ if (!rawText) {
683
+ const restStr = typeof argv.rest === "string" ? argv.rest.trim() : "";
684
+ if (restStr) {
685
+ const restParts = restStr.split(/\s+/).filter(Boolean);
686
+ argsList.push(...restParts);
687
+ }
688
+ if (imgParam && typeof imgParam === "string" && !imgParam.startsWith("http") && !imgParam.startsWith("data:")) {
689
+ const imgParts = imgParam.split(/\s+/).filter(Boolean);
690
+ argsList.push(...imgParts);
691
+ }
684
692
  }
685
693
  if (!argsList.length) return {};
686
694
  const modifiers = { customAdditions: [] };
@@ -702,8 +710,15 @@ function apply(ctx, config) {
702
710
  if (lower === "-add") {
703
711
  index++;
704
712
  const additionTokens = [];
705
- while (index < argsList.length && !argsList[index].startsWith("-")) {
706
- additionTokens.push(argsList[index]);
713
+ while (index < argsList.length) {
714
+ const nextToken = argsList[index];
715
+ if (nextToken.startsWith("-")) {
716
+ const key = normalizeSuffix(nextToken);
717
+ if (key && modelMappingIndex.has(key)) break;
718
+ if (nextToken.toLowerCase().startsWith("-prompt:")) break;
719
+ if (nextToken.toLowerCase() === "-add") break;
720
+ }
721
+ additionTokens.push(nextToken);
707
722
  index++;
708
723
  }
709
724
  if (additionTokens.length) {
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.2",
4
+ "version": "0.2.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [