@lightdash-tools/cli 0.6.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.
Files changed (110) hide show
  1. package/README.md +8 -4
  2. package/dist/commands/agentops/apply.d.ts +5 -0
  3. package/dist/commands/agentops/apply.js +53 -0
  4. package/dist/commands/agentops/bundle-schema.d.ts +5 -0
  5. package/dist/commands/agentops/bundle-schema.js +16 -0
  6. package/dist/commands/agentops/drift.d.ts +5 -0
  7. package/dist/commands/agentops/drift.js +46 -0
  8. package/dist/commands/agentops/evaluate-gate.d.ts +5 -0
  9. package/dist/commands/agentops/evaluate-gate.js +89 -0
  10. package/dist/commands/agentops/gate-schema.d.ts +5 -0
  11. package/dist/commands/agentops/gate-schema.js +16 -0
  12. package/dist/commands/agentops/plan.d.ts +5 -0
  13. package/dist/commands/agentops/plan.js +42 -0
  14. package/dist/commands/agentops/state.d.ts +4 -0
  15. package/dist/commands/agentops/state.js +8 -0
  16. package/dist/commands/agentops.d.ts +8 -0
  17. package/dist/commands/agentops.js +26 -0
  18. package/dist/commands/agentops.test.d.ts +1 -0
  19. package/dist/commands/agentops.test.js +400 -0
  20. package/dist/commands/agents-crud.d.ts +8 -0
  21. package/dist/commands/agents-crud.js +144 -0
  22. package/dist/commands/agents-discovery.d.ts +8 -0
  23. package/dist/commands/agents-discovery.js +139 -0
  24. package/dist/commands/agents-discovery.test.d.ts +1 -0
  25. package/dist/commands/agents-discovery.test.js +13 -0
  26. package/dist/commands/agents-evals.d.ts +8 -0
  27. package/dist/commands/agents-evals.js +246 -0
  28. package/dist/commands/agents-threads.d.ts +8 -0
  29. package/dist/commands/agents-threads.js +83 -0
  30. package/dist/commands/agents.js +8 -360
  31. package/dist/commands/ai-agents.js +52 -70
  32. package/dist/commands/charts.js +35 -46
  33. package/dist/commands/content.js +3 -12
  34. package/dist/commands/dashboards.js +3 -12
  35. package/dist/commands/explores.js +12 -21
  36. package/dist/commands/groups.js +44 -63
  37. package/dist/commands/metrics.js +6 -15
  38. package/dist/commands/organization-roles.js +28 -39
  39. package/dist/commands/organization.js +3 -12
  40. package/dist/commands/project-access.js +9 -18
  41. package/dist/commands/project-role-assignments.js +15 -24
  42. package/dist/commands/projects.js +33 -26
  43. package/dist/commands/query.js +30 -41
  44. package/dist/commands/schedulers.js +6 -15
  45. package/dist/commands/schema.d.ts +1 -2
  46. package/dist/commands/schema.js +24 -97
  47. package/dist/commands/schema.test.js +80 -15
  48. package/dist/commands/space-access.js +12 -21
  49. package/dist/commands/spaces.js +6 -15
  50. package/dist/commands/tags.js +6 -15
  51. package/dist/commands/users.js +23 -41
  52. package/dist/index.js +18 -16
  53. package/dist/index.test.js +9 -9
  54. package/dist/utils/cli-params.d.ts +4 -0
  55. package/dist/utils/cli-params.js +15 -0
  56. package/dist/utils/cli-params.test.d.ts +1 -0
  57. package/dist/utils/cli-params.test.js +12 -0
  58. package/dist/utils/file-input.d.ts +30 -0
  59. package/dist/utils/file-input.js +77 -0
  60. package/dist/utils/file-input.test.d.ts +1 -0
  61. package/dist/utils/file-input.test.js +68 -0
  62. package/dist/utils/safety.d.ts +5 -0
  63. package/dist/utils/safety.js +97 -109
  64. package/dist/utils/safety.test.js +135 -33
  65. package/package.json +14 -5
  66. package/src/commands/agentops/apply.ts +77 -0
  67. package/src/commands/agentops/bundle-schema.ts +20 -0
  68. package/src/commands/agentops/drift.ts +63 -0
  69. package/src/commands/agentops/evaluate-gate.ts +128 -0
  70. package/src/commands/agentops/gate-schema.ts +20 -0
  71. package/src/commands/agentops/plan.ts +55 -0
  72. package/src/commands/agentops/state.ts +5 -0
  73. package/src/commands/agentops.test.ts +454 -0
  74. package/src/commands/agentops.ts +28 -0
  75. package/src/commands/agents-crud.ts +193 -0
  76. package/src/commands/agents-discovery.test.ts +16 -0
  77. package/src/commands/agents-discovery.ts +180 -0
  78. package/src/commands/agents-evals.ts +353 -0
  79. package/src/commands/agents-threads.ts +116 -0
  80. package/src/commands/agents.ts +9 -493
  81. package/src/commands/ai-agents.ts +37 -28
  82. package/src/commands/charts.ts +6 -3
  83. package/src/commands/content.ts +3 -1
  84. package/src/commands/dashboards.ts +3 -1
  85. package/src/commands/explores.ts +3 -1
  86. package/src/commands/groups.ts +33 -33
  87. package/src/commands/metrics.ts +3 -1
  88. package/src/commands/organization-roles.ts +3 -1
  89. package/src/commands/organization.ts +3 -1
  90. package/src/commands/project-access.ts +3 -1
  91. package/src/commands/project-role-assignments.ts +3 -1
  92. package/src/commands/projects.ts +44 -18
  93. package/src/commands/query.ts +4 -1
  94. package/src/commands/schedulers.ts +3 -1
  95. package/src/commands/schema.test.ts +95 -16
  96. package/src/commands/schema.ts +42 -99
  97. package/src/commands/space-access.ts +3 -1
  98. package/src/commands/spaces.ts +3 -1
  99. package/src/commands/tags.ts +3 -1
  100. package/src/commands/users.ts +29 -25
  101. package/src/index.test.ts +10 -9
  102. package/src/index.ts +19 -16
  103. package/src/utils/cli-params.test.ts +13 -0
  104. package/src/utils/cli-params.ts +12 -0
  105. package/src/utils/client.test.ts +1 -0
  106. package/src/utils/file-input.test.ts +91 -0
  107. package/src/utils/file-input.ts +83 -0
  108. package/src/utils/safety.test.ts +158 -2
  109. package/src/utils/safety.ts +27 -20
  110. package/tsconfig.json +2 -1
@@ -2,11 +2,41 @@
2
2
  * Groups command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE } from '@lightdash-tools/common';
6
+
7
+ import { pickDefined } from '../utils/cli-params';
7
8
  import { getClient } from '../utils/client';
8
9
  import { wrapAction } from '../utils/safety';
9
10
 
11
+ import type { LightdashClient } from '@lightdash-tools/client';
12
+ import type { Command } from 'commander';
13
+
14
+ type ListGroupsCliOptions = {
15
+ all?: boolean;
16
+ page?: number;
17
+ pageSize?: number;
18
+ search?: string;
19
+ includeMembers?: number;
20
+ };
21
+
22
+ async function listGroups(client: LightdashClient, options: ListGroupsCliOptions): Promise<void> {
23
+ const shared = {
24
+ searchQuery: options.search,
25
+ includeMembers: options.includeMembers,
26
+ };
27
+
28
+ if (options.all) {
29
+ const list = await client.v1.groups.listAllGroups(pickDefined(shared));
30
+ console.log(JSON.stringify(list, null, 2));
31
+ return;
32
+ }
33
+
34
+ const result = await client.v1.groups.listGroups(
35
+ pickDefined({ page: options.page, pageSize: options.pageSize, ...shared }),
36
+ );
37
+ console.log(JSON.stringify(result, null, 2));
38
+ }
39
+
10
40
  /**
11
41
  * Registers the groups command and its subcommands.
12
42
  * Uses client.v1.groups (typed client) per ADR-0010.
@@ -26,39 +56,9 @@ export function registerGroupsCommand(program: Command): void {
26
56
  )
27
57
  .action(
28
58
  wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
29
- const options = this.opts() as {
30
- all?: boolean;
31
- page?: number;
32
- pageSize?: number;
33
- search?: string;
34
- includeMembers?: number;
35
- };
59
+ const options = this.opts() as ListGroupsCliOptions;
36
60
  try {
37
- const client = getClient();
38
- if (options.all) {
39
- const listParams: { searchQuery?: string; includeMembers?: number } = {};
40
- if (options.search != null) listParams.searchQuery = options.search;
41
- if (options.includeMembers != null) listParams.includeMembers = options.includeMembers;
42
- const list = await client.v1.groups.listAllGroups(
43
- Object.keys(listParams).length > 0 ? listParams : undefined,
44
- );
45
- console.log(JSON.stringify(list, null, 2));
46
- } else {
47
- const params: {
48
- page?: number;
49
- pageSize?: number;
50
- searchQuery?: string;
51
- includeMembers?: number;
52
- } = {};
53
- if (options.page != null) params.page = options.page;
54
- if (options.pageSize != null) params.pageSize = options.pageSize;
55
- if (options.search != null) params.searchQuery = options.search;
56
- if (options.includeMembers != null) params.includeMembers = options.includeMembers;
57
- const result = await client.v1.groups.listGroups(
58
- Object.keys(params).length > 0 ? params : undefined,
59
- );
60
- console.log(JSON.stringify(result, null, 2));
61
- }
61
+ await listGroups(getClient(), options);
62
62
  } catch (error) {
63
63
  console.error(
64
64
  'Error listing groups:',
@@ -2,11 +2,13 @@
2
2
  * Metrics command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the metrics command and its subcommands.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Organization roles (v2) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the organization roles subcommands under the existing organization command.
12
14
  * Resolves org UUID via getCurrentOrganization().organizationUuid.
@@ -2,11 +2,13 @@
2
2
  * Organization command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the organization command and its subcommands.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Project access (v1) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the projects access subcommands under the existing projects command.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Project role assignments (v2) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the projects roles subcommands under the existing projects command.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Projects command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the projects command and its subcommands.
12
14
  */
@@ -79,23 +81,47 @@ export function registerProjectsCommand(program: Command): void {
79
81
 
80
82
  validateCmd
81
83
  .command('results <projectUuid>')
82
- .description('Get latest validation results for a project')
83
- .option('--job-id <id>', 'Specific validation job ID')
84
+ .description('Get validation results for a project (v2 API, paginated)')
85
+ .option('--validation-id <id>', 'Specific validation result ID (number)')
86
+ .option('--page <number>', 'Page number (1-indexed)', (v) => parseInt(v, 10))
87
+ .option('--page-size <number>', 'Results per page', (v) => parseInt(v, 10))
84
88
  .action(
85
- wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string, options: { jobId?: string }) => {
86
- try {
87
- const client = getClient();
88
- const result = await client.v1.validation.getValidationResults(projectUuid, {
89
- jobId: options.jobId,
90
- });
91
- console.log(JSON.stringify(result, null, 2));
92
- } catch (error) {
93
- console.error(
94
- 'Error fetching validation results:',
95
- error instanceof Error ? error.message : String(error),
96
- );
97
- process.exit(1);
98
- }
99
- }),
89
+ wrapAction(
90
+ READ_ONLY_DEFAULT,
91
+ async (
92
+ projectUuid: string,
93
+ options: { validationId?: string; page?: number; pageSize?: number },
94
+ ) => {
95
+ try {
96
+ const client = getClient();
97
+ if (options.validationId) {
98
+ // Get specific validation result by ID
99
+ const validationId = parseInt(options.validationId, 10);
100
+ if (isNaN(validationId)) {
101
+ console.error('Error: validation-id must be a number');
102
+ process.exit(1);
103
+ }
104
+ const result = await client.v2.validation.getValidationResult(
105
+ projectUuid,
106
+ validationId,
107
+ );
108
+ console.log(JSON.stringify(result, null, 2));
109
+ } else {
110
+ // List validation results (first page by default)
111
+ const result = await client.v2.validation.listValidationResults(projectUuid, {
112
+ page: options.page,
113
+ pageSize: options.pageSize,
114
+ });
115
+ console.log(JSON.stringify(result, null, 2));
116
+ }
117
+ } catch (error) {
118
+ console.error(
119
+ 'Error fetching validation results:',
120
+ error instanceof Error ? error.message : String(error),
121
+ );
122
+ process.exit(1);
123
+ }
124
+ },
125
+ ),
100
126
  );
101
127
  }
@@ -2,12 +2,15 @@
2
2
  * Query command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { readFileSync } from 'fs';
6
+
7
7
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
8
+
8
9
  import { getClient } from '../utils/client';
9
10
  import { wrapAction } from '../utils/safety';
11
+
10
12
  import type { CompileQueryRequest } from '@lightdash-tools/common';
13
+ import type { Command } from 'commander';
11
14
 
12
15
  /**
13
16
  * Reads JSON from stdin or a file.
@@ -2,11 +2,13 @@
2
2
  * Schedulers command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the schedulers command and its subcommands.
12
14
  */
@@ -1,42 +1,121 @@
1
1
  import { describe, it, expect } from 'vitest';
2
+
2
3
  import { getSchema, listResources } from './schema';
3
4
 
4
5
  describe('schema command', () => {
5
6
  describe('getSchema', () => {
6
- it('returns JSON with path, method, params for charts.list', () => {
7
- const schema = getSchema('charts.list');
7
+ it('returns schema for ai-agents.project.agents.list from the operation catalog', () => {
8
+ const schema = getSchema('ai-agents.project.agents.list');
8
9
  expect(schema).not.toBeNull();
9
- expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/charts');
10
+ expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/aiAgents');
10
11
  expect(schema).toHaveProperty('method', 'GET');
11
- expect(schema).toHaveProperty('params');
12
- expect(schema?.params).toEqual(['projectUuid']);
13
- expect(schema).toHaveProperty('description');
14
- expect(schema).toHaveProperty('resource', 'charts.list');
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');
15
17
  });
16
18
 
17
- it('returns schema for ai-agents.settings.update', () => {
18
- 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');
19
21
  expect(schema).not.toBeNull();
20
22
  expect(schema).toHaveProperty('path', '/api/v1/aiAgents/admin/settings');
21
23
  expect(schema).toHaveProperty('method', 'PATCH');
24
+ expect(schema).toHaveProperty('cliCommand', 'ai-agents settings update');
25
+ expect(schema).not.toHaveProperty('mcpToolName');
26
+ });
27
+
28
+ it('returns schema for cli.charts.list from the operation catalog', () => {
29
+ const schema = getSchema('cli.charts.list');
30
+ expect(schema).not.toBeNull();
31
+ expect(schema).toHaveProperty('path', '/api/v1/projects/{projectUuid}/code/charts');
32
+ expect(schema).toHaveProperty('method', 'GET');
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');
42
+ });
43
+
44
+ it('returns schema for ai-agents.project.evaluations.create from the operation catalog', () => {
45
+ const schema = getSchema('ai-agents.project.evaluations.create');
46
+ expect(schema).not.toBeNull();
47
+ expect(schema).toHaveProperty('method', 'POST');
48
+ expect(schema).toHaveProperty('cliCommand', 'agents evals create');
49
+ expect(schema?.params).toEqual(expect.arrayContaining(['projectUuid', 'agentUuid']));
50
+ });
51
+
52
+ it('returns schema for ai-agents.project.threads.start from the operation catalog', () => {
53
+ const schema = getSchema('ai-agents.project.threads.start');
54
+ expect(schema).not.toBeNull();
55
+ expect(schema).toHaveProperty('method', 'POST');
56
+ expect(schema).toHaveProperty(
57
+ 'path',
58
+ '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads',
59
+ );
60
+ expect(schema).toHaveProperty('cliCommand', 'agents threads start');
61
+ expect(schema).toHaveProperty('safetyImpact', 'external-side-effect');
62
+ expect(schema?.workflow).toEqual(
63
+ expect.arrayContaining([
64
+ expect.objectContaining({
65
+ method: 'POST',
66
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
67
+ }),
68
+ ]),
69
+ );
70
+ });
71
+
72
+ it('returns workflow for ai-agents.project.threads.continue from the operation catalog', () => {
73
+ const schema = getSchema('ai-agents.project.threads.continue');
74
+ expect(schema).not.toBeNull();
75
+ expect(schema?.workflow).toEqual(
76
+ expect.arrayContaining([
77
+ expect.objectContaining({
78
+ method: 'POST',
79
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/messages',
80
+ }),
81
+ expect.objectContaining({
82
+ method: 'POST',
83
+ path: '/api/v1/projects/{projectUuid}/aiAgents/{agentUuid}/threads/{threadUuid}/generate',
84
+ }),
85
+ ]),
86
+ );
87
+ });
88
+
89
+ it('returns schema for users.members.delete with client-only exposure', () => {
90
+ const schema = getSchema('users.members.delete');
91
+ expect(schema).not.toBeNull();
92
+ expect(schema).toHaveProperty('method', 'DELETE');
93
+ expect(schema).toHaveProperty('path', '/api/v1/org/user/{userUuid}');
94
+ expect(schema).toHaveProperty('agentExposure', 'client-only');
95
+ expect(schema).toHaveProperty('bannedMcpToolName', 'delete_member');
22
96
  });
23
97
 
24
98
  it('returns null for unknown resource', () => {
25
99
  const schema = getSchema('unknown.resource');
26
100
  expect(schema).toBeNull();
27
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
+ });
28
107
  });
29
108
 
30
109
  describe('listResources', () => {
31
- it('returns sorted list of resource identifiers', () => {
110
+ it('returns sorted catalog operation ids only', () => {
32
111
  const resources = listResources();
33
- expect(resources).toContain('charts.list');
34
- expect(resources).toContain('ai-agents.settings.get');
35
112
  expect(resources).toEqual([...resources].sort());
36
- });
37
-
38
- it('includes charts.list', () => {
39
- expect(listResources()).toContain('charts.list');
113
+ expect(resources).not.toContain('charts.list');
114
+ expect(resources).toContain('cli.charts.list');
115
+ expect(resources).toContain('ai-agents.project.agents.list');
116
+ expect(resources).toContain('ai-agents.project.evaluations.run');
117
+ expect(resources).toContain('ai-agents.project.threads.continue');
118
+ expect(resources).toContain('semantic.projects.list');
40
119
  });
41
120
  });
42
121
  });
@@ -1,111 +1,54 @@
1
1
  /**
2
- * Schema introspection command for agent discoverability.
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
- import type { Command } from 'commander';
7
- import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
5
+ import { getOperation, listOperations, READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
8
7
  import { wrapAction } from '../utils/safety';
9
8
 
10
- /** Maps resource identifiers to API path + method + description. */
11
- const SCHEMA_REGISTRY: Record<
12
- string,
13
- { path: string; method: string; description: string; params?: string[] }
14
- > = {
15
- 'organization.get': {
16
- path: '/api/v1/org',
17
- method: 'GET',
18
- description: 'Get current organization details',
19
- },
20
- 'projects.list': {
21
- path: '/api/v1/org/projects',
22
- method: 'GET',
23
- description: 'List all projects in the organization',
24
- },
25
- 'projects.get': {
26
- path: '/api/v1/projects/{projectUuid}',
27
- method: 'GET',
28
- description: 'Get project by UUID',
29
- params: ['projectUuid'],
30
- },
31
- 'charts.list': {
32
- path: '/api/v1/projects/{projectUuid}/charts',
33
- method: 'GET',
34
- description: 'List charts in a project',
35
- params: ['projectUuid'],
36
- },
37
- 'charts.code.list': {
38
- path: '/api/v1/projects/{projectUuid}/charts/code',
39
- method: 'GET',
40
- description: 'Get charts in code representation',
41
- params: ['projectUuid'],
42
- },
43
- 'charts.code.upsert': {
44
- path: '/api/v1/projects/{projectUuid}/charts/{slug}/code',
45
- method: 'POST',
46
- description: 'Create or update chart by slug',
47
- params: ['projectUuid', 'slug'],
48
- },
49
- 'dashboards.list': {
50
- path: '/api/v1/projects/{projectUuid}/dashboards',
51
- method: 'GET',
52
- description: 'List dashboards in a project',
53
- params: ['projectUuid'],
54
- },
55
- 'spaces.list': {
56
- path: '/api/v1/projects/{projectUuid}/spaces',
57
- method: 'GET',
58
- description: 'List spaces in a project',
59
- params: ['projectUuid'],
60
- },
61
- 'ai-agents.list': {
62
- path: '/api/v1/aiAgents/admin/agents',
63
- method: 'GET',
64
- description: 'List AI agents (admin)',
65
- },
66
- 'ai-agents.threads': {
67
- path: '/api/v1/aiAgents/admin/threads',
68
- method: 'GET',
69
- description: 'List AI agent threads (admin)',
70
- },
71
- 'ai-agents.settings.get': {
72
- path: '/api/v1/aiAgents/admin/settings',
73
- method: 'GET',
74
- description: 'Get AI organization settings',
75
- },
76
- 'ai-agents.settings.update': {
77
- path: '/api/v1/aiAgents/admin/settings',
78
- method: 'PATCH',
79
- description: 'Update AI organization settings',
80
- },
81
- 'projects.validate.run': {
82
- path: '/api/v1/projects/{projectUuid}/validate',
83
- method: 'POST',
84
- description: 'Start project validation job',
85
- params: ['projectUuid'],
86
- },
87
- 'projects.validate.results': {
88
- path: '/api/v1/projects/{projectUuid}/validate',
89
- method: 'GET',
90
- description: 'Get latest validation results',
91
- params: ['projectUuid'],
92
- },
93
- };
9
+ import type { OperationDescriptor } from '@lightdash-tools/common';
10
+ import type { Command } from 'commander';
94
11
 
95
- export function getSchema(resource: string): Record<string, unknown> | null {
96
- const entry = SCHEMA_REGISTRY[resource];
97
- if (!entry) return null;
12
+ function extractPathParams(path: string): string[] {
13
+ const params: string[] = [];
14
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
15
+ params.push(match[1]);
16
+ }
17
+ return params;
18
+ }
19
+
20
+ function operationToSchema(operation: OperationDescriptor): Record<string, unknown> {
98
21
  return {
99
- resource,
100
- path: entry.path,
101
- method: entry.method,
102
- description: entry.description,
103
- params: entry.params ?? [],
22
+ resource: operation.id,
23
+ path: operation.http.path,
24
+ method: operation.http.method,
25
+ description: operation.summary,
26
+ params: extractPathParams(operation.http.path),
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,
34
+ profiles: [...operation.profiles],
35
+ safetyImpact: operation.authorization.safetyImpact,
36
+ ...(operation.workflow != null ? { workflow: [...operation.workflow] } : {}),
104
37
  };
105
38
  }
106
39
 
40
+ export function getSchema(resource: string): Record<string, unknown> | null {
41
+ const operation = getOperation(resource);
42
+ if (operation) {
43
+ return operationToSchema(operation);
44
+ }
45
+ return null;
46
+ }
47
+
107
48
  export function listResources(): string[] {
108
- return Object.keys(SCHEMA_REGISTRY).sort();
49
+ return listOperations()
50
+ .map((operation) => operation.id)
51
+ .sort();
109
52
  }
110
53
 
111
54
  /**
@@ -118,7 +61,7 @@ export function registerSchemaCommand(program: Command): void {
118
61
 
119
62
  schemaCmd
120
63
  .command('list')
121
- .description('List all introspectable resources')
64
+ .description('List all introspectable resources from the operation catalog')
122
65
  .action(
123
66
  wrapAction(READ_ONLY_DEFAULT, () => {
124
67
  const resources = listResources();
@@ -128,7 +71,7 @@ export function registerSchemaCommand(program: Command): void {
128
71
 
129
72
  schemaCmd
130
73
  .command('get <resource>')
131
- .description('Get schema for a resource (e.g. charts.list, ai-agents.settings.get)')
74
+ .description('Get schema for a catalog operation id (e.g. ai-agents.project.agents.list)')
132
75
  .action(
133
76
  wrapAction(READ_ONLY_DEFAULT, (resource: string) => {
134
77
  const schema = getSchema(resource);
@@ -2,11 +2,13 @@
2
2
  * Space access (v1) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE, type SpaceMemberRole } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the space access subcommands under the existing projects command.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Spaces (v1) command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the projects spaces subcommands under the existing projects command.
12
14
  */
@@ -2,11 +2,13 @@
2
2
  * Tags command implementation.
3
3
  */
4
4
 
5
- import type { Command } from 'commander';
6
5
  import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
6
+
7
7
  import { getClient } from '../utils/client';
8
8
  import { wrapAction } from '../utils/safety';
9
9
 
10
+ import type { Command } from 'commander';
11
+
10
12
  /**
11
13
  * Registers the tags command and its subcommands.
12
14
  */