@guildai/cli 0.6.0 → 0.6.2
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 +17 -0
- package/dist/commands/agent/chat.js +31 -31
- package/dist/commands/agent/fork.js +1 -1
- package/dist/commands/agent/init.js +1 -1
- package/dist/commands/agent/publish.js +13 -53
- package/dist/commands/agent/pull.js +36 -21
- package/dist/commands/agent/save.js +16 -52
- package/dist/commands/agent/test.js +8 -12
- package/dist/commands/auth/login.js +3 -3
- package/dist/commands/chat.js +68 -106
- package/dist/commands/credentials/endpoint-list.js +1 -1
- package/dist/commands/integration/connect.d.ts +3 -0
- package/dist/commands/integration/connect.js +76 -0
- package/dist/commands/integration/create.d.ts +3 -0
- package/dist/commands/integration/create.js +298 -0
- package/dist/commands/integration/get.d.ts +3 -0
- package/dist/commands/integration/get.js +95 -0
- package/dist/commands/integration/list.d.ts +3 -0
- package/dist/commands/integration/list.js +61 -0
- package/dist/commands/integration/operation/create.d.ts +3 -0
- package/dist/commands/integration/operation/create.js +163 -0
- package/dist/commands/integration/operation/list.d.ts +3 -0
- package/dist/commands/integration/operation/list.js +83 -0
- package/dist/commands/integration/update.d.ts +3 -0
- package/dist/commands/integration/update.js +139 -0
- package/dist/commands/integration/version/build.d.ts +3 -0
- package/dist/commands/integration/version/build.js +86 -0
- package/dist/commands/integration/version/create.d.ts +3 -0
- package/dist/commands/integration/version/create.js +45 -0
- package/dist/commands/integration/version/get.d.ts +3 -0
- package/dist/commands/integration/version/get.js +72 -0
- package/dist/commands/integration/version/list.d.ts +3 -0
- package/dist/commands/integration/version/list.js +44 -0
- package/dist/commands/integration/version/publish.d.ts +3 -0
- package/dist/commands/integration/version/publish.js +79 -0
- package/dist/commands/integration/version/test.d.ts +3 -0
- package/dist/commands/integration/version/test.js +104 -0
- package/dist/commands/workspace/create.js +10 -4
- package/dist/index.js +38 -0
- package/dist/lib/api-types.d.ts +69 -12
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/auth.js +3 -2
- package/dist/lib/integration-helpers.d.ts +15 -0
- package/dist/lib/integration-helpers.js +38 -0
- package/dist/lib/output.d.ts +11 -1
- package/dist/lib/output.js +94 -0
- package/dist/lib/session-events-fetch.d.ts +27 -0
- package/dist/lib/session-events-fetch.js +25 -0
- package/dist/lib/session-polling.d.ts +7 -2
- package/dist/lib/session-polling.js +19 -12
- package/dist/lib/session-resume.js +2 -5
- package/dist/lib/table.d.ts +0 -1
- package/dist/lib/table.js +0 -1
- package/dist/lib/version-helpers.d.ts +15 -0
- package/dist/lib/version-helpers.js +83 -0
- package/dist/mcp/tools.js +6 -12
- package/docs/CLI_WORKFLOW.md +15 -0
- package/docs/skills/agent-dev.md +15 -0
- package/package.json +4 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
6
|
+
import { getAuthToken } from '../../../lib/auth.js';
|
|
7
|
+
import { handleAxiosError } from '../../../lib/errors.js';
|
|
8
|
+
import { getOutputMode } from '../../../lib/output-mode.js';
|
|
9
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
10
|
+
import { resolveVersionId } from '../../../lib/integration-helpers.js';
|
|
11
|
+
import { Table } from '../../../lib/table.js';
|
|
12
|
+
export function createIntegrationOperationListCommand() {
|
|
13
|
+
const cmd = new Command('list');
|
|
14
|
+
cmd
|
|
15
|
+
.description('List operations for an integration version')
|
|
16
|
+
.argument('<id_or_name>', 'Integration ID or name (owner~name)')
|
|
17
|
+
.option('--version <semver>', 'Specific version, e.g. 1.0.0')
|
|
18
|
+
.option('--limit <number>', 'Number of results to return', '100')
|
|
19
|
+
.option('--offset <number>', 'Offset for pagination', '0')
|
|
20
|
+
.action(async (identifier, options) => {
|
|
21
|
+
const output = createOutputWriter();
|
|
22
|
+
try {
|
|
23
|
+
const token = await getAuthToken();
|
|
24
|
+
if (!token) {
|
|
25
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const client = new GuildAPIClient();
|
|
29
|
+
const versionId = await resolveVersionId(client, identifier, options.version);
|
|
30
|
+
const params = new URLSearchParams();
|
|
31
|
+
params.append('limit', options.limit);
|
|
32
|
+
params.append('offset', options.offset);
|
|
33
|
+
const response = await client.get(`/integration_versions/${versionId}/endpoints?${params.toString()}`);
|
|
34
|
+
if (getOutputMode() === 'json') {
|
|
35
|
+
output.data(response);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (response.items.length === 0) {
|
|
39
|
+
console.log(chalk.dim('No operations found'));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
console.log(chalk.bold('Operations'));
|
|
43
|
+
console.log();
|
|
44
|
+
const table = new Table({
|
|
45
|
+
columns: [
|
|
46
|
+
{ name: 'operation', title: 'OPERATION', alignment: 'left' },
|
|
47
|
+
{
|
|
48
|
+
name: 'method',
|
|
49
|
+
title: 'METHOD',
|
|
50
|
+
alignment: 'left',
|
|
51
|
+
color: 'cyan',
|
|
52
|
+
},
|
|
53
|
+
{ name: 'path', title: 'PATH', alignment: 'left' },
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
response.items.forEach((ep) => {
|
|
57
|
+
table.addRow({
|
|
58
|
+
operation: ep.operation,
|
|
59
|
+
method: ep.method,
|
|
60
|
+
path: ep.path,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
table.printTable();
|
|
64
|
+
const showing = Math.min(response.pagination.limit, response.items.length);
|
|
65
|
+
if (response.pagination.has_more) {
|
|
66
|
+
const nextOffset = response.pagination.offset + response.pagination.limit;
|
|
67
|
+
console.log(`\nShowing ${showing} of ${response.pagination.total_count} operations. ` +
|
|
68
|
+
chalk.dim(`Use --offset ${nextOffset} to see more.`));
|
|
69
|
+
}
|
|
70
|
+
else if (response.pagination.total_count > showing) {
|
|
71
|
+
console.log(chalk.dim(`\nShowing ${showing} of ${response.pagination.total_count} operations`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const formattedError = handleAxiosError(error);
|
|
77
|
+
output.error(`Failed to list operations: ${formattedError.details}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return cmd;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
6
|
+
import { getAuthToken } from '../../lib/auth.js';
|
|
7
|
+
import { handleAxiosError } from '../../lib/errors.js';
|
|
8
|
+
import { getOutputMode } from '../../lib/output-mode.js';
|
|
9
|
+
import { createOutputWriter } from '../../lib/output.js';
|
|
10
|
+
function formatUpdatedIntegration(integration) {
|
|
11
|
+
console.log(chalk.green('Integration updated successfully'));
|
|
12
|
+
console.log();
|
|
13
|
+
console.log(` ${'Name'.padEnd(15)}${integration.name}`);
|
|
14
|
+
console.log(` ${'Description'.padEnd(15)}${integration.description || chalk.dim('—')}`);
|
|
15
|
+
console.log(` ${'Visibility'.padEnd(15)}${integration.is_public ? 'public' : 'internal'}`);
|
|
16
|
+
console.log(` ${'Owner'.padEnd(15)}${integration.owner?.name || chalk.dim('—')}`);
|
|
17
|
+
console.log(` ${'Base URL'.padEnd(15)}${integration.protocol_config.base_url}`);
|
|
18
|
+
const scheme = integration.auth_config.auth_scheme === 'API_KEY' ? 'API Key' : 'OAuth 2.0';
|
|
19
|
+
console.log(` ${'Auth Scheme'.padEnd(15)}${scheme}`);
|
|
20
|
+
if (integration.auth_config.token_header_template) {
|
|
21
|
+
console.log(` ${'Header'.padEnd(15)}${integration.auth_config.token_header_template}`);
|
|
22
|
+
}
|
|
23
|
+
if (integration.webhook_config) {
|
|
24
|
+
console.log(` ${'Webhooks'.padEnd(15)}Enabled`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.log(` ${'Webhooks'.padEnd(15)}${chalk.dim('Not configured')}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function createIntegrationUpdateCommand() {
|
|
31
|
+
const cmd = new Command('update');
|
|
32
|
+
cmd
|
|
33
|
+
.description('Update an integration')
|
|
34
|
+
.argument('<id_or_name>', 'Integration ID or name')
|
|
35
|
+
.option('--description <text>', 'Update description')
|
|
36
|
+
.option('--base-url <url>', 'Update REST base URL')
|
|
37
|
+
.option('--public', 'Make integration public')
|
|
38
|
+
.option('--no-public', 'Make integration private')
|
|
39
|
+
.option('--header-template <template>', 'Update API Key header template')
|
|
40
|
+
.option('--install-url <url>', 'Update OAuth authorization URL')
|
|
41
|
+
.option('--token-url <url>', 'Update OAuth token URL')
|
|
42
|
+
.option('--token-content-type <type>', 'Update OAuth token request content type')
|
|
43
|
+
.option('--client-secret <secret>', 'Update OAuth client secret')
|
|
44
|
+
.option('--webhook-events <events>', 'Update webhook events as JSON')
|
|
45
|
+
.action(async (identifier, options) => {
|
|
46
|
+
const output = createOutputWriter();
|
|
47
|
+
try {
|
|
48
|
+
const token = await getAuthToken();
|
|
49
|
+
if (!token) {
|
|
50
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
const client = new GuildAPIClient();
|
|
54
|
+
// Build partial update body
|
|
55
|
+
const body = {};
|
|
56
|
+
let hasUpdates = false;
|
|
57
|
+
if (options.description !== undefined) {
|
|
58
|
+
body.description = options.description;
|
|
59
|
+
hasUpdates = true;
|
|
60
|
+
}
|
|
61
|
+
if (options.public !== undefined) {
|
|
62
|
+
body.is_public = options.public;
|
|
63
|
+
hasUpdates = true;
|
|
64
|
+
}
|
|
65
|
+
if (options.baseUrl !== undefined) {
|
|
66
|
+
body.protocol_config = { base_url: options.baseUrl };
|
|
67
|
+
hasUpdates = true;
|
|
68
|
+
}
|
|
69
|
+
// Auth config updates need the discriminator
|
|
70
|
+
const hasAuthUpdate = options.headerTemplate !== undefined ||
|
|
71
|
+
options.installUrl !== undefined ||
|
|
72
|
+
options.tokenUrl !== undefined ||
|
|
73
|
+
options.tokenContentType !== undefined ||
|
|
74
|
+
options.clientSecret !== undefined;
|
|
75
|
+
if (hasAuthUpdate) {
|
|
76
|
+
// Fetch integration to determine current auth scheme
|
|
77
|
+
const current = await client.get(`/integrations/${identifier}`);
|
|
78
|
+
const scheme = current.auth_config.auth_scheme;
|
|
79
|
+
if (scheme === 'API_KEY') {
|
|
80
|
+
const authConfig = {
|
|
81
|
+
auth_scheme: 'API_KEY',
|
|
82
|
+
};
|
|
83
|
+
if (options.headerTemplate !== undefined) {
|
|
84
|
+
authConfig.token_header_template = options.headerTemplate;
|
|
85
|
+
}
|
|
86
|
+
body.auth_config = authConfig;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const authConfig = {
|
|
90
|
+
auth_scheme: 'OAUTH',
|
|
91
|
+
};
|
|
92
|
+
if (options.installUrl !== undefined) {
|
|
93
|
+
authConfig.install_url = options.installUrl;
|
|
94
|
+
}
|
|
95
|
+
if (options.tokenUrl !== undefined) {
|
|
96
|
+
authConfig.token_url = options.tokenUrl;
|
|
97
|
+
}
|
|
98
|
+
if (options.tokenContentType !== undefined) {
|
|
99
|
+
authConfig.token_url_content_type = options.tokenContentType;
|
|
100
|
+
}
|
|
101
|
+
if (options.clientSecret !== undefined) {
|
|
102
|
+
authConfig.client_secret = options.clientSecret;
|
|
103
|
+
}
|
|
104
|
+
body.auth_config = authConfig;
|
|
105
|
+
}
|
|
106
|
+
hasUpdates = true;
|
|
107
|
+
}
|
|
108
|
+
if (options.webhookEvents !== undefined) {
|
|
109
|
+
try {
|
|
110
|
+
const events = JSON.parse(options.webhookEvents);
|
|
111
|
+
body.webhook_config = { events };
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
output.error(`Error: Invalid JSON for --webhook-events: ${options.webhookEvents}`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
hasUpdates = true;
|
|
118
|
+
}
|
|
119
|
+
if (!hasUpdates) {
|
|
120
|
+
output.error('Error: No update options provided. Use --help to see available options.');
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
const response = await client.patch(`/integrations/${identifier}`, body);
|
|
124
|
+
if (getOutputMode() === 'json') {
|
|
125
|
+
output.data(response);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
formatUpdatedIntegration(response);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
const formattedError = handleAxiosError(error);
|
|
133
|
+
output.error(`Failed to update integration: ${formattedError.details}`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return cmd;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
6
|
+
import { getAuthToken } from '../../../lib/auth.js';
|
|
7
|
+
import { handleAxiosError } from '../../../lib/errors.js';
|
|
8
|
+
import { getOutputMode } from '../../../lib/output-mode.js';
|
|
9
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
10
|
+
import { createSpinner } from '../../../lib/progress.js';
|
|
11
|
+
import { resolveLatestDraftId } from '../../../lib/integration-helpers.js';
|
|
12
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
13
|
+
export function createIntegrationVersionBuildCommand() {
|
|
14
|
+
const cmd = new Command('build');
|
|
15
|
+
cmd
|
|
16
|
+
.description('Build (validate) a draft version')
|
|
17
|
+
.argument('<id_or_name>', 'Integration name (owner~name, defaults to latest draft) or version UUID')
|
|
18
|
+
.requiredOption('--version-number <semver>', 'Semantic version number to assign, e.g. 1.0.0')
|
|
19
|
+
.action(async (identifier, options) => {
|
|
20
|
+
const output = createOutputWriter();
|
|
21
|
+
try {
|
|
22
|
+
const token = await getAuthToken();
|
|
23
|
+
if (!token) {
|
|
24
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const client = new GuildAPIClient();
|
|
28
|
+
// Resolve version ID: UUID directly, or owner~name → latest draft
|
|
29
|
+
let versionId;
|
|
30
|
+
if (UUID_REGEX.test(identifier)) {
|
|
31
|
+
versionId = identifier;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
versionId = await resolveLatestDraftId(client, identifier);
|
|
35
|
+
}
|
|
36
|
+
const buildResponse = await client.post(`/integration_versions/${versionId}/build`, {
|
|
37
|
+
version_number: options.versionNumber,
|
|
38
|
+
});
|
|
39
|
+
if (getOutputMode() === 'json') {
|
|
40
|
+
output.data(buildResponse);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// Poll until build completes
|
|
44
|
+
const spinner = createSpinner(`Building version ${options.versionNumber}...`);
|
|
45
|
+
spinner.start();
|
|
46
|
+
const maxAttempts = 60;
|
|
47
|
+
let attempt = 0;
|
|
48
|
+
let finalVersion = null;
|
|
49
|
+
while (attempt < maxAttempts) {
|
|
50
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
51
|
+
attempt++;
|
|
52
|
+
const version = await client.get(`/integration_versions/${versionId}`);
|
|
53
|
+
if (version.validation_status === 'PASSED' ||
|
|
54
|
+
version.validation_status === 'FAILED') {
|
|
55
|
+
finalVersion = version;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
spinner.text = `Building version ${options.versionNumber}... (${attempt}/${maxAttempts})`;
|
|
59
|
+
}
|
|
60
|
+
if (!finalVersion) {
|
|
61
|
+
spinner.fail('Build timed out');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
if (finalVersion.validation_status === 'PASSED') {
|
|
65
|
+
spinner.succeed('Build passed');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
spinner.fail('Build failed');
|
|
69
|
+
}
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(` ${'Version ID'.padEnd(17)}${finalVersion.id}`);
|
|
72
|
+
console.log(` ${'Version Number'.padEnd(17)}${finalVersion.version_number || chalk.dim('—')}`);
|
|
73
|
+
console.log(` ${'Status'.padEnd(17)}${finalVersion.validation_status === 'PASSED' ? 'Valid' : 'Failed'}`);
|
|
74
|
+
if (finalVersion.validation_status === 'FAILED') {
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const formattedError = handleAxiosError(error);
|
|
80
|
+
output.error(`Failed to build version: ${formattedError.details}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return cmd;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
6
|
+
import { getAuthToken } from '../../../lib/auth.js';
|
|
7
|
+
import { handleAxiosError } from '../../../lib/errors.js';
|
|
8
|
+
import { getOutputMode } from '../../../lib/output-mode.js';
|
|
9
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
10
|
+
export function createIntegrationVersionCreateCommand() {
|
|
11
|
+
const cmd = new Command('create');
|
|
12
|
+
cmd
|
|
13
|
+
.description('Create a new draft version')
|
|
14
|
+
.argument('<id_or_name>', 'Integration ID or name')
|
|
15
|
+
.action(async (identifier) => {
|
|
16
|
+
const output = createOutputWriter();
|
|
17
|
+
try {
|
|
18
|
+
const token = await getAuthToken();
|
|
19
|
+
if (!token) {
|
|
20
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const client = new GuildAPIClient();
|
|
24
|
+
const response = await client.post(`/integrations/${identifier}/versions`, {});
|
|
25
|
+
if (getOutputMode() === 'json') {
|
|
26
|
+
output.data(response);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(chalk.green('Version created successfully'));
|
|
30
|
+
console.log();
|
|
31
|
+
console.log(` ${'Version ID'.padEnd(15)}${response.id}`);
|
|
32
|
+
console.log(` ${'Status'.padEnd(15)}Draft`);
|
|
33
|
+
console.log(` ${'Author'.padEnd(15)}${response.author?.name || chalk.dim('—')}`);
|
|
34
|
+
console.log(` ${'Created'.padEnd(15)}just now`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const formattedError = handleAxiosError(error);
|
|
39
|
+
output.error(`Failed to create version: ${formattedError.details}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return cmd;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
6
|
+
import { getAuthToken } from '../../../lib/auth.js';
|
|
7
|
+
import { handleAxiosError } from '../../../lib/errors.js';
|
|
8
|
+
import { getOutputMode } from '../../../lib/output-mode.js';
|
|
9
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
10
|
+
import { resolveVersionId } from '../../../lib/integration-helpers.js';
|
|
11
|
+
function formatDate(dateStr) {
|
|
12
|
+
return new Date(dateStr).toLocaleString('en-US', {
|
|
13
|
+
month: 'short',
|
|
14
|
+
day: 'numeric',
|
|
15
|
+
year: 'numeric',
|
|
16
|
+
hour: 'numeric',
|
|
17
|
+
minute: '2-digit',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function formatValidationStatus(status) {
|
|
21
|
+
switch (status) {
|
|
22
|
+
case 'PASSED':
|
|
23
|
+
return 'Valid';
|
|
24
|
+
case 'FAILED':
|
|
25
|
+
return 'Failed';
|
|
26
|
+
case 'RUNNING':
|
|
27
|
+
return 'Building';
|
|
28
|
+
default:
|
|
29
|
+
return '—';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function createIntegrationVersionGetCommand() {
|
|
33
|
+
const cmd = new Command('get');
|
|
34
|
+
cmd
|
|
35
|
+
.description('Get version details')
|
|
36
|
+
.argument('<id_or_name>', 'Integration ID or name (owner~name)')
|
|
37
|
+
.option('--version <semver>', 'Specific version, e.g. 1.0.0')
|
|
38
|
+
.action(async (identifier, options) => {
|
|
39
|
+
const output = createOutputWriter();
|
|
40
|
+
try {
|
|
41
|
+
const token = await getAuthToken();
|
|
42
|
+
if (!token) {
|
|
43
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const client = new GuildAPIClient();
|
|
47
|
+
const versionId = await resolveVersionId(client, identifier, options.version);
|
|
48
|
+
const response = await client.get(`/integration_versions/${versionId}`);
|
|
49
|
+
if (getOutputMode() === 'json') {
|
|
50
|
+
output.data(response);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const versionDisplay = response.version_number || 'Draft';
|
|
54
|
+
const integrationName = response.integration?.name || identifier;
|
|
55
|
+
console.log(chalk.bold(`${integrationName} - ${versionDisplay}`));
|
|
56
|
+
console.log();
|
|
57
|
+
console.log(` ${'Status'.padEnd(15)}${formatValidationStatus(response.validation_status)}`);
|
|
58
|
+
console.log(` ${'Author'.padEnd(15)}${response.author?.name || chalk.dim('—')}`);
|
|
59
|
+
console.log(` ${'Published'.padEnd(15)}${response.published_at ? formatDate(response.published_at) : chalk.dim('—')}`);
|
|
60
|
+
console.log(` ${'Created'.padEnd(15)}${formatDate(response.created_at)}`);
|
|
61
|
+
console.log(` ${'Last Updated'.padEnd(15)}${formatDate(response.updated_at)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const formattedError = handleAxiosError(error);
|
|
66
|
+
output.error(`Failed to get version: ${formattedError.details}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return cmd;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
5
|
+
import { getAuthToken } from '../../../lib/auth.js';
|
|
6
|
+
import { handleAxiosError } from '../../../lib/errors.js';
|
|
7
|
+
import { getOutputMode } from '../../../lib/output-mode.js';
|
|
8
|
+
import { createOutputWriter, formatIntegrationVersionTable, } from '../../../lib/output.js';
|
|
9
|
+
export function createIntegrationVersionListCommand() {
|
|
10
|
+
const cmd = new Command('list');
|
|
11
|
+
cmd
|
|
12
|
+
.description('List integration versions')
|
|
13
|
+
.argument('<id_or_name>', 'Integration ID or name')
|
|
14
|
+
.option('--limit <number>', 'Number of results to return', '20')
|
|
15
|
+
.option('--offset <number>', 'Offset for pagination', '0')
|
|
16
|
+
.action(async (identifier, options) => {
|
|
17
|
+
const output = createOutputWriter();
|
|
18
|
+
try {
|
|
19
|
+
const token = await getAuthToken();
|
|
20
|
+
if (!token) {
|
|
21
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const client = new GuildAPIClient();
|
|
25
|
+
const params = new URLSearchParams();
|
|
26
|
+
params.append('limit', options.limit);
|
|
27
|
+
params.append('offset', options.offset);
|
|
28
|
+
const response = await client.get(`/integrations/${identifier}/versions?${params.toString()}`);
|
|
29
|
+
if (getOutputMode() === 'json') {
|
|
30
|
+
output.data(response);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
formatIntegrationVersionTable(response.items, response.pagination, identifier);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const formattedError = handleAxiosError(error);
|
|
38
|
+
output.error(`Failed to list versions: ${formattedError.details}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return cmd;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
6
|
+
import { getAuthToken } from '../../../lib/auth.js';
|
|
7
|
+
import { handleAxiosError } from '../../../lib/errors.js';
|
|
8
|
+
import { getOutputMode } from '../../../lib/output-mode.js';
|
|
9
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
10
|
+
import { createSpinner } from '../../../lib/progress.js';
|
|
11
|
+
import { resolveVersionId } from '../../../lib/integration-helpers.js';
|
|
12
|
+
function formatDate(dateStr) {
|
|
13
|
+
return new Date(dateStr).toLocaleString('en-US', {
|
|
14
|
+
month: 'short',
|
|
15
|
+
day: 'numeric',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
hour: 'numeric',
|
|
18
|
+
minute: '2-digit',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function createIntegrationVersionPublishCommand() {
|
|
22
|
+
const cmd = new Command('publish');
|
|
23
|
+
cmd
|
|
24
|
+
.description('Publish a built version')
|
|
25
|
+
.argument('<id_or_name>', 'Integration ID or name (owner~name)')
|
|
26
|
+
.option('--version <semver>', 'Specific version to publish, e.g. 1.0.0')
|
|
27
|
+
.action(async (identifier, options) => {
|
|
28
|
+
const output = createOutputWriter();
|
|
29
|
+
try {
|
|
30
|
+
const token = await getAuthToken();
|
|
31
|
+
if (!token) {
|
|
32
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
const client = new GuildAPIClient();
|
|
36
|
+
const versionId = await resolveVersionId(client, identifier, options.version);
|
|
37
|
+
// Get current version info for display
|
|
38
|
+
const currentVersion = await client.get(`/integration_versions/${versionId}`);
|
|
39
|
+
const versionDisplay = currentVersion.version_number || versionId;
|
|
40
|
+
const publishResponse = await client.post(`/integration_versions/${versionId}/publish`, {});
|
|
41
|
+
if (getOutputMode() === 'json') {
|
|
42
|
+
output.data(publishResponse);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Poll until published
|
|
46
|
+
const spinner = createSpinner(`Publishing version ${versionDisplay}...`);
|
|
47
|
+
spinner.start();
|
|
48
|
+
const maxAttempts = 60;
|
|
49
|
+
let attempt = 0;
|
|
50
|
+
let finalVersion = null;
|
|
51
|
+
while (attempt < maxAttempts) {
|
|
52
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
53
|
+
attempt++;
|
|
54
|
+
const version = await client.get(`/integration_versions/${versionId}`);
|
|
55
|
+
if (version.published_at) {
|
|
56
|
+
finalVersion = version;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
spinner.text = `Publishing version ${versionDisplay}... (${attempt}/${maxAttempts})`;
|
|
60
|
+
}
|
|
61
|
+
if (!finalVersion) {
|
|
62
|
+
spinner.fail('Publish timed out');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
spinner.succeed('Version published');
|
|
66
|
+
console.log();
|
|
67
|
+
console.log(` ${'Version ID'.padEnd(17)}${finalVersion.id}`);
|
|
68
|
+
console.log(` ${'Version Number'.padEnd(17)}${finalVersion.version_number || chalk.dim('—')}`);
|
|
69
|
+
console.log(` ${'Published'.padEnd(17)}${formatDate(finalVersion.published_at)}`);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const formattedError = handleAxiosError(error);
|
|
73
|
+
output.error(`Failed to publish version: ${formattedError.details}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return cmd;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=publish.js.map
|