@moxxy/agent-cli 0.0.1

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/index.js ADDED
@@ -0,0 +1,1982 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/core/plugin-registry.ts
34
+ var PluginRegistry;
35
+ var init_plugin_registry = __esm({
36
+ "src/core/plugin-registry.ts"() {
37
+ "use strict";
38
+ PluginRegistry = class {
39
+ plugins = /* @__PURE__ */ new Map();
40
+ register(plugin) {
41
+ this.plugins.set(plugin.name, plugin);
42
+ }
43
+ get(name) {
44
+ return this.plugins.get(name);
45
+ }
46
+ getAll() {
47
+ return Array.from(this.plugins.values());
48
+ }
49
+ has(name) {
50
+ return this.plugins.has(name);
51
+ }
52
+ };
53
+ }
54
+ });
55
+
56
+ // src/core/exec.ts
57
+ function exec(command, args, options) {
58
+ return new Promise((resolve14, reject) => {
59
+ (0, import_node_child_process.execFile)(
60
+ command,
61
+ args,
62
+ { ...options, maxBuffer: 10 * 1024 * 1024 },
63
+ (error, stdout, stderr) => {
64
+ if (error) {
65
+ reject(Object.assign(error, { stdout, stderr }));
66
+ } else {
67
+ resolve14({ stdout, stderr });
68
+ }
69
+ }
70
+ );
71
+ });
72
+ }
73
+ var import_node_child_process;
74
+ var init_exec = __esm({
75
+ "src/core/exec.ts"() {
76
+ "use strict";
77
+ import_node_child_process = require("child_process");
78
+ }
79
+ });
80
+
81
+ // src/core/context.ts
82
+ async function detectWorkspace(cwd) {
83
+ const context = {
84
+ cwd,
85
+ isGitRepo: false
86
+ };
87
+ try {
88
+ const { stdout } = await exec("git", ["rev-parse", "--show-toplevel"], { cwd });
89
+ context.isGitRepo = true;
90
+ context.repoRoot = stdout.trim();
91
+ } catch {
92
+ context.isGitRepo = false;
93
+ }
94
+ if (context.isGitRepo) {
95
+ try {
96
+ const { stdout } = await exec("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd });
97
+ context.branch = stdout.trim();
98
+ } catch {
99
+ }
100
+ }
101
+ const lockfiles = [
102
+ { file: "pnpm-lock.yaml", manager: "pnpm" },
103
+ { file: "yarn.lock", manager: "yarn" },
104
+ { file: "bun.lockb", manager: "bun" },
105
+ { file: "package-lock.json", manager: "npm" }
106
+ ];
107
+ const searchDir = context.repoRoot || cwd;
108
+ for (const { file, manager } of lockfiles) {
109
+ if (fs.existsSync(path.join(searchDir, file))) {
110
+ context.packageManager = manager;
111
+ break;
112
+ }
113
+ }
114
+ currentContext = context;
115
+ return context;
116
+ }
117
+ function getContext() {
118
+ return currentContext;
119
+ }
120
+ var fs, path, currentContext;
121
+ var init_context = __esm({
122
+ "src/core/context.ts"() {
123
+ "use strict";
124
+ fs = __toESM(require("fs"));
125
+ path = __toESM(require("path"));
126
+ init_exec();
127
+ currentContext = null;
128
+ }
129
+ });
130
+
131
+ // src/core/result.ts
132
+ function success(command, data, startTime) {
133
+ return {
134
+ success: true,
135
+ command,
136
+ data,
137
+ duration_ms: Date.now() - startTime
138
+ };
139
+ }
140
+ function failure(command, code, message, startTime, details) {
141
+ return {
142
+ success: false,
143
+ command,
144
+ error: { code, message, details },
145
+ duration_ms: Date.now() - startTime
146
+ };
147
+ }
148
+ function output(result) {
149
+ process.stdout.write(JSON.stringify(result) + "\n");
150
+ }
151
+ function log(message) {
152
+ process.stderr.write(message + "\n");
153
+ }
154
+ var init_result = __esm({
155
+ "src/core/result.ts"() {
156
+ "use strict";
157
+ }
158
+ });
159
+
160
+ // src/plugins/workspace/init.ts
161
+ function registerInit(parent) {
162
+ parent.command("init").description("Initialize a workspace by cloning a repo and setting up the environment").option("--repo <url>", "Git repository URL to clone").option("--branch <name>", "Branch to create or checkout").option("--clone-dir <path>", "Directory to clone into").action(async (opts) => {
163
+ const startTime = Date.now();
164
+ const cmd = "workspace init";
165
+ try {
166
+ if (!opts.repo) {
167
+ output(failure(cmd, "MISSING_ARGUMENT", "--repo is required", startTime));
168
+ return;
169
+ }
170
+ const cloneDir = opts.cloneDir || process.cwd();
171
+ log(`Cloning ${opts.repo} into ${cloneDir}...`);
172
+ const cloneArgs = ["clone", opts.repo, cloneDir];
173
+ await exec("git", cloneArgs);
174
+ if (opts.branch) {
175
+ log(`Creating and checking out branch ${opts.branch}...`);
176
+ await exec("git", ["checkout", "-b", opts.branch], { cwd: cloneDir });
177
+ }
178
+ const context = await detectWorkspace(cloneDir);
179
+ if (context.packageManager) {
180
+ log(`Detected ${context.packageManager}, installing dependencies...`);
181
+ try {
182
+ await exec(context.packageManager, ["install"], { cwd: cloneDir });
183
+ } catch (err) {
184
+ log(`Warning: dependency install failed: ${err.message}`);
185
+ }
186
+ }
187
+ output(success(cmd, {
188
+ path: cloneDir,
189
+ repo: opts.repo,
190
+ branch: opts.branch || context.branch,
191
+ packageManager: context.packageManager,
192
+ isGitRepo: context.isGitRepo
193
+ }, startTime));
194
+ } catch (err) {
195
+ output(failure(cmd, "WORKSPACE_INIT_ERROR", err.message, startTime, err.stderr));
196
+ }
197
+ });
198
+ }
199
+ var init_init = __esm({
200
+ "src/plugins/workspace/init.ts"() {
201
+ "use strict";
202
+ init_exec();
203
+ init_context();
204
+ init_result();
205
+ }
206
+ });
207
+
208
+ // src/plugins/workspace/info.ts
209
+ function registerInfo(parent) {
210
+ parent.command("info").description("Display current workspace context").action(async () => {
211
+ const startTime = Date.now();
212
+ const cmd = "workspace info";
213
+ try {
214
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
215
+ const context = await detectWorkspace(cwd);
216
+ output(success(cmd, context, startTime));
217
+ } catch (err) {
218
+ output(failure(cmd, "WORKSPACE_INFO_ERROR", err.message, startTime));
219
+ }
220
+ });
221
+ }
222
+ var init_info = __esm({
223
+ "src/plugins/workspace/info.ts"() {
224
+ "use strict";
225
+ init_context();
226
+ init_result();
227
+ }
228
+ });
229
+
230
+ // src/plugins/workspace/clean.ts
231
+ function registerClean(parent) {
232
+ parent.command("clean").description("Remove workspace directory").argument("<path>", "Workspace directory to remove").action(async (targetPath) => {
233
+ const startTime = Date.now();
234
+ const cmd = "workspace clean";
235
+ try {
236
+ if (!fs2.existsSync(targetPath)) {
237
+ output(failure(cmd, "NOT_FOUND", `Directory not found: ${targetPath}`, startTime));
238
+ return;
239
+ }
240
+ log(`Removing ${targetPath}...`);
241
+ fs2.rmSync(targetPath, { recursive: true, force: true });
242
+ output(success(cmd, { path: targetPath, removed: true }, startTime));
243
+ } catch (err) {
244
+ output(failure(cmd, "WORKSPACE_CLEAN_ERROR", err.message, startTime));
245
+ }
246
+ });
247
+ }
248
+ var fs2;
249
+ var init_clean = __esm({
250
+ "src/plugins/workspace/clean.ts"() {
251
+ "use strict";
252
+ fs2 = __toESM(require("fs"));
253
+ init_result();
254
+ }
255
+ });
256
+
257
+ // src/plugins/workspace/index.ts
258
+ var WorkspacePlugin;
259
+ var init_workspace = __esm({
260
+ "src/plugins/workspace/index.ts"() {
261
+ "use strict";
262
+ init_init();
263
+ init_info();
264
+ init_clean();
265
+ WorkspacePlugin = class {
266
+ name = "workspace";
267
+ version = "1.0.0";
268
+ description = "Workspace initialization and management";
269
+ register(program) {
270
+ const workspace = program.command("workspace").description(this.description);
271
+ registerInit(workspace);
272
+ registerInfo(workspace);
273
+ registerClean(workspace);
274
+ }
275
+ getCommands() {
276
+ return [
277
+ {
278
+ name: "workspace init",
279
+ description: "Clone a repo and set up workspace",
280
+ args: [],
281
+ options: [
282
+ { name: "--repo", description: "Git repository URL", required: true, type: "string" },
283
+ { name: "--branch", description: "Branch to create", required: false, type: "string" },
284
+ { name: "--clone-dir", description: "Clone target directory", required: false, type: "string" }
285
+ ],
286
+ examples: ["moxxy-agent workspace init --repo https://github.com/org/repo --branch feat/new"]
287
+ },
288
+ {
289
+ name: "workspace info",
290
+ description: "Display current workspace context",
291
+ args: [],
292
+ options: [],
293
+ examples: ["moxxy-agent workspace info"]
294
+ },
295
+ {
296
+ name: "workspace clean",
297
+ description: "Remove workspace directory",
298
+ args: [{ name: "path", description: "Directory to remove", required: true, type: "string" }],
299
+ options: [],
300
+ examples: ["moxxy-agent workspace clean /tmp/workspace"]
301
+ }
302
+ ];
303
+ }
304
+ };
305
+ }
306
+ });
307
+
308
+ // src/plugins/file/create.ts
309
+ function registerCreate(parent) {
310
+ parent.command("create").description("Create a new file").argument("<path>", "File path to create").option("--content <text>", "File content").option("--from-stdin", "Read content from stdin").action(async (filePath, opts) => {
311
+ const startTime = Date.now();
312
+ const cmd = "file create";
313
+ try {
314
+ const resolvedPath = path2.resolve(filePath);
315
+ const dir = path2.dirname(resolvedPath);
316
+ if (!fs3.existsSync(dir)) {
317
+ fs3.mkdirSync(dir, { recursive: true });
318
+ }
319
+ let content = opts.content || "";
320
+ if (opts.fromStdin) {
321
+ content = await readStdin();
322
+ }
323
+ fs3.writeFileSync(resolvedPath, content, "utf-8");
324
+ const stats = fs3.statSync(resolvedPath);
325
+ output(success(cmd, { path: resolvedPath, size: stats.size }, startTime));
326
+ } catch (err) {
327
+ output(failure(cmd, "FILE_CREATE_ERROR", err.message, startTime));
328
+ }
329
+ });
330
+ }
331
+ function readStdin() {
332
+ return new Promise((resolve14, reject) => {
333
+ const chunks = [];
334
+ process.stdin.on("data", (chunk) => chunks.push(chunk));
335
+ process.stdin.on("end", () => resolve14(Buffer.concat(chunks).toString("utf-8")));
336
+ process.stdin.on("error", reject);
337
+ });
338
+ }
339
+ var fs3, path2;
340
+ var init_create = __esm({
341
+ "src/plugins/file/create.ts"() {
342
+ "use strict";
343
+ fs3 = __toESM(require("fs"));
344
+ path2 = __toESM(require("path"));
345
+ init_result();
346
+ }
347
+ });
348
+
349
+ // src/plugins/file/read.ts
350
+ function registerRead(parent) {
351
+ parent.command("read").description("Read a file").argument("<path>", "File path to read").option("--lines <range>", "Line range, e.g. 1:10").action(async (filePath, opts) => {
352
+ const startTime = Date.now();
353
+ const cmd = "file read";
354
+ try {
355
+ const resolvedPath = path3.resolve(filePath);
356
+ if (!fs4.existsSync(resolvedPath)) {
357
+ output(failure(cmd, "NOT_FOUND", `File not found: ${resolvedPath}`, startTime));
358
+ return;
359
+ }
360
+ const raw = fs4.readFileSync(resolvedPath, "utf-8");
361
+ let lines = raw.split("\n");
362
+ let startLine = 1;
363
+ let endLine = lines.length;
364
+ if (opts.lines) {
365
+ const parts = opts.lines.split(":");
366
+ startLine = Math.max(1, parseInt(parts[0], 10) || 1);
367
+ endLine = parts[1] ? parseInt(parts[1], 10) || lines.length : lines.length;
368
+ lines = lines.slice(startLine - 1, endLine);
369
+ }
370
+ output(success(cmd, {
371
+ path: resolvedPath,
372
+ content: lines.join("\n"),
373
+ lines: lines.length,
374
+ startLine,
375
+ endLine: Math.min(endLine, startLine + lines.length - 1)
376
+ }, startTime));
377
+ } catch (err) {
378
+ output(failure(cmd, "FILE_READ_ERROR", err.message, startTime));
379
+ }
380
+ });
381
+ }
382
+ var fs4, path3;
383
+ var init_read = __esm({
384
+ "src/plugins/file/read.ts"() {
385
+ "use strict";
386
+ fs4 = __toESM(require("fs"));
387
+ path3 = __toESM(require("path"));
388
+ init_result();
389
+ }
390
+ });
391
+
392
+ // src/plugins/file/update.ts
393
+ function registerUpdate(parent) {
394
+ parent.command("update").description("Overwrite a file with new content").argument("<path>", "File path to update").option("--content <text>", "New file content").option("--from-stdin", "Read content from stdin").action(async (filePath, opts) => {
395
+ const startTime = Date.now();
396
+ const cmd = "file update";
397
+ try {
398
+ const resolvedPath = path4.resolve(filePath);
399
+ if (!fs5.existsSync(resolvedPath)) {
400
+ output(failure(cmd, "NOT_FOUND", `File not found: ${resolvedPath}`, startTime));
401
+ return;
402
+ }
403
+ let content = opts.content || "";
404
+ if (opts.fromStdin) {
405
+ content = await readStdin2();
406
+ }
407
+ fs5.writeFileSync(resolvedPath, content, "utf-8");
408
+ const stats = fs5.statSync(resolvedPath);
409
+ output(success(cmd, { path: resolvedPath, size: stats.size }, startTime));
410
+ } catch (err) {
411
+ output(failure(cmd, "FILE_UPDATE_ERROR", err.message, startTime));
412
+ }
413
+ });
414
+ }
415
+ function readStdin2() {
416
+ return new Promise((resolve14, reject) => {
417
+ const chunks = [];
418
+ process.stdin.on("data", (chunk) => chunks.push(chunk));
419
+ process.stdin.on("end", () => resolve14(Buffer.concat(chunks).toString("utf-8")));
420
+ process.stdin.on("error", reject);
421
+ });
422
+ }
423
+ var fs5, path4;
424
+ var init_update = __esm({
425
+ "src/plugins/file/update.ts"() {
426
+ "use strict";
427
+ fs5 = __toESM(require("fs"));
428
+ path4 = __toESM(require("path"));
429
+ init_result();
430
+ }
431
+ });
432
+
433
+ // src/plugins/file/delete.ts
434
+ function registerDelete(parent) {
435
+ parent.command("delete").description("Delete a file").argument("<path>", "File path to delete").action(async (filePath) => {
436
+ const startTime = Date.now();
437
+ const cmd = "file delete";
438
+ try {
439
+ const resolvedPath = path5.resolve(filePath);
440
+ if (!fs6.existsSync(resolvedPath)) {
441
+ output(failure(cmd, "NOT_FOUND", `File not found: ${resolvedPath}`, startTime));
442
+ return;
443
+ }
444
+ fs6.unlinkSync(resolvedPath);
445
+ output(success(cmd, { path: resolvedPath, deleted: true }, startTime));
446
+ } catch (err) {
447
+ output(failure(cmd, "FILE_DELETE_ERROR", err.message, startTime));
448
+ }
449
+ });
450
+ }
451
+ var fs6, path5;
452
+ var init_delete = __esm({
453
+ "src/plugins/file/delete.ts"() {
454
+ "use strict";
455
+ fs6 = __toESM(require("fs"));
456
+ path5 = __toESM(require("path"));
457
+ init_result();
458
+ }
459
+ });
460
+
461
+ // src/plugins/file/move.ts
462
+ function registerMove(parent) {
463
+ parent.command("move").description("Move or rename a file").argument("<source>", "Source file path").argument("<dest>", "Destination file path").action(async (source, dest) => {
464
+ const startTime = Date.now();
465
+ const cmd = "file move";
466
+ try {
467
+ const resolvedSource = path6.resolve(source);
468
+ const resolvedDest = path6.resolve(dest);
469
+ if (!fs7.existsSync(resolvedSource)) {
470
+ output(failure(cmd, "NOT_FOUND", `Source file not found: ${resolvedSource}`, startTime));
471
+ return;
472
+ }
473
+ const destDir = path6.dirname(resolvedDest);
474
+ if (!fs7.existsSync(destDir)) {
475
+ fs7.mkdirSync(destDir, { recursive: true });
476
+ }
477
+ fs7.renameSync(resolvedSource, resolvedDest);
478
+ output(success(cmd, { source: resolvedSource, dest: resolvedDest }, startTime));
479
+ } catch (err) {
480
+ output(failure(cmd, "FILE_MOVE_ERROR", err.message, startTime));
481
+ }
482
+ });
483
+ }
484
+ var fs7, path6;
485
+ var init_move = __esm({
486
+ "src/plugins/file/move.ts"() {
487
+ "use strict";
488
+ fs7 = __toESM(require("fs"));
489
+ path6 = __toESM(require("path"));
490
+ init_result();
491
+ }
492
+ });
493
+
494
+ // src/plugins/file/patch.ts
495
+ function registerPatch(parent) {
496
+ parent.command("patch").description("Replace a string in a file").argument("<path>", "File path to patch").requiredOption("--search <text>", "String to search for").requiredOption("--replace <text>", "Replacement string").action(async (filePath, opts) => {
497
+ const startTime = Date.now();
498
+ const cmd = "file patch";
499
+ try {
500
+ const resolvedPath = path7.resolve(filePath);
501
+ if (!fs8.existsSync(resolvedPath)) {
502
+ output(failure(cmd, "NOT_FOUND", `File not found: ${resolvedPath}`, startTime));
503
+ return;
504
+ }
505
+ const content = fs8.readFileSync(resolvedPath, "utf-8");
506
+ if (!content.includes(opts.search)) {
507
+ output(failure(
508
+ cmd,
509
+ "SEARCH_NOT_FOUND",
510
+ `Search string not found in ${resolvedPath}`,
511
+ startTime
512
+ ));
513
+ return;
514
+ }
515
+ let replacements = 0;
516
+ let idx = 0;
517
+ while ((idx = content.indexOf(opts.search, idx)) !== -1) {
518
+ replacements++;
519
+ idx += opts.search.length;
520
+ }
521
+ const newContent = content.replaceAll(opts.search, opts.replace);
522
+ fs8.writeFileSync(resolvedPath, newContent, "utf-8");
523
+ output(success(cmd, { path: resolvedPath, replacements }, startTime));
524
+ } catch (err) {
525
+ output(failure(cmd, "FILE_PATCH_ERROR", err.message, startTime));
526
+ }
527
+ });
528
+ }
529
+ var fs8, path7;
530
+ var init_patch = __esm({
531
+ "src/plugins/file/patch.ts"() {
532
+ "use strict";
533
+ fs8 = __toESM(require("fs"));
534
+ path7 = __toESM(require("path"));
535
+ init_result();
536
+ }
537
+ });
538
+
539
+ // src/plugins/file/index.ts
540
+ var FilePlugin;
541
+ var init_file = __esm({
542
+ "src/plugins/file/index.ts"() {
543
+ "use strict";
544
+ init_create();
545
+ init_read();
546
+ init_update();
547
+ init_delete();
548
+ init_move();
549
+ init_patch();
550
+ FilePlugin = class {
551
+ name = "file";
552
+ version = "1.0.0";
553
+ description = "File operations (create, read, update, delete, move, patch)";
554
+ register(program) {
555
+ const file = program.command("file").description(this.description);
556
+ registerCreate(file);
557
+ registerRead(file);
558
+ registerUpdate(file);
559
+ registerDelete(file);
560
+ registerMove(file);
561
+ registerPatch(file);
562
+ }
563
+ getCommands() {
564
+ return [
565
+ {
566
+ name: "file create",
567
+ description: "Create a new file",
568
+ args: [{ name: "path", description: "File path", required: true, type: "string" }],
569
+ options: [
570
+ { name: "--content", description: "File content", required: false, type: "string" },
571
+ { name: "--from-stdin", description: "Read from stdin", required: false, type: "boolean" }
572
+ ],
573
+ examples: ['moxxy-agent file create src/main.ts --content "console.log(1)"']
574
+ },
575
+ {
576
+ name: "file read",
577
+ description: "Read a file",
578
+ args: [{ name: "path", description: "File path", required: true, type: "string" }],
579
+ options: [
580
+ { name: "--lines", description: "Line range (start:end)", required: false, type: "string" }
581
+ ],
582
+ examples: ["moxxy-agent file read src/main.ts --lines 1:10"]
583
+ },
584
+ {
585
+ name: "file update",
586
+ description: "Overwrite a file",
587
+ args: [{ name: "path", description: "File path", required: true, type: "string" }],
588
+ options: [
589
+ { name: "--content", description: "New content", required: false, type: "string" },
590
+ { name: "--from-stdin", description: "Read from stdin", required: false, type: "boolean" }
591
+ ],
592
+ examples: ['moxxy-agent file update src/main.ts --content "updated"']
593
+ },
594
+ {
595
+ name: "file delete",
596
+ description: "Delete a file",
597
+ args: [{ name: "path", description: "File path", required: true, type: "string" }],
598
+ options: [],
599
+ examples: ["moxxy-agent file delete src/old.ts"]
600
+ },
601
+ {
602
+ name: "file move",
603
+ description: "Move or rename a file",
604
+ args: [
605
+ { name: "source", description: "Source path", required: true, type: "string" },
606
+ { name: "dest", description: "Destination path", required: true, type: "string" }
607
+ ],
608
+ options: [],
609
+ examples: ["moxxy-agent file move src/old.ts src/new.ts"]
610
+ },
611
+ {
612
+ name: "file patch",
613
+ description: "Replace a string in a file",
614
+ args: [{ name: "path", description: "File path", required: true, type: "string" }],
615
+ options: [
616
+ { name: "--search", description: "String to find", required: true, type: "string" },
617
+ { name: "--replace", description: "Replacement string", required: true, type: "string" }
618
+ ],
619
+ examples: ['moxxy-agent file patch src/main.ts --search "old" --replace "new"']
620
+ }
621
+ ];
622
+ }
623
+ };
624
+ }
625
+ });
626
+
627
+ // src/plugins/dir/list.ts
628
+ function registerList(parent) {
629
+ parent.command("list").description("List directory entries").argument("[path]", "Directory path", ".").option("--recursive", "List recursively").option("--pattern <glob>", "Filter by glob pattern").action(async (dirPath, opts) => {
630
+ const startTime = Date.now();
631
+ const cmd = "dir list";
632
+ try {
633
+ const resolvedPath = path8.resolve(dirPath);
634
+ if (!fs9.existsSync(resolvedPath)) {
635
+ output(failure(cmd, "NOT_FOUND", `Directory not found: ${resolvedPath}`, startTime));
636
+ return;
637
+ }
638
+ if (!fs9.statSync(resolvedPath).isDirectory()) {
639
+ output(failure(cmd, "NOT_A_DIRECTORY", `Not a directory: ${resolvedPath}`, startTime));
640
+ return;
641
+ }
642
+ let entries;
643
+ if (opts.pattern || opts.recursive) {
644
+ const pattern = opts.pattern || (opts.recursive ? "**/*" : "*");
645
+ const matches = await (0, import_glob.glob)(pattern, {
646
+ cwd: resolvedPath,
647
+ dot: false,
648
+ nodir: false,
649
+ stat: true,
650
+ withFileTypes: true
651
+ });
652
+ entries = matches.map((entry) => ({
653
+ name: entry.relative(),
654
+ type: entry.isDirectory() ? "directory" : "file",
655
+ size: entry.isDirectory() ? 0 : fs9.statSync(path8.join(resolvedPath, entry.relative())).size
656
+ }));
657
+ } else {
658
+ const dirEntries = fs9.readdirSync(resolvedPath, { withFileTypes: true });
659
+ entries = dirEntries.map((entry) => ({
660
+ name: entry.name,
661
+ type: entry.isDirectory() ? "directory" : "file",
662
+ size: entry.isDirectory() ? 0 : fs9.statSync(path8.join(resolvedPath, entry.name)).size
663
+ }));
664
+ }
665
+ output(success(cmd, { path: resolvedPath, entries, count: entries.length }, startTime));
666
+ } catch (err) {
667
+ output(failure(cmd, "DIR_LIST_ERROR", err.message, startTime));
668
+ }
669
+ });
670
+ }
671
+ var fs9, path8, import_glob;
672
+ var init_list = __esm({
673
+ "src/plugins/dir/list.ts"() {
674
+ "use strict";
675
+ fs9 = __toESM(require("fs"));
676
+ path8 = __toESM(require("path"));
677
+ import_glob = require("glob");
678
+ init_result();
679
+ }
680
+ });
681
+
682
+ // src/plugins/dir/create.ts
683
+ function registerCreate2(parent) {
684
+ parent.command("create").description("Create a directory recursively").argument("<path>", "Directory path to create").action(async (dirPath) => {
685
+ const startTime = Date.now();
686
+ const cmd = "dir create";
687
+ try {
688
+ const resolvedPath = path9.resolve(dirPath);
689
+ fs10.mkdirSync(resolvedPath, { recursive: true });
690
+ output(success(cmd, { path: resolvedPath, created: true }, startTime));
691
+ } catch (err) {
692
+ output(failure(cmd, "DIR_CREATE_ERROR", err.message, startTime));
693
+ }
694
+ });
695
+ }
696
+ var fs10, path9;
697
+ var init_create2 = __esm({
698
+ "src/plugins/dir/create.ts"() {
699
+ "use strict";
700
+ fs10 = __toESM(require("fs"));
701
+ path9 = __toESM(require("path"));
702
+ init_result();
703
+ }
704
+ });
705
+
706
+ // src/plugins/dir/delete.ts
707
+ function registerDelete2(parent) {
708
+ parent.command("delete").description("Remove a directory").argument("<path>", "Directory path to remove").action(async (dirPath) => {
709
+ const startTime = Date.now();
710
+ const cmd = "dir delete";
711
+ try {
712
+ const resolvedPath = path10.resolve(dirPath);
713
+ if (!fs11.existsSync(resolvedPath)) {
714
+ output(failure(cmd, "NOT_FOUND", `Directory not found: ${resolvedPath}`, startTime));
715
+ return;
716
+ }
717
+ fs11.rmSync(resolvedPath, { recursive: true, force: true });
718
+ output(success(cmd, { path: resolvedPath, deleted: true }, startTime));
719
+ } catch (err) {
720
+ output(failure(cmd, "DIR_DELETE_ERROR", err.message, startTime));
721
+ }
722
+ });
723
+ }
724
+ var fs11, path10;
725
+ var init_delete2 = __esm({
726
+ "src/plugins/dir/delete.ts"() {
727
+ "use strict";
728
+ fs11 = __toESM(require("fs"));
729
+ path10 = __toESM(require("path"));
730
+ init_result();
731
+ }
732
+ });
733
+
734
+ // src/plugins/dir/tree.ts
735
+ function buildTree(dirPath, currentDepth, maxDepth) {
736
+ if (currentDepth >= maxDepth) {
737
+ return [];
738
+ }
739
+ const entries = fs12.readdirSync(dirPath, { withFileTypes: true });
740
+ const nodes = [];
741
+ for (const entry of entries) {
742
+ if (entry.name.startsWith(".") || entry.name === "node_modules") {
743
+ continue;
744
+ }
745
+ const node = {
746
+ name: entry.name,
747
+ type: entry.isDirectory() ? "directory" : "file"
748
+ };
749
+ if (entry.isDirectory()) {
750
+ node.children = buildTree(
751
+ path11.join(dirPath, entry.name),
752
+ currentDepth + 1,
753
+ maxDepth
754
+ );
755
+ }
756
+ nodes.push(node);
757
+ }
758
+ return nodes.sort((a, b) => {
759
+ if (a.type !== b.type) return a.type === "directory" ? -1 : 1;
760
+ return a.name.localeCompare(b.name);
761
+ });
762
+ }
763
+ function registerTree(parent) {
764
+ parent.command("tree").description("Display directory tree structure").argument("[path]", "Directory path", ".").option("--depth <n>", "Maximum depth", "3").action(async (dirPath, opts) => {
765
+ const startTime = Date.now();
766
+ const cmd = "dir tree";
767
+ try {
768
+ const resolvedPath = path11.resolve(dirPath);
769
+ const maxDepth = parseInt(opts.depth, 10) || 3;
770
+ if (!fs12.existsSync(resolvedPath)) {
771
+ output(failure(cmd, "NOT_FOUND", `Directory not found: ${resolvedPath}`, startTime));
772
+ return;
773
+ }
774
+ if (!fs12.statSync(resolvedPath).isDirectory()) {
775
+ output(failure(cmd, "NOT_A_DIRECTORY", `Not a directory: ${resolvedPath}`, startTime));
776
+ return;
777
+ }
778
+ const tree = buildTree(resolvedPath, 0, maxDepth);
779
+ output(success(cmd, { path: resolvedPath, tree, depth: maxDepth }, startTime));
780
+ } catch (err) {
781
+ output(failure(cmd, "DIR_TREE_ERROR", err.message, startTime));
782
+ }
783
+ });
784
+ }
785
+ var fs12, path11;
786
+ var init_tree = __esm({
787
+ "src/plugins/dir/tree.ts"() {
788
+ "use strict";
789
+ fs12 = __toESM(require("fs"));
790
+ path11 = __toESM(require("path"));
791
+ init_result();
792
+ }
793
+ });
794
+
795
+ // src/plugins/dir/index.ts
796
+ var DirPlugin;
797
+ var init_dir = __esm({
798
+ "src/plugins/dir/index.ts"() {
799
+ "use strict";
800
+ init_list();
801
+ init_create2();
802
+ init_delete2();
803
+ init_tree();
804
+ DirPlugin = class {
805
+ name = "dir";
806
+ version = "1.0.0";
807
+ description = "Directory operations (list, create, delete, tree)";
808
+ register(program) {
809
+ const dir = program.command("dir").description(this.description);
810
+ registerList(dir);
811
+ registerCreate2(dir);
812
+ registerDelete2(dir);
813
+ registerTree(dir);
814
+ }
815
+ getCommands() {
816
+ return [
817
+ {
818
+ name: "dir list",
819
+ description: "List directory entries",
820
+ args: [{ name: "path", description: "Directory path", required: false, type: "string" }],
821
+ options: [
822
+ { name: "--recursive", description: "List recursively", required: false, type: "boolean" },
823
+ { name: "--pattern", description: "Glob filter pattern", required: false, type: "string" }
824
+ ],
825
+ examples: ['moxxy-agent dir list src --recursive --pattern "*.ts"']
826
+ },
827
+ {
828
+ name: "dir create",
829
+ description: "Create a directory",
830
+ args: [{ name: "path", description: "Directory path", required: true, type: "string" }],
831
+ options: [],
832
+ examples: ["moxxy-agent dir create src/utils"]
833
+ },
834
+ {
835
+ name: "dir delete",
836
+ description: "Remove a directory",
837
+ args: [{ name: "path", description: "Directory path", required: true, type: "string" }],
838
+ options: [],
839
+ examples: ["moxxy-agent dir delete tmp"]
840
+ },
841
+ {
842
+ name: "dir tree",
843
+ description: "Display directory tree",
844
+ args: [{ name: "path", description: "Directory path", required: false, type: "string" }],
845
+ options: [
846
+ { name: "--depth", description: "Maximum depth", required: false, type: "number" }
847
+ ],
848
+ examples: ["moxxy-agent dir tree src --depth 2"]
849
+ }
850
+ ];
851
+ }
852
+ };
853
+ }
854
+ });
855
+
856
+ // src/plugins/git/init.ts
857
+ function registerInit2(parent) {
858
+ parent.command("init").description("Initialize a new git repository").argument("[path]", "Directory to initialize", ".").action(async (dirPath) => {
859
+ const startTime = Date.now();
860
+ const cmd = "git init";
861
+ try {
862
+ const { stdout } = await exec("git", ["init", dirPath]);
863
+ output(success(cmd, { path: dirPath, message: stdout.trim() }, startTime));
864
+ } catch (err) {
865
+ output(failure(cmd, "GIT_INIT_ERROR", err.message, startTime, err.stderr));
866
+ }
867
+ });
868
+ }
869
+ var init_init2 = __esm({
870
+ "src/plugins/git/init.ts"() {
871
+ "use strict";
872
+ init_exec();
873
+ init_result();
874
+ }
875
+ });
876
+
877
+ // src/plugins/git/clone.ts
878
+ function registerClone(parent) {
879
+ parent.command("clone").description("Clone a git repository").argument("<url>", "Repository URL").argument("[directory]", "Target directory").option("--branch <name>", "Branch to clone").action(async (url, directory, opts) => {
880
+ const startTime = Date.now();
881
+ const cmd = "git clone";
882
+ try {
883
+ const args = ["clone"];
884
+ if (opts.branch) {
885
+ args.push("--branch", opts.branch);
886
+ }
887
+ args.push(url);
888
+ if (directory) {
889
+ args.push(directory);
890
+ }
891
+ log(`Cloning ${url}...`);
892
+ const { stdout, stderr } = await exec("git", args);
893
+ output(success(cmd, {
894
+ url,
895
+ directory: directory || url.split("/").pop()?.replace(".git", ""),
896
+ branch: opts.branch,
897
+ message: (stdout || stderr).trim()
898
+ }, startTime));
899
+ } catch (err) {
900
+ output(failure(cmd, "GIT_CLONE_ERROR", err.message, startTime, err.stderr));
901
+ }
902
+ });
903
+ }
904
+ var init_clone = __esm({
905
+ "src/plugins/git/clone.ts"() {
906
+ "use strict";
907
+ init_exec();
908
+ init_result();
909
+ }
910
+ });
911
+
912
+ // src/plugins/git/branch.ts
913
+ function registerBranch(parent) {
914
+ parent.command("branch").description("Create or list branches").argument("[name]", "Branch name to create").option("--list", "List all branches").action(async (name, opts) => {
915
+ const startTime = Date.now();
916
+ const cmd = "git branch";
917
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
918
+ try {
919
+ if (opts.list || !name) {
920
+ const { stdout } = await exec("git", ["branch", "-a"], { cwd });
921
+ const branches = stdout.split("\n").filter((line) => line.trim()).map((line) => {
922
+ const isCurrent = line.startsWith("* ");
923
+ const branchName = line.replace(/^\*?\s+/, "").trim();
924
+ return { name: branchName, current: isCurrent };
925
+ });
926
+ output(success(cmd, { branches }, startTime));
927
+ } else {
928
+ const { stdout } = await exec("git", ["branch", name], { cwd });
929
+ output(success(cmd, { name, created: true, message: stdout.trim() }, startTime));
930
+ }
931
+ } catch (err) {
932
+ output(failure(cmd, "GIT_BRANCH_ERROR", err.message, startTime, err.stderr));
933
+ }
934
+ });
935
+ }
936
+ var init_branch = __esm({
937
+ "src/plugins/git/branch.ts"() {
938
+ "use strict";
939
+ init_exec();
940
+ init_result();
941
+ }
942
+ });
943
+
944
+ // src/plugins/git/checkout.ts
945
+ function registerCheckout(parent) {
946
+ parent.command("checkout").description("Checkout a branch").argument("<branch>", "Branch name to checkout").option("-b", "Create new branch").action(async (branch, opts) => {
947
+ const startTime = Date.now();
948
+ const cmd = "git checkout";
949
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
950
+ try {
951
+ const args = ["checkout"];
952
+ if (opts.b) {
953
+ args.push("-b");
954
+ }
955
+ args.push(branch);
956
+ const { stdout, stderr } = await exec("git", args, { cwd });
957
+ output(success(cmd, {
958
+ branch,
959
+ created: !!opts.b,
960
+ message: (stderr || stdout).trim()
961
+ }, startTime));
962
+ } catch (err) {
963
+ output(failure(cmd, "GIT_CHECKOUT_ERROR", err.message, startTime, err.stderr));
964
+ }
965
+ });
966
+ }
967
+ var init_checkout = __esm({
968
+ "src/plugins/git/checkout.ts"() {
969
+ "use strict";
970
+ init_exec();
971
+ init_result();
972
+ }
973
+ });
974
+
975
+ // src/plugins/git/add.ts
976
+ function registerAdd(parent) {
977
+ parent.command("add").description("Stage files for commit").argument("[files...]", "Files to stage").option("--all", "Stage all changes").action(async (files, opts) => {
978
+ const startTime = Date.now();
979
+ const cmd = "git add";
980
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
981
+ try {
982
+ const args = ["add"];
983
+ if (opts.all) {
984
+ args.push("-A");
985
+ } else if (files.length > 0) {
986
+ args.push(...files);
987
+ } else {
988
+ output(failure(
989
+ cmd,
990
+ "MISSING_ARGUMENT",
991
+ "Provide files to stage or use --all",
992
+ startTime
993
+ ));
994
+ return;
995
+ }
996
+ await exec("git", args, { cwd });
997
+ output(success(cmd, {
998
+ files: opts.all ? ["(all)"] : files,
999
+ staged: true
1000
+ }, startTime));
1001
+ } catch (err) {
1002
+ output(failure(cmd, "GIT_ADD_ERROR", err.message, startTime, err.stderr));
1003
+ }
1004
+ });
1005
+ }
1006
+ var init_add = __esm({
1007
+ "src/plugins/git/add.ts"() {
1008
+ "use strict";
1009
+ init_exec();
1010
+ init_result();
1011
+ }
1012
+ });
1013
+
1014
+ // src/plugins/git/commit.ts
1015
+ function registerCommit(parent) {
1016
+ parent.command("commit").description("Create a git commit").requiredOption("-m <message>", "Commit message").action(async (opts) => {
1017
+ const startTime = Date.now();
1018
+ const cmd = "git commit";
1019
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1020
+ try {
1021
+ const { stdout } = await exec("git", ["commit", "-m", opts.m], { cwd });
1022
+ const match = stdout.match(/\[.+?\s+([a-f0-9]+)\]/);
1023
+ const hash = match?.[1] || "";
1024
+ output(success(cmd, {
1025
+ hash,
1026
+ message: opts.m,
1027
+ output: stdout.trim()
1028
+ }, startTime));
1029
+ } catch (err) {
1030
+ const isNothingToCommit = err.stdout?.includes("nothing to commit") || err.stderr?.includes("nothing to commit");
1031
+ if (isNothingToCommit) {
1032
+ output(failure(
1033
+ cmd,
1034
+ "NOTHING_TO_COMMIT",
1035
+ "Nothing to commit, working tree clean",
1036
+ startTime
1037
+ ));
1038
+ } else {
1039
+ output(failure(cmd, "GIT_COMMIT_ERROR", err.message, startTime, err.stderr));
1040
+ }
1041
+ }
1042
+ });
1043
+ }
1044
+ var init_commit = __esm({
1045
+ "src/plugins/git/commit.ts"() {
1046
+ "use strict";
1047
+ init_exec();
1048
+ init_result();
1049
+ }
1050
+ });
1051
+
1052
+ // src/plugins/git/push.ts
1053
+ function registerPush(parent) {
1054
+ parent.command("push").description("Push commits to remote").option("--set-upstream", "Set upstream tracking branch").option("--remote <name>", "Remote name", "origin").option("--branch <name>", "Branch name").action(async (opts) => {
1055
+ const startTime = Date.now();
1056
+ const cmd = "git push";
1057
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1058
+ try {
1059
+ const args = ["push"];
1060
+ if (opts.setUpstream) {
1061
+ args.push("--set-upstream");
1062
+ args.push(opts.remote);
1063
+ if (opts.branch) {
1064
+ args.push(opts.branch);
1065
+ } else {
1066
+ const { stdout: stdout2 } = await exec("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd });
1067
+ args.push(stdout2.trim());
1068
+ }
1069
+ }
1070
+ const { stdout, stderr } = await exec("git", args, { cwd });
1071
+ output(success(cmd, { message: (stderr || stdout).trim() }, startTime));
1072
+ } catch (err) {
1073
+ output(failure(cmd, "GIT_PUSH_ERROR", err.message, startTime, err.stderr));
1074
+ }
1075
+ });
1076
+ }
1077
+ var init_push = __esm({
1078
+ "src/plugins/git/push.ts"() {
1079
+ "use strict";
1080
+ init_exec();
1081
+ init_result();
1082
+ }
1083
+ });
1084
+
1085
+ // src/plugins/git/pull.ts
1086
+ function registerPull(parent) {
1087
+ parent.command("pull").description("Pull changes from remote").action(async () => {
1088
+ const startTime = Date.now();
1089
+ const cmd = "git pull";
1090
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1091
+ try {
1092
+ const { stdout, stderr } = await exec("git", ["pull"], { cwd });
1093
+ output(success(cmd, { message: (stdout || stderr).trim() }, startTime));
1094
+ } catch (err) {
1095
+ output(failure(cmd, "GIT_PULL_ERROR", err.message, startTime, err.stderr));
1096
+ }
1097
+ });
1098
+ }
1099
+ var init_pull = __esm({
1100
+ "src/plugins/git/pull.ts"() {
1101
+ "use strict";
1102
+ init_exec();
1103
+ init_result();
1104
+ }
1105
+ });
1106
+
1107
+ // src/plugins/git/diff.ts
1108
+ function registerDiff(parent) {
1109
+ parent.command("diff").description("Show changes").option("--staged", "Show staged changes").action(async (opts) => {
1110
+ const startTime = Date.now();
1111
+ const cmd = "git diff";
1112
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1113
+ try {
1114
+ const args = ["diff"];
1115
+ if (opts.staged) {
1116
+ args.push("--staged");
1117
+ }
1118
+ const { stdout } = await exec("git", args, { cwd });
1119
+ output(success(cmd, { diff: stdout, staged: !!opts.staged }, startTime));
1120
+ } catch (err) {
1121
+ output(failure(cmd, "GIT_DIFF_ERROR", err.message, startTime, err.stderr));
1122
+ }
1123
+ });
1124
+ }
1125
+ var init_diff = __esm({
1126
+ "src/plugins/git/diff.ts"() {
1127
+ "use strict";
1128
+ init_exec();
1129
+ init_result();
1130
+ }
1131
+ });
1132
+
1133
+ // src/plugins/git/status.ts
1134
+ function parsePorcelain(raw) {
1135
+ return raw.split("\n").filter((line) => line.trim()).map((line) => {
1136
+ const status = line.substring(0, 2).trim();
1137
+ const filePath = line.substring(3);
1138
+ return { status, path: filePath };
1139
+ });
1140
+ }
1141
+ function registerStatus(parent) {
1142
+ parent.command("status").description("Show working tree status").action(async () => {
1143
+ const startTime = Date.now();
1144
+ const cmd = "git status";
1145
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1146
+ try {
1147
+ const { stdout } = await exec("git", ["status", "--porcelain"], { cwd });
1148
+ const entries = parsePorcelain(stdout);
1149
+ const isClean = entries.length === 0;
1150
+ output(success(cmd, {
1151
+ clean: isClean,
1152
+ entries,
1153
+ staged: entries.filter((e) => ["A", "M", "D", "R"].includes(e.status[0])),
1154
+ unstaged: entries.filter((e) => e.status.length > 1 && e.status[1] !== " "),
1155
+ untracked: entries.filter((e) => e.status === "??")
1156
+ }, startTime));
1157
+ } catch (err) {
1158
+ output(failure(cmd, "GIT_STATUS_ERROR", err.message, startTime, err.stderr));
1159
+ }
1160
+ });
1161
+ }
1162
+ var init_status = __esm({
1163
+ "src/plugins/git/status.ts"() {
1164
+ "use strict";
1165
+ init_exec();
1166
+ init_result();
1167
+ }
1168
+ });
1169
+
1170
+ // src/plugins/git/log.ts
1171
+ function parseLog(raw) {
1172
+ return raw.split("\n").filter((line) => line.trim()).map((line) => {
1173
+ const spaceIdx = line.indexOf(" ");
1174
+ if (spaceIdx === -1) return { hash: line, message: "" };
1175
+ return {
1176
+ hash: line.substring(0, spaceIdx),
1177
+ message: line.substring(spaceIdx + 1)
1178
+ };
1179
+ });
1180
+ }
1181
+ function registerLog(parent) {
1182
+ parent.command("log").description("Show commit log").option("--limit <n>", "Number of commits to show", "10").action(async (opts) => {
1183
+ const startTime = Date.now();
1184
+ const cmd = "git log";
1185
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1186
+ try {
1187
+ const limit = parseInt(opts.limit, 10) || 10;
1188
+ const { stdout } = await exec(
1189
+ "git",
1190
+ ["log", `--oneline`, `-n`, String(limit)],
1191
+ { cwd }
1192
+ );
1193
+ const commits = parseLog(stdout);
1194
+ output(success(cmd, { commits, count: commits.length }, startTime));
1195
+ } catch (err) {
1196
+ output(failure(cmd, "GIT_LOG_ERROR", err.message, startTime, err.stderr));
1197
+ }
1198
+ });
1199
+ }
1200
+ var init_log = __esm({
1201
+ "src/plugins/git/log.ts"() {
1202
+ "use strict";
1203
+ init_exec();
1204
+ init_result();
1205
+ }
1206
+ });
1207
+
1208
+ // src/plugins/git/index.ts
1209
+ var GitPlugin;
1210
+ var init_git = __esm({
1211
+ "src/plugins/git/index.ts"() {
1212
+ "use strict";
1213
+ init_init2();
1214
+ init_clone();
1215
+ init_branch();
1216
+ init_checkout();
1217
+ init_add();
1218
+ init_commit();
1219
+ init_push();
1220
+ init_pull();
1221
+ init_diff();
1222
+ init_status();
1223
+ init_log();
1224
+ GitPlugin = class {
1225
+ name = "git";
1226
+ version = "1.0.0";
1227
+ description = "Git operations";
1228
+ register(program) {
1229
+ const git = program.command("git").description(this.description);
1230
+ registerInit2(git);
1231
+ registerClone(git);
1232
+ registerBranch(git);
1233
+ registerCheckout(git);
1234
+ registerAdd(git);
1235
+ registerCommit(git);
1236
+ registerPush(git);
1237
+ registerPull(git);
1238
+ registerDiff(git);
1239
+ registerStatus(git);
1240
+ registerLog(git);
1241
+ }
1242
+ getCommands() {
1243
+ return [
1244
+ {
1245
+ name: "git init",
1246
+ description: "Initialize a new git repository",
1247
+ args: [{ name: "path", description: "Directory path", required: false, type: "string" }],
1248
+ options: [],
1249
+ examples: ["moxxy-agent git init ."]
1250
+ },
1251
+ {
1252
+ name: "git clone",
1253
+ description: "Clone a git repository",
1254
+ args: [
1255
+ { name: "url", description: "Repository URL", required: true, type: "string" },
1256
+ { name: "directory", description: "Target directory", required: false, type: "string" }
1257
+ ],
1258
+ options: [
1259
+ { name: "--branch", description: "Branch to clone", required: false, type: "string" }
1260
+ ],
1261
+ examples: ["moxxy-agent git clone https://github.com/org/repo --branch main"]
1262
+ },
1263
+ {
1264
+ name: "git branch",
1265
+ description: "Create or list branches",
1266
+ args: [{ name: "name", description: "Branch name", required: false, type: "string" }],
1267
+ options: [
1268
+ { name: "--list", description: "List all branches", required: false, type: "boolean" }
1269
+ ],
1270
+ examples: ["moxxy-agent git branch --list", "moxxy-agent git branch feat/new"]
1271
+ },
1272
+ {
1273
+ name: "git checkout",
1274
+ description: "Checkout a branch",
1275
+ args: [{ name: "branch", description: "Branch name", required: true, type: "string" }],
1276
+ options: [
1277
+ { name: "-b", description: "Create new branch", required: false, type: "boolean" }
1278
+ ],
1279
+ examples: ["moxxy-agent git checkout main", "moxxy-agent git checkout -b feat/new"]
1280
+ },
1281
+ {
1282
+ name: "git add",
1283
+ description: "Stage files for commit",
1284
+ args: [{ name: "files", description: "Files to stage", required: false, type: "string" }],
1285
+ options: [
1286
+ { name: "--all", description: "Stage all changes", required: false, type: "boolean" }
1287
+ ],
1288
+ examples: ["moxxy-agent git add src/main.ts", "moxxy-agent git add --all"]
1289
+ },
1290
+ {
1291
+ name: "git commit",
1292
+ description: "Create a commit",
1293
+ args: [],
1294
+ options: [
1295
+ { name: "-m", description: "Commit message", required: true, type: "string" }
1296
+ ],
1297
+ examples: ['moxxy-agent git commit -m "feat: add feature"']
1298
+ },
1299
+ {
1300
+ name: "git push",
1301
+ description: "Push commits to remote",
1302
+ args: [],
1303
+ options: [
1304
+ { name: "--set-upstream", description: "Set upstream tracking", required: false, type: "boolean" },
1305
+ { name: "--remote", description: "Remote name", required: false, type: "string" },
1306
+ { name: "--branch", description: "Branch name", required: false, type: "string" }
1307
+ ],
1308
+ examples: ["moxxy-agent git push", "moxxy-agent git push --set-upstream"]
1309
+ },
1310
+ {
1311
+ name: "git pull",
1312
+ description: "Pull changes from remote",
1313
+ args: [],
1314
+ options: [],
1315
+ examples: ["moxxy-agent git pull"]
1316
+ },
1317
+ {
1318
+ name: "git diff",
1319
+ description: "Show changes",
1320
+ args: [],
1321
+ options: [
1322
+ { name: "--staged", description: "Show staged changes", required: false, type: "boolean" }
1323
+ ],
1324
+ examples: ["moxxy-agent git diff", "moxxy-agent git diff --staged"]
1325
+ },
1326
+ {
1327
+ name: "git status",
1328
+ description: "Show working tree status",
1329
+ args: [],
1330
+ options: [],
1331
+ examples: ["moxxy-agent git status"]
1332
+ },
1333
+ {
1334
+ name: "git log",
1335
+ description: "Show commit log",
1336
+ args: [],
1337
+ options: [
1338
+ { name: "--limit", description: "Number of commits", required: false, type: "number" }
1339
+ ],
1340
+ examples: ["moxxy-agent git log --limit 20"]
1341
+ }
1342
+ ];
1343
+ }
1344
+ };
1345
+ }
1346
+ });
1347
+
1348
+ // src/plugins/search/code.ts
1349
+ function parseGrepOutput(raw) {
1350
+ return raw.split("\n").filter((line) => line.trim()).map((line) => {
1351
+ const firstColon = line.indexOf(":");
1352
+ const secondColon = line.indexOf(":", firstColon + 1);
1353
+ if (firstColon === -1 || secondColon === -1) {
1354
+ return { file: "", line: 0, content: line };
1355
+ }
1356
+ return {
1357
+ file: line.substring(0, firstColon),
1358
+ line: parseInt(line.substring(firstColon + 1, secondColon), 10) || 0,
1359
+ content: line.substring(secondColon + 1)
1360
+ };
1361
+ }).filter((m) => m.file);
1362
+ }
1363
+ function registerCode(parent) {
1364
+ parent.command("code").description("Search for code patterns").argument("<query>", "Search query (regex pattern)").option("--path <dir>", "Directory to search in", ".").option("--type <ext>", "File extension filter (e.g., ts, js)").action(async (query, opts) => {
1365
+ const startTime = Date.now();
1366
+ const cmd = "search code";
1367
+ try {
1368
+ let matches;
1369
+ try {
1370
+ const args = ["--line-number", "--no-heading", "--color", "never"];
1371
+ if (opts.type) {
1372
+ args.push("--type", opts.type);
1373
+ }
1374
+ args.push(query, opts.path);
1375
+ const { stdout } = await exec("rg", args);
1376
+ matches = parseGrepOutput(stdout);
1377
+ } catch {
1378
+ const args = ["-rn"];
1379
+ if (opts.type) {
1380
+ args.push("--include", `*.${opts.type}`);
1381
+ }
1382
+ args.push(query, opts.path);
1383
+ try {
1384
+ const { stdout } = await exec("grep", args);
1385
+ matches = parseGrepOutput(stdout);
1386
+ } catch (grepErr) {
1387
+ if (grepErr.code === 1) {
1388
+ matches = [];
1389
+ } else {
1390
+ throw grepErr;
1391
+ }
1392
+ }
1393
+ }
1394
+ output(success(cmd, { query, matches, count: matches.length }, startTime));
1395
+ } catch (err) {
1396
+ output(failure(cmd, "SEARCH_CODE_ERROR", err.message, startTime, err.stderr));
1397
+ }
1398
+ });
1399
+ }
1400
+ var init_code = __esm({
1401
+ "src/plugins/search/code.ts"() {
1402
+ "use strict";
1403
+ init_exec();
1404
+ init_result();
1405
+ }
1406
+ });
1407
+
1408
+ // src/plugins/search/files.ts
1409
+ function registerFiles(parent) {
1410
+ parent.command("files").description("Find files matching a glob pattern").argument("<pattern>", "Glob pattern").option("--path <dir>", "Directory to search in", ".").action(async (pattern, opts) => {
1411
+ const startTime = Date.now();
1412
+ const cmd = "search files";
1413
+ try {
1414
+ const searchDir = path12.resolve(opts.path);
1415
+ const matches = await (0, import_glob2.glob)(pattern, {
1416
+ cwd: searchDir,
1417
+ nodir: false,
1418
+ dot: false,
1419
+ ignore: ["node_modules/**", ".git/**"]
1420
+ });
1421
+ const files = matches.map((match) => path12.join(searchDir, match));
1422
+ output(success(cmd, { pattern, files, count: files.length }, startTime));
1423
+ } catch (err) {
1424
+ output(failure(cmd, "SEARCH_FILES_ERROR", err.message, startTime));
1425
+ }
1426
+ });
1427
+ }
1428
+ var path12, import_glob2;
1429
+ var init_files = __esm({
1430
+ "src/plugins/search/files.ts"() {
1431
+ "use strict";
1432
+ path12 = __toESM(require("path"));
1433
+ import_glob2 = require("glob");
1434
+ init_result();
1435
+ }
1436
+ });
1437
+
1438
+ // src/plugins/search/docs.ts
1439
+ function registerDocs(parent) {
1440
+ parent.command("docs").description("Search documentation files (README, markdown, comments)").argument("<query>", "Search query").option("--path <dir>", "Directory to search in", ".").action(async (query, opts) => {
1441
+ const startTime = Date.now();
1442
+ const cmd = "search docs";
1443
+ try {
1444
+ const searchDir = path13.resolve(opts.path);
1445
+ const docPatterns = ["**/*.md", "**/README*", "**/*.txt", "**/CHANGELOG*", "**/LICENSE*"];
1446
+ const matches = [];
1447
+ for (const pattern of docPatterns) {
1448
+ const files = await (0, import_glob3.glob)(pattern, {
1449
+ cwd: searchDir,
1450
+ nodir: true,
1451
+ dot: false,
1452
+ ignore: ["node_modules/**", ".git/**"]
1453
+ });
1454
+ for (const file of files) {
1455
+ const fullPath = path13.join(searchDir, file);
1456
+ try {
1457
+ const content = fs13.readFileSync(fullPath, "utf-8");
1458
+ const lines = content.split("\n");
1459
+ const queryLower = query.toLowerCase();
1460
+ for (let i = 0; i < lines.length; i++) {
1461
+ if (lines[i].toLowerCase().includes(queryLower)) {
1462
+ matches.push({
1463
+ file,
1464
+ line: i + 1,
1465
+ content: lines[i].trim()
1466
+ });
1467
+ }
1468
+ }
1469
+ } catch {
1470
+ }
1471
+ }
1472
+ }
1473
+ output(success(cmd, { query, matches, count: matches.length }, startTime));
1474
+ } catch (err) {
1475
+ output(failure(cmd, "SEARCH_DOCS_ERROR", err.message, startTime));
1476
+ }
1477
+ });
1478
+ }
1479
+ var fs13, path13, import_glob3;
1480
+ var init_docs = __esm({
1481
+ "src/plugins/search/docs.ts"() {
1482
+ "use strict";
1483
+ fs13 = __toESM(require("fs"));
1484
+ path13 = __toESM(require("path"));
1485
+ import_glob3 = require("glob");
1486
+ init_result();
1487
+ }
1488
+ });
1489
+
1490
+ // src/plugins/search/index.ts
1491
+ var SearchPlugin;
1492
+ var init_search = __esm({
1493
+ "src/plugins/search/index.ts"() {
1494
+ "use strict";
1495
+ init_code();
1496
+ init_files();
1497
+ init_docs();
1498
+ SearchPlugin = class {
1499
+ name = "search";
1500
+ version = "1.0.0";
1501
+ description = "Search operations (code, files, docs)";
1502
+ register(program) {
1503
+ const search = program.command("search").description(this.description);
1504
+ registerCode(search);
1505
+ registerFiles(search);
1506
+ registerDocs(search);
1507
+ }
1508
+ getCommands() {
1509
+ return [
1510
+ {
1511
+ name: "search code",
1512
+ description: "Search for code patterns using ripgrep/grep",
1513
+ args: [{ name: "query", description: "Regex pattern", required: true, type: "string" }],
1514
+ options: [
1515
+ { name: "--path", description: "Directory to search", required: false, type: "string" },
1516
+ { name: "--type", description: "File extension filter", required: false, type: "string" }
1517
+ ],
1518
+ examples: ['moxxy-agent search code "TODO" --type ts']
1519
+ },
1520
+ {
1521
+ name: "search files",
1522
+ description: "Find files matching a glob pattern",
1523
+ args: [{ name: "pattern", description: "Glob pattern", required: true, type: "string" }],
1524
+ options: [
1525
+ { name: "--path", description: "Directory to search", required: false, type: "string" }
1526
+ ],
1527
+ examples: ['moxxy-agent search files "**/*.ts" --path src']
1528
+ },
1529
+ {
1530
+ name: "search docs",
1531
+ description: "Search documentation files",
1532
+ args: [{ name: "query", description: "Search query", required: true, type: "string" }],
1533
+ options: [
1534
+ { name: "--path", description: "Directory to search", required: false, type: "string" }
1535
+ ],
1536
+ examples: ['moxxy-agent search docs "installation"']
1537
+ }
1538
+ ];
1539
+ }
1540
+ };
1541
+ }
1542
+ });
1543
+
1544
+ // src/plugins/pr/create.ts
1545
+ function registerCreate3(parent) {
1546
+ parent.command("create").description("Create a pull request").requiredOption("--title <text>", "PR title").option("--body <text>", "PR body/description").option("--base <branch>", "Base branch").action(async (opts) => {
1547
+ const startTime = Date.now();
1548
+ const cmd = "pr create";
1549
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1550
+ try {
1551
+ const args = ["pr", "create", "--title", opts.title];
1552
+ if (opts.body) {
1553
+ args.push("--body", opts.body);
1554
+ }
1555
+ if (opts.base) {
1556
+ args.push("--base", opts.base);
1557
+ }
1558
+ log(`Creating PR: ${opts.title}`);
1559
+ const { stdout } = await exec("gh", args, { cwd });
1560
+ const url = stdout.trim();
1561
+ output(success(cmd, {
1562
+ url,
1563
+ title: opts.title,
1564
+ base: opts.base
1565
+ }, startTime));
1566
+ } catch (err) {
1567
+ output(failure(cmd, "PR_CREATE_ERROR", err.message, startTime, err.stderr));
1568
+ }
1569
+ });
1570
+ }
1571
+ var init_create3 = __esm({
1572
+ "src/plugins/pr/create.ts"() {
1573
+ "use strict";
1574
+ init_exec();
1575
+ init_result();
1576
+ }
1577
+ });
1578
+
1579
+ // src/plugins/pr/comment.ts
1580
+ function registerComment(parent) {
1581
+ parent.command("comment").description("Add a comment to a pull request").argument("<number>", "PR number").requiredOption("--body <text>", "Comment body").action(async (number, opts) => {
1582
+ const startTime = Date.now();
1583
+ const cmd = "pr comment";
1584
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1585
+ try {
1586
+ const { stdout } = await exec(
1587
+ "gh",
1588
+ ["pr", "comment", number, "--body", opts.body],
1589
+ { cwd }
1590
+ );
1591
+ output(success(cmd, {
1592
+ prNumber: parseInt(number, 10),
1593
+ commented: true,
1594
+ url: stdout.trim()
1595
+ }, startTime));
1596
+ } catch (err) {
1597
+ output(failure(cmd, "PR_COMMENT_ERROR", err.message, startTime, err.stderr));
1598
+ }
1599
+ });
1600
+ }
1601
+ var init_comment = __esm({
1602
+ "src/plugins/pr/comment.ts"() {
1603
+ "use strict";
1604
+ init_exec();
1605
+ init_result();
1606
+ }
1607
+ });
1608
+
1609
+ // src/plugins/pr/index.ts
1610
+ var PRPlugin;
1611
+ var init_pr = __esm({
1612
+ "src/plugins/pr/index.ts"() {
1613
+ "use strict";
1614
+ init_create3();
1615
+ init_comment();
1616
+ PRPlugin = class {
1617
+ name = "pr";
1618
+ version = "1.0.0";
1619
+ description = "Pull request operations (create, comment)";
1620
+ register(program) {
1621
+ const pr = program.command("pr").description(this.description);
1622
+ registerCreate3(pr);
1623
+ registerComment(pr);
1624
+ }
1625
+ getCommands() {
1626
+ return [
1627
+ {
1628
+ name: "pr create",
1629
+ description: "Create a pull request using gh CLI",
1630
+ args: [],
1631
+ options: [
1632
+ { name: "--title", description: "PR title", required: true, type: "string" },
1633
+ { name: "--body", description: "PR description", required: false, type: "string" },
1634
+ { name: "--base", description: "Base branch", required: false, type: "string" }
1635
+ ],
1636
+ examples: ['moxxy-agent pr create --title "feat: add feature" --base main']
1637
+ },
1638
+ {
1639
+ name: "pr comment",
1640
+ description: "Comment on a pull request",
1641
+ args: [{ name: "number", description: "PR number", required: true, type: "number" }],
1642
+ options: [
1643
+ { name: "--body", description: "Comment text", required: true, type: "string" }
1644
+ ],
1645
+ examples: ['moxxy-agent pr comment 42 --body "LGTM"']
1646
+ }
1647
+ ];
1648
+ }
1649
+ };
1650
+ }
1651
+ });
1652
+
1653
+ // src/plugins/workflow/run.ts
1654
+ async function executeStep(step, cwd) {
1655
+ const args = [step.plugin, step.command];
1656
+ for (const [key, value] of Object.entries(step.args)) {
1657
+ if (typeof value === "boolean") {
1658
+ if (value) args.push(`--${key}`);
1659
+ } else {
1660
+ args.push(`--${key}`, String(value));
1661
+ }
1662
+ }
1663
+ const startTime = Date.now();
1664
+ try {
1665
+ const { stdout } = await exec("moxxy-agent", args, { cwd });
1666
+ const result = JSON.parse(stdout.trim());
1667
+ return { stepId: step.id, result, skipped: false };
1668
+ } catch (err) {
1669
+ return {
1670
+ stepId: step.id,
1671
+ result: {
1672
+ success: false,
1673
+ command: `${step.plugin} ${step.command}`,
1674
+ error: { code: "STEP_FAILED", message: err.message },
1675
+ duration_ms: Date.now() - startTime
1676
+ },
1677
+ skipped: false
1678
+ };
1679
+ }
1680
+ }
1681
+ function topologicalSort(steps) {
1682
+ const visited = /* @__PURE__ */ new Set();
1683
+ const sorted = [];
1684
+ const stepsById = new Map(steps.map((s) => [s.id, s]));
1685
+ function visit(step) {
1686
+ if (visited.has(step.id)) return;
1687
+ visited.add(step.id);
1688
+ for (const depId of step.dependsOn || []) {
1689
+ const dep = stepsById.get(depId);
1690
+ if (dep) visit(dep);
1691
+ }
1692
+ sorted.push(step);
1693
+ }
1694
+ for (const step of steps) {
1695
+ visit(step);
1696
+ }
1697
+ return sorted;
1698
+ }
1699
+ function registerRun(parent) {
1700
+ parent.command("run").description("Run a workflow from a JSON file").argument("<workflow-file>", "Path to workflow JSON file").action(async (workflowFile) => {
1701
+ const startTime = Date.now();
1702
+ const cmd = "workflow run";
1703
+ const cwd = parent.optsWithGlobals().cwd || process.cwd();
1704
+ try {
1705
+ const filePath = path14.resolve(workflowFile);
1706
+ if (!fs14.existsSync(filePath)) {
1707
+ output(failure(cmd, "NOT_FOUND", `Workflow file not found: ${filePath}`, startTime));
1708
+ return;
1709
+ }
1710
+ const raw = JSON.parse(fs14.readFileSync(filePath, "utf-8"));
1711
+ const workflow = import_types.workflowSchema.parse(raw);
1712
+ log(`Running workflow: ${workflow.name}`);
1713
+ const sortedSteps = topologicalSort(workflow.steps);
1714
+ const stepResults = [];
1715
+ const completedSteps = /* @__PURE__ */ new Set();
1716
+ let allSuccess = true;
1717
+ for (const step of sortedSteps) {
1718
+ const depsFailed = (step.dependsOn || []).some((depId) => {
1719
+ const depResult = stepResults.find((r) => r.stepId === depId);
1720
+ return depResult && !depResult.result.success;
1721
+ });
1722
+ if (depsFailed) {
1723
+ if (step.optional) {
1724
+ stepResults.push({
1725
+ stepId: step.id,
1726
+ result: {
1727
+ success: false,
1728
+ command: `${step.plugin} ${step.command}`,
1729
+ error: {
1730
+ code: "SKIPPED",
1731
+ message: "Skipped due to failed dependency"
1732
+ },
1733
+ duration_ms: 0
1734
+ },
1735
+ skipped: true
1736
+ });
1737
+ continue;
1738
+ }
1739
+ allSuccess = false;
1740
+ stepResults.push({
1741
+ stepId: step.id,
1742
+ result: {
1743
+ success: false,
1744
+ command: `${step.plugin} ${step.command}`,
1745
+ error: {
1746
+ code: "DEP_FAILED",
1747
+ message: "Dependency failed, step not executed"
1748
+ },
1749
+ duration_ms: 0
1750
+ },
1751
+ skipped: true
1752
+ });
1753
+ continue;
1754
+ }
1755
+ log(` Step: ${step.id} - ${step.description}`);
1756
+ const result = await executeStep(step, cwd);
1757
+ stepResults.push(result);
1758
+ if (result.result.success) {
1759
+ completedSteps.add(step.id);
1760
+ } else {
1761
+ allSuccess = false;
1762
+ if (!step.optional) {
1763
+ log(` Step ${step.id} failed, stopping workflow`);
1764
+ for (const remaining of sortedSteps) {
1765
+ if (!stepResults.find((r) => r.stepId === remaining.id)) {
1766
+ stepResults.push({
1767
+ stepId: remaining.id,
1768
+ result: {
1769
+ success: false,
1770
+ command: `${remaining.plugin} ${remaining.command}`,
1771
+ error: {
1772
+ code: "SKIPPED",
1773
+ message: "Skipped due to earlier failure"
1774
+ },
1775
+ duration_ms: 0
1776
+ },
1777
+ skipped: true
1778
+ });
1779
+ }
1780
+ }
1781
+ break;
1782
+ }
1783
+ }
1784
+ }
1785
+ const workflowResult = {
1786
+ workflowId: workflow.id,
1787
+ success: allSuccess,
1788
+ stepResults,
1789
+ duration_ms: Date.now() - startTime
1790
+ };
1791
+ output(success(cmd, workflowResult, startTime));
1792
+ } catch (err) {
1793
+ output(failure(cmd, "WORKFLOW_RUN_ERROR", err.message, startTime));
1794
+ }
1795
+ });
1796
+ }
1797
+ var fs14, path14, import_types;
1798
+ var init_run = __esm({
1799
+ "src/plugins/workflow/run.ts"() {
1800
+ "use strict";
1801
+ fs14 = __toESM(require("fs"));
1802
+ path14 = __toESM(require("path"));
1803
+ import_types = require("@moxxy/types");
1804
+ init_exec();
1805
+ init_result();
1806
+ }
1807
+ });
1808
+
1809
+ // src/plugins/workflow/status.ts
1810
+ function registerStatus2(parent) {
1811
+ parent.command("status").description("Show status of running workflows").action(async () => {
1812
+ const startTime = Date.now();
1813
+ const cmd = "workflow status";
1814
+ output(success(cmd, {
1815
+ running: [],
1816
+ message: "No workflows currently running"
1817
+ }, startTime));
1818
+ });
1819
+ }
1820
+ var init_status2 = __esm({
1821
+ "src/plugins/workflow/status.ts"() {
1822
+ "use strict";
1823
+ init_result();
1824
+ }
1825
+ });
1826
+
1827
+ // src/plugins/workflow/index.ts
1828
+ var WorkflowPlugin;
1829
+ var init_workflow = __esm({
1830
+ "src/plugins/workflow/index.ts"() {
1831
+ "use strict";
1832
+ init_run();
1833
+ init_status2();
1834
+ WorkflowPlugin = class {
1835
+ name = "workflow";
1836
+ version = "1.0.0";
1837
+ description = "Workflow orchestration (run, status)";
1838
+ register(program) {
1839
+ const workflow = program.command("workflow").description(this.description);
1840
+ registerRun(workflow);
1841
+ registerStatus2(workflow);
1842
+ }
1843
+ getCommands() {
1844
+ return [
1845
+ {
1846
+ name: "workflow run",
1847
+ description: "Run a workflow from a JSON definition file",
1848
+ args: [
1849
+ { name: "workflow-file", description: "Path to workflow JSON", required: true, type: "string" }
1850
+ ],
1851
+ options: [],
1852
+ examples: ["moxxy-agent workflow run deploy.json"]
1853
+ },
1854
+ {
1855
+ name: "workflow status",
1856
+ description: "Show status of running workflows",
1857
+ args: [],
1858
+ options: [],
1859
+ examples: ["moxxy-agent workflow status"]
1860
+ }
1861
+ ];
1862
+ }
1863
+ };
1864
+ }
1865
+ });
1866
+
1867
+ // src/core/plugin-loader.ts
1868
+ function loadBuiltinPlugins(registry) {
1869
+ registry.register(new WorkspacePlugin());
1870
+ registry.register(new FilePlugin());
1871
+ registry.register(new DirPlugin());
1872
+ registry.register(new GitPlugin());
1873
+ registry.register(new SearchPlugin());
1874
+ registry.register(new PRPlugin());
1875
+ registry.register(new WorkflowPlugin());
1876
+ }
1877
+ var init_plugin_loader = __esm({
1878
+ "src/core/plugin-loader.ts"() {
1879
+ "use strict";
1880
+ init_workspace();
1881
+ init_file();
1882
+ init_dir();
1883
+ init_git();
1884
+ init_search();
1885
+ init_pr();
1886
+ init_workflow();
1887
+ }
1888
+ });
1889
+
1890
+ // src/help/index.ts
1891
+ function showHelp(registry) {
1892
+ log("");
1893
+ log("moxxy-agent - Agent-facing CLI tool for structured operations");
1894
+ log("");
1895
+ log("Usage: moxxy-agent [options] <plugin> <command> [args...]");
1896
+ log("");
1897
+ log("Global Options:");
1898
+ log(" --cwd <path> Set working directory");
1899
+ log(" --verbose Enable verbose logging");
1900
+ log(" -h, --help Show help");
1901
+ log(" -V, --version Show version");
1902
+ log("");
1903
+ log("Plugins:");
1904
+ for (const plugin of registry.getAll()) {
1905
+ log(` ${plugin.name.padEnd(15)} ${plugin.description}`);
1906
+ for (const cmd of plugin.getCommands()) {
1907
+ log(` ${cmd.name.padEnd(25)} ${cmd.description}`);
1908
+ }
1909
+ log("");
1910
+ }
1911
+ }
1912
+ var init_help = __esm({
1913
+ "src/help/index.ts"() {
1914
+ "use strict";
1915
+ init_result();
1916
+ }
1917
+ });
1918
+
1919
+ // src/cli.ts
1920
+ var cli_exports = {};
1921
+ __export(cli_exports, {
1922
+ createProgram: () => createProgram
1923
+ });
1924
+ function createProgram() {
1925
+ const program = new import_commander.Command();
1926
+ const registry = new PluginRegistry();
1927
+ program.name("moxxy-agent").description("Agent-facing CLI tool for structured operations").version("1.0.0").option("--cwd <path>", "Set working directory").option("--verbose", "Enable verbose logging");
1928
+ loadBuiltinPlugins(registry);
1929
+ for (const plugin of registry.getAll()) {
1930
+ plugin.register(program);
1931
+ }
1932
+ program.on("--help", () => {
1933
+ showHelp(registry);
1934
+ });
1935
+ return program;
1936
+ }
1937
+ var import_commander;
1938
+ var init_cli = __esm({
1939
+ "src/cli.ts"() {
1940
+ "use strict";
1941
+ import_commander = require("commander");
1942
+ init_plugin_registry();
1943
+ init_plugin_loader();
1944
+ init_help();
1945
+ }
1946
+ });
1947
+
1948
+ // src/index.ts
1949
+ var index_exports = {};
1950
+ __export(index_exports, {
1951
+ PluginRegistry: () => PluginRegistry,
1952
+ createProgram: () => createProgram,
1953
+ detectWorkspace: () => detectWorkspace,
1954
+ failure: () => failure,
1955
+ getContext: () => getContext,
1956
+ log: () => log,
1957
+ output: () => output,
1958
+ run: () => run,
1959
+ success: () => success
1960
+ });
1961
+ module.exports = __toCommonJS(index_exports);
1962
+ init_cli();
1963
+ init_plugin_registry();
1964
+ init_result();
1965
+ init_context();
1966
+ async function run() {
1967
+ const { createProgram: createProgram2 } = await Promise.resolve().then(() => (init_cli(), cli_exports));
1968
+ const program = createProgram2();
1969
+ await program.parseAsync(process.argv);
1970
+ }
1971
+ // Annotate the CommonJS export names for ESM import in node:
1972
+ 0 && (module.exports = {
1973
+ PluginRegistry,
1974
+ createProgram,
1975
+ detectWorkspace,
1976
+ failure,
1977
+ getContext,
1978
+ log,
1979
+ output,
1980
+ run,
1981
+ success
1982
+ });