@guildai/cli 0.3.16 → 0.3.17
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/commands/agent/clone.js +21 -40
- package/dist/commands/agent/code.js +12 -32
- package/dist/commands/agent/create.js +14 -30
- package/dist/commands/agent/fork.js +27 -73
- package/dist/commands/agent/get.js +5 -4
- package/dist/commands/agent/grep.js +7 -9
- package/dist/commands/agent/init.js +2 -0
- package/dist/commands/agent/list.js +5 -12
- package/dist/commands/agent/publish.js +27 -44
- package/dist/commands/agent/pull.js +8 -35
- package/dist/commands/agent/revalidate.js +8 -16
- package/dist/commands/agent/save.js +23 -74
- package/dist/commands/agent/search.js +5 -12
- package/dist/commands/agent/tags/add.js +14 -24
- package/dist/commands/agent/tags/list.js +12 -23
- package/dist/commands/agent/tags/remove.js +16 -27
- package/dist/commands/agent/tags/set.js +14 -19
- package/dist/commands/agent/unpublish.js +12 -17
- package/dist/commands/agent/update.js +12 -29
- package/dist/commands/agent/versions.js +7 -11
- package/dist/commands/auth/login.js +4 -2
- package/dist/commands/auth/logout.js +3 -1
- package/dist/commands/auth/status.js +4 -3
- package/dist/commands/auth/token.js +3 -2
- package/dist/commands/config/get.js +7 -9
- package/dist/commands/config/list.js +13 -11
- package/dist/commands/config/path.js +6 -4
- package/dist/commands/config/set.js +17 -22
- package/dist/commands/doctor.js +9 -7
- package/dist/commands/session/create.js +7 -5
- package/dist/commands/session/events.js +5 -3
- package/dist/commands/session/get.js +5 -3
- package/dist/commands/session/list.js +5 -4
- package/dist/commands/session/send.js +7 -5
- package/dist/commands/session/tasks.js +5 -3
- package/dist/commands/setup.js +15 -14
- package/dist/commands/trigger/activate.js +7 -6
- package/dist/commands/trigger/create.js +16 -15
- package/dist/commands/trigger/deactivate.js +7 -6
- package/dist/commands/trigger/get.js +5 -4
- package/dist/commands/trigger/list.js +5 -5
- package/dist/commands/trigger/sessions.js +7 -6
- package/dist/commands/trigger/update.js +11 -10
- package/dist/commands/version.js +7 -5
- package/dist/commands/workspace/agent/add.js +16 -22
- package/dist/commands/workspace/agent/list.js +9 -30
- package/dist/commands/workspace/agent/remove.js +9 -15
- package/dist/commands/workspace/context/edit.js +13 -27
- package/dist/commands/workspace/context/get.js +8 -14
- package/dist/commands/workspace/context/list.js +7 -38
- package/dist/commands/workspace/context/publish.js +7 -11
- package/dist/commands/workspace/create.js +7 -11
- package/dist/commands/workspace/current.js +19 -31
- package/dist/commands/workspace/get.js +7 -11
- package/dist/commands/workspace/list.js +5 -8
- package/dist/commands/workspace/select.js +17 -22
- package/dist/lib/output.js +4 -4
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import { join } from 'path';
|
|
|
6
6
|
import { tmpdir } from 'os';
|
|
7
7
|
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
8
8
|
import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
|
|
9
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
9
10
|
export function createWorkspaceContextEditCommand() {
|
|
10
11
|
const cmd = new Command('edit');
|
|
11
12
|
cmd
|
|
@@ -13,6 +14,7 @@ export function createWorkspaceContextEditCommand() {
|
|
|
13
14
|
.argument('<workspace>', 'Workspace ID or full name (e.g., owner/workspace-name)')
|
|
14
15
|
.option('--from <context-id>', 'Edit from a specific context version')
|
|
15
16
|
.action(async (workspaceId, options) => {
|
|
17
|
+
const output = createOutputWriter();
|
|
16
18
|
let tempDir = null;
|
|
17
19
|
try {
|
|
18
20
|
const client = new GuildAPIClient();
|
|
@@ -25,9 +27,7 @@ export function createWorkspaceContextEditCommand() {
|
|
|
25
27
|
// Edit from specific context version
|
|
26
28
|
sourceContext = contexts.find((ctx) => ctx.id === options.from) || null;
|
|
27
29
|
if (!sourceContext) {
|
|
28
|
-
|
|
29
|
-
console.error('');
|
|
30
|
-
console.error(`Run: guild workspace context list ${workspaceId}`);
|
|
30
|
+
output.error(`Context not found: ${options.from}`, `Run: guild workspace context list ${workspaceId}`);
|
|
31
31
|
process.exit(1);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -38,12 +38,7 @@ export function createWorkspaceContextEditCommand() {
|
|
|
38
38
|
// Get the editor from environment
|
|
39
39
|
const editor = process.env.EDITOR || process.env.VISUAL || process.env.GIT_EDITOR;
|
|
40
40
|
if (!editor) {
|
|
41
|
-
|
|
42
|
-
console.error('');
|
|
43
|
-
console.error('Set EDITOR environment variable:');
|
|
44
|
-
console.error(' export EDITOR=vim');
|
|
45
|
-
console.error(' # or');
|
|
46
|
-
console.error(' export EDITOR="code --wait"');
|
|
41
|
+
output.error('No editor configured', 'Set EDITOR environment variable:\n export EDITOR=vim\n # or\n export EDITOR="code --wait"');
|
|
47
42
|
process.exit(1);
|
|
48
43
|
}
|
|
49
44
|
// Create temp file with current context content
|
|
@@ -51,7 +46,7 @@ export function createWorkspaceContextEditCommand() {
|
|
|
51
46
|
const tempFile = join(tempDir, 'workspace.md');
|
|
52
47
|
const currentContent = sourceContext?.manual_context || '';
|
|
53
48
|
writeFileSync(tempFile, currentContent, 'utf-8');
|
|
54
|
-
|
|
49
|
+
output.progress('Opening editor...');
|
|
55
50
|
// Open editor
|
|
56
51
|
const result = spawnSync(editor, [tempFile], {
|
|
57
52
|
stdio: 'inherit',
|
|
@@ -68,39 +63,30 @@ export function createWorkspaceContextEditCommand() {
|
|
|
68
63
|
context: editedContent,
|
|
69
64
|
summary: null,
|
|
70
65
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.log(` guild workspace context publish ${workspaceId} ${newContext.id}`);
|
|
66
|
+
output.success(`Draft context created: ${newContext.id}`, {
|
|
67
|
+
publish: `guild workspace context publish ${workspaceId} ${newContext.id}`,
|
|
68
|
+
});
|
|
75
69
|
}
|
|
76
70
|
catch (error) {
|
|
77
71
|
const formattedError = handleAxiosError(error);
|
|
78
72
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
79
|
-
|
|
80
|
-
console.error('');
|
|
81
|
-
console.error('Run: guild auth login');
|
|
73
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
82
74
|
process.exit(1);
|
|
83
75
|
}
|
|
84
76
|
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
85
77
|
if (options.from) {
|
|
86
|
-
|
|
87
|
-
console.error('');
|
|
88
|
-
console.error(`Run: guild workspace context list ${workspaceId}`);
|
|
78
|
+
output.error(`Context not found: ${options.from}`, `Run: guild workspace context list ${workspaceId}`);
|
|
89
79
|
}
|
|
90
80
|
else {
|
|
91
|
-
|
|
92
|
-
console.error('');
|
|
93
|
-
console.error('Run: guild workspace list');
|
|
81
|
+
output.error(`Workspace not found: ${workspaceId}`, 'Run: guild workspace list');
|
|
94
82
|
}
|
|
95
83
|
process.exit(1);
|
|
96
84
|
}
|
|
97
85
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
98
|
-
|
|
99
|
-
console.error('');
|
|
100
|
-
console.error('Run with --debug for more details');
|
|
86
|
+
output.error(`Failed to edit context: ${formattedError.details}`, 'Run with --debug for more details');
|
|
101
87
|
process.exit(1);
|
|
102
88
|
}
|
|
103
|
-
|
|
89
|
+
output.error(`Failed to edit context: ${formattedError.details}`);
|
|
104
90
|
process.exit(1);
|
|
105
91
|
}
|
|
106
92
|
finally {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
4
4
|
import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
|
|
5
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
5
6
|
export function createWorkspaceContextGetCommand() {
|
|
6
7
|
const cmd = new Command('get');
|
|
7
8
|
cmd
|
|
@@ -9,6 +10,7 @@ export function createWorkspaceContextGetCommand() {
|
|
|
9
10
|
.argument('<workspace>', 'Workspace ID or full name (e.g., owner/workspace-name)')
|
|
10
11
|
.argument('<context-id>', 'Context ID')
|
|
11
12
|
.action(async (workspaceId, contextId) => {
|
|
13
|
+
const output = createOutputWriter();
|
|
12
14
|
try {
|
|
13
15
|
const client = new GuildAPIClient();
|
|
14
16
|
// Backend doesn't have GET endpoint for individual context
|
|
@@ -16,34 +18,26 @@ export function createWorkspaceContextGetCommand() {
|
|
|
16
18
|
const response = await client.get(`/workspaces/${workspaceId}/contexts`);
|
|
17
19
|
const context = response.items.find((ctx) => ctx.id === contextId);
|
|
18
20
|
if (!context) {
|
|
19
|
-
|
|
20
|
-
console.error('');
|
|
21
|
-
console.error(`Run: guild workspace context list ${workspaceId}`);
|
|
21
|
+
output.error(`Context not found: ${contextId}`, `Run: guild workspace context list ${workspaceId}`);
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
output.data(context);
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
27
27
|
const formattedError = handleAxiosError(error);
|
|
28
28
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
29
|
-
|
|
30
|
-
console.error('');
|
|
31
|
-
console.error('Run: guild auth login');
|
|
29
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
32
30
|
process.exit(1);
|
|
33
31
|
}
|
|
34
32
|
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
35
|
-
|
|
36
|
-
console.error('');
|
|
37
|
-
console.error(`Run: guild workspace context list ${workspaceId}`);
|
|
33
|
+
output.error(`Context not found: ${contextId}`, `Run: guild workspace context list ${workspaceId}`);
|
|
38
34
|
process.exit(1);
|
|
39
35
|
}
|
|
40
36
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
41
|
-
|
|
42
|
-
console.error('');
|
|
43
|
-
console.error('Run with --debug for more details');
|
|
37
|
+
output.error(`Failed to get context: ${formattedError.details}`, 'Run with --debug for more details');
|
|
44
38
|
process.exit(1);
|
|
45
39
|
}
|
|
46
|
-
|
|
40
|
+
output.error(`Failed to get context: ${formattedError.details}`);
|
|
47
41
|
process.exit(1);
|
|
48
42
|
}
|
|
49
43
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
4
4
|
import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
|
|
5
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
5
6
|
export function createWorkspaceContextListCommand() {
|
|
6
7
|
const cmd = new Command('list');
|
|
7
8
|
cmd
|
|
@@ -10,62 +11,30 @@ export function createWorkspaceContextListCommand() {
|
|
|
10
11
|
.option('--limit <number>', 'Number of results to return', '20')
|
|
11
12
|
.option('--offset <number>', 'Offset for pagination', '0')
|
|
12
13
|
.action(async (workspaceId, options) => {
|
|
14
|
+
const output = createOutputWriter();
|
|
13
15
|
try {
|
|
14
16
|
const client = new GuildAPIClient();
|
|
15
17
|
const params = new URLSearchParams();
|
|
16
18
|
params.append('limit', options.limit);
|
|
17
19
|
params.append('offset', options.offset);
|
|
18
20
|
const response = await client.get(`/workspaces/${workspaceId}/contexts?${params.toString()}`);
|
|
19
|
-
|
|
20
|
-
console.log(`Context Versions for workspace ${workspaceId}:`);
|
|
21
|
-
console.log('');
|
|
22
|
-
if (contexts.length === 0) {
|
|
23
|
-
console.log(`No context versions found for workspace ${workspaceId}`);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// Print table header
|
|
27
|
-
console.log('ID'.padEnd(36) +
|
|
28
|
-
' ' +
|
|
29
|
-
'Status'.padEnd(12) +
|
|
30
|
-
' ' +
|
|
31
|
-
'Summary'.padEnd(20) +
|
|
32
|
-
' ' +
|
|
33
|
-
'Created');
|
|
34
|
-
// Print each context
|
|
35
|
-
contexts.forEach((ctx) => {
|
|
36
|
-
const date = new Date(ctx.created_at).toISOString().split('T')[0];
|
|
37
|
-
const summary = ctx.summary || '';
|
|
38
|
-
const truncatedSummary = summary.length > 17 ? summary.substring(0, 17) : summary;
|
|
39
|
-
console.log(ctx.id.padEnd(36) +
|
|
40
|
-
' ' +
|
|
41
|
-
ctx.status.padEnd(12) +
|
|
42
|
-
' ' +
|
|
43
|
-
truncatedSummary.padEnd(20) +
|
|
44
|
-
' ' +
|
|
45
|
-
date);
|
|
46
|
-
});
|
|
21
|
+
output.data(response);
|
|
47
22
|
}
|
|
48
23
|
catch (error) {
|
|
49
24
|
const formattedError = handleAxiosError(error);
|
|
50
25
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
51
|
-
|
|
52
|
-
console.error('');
|
|
53
|
-
console.error('Run: guild auth login');
|
|
26
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
54
27
|
process.exit(1);
|
|
55
28
|
}
|
|
56
29
|
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
57
|
-
|
|
58
|
-
console.error('');
|
|
59
|
-
console.error('Run: guild workspace list');
|
|
30
|
+
output.error(`Workspace not found: ${workspaceId}`, 'Run: guild workspace list');
|
|
60
31
|
process.exit(1);
|
|
61
32
|
}
|
|
62
33
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
63
|
-
|
|
64
|
-
console.error('');
|
|
65
|
-
console.error('Run with --debug for more details');
|
|
34
|
+
output.error(`Failed to list contexts: ${formattedError.details}`, 'Run with --debug for more details');
|
|
66
35
|
process.exit(1);
|
|
67
36
|
}
|
|
68
|
-
|
|
37
|
+
output.error(`Failed to list contexts: ${formattedError.details}`);
|
|
69
38
|
process.exit(1);
|
|
70
39
|
}
|
|
71
40
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
4
4
|
import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
|
|
5
|
+
import { createOutputWriter } from '../../../lib/output.js';
|
|
5
6
|
export function createWorkspaceContextPublishCommand() {
|
|
6
7
|
const cmd = new Command('publish');
|
|
7
8
|
cmd
|
|
@@ -9,34 +10,29 @@ export function createWorkspaceContextPublishCommand() {
|
|
|
9
10
|
.argument('<workspace>', 'Workspace ID or full name (e.g., owner/workspace-name)')
|
|
10
11
|
.argument('<context-id>', 'Context ID to publish')
|
|
11
12
|
.action(async (workspaceId, contextId) => {
|
|
13
|
+
const output = createOutputWriter();
|
|
12
14
|
try {
|
|
13
15
|
const client = new GuildAPIClient();
|
|
14
16
|
await client.patch(`/workspaces/${workspaceId}/contexts/${contextId}`, {
|
|
15
17
|
status: 'PUBLISHED',
|
|
16
18
|
});
|
|
17
|
-
|
|
19
|
+
output.success(`Context ${contextId} published successfully`);
|
|
18
20
|
}
|
|
19
21
|
catch (error) {
|
|
20
22
|
const formattedError = handleAxiosError(error);
|
|
21
23
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
22
|
-
|
|
23
|
-
console.error('');
|
|
24
|
-
console.error('Run: guild auth login');
|
|
24
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
25
25
|
process.exit(1);
|
|
26
26
|
}
|
|
27
27
|
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
28
|
-
|
|
29
|
-
console.error('');
|
|
30
|
-
console.error(`Run: guild workspace context list ${workspaceId}`);
|
|
28
|
+
output.error(`Context not found: ${contextId}`, `Run: guild workspace context list ${workspaceId}`);
|
|
31
29
|
process.exit(1);
|
|
32
30
|
}
|
|
33
31
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
34
|
-
|
|
35
|
-
console.error('');
|
|
36
|
-
console.error('Run with --debug for more details');
|
|
32
|
+
output.error(`Failed to publish context: ${formattedError.details}`, 'Run with --debug for more details');
|
|
37
33
|
process.exit(1);
|
|
38
34
|
}
|
|
39
|
-
|
|
35
|
+
output.error(`Failed to publish context: ${formattedError.details}`);
|
|
40
36
|
process.exit(1);
|
|
41
37
|
}
|
|
42
38
|
});
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
4
4
|
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
5
|
+
import { createOutputWriter } from '../../lib/output.js';
|
|
5
6
|
export function createWorkspaceCreateCommand() {
|
|
6
7
|
const cmd = new Command('create');
|
|
7
8
|
cmd
|
|
8
9
|
.description('Create a new workspace')
|
|
9
10
|
.argument('<name>', 'Workspace name')
|
|
10
11
|
.action(async (name) => {
|
|
12
|
+
const output = createOutputWriter();
|
|
11
13
|
try {
|
|
12
14
|
const client = new GuildAPIClient();
|
|
13
15
|
// Get current user info to use as workspace owner
|
|
@@ -17,29 +19,23 @@ export function createWorkspaceCreateCommand() {
|
|
|
17
19
|
name,
|
|
18
20
|
owner_id: me.id,
|
|
19
21
|
});
|
|
20
|
-
|
|
22
|
+
output.data(workspace);
|
|
21
23
|
}
|
|
22
24
|
catch (error) {
|
|
23
25
|
const formattedError = handleAxiosError(error);
|
|
24
26
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
25
|
-
|
|
26
|
-
console.error('');
|
|
27
|
-
console.error('Run: guild auth login');
|
|
27
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
30
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
31
|
-
|
|
32
|
-
console.error('');
|
|
33
|
-
console.error('Run with --debug for more details');
|
|
31
|
+
output.error(`Failed to create workspace: ${formattedError.details}`, 'Run with --debug for more details');
|
|
34
32
|
process.exit(1);
|
|
35
33
|
}
|
|
36
34
|
if (formattedError.code === ErrorCodes.BAD_REQUEST) {
|
|
37
|
-
|
|
38
|
-
console.error('');
|
|
39
|
-
console.error('Run with --debug for more details');
|
|
35
|
+
output.error(`Failed to create workspace: ${formattedError.details}`, 'Run with --debug for more details');
|
|
40
36
|
process.exit(1);
|
|
41
37
|
}
|
|
42
|
-
|
|
38
|
+
output.error(`Failed to create workspace: ${formattedError.details}`);
|
|
43
39
|
process.exit(1);
|
|
44
40
|
}
|
|
45
41
|
});
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
// Copyright (c) 2026 Guild.ai All Rights Reserved
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
3
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
5
4
|
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
5
|
+
import { createOutputWriter } from '../../lib/output.js';
|
|
6
6
|
import { getWorkspaceId, loadGlobalConfig } from '../../lib/guild-config.js';
|
|
7
|
-
import { warn } from '../../lib/colors.js';
|
|
8
7
|
export function createWorkspaceCurrentCommand() {
|
|
9
8
|
const cmd = new Command('current');
|
|
10
9
|
cmd.description('Show current default workspace').action(async () => {
|
|
10
|
+
const output = createOutputWriter();
|
|
11
11
|
try {
|
|
12
12
|
// Get configured workspace ID
|
|
13
13
|
const resolved = await getWorkspaceId();
|
|
14
14
|
if (!resolved) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log('Set a default workspace:');
|
|
18
|
-
console.log(chalk.dim(' guild workspace select'));
|
|
15
|
+
output.data({ configured: false, message: 'No default workspace configured.' });
|
|
16
|
+
output.progress('Set a default workspace:\n guild workspace select');
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
19
|
const { workspaceId, source } = resolved;
|
|
22
20
|
// Fetch workspace details from API
|
|
23
21
|
const client = new GuildAPIClient();
|
|
24
22
|
const workspace = await client.get(`/workspaces/${workspaceId}`);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
output.data({
|
|
24
|
+
name: workspace.name,
|
|
25
|
+
id: workspaceId,
|
|
26
|
+
source: source === 'local' ? 'guild.json (local)' : '~/.guild/config.json (global)',
|
|
27
|
+
});
|
|
30
28
|
}
|
|
31
29
|
catch (error) {
|
|
32
30
|
const formattedError = handleAxiosError(error);
|
|
@@ -34,38 +32,28 @@ export function createWorkspaceCurrentCommand() {
|
|
|
34
32
|
// Still show configured workspace ID even if not authenticated
|
|
35
33
|
const globalConfig = await loadGlobalConfig();
|
|
36
34
|
if (globalConfig?.default_workspace) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
console.log(chalk.dim(' guild auth login'));
|
|
35
|
+
output.data({
|
|
36
|
+
id: globalConfig.default_workspace,
|
|
37
|
+
source: '~/.guild/config.json (global)',
|
|
38
|
+
authenticated: false,
|
|
39
|
+
});
|
|
40
|
+
output.progress('Log in to see workspace name:\n guild auth login');
|
|
44
41
|
return;
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
console.error('');
|
|
48
|
-
console.error('Run: guild auth login');
|
|
43
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
49
44
|
process.exit(1);
|
|
50
45
|
}
|
|
51
46
|
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
52
47
|
// Workspace ID is configured but doesn't exist
|
|
53
48
|
const resolved = await getWorkspaceId();
|
|
54
|
-
|
|
55
|
-
console.log('');
|
|
56
|
-
console.log(` ${chalk.bold('ID:')} ${resolved?.workspaceId || 'unknown'}`);
|
|
57
|
-
console.log('');
|
|
58
|
-
console.log('The workspace may have been deleted. Select a new one:');
|
|
59
|
-
console.log(chalk.dim(' guild workspace select'));
|
|
49
|
+
output.error('Configured workspace not found', `ID: ${resolved?.workspaceId || 'unknown'}\n\nThe workspace may have been deleted. Select a new one:\n guild workspace select`);
|
|
60
50
|
return;
|
|
61
51
|
}
|
|
62
52
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
63
|
-
|
|
64
|
-
console.error('');
|
|
65
|
-
console.error('Run with --debug for more details');
|
|
53
|
+
output.error(`Failed to fetch workspace: ${formattedError.details}`, 'Run with --debug for more details');
|
|
66
54
|
process.exit(1);
|
|
67
55
|
}
|
|
68
|
-
|
|
56
|
+
output.error(`Failed to get workspace: ${formattedError.details}`);
|
|
69
57
|
process.exit(1);
|
|
70
58
|
}
|
|
71
59
|
});
|
|
@@ -2,38 +2,34 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
4
4
|
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
5
|
+
import { createOutputWriter } from '../../lib/output.js';
|
|
5
6
|
export function createWorkspaceGetCommand() {
|
|
6
7
|
const cmd = new Command('get');
|
|
7
8
|
cmd
|
|
8
9
|
.description('Get workspace details')
|
|
9
10
|
.argument('<identifier>', 'Workspace ID or full name (e.g., owner/workspace-name)')
|
|
10
11
|
.action(async (id) => {
|
|
12
|
+
const output = createOutputWriter();
|
|
11
13
|
try {
|
|
12
14
|
const client = new GuildAPIClient();
|
|
13
15
|
const workspace = await client.get(`/workspaces/${id}`);
|
|
14
|
-
|
|
16
|
+
output.data(workspace);
|
|
15
17
|
}
|
|
16
18
|
catch (error) {
|
|
17
19
|
const formattedError = handleAxiosError(error);
|
|
18
20
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
19
|
-
|
|
20
|
-
console.error('');
|
|
21
|
-
console.error('Run: guild auth login');
|
|
21
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
25
|
-
|
|
26
|
-
console.error('');
|
|
27
|
-
console.error('Run with --debug for more details');
|
|
25
|
+
output.error(`Failed to get workspace: ${formattedError.details}`, 'Run with --debug for more details');
|
|
28
26
|
process.exit(1);
|
|
29
27
|
}
|
|
30
28
|
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
31
|
-
|
|
32
|
-
console.error('');
|
|
33
|
-
console.error('Run: guild workspace list');
|
|
29
|
+
output.error(`Workspace not found: ${id}`, 'Run: guild workspace list');
|
|
34
30
|
process.exit(1);
|
|
35
31
|
}
|
|
36
|
-
|
|
32
|
+
output.error(`Failed to get workspace: ${formattedError.details}`);
|
|
37
33
|
process.exit(1);
|
|
38
34
|
}
|
|
39
35
|
});
|
|
@@ -3,7 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
4
4
|
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
5
5
|
import { getOutputMode } from '../../lib/output-mode.js';
|
|
6
|
-
import { formatWorkspaceTable } from '../../lib/output.js';
|
|
6
|
+
import { createOutputWriter, formatWorkspaceTable } from '../../lib/output.js';
|
|
7
7
|
export function createWorkspaceListCommand() {
|
|
8
8
|
const cmd = new Command('list');
|
|
9
9
|
cmd
|
|
@@ -11,6 +11,7 @@ export function createWorkspaceListCommand() {
|
|
|
11
11
|
.option('--limit <number>', 'Number of results to return', '20')
|
|
12
12
|
.option('--offset <number>', 'Offset for pagination', '0')
|
|
13
13
|
.action(async (options) => {
|
|
14
|
+
const output = createOutputWriter();
|
|
14
15
|
try {
|
|
15
16
|
const client = new GuildAPIClient();
|
|
16
17
|
const params = new URLSearchParams();
|
|
@@ -29,18 +30,14 @@ export function createWorkspaceListCommand() {
|
|
|
29
30
|
catch (error) {
|
|
30
31
|
const formattedError = handleAxiosError(error);
|
|
31
32
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
32
|
-
|
|
33
|
-
console.error('');
|
|
34
|
-
console.error('Run: guild auth login');
|
|
33
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
35
34
|
process.exit(1);
|
|
36
35
|
}
|
|
37
36
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
38
|
-
|
|
39
|
-
console.error('');
|
|
40
|
-
console.error('Run with --debug for more details');
|
|
37
|
+
output.error(`Failed to list workspaces: ${formattedError.details}`, 'Run with --debug for more details');
|
|
41
38
|
process.exit(1);
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
output.error(`Failed to list workspaces: ${formattedError.details}`);
|
|
44
41
|
process.exit(1);
|
|
45
42
|
}
|
|
46
43
|
});
|
|
@@ -4,6 +4,7 @@ import * as fs from 'fs/promises';
|
|
|
4
4
|
import * as readline from 'readline';
|
|
5
5
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
6
6
|
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
7
|
+
import { createOutputWriter } from '../../lib/output.js';
|
|
7
8
|
import { isAgentDirectory, loadLocalConfig, getLocalConfigPath, getWorkspaceId, saveGlobalConfig, } from '../../lib/guild-config.js';
|
|
8
9
|
/**
|
|
9
10
|
* Format workspace for display with owner name.
|
|
@@ -23,37 +24,35 @@ export function createWorkspaceSelectCommand() {
|
|
|
23
24
|
.description('Select default workspace for agent testing')
|
|
24
25
|
.argument('[workspace]', 'Workspace name or ID to select directly')
|
|
25
26
|
.action(async (workspaceArg) => {
|
|
27
|
+
const output = createOutputWriter();
|
|
26
28
|
try {
|
|
27
29
|
const client = new GuildAPIClient();
|
|
28
30
|
// Use filter=all to get workspaces from all orgs user is a member of
|
|
29
31
|
const workspaces = await client.get('/me/workspaces?filter=all');
|
|
30
32
|
if (workspaces.items.length === 0) {
|
|
31
|
-
|
|
32
|
-
console.error('');
|
|
33
|
-
console.error('Create a workspace first:');
|
|
34
|
-
console.error(' guild workspace create <name>');
|
|
33
|
+
output.error('No workspaces found.', 'Create a workspace first:\n guild workspace create <name>');
|
|
35
34
|
process.exit(1);
|
|
36
35
|
}
|
|
37
36
|
// If a workspace argument was provided, find and select it directly
|
|
38
37
|
if (workspaceArg) {
|
|
39
38
|
const workspace = workspaces.items.find((w) => w.name === workspaceArg ||
|
|
40
39
|
w.name.toLowerCase() === workspaceArg.toLowerCase() ||
|
|
40
|
+
w.full_name === workspaceArg ||
|
|
41
|
+
w.full_name?.toLowerCase() === workspaceArg.toLowerCase() ||
|
|
41
42
|
w.id === workspaceArg);
|
|
42
43
|
if (!workspace) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.error(` - ${formatWorkspaceDisplay(w)}`);
|
|
48
|
-
});
|
|
44
|
+
const available = workspaces.items
|
|
45
|
+
.map((w) => ` - ${formatWorkspaceDisplay(w)}`)
|
|
46
|
+
.join('\n');
|
|
47
|
+
output.error(`Workspace "${workspaceArg}" not found.`, `Available workspaces:\n${available}`);
|
|
49
48
|
process.exit(1);
|
|
50
49
|
}
|
|
51
50
|
const target = await saveWorkspaceConfig(workspace.id, workspace.name);
|
|
52
51
|
if (target === 'local') {
|
|
53
|
-
|
|
52
|
+
output.success(`Workspace set for this agent: ${formatWorkspaceDisplay(workspace)}`);
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
56
|
-
|
|
55
|
+
output.success(`Default workspace set to: ${formatWorkspaceDisplay(workspace)}`);
|
|
57
56
|
}
|
|
58
57
|
return;
|
|
59
58
|
}
|
|
@@ -85,33 +84,29 @@ export function createWorkspaceSelectCommand() {
|
|
|
85
84
|
}
|
|
86
85
|
const selection = parseInt(answer.trim(), 10);
|
|
87
86
|
if (isNaN(selection) || selection < 1 || selection > workspaces.items.length) {
|
|
88
|
-
|
|
87
|
+
output.error('Invalid selection');
|
|
89
88
|
process.exit(1);
|
|
90
89
|
}
|
|
91
90
|
const selectedWorkspace = workspaces.items[selection - 1];
|
|
92
91
|
const target = await saveWorkspaceConfig(selectedWorkspace.id, selectedWorkspace.name);
|
|
93
92
|
if (target === 'local') {
|
|
94
|
-
|
|
93
|
+
output.success(`Workspace set for this agent: ${formatWorkspaceDisplay(selectedWorkspace)}`);
|
|
95
94
|
}
|
|
96
95
|
else {
|
|
97
|
-
|
|
96
|
+
output.success(`Default workspace set to: ${formatWorkspaceDisplay(selectedWorkspace)}`);
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
catch (error) {
|
|
101
100
|
const formattedError = handleAxiosError(error);
|
|
102
101
|
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
103
|
-
|
|
104
|
-
console.error('');
|
|
105
|
-
console.error('Run: guild auth login');
|
|
102
|
+
output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
|
|
106
103
|
process.exit(1);
|
|
107
104
|
}
|
|
108
105
|
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
109
|
-
|
|
110
|
-
console.error('');
|
|
111
|
-
console.error('Run with --debug for more details');
|
|
106
|
+
output.error(`Failed to fetch workspaces: ${formattedError.details}`, 'Run with --debug for more details');
|
|
112
107
|
process.exit(1);
|
|
113
108
|
}
|
|
114
|
-
|
|
109
|
+
output.error(`Failed to select workspace: ${formattedError.details}`);
|
|
115
110
|
process.exit(1);
|
|
116
111
|
}
|
|
117
112
|
});
|
package/dist/lib/output.js
CHANGED
|
@@ -217,10 +217,10 @@ export class HumanOutputWriter {
|
|
|
217
217
|
Array.isArray(value.items));
|
|
218
218
|
}
|
|
219
219
|
success(message, details) {
|
|
220
|
-
|
|
220
|
+
process.stderr.write(chalk.green('✓') + ' ' + message + '\n');
|
|
221
221
|
if (details) {
|
|
222
222
|
Object.entries(details).forEach(([k, v]) => {
|
|
223
|
-
|
|
223
|
+
process.stderr.write(` ${k}: ${brand(String(v))}\n`);
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
}
|
|
@@ -253,10 +253,10 @@ export class JSONOutputWriter {
|
|
|
253
253
|
console.log(JSON.stringify(value, null, 2));
|
|
254
254
|
}
|
|
255
255
|
success(message, details) {
|
|
256
|
-
|
|
256
|
+
process.stderr.write(JSON.stringify({ success: true, message, ...details }) + '\n');
|
|
257
257
|
}
|
|
258
258
|
error(message, details) {
|
|
259
|
-
|
|
259
|
+
process.stderr.write(JSON.stringify({ success: false, error: message, details }) + '\n');
|
|
260
260
|
}
|
|
261
261
|
progress(message) {
|
|
262
262
|
if (!isQuietMode()) {
|