@schuttdev/gigai 0.2.8 → 0.3.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.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ editBuiltin,
4
+ globBuiltin,
5
+ grepBuiltin,
6
+ listDirSafe,
7
+ readBuiltin,
8
+ readFileSafe,
9
+ searchFilesSafe,
10
+ validatePath,
11
+ writeBuiltin
12
+ } from "./chunk-FW3JH5IG.js";
13
+ import "./chunk-P53UVHTF.js";
14
+ export {
15
+ editBuiltin,
16
+ globBuiltin,
17
+ grepBuiltin,
18
+ listDirSafe,
19
+ readBuiltin,
20
+ readFileSafe,
21
+ searchFilesSafe,
22
+ validatePath,
23
+ writeBuiltin
24
+ };
package/dist/index.js CHANGED
@@ -4,12 +4,12 @@
4
4
  import { defineCommand, runMain } from "citty";
5
5
 
6
6
  // src/version.ts
7
- var VERSION = "0.2.8";
7
+ var VERSION = "0.3.0";
8
8
 
9
9
  // src/index.ts
10
10
  async function requireServer() {
11
11
  try {
12
- return await import("./dist-Z7XWWQBF.js");
12
+ return await import("./dist-H6URC2HQ.js");
13
13
  } catch {
14
14
  console.error("Server dependencies not installed.");
15
15
  console.error("Run: npm install -g @schuttdev/gigai");
@@ -150,6 +150,251 @@ var unwrapCommand = defineCommand({
150
150
  await unwrapTool(args.name);
151
151
  }
152
152
  });
153
+ var mcpCommand = defineCommand({
154
+ meta: { name: "mcp", description: "Manage MCP servers" },
155
+ subCommands: {
156
+ add: defineCommand({
157
+ meta: {
158
+ name: "add",
159
+ description: "Add an MCP server (e.g. gigai mcp add <name> -- <command> [args...])"
160
+ },
161
+ args: {
162
+ name: {
163
+ type: "positional",
164
+ description: "MCP server name",
165
+ required: true
166
+ }
167
+ },
168
+ async run({ args: cmdArgs }) {
169
+ const { mcpAdd } = await requireServer();
170
+ const name = cmdArgs.name;
171
+ const rawArgs = process.argv;
172
+ const dashDashIdx = rawArgs.indexOf("--");
173
+ if (dashDashIdx === -1 || dashDashIdx >= rawArgs.length - 1) {
174
+ console.error(
175
+ "Usage: gigai mcp add <name> [--env KEY=VALUE ...] -- <command> [args...]"
176
+ );
177
+ console.error(
178
+ "\nExamples:"
179
+ );
180
+ console.error(
181
+ " gigai mcp add browser -- npx -y @anthropic-ai/mcp-server-puppeteer"
182
+ );
183
+ console.error(
184
+ " gigai mcp add myserver --env API_KEY=abc123 -- uvx mcp-server"
185
+ );
186
+ process.exitCode = 1;
187
+ return;
188
+ }
189
+ const beforeDash = rawArgs.slice(0, dashDashIdx);
190
+ const env = {};
191
+ for (let i = 0; i < beforeDash.length; i++) {
192
+ if (beforeDash[i] === "--env" && i + 1 < beforeDash.length) {
193
+ const pair = beforeDash[i + 1];
194
+ const eqIdx = pair.indexOf("=");
195
+ if (eqIdx > 0) {
196
+ env[pair.slice(0, eqIdx)] = pair.slice(eqIdx + 1);
197
+ }
198
+ i++;
199
+ }
200
+ }
201
+ const afterDash = rawArgs.slice(dashDashIdx + 1);
202
+ const commandParts = [];
203
+ for (let i = 0; i < afterDash.length; i++) {
204
+ if (afterDash[i] === "--env" && i + 1 < afterDash.length) {
205
+ const pair = afterDash[i + 1];
206
+ const eqIdx = pair.indexOf("=");
207
+ if (eqIdx > 0) {
208
+ env[pair.slice(0, eqIdx)] = pair.slice(eqIdx + 1);
209
+ }
210
+ i++;
211
+ } else {
212
+ commandParts.push(afterDash[i]);
213
+ }
214
+ }
215
+ if (commandParts.length === 0) {
216
+ console.error("Error: No command specified after '--'.");
217
+ process.exitCode = 1;
218
+ return;
219
+ }
220
+ const command = commandParts[0];
221
+ const commandArgs = commandParts.slice(1);
222
+ await mcpAdd(
223
+ name,
224
+ command,
225
+ commandArgs,
226
+ Object.keys(env).length > 0 ? env : void 0
227
+ );
228
+ }
229
+ }),
230
+ remove: defineCommand({
231
+ meta: { name: "remove", description: "Remove an MCP server" },
232
+ args: {
233
+ name: {
234
+ type: "positional",
235
+ description: "MCP server name",
236
+ required: true
237
+ }
238
+ },
239
+ async run({ args }) {
240
+ const { unwrapTool } = await requireServer();
241
+ await unwrapTool(args.name);
242
+ }
243
+ }),
244
+ list: defineCommand({
245
+ meta: { name: "list", description: "List configured MCP servers" },
246
+ async run() {
247
+ const { mcpList } = await requireServer();
248
+ await mcpList();
249
+ }
250
+ })
251
+ }
252
+ });
253
+ var cronCommand = defineCommand({
254
+ meta: { name: "cron", description: "Manage scheduled jobs" },
255
+ subCommands: {
256
+ add: defineCommand({
257
+ meta: {
258
+ name: "add",
259
+ description: 'Schedule a tool execution (e.g. gigai cron add "0 9 * * *" bash git pull)'
260
+ },
261
+ args: {
262
+ at: { type: "string", description: 'Human-readable time (e.g. "9:00 AM tomorrow", "in 30 minutes")' },
263
+ description: { type: "string", alias: "d", description: "Optional label for the job" }
264
+ },
265
+ async run({ args: cmdArgs }) {
266
+ const rawArgs = process.argv;
267
+ const addIdx = rawArgs.indexOf("add");
268
+ if (addIdx === -1) {
269
+ console.error("Usage: gigai cron add [--at <time>] <tool> [args...]");
270
+ console.error(' gigai cron add "0 9 * * *" <tool> [args...]');
271
+ process.exitCode = 1;
272
+ return;
273
+ }
274
+ const positionals = [];
275
+ const rest = rawArgs.slice(addIdx + 1);
276
+ for (let i = 0; i < rest.length; i++) {
277
+ if (rest[i] === "--at" || rest[i] === "--description" || rest[i] === "-d") {
278
+ i++;
279
+ continue;
280
+ }
281
+ if (rest[i].startsWith("--")) continue;
282
+ positionals.push(rest[i]);
283
+ }
284
+ let schedule;
285
+ let tool;
286
+ let toolArgs;
287
+ let oneShot = false;
288
+ if (cmdArgs.at) {
289
+ const { parseAtExpression } = await requireServer();
290
+ schedule = parseAtExpression(cmdArgs.at);
291
+ oneShot = true;
292
+ tool = positionals[0];
293
+ toolArgs = positionals.slice(1);
294
+ } else {
295
+ schedule = positionals[0];
296
+ tool = positionals[1];
297
+ toolArgs = positionals.slice(2);
298
+ }
299
+ if (!schedule || !tool) {
300
+ console.error('Usage: gigai cron add "0 9 * * *" <tool> [args...]');
301
+ console.error(' gigai cron add --at "9:00 AM tomorrow" <tool> [args...]');
302
+ process.exitCode = 1;
303
+ return;
304
+ }
305
+ try {
306
+ const res = await fetch("http://localhost:7443/cron", {
307
+ method: "POST",
308
+ headers: { "Content-Type": "application/json" },
309
+ body: JSON.stringify({
310
+ schedule,
311
+ tool,
312
+ args: toolArgs,
313
+ description: cmdArgs.description,
314
+ oneShot
315
+ })
316
+ });
317
+ if (!res.ok) {
318
+ const err = await res.json();
319
+ console.error(`Error: ${err.error?.message ?? res.statusText}`);
320
+ process.exitCode = 1;
321
+ return;
322
+ }
323
+ const data = await res.json();
324
+ const job = data.job;
325
+ console.log(`Created cron job ${job.id}`);
326
+ console.log(` Schedule: ${job.schedule}`);
327
+ console.log(` Tool: ${job.tool} ${job.args.join(" ")}`);
328
+ if (job.description) console.log(` Label: ${job.description}`);
329
+ if (job.nextRun) console.log(` Next run: ${new Date(job.nextRun).toLocaleString()}`);
330
+ if (oneShot) console.log(` Type: one-shot (will disable after execution)`);
331
+ } catch {
332
+ console.error("Server is not running. Start it with: gigai start");
333
+ process.exitCode = 1;
334
+ }
335
+ }
336
+ }),
337
+ list: defineCommand({
338
+ meta: { name: "list", description: "List all scheduled jobs" },
339
+ async run() {
340
+ try {
341
+ const res = await fetch("http://localhost:7443/cron");
342
+ if (!res.ok) {
343
+ const err = await res.json();
344
+ console.error(`Error: ${err.error?.message ?? res.statusText}`);
345
+ process.exitCode = 1;
346
+ return;
347
+ }
348
+ const data = await res.json();
349
+ const jobs = data.jobs;
350
+ if (jobs.length === 0) {
351
+ console.log("No scheduled jobs.");
352
+ return;
353
+ }
354
+ console.log(`${"ID".padEnd(14)} ${"Schedule".padEnd(16)} ${"Tool".padEnd(20)} ${"Enabled".padEnd(9)} ${"Next Run"}`);
355
+ console.log("-".repeat(80));
356
+ for (const job of jobs) {
357
+ const enabled = job.enabled ? "yes" : "no";
358
+ const next = job.nextRun && job.enabled ? new Date(job.nextRun).toLocaleString() : "-";
359
+ const toolStr = `${job.tool} ${job.args.join(" ")}`.slice(0, 18);
360
+ console.log(
361
+ `${job.id.padEnd(14)} ${job.schedule.padEnd(16)} ${toolStr.padEnd(20)} ${enabled.padEnd(9)} ${next}`
362
+ );
363
+ if (job.description) {
364
+ console.log(`${"".padEnd(14)} ${job.description}`);
365
+ }
366
+ }
367
+ } catch {
368
+ console.error("Server is not running. Start it with: gigai start");
369
+ process.exitCode = 1;
370
+ }
371
+ }
372
+ }),
373
+ remove: defineCommand({
374
+ meta: { name: "remove", description: "Remove a scheduled job" },
375
+ args: {
376
+ id: { type: "positional", description: "Job ID", required: true }
377
+ },
378
+ async run({ args }) {
379
+ try {
380
+ const res = await fetch(`http://localhost:7443/cron/${args.id}`, {
381
+ method: "DELETE"
382
+ });
383
+ if (!res.ok) {
384
+ const err = await res.json();
385
+ console.error(`Error: ${err.error?.message ?? res.statusText}`);
386
+ process.exitCode = 1;
387
+ return;
388
+ }
389
+ console.log(`Removed cron job ${args.id}`);
390
+ } catch {
391
+ console.error("Server is not running. Start it with: gigai start");
392
+ process.exitCode = 1;
393
+ }
394
+ }
395
+ })
396
+ }
397
+ });
153
398
  var versionCommand = defineCommand({
154
399
  meta: { name: "version", description: "Show version" },
155
400
  run() {
@@ -172,6 +417,8 @@ var main = defineCommand({
172
417
  uninstall: uninstallCommand,
173
418
  wrap: wrapCommand,
174
419
  unwrap: unwrapCommand,
420
+ mcp: mcpCommand,
421
+ cron: cronCommand,
175
422
  version: versionCommand
176
423
  }
177
424
  });
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ execCommandSafe
4
+ } from "./chunk-O45SW2HC.js";
5
+ import "./chunk-P53UVHTF.js";
6
+ export {
7
+ execCommandSafe
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schuttdev/gigai",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "gigai": "dist/index.js"