@agiflowai/aicode-utils 1.0.17 → 1.0.18

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/dist/index.cjs CHANGED
@@ -783,6 +783,27 @@ var ScaffoldProcessingService = class {
783
783
  }
784
784
  };
785
785
 
786
+ //#endregion
787
+ //#region src/utils/fallbacks.ts
788
+ function resolveFallbackConfig(config) {
789
+ if (!config) return {};
790
+ const tool = ("fallbackTool" in config ? config.fallbackTool : void 0) ?? ("fallback-tool" in config ? config["fallback-tool"] : void 0);
791
+ const fallbackConfig = ("fallbackToolConfig" in config ? config.fallbackToolConfig : void 0) ?? ("fallback-tool-config" in config ? config["fallback-tool-config"] : void 0);
792
+ if (tool) return {
793
+ tool,
794
+ config: fallbackConfig
795
+ };
796
+ const firstValidFallback = config.fallbacks?.find((entry) => isFallbackConfigEntry(entry));
797
+ if (!firstValidFallback) return {};
798
+ return {
799
+ tool: firstValidFallback.tool,
800
+ config: firstValidFallback.config
801
+ };
802
+ }
803
+ function isFallbackConfigEntry(entry) {
804
+ return Boolean(entry?.tool && typeof entry.tool === "string");
805
+ }
806
+
786
807
  //#endregion
787
808
  //#region src/utils/generateStableId.ts
788
809
  /**
@@ -1307,6 +1328,7 @@ exports.readJson = readJson;
1307
1328
  exports.readJsonSync = readJsonSync;
1308
1329
  exports.readdir = readdir;
1309
1330
  exports.remove = remove;
1331
+ exports.resolveFallbackConfig = resolveFallbackConfig;
1310
1332
  exports.sections = sections;
1311
1333
  exports.stat = stat;
1312
1334
  exports.statSync = node_fs.statSync;
package/dist/index.d.cts CHANGED
@@ -46,6 +46,15 @@ interface NxProjectJson {
46
46
  //#endregion
47
47
  //#region src/types/index.d.ts
48
48
 
49
+ /**
50
+ * Ordered fallback LLM entry used in toolkit settings.
51
+ */
52
+ interface FallbackConfigEntry {
53
+ /** Fallback LLM tool identifier. */
54
+ tool: string;
55
+ /** Config object forwarded when this fallback tool is selected. */
56
+ config?: Record<string, unknown>;
57
+ }
49
58
  /**
50
59
  * Configuration for the scaffold-mcp mcp-serve command.
51
60
  * Keys map 1-to-1 with CLI flags (camelCase).
@@ -65,6 +74,8 @@ interface McpServeConfig {
65
74
  fallbackTool?: string;
66
75
  /** Config passed to the fallback LLM tool. */
67
76
  fallbackToolConfig?: Record<string, unknown>;
77
+ /** Ordered fallback LLM chain consulted when fallbackTool is not set. */
78
+ fallbacks?: FallbackConfigEntry[];
68
79
  /** Extra CLI args merged into the mcp-serve command (key → --key value). */
69
80
  args?: Record<string, string | boolean | number>;
70
81
  }
@@ -81,6 +92,10 @@ interface HookMethodConfig {
81
92
  'fallback-tool'?: string;
82
93
  /** Config object forwarded to the fallback LLM tool. */
83
94
  'fallback-tool-config'?: Record<string, unknown>;
95
+ /** Ordered fallback LLM chain consulted when fallback-tool is not set. */
96
+ fallbacks?: FallbackConfigEntry[];
97
+ /** Optional Claude Code tool matcher written to .claude/settings.json. */
98
+ matcher?: string;
84
99
  /** Extra CLI args appended to the generated hook command (key → --key value). */
85
100
  args?: Record<string, string | boolean | number>;
86
101
  }
@@ -134,6 +149,8 @@ interface ArchitectMcpServeConfig {
134
149
  fallbackTool?: string;
135
150
  /** Config passed to the fallback LLM tool. */
136
151
  fallbackToolConfig?: Record<string, unknown>;
152
+ /** Ordered fallback LLM chain consulted when fallbackTool is not set. */
153
+ fallbacks?: FallbackConfigEntry[];
137
154
  /** LLM tool used specifically for get-file-design-pattern analysis. */
138
155
  designPatternTool?: string;
139
156
  /** Config passed to the design-pattern LLM tool. */
@@ -154,6 +171,14 @@ interface ArchitectHookMethodConfig {
154
171
  'llm-tool'?: string;
155
172
  /** Config object forwarded to the LLM tool. */
156
173
  'tool-config'?: Record<string, unknown>;
174
+ /** Fallback LLM tool used when llm-tool is not set. */
175
+ 'fallback-tool'?: string;
176
+ /** Config object forwarded to the fallback LLM tool. */
177
+ 'fallback-tool-config'?: Record<string, unknown>;
178
+ /** Ordered fallback LLM chain consulted when fallback-tool is not set. */
179
+ fallbacks?: FallbackConfigEntry[];
180
+ /** Optional Claude Code tool matcher written to .claude/settings.json. */
181
+ matcher?: string;
157
182
  /** Extra CLI args appended to the generated hook command (key → --key value). */
158
183
  args?: Record<string, string | boolean | number>;
159
184
  }
@@ -653,6 +678,24 @@ declare const readdir: typeof fs.readdir;
653
678
  declare const mkdir: typeof fs.mkdir;
654
679
  declare const stat: typeof fs.stat;
655
680
  //#endregion
681
+ //#region src/utils/fallbacks.d.ts
682
+ interface SingleFallbackShape {
683
+ fallbackTool?: string;
684
+ fallbackToolConfig?: Record<string, unknown>;
685
+ }
686
+ interface HookFallbackShape {
687
+ 'fallback-tool'?: string;
688
+ 'fallback-tool-config'?: Record<string, unknown>;
689
+ }
690
+ interface FallbackListShape {
691
+ fallbacks?: FallbackConfigEntry[];
692
+ }
693
+ interface ResolvedFallbackConfig {
694
+ tool?: string;
695
+ config?: Record<string, unknown>;
696
+ }
697
+ declare function resolveFallbackConfig(config?: (SingleFallbackShape | HookFallbackShape) & FallbackListShape): ResolvedFallbackConfig;
698
+ //#endregion
656
699
  //#region src/utils/generateStableId.d.ts
657
700
  /**
658
701
  * Generate a stable, random ID string
@@ -956,4 +999,4 @@ interface ProjectTypeDetectionResult {
956
999
  */
957
1000
  declare function detectProjectType(workspaceRoot: string): Promise<ProjectTypeDetectionResult>;
958
1001
  //#endregion
959
- export { ArchitectHookAgentConfig, ArchitectHookConfig, ArchitectHookMethodConfig, ArchitectMcpConfig, ArchitectMcpServeConfig, ConfigSource, FileStat, GeneratorContext, GeneratorFunction, GitHubDirectoryEntry, HookAgentConfig, HookConfig, HookMethodConfig, IFileSystemService, IVariableReplacementService, McpServeConfig, type NxProjectJson, ParsedGitHubUrl, ParsedInclude, ProjectConfig, ProjectConfigResolver, type ProjectConfigResult, ProjectFinderService, ProjectType, ScaffoldMcpConfig, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService, ToolkitConfig, accessSync, cloneRepository, cloneSubdirectory, copy, detectProjectType, ensureDir, fetchGitHubDirectoryContents, findWorkspaceRoot, generateStableId, gitInit, icons, log, logger, messages, mkdir, mkdirSync, move, parseGitHubUrl, pathExists, pathExistsSync, print, readFile, readFileSync, readJson, readJsonSync, readdir, remove, sections, stat, statSync, writeFile, writeFileSync };
1002
+ export { ArchitectHookAgentConfig, ArchitectHookConfig, ArchitectHookMethodConfig, ArchitectMcpConfig, ArchitectMcpServeConfig, ConfigSource, FallbackConfigEntry, FileStat, GeneratorContext, GeneratorFunction, GitHubDirectoryEntry, HookAgentConfig, HookConfig, HookMethodConfig, IFileSystemService, IVariableReplacementService, McpServeConfig, type NxProjectJson, ParsedGitHubUrl, ParsedInclude, ProjectConfig, ProjectConfigResolver, type ProjectConfigResult, ProjectFinderService, ProjectType, ResolvedFallbackConfig, ScaffoldMcpConfig, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService, ToolkitConfig, accessSync, cloneRepository, cloneSubdirectory, copy, detectProjectType, ensureDir, fetchGitHubDirectoryContents, findWorkspaceRoot, generateStableId, gitInit, icons, log, logger, messages, mkdir, mkdirSync, move, parseGitHubUrl, pathExists, pathExistsSync, print, readFile, readFileSync, readJson, readJsonSync, readdir, remove, resolveFallbackConfig, sections, stat, statSync, writeFile, writeFileSync };
package/dist/index.d.mts CHANGED
@@ -46,6 +46,15 @@ interface NxProjectJson {
46
46
  //#endregion
47
47
  //#region src/types/index.d.ts
48
48
 
49
+ /**
50
+ * Ordered fallback LLM entry used in toolkit settings.
51
+ */
52
+ interface FallbackConfigEntry {
53
+ /** Fallback LLM tool identifier. */
54
+ tool: string;
55
+ /** Config object forwarded when this fallback tool is selected. */
56
+ config?: Record<string, unknown>;
57
+ }
49
58
  /**
50
59
  * Configuration for the scaffold-mcp mcp-serve command.
51
60
  * Keys map 1-to-1 with CLI flags (camelCase).
@@ -65,6 +74,8 @@ interface McpServeConfig {
65
74
  fallbackTool?: string;
66
75
  /** Config passed to the fallback LLM tool. */
67
76
  fallbackToolConfig?: Record<string, unknown>;
77
+ /** Ordered fallback LLM chain consulted when fallbackTool is not set. */
78
+ fallbacks?: FallbackConfigEntry[];
68
79
  /** Extra CLI args merged into the mcp-serve command (key → --key value). */
69
80
  args?: Record<string, string | boolean | number>;
70
81
  }
@@ -81,6 +92,10 @@ interface HookMethodConfig {
81
92
  'fallback-tool'?: string;
82
93
  /** Config object forwarded to the fallback LLM tool. */
83
94
  'fallback-tool-config'?: Record<string, unknown>;
95
+ /** Ordered fallback LLM chain consulted when fallback-tool is not set. */
96
+ fallbacks?: FallbackConfigEntry[];
97
+ /** Optional Claude Code tool matcher written to .claude/settings.json. */
98
+ matcher?: string;
84
99
  /** Extra CLI args appended to the generated hook command (key → --key value). */
85
100
  args?: Record<string, string | boolean | number>;
86
101
  }
@@ -134,6 +149,8 @@ interface ArchitectMcpServeConfig {
134
149
  fallbackTool?: string;
135
150
  /** Config passed to the fallback LLM tool. */
136
151
  fallbackToolConfig?: Record<string, unknown>;
152
+ /** Ordered fallback LLM chain consulted when fallbackTool is not set. */
153
+ fallbacks?: FallbackConfigEntry[];
137
154
  /** LLM tool used specifically for get-file-design-pattern analysis. */
138
155
  designPatternTool?: string;
139
156
  /** Config passed to the design-pattern LLM tool. */
@@ -154,6 +171,14 @@ interface ArchitectHookMethodConfig {
154
171
  'llm-tool'?: string;
155
172
  /** Config object forwarded to the LLM tool. */
156
173
  'tool-config'?: Record<string, unknown>;
174
+ /** Fallback LLM tool used when llm-tool is not set. */
175
+ 'fallback-tool'?: string;
176
+ /** Config object forwarded to the fallback LLM tool. */
177
+ 'fallback-tool-config'?: Record<string, unknown>;
178
+ /** Ordered fallback LLM chain consulted when fallback-tool is not set. */
179
+ fallbacks?: FallbackConfigEntry[];
180
+ /** Optional Claude Code tool matcher written to .claude/settings.json. */
181
+ matcher?: string;
157
182
  /** Extra CLI args appended to the generated hook command (key → --key value). */
158
183
  args?: Record<string, string | boolean | number>;
159
184
  }
@@ -653,6 +678,24 @@ declare const readdir: typeof fs.readdir;
653
678
  declare const mkdir: typeof fs.mkdir;
654
679
  declare const stat: typeof fs.stat;
655
680
  //#endregion
681
+ //#region src/utils/fallbacks.d.ts
682
+ interface SingleFallbackShape {
683
+ fallbackTool?: string;
684
+ fallbackToolConfig?: Record<string, unknown>;
685
+ }
686
+ interface HookFallbackShape {
687
+ 'fallback-tool'?: string;
688
+ 'fallback-tool-config'?: Record<string, unknown>;
689
+ }
690
+ interface FallbackListShape {
691
+ fallbacks?: FallbackConfigEntry[];
692
+ }
693
+ interface ResolvedFallbackConfig {
694
+ tool?: string;
695
+ config?: Record<string, unknown>;
696
+ }
697
+ declare function resolveFallbackConfig(config?: (SingleFallbackShape | HookFallbackShape) & FallbackListShape): ResolvedFallbackConfig;
698
+ //#endregion
656
699
  //#region src/utils/generateStableId.d.ts
657
700
  /**
658
701
  * Generate a stable, random ID string
@@ -956,4 +999,4 @@ interface ProjectTypeDetectionResult {
956
999
  */
957
1000
  declare function detectProjectType(workspaceRoot: string): Promise<ProjectTypeDetectionResult>;
958
1001
  //#endregion
959
- export { ArchitectHookAgentConfig, ArchitectHookConfig, ArchitectHookMethodConfig, ArchitectMcpConfig, ArchitectMcpServeConfig, ConfigSource, FileStat, GeneratorContext, GeneratorFunction, type GitHubDirectoryEntry, HookAgentConfig, HookConfig, HookMethodConfig, IFileSystemService, IVariableReplacementService, McpServeConfig, type NxProjectJson, type ParsedGitHubUrl, ParsedInclude, ProjectConfig, ProjectConfigResolver, type ProjectConfigResult, ProjectFinderService, ProjectType, ScaffoldMcpConfig, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService, ToolkitConfig, accessSync, cloneRepository, cloneSubdirectory, copy, detectProjectType, ensureDir, fetchGitHubDirectoryContents, findWorkspaceRoot, generateStableId, gitInit, icons, log, logger, messages, mkdir, mkdirSync, move, parseGitHubUrl, pathExists, pathExistsSync, print, readFile, readFileSync, readJson, readJsonSync, readdir, remove, sections, stat, statSync, writeFile, writeFileSync };
1002
+ export { ArchitectHookAgentConfig, ArchitectHookConfig, ArchitectHookMethodConfig, ArchitectMcpConfig, ArchitectMcpServeConfig, ConfigSource, FallbackConfigEntry, FileStat, GeneratorContext, GeneratorFunction, type GitHubDirectoryEntry, HookAgentConfig, HookConfig, HookMethodConfig, IFileSystemService, IVariableReplacementService, McpServeConfig, type NxProjectJson, type ParsedGitHubUrl, ParsedInclude, ProjectConfig, ProjectConfigResolver, type ProjectConfigResult, ProjectFinderService, ProjectType, type ResolvedFallbackConfig, ScaffoldMcpConfig, ScaffoldProcessingService, ScaffoldResult, TemplatesManagerService, ToolkitConfig, accessSync, cloneRepository, cloneSubdirectory, copy, detectProjectType, ensureDir, fetchGitHubDirectoryContents, findWorkspaceRoot, generateStableId, gitInit, icons, log, logger, messages, mkdir, mkdirSync, move, parseGitHubUrl, pathExists, pathExistsSync, print, readFile, readFileSync, readJson, readJsonSync, readdir, remove, resolveFallbackConfig, sections, stat, statSync, writeFile, writeFileSync };
package/dist/index.mjs CHANGED
@@ -756,6 +756,27 @@ var ScaffoldProcessingService = class {
756
756
  }
757
757
  };
758
758
 
759
+ //#endregion
760
+ //#region src/utils/fallbacks.ts
761
+ function resolveFallbackConfig(config) {
762
+ if (!config) return {};
763
+ const tool = ("fallbackTool" in config ? config.fallbackTool : void 0) ?? ("fallback-tool" in config ? config["fallback-tool"] : void 0);
764
+ const fallbackConfig = ("fallbackToolConfig" in config ? config.fallbackToolConfig : void 0) ?? ("fallback-tool-config" in config ? config["fallback-tool-config"] : void 0);
765
+ if (tool) return {
766
+ tool,
767
+ config: fallbackConfig
768
+ };
769
+ const firstValidFallback = config.fallbacks?.find((entry) => isFallbackConfigEntry(entry));
770
+ if (!firstValidFallback) return {};
771
+ return {
772
+ tool: firstValidFallback.tool,
773
+ config: firstValidFallback.config
774
+ };
775
+ }
776
+ function isFallbackConfigEntry(entry) {
777
+ return Boolean(entry?.tool && typeof entry.tool === "string");
778
+ }
779
+
759
780
  //#endregion
760
781
  //#region src/utils/generateStableId.ts
761
782
  /**
@@ -1247,4 +1268,4 @@ async function detectProjectType(workspaceRoot) {
1247
1268
  }
1248
1269
 
1249
1270
  //#endregion
1250
- export { ConfigSource, ProjectConfigResolver, ProjectFinderService, ProjectType, ScaffoldProcessingService, TemplatesManagerService, accessSync, cloneRepository, cloneSubdirectory, copy, detectProjectType, ensureDir, fetchGitHubDirectoryContents, findWorkspaceRoot, generateStableId, gitInit, icons, log, logger, messages, mkdir, mkdirSync, move, parseGitHubUrl, pathExists, pathExistsSync, print, readFile, readFileSync, readJson, readJsonSync, readdir, remove, sections, stat, statSync, writeFile, writeFileSync };
1271
+ export { ConfigSource, ProjectConfigResolver, ProjectFinderService, ProjectType, ScaffoldProcessingService, TemplatesManagerService, accessSync, cloneRepository, cloneSubdirectory, copy, detectProjectType, ensureDir, fetchGitHubDirectoryContents, findWorkspaceRoot, generateStableId, gitInit, icons, log, logger, messages, mkdir, mkdirSync, move, parseGitHubUrl, pathExists, pathExistsSync, print, readFile, readFileSync, readJson, readJsonSync, readdir, remove, resolveFallbackConfig, sections, stat, statSync, writeFile, writeFileSync };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agiflowai/aicode-utils",
3
3
  "description": "Shared utilities and types for AI-powered code generation, scaffolding, and analysis",
4
- "version": "1.0.17",
4
+ "version": "1.0.18",
5
5
  "license": "AGPL-3.0",
6
6
  "author": "AgiflowIO",
7
7
  "repository": {