@guildai/cli 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/auth-CRMO5O3N.js +29 -0
  2. package/dist/auth-CRMO5O3N.js.map +7 -0
  3. package/dist/chat-5VX2WJH2.js +303 -0
  4. package/dist/chat-5VX2WJH2.js.map +7 -0
  5. package/dist/chat-SIKDYZQK.js +31 -0
  6. package/dist/chat-SIKDYZQK.js.map +7 -0
  7. package/dist/chunk-56YCMGL3.js +522 -0
  8. package/dist/chunk-56YCMGL3.js.map +7 -0
  9. package/dist/chunk-6EX6E7WP.js +7042 -0
  10. package/dist/chunk-6EX6E7WP.js.map +7 -0
  11. package/dist/chunk-B7VAF5UG.js +532 -0
  12. package/dist/chunk-B7VAF5UG.js.map +7 -0
  13. package/dist/chunk-DOIYVBNY.js +3057 -0
  14. package/dist/chunk-DOIYVBNY.js.map +7 -0
  15. package/dist/chunk-ENKEEJ45.js +17 -0
  16. package/dist/chunk-ENKEEJ45.js.map +7 -0
  17. package/dist/chunk-IBRKVGMZ.js +97041 -0
  18. package/dist/chunk-IBRKVGMZ.js.map +7 -0
  19. package/dist/chunk-LFMQJOKC.js +19778 -0
  20. package/dist/chunk-LFMQJOKC.js.map +7 -0
  21. package/dist/chunk-M347HP6M.js +22896 -0
  22. package/dist/chunk-M347HP6M.js.map +7 -0
  23. package/dist/chunk-OYQ476FQ.js +44 -0
  24. package/dist/chunk-OYQ476FQ.js.map +7 -0
  25. package/dist/chunk-PNCUR4OB.js +257 -0
  26. package/dist/chunk-PNCUR4OB.js.map +7 -0
  27. package/dist/chunk-RIG2HZWM.js +317 -0
  28. package/dist/chunk-RIG2HZWM.js.map +7 -0
  29. package/dist/chunk-SPZPZXUN.js +826 -0
  30. package/dist/chunk-SPZPZXUN.js.map +7 -0
  31. package/dist/chunk-VVSOU6ON.js +53 -0
  32. package/dist/chunk-VVSOU6ON.js.map +7 -0
  33. package/dist/chunk-X3ADGWOF.js +3643 -0
  34. package/dist/chunk-X3ADGWOF.js.map +7 -0
  35. package/dist/commands/agent/logs.d.ts +3 -0
  36. package/dist/commands/setup.d.ts +16 -0
  37. package/dist/commands/skill/create.d.ts +3 -0
  38. package/dist/commands/skill/get.d.ts +3 -0
  39. package/dist/commands/skill/list.d.ts +3 -0
  40. package/dist/commands/skill/update.d.ts +3 -0
  41. package/dist/commands/skill/version/create.d.ts +3 -0
  42. package/dist/commands/skill/version/get.d.ts +3 -0
  43. package/dist/commands/skill/version/list.d.ts +3 -0
  44. package/dist/devtools-AO7YSDOD.js +67 -0
  45. package/dist/devtools-AO7YSDOD.js.map +7 -0
  46. package/dist/dist-4CBK6X5H.js +1566 -0
  47. package/dist/dist-4CBK6X5H.js.map +7 -0
  48. package/dist/esm-FRAVZP4J.js +13 -0
  49. package/dist/esm-FRAVZP4J.js.map +7 -0
  50. package/dist/execa-XQMWSABC.js +35 -0
  51. package/dist/execa-XQMWSABC.js.map +7 -0
  52. package/dist/index.js +8231 -253
  53. package/dist/index.js.map +7 -0
  54. package/dist/lib/api-types.d.ts +44 -0
  55. package/dist/lib/auth.d.ts +1 -1
  56. package/dist/lib/config.d.ts +9 -0
  57. package/dist/lib/errors.d.ts +1 -1
  58. package/dist/lib/output-mode.d.ts +9 -2
  59. package/dist/lib/output.d.ts +17 -1
  60. package/dist/lib/session-events.d.ts +14 -3
  61. package/dist/lib/session-polling.d.ts +24 -1
  62. package/dist/lib/session-resume.d.ts +15 -1
  63. package/dist/lib/stdin.d.ts +5 -1
  64. package/dist/lib/websocket-client.d.ts +46 -0
  65. package/dist/open-RF4X5MOP.js +13 -0
  66. package/dist/open-RF4X5MOP.js.map +7 -0
  67. package/dist/server-JYVH64FD.js +27659 -0
  68. package/dist/server-JYVH64FD.js.map +7 -0
  69. package/dist/test-SNIYRJ32.js +692 -0
  70. package/dist/test-SNIYRJ32.js.map +7 -0
  71. package/docs/skills/codex-agent-dev.md +2 -2
  72. package/package.json +8 -12
  73. package/dist/commands/agent/chat.js +0 -278
  74. package/dist/commands/agent/clone.js +0 -116
  75. package/dist/commands/agent/code.js +0 -87
  76. package/dist/commands/agent/fork.js +0 -218
  77. package/dist/commands/agent/get.js +0 -37
  78. package/dist/commands/agent/grep.js +0 -107
  79. package/dist/commands/agent/init.js +0 -390
  80. package/dist/commands/agent/list.js +0 -110
  81. package/dist/commands/agent/owners.js +0 -74
  82. package/dist/commands/agent/publish.js +0 -91
  83. package/dist/commands/agent/pull.js +0 -198
  84. package/dist/commands/agent/revalidate.js +0 -56
  85. package/dist/commands/agent/save.js +0 -346
  86. package/dist/commands/agent/search.js +0 -61
  87. package/dist/commands/agent/tags/add.js +0 -73
  88. package/dist/commands/agent/tags/list.js +0 -43
  89. package/dist/commands/agent/tags/remove.js +0 -84
  90. package/dist/commands/agent/tags/set.js +0 -71
  91. package/dist/commands/agent/test.js +0 -486
  92. package/dist/commands/agent/unpublish.js +0 -64
  93. package/dist/commands/agent/update.js +0 -110
  94. package/dist/commands/agent/versions.js +0 -55
  95. package/dist/commands/agent/workspaces.js +0 -54
  96. package/dist/commands/auth/login.js +0 -33
  97. package/dist/commands/auth/logout.js +0 -24
  98. package/dist/commands/auth/status.js +0 -38
  99. package/dist/commands/auth/token.js +0 -19
  100. package/dist/commands/chat.js +0 -1345
  101. package/dist/commands/config/get.js +0 -64
  102. package/dist/commands/config/list.js +0 -47
  103. package/dist/commands/config/path.js +0 -38
  104. package/dist/commands/config/set.js +0 -132
  105. package/dist/commands/credentials/endpoint-list.js +0 -88
  106. package/dist/commands/credentials/list.js +0 -50
  107. package/dist/commands/credentials/policy-create.js +0 -66
  108. package/dist/commands/credentials/policy-delete.js +0 -33
  109. package/dist/commands/credentials/policy-list.js +0 -45
  110. package/dist/commands/credentials/policy-update.js +0 -66
  111. package/dist/commands/doctor.js +0 -233
  112. package/dist/commands/integration/connect.js +0 -76
  113. package/dist/commands/integration/create.js +0 -298
  114. package/dist/commands/integration/get.js +0 -95
  115. package/dist/commands/integration/list.js +0 -62
  116. package/dist/commands/integration/operation/create.js +0 -164
  117. package/dist/commands/integration/operation/list.js +0 -92
  118. package/dist/commands/integration/update.js +0 -139
  119. package/dist/commands/integration/version/build.js +0 -86
  120. package/dist/commands/integration/version/create.js +0 -45
  121. package/dist/commands/integration/version/get.js +0 -72
  122. package/dist/commands/integration/version/list.js +0 -45
  123. package/dist/commands/integration/version/publish.js +0 -79
  124. package/dist/commands/integration/version/test.js +0 -104
  125. package/dist/commands/job/get-step.js +0 -40
  126. package/dist/commands/job/get.js +0 -44
  127. package/dist/commands/mcp.js +0 -34
  128. package/dist/commands/session/create.js +0 -59
  129. package/dist/commands/session/events.js +0 -56
  130. package/dist/commands/session/get.js +0 -33
  131. package/dist/commands/session/interrupt.js +0 -33
  132. package/dist/commands/session/list.js +0 -59
  133. package/dist/commands/session/send.js +0 -54
  134. package/dist/commands/session/tasks.js +0 -45
  135. package/dist/commands/setup.js +0 -230
  136. package/dist/commands/trigger/activate.js +0 -41
  137. package/dist/commands/trigger/create.js +0 -197
  138. package/dist/commands/trigger/deactivate.js +0 -41
  139. package/dist/commands/trigger/get.js +0 -33
  140. package/dist/commands/trigger/list.js +0 -57
  141. package/dist/commands/trigger/sessions.js +0 -48
  142. package/dist/commands/trigger/update.js +0 -128
  143. package/dist/commands/version.js +0 -24
  144. package/dist/commands/workspace/agent/add.js +0 -114
  145. package/dist/commands/workspace/agent/list.js +0 -78
  146. package/dist/commands/workspace/agent/remove.js +0 -78
  147. package/dist/commands/workspace/clear.js +0 -45
  148. package/dist/commands/workspace/context/edit.js +0 -107
  149. package/dist/commands/workspace/context/get.js +0 -47
  150. package/dist/commands/workspace/context/list.js +0 -51
  151. package/dist/commands/workspace/context/publish.js +0 -42
  152. package/dist/commands/workspace/create.js +0 -51
  153. package/dist/commands/workspace/current.js +0 -63
  154. package/dist/commands/workspace/get.js +0 -39
  155. package/dist/commands/workspace/list.js +0 -70
  156. package/dist/commands/workspace/select.js +0 -184
  157. package/dist/components/AgentInstallPrompt.js +0 -97
  158. package/dist/components/SplashAnimation.js +0 -321
  159. package/dist/components/TaskView.js +0 -268
  160. package/dist/lib/agent-helpers.js +0 -306
  161. package/dist/lib/alternate-screen.js +0 -59
  162. package/dist/lib/api-client.js +0 -154
  163. package/dist/lib/api-types.js +0 -10
  164. package/dist/lib/auth.js +0 -284
  165. package/dist/lib/braille-canvas.js +0 -321
  166. package/dist/lib/colors.js +0 -46
  167. package/dist/lib/config-cache.js +0 -45
  168. package/dist/lib/config.js +0 -153
  169. package/dist/lib/did-you-mean.js +0 -144
  170. package/dist/lib/errors.js +0 -375
  171. package/dist/lib/event-filter.js +0 -91
  172. package/dist/lib/generated-types.js +0 -56
  173. package/dist/lib/git.js +0 -176
  174. package/dist/lib/gk.js +0 -91
  175. package/dist/lib/guild-config.js +0 -178
  176. package/dist/lib/iap.js +0 -117
  177. package/dist/lib/integration-helpers.js +0 -38
  178. package/dist/lib/loading-messages.js +0 -72
  179. package/dist/lib/logo.js +0 -141
  180. package/dist/lib/lottie-serverside.js +0 -181
  181. package/dist/lib/markdown.js +0 -38
  182. package/dist/lib/npmrc.js +0 -59
  183. package/dist/lib/output-mode.js +0 -33
  184. package/dist/lib/output.js +0 -591
  185. package/dist/lib/owner-helpers.js +0 -112
  186. package/dist/lib/polling.js +0 -76
  187. package/dist/lib/progress.js +0 -324
  188. package/dist/lib/session-events-fetch.js +0 -25
  189. package/dist/lib/session-events.js +0 -112
  190. package/dist/lib/session-polling.js +0 -160
  191. package/dist/lib/session-resume.js +0 -96
  192. package/dist/lib/spinners.js +0 -770
  193. package/dist/lib/splash.js +0 -41
  194. package/dist/lib/stdin.js +0 -84
  195. package/dist/lib/svg-to-braille.js +0 -76
  196. package/dist/lib/table.js +0 -59
  197. package/dist/lib/update-check.js +0 -65
  198. package/dist/lib/validate-input-schema.js +0 -208
  199. package/dist/lib/version-helpers.js +0 -121
  200. package/dist/lib/workspace-helpers.js +0 -49
  201. package/dist/mcp/resources.js +0 -67
  202. package/dist/mcp/server.js +0 -64
  203. package/dist/mcp/tools.js +0 -753
@@ -1,390 +0,0 @@
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 { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
6
- import { createSteps, createSpinner, format } from '../../lib/progress.js';
7
- import * as fs from 'fs/promises';
8
- import * as path from 'path';
9
- import * as readline from 'readline';
10
- import { getAuthenticatedUrl } from '../../lib/auth.js';
11
- import { runGit, GitError, formatGitError, installPrePushHook } from '../../lib/git.js';
12
- import { resolveOwnerId } from '../../lib/owner-helpers.js';
13
- import { isInteractive } from '../../lib/stdin.js';
14
- const TEMPLATE_CHOICES = [
15
- {
16
- name: 'LLM - Simple language model agent (recommended)',
17
- value: 'LLM',
18
- short: 'LLM',
19
- },
20
- {
21
- name: 'Auto-managed state - Agent with automatic state management',
22
- value: 'AUTO_MANAGED_STATE',
23
- short: 'Auto-managed state',
24
- },
25
- {
26
- name: 'Blank - Start from scratch',
27
- value: 'BLANK',
28
- short: 'Blank',
29
- },
30
- ];
31
- function slugify(text) {
32
- return text
33
- .toLowerCase()
34
- .replace(/[^a-z0-9]+/g, '-')
35
- .replace(/^-+|-+$/g, '');
36
- }
37
- const NAME_RULES = 'Lowercase letters, digits, hyphens, and underscores only (1-100 characters)';
38
- function isValidAgentName(name) {
39
- return name.length >= 1 && name.length <= 100 && /^[a-z0-9\-_.]+$/.test(name);
40
- }
41
- async function promptForName(defaultName) {
42
- const rl = readline.createInterface({
43
- input: process.stdin,
44
- output: process.stdout,
45
- });
46
- const ask = () => new Promise((resolve) => {
47
- rl.question(`Agent name [${defaultName}]: `, (answer) => {
48
- const trimmed = answer.trim();
49
- const name = trimmed || defaultName;
50
- if (!isValidAgentName(name)) {
51
- console.error(`Invalid name "${name}": ${NAME_RULES}`);
52
- resolve(ask());
53
- }
54
- else {
55
- rl.close();
56
- resolve(name);
57
- }
58
- });
59
- });
60
- return ask();
61
- }
62
- async function promptForTemplate() {
63
- const { default: inquirer } = await import('inquirer');
64
- const { template } = await inquirer.prompt([
65
- {
66
- type: 'list',
67
- name: 'template',
68
- message: 'Select agent template:',
69
- choices: TEMPLATE_CHOICES,
70
- default: 'LLM',
71
- },
72
- ]);
73
- return template;
74
- }
75
- export function createAgentInitCommand() {
76
- const cmd = new Command('init');
77
- cmd
78
- .description('Initialize a directory as a Guild agent')
79
- .option('--name <name>', 'Agent name')
80
- .option('--template <template>', 'Agent template (LLM, AUTO_MANAGED_STATE, BLANK)')
81
- .option('--fork <agent-id>', 'Fork from existing agent')
82
- .option('--owner <owner>', 'Owner (name or ID)')
83
- .option('--directory <path>', 'Directory to initialize (created if needed)')
84
- .option('--force', 'Overwrite existing guild.json', false)
85
- .action(async (options) => {
86
- // Resolve target directory
87
- const targetDir = options.directory
88
- ? path.resolve(process.cwd(), options.directory)
89
- : process.cwd();
90
- // Create directory if it doesn't exist
91
- if (options.directory) {
92
- await fs.mkdir(targetDir, { recursive: true });
93
- }
94
- const guildJsonPath = path.join(targetDir, 'guild.json');
95
- try {
96
- // Check if already initialized
97
- const guildJsonExists = await fs
98
- .access(guildJsonPath)
99
- .then(() => true)
100
- .catch(() => false);
101
- if (guildJsonExists && !options.force) {
102
- const existingConfig = JSON.parse(await fs.readFile(guildJsonPath, 'utf-8'));
103
- console.error('Error: Directory already initialized as Guild agent');
104
- console.error('');
105
- console.error(`guild.json already exists with agent_id: ${existingConfig.agent_id}`);
106
- console.error('');
107
- console.error('To reinitialize, use: guild agent init --force');
108
- process.exit(1);
109
- }
110
- // Get agent name
111
- let agentName = options.name;
112
- if (!agentName) {
113
- if (isInteractive()) {
114
- // Use slugified directory name as default
115
- const dirName = path.basename(targetDir);
116
- const defaultName = slugify(dirName);
117
- agentName = await promptForName(defaultName);
118
- if (!agentName) {
119
- console.error('Error: Agent name cannot be empty');
120
- process.exit(1);
121
- }
122
- }
123
- else {
124
- console.error('Error: Agent name is required');
125
- console.error('');
126
- console.error('Provide a name:');
127
- console.error(' guild agent init --name my-agent');
128
- console.error('');
129
- console.error('Or run interactively to be prompted for a name.');
130
- process.exit(1);
131
- }
132
- }
133
- // Validate name (catches --name flag and non-interactive paths)
134
- if (!isValidAgentName(agentName)) {
135
- console.error(`Error: Invalid agent name "${agentName}"`);
136
- console.error('');
137
- console.error(`Agent names must use ${NAME_RULES}`);
138
- console.error('');
139
- console.error('Examples: my-agent, my_agent');
140
- process.exit(1);
141
- }
142
- // Determine template: use --template option, prompt if interactive, or error
143
- let template = options.template;
144
- if (!template) {
145
- if (isInteractive()) {
146
- template = await promptForTemplate();
147
- }
148
- else {
149
- console.error('Error: --template is required in non-interactive mode');
150
- console.error('');
151
- console.error('Provide a template:');
152
- console.error(' guild agent init --name my-agent --template LLM');
153
- console.error('');
154
- console.error('Available templates:');
155
- console.error(' • LLM - Simple language model agent (recommended)');
156
- console.error(' • AUTO_MANAGED_STATE - Agent with automatic state management');
157
- console.error(' • BLANK - Start from scratch');
158
- process.exit(1);
159
- }
160
- }
161
- // Normalize template to uppercase for case-insensitive matching
162
- template = template.toUpperCase();
163
- // Validate template
164
- const validTemplates = [
165
- 'LLM',
166
- 'AUTO_MANAGED_STATE',
167
- 'BLANK',
168
- ];
169
- if (!validTemplates.includes(template)) {
170
- console.error(`Error: Invalid template '${template}'`);
171
- console.error('');
172
- console.error('Valid templates:');
173
- console.error(' • LLM');
174
- console.error(' • AUTO_MANAGED_STATE');
175
- console.error(' • BLANK');
176
- process.exit(1);
177
- }
178
- // Create progress tracker for initialization steps
179
- const steps = createSteps([
180
- 'Create agent in backend',
181
- 'Initialize git repository',
182
- 'Configure git remote',
183
- 'Wait for backend initialization',
184
- 'Pull scaffolding from remote',
185
- 'Create guild.json',
186
- ]);
187
- steps.start();
188
- // Step 1: Create agent in backend
189
- const client = new GuildAPIClient();
190
- // Resolve owner
191
- const owner = await resolveOwnerId({
192
- ownerFlag: options.owner,
193
- client,
194
- interactive: isInteractive(),
195
- requireExplicitOwner: true,
196
- });
197
- const agent = await client.post('/agents', {
198
- name: agentName,
199
- description: `Agent created via CLI`,
200
- is_public: false,
201
- template,
202
- owner_id: owner.id,
203
- });
204
- steps.succeed('Create agent in backend');
205
- format.detail(`Agent: ${agent.name} (${agent.id})`);
206
- format.detail(`Owner: ${owner.name}`);
207
- // Step 2: Initialize git repository if needed
208
- const gitDir = path.join(targetDir, '.git');
209
- const gitExists = await fs
210
- .access(gitDir)
211
- .then(() => true)
212
- .catch(() => false);
213
- if (!gitExists) {
214
- await runGit(['init', '-b', 'main'], { cwd: targetDir });
215
- steps.succeed('Initialize git repository');
216
- }
217
- else {
218
- steps.succeed('Initialize git repository');
219
- format.detail('Already initialized');
220
- }
221
- // Step 3: Configure git remote
222
- try {
223
- // Check if remote 'origin' exists
224
- await runGit(['remote', 'get-url', 'origin'], { cwd: targetDir });
225
- // Remote exists, update it
226
- await runGit(['remote', 'set-url', 'origin', agent.git_url], {
227
- cwd: targetDir,
228
- });
229
- }
230
- catch {
231
- // Remote doesn't exist, add it
232
- await runGit(['remote', 'add', 'origin', agent.git_url], {
233
- cwd: targetDir,
234
- });
235
- }
236
- steps.succeed('Configure git remote');
237
- format.detail(`Remote: ${agent.git_url}`);
238
- // Step 2: Wait for backend to complete initialization
239
- // Backend pushes scaffolding files in a background task and sets status to READY
240
- const spinner = createSpinner('Waiting for backend initialization...');
241
- spinner.start();
242
- const maxAttempts = 60; // 60 seconds max wait for backend initialization
243
- const delayMs = 1000;
244
- let agentReady = false;
245
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
246
- await new Promise((resolve) => setTimeout(resolve, delayMs));
247
- try {
248
- // Poll agent status
249
- const updatedAgent = await client.get(`/agents/${agent.id}`);
250
- if (updatedAgent.status === 'READY') {
251
- agentReady = true;
252
- spinner.succeed('Backend initialization complete');
253
- steps.succeed('Wait for backend initialization');
254
- break;
255
- }
256
- // Update spinner with progress
257
- spinner.text = `Waiting for backend initialization... (${attempt}/${maxAttempts})`;
258
- }
259
- catch {
260
- // If we can't fetch the agent, continue polling
261
- if (attempt === maxAttempts) {
262
- spinner.warn('Could not verify initialization status');
263
- steps.warn('Wait for backend initialization', 'Status unknown');
264
- }
265
- }
266
- }
267
- if (!agentReady) {
268
- spinner.fail('Backend initialization timed out');
269
- steps.fail('Wait for backend initialization');
270
- console.error('');
271
- console.error('The backend is taking longer than expected to initialize the agent.');
272
- console.error('This usually means the GitHub repository creation is delayed.');
273
- console.error('');
274
- console.error('You can check the status later with:');
275
- console.error(` guild agent get ${agent.id}`);
276
- console.error('');
277
- console.error('Or wait and try pulling the scaffolding manually:');
278
- console.error(` cd ${targetDir}`);
279
- console.error(' git pull origin main');
280
- process.exit(1);
281
- }
282
- // Step 5: Pull scaffolding from remote
283
- // Retry pull with short delays since GitHub may need a moment after API push
284
- const pullMaxAttempts = 15;
285
- const pullDelayMs = 1000; // 1 second between attempts
286
- // Get authenticated URL for git pull
287
- const authenticatedGitUrl = await getAuthenticatedUrl(agent.git_url);
288
- if (!authenticatedGitUrl) {
289
- console.error('Error: Not authenticated. Run: guild auth login');
290
- process.exit(1);
291
- }
292
- for (let attempt = 1; attempt <= pullMaxAttempts; attempt++) {
293
- try {
294
- await runGit(['pull', authenticatedGitUrl, 'main'], { cwd: targetDir });
295
- steps.succeed('Pull scaffolding from remote');
296
- break;
297
- }
298
- catch (error) {
299
- if (attempt < pullMaxAttempts) {
300
- // Short, consistent delay between retries (total max wait: 15s)
301
- await new Promise((resolve) => setTimeout(resolve, pullDelayMs));
302
- }
303
- else {
304
- // Final attempt failed - log error for debugging
305
- const errMsg = error instanceof GitError
306
- ? error.stderr || error.stdout
307
- : error instanceof Error
308
- ? error.message
309
- : String(error);
310
- steps.warn('Pull scaffolding from remote', 'Could not pull from remote');
311
- format.detail(`Git pull error: ${errMsg}`);
312
- format.detail('Backend may still be initializing the repository');
313
- }
314
- }
315
- }
316
- // Step 6: Create guild.json
317
- const guildConfig = {
318
- agent_id: agent.id,
319
- name: agentName,
320
- };
321
- await fs.writeFile(guildJsonPath, JSON.stringify(guildConfig, null, 2) + '\n', 'utf-8');
322
- steps.succeed('Create guild.json');
323
- // Add guild.json and .guild/cache/ to .gitignore if not already present
324
- const gitignorePath = path.join(targetDir, '.gitignore');
325
- try {
326
- const gitignoreContent = await fs.readFile(gitignorePath, 'utf-8');
327
- const existingLines = gitignoreContent.split('\n').map((l) => l.trim());
328
- const lines = [];
329
- if (!existingLines.includes('guild.json')) {
330
- lines.push('guild.json');
331
- }
332
- if (!existingLines.includes('.guild/cache/')) {
333
- lines.push('.guild/cache/');
334
- }
335
- if (lines.length > 0) {
336
- const prefix = gitignoreContent.endsWith('\n') ? '' : '\n';
337
- await fs.appendFile(gitignorePath, prefix + lines.join('\n') + '\n');
338
- }
339
- }
340
- catch {
341
- // .gitignore doesn't exist (backend should have created it), create it
342
- await fs.writeFile(gitignorePath, 'guild.json\n.guild/cache/\n');
343
- }
344
- // Install pre-push hook to block direct git push
345
- await installPrePushHook(targetDir);
346
- // Complete progress tracking
347
- steps.complete('Agent initialized successfully');
348
- // Display next steps
349
- format.section('Next steps:');
350
- if (options.directory) {
351
- format.detail(`1. cd ${targetDir}`);
352
- format.detail('2. Edit agent.ts to implement your agent logic');
353
- format.detail('3. git add . && git commit -m "Initial implementation"');
354
- format.detail("4. Run 'guild agent save' to push and create a version");
355
- format.detail(`5. Run 'guild agent test' to test your agent`);
356
- }
357
- else {
358
- format.detail('1. Edit agent.ts to implement your agent logic');
359
- format.detail('2. git add . && git commit -m "Initial implementation"');
360
- format.detail("3. Run 'guild agent save' to push and create a version");
361
- format.detail(`4. Run 'guild agent test' to test your agent`);
362
- }
363
- }
364
- catch (error) {
365
- if (error instanceof GitError) {
366
- console.error('Error: Git operation failed');
367
- console.error('');
368
- console.error(formatGitError(error));
369
- process.exit(1);
370
- }
371
- const formattedError = handleAxiosError(error);
372
- if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
373
- console.error('Not authenticated. Please log in first.');
374
- console.error('');
375
- console.error('Run: guild auth login');
376
- process.exit(1);
377
- }
378
- if (formattedError.code === ErrorCodes.CONN_REFUSED) {
379
- console.error('Cannot connect to Guild servers.');
380
- console.error('');
381
- console.error('Please check your connection and try again.');
382
- process.exit(1);
383
- }
384
- console.error(`Failed to initialize agent: ${formattedError.details}`);
385
- process.exit(1);
386
- }
387
- });
388
- return cmd;
389
- }
390
- //# sourceMappingURL=init.js.map
@@ -1,110 +0,0 @@
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, ErrorCodes } from '../../lib/errors.js';
7
- import { getOutputMode } from '../../lib/output-mode.js';
8
- import { createOutputWriter, formatAgentTable } from '../../lib/output.js';
9
- import { DEFAULT_PAGE_LIMIT } from '../../lib/api-types.js';
10
- const SORT_MAP = {
11
- updated: 'updated_at',
12
- newest: 'created_at',
13
- name: 'name',
14
- popular: 'cached_likes_count',
15
- };
16
- export function createAgentListCommand() {
17
- const cmd = new Command('list');
18
- cmd
19
- .description('List agents')
20
- .option('--search <query>', 'Search agents by name or description')
21
- .option('--sort <field>', 'Sort by: name, updated, newest, popular (default: name)', 'name')
22
- .option('--published', 'Only show published agents')
23
- .option('--archived', 'Show only archived agents')
24
- .option('--all', 'Show all agents including archived')
25
- .option('--owner <name>', 'Filter by owner (user or org name). Without this flag, lists your own agents')
26
- .option('--workspace <id>', 'Filter agents by workspace ID or name')
27
- .option('--limit <number>', `Number of results to return (default: ${DEFAULT_PAGE_LIMIT})`, String(DEFAULT_PAGE_LIMIT))
28
- .option('--offset <number>', 'Offset for pagination (default: 0)', '0')
29
- .action(async (options) => {
30
- const output = createOutputWriter();
31
- if (options.archived && options.all) {
32
- output.error('--archived and --all are mutually exclusive', 'Use --archived to show only archived agents, or --all to show all agents including archived');
33
- process.exit(1);
34
- }
35
- try {
36
- const token = await getAuthToken();
37
- if (!token) {
38
- output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
39
- process.exit(1);
40
- }
41
- const client = new GuildAPIClient();
42
- const params = new URLSearchParams();
43
- params.append('limit', options.limit);
44
- params.append('offset', options.offset);
45
- if (options.search) {
46
- params.append('search', options.search);
47
- }
48
- if (options.published) {
49
- params.append('published_only', 'true');
50
- }
51
- const sortField = SORT_MAP[options.sort];
52
- if (sortField) {
53
- params.append('sort_by', sortField);
54
- }
55
- // Determine the right endpoint:
56
- // - --workspace → GET /agents?for_workspace=... (global, workspace-scoped)
57
- // - --owner → GET /users/{owner}/agents or /organizations/{owner}/agents
58
- // - default → GET /users/{me}/agents (same as web)
59
- let endpoint;
60
- const showArchived = options.all || options.archived;
61
- if (options.workspace) {
62
- // Workspace filter uses the global endpoint
63
- params.append('for_workspace', options.workspace);
64
- endpoint = `/agents?${params.toString()}`;
65
- }
66
- else {
67
- // Use scoped endpoint (matches web frontend pattern)
68
- if (options.archived) {
69
- params.append('include_archived', 'true');
70
- }
71
- else if (options.all) {
72
- params.append('include_archived', 'true');
73
- }
74
- const ownerName = options.owner ?? (await client.get('/me')).name;
75
- endpoint = `/users/${encodeURIComponent(ownerName)}/agents?${params.toString()}`;
76
- }
77
- const response = await client.get(endpoint);
78
- // When --archived is used, filter to only archived agents client-side
79
- // (the backend only supports include_archived, not archived_only)
80
- if (options.archived) {
81
- response.items = response.items.filter((a) => a.is_archived);
82
- }
83
- if (getOutputMode() === 'json') {
84
- output.data(response);
85
- }
86
- else {
87
- formatAgentTable(response.items, response.pagination, showArchived);
88
- }
89
- }
90
- catch (error) {
91
- const formattedError = handleAxiosError(error);
92
- if (formattedError.code === ErrorCodes.NOT_FOUND) {
93
- if (options.workspace) {
94
- output.error('Workspace not found');
95
- }
96
- else if (options.owner) {
97
- output.error(`Owner not found: ${options.owner}`);
98
- }
99
- else {
100
- output.error('Not found');
101
- }
102
- process.exit(1);
103
- }
104
- output.error(`Failed to list agents: ${formattedError.details}`);
105
- process.exit(1);
106
- }
107
- });
108
- return cmd;
109
- }
110
- //# sourceMappingURL=list.js.map
@@ -1,74 +0,0 @@
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 { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
- import { getOutputMode } from '../../lib/output-mode.js';
8
- import { createOutputWriter } from '../../lib/output.js';
9
- import { loadGlobalConfig } from '../../lib/guild-config.js';
10
- export function createAgentOwnersCommand() {
11
- const cmd = new Command('owners');
12
- cmd.description('List accounts that can own agents').action(async () => {
13
- const output = createOutputWriter();
14
- try {
15
- const mode = getOutputMode();
16
- const client = new GuildAPIClient();
17
- const [me, orgs, globalConfig] = await Promise.all([
18
- client.get('/me'),
19
- client.fetchAll('/me/organizations'),
20
- loadGlobalConfig(),
21
- ]);
22
- const defaultOwnerId = globalConfig?.default_owner;
23
- const owners = [
24
- {
25
- id: me.id,
26
- name: me.name,
27
- type: 'user',
28
- is_default: defaultOwnerId === me.id,
29
- },
30
- ...orgs.map((org) => ({
31
- id: org.id,
32
- name: org.name,
33
- type: 'organization',
34
- is_default: defaultOwnerId === org.id,
35
- })),
36
- ];
37
- if (mode === 'json') {
38
- output.data({ owners });
39
- return;
40
- }
41
- // Table display
42
- console.log('');
43
- console.log(`${chalk.dim('TYPE')} ${chalk.dim('NAME')} ${chalk.dim('ID')}`);
44
- console.log(chalk.dim('─'.repeat(72)));
45
- for (const owner of owners) {
46
- const typeLabel = owner.type === 'user' ? 'user' : 'org';
47
- const typePadded = typeLabel.padEnd(15);
48
- const defaultLabel = owner.is_default ? chalk.cyan(' (default)') : '';
49
- const namePadded = (owner.name + (owner.is_default ? '' : '')).padEnd(25);
50
- console.log(`${typePadded} ${namePadded}${defaultLabel ? defaultLabel + ' ' : ''}${chalk.dim(owner.id)}`);
51
- }
52
- console.log('');
53
- if (!defaultOwnerId) {
54
- console.log(chalk.dim('No default owner set. Run: guild config set default_owner <id>'));
55
- console.log('');
56
- }
57
- }
58
- catch (error) {
59
- const formattedError = handleAxiosError(error);
60
- if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
61
- output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
62
- process.exit(1);
63
- }
64
- if (formattedError.code === ErrorCodes.CONN_REFUSED) {
65
- output.error('Cannot connect to Guild servers.', 'Please check your connection and try again.');
66
- process.exit(1);
67
- }
68
- output.error(`Failed to list owners: ${formattedError.details}`);
69
- process.exit(1);
70
- }
71
- });
72
- return cmd;
73
- }
74
- //# sourceMappingURL=owners.js.map
@@ -1,91 +0,0 @@
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 { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
6
- import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
- import { createOutputWriter } from '../../lib/output.js';
8
- import { waitForValidation, waitForPublish } from '../../lib/version-helpers.js';
9
- export function createAgentPublishCommand() {
10
- const cmd = new Command('publish');
11
- cmd
12
- .description('Publish the latest draft version of an agent')
13
- .argument('[identifier]', 'Agent ID or full name (e.g., owner~agent-name)')
14
- .option('--wait', 'Wait for validation to complete before publishing')
15
- .action(async (agentIdArg, options) => {
16
- const output = createOutputWriter();
17
- try {
18
- const client = new GuildAPIClient();
19
- // Resolve agent ID
20
- const { agentId, config } = await getAgentId(agentIdArg);
21
- const resolvedId = await resolveAgentRef(client, agentId);
22
- // Fetch all versions
23
- const response = await client.get(`/agents/${resolvedId}/versions`);
24
- // Find latest DRAFT version
25
- const draftVersions = response.items
26
- .filter((v) => v.status === 'DRAFT')
27
- .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
28
- if (draftVersions.length === 0) {
29
- const agentName = config?.name || agentId;
30
- output.error(`No draft versions available for agent: ${agentName}`, 'Create a new version:\n guild agent save --message "your changes"');
31
- process.exit(1);
32
- }
33
- const versionToPublish = draftVersions[0];
34
- // Check if already published
35
- if (versionToPublish.status === 'PUBLISHED') {
36
- output.error(`Version ${versionToPublish.id} is already published`, 'To unpublish:\n guild agent unpublish');
37
- process.exit(1);
38
- }
39
- // Check validation status before attempting publish
40
- let currentVersion = versionToPublish;
41
- const validationStatus = currentVersion.validation_status;
42
- if (validationStatus === 'PENDING' || validationStatus === 'RUNNING') {
43
- if (options.wait) {
44
- currentVersion = await waitForValidation(currentVersion.id, output);
45
- }
46
- else {
47
- output.error('Cannot publish: validation is still in progress', `Validation status: ${validationStatus === 'PENDING' ? 'Waiting to start' : 'Running'}\n\nOptions:\n • Wait for validation: guild agent publish --wait\n • Check status: guild agent versions`);
48
- process.exit(1);
49
- }
50
- }
51
- else if (validationStatus === 'FAILED') {
52
- output.error('Cannot publish: validation failed', 'Fix the issues, then save a new version:\n guild agent save --message "Fix validation errors"');
53
- process.exit(1);
54
- }
55
- // Publish version
56
- currentVersion = await client.post(`/versions/${currentVersion.id}/publish`, {});
57
- if (options.wait && currentVersion.status !== 'PUBLISHED') {
58
- currentVersion = await waitForPublish(currentVersion.id, output);
59
- }
60
- const details = {
61
- agent: `${currentVersion.agent?.name || config?.name || agentId}${config ? '' : ` (${agentId})`}`,
62
- status: currentVersion.status === 'PUBLISHED'
63
- ? 'DRAFT → PUBLISHED'
64
- : 'DRAFT → PUBLISHING',
65
- };
66
- if (currentVersion.version_number) {
67
- details.version = currentVersion.version_number;
68
- }
69
- output.success(`Published version ${currentVersion.id}`, details);
70
- }
71
- catch (error) {
72
- const formattedError = handleAxiosError(error);
73
- if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
74
- output.error('Not authenticated. Run: guild auth login');
75
- process.exit(1);
76
- }
77
- if (formattedError.code === ErrorCodes.NOT_FOUND) {
78
- output.error('Agent not found', 'Run: guild agent list');
79
- process.exit(1);
80
- }
81
- if (formattedError.code === ErrorCodes.CONN_REFUSED) {
82
- output.error('Cannot connect to Guild servers');
83
- process.exit(1);
84
- }
85
- output.error(`Failed to publish: ${formattedError.details}`);
86
- process.exit(1);
87
- }
88
- });
89
- return cmd;
90
- }
91
- //# sourceMappingURL=publish.js.map