@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.
Files changed (58) hide show
  1. package/dist/commands/agent/clone.js +21 -40
  2. package/dist/commands/agent/code.js +12 -32
  3. package/dist/commands/agent/create.js +14 -30
  4. package/dist/commands/agent/fork.js +27 -73
  5. package/dist/commands/agent/get.js +5 -4
  6. package/dist/commands/agent/grep.js +7 -9
  7. package/dist/commands/agent/init.js +2 -0
  8. package/dist/commands/agent/list.js +5 -12
  9. package/dist/commands/agent/publish.js +27 -44
  10. package/dist/commands/agent/pull.js +8 -35
  11. package/dist/commands/agent/revalidate.js +8 -16
  12. package/dist/commands/agent/save.js +23 -74
  13. package/dist/commands/agent/search.js +5 -12
  14. package/dist/commands/agent/tags/add.js +14 -24
  15. package/dist/commands/agent/tags/list.js +12 -23
  16. package/dist/commands/agent/tags/remove.js +16 -27
  17. package/dist/commands/agent/tags/set.js +14 -19
  18. package/dist/commands/agent/unpublish.js +12 -17
  19. package/dist/commands/agent/update.js +12 -29
  20. package/dist/commands/agent/versions.js +7 -11
  21. package/dist/commands/auth/login.js +4 -2
  22. package/dist/commands/auth/logout.js +3 -1
  23. package/dist/commands/auth/status.js +4 -3
  24. package/dist/commands/auth/token.js +3 -2
  25. package/dist/commands/config/get.js +7 -9
  26. package/dist/commands/config/list.js +13 -11
  27. package/dist/commands/config/path.js +6 -4
  28. package/dist/commands/config/set.js +17 -22
  29. package/dist/commands/doctor.js +9 -7
  30. package/dist/commands/session/create.js +7 -5
  31. package/dist/commands/session/events.js +5 -3
  32. package/dist/commands/session/get.js +5 -3
  33. package/dist/commands/session/list.js +5 -4
  34. package/dist/commands/session/send.js +7 -5
  35. package/dist/commands/session/tasks.js +5 -3
  36. package/dist/commands/setup.js +15 -14
  37. package/dist/commands/trigger/activate.js +7 -6
  38. package/dist/commands/trigger/create.js +16 -15
  39. package/dist/commands/trigger/deactivate.js +7 -6
  40. package/dist/commands/trigger/get.js +5 -4
  41. package/dist/commands/trigger/list.js +5 -5
  42. package/dist/commands/trigger/sessions.js +7 -6
  43. package/dist/commands/trigger/update.js +11 -10
  44. package/dist/commands/version.js +7 -5
  45. package/dist/commands/workspace/agent/add.js +16 -22
  46. package/dist/commands/workspace/agent/list.js +9 -30
  47. package/dist/commands/workspace/agent/remove.js +9 -15
  48. package/dist/commands/workspace/context/edit.js +13 -27
  49. package/dist/commands/workspace/context/get.js +8 -14
  50. package/dist/commands/workspace/context/list.js +7 -38
  51. package/dist/commands/workspace/context/publish.js +7 -11
  52. package/dist/commands/workspace/create.js +7 -11
  53. package/dist/commands/workspace/current.js +19 -31
  54. package/dist/commands/workspace/get.js +7 -11
  55. package/dist/commands/workspace/list.js +5 -8
  56. package/dist/commands/workspace/select.js +17 -22
  57. package/dist/lib/output.js +4 -4
  58. 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
- console.error(`Context not found: ${options.from}`);
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
- console.error('No editor configured');
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
- console.log('Opening editor...');
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
- console.log(`Draft context created: ${newContext.id}`);
72
- console.log('');
73
- console.log('To publish this draft:');
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Context not found: ${options.from}`);
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
- console.error(`Workspace not found: ${workspaceId}`);
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
- console.error(`Failed to edit context: ${formattedError.details}`);
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
- console.error(`Failed to edit context: ${formattedError.details}`);
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
- console.error(`Context not found: ${contextId}`);
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
- console.log(JSON.stringify(context, null, 2));
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Context not found: ${contextId}`);
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
- console.error(`Failed to get context: ${formattedError.details}`);
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
- console.error(`Failed to get context: ${formattedError.details}`);
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
- const contexts = response.items;
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Workspace not found: ${workspaceId}`);
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
- console.error(`Failed to list contexts: ${formattedError.details}`);
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
- console.error(`Failed to list contexts: ${formattedError.details}`);
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
- console.log(`✓ Context ${contextId} published successfully`);
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Context not found: ${contextId}`);
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
- console.error(`Failed to publish context: ${formattedError.details}`);
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
- console.error(`Failed to publish context: ${formattedError.details}`);
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
- console.log(JSON.stringify(workspace, null, 2));
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Failed to create workspace: ${formattedError.details}`);
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
- console.error(`Failed to create workspace: ${formattedError.details}`);
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
- console.error(`Failed to create workspace: ${formattedError.details}`);
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
- console.log(warn('No default workspace configured.'));
16
- console.log('');
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
- console.log(chalk.green('Current workspace:'));
26
- console.log('');
27
- console.log(` ${chalk.bold('Name:')} ${workspace.name}`);
28
- console.log(` ${chalk.bold('ID:')} ${workspaceId}`);
29
- console.log(` ${chalk.bold('Source:')} ${source === 'local' ? 'guild.json (local)' : '~/.guild/config.json (global)'}`);
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
- console.log(warn('Current workspace (not authenticated):'));
38
- console.log('');
39
- console.log(` ${chalk.bold('ID:')} ${globalConfig.default_workspace}`);
40
- console.log(` ${chalk.bold('Source:')} ~/.guild/config.json (global)`);
41
- console.log('');
42
- console.log(chalk.dim('Log in to see workspace name:'));
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
- console.error('Not authenticated. Please log in first.');
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
- console.log(warn('Configured workspace not found:'));
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
- console.error(`Failed to fetch workspace: ${formattedError.details}`);
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
- console.error(`Failed to get workspace: ${formattedError.details}`);
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
- console.log(JSON.stringify(workspace, null, 2));
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Failed to get workspace: ${formattedError.details}`);
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
- console.error(`Workspace not found: ${id}`);
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
- console.error(`Failed to get workspace: ${formattedError.details}`);
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Failed to list workspaces: ${formattedError.details}`);
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
- console.error(`Failed to list workspaces: ${formattedError.details}`);
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
- console.error('No workspaces found.');
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
- console.error(`Workspace "${workspaceArg}" not found.`);
44
- console.error('');
45
- console.error('Available workspaces:');
46
- workspaces.items.forEach((w) => {
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
- console.log(`✓ Workspace set for this agent: ${formatWorkspaceDisplay(workspace)}`);
52
+ output.success(`Workspace set for this agent: ${formatWorkspaceDisplay(workspace)}`);
54
53
  }
55
54
  else {
56
- console.log(`✓ Default workspace set to: ${formatWorkspaceDisplay(workspace)}`);
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
- console.error('Invalid selection');
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
- console.log(`✓ Workspace set for this agent: ${formatWorkspaceDisplay(selectedWorkspace)}`);
93
+ output.success(`Workspace set for this agent: ${formatWorkspaceDisplay(selectedWorkspace)}`);
95
94
  }
96
95
  else {
97
- console.log(`✓ Default workspace set to: ${formatWorkspaceDisplay(selectedWorkspace)}`);
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
- console.error('Not authenticated. Please log in first.');
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
- console.error(`Failed to fetch workspaces: ${formattedError.details}`);
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
- console.error(`Failed to select workspace: ${formattedError.details}`);
109
+ output.error(`Failed to select workspace: ${formattedError.details}`);
115
110
  process.exit(1);
116
111
  }
117
112
  });
@@ -217,10 +217,10 @@ export class HumanOutputWriter {
217
217
  Array.isArray(value.items));
218
218
  }
219
219
  success(message, details) {
220
- console.log(chalk.green('✓'), message);
220
+ process.stderr.write(chalk.green('✓') + ' ' + message + '\n');
221
221
  if (details) {
222
222
  Object.entries(details).forEach(([k, v]) => {
223
- console.log(` ${k}: ${brand(String(v))}`);
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
- this.data({ success: true, message, ...details });
256
+ process.stderr.write(JSON.stringify({ success: true, message, ...details }) + '\n');
257
257
  }
258
258
  error(message, details) {
259
- this.data({ success: false, error: message, details });
259
+ process.stderr.write(JSON.stringify({ success: false, error: message, details }) + '\n');
260
260
  }
261
261
  progress(message) {
262
262
  if (!isQuietMode()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guildai/cli",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "Guild.ai CLI - Build, test, and deploy AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",