@salesforce/b2c-tooling-sdk 0.0.8 → 0.2.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/dist/cjs/auth/index.d.ts +2 -0
- package/dist/cjs/auth/index.js +2 -0
- package/dist/cjs/auth/index.js.map +1 -1
- package/dist/cjs/auth/middleware.d.ts +196 -0
- package/dist/cjs/auth/middleware.js +190 -0
- package/dist/cjs/auth/middleware.js.map +1 -0
- package/dist/cjs/auth/oauth.js +21 -9
- package/dist/cjs/auth/oauth.js.map +1 -1
- package/dist/cjs/cli/base-command.d.ts +15 -0
- package/dist/cjs/cli/base-command.js +58 -2
- package/dist/cjs/cli/base-command.js.map +1 -1
- package/dist/cjs/cli/hooks.d.ts +98 -5
- package/dist/cjs/cli/hooks.js.map +1 -1
- package/dist/cjs/cli/instance-command.d.ts +1 -0
- package/dist/cjs/cli/mrt-command.d.ts +2 -1
- package/dist/cjs/cli/mrt-command.js +3 -2
- package/dist/cjs/cli/mrt-command.js.map +1 -1
- package/dist/cjs/cli/oauth-command.d.ts +1 -0
- package/dist/cjs/cli/oauth-command.js +6 -0
- package/dist/cjs/cli/oauth-command.js.map +1 -1
- package/dist/cjs/cli/ods-command.d.ts +1 -0
- package/dist/cjs/cli/webdav-command.d.ts +1 -0
- package/dist/cjs/clients/cdn-zones.d.ts +154 -0
- package/dist/cjs/clients/cdn-zones.generated.d.ts +8330 -0
- package/dist/cjs/clients/cdn-zones.generated.js +6 -0
- package/dist/cjs/clients/cdn-zones.generated.js.map +1 -0
- package/dist/cjs/clients/cdn-zones.js +100 -0
- package/dist/cjs/clients/cdn-zones.js.map +1 -0
- package/dist/cjs/clients/error-utils.d.ts +35 -0
- package/dist/cjs/clients/error-utils.js +69 -0
- package/dist/cjs/clients/error-utils.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +11 -2
- package/dist/cjs/clients/index.js +8 -1
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/middleware-registry.d.ts +1 -1
- package/dist/cjs/clients/middleware-registry.js.map +1 -1
- package/dist/cjs/clients/middleware.d.ts +25 -0
- package/dist/cjs/clients/middleware.js +16 -10
- package/dist/cjs/clients/middleware.js.map +1 -1
- package/dist/cjs/clients/mrt-b2c.d.ts +114 -0
- package/dist/cjs/clients/mrt-b2c.generated.d.ts +176 -0
- package/dist/cjs/clients/mrt-b2c.generated.js +6 -0
- package/dist/cjs/clients/mrt-b2c.generated.js.map +1 -0
- package/dist/cjs/clients/mrt-b2c.js +86 -0
- package/dist/cjs/clients/mrt-b2c.js.map +1 -0
- package/dist/cjs/clients/scapi-schemas.d.ts +132 -0
- package/dist/cjs/clients/scapi-schemas.generated.d.ts +328 -0
- package/dist/cjs/clients/scapi-schemas.generated.js +6 -0
- package/dist/cjs/clients/scapi-schemas.generated.js.map +1 -0
- package/dist/cjs/clients/scapi-schemas.js +95 -0
- package/dist/cjs/clients/scapi-schemas.js.map +1 -0
- package/dist/cjs/clients/user-agent.d.ts +43 -0
- package/dist/cjs/clients/user-agent.js +87 -0
- package/dist/cjs/clients/user-agent.js.map +1 -0
- package/dist/cjs/config/dw-json.d.ts +6 -0
- package/dist/cjs/config/dw-json.js.map +1 -1
- package/dist/cjs/config/mapping.js +3 -0
- package/dist/cjs/config/mapping.js.map +1 -1
- package/dist/cjs/config/resolver.d.ts +2 -1
- package/dist/cjs/config/resolver.js +14 -7
- package/dist/cjs/config/resolver.js.map +1 -1
- package/dist/cjs/config/sources/dw-json-source.d.ts +1 -0
- package/dist/cjs/config/sources/dw-json-source.js +1 -0
- package/dist/cjs/config/sources/dw-json-source.js.map +1 -1
- package/dist/cjs/config/sources/index.d.ts +1 -0
- package/dist/cjs/config/sources/index.js +1 -0
- package/dist/cjs/config/sources/index.js.map +1 -1
- package/dist/cjs/config/sources/mobify-source.d.ts +1 -0
- package/dist/cjs/config/sources/mobify-source.js +1 -0
- package/dist/cjs/config/sources/mobify-source.js.map +1 -1
- package/dist/cjs/config/sources/package-json-source.d.ts +14 -0
- package/dist/cjs/config/sources/package-json-source.js +86 -0
- package/dist/cjs/config/sources/package-json-source.js.map +1 -0
- package/dist/cjs/config/types.d.ts +14 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/operations/code/deploy.js +9 -3
- package/dist/cjs/operations/code/deploy.js.map +1 -1
- package/dist/cjs/operations/mrt/access-control.d.ts +192 -0
- package/dist/cjs/operations/mrt/access-control.js +152 -0
- package/dist/cjs/operations/mrt/access-control.js.map +1 -0
- package/dist/cjs/operations/mrt/b2c-config.d.ts +201 -0
- package/dist/cjs/operations/mrt/b2c-config.js +195 -0
- package/dist/cjs/operations/mrt/b2c-config.js.map +1 -0
- package/dist/cjs/operations/mrt/cache.d.ts +80 -0
- package/dist/cjs/operations/mrt/cache.js +65 -0
- package/dist/cjs/operations/mrt/cache.js.map +1 -0
- package/dist/cjs/operations/mrt/deployment.d.ts +157 -0
- package/dist/cjs/operations/mrt/deployment.js +109 -0
- package/dist/cjs/operations/mrt/deployment.js.map +1 -0
- package/dist/cjs/operations/mrt/env.d.ts +141 -0
- package/dist/cjs/operations/mrt/env.js +119 -0
- package/dist/cjs/operations/mrt/env.js.map +1 -1
- package/dist/cjs/operations/mrt/index.d.ts +24 -4
- package/dist/cjs/operations/mrt/index.js +23 -3
- package/dist/cjs/operations/mrt/index.js.map +1 -1
- package/dist/cjs/operations/mrt/member.d.ts +281 -0
- package/dist/cjs/operations/mrt/member.js +244 -0
- package/dist/cjs/operations/mrt/member.js.map +1 -0
- package/dist/cjs/operations/mrt/notification.d.ts +252 -0
- package/dist/cjs/operations/mrt/notification.js +206 -0
- package/dist/cjs/operations/mrt/notification.js.map +1 -0
- package/dist/cjs/operations/mrt/organization.d.ts +80 -0
- package/dist/cjs/operations/mrt/organization.js +53 -0
- package/dist/cjs/operations/mrt/organization.js.map +1 -0
- package/dist/cjs/operations/mrt/project.d.ts +261 -0
- package/dist/cjs/operations/mrt/project.js +232 -0
- package/dist/cjs/operations/mrt/project.js.map +1 -0
- package/dist/cjs/operations/mrt/push.d.ts +122 -8
- package/dist/cjs/operations/mrt/push.js +83 -10
- package/dist/cjs/operations/mrt/push.js.map +1 -1
- package/dist/cjs/operations/mrt/redirect.d.ts +337 -0
- package/dist/cjs/operations/mrt/redirect.js +256 -0
- package/dist/cjs/operations/mrt/redirect.js.map +1 -0
- package/dist/cjs/operations/mrt/user.d.ts +135 -0
- package/dist/cjs/operations/mrt/user.js +153 -0
- package/dist/cjs/operations/mrt/user.js.map +1 -0
- package/dist/cjs/operations/scapi-schemas/collapse.d.ts +150 -0
- package/dist/cjs/operations/scapi-schemas/collapse.js +180 -0
- package/dist/cjs/operations/scapi-schemas/collapse.js.map +1 -0
- package/dist/cjs/operations/scapi-schemas/index.d.ts +53 -0
- package/dist/cjs/operations/scapi-schemas/index.js +59 -0
- package/dist/cjs/operations/scapi-schemas/index.js.map +1 -0
- package/dist/cjs/skills/agents.d.ts +41 -0
- package/dist/cjs/skills/agents.js +159 -0
- package/dist/cjs/skills/agents.js.map +1 -0
- package/dist/cjs/skills/github.d.ts +47 -0
- package/dist/cjs/skills/github.js +246 -0
- package/dist/cjs/skills/github.js.map +1 -0
- package/dist/cjs/skills/index.d.ts +42 -0
- package/dist/cjs/skills/index.js +14 -0
- package/dist/cjs/skills/index.js.map +1 -0
- package/dist/cjs/skills/installer.d.ts +34 -0
- package/dist/cjs/skills/installer.js +181 -0
- package/dist/cjs/skills/installer.js.map +1 -0
- package/dist/cjs/skills/parser.d.ts +39 -0
- package/dist/cjs/skills/parser.js +131 -0
- package/dist/cjs/skills/parser.js.map +1 -0
- package/dist/cjs/skills/types.d.ts +134 -0
- package/dist/cjs/skills/types.js +7 -0
- package/dist/cjs/skills/types.js.map +1 -0
- package/dist/cjs/test-utils/config-isolation.d.ts +2 -0
- package/dist/cjs/test-utils/config-isolation.js +41 -0
- package/dist/cjs/test-utils/config-isolation.js.map +1 -0
- package/dist/cjs/test-utils/index.d.ts +1 -0
- package/dist/cjs/test-utils/index.js +7 -0
- package/dist/cjs/test-utils/index.js.map +1 -0
- package/dist/cjs/version.d.ts +14 -0
- package/dist/cjs/version.js +29 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/auth/index.d.ts +2 -0
- package/dist/esm/auth/index.js +2 -0
- package/dist/esm/auth/index.js.map +1 -1
- package/dist/esm/auth/middleware.d.ts +196 -0
- package/dist/esm/auth/middleware.js +190 -0
- package/dist/esm/auth/middleware.js.map +1 -0
- package/dist/esm/auth/oauth.js +21 -9
- package/dist/esm/auth/oauth.js.map +1 -1
- package/dist/esm/cli/base-command.d.ts +15 -0
- package/dist/esm/cli/base-command.js +58 -2
- package/dist/esm/cli/base-command.js.map +1 -1
- package/dist/esm/cli/hooks.d.ts +98 -5
- package/dist/esm/cli/hooks.js.map +1 -1
- package/dist/esm/cli/instance-command.d.ts +1 -0
- package/dist/esm/cli/mrt-command.d.ts +2 -1
- package/dist/esm/cli/mrt-command.js +3 -2
- package/dist/esm/cli/mrt-command.js.map +1 -1
- package/dist/esm/cli/oauth-command.d.ts +1 -0
- package/dist/esm/cli/oauth-command.js +6 -0
- package/dist/esm/cli/oauth-command.js.map +1 -1
- package/dist/esm/cli/ods-command.d.ts +1 -0
- package/dist/esm/cli/webdav-command.d.ts +1 -0
- package/dist/esm/clients/cdn-zones.d.ts +154 -0
- package/dist/esm/clients/cdn-zones.generated.d.ts +8330 -0
- package/dist/esm/clients/cdn-zones.generated.js +6 -0
- package/dist/esm/clients/cdn-zones.generated.js.map +1 -0
- package/dist/esm/clients/cdn-zones.js +100 -0
- package/dist/esm/clients/cdn-zones.js.map +1 -0
- package/dist/esm/clients/error-utils.d.ts +35 -0
- package/dist/esm/clients/error-utils.js +69 -0
- package/dist/esm/clients/error-utils.js.map +1 -0
- package/dist/esm/clients/index.d.ts +11 -2
- package/dist/esm/clients/index.js +8 -1
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/middleware-registry.d.ts +1 -1
- package/dist/esm/clients/middleware-registry.js.map +1 -1
- package/dist/esm/clients/middleware.d.ts +25 -0
- package/dist/esm/clients/middleware.js +16 -10
- package/dist/esm/clients/middleware.js.map +1 -1
- package/dist/esm/clients/mrt-b2c.d.ts +114 -0
- package/dist/esm/clients/mrt-b2c.generated.d.ts +176 -0
- package/dist/esm/clients/mrt-b2c.generated.js +6 -0
- package/dist/esm/clients/mrt-b2c.generated.js.map +1 -0
- package/dist/esm/clients/mrt-b2c.js +86 -0
- package/dist/esm/clients/mrt-b2c.js.map +1 -0
- package/dist/esm/clients/scapi-schemas.d.ts +132 -0
- package/dist/esm/clients/scapi-schemas.generated.d.ts +328 -0
- package/dist/esm/clients/scapi-schemas.generated.js +6 -0
- package/dist/esm/clients/scapi-schemas.generated.js.map +1 -0
- package/dist/esm/clients/scapi-schemas.js +95 -0
- package/dist/esm/clients/scapi-schemas.js.map +1 -0
- package/dist/esm/clients/user-agent.d.ts +43 -0
- package/dist/esm/clients/user-agent.js +87 -0
- package/dist/esm/clients/user-agent.js.map +1 -0
- package/dist/esm/config/dw-json.d.ts +6 -0
- package/dist/esm/config/dw-json.js.map +1 -1
- package/dist/esm/config/mapping.js +3 -0
- package/dist/esm/config/mapping.js.map +1 -1
- package/dist/esm/config/resolver.d.ts +2 -1
- package/dist/esm/config/resolver.js +14 -7
- package/dist/esm/config/resolver.js.map +1 -1
- package/dist/esm/config/sources/dw-json-source.d.ts +1 -0
- package/dist/esm/config/sources/dw-json-source.js +1 -0
- package/dist/esm/config/sources/dw-json-source.js.map +1 -1
- package/dist/esm/config/sources/index.d.ts +1 -0
- package/dist/esm/config/sources/index.js +1 -0
- package/dist/esm/config/sources/index.js.map +1 -1
- package/dist/esm/config/sources/mobify-source.d.ts +1 -0
- package/dist/esm/config/sources/mobify-source.js +1 -0
- package/dist/esm/config/sources/mobify-source.js.map +1 -1
- package/dist/esm/config/sources/package-json-source.d.ts +14 -0
- package/dist/esm/config/sources/package-json-source.js +86 -0
- package/dist/esm/config/sources/package-json-source.js.map +1 -0
- package/dist/esm/config/types.d.ts +14 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/operations/code/deploy.js +9 -3
- package/dist/esm/operations/code/deploy.js.map +1 -1
- package/dist/esm/operations/mrt/access-control.d.ts +192 -0
- package/dist/esm/operations/mrt/access-control.js +152 -0
- package/dist/esm/operations/mrt/access-control.js.map +1 -0
- package/dist/esm/operations/mrt/b2c-config.d.ts +201 -0
- package/dist/esm/operations/mrt/b2c-config.js +195 -0
- package/dist/esm/operations/mrt/b2c-config.js.map +1 -0
- package/dist/esm/operations/mrt/cache.d.ts +80 -0
- package/dist/esm/operations/mrt/cache.js +65 -0
- package/dist/esm/operations/mrt/cache.js.map +1 -0
- package/dist/esm/operations/mrt/deployment.d.ts +157 -0
- package/dist/esm/operations/mrt/deployment.js +109 -0
- package/dist/esm/operations/mrt/deployment.js.map +1 -0
- package/dist/esm/operations/mrt/env.d.ts +141 -0
- package/dist/esm/operations/mrt/env.js +119 -0
- package/dist/esm/operations/mrt/env.js.map +1 -1
- package/dist/esm/operations/mrt/index.d.ts +24 -4
- package/dist/esm/operations/mrt/index.js +23 -3
- package/dist/esm/operations/mrt/index.js.map +1 -1
- package/dist/esm/operations/mrt/member.d.ts +281 -0
- package/dist/esm/operations/mrt/member.js +244 -0
- package/dist/esm/operations/mrt/member.js.map +1 -0
- package/dist/esm/operations/mrt/notification.d.ts +252 -0
- package/dist/esm/operations/mrt/notification.js +206 -0
- package/dist/esm/operations/mrt/notification.js.map +1 -0
- package/dist/esm/operations/mrt/organization.d.ts +80 -0
- package/dist/esm/operations/mrt/organization.js +53 -0
- package/dist/esm/operations/mrt/organization.js.map +1 -0
- package/dist/esm/operations/mrt/project.d.ts +261 -0
- package/dist/esm/operations/mrt/project.js +232 -0
- package/dist/esm/operations/mrt/project.js.map +1 -0
- package/dist/esm/operations/mrt/push.d.ts +122 -8
- package/dist/esm/operations/mrt/push.js +83 -10
- package/dist/esm/operations/mrt/push.js.map +1 -1
- package/dist/esm/operations/mrt/redirect.d.ts +337 -0
- package/dist/esm/operations/mrt/redirect.js +256 -0
- package/dist/esm/operations/mrt/redirect.js.map +1 -0
- package/dist/esm/operations/mrt/user.d.ts +135 -0
- package/dist/esm/operations/mrt/user.js +153 -0
- package/dist/esm/operations/mrt/user.js.map +1 -0
- package/dist/esm/operations/scapi-schemas/collapse.d.ts +150 -0
- package/dist/esm/operations/scapi-schemas/collapse.js +180 -0
- package/dist/esm/operations/scapi-schemas/collapse.js.map +1 -0
- package/dist/esm/operations/scapi-schemas/index.d.ts +53 -0
- package/dist/esm/operations/scapi-schemas/index.js +59 -0
- package/dist/esm/operations/scapi-schemas/index.js.map +1 -0
- package/dist/esm/skills/agents.d.ts +41 -0
- package/dist/esm/skills/agents.js +159 -0
- package/dist/esm/skills/agents.js.map +1 -0
- package/dist/esm/skills/github.d.ts +47 -0
- package/dist/esm/skills/github.js +246 -0
- package/dist/esm/skills/github.js.map +1 -0
- package/dist/esm/skills/index.d.ts +42 -0
- package/dist/esm/skills/index.js +14 -0
- package/dist/esm/skills/index.js.map +1 -0
- package/dist/esm/skills/installer.d.ts +34 -0
- package/dist/esm/skills/installer.js +181 -0
- package/dist/esm/skills/installer.js.map +1 -0
- package/dist/esm/skills/parser.d.ts +39 -0
- package/dist/esm/skills/parser.js +131 -0
- package/dist/esm/skills/parser.js.map +1 -0
- package/dist/esm/skills/types.d.ts +134 -0
- package/dist/esm/skills/types.js +7 -0
- package/dist/esm/skills/types.js.map +1 -0
- package/dist/esm/test-utils/config-isolation.d.ts +2 -0
- package/dist/esm/test-utils/config-isolation.js +41 -0
- package/dist/esm/test-utils/config-isolation.js.map +1 -0
- package/dist/esm/test-utils/index.d.ts +1 -0
- package/dist/esm/test-utils/index.js +7 -0
- package/dist/esm/test-utils/index.js.map +1 -0
- package/dist/esm/version.d.ts +14 -0
- package/dist/esm/version.js +29 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +35 -2
- package/specs/cdn-zones-v1.yaml +9324 -0
- package/specs/mrt-b2c.json +384 -0
- package/specs/scapi-schemas-v1.yaml +341 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI schema collapsing utilities for agentic clients.
|
|
3
|
+
*
|
|
4
|
+
* These utilities implement a three-tier disclosure model for OpenAPI schemas:
|
|
5
|
+
* - **Collapsed** (default): Show structure only - paths as method names, schemas as keys
|
|
6
|
+
* - **Selective expansion**: Full details for specific items only
|
|
7
|
+
* - **Full expansion**: Complete schema without any collapsing
|
|
8
|
+
*
|
|
9
|
+
* This approach addresses context length concerns when working with large OpenAPI
|
|
10
|
+
* schemas in agentic/LLM contexts.
|
|
11
|
+
*
|
|
12
|
+
* @module operations/scapi-schemas/collapse
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Options for collapsing an OpenAPI schema.
|
|
16
|
+
*/
|
|
17
|
+
export interface SchemaCollapseOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Paths to fully expand (e.g., ["/products", "/orders"]).
|
|
20
|
+
* When provided, only these paths will have full operation details.
|
|
21
|
+
* Other paths will show only their HTTP method names.
|
|
22
|
+
*/
|
|
23
|
+
expandPaths?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Schema names to fully expand (e.g., ["Product", "Order"]).
|
|
26
|
+
* When provided, only these schemas will have full definitions.
|
|
27
|
+
* Other schemas will be shown as empty objects.
|
|
28
|
+
*/
|
|
29
|
+
expandSchemas?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Example names to fully expand (e.g., ["ProductExample"]).
|
|
32
|
+
* When provided, only these examples will have full content.
|
|
33
|
+
* Other examples will be shown as empty objects.
|
|
34
|
+
*/
|
|
35
|
+
expandExamples?: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents an OpenAPI 3.x schema structure.
|
|
39
|
+
* This is a simplified type that captures the structure we need for collapsing.
|
|
40
|
+
*/
|
|
41
|
+
export interface OpenApiSchemaInput {
|
|
42
|
+
openapi?: string;
|
|
43
|
+
info?: Record<string, unknown>;
|
|
44
|
+
servers?: unknown[];
|
|
45
|
+
paths?: Record<string, Record<string, unknown>>;
|
|
46
|
+
components?: {
|
|
47
|
+
schemas?: Record<string, unknown>;
|
|
48
|
+
examples?: Record<string, unknown>;
|
|
49
|
+
parameters?: Record<string, unknown>;
|
|
50
|
+
responses?: Record<string, unknown>;
|
|
51
|
+
requestBodies?: Record<string, unknown>;
|
|
52
|
+
headers?: Record<string, unknown>;
|
|
53
|
+
securitySchemes?: Record<string, unknown>;
|
|
54
|
+
links?: Record<string, unknown>;
|
|
55
|
+
callbacks?: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
security?: unknown[];
|
|
58
|
+
tags?: unknown[];
|
|
59
|
+
externalDocs?: unknown;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Represents a collapsed path entry.
|
|
64
|
+
* When collapsed, a path only shows the HTTP methods it supports.
|
|
65
|
+
*/
|
|
66
|
+
export type CollapsedPath = string[] | Record<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* The output schema structure after collapsing.
|
|
69
|
+
*/
|
|
70
|
+
export interface CollapsedOpenApiSchema {
|
|
71
|
+
openapi?: string;
|
|
72
|
+
info?: Record<string, unknown>;
|
|
73
|
+
servers?: unknown[];
|
|
74
|
+
paths?: Record<string, CollapsedPath>;
|
|
75
|
+
components?: {
|
|
76
|
+
schemas?: Record<string, unknown>;
|
|
77
|
+
examples?: Record<string, unknown>;
|
|
78
|
+
parameters?: Record<string, unknown>;
|
|
79
|
+
responses?: Record<string, unknown>;
|
|
80
|
+
requestBodies?: Record<string, unknown>;
|
|
81
|
+
headers?: Record<string, unknown>;
|
|
82
|
+
securitySchemes?: Record<string, unknown>;
|
|
83
|
+
links?: Record<string, unknown>;
|
|
84
|
+
callbacks?: Record<string, unknown>;
|
|
85
|
+
};
|
|
86
|
+
security?: unknown[];
|
|
87
|
+
tags?: unknown[];
|
|
88
|
+
externalDocs?: unknown;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Collapses an OpenAPI schema for context-efficient representation.
|
|
93
|
+
*
|
|
94
|
+
* This function implements a three-tier disclosure model:
|
|
95
|
+
*
|
|
96
|
+
* 1. **No options provided (default):**
|
|
97
|
+
* - Paths: `{"/products": ["get", "post"]}` (method names only)
|
|
98
|
+
* - Schemas: `{"Product": {}}` (keys only)
|
|
99
|
+
* - Examples: `{"ProductExample": {}}` (keys only)
|
|
100
|
+
*
|
|
101
|
+
* 2. **Selective expansion:**
|
|
102
|
+
* - Only specified paths/schemas/examples are fully expanded
|
|
103
|
+
* - Everything else remains collapsed
|
|
104
|
+
*
|
|
105
|
+
* Non-collapsible sections (info, servers, security, tags, etc.) are preserved as-is.
|
|
106
|
+
*
|
|
107
|
+
* @param schema - The OpenAPI schema to collapse
|
|
108
|
+
* @param options - Options controlling what to expand
|
|
109
|
+
* @returns The collapsed schema
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Collapse everything (default behavior)
|
|
113
|
+
* const collapsed = collapseOpenApiSchema(fullSchema);
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // Expand only /products path and Product schema
|
|
117
|
+
* const collapsed = collapseOpenApiSchema(fullSchema, {
|
|
118
|
+
* expandPaths: ['/products'],
|
|
119
|
+
* expandSchemas: ['Product']
|
|
120
|
+
* });
|
|
121
|
+
*/
|
|
122
|
+
export declare function collapseOpenApiSchema(schema: OpenApiSchemaInput, options?: SchemaCollapseOptions): CollapsedOpenApiSchema;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if a schema has been collapsed (i.e., is in outline form).
|
|
125
|
+
*
|
|
126
|
+
* @param schema - The schema to check
|
|
127
|
+
* @returns true if paths are collapsed (arrays) or schemas are empty objects
|
|
128
|
+
*/
|
|
129
|
+
export declare function isCollapsedSchema(schema: CollapsedOpenApiSchema): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Gets the list of available path keys from a schema.
|
|
132
|
+
*
|
|
133
|
+
* @param schema - The OpenAPI schema
|
|
134
|
+
* @returns Array of path keys (e.g., ["/products", "/orders"])
|
|
135
|
+
*/
|
|
136
|
+
export declare function getPathKeys(schema: OpenApiSchemaInput | CollapsedOpenApiSchema): string[];
|
|
137
|
+
/**
|
|
138
|
+
* Gets the list of available schema names from a schema.
|
|
139
|
+
*
|
|
140
|
+
* @param schema - The OpenAPI schema
|
|
141
|
+
* @returns Array of schema names (e.g., ["Product", "Order"])
|
|
142
|
+
*/
|
|
143
|
+
export declare function getSchemaNames(schema: OpenApiSchemaInput | CollapsedOpenApiSchema): string[];
|
|
144
|
+
/**
|
|
145
|
+
* Gets the list of available example names from a schema.
|
|
146
|
+
*
|
|
147
|
+
* @param schema - The OpenAPI schema
|
|
148
|
+
* @returns Array of example names
|
|
149
|
+
*/
|
|
150
|
+
export declare function getExampleNames(schema: OpenApiSchemaInput | CollapsedOpenApiSchema): string[];
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** HTTP methods that can appear in OpenAPI paths */
|
|
7
|
+
const HTTP_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'];
|
|
8
|
+
/**
|
|
9
|
+
* Collapses an OpenAPI schema for context-efficient representation.
|
|
10
|
+
*
|
|
11
|
+
* This function implements a three-tier disclosure model:
|
|
12
|
+
*
|
|
13
|
+
* 1. **No options provided (default):**
|
|
14
|
+
* - Paths: `{"/products": ["get", "post"]}` (method names only)
|
|
15
|
+
* - Schemas: `{"Product": {}}` (keys only)
|
|
16
|
+
* - Examples: `{"ProductExample": {}}` (keys only)
|
|
17
|
+
*
|
|
18
|
+
* 2. **Selective expansion:**
|
|
19
|
+
* - Only specified paths/schemas/examples are fully expanded
|
|
20
|
+
* - Everything else remains collapsed
|
|
21
|
+
*
|
|
22
|
+
* Non-collapsible sections (info, servers, security, tags, etc.) are preserved as-is.
|
|
23
|
+
*
|
|
24
|
+
* @param schema - The OpenAPI schema to collapse
|
|
25
|
+
* @param options - Options controlling what to expand
|
|
26
|
+
* @returns The collapsed schema
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Collapse everything (default behavior)
|
|
30
|
+
* const collapsed = collapseOpenApiSchema(fullSchema);
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Expand only /products path and Product schema
|
|
34
|
+
* const collapsed = collapseOpenApiSchema(fullSchema, {
|
|
35
|
+
* expandPaths: ['/products'],
|
|
36
|
+
* expandSchemas: ['Product']
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
export function collapseOpenApiSchema(schema, options = {}) {
|
|
40
|
+
const { expandPaths = [], expandSchemas = [], expandExamples = [] } = options;
|
|
41
|
+
// Start with a shallow copy
|
|
42
|
+
const result = { ...schema };
|
|
43
|
+
// Collapse paths
|
|
44
|
+
if (schema.paths) {
|
|
45
|
+
result.paths = collapsePaths(schema.paths, expandPaths);
|
|
46
|
+
}
|
|
47
|
+
// Collapse components
|
|
48
|
+
if (schema.components) {
|
|
49
|
+
result.components = {
|
|
50
|
+
...schema.components,
|
|
51
|
+
};
|
|
52
|
+
if (schema.components.schemas) {
|
|
53
|
+
result.components.schemas = collapseSchemas(schema.components.schemas, expandSchemas);
|
|
54
|
+
}
|
|
55
|
+
if (schema.components.examples) {
|
|
56
|
+
result.components.examples = collapseExamples(schema.components.examples, expandExamples);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Collapses path items to show only HTTP method names.
|
|
63
|
+
*
|
|
64
|
+
* @param paths - The paths object from an OpenAPI schema
|
|
65
|
+
* @param expandPaths - Paths to keep fully expanded
|
|
66
|
+
* @returns Collapsed paths object
|
|
67
|
+
*/
|
|
68
|
+
function collapsePaths(paths, expandPaths) {
|
|
69
|
+
const result = {};
|
|
70
|
+
const expandSet = new Set(expandPaths);
|
|
71
|
+
for (const [pathKey, pathItem] of Object.entries(paths)) {
|
|
72
|
+
if (expandSet.has(pathKey)) {
|
|
73
|
+
// Keep full path item for expanded paths
|
|
74
|
+
result[pathKey] = pathItem;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Collapse to method names only
|
|
78
|
+
const methods = Object.keys(pathItem).filter((key) => HTTP_METHODS.includes(key));
|
|
79
|
+
result[pathKey] = methods;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Collapses schemas to show only keys with empty objects.
|
|
86
|
+
*
|
|
87
|
+
* @param schemas - The schemas object from components
|
|
88
|
+
* @param expandSchemas - Schema names to keep fully expanded
|
|
89
|
+
* @returns Collapsed schemas object
|
|
90
|
+
*/
|
|
91
|
+
function collapseSchemas(schemas, expandSchemas) {
|
|
92
|
+
const result = {};
|
|
93
|
+
const expandSet = new Set(expandSchemas);
|
|
94
|
+
for (const [schemaName, schemaValue] of Object.entries(schemas)) {
|
|
95
|
+
if (expandSet.has(schemaName)) {
|
|
96
|
+
// Keep full schema for expanded schemas
|
|
97
|
+
result[schemaName] = schemaValue;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Collapse to empty object
|
|
101
|
+
result[schemaName] = {};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Collapses examples to show only keys with empty objects.
|
|
108
|
+
*
|
|
109
|
+
* @param examples - The examples object from components
|
|
110
|
+
* @param expandExamples - Example names to keep fully expanded
|
|
111
|
+
* @returns Collapsed examples object
|
|
112
|
+
*/
|
|
113
|
+
function collapseExamples(examples, expandExamples) {
|
|
114
|
+
const result = {};
|
|
115
|
+
const expandSet = new Set(expandExamples);
|
|
116
|
+
for (const [exampleName, exampleValue] of Object.entries(examples)) {
|
|
117
|
+
if (expandSet.has(exampleName)) {
|
|
118
|
+
// Keep full example for expanded examples
|
|
119
|
+
result[exampleName] = exampleValue;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// Collapse to empty object
|
|
123
|
+
result[exampleName] = {};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks if a schema has been collapsed (i.e., is in outline form).
|
|
130
|
+
*
|
|
131
|
+
* @param schema - The schema to check
|
|
132
|
+
* @returns true if paths are collapsed (arrays) or schemas are empty objects
|
|
133
|
+
*/
|
|
134
|
+
export function isCollapsedSchema(schema) {
|
|
135
|
+
// Check if any path is collapsed (array of methods instead of full path item)
|
|
136
|
+
if (schema.paths) {
|
|
137
|
+
for (const pathItem of Object.values(schema.paths)) {
|
|
138
|
+
if (Array.isArray(pathItem)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Check if any schema is collapsed (empty object)
|
|
144
|
+
if (schema.components?.schemas) {
|
|
145
|
+
for (const schemaValue of Object.values(schema.components.schemas)) {
|
|
146
|
+
if (typeof schemaValue === 'object' && schemaValue !== null && Object.keys(schemaValue).length === 0) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Gets the list of available path keys from a schema.
|
|
155
|
+
*
|
|
156
|
+
* @param schema - The OpenAPI schema
|
|
157
|
+
* @returns Array of path keys (e.g., ["/products", "/orders"])
|
|
158
|
+
*/
|
|
159
|
+
export function getPathKeys(schema) {
|
|
160
|
+
return schema.paths ? Object.keys(schema.paths) : [];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Gets the list of available schema names from a schema.
|
|
164
|
+
*
|
|
165
|
+
* @param schema - The OpenAPI schema
|
|
166
|
+
* @returns Array of schema names (e.g., ["Product", "Order"])
|
|
167
|
+
*/
|
|
168
|
+
export function getSchemaNames(schema) {
|
|
169
|
+
return schema.components?.schemas ? Object.keys(schema.components.schemas) : [];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Gets the list of available example names from a schema.
|
|
173
|
+
*
|
|
174
|
+
* @param schema - The OpenAPI schema
|
|
175
|
+
* @returns Array of example names
|
|
176
|
+
*/
|
|
177
|
+
export function getExampleNames(schema) {
|
|
178
|
+
return schema.components?.examples ? Object.keys(schema.components.examples) : [];
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=collapse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapse.js","sourceRoot":"","sources":["../../../../src/operations/scapi-schemas/collapse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmGH,oDAAoD;AACpD,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AAEpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA0B,EAC1B,UAAiC,EAAE;IAEnC,MAAM,EAAC,WAAW,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,cAAc,GAAG,EAAE,EAAC,GAAG,OAAO,CAAC;IAE5E,4BAA4B;IAC5B,MAAM,MAAM,GAA2B,EAAC,GAAG,MAAM,EAAC,CAAC;IAEnD,iBAAiB;IACjB,IAAI,MAAM,CAAC,KAAK,EAAE,C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CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCAPI Schemas operations for B2C Commerce.
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for working with SCAPI OpenAPI schemas, including
|
|
5
|
+
* collapsing large schemas for context-efficient representation in
|
|
6
|
+
* agentic/LLM scenarios.
|
|
7
|
+
*
|
|
8
|
+
* ## Schema Collapsing
|
|
9
|
+
*
|
|
10
|
+
* Use {@link collapseOpenApiSchema} to reduce the size of large OpenAPI schemas
|
|
11
|
+
* while preserving structure for discovery:
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { collapseOpenApiSchema } from '@salesforce/b2c-tooling-sdk/operations/scapi-schemas';
|
|
15
|
+
*
|
|
16
|
+
* // Collapse to outline form (default)
|
|
17
|
+
* const collapsed = collapseOpenApiSchema(fullSchema);
|
|
18
|
+
* // Result: paths show only ["get", "post"], schemas show only {}
|
|
19
|
+
*
|
|
20
|
+
* // Selectively expand specific items
|
|
21
|
+
* const collapsed = collapseOpenApiSchema(fullSchema, {
|
|
22
|
+
* expandPaths: ['/products/search'],
|
|
23
|
+
* expandSchemas: ['Product', 'SearchResult']
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ## Utility Functions
|
|
28
|
+
*
|
|
29
|
+
* Helper functions for inspecting schemas:
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import {
|
|
33
|
+
* getPathKeys,
|
|
34
|
+
* getSchemaNames,
|
|
35
|
+
* isCollapsedSchema
|
|
36
|
+
* } from '@salesforce/b2c-tooling-sdk/operations/scapi-schemas';
|
|
37
|
+
*
|
|
38
|
+
* // Get available paths
|
|
39
|
+
* const paths = getPathKeys(schema); // ["/products", "/orders", ...]
|
|
40
|
+
*
|
|
41
|
+
* // Get available schemas
|
|
42
|
+
* const schemas = getSchemaNames(schema); // ["Product", "Order", ...]
|
|
43
|
+
*
|
|
44
|
+
* // Check if schema is collapsed
|
|
45
|
+
* if (isCollapsedSchema(schema)) {
|
|
46
|
+
* console.log('Schema is in collapsed form');
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @module operations/scapi-schemas
|
|
51
|
+
*/
|
|
52
|
+
export { collapseOpenApiSchema, isCollapsedSchema, getPathKeys, getSchemaNames, getExampleNames } from './collapse.js';
|
|
53
|
+
export type { SchemaCollapseOptions, OpenApiSchemaInput, CollapsedOpenApiSchema, CollapsedPath } from './collapse.js';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* SCAPI Schemas operations for B2C Commerce.
|
|
8
|
+
*
|
|
9
|
+
* Provides utilities for working with SCAPI OpenAPI schemas, including
|
|
10
|
+
* collapsing large schemas for context-efficient representation in
|
|
11
|
+
* agentic/LLM scenarios.
|
|
12
|
+
*
|
|
13
|
+
* ## Schema Collapsing
|
|
14
|
+
*
|
|
15
|
+
* Use {@link collapseOpenApiSchema} to reduce the size of large OpenAPI schemas
|
|
16
|
+
* while preserving structure for discovery:
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { collapseOpenApiSchema } from '@salesforce/b2c-tooling-sdk/operations/scapi-schemas';
|
|
20
|
+
*
|
|
21
|
+
* // Collapse to outline form (default)
|
|
22
|
+
* const collapsed = collapseOpenApiSchema(fullSchema);
|
|
23
|
+
* // Result: paths show only ["get", "post"], schemas show only {}
|
|
24
|
+
*
|
|
25
|
+
* // Selectively expand specific items
|
|
26
|
+
* const collapsed = collapseOpenApiSchema(fullSchema, {
|
|
27
|
+
* expandPaths: ['/products/search'],
|
|
28
|
+
* expandSchemas: ['Product', 'SearchResult']
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Utility Functions
|
|
33
|
+
*
|
|
34
|
+
* Helper functions for inspecting schemas:
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import {
|
|
38
|
+
* getPathKeys,
|
|
39
|
+
* getSchemaNames,
|
|
40
|
+
* isCollapsedSchema
|
|
41
|
+
* } from '@salesforce/b2c-tooling-sdk/operations/scapi-schemas';
|
|
42
|
+
*
|
|
43
|
+
* // Get available paths
|
|
44
|
+
* const paths = getPathKeys(schema); // ["/products", "/orders", ...]
|
|
45
|
+
*
|
|
46
|
+
* // Get available schemas
|
|
47
|
+
* const schemas = getSchemaNames(schema); // ["Product", "Order", ...]
|
|
48
|
+
*
|
|
49
|
+
* // Check if schema is collapsed
|
|
50
|
+
* if (isCollapsedSchema(schema)) {
|
|
51
|
+
* console.log('Schema is in collapsed form');
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @module operations/scapi-schemas
|
|
56
|
+
*/
|
|
57
|
+
// Collapse utilities
|
|
58
|
+
export { collapseOpenApiSchema, isCollapsedSchema, getPathKeys, getSchemaNames, getExampleNames } from './collapse.js';
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/operations/scapi-schemas/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,qBAAqB;AACrB,OAAO,EAAC,qBAAqB,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IdeConfig, IdeType } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* IDE configurations with paths and detection logic.
|
|
4
|
+
*/
|
|
5
|
+
export declare const IDE_CONFIGS: Record<IdeType, IdeConfig>;
|
|
6
|
+
/**
|
|
7
|
+
* All supported IDE types in display order.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ALL_IDE_TYPES: IdeType[];
|
|
10
|
+
/**
|
|
11
|
+
* Detect which IDEs are installed on the system.
|
|
12
|
+
*
|
|
13
|
+
* @returns Array of IDE types that appear to be installed
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectInstalledIdes(): Promise<IdeType[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Get the installation path for a skill.
|
|
18
|
+
*
|
|
19
|
+
* @param ide - Target IDE
|
|
20
|
+
* @param skillName - Name of the skill
|
|
21
|
+
* @param options - Installation options
|
|
22
|
+
* @returns Absolute path where the skill would be installed
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSkillInstallPath(ide: IdeType, skillName: string, options: {
|
|
25
|
+
global: boolean;
|
|
26
|
+
projectRoot?: string;
|
|
27
|
+
}): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get the display name for an IDE.
|
|
30
|
+
*
|
|
31
|
+
* @param ide - IDE type
|
|
32
|
+
* @returns Human-readable display name
|
|
33
|
+
*/
|
|
34
|
+
export declare function getIdeDisplayName(ide: IdeType): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get the documentation URL for an IDE.
|
|
37
|
+
*
|
|
38
|
+
* @param ide - IDE type
|
|
39
|
+
* @returns Documentation URL or undefined if not available
|
|
40
|
+
*/
|
|
41
|
+
export declare function getIdeDocsUrl(ide: IdeType): string | undefined;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2
|
|
4
|
+
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from 'node:fs';
|
|
7
|
+
import * as os from 'node:os';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
const home = os.homedir();
|
|
10
|
+
/**
|
|
11
|
+
* IDE configurations with paths and detection logic.
|
|
12
|
+
*/
|
|
13
|
+
export const IDE_CONFIGS = {
|
|
14
|
+
'claude-code': {
|
|
15
|
+
id: 'claude-code',
|
|
16
|
+
displayName: 'Claude Code',
|
|
17
|
+
paths: {
|
|
18
|
+
projectDir: '.claude/skills',
|
|
19
|
+
globalDir: path.join(home, '.claude/skills'),
|
|
20
|
+
},
|
|
21
|
+
detectInstalled: async () => {
|
|
22
|
+
return fs.existsSync(path.join(home, '.claude'));
|
|
23
|
+
},
|
|
24
|
+
docsUrl: 'https://docs.anthropic.com/en/docs/claude-code',
|
|
25
|
+
},
|
|
26
|
+
cursor: {
|
|
27
|
+
id: 'cursor',
|
|
28
|
+
displayName: 'Cursor',
|
|
29
|
+
paths: {
|
|
30
|
+
projectDir: '.cursor/skills',
|
|
31
|
+
globalDir: path.join(home, '.cursor/skills'),
|
|
32
|
+
},
|
|
33
|
+
detectInstalled: async () => {
|
|
34
|
+
return fs.existsSync(path.join(home, '.cursor'));
|
|
35
|
+
},
|
|
36
|
+
docsUrl: 'https://cursor.com/docs/context/skills',
|
|
37
|
+
},
|
|
38
|
+
windsurf: {
|
|
39
|
+
id: 'windsurf',
|
|
40
|
+
displayName: 'Windsurf',
|
|
41
|
+
paths: {
|
|
42
|
+
projectDir: '.windsurf/skills',
|
|
43
|
+
globalDir: path.join(home, '.codeium/windsurf/skills'),
|
|
44
|
+
},
|
|
45
|
+
detectInstalled: async () => {
|
|
46
|
+
return fs.existsSync(path.join(home, '.codeium/windsurf'));
|
|
47
|
+
},
|
|
48
|
+
docsUrl: 'https://docs.windsurf.com/',
|
|
49
|
+
},
|
|
50
|
+
vscode: {
|
|
51
|
+
id: 'vscode',
|
|
52
|
+
displayName: 'VS Code / GitHub Copilot',
|
|
53
|
+
paths: {
|
|
54
|
+
projectDir: '.github/skills',
|
|
55
|
+
globalDir: path.join(home, '.copilot/skills'),
|
|
56
|
+
},
|
|
57
|
+
detectInstalled: async () => {
|
|
58
|
+
// Check for either .github directory (project-based) or ~/.copilot
|
|
59
|
+
return fs.existsSync(path.join(home, '.copilot'));
|
|
60
|
+
},
|
|
61
|
+
docsUrl: 'https://code.visualstudio.com/docs/copilot/customization/agent-skills',
|
|
62
|
+
},
|
|
63
|
+
codex: {
|
|
64
|
+
id: 'codex',
|
|
65
|
+
displayName: 'OpenAI Codex CLI',
|
|
66
|
+
paths: {
|
|
67
|
+
projectDir: '.codex/skills',
|
|
68
|
+
globalDir: path.join(home, '.codex/skills'),
|
|
69
|
+
},
|
|
70
|
+
detectInstalled: async () => {
|
|
71
|
+
return fs.existsSync(path.join(home, '.codex'));
|
|
72
|
+
},
|
|
73
|
+
docsUrl: 'https://github.com/openai/codex',
|
|
74
|
+
},
|
|
75
|
+
opencode: {
|
|
76
|
+
id: 'opencode',
|
|
77
|
+
displayName: 'OpenCode',
|
|
78
|
+
paths: {
|
|
79
|
+
projectDir: '.opencode/skills',
|
|
80
|
+
globalDir: path.join(home, '.config/opencode/skills'),
|
|
81
|
+
},
|
|
82
|
+
detectInstalled: async () => {
|
|
83
|
+
return fs.existsSync(path.join(home, '.config/opencode'));
|
|
84
|
+
},
|
|
85
|
+
docsUrl: 'https://opencode.ai/',
|
|
86
|
+
},
|
|
87
|
+
manual: {
|
|
88
|
+
id: 'manual',
|
|
89
|
+
displayName: 'Manual Installation',
|
|
90
|
+
paths: {
|
|
91
|
+
// Manual mode uses same paths as Claude Code
|
|
92
|
+
projectDir: '.claude/skills',
|
|
93
|
+
globalDir: path.join(home, '.claude/skills'),
|
|
94
|
+
},
|
|
95
|
+
detectInstalled: async () => {
|
|
96
|
+
// Manual is always "available" as a fallback
|
|
97
|
+
return true;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* All supported IDE types in display order.
|
|
103
|
+
*/
|
|
104
|
+
export const ALL_IDE_TYPES = ['claude-code', 'cursor', 'windsurf', 'vscode', 'codex', 'opencode', 'manual'];
|
|
105
|
+
/**
|
|
106
|
+
* Detect which IDEs are installed on the system.
|
|
107
|
+
*
|
|
108
|
+
* @returns Array of IDE types that appear to be installed
|
|
109
|
+
*/
|
|
110
|
+
export async function detectInstalledIdes() {
|
|
111
|
+
const installed = [];
|
|
112
|
+
for (const ideType of ALL_IDE_TYPES) {
|
|
113
|
+
// Skip 'manual' from auto-detection since it's always available
|
|
114
|
+
if (ideType === 'manual') {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const config = IDE_CONFIGS[ideType];
|
|
118
|
+
const isInstalled = await config.detectInstalled();
|
|
119
|
+
if (isInstalled) {
|
|
120
|
+
installed.push(ideType);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return installed;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get the installation path for a skill.
|
|
127
|
+
*
|
|
128
|
+
* @param ide - Target IDE
|
|
129
|
+
* @param skillName - Name of the skill
|
|
130
|
+
* @param options - Installation options
|
|
131
|
+
* @returns Absolute path where the skill would be installed
|
|
132
|
+
*/
|
|
133
|
+
export function getSkillInstallPath(ide, skillName, options) {
|
|
134
|
+
const config = IDE_CONFIGS[ide];
|
|
135
|
+
if (options.global) {
|
|
136
|
+
return path.join(config.paths.globalDir, skillName);
|
|
137
|
+
}
|
|
138
|
+
const projectRoot = options.projectRoot || process.cwd();
|
|
139
|
+
return path.join(projectRoot, config.paths.projectDir, skillName);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the display name for an IDE.
|
|
143
|
+
*
|
|
144
|
+
* @param ide - IDE type
|
|
145
|
+
* @returns Human-readable display name
|
|
146
|
+
*/
|
|
147
|
+
export function getIdeDisplayName(ide) {
|
|
148
|
+
return IDE_CONFIGS[ide].displayName;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get the documentation URL for an IDE.
|
|
152
|
+
*
|
|
153
|
+
* @param ide - IDE type
|
|
154
|
+
* @returns Documentation URL or undefined if not available
|
|
155
|
+
*/
|
|
156
|
+
export function getIdeDocsUrl(ide) {
|
|
157
|
+
return IDE_CONFIGS[ide].docsUrl;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/skills/agents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA+B;IACrD,aAAa,EAAE;QACb,EAAE,EAAE,aAAa;QACjB,WAAW,EAAE,aAAa;QAC1B,KAAK,EAAE;YACL,UAAU,EAAE,gBAAgB;YAC5B,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;SAC7C;QACD,eAAe,EAAE,KAAK,IAAI,EAAE;YAC1B,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,EAAE,gDAAgD;KAC1D;IACD,MAAM,EAAE;QACN,EAAE,EAAE,QAAQ;QACZ,WAAW,EAAE,QAAQ;QACrB,KAAK,EAAE;YACL,UAAU,EAAE,gBAAgB;YAC5B,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC;SAC7C;QACD,eAAe,EAAE,KAAK,IAAI,EAAE;YAC1B,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EA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