@equinor/fusion-framework-cli-plugin-ai-base 1.0.5 → 2.0.0

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.
@@ -30,12 +30,21 @@ export interface FusionAIConfig {
30
30
  */
31
31
  export declare const configureFusionAI: <T extends FusionAIConfig>(fn: () => Promise<T> | T) => () => Promise<T> | T;
32
32
  /**
33
- * Options for loading Fusion AI configuration
33
+ * Options controlling how {@link loadFusionAIConfig} resolves and imports the
34
+ * Fusion AI configuration file.
34
35
  */
35
36
  export interface LoadFusionAIConfigOptions {
36
- /** Base directory to resolve the config file from (default: process.cwd()) */
37
+ /**
38
+ * Base directory used to resolve the config file path.
39
+ *
40
+ * @defaultValue `process.cwd()`
41
+ */
37
42
  baseDir?: string;
38
- /** File extensions to consider when resolving the config file (default: ['.ts', '.mjs', '.js', '.json']) */
43
+ /**
44
+ * File extensions tried (in order) when locating the config file.
45
+ *
46
+ * @defaultValue `['.ts', '.mjs', '.js', '.json']`
47
+ */
39
48
  extensions?: string[];
40
49
  }
41
50
  /**
@@ -1,3 +1,14 @@
1
+ /**
2
+ * AI command-option utilities for Fusion Framework CLI plugins.
3
+ *
4
+ * @remarks
5
+ * This entry point provides Commander option definitions, a Zod validation schema,
6
+ * and the {@link withOptions} helper that wires options and pre-action validation
7
+ * into any Commander command. Import from
8
+ * `@equinor/fusion-framework-cli-plugin-ai-base/command-options`.
9
+ *
10
+ * @packageDocumentation
11
+ */
1
12
  export { default as options } from './options.js';
2
13
  export { withOptions } from './with-options.js';
3
14
  export { AiOptionsSchema, type AiOptionsType } from './schema.js';
@@ -1,48 +1,78 @@
1
1
  /**
2
- * Option for specifying the Azure OpenAI API key.
3
- * Required for authentication with Azure OpenAI services.
2
+ * Commander option for the Azure OpenAI API key (`--openai-api-key`).
3
+ *
4
+ * @remarks
5
+ * Required for all Azure OpenAI operations. Falls back to the
6
+ * `AZURE_OPENAI_API_KEY` environment variable when the flag is omitted.
4
7
  */
5
8
  export declare const apiKeyOption: import("commander").Option;
6
9
  /**
7
- * Option for specifying the Azure OpenAI API version.
8
- * Defaults to the latest stable version if not provided.
10
+ * Commander option for the Azure OpenAI API version (`--openai-api-version`).
11
+ *
12
+ * @remarks
13
+ * Defaults to `2024-02-15-preview`. Falls back to the
14
+ * `AZURE_OPENAI_API_VERSION` environment variable when the flag is omitted.
9
15
  */
10
16
  export declare const apiVersionOption: import("commander").Option;
11
17
  /**
12
- * Option for specifying the Azure OpenAI instance name.
13
- * Required for Azure OpenAI service endpoint construction.
18
+ * Commander option for the Azure OpenAI instance name (`--openai-instance`).
19
+ *
20
+ * @remarks
21
+ * Required for constructing the Azure OpenAI service endpoint. Falls back to
22
+ * the `AZURE_OPENAI_INSTANCE_NAME` environment variable when the flag is omitted.
14
23
  */
15
24
  export declare const apiInstanceOption: import("commander").Option;
16
25
  /**
17
- * Option for specifying the Azure OpenAI deployment name for chat models.
18
- * Required for chat completions API calls.
26
+ * Commander option for the Azure OpenAI chat deployment (`--openai-chat-deployment`).
27
+ *
28
+ * @remarks
29
+ * Required for chat-completion operations. Falls back to the
30
+ * `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` environment variable when the flag is omitted.
31
+ * Only added to a command when `withOptions` is called with `includeChat: true`.
19
32
  */
20
33
  export declare const chatDeploymentOption: import("commander").Option;
21
34
  /**
22
- * Option for specifying the Azure OpenAI deployment name for embedding models.
23
- * Required for embeddings API calls.
35
+ * Commander option for the Azure OpenAI embedding deployment (`--openai-embedding-deployment`).
36
+ *
37
+ * @remarks
38
+ * Required for embedding and vector-search operations. Falls back to the
39
+ * `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` environment variable when the flag is omitted.
40
+ * Only added to a command when `withOptions` is called with `includeEmbedding: true`.
24
41
  */
25
42
  export declare const embeddingDeploymentOption: import("commander").Option;
26
43
  /**
27
- * Option for specifying the Azure Search endpoint URL.
28
- * Required for Azure Cognitive Search operations.
44
+ * Commander option for the Azure Cognitive Search endpoint (`--azure-search-endpoint`).
45
+ *
46
+ * @remarks
47
+ * Required for vector-search operations. Falls back to the
48
+ * `AZURE_SEARCH_ENDPOINT` environment variable when the flag is omitted.
49
+ * Only added to a command when `withOptions` is called with `includeSearch: true`.
29
50
  */
30
51
  export declare const azureSearchEndpointOption: import("commander").Option;
31
52
  /**
32
- * Option for specifying the Azure Search API key.
33
- * Required for authentication with Azure Cognitive Search.
53
+ * Commander option for the Azure Cognitive Search API key (`--azure-search-api-key`).
54
+ *
55
+ * @remarks
56
+ * Required for authenticating with Azure Cognitive Search. Falls back to the
57
+ * `AZURE_SEARCH_API_KEY` environment variable when the flag is omitted.
58
+ * Only added to a command when `withOptions` is called with `includeSearch: true`.
34
59
  */
35
60
  export declare const azureSearchApiKeyOption: import("commander").Option;
36
61
  /**
37
- * Option for specifying the Azure Search index name.
38
- * Required for search operations on a specific index.
62
+ * Commander option for the Azure Cognitive Search index name (`--azure-search-index-name`).
63
+ *
64
+ * @remarks
65
+ * Identifies the target search index to query or write to. Falls back to the
66
+ * `AZURE_SEARCH_INDEX_NAME` environment variable when the flag is omitted.
67
+ * Only added to a command when `withOptions` is called with `includeSearch: true`.
39
68
  */
40
69
  export declare const azureSearchIndexNameOption: import("commander").Option;
41
70
  /**
42
- * Default export containing all AI-related command options.
71
+ * All AI-related Commander option definitions as a single object.
43
72
  *
44
- * Provides convenient access to all option definitions for use in CLI commands.
45
- * Each option can also be imported individually for more granular control.
73
+ * @remarks
74
+ * Use this default export for convenient bulk access when you need every option.
75
+ * For selective inclusion prefer importing the named constants directly.
46
76
  */
47
77
  declare const _default: {
48
78
  apiKeyOption: import("commander").Option;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Zod validation schema and inferred type for AI command options.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import z from 'zod';
2
7
  /**
3
8
  * Base Zod schema for AI-related command options.
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Hand-authored TypeScript interface for AI CLI command options.
3
+ *
4
+ * @remarks
5
+ * Use {@link AiOptions} when you need a lightweight type without pulling in Zod.
6
+ * For runtime validation prefer {@link AiOptionsSchema} from the schema module.
7
+ *
8
+ * @packageDocumentation
9
+ */
1
10
  /**
2
11
  * Configuration options for AI-related CLI commands.
3
12
  *
@@ -2,23 +2,22 @@ import type { Command } from 'commander';
2
2
  /**
3
3
  * Registers an AI plugin command with the CLI program.
4
4
  *
5
- * This function ensures the 'ai' command group exists in the CLI program and adds
6
- * the provided command as a subcommand. If the 'ai' group doesn't exist, it creates
7
- * it with a standard description. This allows multiple AI-related plugins to register
8
- * their commands under a common namespace.
5
+ * Ensures the `ai` command group exists and attaches the provided command
6
+ * as a direct subcommand. Each plugin is responsible for structuring its
7
+ * own subcommands internally.
9
8
  *
10
- * @param program - The Commander program instance to register commands with
11
- * @param command - The command to add to the 'ai' command group
12
- * @returns void
9
+ * @param program - The Commander program instance to register commands with.
10
+ * @param command - The command to add under the `ai` command group.
13
11
  *
14
12
  * @example
15
13
  * ```ts
16
- * const myAiCommand = createCommand('chat')
17
- * .description('Start an AI chat session')
18
- * .action(() => { ... });
14
+ * // Register a command under `ai`:
15
+ * registerAiPlugin(program, chatCommand);
16
+ * // Results in: ffc ai chat
19
17
  *
20
- * registerAiPlugin(program, myAiCommand);
21
- * // Results in: fusion-cli ai chat
18
+ * // Register a command that has its own subcommands:
19
+ * registerAiPlugin(program, indexCommand);
20
+ * // Results in: ffc ai index embeddings, ffc ai index delete, etc.
22
21
  * ```
23
22
  */
24
23
  export declare function registerAiPlugin(program: Command, command: Command): void;
@@ -1 +1 @@
1
- export declare const version = "1.0.5";
1
+ export declare const version = "2.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-cli-plugin-ai-base",
3
- "version": "1.0.5",
3
+ "version": "2.0.0",
4
4
  "description": "Base AI plugin package for Fusion Framework CLI",
5
5
  "type": "module",
6
6
  "main": "dist/esm/index.js",
@@ -44,17 +44,18 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "commander": "^14.0.1",
47
- "zod": "^4.3.5",
48
- "@equinor/fusion-framework-module": "5.0.6",
49
- "@equinor/fusion-imports": "1.1.11",
50
- "@equinor/fusion-framework-module-ai": "2.0.2"
47
+ "zod": "^4.3.6",
48
+ "@equinor/fusion-framework-module": "6.0.0",
49
+ "@equinor/fusion-framework-module-ai": "3.0.0",
50
+ "@equinor/fusion-imports": "2.0.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@equinor/fusion-framework-cli": "^13.3.16"
53
+ "@equinor/fusion-framework-cli": "^14.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "typescript": "^5.8.2",
57
- "vitest": "^3.2.4"
56
+ "typescript": "^5.9.3",
57
+ "vitest": "^4.1.0",
58
+ "@equinor/fusion-framework-cli": "^14.0.0"
58
59
  },
59
60
  "scripts": {
60
61
  "build": "tsc -b",
package/src/config.ts CHANGED
@@ -34,12 +34,21 @@ export interface FusionAIConfig {
34
34
  export const configureFusionAI = <T extends FusionAIConfig>(fn: () => Promise<T> | T) => fn;
35
35
 
36
36
  /**
37
- * Options for loading Fusion AI configuration
37
+ * Options controlling how {@link loadFusionAIConfig} resolves and imports the
38
+ * Fusion AI configuration file.
38
39
  */
39
40
  export interface LoadFusionAIConfigOptions {
40
- /** Base directory to resolve the config file from (default: process.cwd()) */
41
+ /**
42
+ * Base directory used to resolve the config file path.
43
+ *
44
+ * @defaultValue `process.cwd()`
45
+ */
41
46
  baseDir?: string;
42
- /** File extensions to consider when resolving the config file (default: ['.ts', '.mjs', '.js', '.json']) */
47
+ /**
48
+ * File extensions tried (in order) when locating the config file.
49
+ *
50
+ * @defaultValue `['.ts', '.mjs', '.js', '.json']`
51
+ */
43
52
  extensions?: string[];
44
53
  }
45
54
 
@@ -1,3 +1,15 @@
1
+ /**
2
+ * AI command-option utilities for Fusion Framework CLI plugins.
3
+ *
4
+ * @remarks
5
+ * This entry point provides Commander option definitions, a Zod validation schema,
6
+ * and the {@link withOptions} helper that wires options and pre-action validation
7
+ * into any Commander command. Import from
8
+ * `@equinor/fusion-framework-cli-plugin-ai-base/command-options`.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+
1
13
  export { default as options } from './options.js';
2
14
  export { withOptions } from './with-options.js';
3
15
  export { AiOptionsSchema, type AiOptionsType } from './schema.js';
@@ -1,8 +1,11 @@
1
1
  import { createOption } from 'commander';
2
2
 
3
3
  /**
4
- * Option for specifying the Azure OpenAI API key.
5
- * Required for authentication with Azure OpenAI services.
4
+ * Commander option for the Azure OpenAI API key (`--openai-api-key`).
5
+ *
6
+ * @remarks
7
+ * Required for all Azure OpenAI operations. Falls back to the
8
+ * `AZURE_OPENAI_API_KEY` environment variable when the flag is omitted.
6
9
  */
7
10
  export const apiKeyOption = createOption(
8
11
  '--openai-api-key <key>',
@@ -10,8 +13,11 @@ export const apiKeyOption = createOption(
10
13
  ).env('AZURE_OPENAI_API_KEY');
11
14
 
12
15
  /**
13
- * Option for specifying the Azure OpenAI API version.
14
- * Defaults to the latest stable version if not provided.
16
+ * Commander option for the Azure OpenAI API version (`--openai-api-version`).
17
+ *
18
+ * @remarks
19
+ * Defaults to `2024-02-15-preview`. Falls back to the
20
+ * `AZURE_OPENAI_API_VERSION` environment variable when the flag is omitted.
15
21
  */
16
22
  export const apiVersionOption = createOption(
17
23
  '--openai-api-version <version>',
@@ -21,8 +27,11 @@ export const apiVersionOption = createOption(
21
27
  .default('2024-02-15-preview');
22
28
 
23
29
  /**
24
- * Option for specifying the Azure OpenAI instance name.
25
- * Required for Azure OpenAI service endpoint construction.
30
+ * Commander option for the Azure OpenAI instance name (`--openai-instance`).
31
+ *
32
+ * @remarks
33
+ * Required for constructing the Azure OpenAI service endpoint. Falls back to
34
+ * the `AZURE_OPENAI_INSTANCE_NAME` environment variable when the flag is omitted.
26
35
  */
27
36
  export const apiInstanceOption = createOption(
28
37
  '--openai-instance <name>',
@@ -30,8 +39,12 @@ export const apiInstanceOption = createOption(
30
39
  ).env('AZURE_OPENAI_INSTANCE_NAME');
31
40
 
32
41
  /**
33
- * Option for specifying the Azure OpenAI deployment name for chat models.
34
- * Required for chat completions API calls.
42
+ * Commander option for the Azure OpenAI chat deployment (`--openai-chat-deployment`).
43
+ *
44
+ * @remarks
45
+ * Required for chat-completion operations. Falls back to the
46
+ * `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` environment variable when the flag is omitted.
47
+ * Only added to a command when `withOptions` is called with `includeChat: true`.
35
48
  */
36
49
  export const chatDeploymentOption = createOption(
37
50
  '--openai-chat-deployment <name>',
@@ -39,8 +52,12 @@ export const chatDeploymentOption = createOption(
39
52
  ).env('AZURE_OPENAI_CHAT_DEPLOYMENT_NAME');
40
53
 
41
54
  /**
42
- * Option for specifying the Azure OpenAI deployment name for embedding models.
43
- * Required for embeddings API calls.
55
+ * Commander option for the Azure OpenAI embedding deployment (`--openai-embedding-deployment`).
56
+ *
57
+ * @remarks
58
+ * Required for embedding and vector-search operations. Falls back to the
59
+ * `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` environment variable when the flag is omitted.
60
+ * Only added to a command when `withOptions` is called with `includeEmbedding: true`.
44
61
  */
45
62
  export const embeddingDeploymentOption = createOption(
46
63
  '--openai-embedding-deployment <name>',
@@ -48,8 +65,12 @@ export const embeddingDeploymentOption = createOption(
48
65
  ).env('AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME');
49
66
 
50
67
  /**
51
- * Option for specifying the Azure Search endpoint URL.
52
- * Required for Azure Cognitive Search operations.
68
+ * Commander option for the Azure Cognitive Search endpoint (`--azure-search-endpoint`).
69
+ *
70
+ * @remarks
71
+ * Required for vector-search operations. Falls back to the
72
+ * `AZURE_SEARCH_ENDPOINT` environment variable when the flag is omitted.
73
+ * Only added to a command when `withOptions` is called with `includeSearch: true`.
53
74
  */
54
75
  export const azureSearchEndpointOption = createOption(
55
76
  '--azure-search-endpoint <url>',
@@ -57,8 +78,12 @@ export const azureSearchEndpointOption = createOption(
57
78
  ).env('AZURE_SEARCH_ENDPOINT');
58
79
 
59
80
  /**
60
- * Option for specifying the Azure Search API key.
61
- * Required for authentication with Azure Cognitive Search.
81
+ * Commander option for the Azure Cognitive Search API key (`--azure-search-api-key`).
82
+ *
83
+ * @remarks
84
+ * Required for authenticating with Azure Cognitive Search. Falls back to the
85
+ * `AZURE_SEARCH_API_KEY` environment variable when the flag is omitted.
86
+ * Only added to a command when `withOptions` is called with `includeSearch: true`.
62
87
  */
63
88
  export const azureSearchApiKeyOption = createOption(
64
89
  '--azure-search-api-key <key>',
@@ -66,8 +91,12 @@ export const azureSearchApiKeyOption = createOption(
66
91
  ).env('AZURE_SEARCH_API_KEY');
67
92
 
68
93
  /**
69
- * Option for specifying the Azure Search index name.
70
- * Required for search operations on a specific index.
94
+ * Commander option for the Azure Cognitive Search index name (`--azure-search-index-name`).
95
+ *
96
+ * @remarks
97
+ * Identifies the target search index to query or write to. Falls back to the
98
+ * `AZURE_SEARCH_INDEX_NAME` environment variable when the flag is omitted.
99
+ * Only added to a command when `withOptions` is called with `includeSearch: true`.
71
100
  */
72
101
  export const azureSearchIndexNameOption = createOption(
73
102
  '--azure-search-index-name <name>',
@@ -75,10 +104,11 @@ export const azureSearchIndexNameOption = createOption(
75
104
  ).env('AZURE_SEARCH_INDEX_NAME');
76
105
 
77
106
  /**
78
- * Default export containing all AI-related command options.
107
+ * All AI-related Commander option definitions as a single object.
79
108
  *
80
- * Provides convenient access to all option definitions for use in CLI commands.
81
- * Each option can also be imported individually for more granular control.
109
+ * @remarks
110
+ * Use this default export for convenient bulk access when you need every option.
111
+ * For selective inclusion prefer importing the named constants directly.
82
112
  */
83
113
  export default {
84
114
  apiKeyOption,
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Zod validation schema and inferred type for AI command options.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
1
7
  import z from 'zod';
2
8
 
3
9
  /**
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Hand-authored TypeScript interface for AI CLI command options.
3
+ *
4
+ * @remarks
5
+ * Use {@link AiOptions} when you need a lightweight type without pulling in Zod.
6
+ * For runtime validation prefer {@link AiOptionsSchema} from the schema module.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+
1
11
  /**
2
12
  * Configuration options for AI-related CLI commands.
3
13
  *
@@ -79,7 +79,9 @@ export const withOptions = (
79
79
  typeof options.openaiApiKey !== 'string' ||
80
80
  options.openaiApiKey.trim() === ''
81
81
  ) {
82
- throw new InvalidOptionArgumentError('API key is required and must be a non-empty string.');
82
+ throw new InvalidOptionArgumentError(
83
+ 'Azure OpenAI API key is required. Provide it via --openai-api-key option or AZURE_OPENAI_API_KEY environment variable.',
84
+ );
83
85
  }
84
86
 
85
87
  // Validate API version
@@ -94,7 +96,7 @@ export const withOptions = (
94
96
  options.openaiInstance.trim() === ''
95
97
  ) {
96
98
  throw new InvalidOptionArgumentError(
97
- 'API instance name is required and must be a non-empty string.',
99
+ 'Azure OpenAI instance name is required. Provide it via --openai-instance option or AZURE_OPENAI_INSTANCE_NAME environment variable.',
98
100
  );
99
101
  }
100
102
 
@@ -117,7 +119,7 @@ export const withOptions = (
117
119
  options.openaiEmbeddingDeployment.trim() === ''
118
120
  ) {
119
121
  throw new InvalidOptionArgumentError(
120
- 'Embedding deployment name is required and must be a non-empty string.',
122
+ 'Azure OpenAI embedding deployment name is required. Provide it via --openai-embedding-deployment option or AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME environment variable.',
121
123
  );
122
124
  }
123
125
  }
@@ -139,7 +141,7 @@ export const withOptions = (
139
141
  options.azureSearchApiKey.trim() === ''
140
142
  ) {
141
143
  throw new InvalidOptionArgumentError(
142
- 'Azure Search API key is required and must be a non-empty string.',
144
+ 'Azure Search API key is required. Provide it via --azure-search-api-key option or AZURE_SEARCH_API_KEY environment variable.',
143
145
  );
144
146
  }
145
147
 
package/src/register.ts CHANGED
@@ -4,23 +4,22 @@ import { createCommand } from 'commander';
4
4
  /**
5
5
  * Registers an AI plugin command with the CLI program.
6
6
  *
7
- * This function ensures the 'ai' command group exists in the CLI program and adds
8
- * the provided command as a subcommand. If the 'ai' group doesn't exist, it creates
9
- * it with a standard description. This allows multiple AI-related plugins to register
10
- * their commands under a common namespace.
7
+ * Ensures the `ai` command group exists and attaches the provided command
8
+ * as a direct subcommand. Each plugin is responsible for structuring its
9
+ * own subcommands internally.
11
10
  *
12
- * @param program - The Commander program instance to register commands with
13
- * @param command - The command to add to the 'ai' command group
14
- * @returns void
11
+ * @param program - The Commander program instance to register commands with.
12
+ * @param command - The command to add under the `ai` command group.
15
13
  *
16
14
  * @example
17
15
  * ```ts
18
- * const myAiCommand = createCommand('chat')
19
- * .description('Start an AI chat session')
20
- * .action(() => { ... });
16
+ * // Register a command under `ai`:
17
+ * registerAiPlugin(program, chatCommand);
18
+ * // Results in: ffc ai chat
21
19
  *
22
- * registerAiPlugin(program, myAiCommand);
23
- * // Results in: fusion-cli ai chat
20
+ * // Register a command that has its own subcommands:
21
+ * registerAiPlugin(program, indexCommand);
22
+ * // Results in: ffc ai index embeddings, ffc ai index delete, etc.
24
23
  * ```
25
24
  */
26
25
  export function registerAiPlugin(program: Command, command: Command): void {
@@ -32,6 +31,7 @@ export function registerAiPlugin(program: Command, command: Command): void {
32
31
  );
33
32
  program.addCommand(aiCommand);
34
33
  }
34
+
35
35
  aiCommand.addCommand(command);
36
36
  }
37
37
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '1.0.5';
2
+ export const version = '2.0.0';
package/tsconfig.json CHANGED
@@ -14,6 +14,9 @@
14
14
  },
15
15
  {
16
16
  "path": "../../modules/module"
17
+ },
18
+ {
19
+ "path": "../../utils/imports"
17
20
  }
18
21
  ],
19
22
  "include": ["src/**/*"],