@ama-sdk/schematics 14.1.0-prerelease.9 → 14.1.0-rc.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.
- package/README.md +29 -2
- package/cli/clear-index.cjs.map +1 -0
- package/cli/files-pack.cjs.map +1 -0
- package/cli/genai-context/templates/SDK_CONTEXT.md.template +64 -0
- package/cli/genai-context/update-sdk-context.cjs +355 -0
- package/cli/genai-context/update-sdk-context.cjs.map +1 -0
- package/cli/genai-context/update-sdk-context.d.cts +20 -0
- package/cli/genai-context/update-sdk-context.d.cts.map +1 -0
- package/cli/genai-context/update-sdk-context.helpers.d.ts +89 -0
- package/cli/genai-context/update-sdk-context.helpers.d.ts.map +1 -0
- package/cli/genai-context/update-sdk-context.helpers.js +197 -0
- package/cli/genai-context/update-sdk-context.helpers.js.map +1 -0
- package/cli/genai-context/update-sdk-context.template.d.ts +24 -0
- package/cli/genai-context/update-sdk-context.template.d.ts.map +1 -0
- package/cli/genai-context/update-sdk-context.template.js +15 -0
- package/cli/genai-context/update-sdk-context.template.js.map +1 -0
- package/cli/update-sdk-genai-context.cjs +60 -0
- package/cli/update-sdk-genai-context.cjs.map +1 -0
- package/cli/update-sdk-genai-context.d.cts +3 -0
- package/cli/update-sdk-genai-context.d.cts.map +1 -0
- package/cli/update-spec-from-npm.cjs.map +1 -0
- package/package.json +37 -33
- package/schematics/api-extension/index.js.map +1 -0
- package/schematics/api-extension/schema.js.map +1 -0
- package/schematics/code-generator/code-generator.js.map +1 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli-generator.js.map +1 -0
- package/schematics/code-generator/open-api-cli-generator/open-api-cli-options.js.map +1 -0
- package/schematics/helpers/generators.js.map +1 -0
- package/schematics/helpers/is-typescript-project.js.map +1 -0
- package/schematics/helpers/node-install.js.map +1 -0
- package/schematics/helpers/open-api-tools-configuration.js.map +1 -0
- package/schematics/helpers/read-package.js.map +1 -0
- package/schematics/helpers/tree-glob.js.map +1 -0
- package/schematics/migrate/index.js.map +1 -0
- package/schematics/migrate/schema.js.map +1 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-update/index.js.map +1 -0
- package/schematics/ng-update/typescript/index.js.map +1 -0
- package/schematics/ng-update/typescript/v10.0/script-removal.js.map +1 -0
- package/schematics/ng-update/typescript/v10.1/add-presets-renovate.js.map +1 -0
- package/schematics/ng-update/typescript/v10.3/update-openapiversion.js.map +1 -0
- package/schematics/ng-update/typescript/v11.0/update-openapitools.js.map +1 -0
- package/schematics/ng-update/typescript/v11.0/update-regen-script.js.map +1 -0
- package/schematics/ng-update/typescript/v11.4/create-gitattributes.js.map +1 -0
- package/schematics/ng-update/typescript/v12.1/clean-packagejson-exports.js.map +1 -0
- package/schematics/ng-update/typescript/v12.3/coverage-ignore.js.map +1 -0
- package/schematics/typescript/core/helpers/copy-referenced-files.js.map +1 -0
- package/schematics/typescript/core/helpers/path-extractor.js.map +1 -0
- package/schematics/typescript/core/index.js.map +1 -0
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator-tests.jar +0 -0
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator.jar +0 -0
- package/schematics/typescript/core/schema.js.map +1 -0
- package/schematics/typescript/mock/index.js.map +1 -0
- package/schematics/typescript/mock/schema.js.map +1 -0
- package/schematics/typescript/shell/index.js.map +1 -0
- package/schematics/typescript/shell/schema.js.map +1 -0
- package/src/public_api.js.map +1 -0
package/README.md
CHANGED
|
@@ -116,10 +116,11 @@ To align ourselves with OpenAPI 3.1, we now support arrays and objects in path a
|
|
|
116
116
|
Based on the values of the keywords `style` and `explode` within the specification file, the parameters are serialized accordingly in the URLs of the APIs.
|
|
117
117
|
For more information, check out OpenAPI's documentation on [parameter serialization](https://swagger.io/specification/).
|
|
118
118
|
|
|
119
|
-
It is important to note that, as in OpenAPI 3.1, we only support simple arrays and simple non-nested objects in path and query parameters.
|
|
119
|
+
It is important to note that, as in OpenAPI 3.1, we only support simple arrays and simple non-nested objects in path and query parameters.
|
|
120
120
|
The parameter types that we support are stored in `SupportedParamType` in the package `@ama-sdk/core`.
|
|
121
121
|
|
|
122
122
|
To enable the parameter serialization within your API, you can set the option `enableParameterSerialization` to `true` (its current default value is `false`) in the constructor. For example:
|
|
123
|
+
|
|
123
124
|
```typescript
|
|
124
125
|
const apiConfig: ApiClient = new ApiFetchClient(
|
|
125
126
|
{
|
|
@@ -163,9 +164,10 @@ If your specification file includes dates, there are multiple options for the ge
|
|
|
163
164
|
For more information related to these types, check out this [documentation](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/shell/templates/base#manage-dates).
|
|
164
165
|
This can be done by adding `--global-property stringifyDate=false` to the generator command or by adding the global property
|
|
165
166
|
to the `openapitools.json`.
|
|
167
|
+
|
|
166
168
|
> [!NOTE]
|
|
167
169
|
> An extra type to manage special timezone use cases can be used at property level thanks to the
|
|
168
|
-
> `x-local-timezone` vendor.
|
|
170
|
+
> `x-local-timezone` vendor.
|
|
169
171
|
> Please check out the [date documentation](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/schematics/typescript/shell/templates/base#manage-dates).
|
|
170
172
|
|
|
171
173
|
Example to use `Date`:
|
|
@@ -174,6 +176,30 @@ Example to use `Date`:
|
|
|
174
176
|
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property stringifyDate=false
|
|
175
177
|
```
|
|
176
178
|
|
|
179
|
+
##### Request Body Transformation
|
|
180
|
+
|
|
181
|
+
You may want to customize the request body parameters in your SDK.
|
|
182
|
+
This can be done by using the global property option `requestBodyTransform` by adding `--global-property requestBodyTransform=yourTransform` to the generator command.
|
|
183
|
+
The original name of the body request parameter can be referred in the value of `requestBodyTransform` with `{{bodyRequest}}`.
|
|
184
|
+
|
|
185
|
+
Examples:
|
|
186
|
+
|
|
187
|
+
```shell
|
|
188
|
+
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property requestBodyTransform=content{{bodyRequest}}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
> In this example, the prefix for request body parameters will be prefixed with `content`.
|
|
192
|
+
|
|
193
|
+
```shell
|
|
194
|
+
yarn schematics @ama-sdk/schematics:typescript-core --spec-path ./swagger-spec.yaml --global-property requestBodyTransform=content
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
> In this example, the prefix for request body parameters will be replaced by `content`.
|
|
198
|
+
|
|
199
|
+
The Body request parameter generated in the SDK can also be defined in the specification file by using the vendor extension `x-body-param-name` at body parameter level.
|
|
200
|
+
> [!WARNING]
|
|
201
|
+
> This vendor extension will take precedence over the global property `requestBodyTransform`.
|
|
202
|
+
|
|
177
203
|
##### Extensible models
|
|
178
204
|
|
|
179
205
|
You may be in a case in which you want to be able to extend your SDK models and therefore ensure that revivers are generated
|
|
@@ -328,3 +354,4 @@ Use `--help` on each command for more information
|
|
|
328
354
|
| amasdk-clear-index | Remove the index files that are no longer necessary after the deletion of the associated model |
|
|
329
355
|
| amasdk-files-pack | Prepare the dist folder for publication |
|
|
330
356
|
| amasdk-update-spec-from-npm | Update the OpenAPI spec from an NPM package |
|
|
357
|
+
| amasdk-update-sdk-context | Update the SDK_CONTEXT.md file with the latest information from the OpenAPI spec (see [update-sdk-context](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/schematics/cli/genai-context/README.md)) |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear-index.cjs","sourceRoot":"","sources":["../../cli/clear-index.cts"],"names":[],"mappings":";;AAEA;;GAEG;;AAEH,qCAGiB;AACjB,yCAEmB;AAInB,qCAAqC;AAErC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAA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AC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;iBAChB,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE1B,4BAA4B;IAC5B,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,aAAa,EAAE,CAAC;IACxB,CAAC;AACH,CAAC,CAAC;AAEF,KAAK,CAAC,KAAK,IAAI,EAAE;IACf,IAAI,OAAO,GAAe,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC;IAC1C,IAAI,CAAC;QACH,MAAM,EAAE,oBAAoB,EAAE,GAAG,2CAAa,gBAAgB,EAAC,CAAC;QAChE,OAAO,GAAG,oBAAoB,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,oDAAoD;IACtD,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,EAAE,gCAAgC,CAAC,EAAE,CAAC;AAC1D,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# SDK Context for AI Tools
|
|
2
|
+
|
|
3
|
+
This document provides context about the generated TypeScript SDK to help AI assistants understand the codebase structure and avoid hallucinations.
|
|
4
|
+
|
|
5
|
+
## SDK Information
|
|
6
|
+
|
|
7
|
+
- **Package Name**: `<%= packageName %>`
|
|
8
|
+
- **OpenAPI Version**: `<%= openApiVersion %>`
|
|
9
|
+
- **API Title**: <%= apiTitle %>
|
|
10
|
+
- **Generated with**: `@ama-sdk/schematics:typescript-core`
|
|
11
|
+
|
|
12
|
+
## Project Structure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
<%= packageName %>/
|
|
16
|
+
├── api/ # API endpoint classes (domain-based)
|
|
17
|
+
<%= domainTree %>
|
|
18
|
+
│ └── index.ts
|
|
19
|
+
├── models/
|
|
20
|
+
│ ├── base/ # Auto-generated from OpenAPI (DO NOT MODIFY)
|
|
21
|
+
│ ├── core/ # Extensions of base models if needed
|
|
22
|
+
│ ├── custom/ # Custom business models if needed
|
|
23
|
+
│ └── index.ts
|
|
24
|
+
├── spec/ # Operation specifications
|
|
25
|
+
├── fixtures/ # Test fixtures
|
|
26
|
+
├── open-api.yaml # OpenAPI specification source
|
|
27
|
+
└── openapitools.json # Generator configuration
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
<!-- DOMAINS-START -->
|
|
31
|
+
## Domains
|
|
32
|
+
|
|
33
|
+
The following domains were extracted from the OpenAPI specification. Each domain represents a logical grouping of related API operations.
|
|
34
|
+
|
|
35
|
+
<%= domainsSection %>
|
|
36
|
+
<!-- DOMAINS-END -->
|
|
37
|
+
|
|
38
|
+
## Important Guidelines
|
|
39
|
+
|
|
40
|
+
### DO NOT
|
|
41
|
+
|
|
42
|
+
- Modify files in `models/base/` - these are auto-generated
|
|
43
|
+
- Invent operation IDs that don't exist in the domains above
|
|
44
|
+
- Assume model properties not defined in the OpenAPI spec
|
|
45
|
+
- Create new API classes outside the domain structure
|
|
46
|
+
|
|
47
|
+
### DO
|
|
48
|
+
|
|
49
|
+
- Use the exact operation IDs listed above
|
|
50
|
+
- Reference models from `models/base/` (or `src/models/base/` in case mcp server is running in the o3r/framework project) for type definitions
|
|
51
|
+
- Check `api/{domain}/{domain}-api.ts` for available methods
|
|
52
|
+
|
|
53
|
+
## User Disambiguation Notes
|
|
54
|
+
|
|
55
|
+
<!-- Add project-specific clarifications below -->
|
|
56
|
+
<% if (disambiguation) { %>
|
|
57
|
+
<%= disambiguation %>
|
|
58
|
+
<% } else { %>
|
|
59
|
+
(No disambiguation notes added yet. Run with --interactive to add notes.)
|
|
60
|
+
<% } %>
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
*This file was generated using `amasdk-update-sdk-context`. Re-run after SDK regeneration to update domains.*
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSdkContext = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const node_readline_1 = require("node:readline");
|
|
8
|
+
const core_1 = require("@angular-devkit/core");
|
|
9
|
+
const schematics_1 = require("@o3r/schematics");
|
|
10
|
+
const js_yaml_1 = require("js-yaml");
|
|
11
|
+
const update_sdk_context_helpers_1 = require("./update-sdk-context.helpers");
|
|
12
|
+
const update_sdk_context_template_1 = require("./update-sdk-context.template");
|
|
13
|
+
const DOMAIN_DESCRIPTIONS_FILENAME = 'domain-descriptions.json';
|
|
14
|
+
/**
|
|
15
|
+
* Load OpenAPI specifications from file or default locations
|
|
16
|
+
* @param projectPath Path to the OpenAPI specification file
|
|
17
|
+
* @param specFileName Name of the OpenAPI specification file
|
|
18
|
+
* @returns OpenAPI specification as JSON object
|
|
19
|
+
*/
|
|
20
|
+
function loadOpenAPISpec(projectPath, specFileName) {
|
|
21
|
+
let isYaml = false;
|
|
22
|
+
let specPath;
|
|
23
|
+
if (specFileName) {
|
|
24
|
+
specPath = (0, node_path_1.resolve)(projectPath, specFileName);
|
|
25
|
+
if (!(0, node_fs_1.existsSync)(specPath)) {
|
|
26
|
+
throw new Error(`OpenAPI specification not found at: ${specPath}`);
|
|
27
|
+
}
|
|
28
|
+
isYaml = specPath.endsWith('.yaml') || specPath.endsWith('.yml');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const yamlPath = (0, node_path_1.join)(projectPath, 'open-api.yaml');
|
|
32
|
+
const jsonPath = (0, node_path_1.join)(projectPath, 'open-api.json');
|
|
33
|
+
if ((0, node_fs_1.existsSync)(yamlPath)) {
|
|
34
|
+
specPath = yamlPath;
|
|
35
|
+
isYaml = true;
|
|
36
|
+
}
|
|
37
|
+
else if ((0, node_fs_1.existsSync)(jsonPath)) {
|
|
38
|
+
specPath = jsonPath;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw new Error(`No OpenAPI specification found. Looked for:\n - ${yamlPath}\n - ${jsonPath}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const specContent = (0, node_fs_1.readFileSync)(specPath, 'utf8');
|
|
45
|
+
try {
|
|
46
|
+
return (isYaml ? (0, js_yaml_1.load)(specContent) : JSON.parse(specContent));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new Error(`Failed to parse OpenAPI specification at ${specPath}: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Read the domain descriptions from user file, this allow for custom domain descriptions
|
|
54
|
+
* and extra clarifications
|
|
55
|
+
* @param filePath Path to the domain descriptions file
|
|
56
|
+
*/
|
|
57
|
+
function loadDomainDescriptions(filePath) {
|
|
58
|
+
if (!(0, node_fs_1.existsSync)(filePath)) {
|
|
59
|
+
throw new Error(`Domain descriptions file not found: ${filePath}`);
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse((0, node_fs_1.readFileSync)(filePath, 'utf8'));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throw new Error(`Failed to parse domain descriptions file: ${filePath}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Read the package.json file
|
|
70
|
+
* @param projectPath Path to the project root
|
|
71
|
+
*/
|
|
72
|
+
function loadPackageJson(projectPath) {
|
|
73
|
+
const packagePath = (0, node_path_1.join)(projectPath, 'package.json');
|
|
74
|
+
if ((0, node_fs_1.existsSync)(packagePath)) {
|
|
75
|
+
return JSON.parse((0, node_fs_1.readFileSync)(packagePath, 'utf8'));
|
|
76
|
+
}
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Load and parse existing SDK_CONTEXT.md to extract preserved sections
|
|
81
|
+
* @param projectPath Path to the project root
|
|
82
|
+
* @returns Parsed sections or defaults if file doesn't exist
|
|
83
|
+
*/
|
|
84
|
+
function loadExistingContext(projectPath) {
|
|
85
|
+
const contextPath = (0, node_path_1.join)(projectPath, 'SDK_CONTEXT.md');
|
|
86
|
+
if (!(0, node_fs_1.existsSync)(contextPath)) {
|
|
87
|
+
return (0, update_sdk_context_helpers_1.parseExistingContext)(null);
|
|
88
|
+
}
|
|
89
|
+
const content = (0, node_fs_1.readFileSync)(contextPath, 'utf8');
|
|
90
|
+
return (0, update_sdk_context_helpers_1.parseExistingContext)(content);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate the domains section content
|
|
94
|
+
* @param domains Map of domains
|
|
95
|
+
* @returns Formatted domains section markdown
|
|
96
|
+
*/
|
|
97
|
+
function generateDomainsSection(domains) {
|
|
98
|
+
let domainsSection = '';
|
|
99
|
+
domains.forEach((domain) => {
|
|
100
|
+
domainsSection += `
|
|
101
|
+
### ${domain.name}
|
|
102
|
+
|
|
103
|
+
**What this domain is about**: ${domain.description}
|
|
104
|
+
|
|
105
|
+
**API Class**: \`src/api/${domain.name}/${domain.name}-api.ts\`
|
|
106
|
+
|
|
107
|
+
**Available Operations:**
|
|
108
|
+
|
|
109
|
+
| Operation ID | Method | Description |
|
|
110
|
+
|--------------|--------|-------------|
|
|
111
|
+
`;
|
|
112
|
+
domain.operations.forEach((op) => {
|
|
113
|
+
domainsSection += `| \`${op.operationId}\` | ${op.method} | ${op.summary} |\n`;
|
|
114
|
+
});
|
|
115
|
+
domainsSection += `\n**Models used in this domain:**\n`;
|
|
116
|
+
if (domain.models.size > 0) {
|
|
117
|
+
domain.models.forEach((model) => {
|
|
118
|
+
domainsSection += `- \`${model}\` - imported from \`src/models/base/${core_1.strings.dasherize(model)}/\`\n`;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
domainsSection += `- (none)\n`;
|
|
123
|
+
}
|
|
124
|
+
domainsSection += '\n';
|
|
125
|
+
});
|
|
126
|
+
return domainsSection;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Generate the SDK_CONTEXT.md file from template
|
|
130
|
+
* @param spec OpenAPI specification as JSON object
|
|
131
|
+
* @param domains Map of domains
|
|
132
|
+
* @param packageName Package name
|
|
133
|
+
* @param disambiguation Disambiguation notes
|
|
134
|
+
*/
|
|
135
|
+
async function generateContextFile(spec, domains, packageName, disambiguation) {
|
|
136
|
+
const openApiVersion = 'openapi' in spec ? spec.openapi : ('swagger' in spec ? spec.swagger : 'unknown');
|
|
137
|
+
const apiTitle = spec.info?.title || 'Unknown API';
|
|
138
|
+
const domainsSection = generateDomainsSection(domains);
|
|
139
|
+
const domainTree = Array.from(domains.values())
|
|
140
|
+
.map((d) => `│ ├── ${d.name}/ # ${d.description.substring(0, 40)}...`)
|
|
141
|
+
.join('\n');
|
|
142
|
+
return await (0, update_sdk_context_template_1.renderSdkContextTemplate)({
|
|
143
|
+
packageName,
|
|
144
|
+
openApiVersion,
|
|
145
|
+
apiTitle,
|
|
146
|
+
domainTree,
|
|
147
|
+
domainsSection,
|
|
148
|
+
disambiguation
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Prompt the user for disambiguation notes
|
|
153
|
+
* @param domains Map of domains
|
|
154
|
+
* @param existingDisambiguation Existing disambiguation notes
|
|
155
|
+
* @param hasCustomDescriptions Whether the user provided custom descriptions
|
|
156
|
+
* @param domainDescriptionsFileName Name of the domain descriptions file
|
|
157
|
+
* @param logger Logger instance
|
|
158
|
+
* @returns Disambiguation notes
|
|
159
|
+
*/
|
|
160
|
+
async function promptForDisambiguation(domains, existingDisambiguation, hasCustomDescriptions, domainDescriptionsFileName, logger) {
|
|
161
|
+
const rl = (0, node_readline_1.createInterface)({
|
|
162
|
+
input: process.stdin,
|
|
163
|
+
output: process.stdout
|
|
164
|
+
});
|
|
165
|
+
const question = (prompt) => {
|
|
166
|
+
return new Promise((res) => rl.question(prompt, res));
|
|
167
|
+
};
|
|
168
|
+
logger.log(`
|
|
169
|
+
=== SDK Context Update - Interactive Mode ===
|
|
170
|
+
Computed domain descriptions:
|
|
171
|
+
`);
|
|
172
|
+
domains.forEach((domain) => {
|
|
173
|
+
logger.log(`
|
|
174
|
+
• ${domain.name}
|
|
175
|
+
Description: ${domain.description}
|
|
176
|
+
Operations: ${domain.operations.length}
|
|
177
|
+
Models: ${domain.models.size}
|
|
178
|
+
`);
|
|
179
|
+
});
|
|
180
|
+
if (hasCustomDescriptions) {
|
|
181
|
+
logger.log(`(Using custom descriptions from --domain-descriptions file)`);
|
|
182
|
+
}
|
|
183
|
+
const confirmDomains = await question('\nAre these domain descriptions correct? (y/n): ');
|
|
184
|
+
if (confirmDomains.toLowerCase() !== 'y') {
|
|
185
|
+
const overrideFile = domainDescriptionsFileName || DOMAIN_DESCRIPTIONS_FILENAME;
|
|
186
|
+
logger.log(`
|
|
187
|
+
To modify domain descriptions, edit the override file:
|
|
188
|
+
File: ${overrideFile}
|
|
189
|
+
Format: { "domainName": "description", ... }
|
|
190
|
+
`);
|
|
191
|
+
rl.close();
|
|
192
|
+
throw new Error(hasCustomDescriptions
|
|
193
|
+
? `User rejected domain descriptions. Please edit the ${overrideFile} file and re-run this command.`
|
|
194
|
+
: `User rejected domain descriptions. Create ${overrideFile} and run: amasdk-update-sdk-context --interactive --domain-descriptions ${overrideFile}`);
|
|
195
|
+
}
|
|
196
|
+
logger.log(`
|
|
197
|
+
--- Disambiguation Notes ---
|
|
198
|
+
Add any clarifications AI tools should know about your SDK.
|
|
199
|
+
Examples: naming conventions, domain relationships, custom extensions, known limitations.
|
|
200
|
+
`);
|
|
201
|
+
if (existingDisambiguation) {
|
|
202
|
+
logger.log(`
|
|
203
|
+
Existing notes:
|
|
204
|
+
${existingDisambiguation}
|
|
205
|
+
`);
|
|
206
|
+
const keepExisting = await question(`
|
|
207
|
+
Keep existing disambiguation notes? (y/n): `);
|
|
208
|
+
if (keepExisting.toLowerCase() === 'y') {
|
|
209
|
+
const addMore = await question('Add more notes? (y/n): ');
|
|
210
|
+
if (addMore.toLowerCase() === 'y') {
|
|
211
|
+
const additional = await question('Enter additional notes (single line): ');
|
|
212
|
+
rl.close();
|
|
213
|
+
return `
|
|
214
|
+
${existingDisambiguation}
|
|
215
|
+
${additional}
|
|
216
|
+
`;
|
|
217
|
+
}
|
|
218
|
+
rl.close();
|
|
219
|
+
return existingDisambiguation;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const newNotes = await question(`
|
|
223
|
+
Enter disambiguation notes (or press Enter to skip):
|
|
224
|
+
`);
|
|
225
|
+
rl.close();
|
|
226
|
+
return newNotes || '';
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get the cpy-cli version from `@ama-sdk/schematics` package.json
|
|
230
|
+
*/
|
|
231
|
+
function getCpyCliVersion() {
|
|
232
|
+
const schematicsPackagePath = (0, node_path_1.join)(__dirname, '../../../package.json');
|
|
233
|
+
try {
|
|
234
|
+
const schematicsPackageJson = JSON.parse((0, node_fs_1.readFileSync)(schematicsPackagePath, 'utf8'));
|
|
235
|
+
return schematicsPackageJson.devDependencies?.['cpy-cli'] || null;
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Adds a prepare:context script to package.json that copies SDK_CONTEXT.md to dist/
|
|
243
|
+
* and updates the build script to include prepare:context if needed.
|
|
244
|
+
* @param packageJsonPath - Path to the package.json file
|
|
245
|
+
* @param logger - Logger instance
|
|
246
|
+
*/
|
|
247
|
+
async function addPrepareContextScript(packageJsonPath, logger) {
|
|
248
|
+
try {
|
|
249
|
+
if (!(0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
250
|
+
logger.error(`Package.json not found at: ${packageJsonPath}`);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const packageJsonContent = (0, node_fs_1.readFileSync)(packageJsonPath, 'utf8');
|
|
254
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
255
|
+
// Initialize scripts object if it doesn't exist
|
|
256
|
+
packageJson.scripts ||= {};
|
|
257
|
+
// Initialize devDependencies object if it doesn't exist
|
|
258
|
+
packageJson.devDependencies ||= {};
|
|
259
|
+
// Check if cpy-cli is available as dev dependency, install if missing
|
|
260
|
+
if (!packageJson.devDependencies['cpy-cli']) {
|
|
261
|
+
const cpyCliVersion = getCpyCliVersion();
|
|
262
|
+
if (cpyCliVersion) {
|
|
263
|
+
logger.log(`Installing cpy-cli@${cpyCliVersion} as dev dependency...`);
|
|
264
|
+
try {
|
|
265
|
+
const targetDir = (0, node_path_1.dirname)(packageJsonPath);
|
|
266
|
+
(0, node_child_process_1.execFileSync)((0, schematics_1.getPackageManager)(), [
|
|
267
|
+
...(0, schematics_1.getPackageManager)() === 'npm' ? ['install', '--save-dev'] : ['add', '--dev'],
|
|
268
|
+
`cpy-cli@${cpyCliVersion}`
|
|
269
|
+
], { cwd: targetDir, stdio: 'pipe', shell: process.platform === 'win32' });
|
|
270
|
+
packageJson.devDependencies['cpy-cli'] = cpyCliVersion;
|
|
271
|
+
logger.log(`Successfully installed cpy-cli@${cpyCliVersion}`);
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
logger.warn(`Failed to install cpy-cli: ${error instanceof Error ? error.message : String(error)}. Please install it manually.`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
logger.warn(`cpy-cli is required but version could not be determined. Please install it manually with: npm install --save-dev cpy-cli`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Update package.json with prepare:context script
|
|
282
|
+
const updateResult = (0, update_sdk_context_helpers_1.updatePackageJsonForContextScript)(packageJson);
|
|
283
|
+
if (updateResult.prepareContextAdded) {
|
|
284
|
+
logger.log(`Added 'prepare:context' script to package.json`);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
logger.log(`'prepare:context' script already exists in package.json`);
|
|
288
|
+
}
|
|
289
|
+
if (updateResult.buildScriptUpdated) {
|
|
290
|
+
logger.log(`Updated 'build' script to include 'prepare:context'`);
|
|
291
|
+
}
|
|
292
|
+
// Write the updated package.json back to file
|
|
293
|
+
await node_fs_1.promises.writeFile(packageJsonPath, JSON.stringify(updateResult.packageJson, null, 2), 'utf8');
|
|
294
|
+
logger.log(`Package.json updated successfully: ${packageJsonPath}`);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
// Ignore errors for now
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Generate the SDK_CONTEXT.md file
|
|
302
|
+
* @param projectPath Path to the project root
|
|
303
|
+
* @param specFileName Name of the OpenAPI spec file
|
|
304
|
+
* @param domainDescriptionsFileName Name of the domain descriptions file
|
|
305
|
+
* @param isInteractive Whether to run in interactive mode
|
|
306
|
+
* @param prepareScript Whether to add a prepare:context script to package.json
|
|
307
|
+
* @param preserveEdits Whether to preserve user edits outside the Domains section on re-run
|
|
308
|
+
* @param logger Logger instance
|
|
309
|
+
*/
|
|
310
|
+
const generateSdkContext = async (projectPath, specFileName, domainDescriptionsFileName, isInteractive, prepareScript, preserveEdits, logger) => {
|
|
311
|
+
logger.log(`Loading OpenAPI spec from: ${projectPath}`);
|
|
312
|
+
const spec = loadOpenAPISpec(projectPath, specFileName);
|
|
313
|
+
const customDescriptions = domainDescriptionsFileName ? loadDomainDescriptions((0, node_path_1.join)(projectPath, domainDescriptionsFileName)) : null;
|
|
314
|
+
const domains = (0, update_sdk_context_helpers_1.extractDomains)(spec, customDescriptions);
|
|
315
|
+
const packageJson = loadPackageJson(projectPath);
|
|
316
|
+
const packageName = packageJson.name || (0, node_path_1.basename)(projectPath);
|
|
317
|
+
logger.log(`Found ${domains.size} domains with ${Array.from(domains.values()).reduce((sum, d) => sum + d.operations.length, 0)} operations`);
|
|
318
|
+
// Load existing context to preserve user edits
|
|
319
|
+
const existingContext = loadExistingContext(projectPath);
|
|
320
|
+
let disambiguation = existingContext.disambiguation;
|
|
321
|
+
if (isInteractive) {
|
|
322
|
+
disambiguation = await promptForDisambiguation(domains, disambiguation, !!customDescriptions, projectPath, logger);
|
|
323
|
+
}
|
|
324
|
+
// Generate the new domains section
|
|
325
|
+
const domainsSection = generateDomainsSection(domains);
|
|
326
|
+
// If preserveEdits is enabled and we have existing content with markers, preserve user edits; otherwise generate fresh file
|
|
327
|
+
const contextContent = (preserveEdits && existingContext.beforeDomains !== null && existingContext.afterDomains !== null)
|
|
328
|
+
? existingContext.beforeDomains
|
|
329
|
+
+ '<!-- DOMAINS-START -->\n'
|
|
330
|
+
+ '## Domains\n\n'
|
|
331
|
+
+ 'The following domains were extracted from the OpenAPI specification. Each domain represents a logical grouping of related API operations.\n\n'
|
|
332
|
+
+ domainsSection
|
|
333
|
+
+ '<!-- DOMAINS-END -->'
|
|
334
|
+
+ existingContext.afterDomains
|
|
335
|
+
: await generateContextFile(spec, domains, packageName, disambiguation);
|
|
336
|
+
const outputPath = (0, node_path_1.join)(projectPath, 'SDK_CONTEXT.md');
|
|
337
|
+
await node_fs_1.promises.writeFile(outputPath, contextContent, 'utf8');
|
|
338
|
+
logger.log(`
|
|
339
|
+
SDK context written to: ${outputPath}
|
|
340
|
+
--- Domain Summary ---
|
|
341
|
+
`);
|
|
342
|
+
domains.forEach((domain) => {
|
|
343
|
+
logger.log(`${domain.name}:`);
|
|
344
|
+
domain.operations.forEach((op) => {
|
|
345
|
+
logger.log(` - ${op.operationId}`);
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
// Handle prepare script addition if requested
|
|
349
|
+
if (prepareScript) {
|
|
350
|
+
const targetPackageJsonPath = (0, node_path_1.join)(projectPath, 'package.json');
|
|
351
|
+
await addPrepareContextScript(targetPackageJsonPath, logger);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
exports.generateSdkContext = generateSdkContext;
|
|
355
|
+
//# sourceMappingURL=update-sdk-context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-sdk-context.cjs","sourceRoot":"","sources":["../../../cli/genai-context/update-sdk-context.cts"],"names":[],"mappings":";;;AAAA,2DAE4B;AAC5B,qCAIiB;AACjB,yCAKmB;AACnB,iDAEuB;AACvB,+CAE8B;AAC9B,gDAEyB;AACzB,qCAEiB;AAIjB,6EAOsC;AACtC,+EAEuC;AAWvC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEhE;;;;;GAKG;AACH,SAAS,eAAe,CAAC,WAAmB,EAAE,YAAgC;IAC5E,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAgB,CAAC;IACrB,IAAI,YAAY,EAAE,CAAC;QACjB,QAAQ,GAAG,IAAA,mBAAO,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAA,oBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAEpD,IAAI,IAAA,oBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,QAAQ,GAAG,QAAQ,CAAC;YACpB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;aAAM,IAAI,IAAA,oBAAU,EAAC,QAAQ,CAAC,EAAE,CA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AC;8BACiB,UAAU;;GAErC,CAAC,CAAC;IACH,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9B,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC/B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,8CAA8C;IAC9C,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,qBAAqB,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAChE,MAAM,uBAAuB,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AA7DW,QAAA,kBAAkB,sBA6D7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Logger interface */
|
|
2
|
+
export type Logger = {
|
|
3
|
+
log: (message: string) => void;
|
|
4
|
+
error: (message: string) => void;
|
|
5
|
+
warn: (message: string) => void;
|
|
6
|
+
info: (message: string) => void;
|
|
7
|
+
debug: (message: string) => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Generate the SDK_CONTEXT.md file
|
|
11
|
+
* @param projectPath Path to the project root
|
|
12
|
+
* @param specFileName Name of the OpenAPI spec file
|
|
13
|
+
* @param domainDescriptionsFileName Name of the domain descriptions file
|
|
14
|
+
* @param isInteractive Whether to run in interactive mode
|
|
15
|
+
* @param prepareScript Whether to add a prepare:context script to package.json
|
|
16
|
+
* @param preserveEdits Whether to preserve user edits outside the Domains section on re-run
|
|
17
|
+
* @param logger Logger instance
|
|
18
|
+
*/
|
|
19
|
+
export declare const generateSdkContext: (projectPath: string, specFileName: string | undefined, domainDescriptionsFileName: string | undefined, isInteractive: boolean, prepareScript: boolean | undefined, preserveEdits: boolean, logger: Logger) => Promise<void>;
|
|
20
|
+
//# sourceMappingURL=update-sdk-context.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-sdk-context.d.cts","sourceRoot":"","sources":["../../../cli/genai-context/update-sdk-context.cts"],"names":[],"mappings":"AAyCA,uBAAuB;AACvB,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC,CAAC;AAuUF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,aAAa,MAAM,EACnB,cAAc,MAAM,GAAG,SAAS,EAChC,4BAA4B,MAAM,GAAG,SAAS,EAC9C,eAAe,OAAO,EACtB,eAAe,OAAO,GAAG,SAAS,EAClC,eAAe,OAAO,EACtB,QAAQ,MAAM,kBAsDf,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import type { PackageJson } from 'type-fest';
|
|
3
|
+
/** Supported OpenAPI document types */
|
|
4
|
+
export type OpenAPISpec = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
5
|
+
/**
|
|
6
|
+
* Represents the parsed sections of an existing SDK_CONTEXT.md file
|
|
7
|
+
*/
|
|
8
|
+
export interface ExistingContextSections {
|
|
9
|
+
/** Content before the DOMAINS-START marker (null if no existing file or no markers) */
|
|
10
|
+
beforeDomains: string | null;
|
|
11
|
+
/** Content after the DOMAINS-END marker (null if no existing file or no markers) */
|
|
12
|
+
afterDomains: string | null;
|
|
13
|
+
/** Disambiguation notes extracted from the file */
|
|
14
|
+
disambiguation: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse SDK_CONTEXT.md content to extract preserved sections
|
|
18
|
+
* @param content The content of the SDK_CONTEXT.md file (null if file doesn't exist)
|
|
19
|
+
* @returns Parsed sections or defaults if content is null
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseExistingContext(content: string | null): ExistingContextSections;
|
|
22
|
+
/**
|
|
23
|
+
* Result of updating package.json for prepare:context script
|
|
24
|
+
*/
|
|
25
|
+
export interface PrepareContextScriptResult {
|
|
26
|
+
/** Updated package.json object */
|
|
27
|
+
packageJson: PackageJson.PackageJsonStandard;
|
|
28
|
+
/** Whether the prepare:context script was added */
|
|
29
|
+
prepareContextAdded: boolean;
|
|
30
|
+
/** Whether the build script was updated */
|
|
31
|
+
buildScriptUpdated: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Updates a package.json object to add prepare:context script and update build script
|
|
35
|
+
* @param packageJson The package.json object to update
|
|
36
|
+
* @returns Result containing updated package.json and flags indicating what was changed
|
|
37
|
+
*/
|
|
38
|
+
export declare function updatePackageJsonForContextScript(packageJson: PackageJson): PrepareContextScriptResult;
|
|
39
|
+
/**
|
|
40
|
+
* Represents a domain extracted from an OpenAPI specification
|
|
41
|
+
* A domain groups related API operations together
|
|
42
|
+
*/
|
|
43
|
+
export interface Domain {
|
|
44
|
+
/** Domain name (typically from OpenAPI tag) */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Human-readable description of the domain */
|
|
47
|
+
description: string;
|
|
48
|
+
/** List of operations belonging to this domain */
|
|
49
|
+
operations: {
|
|
50
|
+
/** Unique operation identifier */
|
|
51
|
+
operationId: string;
|
|
52
|
+
/** HTTP method (GET, POST, etc.) */
|
|
53
|
+
method: string;
|
|
54
|
+
/** Short description of the operation */
|
|
55
|
+
summary: string;
|
|
56
|
+
/** API endpoint path */
|
|
57
|
+
path: string;
|
|
58
|
+
}[];
|
|
59
|
+
/** Set of model names referenced by operations in this domain */
|
|
60
|
+
models: Set<string>;
|
|
61
|
+
}
|
|
62
|
+
/** Standard HTTP methods supported in OpenAPI specifications */
|
|
63
|
+
export declare const HTTP_METHODS: ["get", "post", "put", "delete", "patch", "options", "head"];
|
|
64
|
+
/**
|
|
65
|
+
* Extracts the model name from an OpenAPI $ref string
|
|
66
|
+
* @param ref The $ref string to extract from
|
|
67
|
+
* @returns The model name or null if not found
|
|
68
|
+
*/
|
|
69
|
+
export declare function extractRefModel(ref?: string): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Extracts all referenced model names from an OpenAPI operation
|
|
72
|
+
* @param operation The OpenAPI operation to extract models from
|
|
73
|
+
* @returns Array of model names
|
|
74
|
+
*/
|
|
75
|
+
export declare function extractModelsFromOperation(operation: OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Infers a domain name from an API path
|
|
78
|
+
* @param apiPath The API path to infer from
|
|
79
|
+
* @returns The inferred domain name or 'default'
|
|
80
|
+
*/
|
|
81
|
+
export declare function inferDomainFromPath(apiPath: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Extracts domains from an OpenAPI specification
|
|
84
|
+
* @param spec The OpenAPI specification to extract from
|
|
85
|
+
* @param customDescriptions Optional custom descriptions for domains
|
|
86
|
+
* @returns Map of domain names to Domain objects
|
|
87
|
+
*/
|
|
88
|
+
export declare function extractDomains(spec: OpenAPISpec, customDescriptions?: Record<string, string> | null): Map<string, Domain>;
|
|
89
|
+
//# sourceMappingURL=update-sdk-context.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-sdk-context.helpers.d.ts","sourceRoot":"","sources":["../../../cli/genai-context/update-sdk-context.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,WAAW,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