koishi-plugin-aka-ai-generator 0.2.7 → 0.2.8

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.d.ts CHANGED
@@ -10,6 +10,11 @@ export interface StyleConfig {
10
10
  commandName: string;
11
11
  prompt: string;
12
12
  }
13
+ export interface StyleGroupConfig {
14
+ typeName: string;
15
+ typeDescription?: string;
16
+ prompts: StyleConfig[];
17
+ }
13
18
  export interface UserData {
14
19
  userId: string;
15
20
  userName: string;
@@ -41,6 +46,7 @@ export interface Config {
41
46
  rateLimitMax: number;
42
47
  adminUsers: string[];
43
48
  styles: StyleConfig[];
49
+ styleGroups?: StyleGroupConfig[];
44
50
  logLevel: 'info' | 'debug';
45
51
  }
46
52
  export interface RechargeRecord {
package/lib/index.js CHANGED
@@ -604,6 +604,10 @@ var COMMANDS = {
604
604
  RECHARGE_HISTORY: "图像充值记录",
605
605
  FUNCTION_LIST: "图像功能"
606
606
  };
607
+ var StyleItemSchema = import_koishi.Schema.object({
608
+ commandName: import_koishi.Schema.string().required().description("命令名称(不含前缀斜杠)"),
609
+ prompt: import_koishi.Schema.string().role("textarea", { rows: 4 }).required().description("生成 prompt")
610
+ });
607
611
  var Config = import_koishi.Schema.intersect([
608
612
  import_koishi.Schema.object({
609
613
  provider: import_koishi.Schema.union([
@@ -641,10 +645,7 @@ var Config = import_koishi.Schema.intersect([
641
645
  }),
642
646
  // 自定义风格命令配置
643
647
  import_koishi.Schema.object({
644
- styles: import_koishi.Schema.array(import_koishi.Schema.object({
645
- commandName: import_koishi.Schema.string().required().description("命令名称(不含前缀斜杠)"),
646
- prompt: import_koishi.Schema.string().role("textarea", { rows: 4 }).required().description("生成 prompt")
647
- })).role("table").default([
648
+ styles: import_koishi.Schema.array(StyleItemSchema).role("table").default([
648
649
  {
649
650
  commandName: "变手办",
650
651
  prompt: "将这张照片变成手办模型。在它后面放置一个印有图像主体的盒子,桌子上有一台电脑显示Blender建模过程。在盒子前面添加一个圆形塑料底座,角色手办站在上面。如果可能的话,将场景设置在室内"
@@ -669,7 +670,12 @@ var Config = import_koishi.Schema.intersect([
669
670
  commandName: "变像素",
670
671
  prompt: "请根据用户提供的图片,将图像主体转换为经典的8位像素艺术风格。要求:1. 完全保持主体的身份、外观特征和核心识别元素不变,确保转换后仍然清晰可识别;2. 采用极简的8位像素风格,使用有限的复古调色板(通常为16-256色),营造经典街机游戏的美学氛围;3. 所有细节都进行像素化处理,使用清晰的像素块和锐利的边缘,避免平滑渐变;4. 采用干净的块状形式,保持简单、标志性的设计,突出主体的核心特征;5. 背景可以简化为纯色背景(如纯白或纯黑),或者保持简单的像素化背景,确保主体突出;6. 整体风格应具有强烈的复古游戏感,让人联想到经典街机游戏和早期电子游戏的视觉美学;7. 保持主体的比例和基本结构,但用像素块重新诠释所有细节。"
671
672
  }
672
- ]).description("自定义风格命令配置")
673
+ ]).description("自定义风格命令配置"),
674
+ styleGroups: import_koishi.Schema.array(import_koishi.Schema.object({
675
+ typeName: import_koishi.Schema.string().required().description("类型名称,用于分组展示"),
676
+ typeDescription: import_koishi.Schema.string().role("textarea", { rows: 2 }).description("可选:类型说明"),
677
+ prompts: import_koishi.Schema.array(StyleItemSchema).role("table").default([]).description("属于该类型的 prompt 列表")
678
+ })).role("table").default([]).description("按类型管理的 prompt 组,保存时将自动展开为 styles")
673
679
  })
674
680
  ]);
675
681
  function apply(ctx, config) {
@@ -812,11 +818,41 @@ function apply(ctx, config) {
812
818
  return modifiers;
813
819
  }
814
820
  __name(parseStyleCommandModifiers, "parseStyleCommandModifiers");
821
+ const styleDefinitions = collectStyleDefinitions();
822
+ function collectStyleDefinitions() {
823
+ const unique = /* @__PURE__ */ new Map();
824
+ const pushStyle = /* @__PURE__ */ __name((style, groupName) => {
825
+ if (!style?.commandName || !style?.prompt) return;
826
+ if (unique.has(style.commandName)) {
827
+ logger.warn("检测到重复的风格命令名称,已跳过", { commandName: style.commandName, groupName });
828
+ return;
829
+ }
830
+ unique.set(style.commandName, {
831
+ ...style,
832
+ groupName
833
+ });
834
+ }, "pushStyle");
835
+ if (Array.isArray(config.styles)) {
836
+ for (const style of config.styles) {
837
+ pushStyle(style);
838
+ }
839
+ }
840
+ if (Array.isArray(config.styleGroups)) {
841
+ for (const group of config.styleGroups) {
842
+ if (!group?.typeName || !Array.isArray(group.prompts)) continue;
843
+ for (const style of group.prompts) {
844
+ pushStyle(style, group.typeName);
845
+ }
846
+ }
847
+ }
848
+ return Array.from(unique.values());
849
+ }
850
+ __name(collectStyleDefinitions, "collectStyleDefinitions");
815
851
  function getStyleCommands() {
816
- if (!config.styles || !Array.isArray(config.styles)) return [];
817
- return config.styles.filter((style) => style.commandName && style.prompt).map((style) => ({
852
+ if (!styleDefinitions.length) return [];
853
+ return styleDefinitions.filter((style) => style.commandName && style.prompt).map((style) => ({
818
854
  name: style.commandName,
819
- description: "图像风格转换"
855
+ description: style.groupName ? `图像风格转换(${style.groupName})` : "图像风格转换"
820
856
  }));
821
857
  }
822
858
  __name(getStyleCommands, "getStyleCommands");
@@ -1202,8 +1238,8 @@ ${infoParts.join("\n")}`;
1202
1238
  }
1203
1239
  }
1204
1240
  __name(processImage, "processImage");
1205
- if (config.styles && Array.isArray(config.styles)) {
1206
- for (const style of config.styles) {
1241
+ if (styleDefinitions.length > 0) {
1242
+ for (const style of styleDefinitions) {
1207
1243
  if (style.commandName && style.prompt) {
1208
1244
  ctx.command(`${style.commandName} [img:text]`, "图像风格转换").option("num", "-n <num:number> 生成图片数量 (1-4)").action(async (argv, img) => {
1209
1245
  const { session, options } = argv;
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.7",
4
+ "version": "0.2.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [