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