@rigkit/cli 0.2.9 → 0.2.11

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.
@@ -15,7 +15,7 @@ describe("CLI completion", () => {
15
15
  currentIndex: 2,
16
16
  });
17
17
 
18
- expect(items.map((item) => item.value)).toEqual(["api", "web"]);
18
+ expect(items.map((item) => item.value)).toEqual(["api", "web", "--json", "--help"]);
19
19
  expect(items[0]?.description).toBe("created 2h ago");
20
20
  });
21
21
  });
@@ -43,7 +43,7 @@ describe("CLI completion", () => {
43
43
  currentIndex: 3,
44
44
  });
45
45
 
46
- expect(items.map((item) => item.value)).toEqual(["api", "web"]);
46
+ expect(items.map((item) => item.value)).toEqual(["api", "web", "--json", "--help"]);
47
47
  });
48
48
  });
49
49
 
@@ -82,6 +82,45 @@ describe("CLI completion", () => {
82
82
  }
83
83
  });
84
84
 
85
+ test("suggests conventional double-dash global flags by default", async () => {
86
+ const items = await completeRig({
87
+ cwd: process.cwd(),
88
+ words: ["rig", "--"],
89
+ currentIndex: 1,
90
+ });
91
+
92
+ expect(items.map((item) => item.value)).toEqual([
93
+ "--chdir=",
94
+ "--config=",
95
+ "--state=",
96
+ "--json",
97
+ "--help",
98
+ "--version",
99
+ ]);
100
+ });
101
+
102
+ test("completes project directories for --chdir", async () => {
103
+ const cwd = mkdtempSync(join(tmpdir(), "rigkit-completion-dirs-"));
104
+ mkdirSync(join(cwd, "examples", "global-fragments"), { recursive: true });
105
+
106
+ try {
107
+ const roots = await completeRig({
108
+ cwd,
109
+ words: ["rig", "--chdir="],
110
+ currentIndex: 1,
111
+ });
112
+
113
+ expect(roots).toContainEqual({
114
+ value: "--chdir=examples/",
115
+ description: "directory",
116
+ noSpace: true,
117
+ group: "Paths",
118
+ });
119
+ } finally {
120
+ rmSync(cwd, { recursive: true, force: true });
121
+ }
122
+ });
123
+
85
124
  test("completes named config files", async () => {
86
125
  const cwd = mkdtempSync(join(tmpdir(), "rigkit-completion-configs-"));
87
126
  writeFileSync(join(cwd, "api.rig.config.ts"), "export default {}\n");
@@ -128,7 +167,7 @@ describe("CLI completion", () => {
128
167
  words: ["rig", "run", ""],
129
168
  currentIndex: 2,
130
169
  });
131
- expect(roots.map((item) => item.value)).toEqual(["api", "web"]);
170
+ expect(roots.map((item) => item.value)).toEqual(["api", "web", "--json", "--help"]);
132
171
  expect(roots[0]).toMatchObject({ description: "created 2h ago" });
133
172
 
134
173
  const exactWorkspace = await completeRig({
@@ -143,7 +182,7 @@ describe("CLI completion", () => {
143
182
  words: ["rig", "run", "api", ""],
144
183
  currentIndex: 3,
145
184
  });
146
- expect(workspaceAfterSpace.map((item) => item.value)).toEqual(["remove", "open-cmux"]);
185
+ expect(workspaceAfterSpace.map((item) => item.value)).toEqual(["remove", "open-cmux", "--json", "--help"]);
147
186
 
148
187
  const operationPrefix = await completeRig({
149
188
  cwd: projectDir,
@@ -162,7 +201,7 @@ describe("CLI completion", () => {
162
201
  words: ["rig", "rm", ""],
163
202
  currentIndex: 2,
164
203
  });
165
- expect(workspaces.map((item) => item.value)).toEqual(["api", "web"]);
204
+ expect(workspaces.map((item) => item.value)).toEqual(["api", "web", "-y", "--yes", "--all", "--json", "--help"]);
166
205
 
167
206
  const flags = await completeRig({
168
207
  cwd: projectDir,
@@ -183,7 +222,7 @@ describe("CLI completion", () => {
183
222
  currentIndex: 1,
184
223
  });
185
224
 
186
- expect(items.map((item) => item.value)).toEqual(["plan", "projects"]);
225
+ expect(items.map((item) => item.value)).toEqual(["plan", "providers", "projects"]);
187
226
  });
188
227
  });
189
228
 
@@ -204,7 +243,7 @@ describe("CLI completion", () => {
204
243
  currentIndex: 2,
205
244
  });
206
245
 
207
- expect(subcommands.map((item) => item.value)).toEqual(["ls", "clear"]);
246
+ expect(subcommands.map((item) => item.value)).toEqual(["ls", "clear", "invalidate"]);
208
247
 
209
248
  const clearFlags = await completeRig({
210
249
  cwd: process.cwd(),
@@ -217,9 +256,163 @@ describe("CLI completion", () => {
217
256
  "--global",
218
257
  "--all",
219
258
  "--json",
259
+ "--help",
220
260
  ]);
221
261
  });
222
262
 
263
+ test("completes provider targets, subcommands, and flags", async () => {
264
+ const targets = await completeRig({
265
+ cwd: process.cwd(),
266
+ words: ["rig", "providers", ""],
267
+ currentIndex: 2,
268
+ });
269
+
270
+ expect(targets.map((item) => item.value)).toEqual(["freestyle"]);
271
+
272
+ const targetFlags = await completeRig({
273
+ cwd: process.cwd(),
274
+ words: ["rig", "providers", "--"],
275
+ currentIndex: 2,
276
+ });
277
+
278
+ expect(targetFlags.map((item) => item.value)).toEqual(["--help"]);
279
+
280
+ const subcommands = await completeRig({
281
+ cwd: process.cwd(),
282
+ words: ["rig", "providers", "freestyle", ""],
283
+ currentIndex: 3,
284
+ });
285
+
286
+ expect(subcommands.map((item) => item.value)).toEqual(["clear"]);
287
+
288
+ const clearFlags = await completeRig({
289
+ cwd: process.cwd(),
290
+ words: ["rig", "providers", "freestyle", "clear", "--"],
291
+ currentIndex: 4,
292
+ });
293
+
294
+ expect(clearFlags.map((item) => item.value)).toEqual(["--json", "--help"]);
295
+ });
296
+
297
+ test("completes project operation flags and workflow values", async () => {
298
+ const projectDir = mkdtempSync(join(tmpdir(), "rigkit-completion-"));
299
+ await withWorkspaceRuntime({ projectDir }, async () => {
300
+ const flags = await completeRig({
301
+ cwd: projectDir,
302
+ words: ["rig", "apply", "--"],
303
+ currentIndex: 2,
304
+ });
305
+
306
+ expect(flags.map((item) => item.value)).toEqual([
307
+ "--workflow",
308
+ "--dry-run",
309
+ "--all",
310
+ "--discover",
311
+ "--json",
312
+ "--help",
313
+ ]);
314
+
315
+ const workflowValues = await completeRig({
316
+ cwd: projectDir,
317
+ words: ["rig", "apply", "--workflow", ""],
318
+ currentIndex: 3,
319
+ });
320
+ expect(workflowValues.map((item) => item.value)).toEqual(["smoke", "api"]);
321
+
322
+ const inlineWorkflow = await completeRig({
323
+ cwd: projectDir,
324
+ words: ["rig", "apply", "--workflow=s"],
325
+ currentIndex: 2,
326
+ });
327
+ expect(inlineWorkflow.map((item) => item.value)).toEqual(["--workflow=smoke"]);
328
+ });
329
+ });
330
+
331
+ test("completes workspace operation flags and enum values", async () => {
332
+ const projectDir = mkdtempSync(join(tmpdir(), "rigkit-completion-"));
333
+ await withWorkspaceRuntime({ projectDir }, async () => {
334
+ const flags = await completeRig({
335
+ cwd: projectDir,
336
+ words: ["rig", "run", "api", "open-cmux", "--"],
337
+ currentIndex: 4,
338
+ });
339
+
340
+ expect(flags.map((item) => item.value)).toEqual(["--layout", "--json", "--help"]);
341
+
342
+ const values = await completeRig({
343
+ cwd: projectDir,
344
+ words: ["rig", "run", "api", "open-cmux", "--layout", ""],
345
+ currentIndex: 5,
346
+ });
347
+ expect(values.map((item) => item.value)).toEqual(["tabs", "splits"]);
348
+ });
349
+ });
350
+
351
+ test("completes cache invalidate targets and flags", async () => {
352
+ const projectDir = mkdtempSync(join(tmpdir(), "rigkit-completion-"));
353
+ await withWorkspaceRuntime({ projectDir }, async () => {
354
+ const targets = await completeRig({
355
+ cwd: projectDir,
356
+ words: ["rig", "cache", "invalidate", ""],
357
+ currentIndex: 3,
358
+ });
359
+
360
+ expect(targets.map((item) => item.value)).toEqual([
361
+ "install-tooling",
362
+ "build",
363
+ "--all",
364
+ "-y",
365
+ "--yes",
366
+ "--json",
367
+ "--help",
368
+ ]);
369
+
370
+ const flags = await completeRig({
371
+ cwd: projectDir,
372
+ words: ["rig", "cache", "invalidate", "--"],
373
+ currentIndex: 3,
374
+ });
375
+ expect(flags.map((item) => item.value)).toEqual(["--all", "--yes", "--json", "--help"]);
376
+ });
377
+ });
378
+
379
+ test("completes static command flags and option values", async () => {
380
+ const initFlags = await completeRig({
381
+ cwd: process.cwd(),
382
+ words: ["rig", "init", "--"],
383
+ currentIndex: 2,
384
+ });
385
+ expect(initFlags.map((item) => item.value)).toEqual([
386
+ "--name",
387
+ "--api-key",
388
+ "--package-manager",
389
+ "--force",
390
+ "--json",
391
+ "--help",
392
+ ]);
393
+
394
+ const packageManagers = await completeRig({
395
+ cwd: process.cwd(),
396
+ words: ["rig", "init", "--package-manager", "p"],
397
+ currentIndex: 3,
398
+ });
399
+ expect(packageManagers.map((item) => item.value)).toEqual(["pnpm"]);
400
+
401
+ const doctorFlags = await completeRig({
402
+ cwd: process.cwd(),
403
+ words: ["rig", "doctor", "--"],
404
+ currentIndex: 2,
405
+ });
406
+ expect(doctorFlags.map((item) => item.value)).toEqual(["--cli", "--json", "--help"]);
407
+
408
+ const completionShells = await completeRig({
409
+ cwd: process.cwd(),
410
+ words: ["rig", "completion", ""],
411
+ currentIndex: 2,
412
+ });
413
+ expect(completionShells.map((item) => item.value)).toEqual(["bash", "fish", "zsh", "--help"]);
414
+ });
415
+
223
416
  test("formats shell completion items", () => {
224
417
  const items = [{ value: "api", description: "vm-api" }];
225
418
 
@@ -254,7 +447,7 @@ describe("CLI completion", () => {
254
447
  currentIndex: 2,
255
448
  });
256
449
 
257
- expect(items.map((item) => item.value)).toEqual(["workspaces", "snapshots", "config", "--json"]);
450
+ expect(items.map((item) => item.value)).toEqual(["workspaces", "snapshots", "config", "--json", "--help"]);
258
451
  });
259
452
  });
260
453
 
@@ -321,9 +514,139 @@ async function withWorkspaceRuntime(
321
514
  ],
322
515
  });
323
516
  }
517
+ if (pathname === "/workflows") {
518
+ return runtimeJson({
519
+ workflows: [
520
+ {
521
+ name: "smoke",
522
+ providers: [],
523
+ nodes: ["install-tooling", "build"],
524
+ operations: ["plan", "apply", "create"],
525
+ createsWorkspace: true,
526
+ },
527
+ {
528
+ name: "api",
529
+ providers: [],
530
+ nodes: ["install-tooling"],
531
+ operations: ["plan", "apply"],
532
+ createsWorkspace: false,
533
+ },
534
+ ],
535
+ });
536
+ }
537
+ if (pathname === "/cache") {
538
+ const nowMs = Date.now();
539
+ return runtimeJson({
540
+ entries: [
541
+ {
542
+ scope: "local",
543
+ workflow: "smoke",
544
+ nodePath: "install-tooling",
545
+ nodeName: "install-tooling",
546
+ nodeKind: "task",
547
+ runId: "run-install",
548
+ invalidated: false,
549
+ createdAt: new Date(nowMs - 60_000).toISOString(),
550
+ },
551
+ {
552
+ scope: "local",
553
+ workflow: "smoke",
554
+ nodePath: "build",
555
+ nodeName: "build",
556
+ nodeKind: "task",
557
+ runId: "run-build",
558
+ invalidated: false,
559
+ createdAt: new Date(nowMs - 30_000).toISOString(),
560
+ },
561
+ {
562
+ scope: "local",
563
+ workflow: "smoke",
564
+ nodePath: "old-task",
565
+ nodeName: "old-task",
566
+ nodeKind: "task",
567
+ runId: "run-old",
568
+ invalidated: true,
569
+ createdAt: new Date(nowMs - 10_000).toISOString(),
570
+ },
571
+ {
572
+ scope: "global",
573
+ workflow: "smoke",
574
+ nodePath: "base",
575
+ nodeName: "base",
576
+ nodeKind: "task",
577
+ runId: "run-base",
578
+ invalidated: false,
579
+ createdAt: new Date(nowMs - 5_000).toISOString(),
580
+ fragmentHash: "fragment",
581
+ },
582
+ ],
583
+ });
584
+ }
324
585
  if (pathname === "/operations") {
325
586
  return runtimeJson({
326
587
  operations: [
588
+ {
589
+ id: "plan",
590
+ kind: "command",
591
+ source: "core",
592
+ title: "Plan",
593
+ description: "Show cached and pending steps",
594
+ cli: {
595
+ options: [{ name: "workflow", flag: "--workflow" }],
596
+ },
597
+ inputSchema: {
598
+ type: "object",
599
+ additionalProperties: false,
600
+ properties: {
601
+ workflow: { type: "string", enum: ["smoke", "api"] },
602
+ },
603
+ },
604
+ },
605
+ {
606
+ id: "apply",
607
+ kind: "command",
608
+ source: "core",
609
+ title: "Apply",
610
+ description: "Resolve the workflow",
611
+ cli: {
612
+ options: [
613
+ { name: "workflow", flag: "--workflow" },
614
+ { name: "dryRun", flag: "--dry-run", type: "boolean" },
615
+ ],
616
+ },
617
+ inputSchema: {
618
+ type: "object",
619
+ additionalProperties: false,
620
+ properties: {
621
+ workflow: { type: "string", enum: ["smoke", "api"] },
622
+ dryRun: { type: "boolean" },
623
+ },
624
+ },
625
+ },
626
+ {
627
+ id: "create",
628
+ kind: "command",
629
+ source: "core",
630
+ title: "Create",
631
+ description: "Create a workspace",
632
+ createsWorkspace: true,
633
+ cli: {
634
+ positionals: [{ name: "name", index: 0 }],
635
+ options: [
636
+ { name: "workflow", flag: "--workflow" },
637
+ { name: "name", flag: "--name", required: true },
638
+ ],
639
+ },
640
+ inputSchema: {
641
+ type: "object",
642
+ additionalProperties: false,
643
+ required: ["name"],
644
+ properties: {
645
+ workflow: { type: "string", enum: ["smoke", "api"] },
646
+ name: { type: "string" },
647
+ },
648
+ },
649
+ },
327
650
  {
328
651
  id: "ssh",
329
652
  kind: "command",
@@ -365,10 +688,15 @@ async function withWorkspaceRuntime(
365
688
  source: "config",
366
689
  title: "Open cmux",
367
690
  description: "open cmux",
691
+ cli: {
692
+ options: [{ name: "layout", flag: "--layout", type: "string" }],
693
+ },
368
694
  inputSchema: {
369
695
  type: "object",
370
696
  additionalProperties: false,
371
- properties: {},
697
+ properties: {
698
+ layout: { type: "string", enum: ["tabs", "splits"] },
699
+ },
372
700
  },
373
701
  },
374
702
  ],