@lightdash-tools/cli 0.7.0 → 0.8.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 +2 -2
- package/dist/commands/schema.d.ts +1 -2
- package/dist/commands/schema.js +9 -105
- package/dist/commands/schema.test.js +35 -27
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/commands/schema.test.ts +37 -29
- package/src/commands/schema.ts +13 -116
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -168,8 +168,8 @@ lightdash-ai ai-agents threads --page 1 --page-size 10
|
|
|
168
168
|
lightdash-ai schema list
|
|
169
169
|
|
|
170
170
|
# Get schema for a resource (path, method, params)
|
|
171
|
-
lightdash-ai schema get charts.list
|
|
172
|
-
lightdash-ai schema get ai-agents.settings.update
|
|
171
|
+
lightdash-ai schema get cli.charts.list
|
|
172
|
+
lightdash-ai schema get ai-agents.admin.settings.update
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
### Global Options
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Outputs machine-readable JSON describing API paths, methods, and parameters.
|
|
2
|
+
* Shared CLI schema command — catalog-only introspection (ADR-0013).
|
|
4
3
|
*/
|
|
5
4
|
import type { Command } from 'commander';
|
|
6
5
|
export declare function getSchema(resource: string): Record<string, unknown> | null;
|
package/dist/commands/schema.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Outputs machine-readable JSON describing API paths, methods, and parameters.
|
|
3
|
+
* Shared CLI schema command — catalog-only introspection (ADR-0013).
|
|
5
4
|
*/
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.getSchema = getSchema;
|
|
@@ -9,87 +8,6 @@ exports.listResources = listResources;
|
|
|
9
8
|
exports.registerSchemaCommand = registerSchemaCommand;
|
|
10
9
|
const common_1 = require("@lightdash-tools/common");
|
|
11
10
|
const safety_1 = require("../utils/safety");
|
|
12
|
-
/** Maps legacy resource identifiers to API path + method + description. */
|
|
13
|
-
const LEGACY_SCHEMA_REGISTRY = {
|
|
14
|
-
'organization.get': {
|
|
15
|
-
path: '/api/v1/org',
|
|
16
|
-
method: 'GET',
|
|
17
|
-
description: 'Get current organization details',
|
|
18
|
-
},
|
|
19
|
-
'projects.list': {
|
|
20
|
-
path: '/api/v1/org/projects',
|
|
21
|
-
method: 'GET',
|
|
22
|
-
description: 'List all projects in the organization',
|
|
23
|
-
},
|
|
24
|
-
'projects.get': {
|
|
25
|
-
path: '/api/v1/projects/{projectUuid}',
|
|
26
|
-
method: 'GET',
|
|
27
|
-
description: 'Get project by UUID',
|
|
28
|
-
params: ['projectUuid'],
|
|
29
|
-
},
|
|
30
|
-
'charts.list': {
|
|
31
|
-
path: '/api/v1/projects/{projectUuid}/charts',
|
|
32
|
-
method: 'GET',
|
|
33
|
-
description: 'List charts in a project',
|
|
34
|
-
params: ['projectUuid'],
|
|
35
|
-
},
|
|
36
|
-
'charts.code.list': {
|
|
37
|
-
path: '/api/v1/projects/{projectUuid}/code/charts',
|
|
38
|
-
method: 'GET',
|
|
39
|
-
description: 'Get charts in code representation',
|
|
40
|
-
params: ['projectUuid'],
|
|
41
|
-
},
|
|
42
|
-
'charts.code.upsert': {
|
|
43
|
-
path: '/api/v1/projects/{projectUuid}/code/charts/{slug}',
|
|
44
|
-
method: 'POST',
|
|
45
|
-
description: 'Create or update chart by slug',
|
|
46
|
-
params: ['projectUuid', 'slug'],
|
|
47
|
-
},
|
|
48
|
-
'dashboards.list': {
|
|
49
|
-
path: '/api/v1/projects/{projectUuid}/dashboards',
|
|
50
|
-
method: 'GET',
|
|
51
|
-
description: 'List dashboards in a project',
|
|
52
|
-
params: ['projectUuid'],
|
|
53
|
-
},
|
|
54
|
-
'spaces.list': {
|
|
55
|
-
path: '/api/v1/projects/{projectUuid}/spaces',
|
|
56
|
-
method: 'GET',
|
|
57
|
-
description: 'List spaces in a project',
|
|
58
|
-
params: ['projectUuid'],
|
|
59
|
-
},
|
|
60
|
-
'ai-agents.list': {
|
|
61
|
-
path: '/api/v1/aiAgents/admin/agents',
|
|
62
|
-
method: 'GET',
|
|
63
|
-
description: 'List AI agents (admin)',
|
|
64
|
-
},
|
|
65
|
-
'ai-agents.threads': {
|
|
66
|
-
path: '/api/v1/aiAgents/admin/threads',
|
|
67
|
-
method: 'GET',
|
|
68
|
-
description: 'List AI agent threads (admin)',
|
|
69
|
-
},
|
|
70
|
-
'ai-agents.settings.get': {
|
|
71
|
-
path: '/api/v1/aiAgents/admin/settings',
|
|
72
|
-
method: 'GET',
|
|
73
|
-
description: 'Get AI organization settings',
|
|
74
|
-
},
|
|
75
|
-
'ai-agents.settings.update': {
|
|
76
|
-
path: '/api/v1/aiAgents/admin/settings',
|
|
77
|
-
method: 'PATCH',
|
|
78
|
-
description: 'Update AI organization settings',
|
|
79
|
-
},
|
|
80
|
-
'projects.validate.run': {
|
|
81
|
-
path: '/api/v1/projects/{projectUuid}/validate',
|
|
82
|
-
method: 'POST',
|
|
83
|
-
description: 'Start project validation job',
|
|
84
|
-
params: ['projectUuid'],
|
|
85
|
-
},
|
|
86
|
-
'projects.validate.results': {
|
|
87
|
-
path: '/api/v1/projects/{projectUuid}/validate',
|
|
88
|
-
method: 'GET',
|
|
89
|
-
description: 'Get latest validation results',
|
|
90
|
-
params: ['projectUuid'],
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
11
|
function extractPathParams(path) {
|
|
94
12
|
const params = [];
|
|
95
13
|
for (const match of path.matchAll(/\{([^}]+)\}/g)) {
|
|
@@ -99,23 +17,11 @@ function extractPathParams(path) {
|
|
|
99
17
|
}
|
|
100
18
|
function operationToSchema(operation) {
|
|
101
19
|
var _a;
|
|
102
|
-
return Object.assign({ resource: operation.id, path: operation.http.path, method: operation.http.method, description: operation.summary, params: extractPathParams(operation.http.path), cliCommand: operation.cli.commandPath
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
var _a;
|
|
106
|
-
return {
|
|
107
|
-
resource,
|
|
108
|
-
path: entry.path,
|
|
109
|
-
method: entry.method,
|
|
110
|
-
description: entry.description,
|
|
111
|
-
params: (_a = entry.params) !== null && _a !== void 0 ? _a : [],
|
|
112
|
-
};
|
|
20
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ resource: operation.id, path: operation.http.path, method: operation.http.method, description: operation.summary, params: extractPathParams(operation.http.path) }, (operation.cli != null ? { cliCommand: operation.cli.commandPath } : {})), (((_a = operation.mcp) === null || _a === void 0 ? void 0 : _a.taskSupport.exposed) === true ? { mcpToolName: operation.mcp.toolName } : {})), (operation.bannedMcpToolName != null
|
|
21
|
+
? { bannedMcpToolName: operation.bannedMcpToolName }
|
|
22
|
+
: {})), { agentExposure: operation.agentExposure, sensitivity: operation.sensitivity, profiles: [...operation.profiles], safetyImpact: operation.authorization.safetyImpact }), (operation.workflow != null ? { workflow: [...operation.workflow] } : {}));
|
|
113
23
|
}
|
|
114
24
|
function getSchema(resource) {
|
|
115
|
-
const legacy = LEGACY_SCHEMA_REGISTRY[resource];
|
|
116
|
-
if (legacy) {
|
|
117
|
-
return legacyToSchema(resource, legacy);
|
|
118
|
-
}
|
|
119
25
|
const operation = (0, common_1.getOperation)(resource);
|
|
120
26
|
if (operation) {
|
|
121
27
|
return operationToSchema(operation);
|
|
@@ -123,11 +29,9 @@ function getSchema(resource) {
|
|
|
123
29
|
return null;
|
|
124
30
|
}
|
|
125
31
|
function listResources() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
]);
|
|
130
|
-
return [...resources].sort();
|
|
32
|
+
return (0, common_1.listOperations)()
|
|
33
|
+
.map((operation) => operation.id)
|
|
34
|
+
.sort();
|
|
131
35
|
}
|
|
132
36
|
/**
|
|
133
37
|
* Registers the schema introspection command.
|
|
@@ -138,14 +42,14 @@ function registerSchemaCommand(program) {
|
|
|
138
42
|
.description('Introspect API schema for agent discoverability');
|
|
139
43
|
schemaCmd
|
|
140
44
|
.command('list')
|
|
141
|
-
.description('List all introspectable resources')
|
|
45
|
+
.description('List all introspectable resources from the operation catalog')
|
|
142
46
|
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, () => {
|
|
143
47
|
const resources = listResources();
|
|
144
48
|
console.log(JSON.stringify({ resources }, null, 2));
|
|
145
49
|
}));
|
|
146
50
|
schemaCmd
|
|
147
51
|
.command('get <resource>')
|
|
148
|
-
.description('Get schema for a
|
|
52
|
+
.description('Get schema for a catalog operation id (e.g. ai-agents.project.agents.list)')
|
|
149
53
|
.action((0, safety_1.wrapAction)(common_1.READ_ONLY_DEFAULT, (resource) => {
|
|
150
54
|
const schema = getSchema(resource);
|
|
151
55
|
if (!schema) {
|
|
@@ -4,39 +4,47 @@ const vitest_1 = require("vitest");
|
|
|
4
4
|
const schema_1 = require("./schema");
|
|
5
5
|
(0, vitest_1.describe)('schema command', () => {
|
|
6
6
|
(0, vitest_1.describe)('getSchema', () => {
|
|
7
|
-
(0, vitest_1.it)('returns
|
|
8
|
-
const schema = (0, schema_1.getSchema)('
|
|
7
|
+
(0, vitest_1.it)('returns schema for ai-agents.project.agents.list from the operation catalog', () => {
|
|
8
|
+
const schema = (0, schema_1.getSchema)('ai-agents.project.agents.list');
|
|
9
9
|
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
10
|
-
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/
|
|
10
|
+
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
|
|
11
11
|
(0, vitest_1.expect)(schema).toHaveProperty('method', 'GET');
|
|
12
|
-
(0, vitest_1.expect)(schema).toHaveProperty('
|
|
13
|
-
(0, vitest_1.expect)(schema
|
|
14
|
-
(0, vitest_1.expect)(schema).toHaveProperty('
|
|
15
|
-
(0, vitest_1.expect)(schema).
|
|
12
|
+
(0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents list');
|
|
13
|
+
(0, vitest_1.expect)(schema).not.toHaveProperty('mcpToolName');
|
|
14
|
+
(0, vitest_1.expect)(schema).toHaveProperty('profiles');
|
|
15
|
+
(0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.profiles).toContain('core-lifecycle');
|
|
16
|
+
(0, vitest_1.expect)(schema).toHaveProperty('sensitivity', 'none');
|
|
16
17
|
});
|
|
17
|
-
(0, vitest_1.it)('returns schema for ai-agents.settings.update
|
|
18
|
-
const schema = (0, schema_1.getSchema)('ai-agents.settings.update');
|
|
18
|
+
(0, vitest_1.it)('returns schema for ai-agents.admin.settings.update from the operation catalog', () => {
|
|
19
|
+
const schema = (0, schema_1.getSchema)('ai-agents.admin.settings.update');
|
|
19
20
|
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
20
21
|
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
|
|
21
22
|
(0, vitest_1.expect)(schema).toHaveProperty('method', 'PATCH');
|
|
23
|
+
(0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'ai-agents settings update');
|
|
24
|
+
(0, vitest_1.expect)(schema).not.toHaveProperty('mcpToolName');
|
|
22
25
|
});
|
|
23
|
-
(0, vitest_1.it)('returns schema for
|
|
24
|
-
const schema = (0, schema_1.getSchema)('
|
|
26
|
+
(0, vitest_1.it)('returns schema for cli.charts.list from the operation catalog', () => {
|
|
27
|
+
const schema = (0, schema_1.getSchema)('cli.charts.list');
|
|
25
28
|
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
26
|
-
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/
|
|
29
|
+
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/code/charts');
|
|
27
30
|
(0, vitest_1.expect)(schema).toHaveProperty('method', 'GET');
|
|
28
|
-
(0, vitest_1.expect)(schema).
|
|
29
|
-
(0, vitest_1.expect)(schema).toHaveProperty('
|
|
30
|
-
|
|
31
|
+
(0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.params).toEqual(['projectUuid']);
|
|
32
|
+
(0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'projects charts list');
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)('returns schema for semantic.projects.list with exposed MCP tool name', () => {
|
|
35
|
+
const schema = (0, schema_1.getSchema)('semantic.projects.list');
|
|
36
|
+
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
37
|
+
(0, vitest_1.expect)(schema).toHaveProperty('mcpToolName', 'list_projects');
|
|
38
|
+
(0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'projects list');
|
|
31
39
|
});
|
|
32
|
-
(0, vitest_1.it)('returns schema for ai-agents.project.evaluations.create from operation
|
|
40
|
+
(0, vitest_1.it)('returns schema for ai-agents.project.evaluations.create from the operation catalog', () => {
|
|
33
41
|
const schema = (0, schema_1.getSchema)('ai-agents.project.evaluations.create');
|
|
34
42
|
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
35
43
|
(0, vitest_1.expect)(schema).toHaveProperty('method', 'POST');
|
|
36
44
|
(0, vitest_1.expect)(schema).toHaveProperty('cliCommand', 'agents evals create');
|
|
37
45
|
(0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.params).toEqual(vitest_1.expect.arrayContaining(['projectUuid', 'agentUuid']));
|
|
38
46
|
});
|
|
39
|
-
(0, vitest_1.it)('returns schema for ai-agents.project.threads.start from operation
|
|
47
|
+
(0, vitest_1.it)('returns schema for ai-agents.project.threads.start from the operation catalog', () => {
|
|
40
48
|
const schema = (0, schema_1.getSchema)('ai-agents.project.threads.start');
|
|
41
49
|
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
42
50
|
(0, vitest_1.expect)(schema).toHaveProperty('method', 'POST');
|
|
@@ -50,7 +58,7 @@ const schema_1 = require("./schema");
|
|
|
50
58
|
}),
|
|
51
59
|
]));
|
|
52
60
|
});
|
|
53
|
-
(0, vitest_1.it)('returns workflow for ai-agents.project.threads.continue from operation
|
|
61
|
+
(0, vitest_1.it)('returns workflow for ai-agents.project.threads.continue from the operation catalog', () => {
|
|
54
62
|
const schema = (0, schema_1.getSchema)('ai-agents.project.threads.continue');
|
|
55
63
|
(0, vitest_1.expect)(schema).not.toBeNull();
|
|
56
64
|
(0, vitest_1.expect)(schema === null || schema === void 0 ? void 0 : schema.workflow).toEqual(vitest_1.expect.arrayContaining([
|
|
@@ -70,27 +78,27 @@ const schema_1 = require("./schema");
|
|
|
70
78
|
(0, vitest_1.expect)(schema).toHaveProperty('method', 'DELETE');
|
|
71
79
|
(0, vitest_1.expect)(schema).toHaveProperty('path', '/api/v1/org/user/{userUuid}');
|
|
72
80
|
(0, vitest_1.expect)(schema).toHaveProperty('agentExposure', 'client-only');
|
|
81
|
+
(0, vitest_1.expect)(schema).toHaveProperty('bannedMcpToolName', 'delete_member');
|
|
73
82
|
});
|
|
74
83
|
(0, vitest_1.it)('returns null for unknown resource', () => {
|
|
75
84
|
const schema = (0, schema_1.getSchema)('unknown.resource');
|
|
76
85
|
(0, vitest_1.expect)(schema).toBeNull();
|
|
77
86
|
});
|
|
87
|
+
(0, vitest_1.it)('does not resolve retired legacy schema keys', () => {
|
|
88
|
+
(0, vitest_1.expect)((0, schema_1.getSchema)('charts.list')).toBeNull();
|
|
89
|
+
(0, vitest_1.expect)((0, schema_1.getSchema)('ai-agents.settings.update')).toBeNull();
|
|
90
|
+
});
|
|
78
91
|
});
|
|
79
92
|
(0, vitest_1.describe)('listResources', () => {
|
|
80
|
-
(0, vitest_1.it)('returns sorted
|
|
93
|
+
(0, vitest_1.it)('returns sorted catalog operation ids only', () => {
|
|
81
94
|
const resources = (0, schema_1.listResources)();
|
|
82
|
-
(0, vitest_1.expect)(resources).toContain('charts.list');
|
|
83
|
-
(0, vitest_1.expect)(resources).toContain('ai-agents.settings.get');
|
|
84
95
|
(0, vitest_1.expect)(resources).toEqual([...resources].sort());
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
(0, vitest_1.expect)((0, schema_1.listResources)()).toContain('charts.list');
|
|
88
|
-
});
|
|
89
|
-
(0, vitest_1.it)('includes project-scoped registry operation ids', () => {
|
|
90
|
-
const resources = (0, schema_1.listResources)();
|
|
96
|
+
(0, vitest_1.expect)(resources).not.toContain('charts.list');
|
|
97
|
+
(0, vitest_1.expect)(resources).toContain('cli.charts.list');
|
|
91
98
|
(0, vitest_1.expect)(resources).toContain('ai-agents.project.agents.list');
|
|
92
99
|
(0, vitest_1.expect)(resources).toContain('ai-agents.project.evaluations.run');
|
|
93
100
|
(0, vitest_1.expect)(resources).toContain('ai-agents.project.threads.continue');
|
|
101
|
+
(0, vitest_1.expect)(resources).toContain('semantic.projects.list');
|
|
94
102
|
});
|
|
95
103
|
});
|
|
96
104
|
});
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ const program = new commander_1.Command();
|
|
|
33
33
|
program
|
|
34
34
|
.name('lightdash-ai')
|
|
35
35
|
.description('CLI for Lightdash AI')
|
|
36
|
-
.version('0.
|
|
36
|
+
.version('0.8.0')
|
|
37
37
|
.option('--safety-mode <mode>', 'Safety mode (read-only, write-idempotent, write-destructive)', 'read-only')
|
|
38
38
|
.option('--projects <uuids>', 'Comma-separated list of allowed project UUIDs (security guardrail)')
|
|
39
39
|
.option('--dry-run', 'Simulate mutating operations without executing (env: LIGHTDASH_TOOLS_DRY_RUN=1)');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash-tools/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "CLI for Lightdash AI.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"commander": "^15.0.0",
|
|
20
20
|
"yaml": "^2.9.0",
|
|
21
|
-
"@lightdash-tools/client": "0.
|
|
22
|
-
"@lightdash-tools/common": "0.
|
|
21
|
+
"@lightdash-tools/client": "0.8.0",
|
|
22
|
+
"@lightdash-tools/common": "0.8.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^25.9.3"
|
|
@@ -4,35 +4,44 @@ import { getSchema, listResources } from './schema';
|
|
|
4
4
|
|
|
5
5
|
describe('schema command', () => {
|
|
6
6
|
describe('getSchema', () => {
|
|
7
|
-
it('returns
|
|
8
|
-
const schema = getSchema('
|
|
7
|
+
it('returns schema for ai-agents.project.agents.list from the operation catalog', () => {
|
|
8
|
+
const schema = getSchema('ai-agents.project.agents.list');
|
|
9
9
|
expect(schema).not.toBeNull();
|
|
10
|
-
expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/
|
|
10
|
+
expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
|
|
11
11
|
expect(schema).toHaveProperty('method', 'GET');
|
|
12
|
-
expect(schema).toHaveProperty('
|
|
13
|
-
expect(schema
|
|
14
|
-
expect(schema).toHaveProperty('
|
|
15
|
-
expect(schema).
|
|
12
|
+
expect(schema).toHaveProperty('cliCommand', 'agents list');
|
|
13
|
+
expect(schema).not.toHaveProperty('mcpToolName');
|
|
14
|
+
expect(schema).toHaveProperty('profiles');
|
|
15
|
+
expect(schema?.profiles).toContain('core-lifecycle');
|
|
16
|
+
expect(schema).toHaveProperty('sensitivity', 'none');
|
|
16
17
|
});
|
|
17
18
|
|
|
18
|
-
it('returns schema for ai-agents.settings.update
|
|
19
|
-
const schema = getSchema('ai-agents.settings.update');
|
|
19
|
+
it('returns schema for ai-agents.admin.settings.update from the operation catalog', () => {
|
|
20
|
+
const schema = getSchema('ai-agents.admin.settings.update');
|
|
20
21
|
expect(schema).not.toBeNull();
|
|
21
22
|
expect(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
|
|
22
23
|
expect(schema).toHaveProperty('method', 'PATCH');
|
|
24
|
+
expect(schema).toHaveProperty('cliCommand', 'ai-agents settings update');
|
|
25
|
+
expect(schema).not.toHaveProperty('mcpToolName');
|
|
23
26
|
});
|
|
24
27
|
|
|
25
|
-
it('returns schema for
|
|
26
|
-
const schema = getSchema('
|
|
28
|
+
it('returns schema for cli.charts.list from the operation catalog', () => {
|
|
29
|
+
const schema = getSchema('cli.charts.list');
|
|
27
30
|
expect(schema).not.toBeNull();
|
|
28
|
-
expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/
|
|
31
|
+
expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/code/charts');
|
|
29
32
|
expect(schema).toHaveProperty('method', 'GET');
|
|
30
|
-
expect(schema).
|
|
31
|
-
expect(schema).toHaveProperty('
|
|
32
|
-
|
|
33
|
+
expect(schema?.params).toEqual(['projectUuid']);
|
|
34
|
+
expect(schema).toHaveProperty('cliCommand', 'projects charts list');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('returns schema for semantic.projects.list with exposed MCP tool name', () => {
|
|
38
|
+
const schema = getSchema('semantic.projects.list');
|
|
39
|
+
expect(schema).not.toBeNull();
|
|
40
|
+
expect(schema).toHaveProperty('mcpToolName', 'list_projects');
|
|
41
|
+
expect(schema).toHaveProperty('cliCommand', 'projects list');
|
|
33
42
|
});
|
|
34
43
|
|
|
35
|
-
it('returns schema for ai-agents.project.evaluations.create from operation
|
|
44
|
+
it('returns schema for ai-agents.project.evaluations.create from the operation catalog', () => {
|
|
36
45
|
const schema = getSchema('ai-agents.project.evaluations.create');
|
|
37
46
|
expect(schema).not.toBeNull();
|
|
38
47
|
expect(schema).toHaveProperty('method', 'POST');
|
|
@@ -40,7 +49,7 @@ describe('schema command', () => {
|
|
|
40
49
|
expect(schema?.params).toEqual(expect.arrayContaining(['projectUuid', 'agentUuid']));
|
|
41
50
|
});
|
|
42
51
|
|
|
43
|
-
it('returns schema for ai-agents.project.threads.start from operation
|
|
52
|
+
it('returns schema for ai-agents.project.threads.start from the operation catalog', () => {
|
|
44
53
|
const schema = getSchema('ai-agents.project.threads.start');
|
|
45
54
|
expect(schema).not.toBeNull();
|
|
46
55
|
expect(schema).toHaveProperty('method', 'POST');
|
|
@@ -60,7 +69,7 @@ describe('schema command', () => {
|
|
|
60
69
|
);
|
|
61
70
|
});
|
|
62
71
|
|
|
63
|
-
it('returns workflow for ai-agents.project.threads.continue from operation
|
|
72
|
+
it('returns workflow for ai-agents.project.threads.continue from the operation catalog', () => {
|
|
64
73
|
const schema = getSchema('ai-agents.project.threads.continue');
|
|
65
74
|
expect(schema).not.toBeNull();
|
|
66
75
|
expect(schema?.workflow).toEqual(
|
|
@@ -83,31 +92,30 @@ describe('schema command', () => {
|
|
|
83
92
|
expect(schema).toHaveProperty('method', 'DELETE');
|
|
84
93
|
expect(schema).toHaveProperty('path', '/api/v1/org/user/{userUuid}');
|
|
85
94
|
expect(schema).toHaveProperty('agentExposure', 'client-only');
|
|
95
|
+
expect(schema).toHaveProperty('bannedMcpToolName', 'delete_member');
|
|
86
96
|
});
|
|
87
97
|
|
|
88
98
|
it('returns null for unknown resource', () => {
|
|
89
99
|
const schema = getSchema('unknown.resource');
|
|
90
100
|
expect(schema).toBeNull();
|
|
91
101
|
});
|
|
102
|
+
|
|
103
|
+
it('does not resolve retired legacy schema keys', () => {
|
|
104
|
+
expect(getSchema('charts.list')).toBeNull();
|
|
105
|
+
expect(getSchema('ai-agents.settings.update')).toBeNull();
|
|
106
|
+
});
|
|
92
107
|
});
|
|
93
108
|
|
|
94
109
|
describe('listResources', () => {
|
|
95
|
-
it('returns sorted
|
|
110
|
+
it('returns sorted catalog operation ids only', () => {
|
|
96
111
|
const resources = listResources();
|
|
97
|
-
expect(resources).toContain('charts.list');
|
|
98
|
-
expect(resources).toContain('ai-agents.settings.get');
|
|
99
112
|
expect(resources).toEqual([...resources].sort());
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
it('includes charts.list', () => {
|
|
103
|
-
expect(listResources()).toContain('charts.list');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('includes project-scoped registry operation ids', () => {
|
|
107
|
-
const resources = listResources();
|
|
113
|
+
expect(resources).not.toContain('charts.list');
|
|
114
|
+
expect(resources).toContain('cli.charts.list');
|
|
108
115
|
expect(resources).toContain('ai-agents.project.agents.list');
|
|
109
116
|
expect(resources).toContain('ai-agents.project.evaluations.run');
|
|
110
117
|
expect(resources).toContain('ai-agents.project.threads.continue');
|
|
118
|
+
expect(resources).toContain('semantic.projects.list');
|
|
111
119
|
});
|
|
112
120
|
});
|
|
113
121
|
});
|
package/src/commands/schema.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Outputs machine-readable JSON describing API paths, methods, and parameters.
|
|
2
|
+
* Shared CLI schema command — catalog-only introspection (ADR-0013).
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
5
|
import { getOperation, listOperations, READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
@@ -10,95 +9,6 @@ import { wrapAction } from '../utils/safety';
|
|
|
10
9
|
import type { OperationDescriptor } from '@lightdash-tools/common';
|
|
11
10
|
import type { Command } from 'commander';
|
|
12
11
|
|
|
13
|
-
type SchemaEntry = {
|
|
14
|
-
path: string;
|
|
15
|
-
method: string;
|
|
16
|
-
description: string;
|
|
17
|
-
params?: string[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** Maps legacy resource identifiers to API path + method + description. */
|
|
21
|
-
const LEGACY_SCHEMA_REGISTRY: Record<string, SchemaEntry> = {
|
|
22
|
-
'organization.get': {
|
|
23
|
-
path: '/api/v1/org',
|
|
24
|
-
method: 'GET',
|
|
25
|
-
description: 'Get current organization details',
|
|
26
|
-
},
|
|
27
|
-
'projects.list': {
|
|
28
|
-
path: '/api/v1/org/projects',
|
|
29
|
-
method: 'GET',
|
|
30
|
-
description: 'List all projects in the organization',
|
|
31
|
-
},
|
|
32
|
-
'projects.get': {
|
|
33
|
-
path: '/api/v1/projects/{projectUuid}',
|
|
34
|
-
method: 'GET',
|
|
35
|
-
description: 'Get project by UUID',
|
|
36
|
-
params: ['projectUuid'],
|
|
37
|
-
},
|
|
38
|
-
'charts.list': {
|
|
39
|
-
path: '/api/v1/projects/{projectUuid}/charts',
|
|
40
|
-
method: 'GET',
|
|
41
|
-
description: 'List charts in a project',
|
|
42
|
-
params: ['projectUuid'],
|
|
43
|
-
},
|
|
44
|
-
'charts.code.list': {
|
|
45
|
-
path: '/api/v1/projects/{projectUuid}/code/charts',
|
|
46
|
-
method: 'GET',
|
|
47
|
-
description: 'Get charts in code representation',
|
|
48
|
-
params: ['projectUuid'],
|
|
49
|
-
},
|
|
50
|
-
'charts.code.upsert': {
|
|
51
|
-
path: '/api/v1/projects/{projectUuid}/code/charts/{slug}',
|
|
52
|
-
method: 'POST',
|
|
53
|
-
description: 'Create or update chart by slug',
|
|
54
|
-
params: ['projectUuid', 'slug'],
|
|
55
|
-
},
|
|
56
|
-
'dashboards.list': {
|
|
57
|
-
path: '/api/v1/projects/{projectUuid}/dashboards',
|
|
58
|
-
method: 'GET',
|
|
59
|
-
description: 'List dashboards in a project',
|
|
60
|
-
params: ['projectUuid'],
|
|
61
|
-
},
|
|
62
|
-
'spaces.list': {
|
|
63
|
-
path: '/api/v1/projects/{projectUuid}/spaces',
|
|
64
|
-
method: 'GET',
|
|
65
|
-
description: 'List spaces in a project',
|
|
66
|
-
params: ['projectUuid'],
|
|
67
|
-
},
|
|
68
|
-
'ai-agents.list': {
|
|
69
|
-
path: '/api/v1/aiAgents/admin/agents',
|
|
70
|
-
method: 'GET',
|
|
71
|
-
description: 'List AI agents (admin)',
|
|
72
|
-
},
|
|
73
|
-
'ai-agents.threads': {
|
|
74
|
-
path: '/api/v1/aiAgents/admin/threads',
|
|
75
|
-
method: 'GET',
|
|
76
|
-
description: 'List AI agent threads (admin)',
|
|
77
|
-
},
|
|
78
|
-
'ai-agents.settings.get': {
|
|
79
|
-
path: '/api/v1/aiAgents/admin/settings',
|
|
80
|
-
method: 'GET',
|
|
81
|
-
description: 'Get AI organization settings',
|
|
82
|
-
},
|
|
83
|
-
'ai-agents.settings.update': {
|
|
84
|
-
path: '/api/v1/aiAgents/admin/settings',
|
|
85
|
-
method: 'PATCH',
|
|
86
|
-
description: 'Update AI organization settings',
|
|
87
|
-
},
|
|
88
|
-
'projects.validate.run': {
|
|
89
|
-
path: '/api/v1/projects/{projectUuid}/validate',
|
|
90
|
-
method: 'POST',
|
|
91
|
-
description: 'Start project validation job',
|
|
92
|
-
params: ['projectUuid'],
|
|
93
|
-
},
|
|
94
|
-
'projects.validate.results': {
|
|
95
|
-
path: '/api/v1/projects/{projectUuid}/validate',
|
|
96
|
-
method: 'GET',
|
|
97
|
-
description: 'Get latest validation results',
|
|
98
|
-
params: ['projectUuid'],
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
12
|
function extractPathParams(path: string): string[] {
|
|
103
13
|
const params: string[] = [];
|
|
104
14
|
for (const match of path.matchAll(/\{([^}]+)\}/g)) {
|
|
@@ -114,44 +24,31 @@ function operationToSchema(operation: OperationDescriptor): Record<string, unkno
|
|
|
114
24
|
method: operation.http.method,
|
|
115
25
|
description: operation.summary,
|
|
116
26
|
params: extractPathParams(operation.http.path),
|
|
117
|
-
cliCommand: operation.cli.commandPath,
|
|
118
|
-
|
|
27
|
+
...(operation.cli != null ? { cliCommand: operation.cli.commandPath } : {}),
|
|
28
|
+
...(operation.mcp?.taskSupport.exposed === true ? { mcpToolName: operation.mcp.toolName } : {}),
|
|
29
|
+
...(operation.bannedMcpToolName != null
|
|
30
|
+
? { bannedMcpToolName: operation.bannedMcpToolName }
|
|
31
|
+
: {}),
|
|
32
|
+
agentExposure: operation.agentExposure,
|
|
33
|
+
sensitivity: operation.sensitivity,
|
|
119
34
|
profiles: [...operation.profiles],
|
|
120
35
|
safetyImpact: operation.authorization.safetyImpact,
|
|
121
36
|
...(operation.workflow != null ? { workflow: [...operation.workflow] } : {}),
|
|
122
37
|
};
|
|
123
38
|
}
|
|
124
39
|
|
|
125
|
-
function legacyToSchema(resource: string, entry: SchemaEntry): Record<string, unknown> {
|
|
126
|
-
return {
|
|
127
|
-
resource,
|
|
128
|
-
path: entry.path,
|
|
129
|
-
method: entry.method,
|
|
130
|
-
description: entry.description,
|
|
131
|
-
params: entry.params ?? [],
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
40
|
export function getSchema(resource: string): Record<string, unknown> | null {
|
|
136
|
-
const legacy = LEGACY_SCHEMA_REGISTRY[resource];
|
|
137
|
-
if (legacy) {
|
|
138
|
-
return legacyToSchema(resource, legacy);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
41
|
const operation = getOperation(resource);
|
|
142
42
|
if (operation) {
|
|
143
43
|
return operationToSchema(operation);
|
|
144
44
|
}
|
|
145
|
-
|
|
146
45
|
return null;
|
|
147
46
|
}
|
|
148
47
|
|
|
149
48
|
export function listResources(): string[] {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
]);
|
|
154
|
-
return [...resources].sort();
|
|
49
|
+
return listOperations()
|
|
50
|
+
.map((operation) => operation.id)
|
|
51
|
+
.sort();
|
|
155
52
|
}
|
|
156
53
|
|
|
157
54
|
/**
|
|
@@ -164,7 +61,7 @@ export function registerSchemaCommand(program: Command): void {
|
|
|
164
61
|
|
|
165
62
|
schemaCmd
|
|
166
63
|
.command('list')
|
|
167
|
-
.description('List all introspectable resources')
|
|
64
|
+
.description('List all introspectable resources from the operation catalog')
|
|
168
65
|
.action(
|
|
169
66
|
wrapAction(READ_ONLY_DEFAULT, () => {
|
|
170
67
|
const resources = listResources();
|
|
@@ -174,7 +71,7 @@ export function registerSchemaCommand(program: Command): void {
|
|
|
174
71
|
|
|
175
72
|
schemaCmd
|
|
176
73
|
.command('get <resource>')
|
|
177
|
-
.description('Get schema for a
|
|
74
|
+
.description('Get schema for a catalog operation id (e.g. ai-agents.project.agents.list)')
|
|
178
75
|
.action(
|
|
179
76
|
wrapAction(READ_ONLY_DEFAULT, (resource: string) => {
|
|
180
77
|
const schema = getSchema(resource);
|
package/src/index.ts
CHANGED