@rendotdev/rig 0.0.20 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +3 -1
  2. package/dist/{cli-nk194xv0.js → cli-043bae8s.js} +85 -3
  3. package/dist/{cli-es8j6mma.js → cli-1ssn3a04.js} +3 -3
  4. package/dist/{cli-13q90bjr.js → cli-32dzwg3p.js} +6 -0
  5. package/dist/{cli-1hm5dxfw.js → cli-ahwyqf1f.js} +2 -2
  6. package/dist/{cli-f7p31fzm.js → cli-dqz4gvqd.js} +3 -3
  7. package/dist/cli-eavzwv49.js +5161 -0
  8. package/dist/{cli-1354fmns.js → cli-q2ajq5qe.js} +3 -3
  9. package/dist/{cli-884hpkjc.js → cli-zbp3334x.js} +1 -1
  10. package/dist/{config-20f90shh.js → config-72dha2z0.js} +2 -2
  11. package/dist/{create-pvym2abv.js → create-pnsj60ym.js} +4 -4
  12. package/dist/cron-zhb9hpbs.js +18 -0
  13. package/dist/{dev-link-e1mj8w17.js → dev-link-znh4mch1.js} +1 -1
  14. package/dist/{discover-95bpzy46.js → discover-549nzamy.js} +3 -3
  15. package/dist/{help-qj75r0x3.js → help-kg1zhj6n.js} +5 -5
  16. package/dist/{inspect-0ckw7bs5.js → inspect-vqtm5htv.js} +5 -5
  17. package/dist/list-2n0p40dn.js +13 -0
  18. package/dist/{paths-3vxw7dek.js → paths-4kzahz8f.js} +1 -1
  19. package/dist/{registry-fzc3aeb8.js → registry-nvnbmws0.js} +2 -2
  20. package/dist/rig.js +50 -40
  21. package/dist/run-mvhmkkfe.js +13 -0
  22. package/dist/{runtime-comment-07cpchsr.js → runtime-comment-n9aft3g5.js} +10 -3
  23. package/dist/{sync-k2spbt3f.js → sync-javg558s.js} +11 -7
  24. package/dist/{typecheck-971tmqbp.js → typecheck-c944bvz2.js} +4 -4
  25. package/dist/{update-check-dpkh7hc6.js → update-check-bqa9ejex.js} +1 -1
  26. package/package.json +2 -1
  27. package/dist/cli-113n7c3t.js +0 -513
  28. package/dist/cron-aw908dzn.js +0 -18
  29. package/dist/list-gqdh0m23.js +0 -13
  30. package/dist/run-thx15p83.js +0 -13
package/README.md CHANGED
@@ -76,7 +76,9 @@ The `rig` CLI is installed on this machine. It allows you to write, run and own
76
76
  - To remove an existing tool, run `rig remove <tool>`.
77
77
  - To list tool registries, run `rig registry list`.
78
78
  - To add a registry, run `rig registry create [path]` (defaults to current directory).
79
- - If a tool needs persistent state, define `setupDb` and use `context.db`; Rig stores that SQLite database beside the tool entry file as `index.sqlite`.
79
+ - Use `context.log` for structured Pino logs with a default tool command prefix; Rig writes logs to `~/rig/.logs`, rolls files by size, and keeps seven days.
80
+ - Use `context.kv.set(key, value)` and `context.kv.get(key)` for lightweight JSON state in `kv.sqlite` beside the tool entry file.
81
+ - If a tool needs relational persistent state, define `setupDb` and use `context.db`; Rig stores that SQLite database beside the tool entry file as `index.sqlite`.
80
82
 
81
83
  When rig runs, it keeps detected `AGENTS.md` and `CLAUDE.md` files updated with these instructions and the current `rig list` output.
82
84
 
@@ -3,7 +3,7 @@ import {
3
3
  } from "./cli-1c7te5cg.js";
4
4
  import {
5
5
  RigPaths
6
- } from "./cli-13q90bjr.js";
6
+ } from "./cli-32dzwg3p.js";
7
7
  import {
8
8
  __export
9
9
  } from "./cli-b7jgjgy7.js";
@@ -318,12 +318,36 @@ export type RigToolDatabase = Database & {
318
318
  migrate(version: number, name: string, sql: string): void;
319
319
  };
320
320
 
321
+ export type RigToolKvStore = {
322
+ readonly path: string;
323
+ get<T = unknown>(key: string): T | undefined;
324
+ set(key: string, value: unknown): void;
325
+ };
326
+
327
+ export type RigLogMethod = {
328
+ (message: string): void;
329
+ (bindings: Record<string, unknown>, message?: string): void;
330
+ (error: Error, message?: string): void;
331
+ };
332
+
333
+ export type RigToolLogger = {
334
+ trace: RigLogMethod;
335
+ debug: RigLogMethod;
336
+ info: RigLogMethod;
337
+ warn: RigLogMethod;
338
+ error: RigLogMethod;
339
+ fatal: RigLogMethod;
340
+ child(bindings: Record<string, unknown>): RigToolLogger;
341
+ };
342
+
321
343
  export type RigToolRunContext<Input, Env = unknown> = {
322
344
  input: Input;
323
345
  env: Env;
324
346
  processEnv: NodeJS.ProcessEnv;
325
347
  cwd: string;
326
348
  db: RigToolDatabase;
349
+ kv: RigToolKvStore;
350
+ log: RigToolLogger;
327
351
  rig: RigToolKit;
328
352
  };
329
353
 
@@ -421,12 +445,54 @@ ${JSON.stringify({
421
445
  import { existsSync as existsSync3 } from "node:fs";
422
446
  import { mkdir as mkdir2, readdir, readFile as readFile2, rename, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
423
447
  import { join as join3 } from "node:path";
448
+ var RigHomeDirectoryMigrationPromptId = "v0.0.19-home-directory";
424
449
 
425
- class RigDirectoryMigrationService {
450
+ class RigMigrationPromptStore {
426
451
  paths;
427
452
  constructor(paths) {
428
453
  this.paths = paths;
429
454
  }
455
+ async hasPrompted(promptId) {
456
+ const state = await this.read();
457
+ return state.prompts[promptId] !== undefined;
458
+ }
459
+ async markPrompted(promptId) {
460
+ const state = await this.read();
461
+ state.prompts[promptId] ??= { shownAt: new Date().toISOString() };
462
+ await this.write(state);
463
+ }
464
+ async read() {
465
+ try {
466
+ const parsed = JSON.parse(await readFile2(this.paths.migrationPromptStatePath, "utf8"));
467
+ if (!this.isState(parsed))
468
+ return this.emptyState();
469
+ return parsed;
470
+ } catch {
471
+ return this.emptyState();
472
+ }
473
+ }
474
+ async write(state) {
475
+ await mkdir2(this.paths.rigDir, { recursive: true });
476
+ const tmpPath = `${this.paths.migrationPromptStatePath}.tmp-${process.pid}`;
477
+ await writeFile2(tmpPath, `${JSON.stringify(state, null, 2)}
478
+ `, "utf8");
479
+ await rename(tmpPath, this.paths.migrationPromptStatePath);
480
+ }
481
+ emptyState() {
482
+ return { version: 1, prompts: {} };
483
+ }
484
+ isState(value) {
485
+ return typeof value === "object" && value !== null && !Array.isArray(value) && value.version === 1 && typeof value.prompts === "object" && value.prompts !== null && !Array.isArray(value.prompts);
486
+ }
487
+ }
488
+
489
+ class RigDirectoryMigrationService {
490
+ paths;
491
+ promptStore;
492
+ constructor(paths, promptStore = new RigMigrationPromptStore(paths)) {
493
+ this.paths = paths;
494
+ this.promptStore = promptStore;
495
+ }
430
496
  async migrateIfNeeded() {
431
497
  const legacyDir = this.paths.legacyRigDir;
432
498
  const currentDir = this.paths.rigDir;
@@ -434,7 +500,10 @@ class RigDirectoryMigrationService {
434
500
  return;
435
501
  const currentExists = existsSync3(currentDir);
436
502
  if (currentExists && !await this.canReplaceCurrentDirectory(currentDir)) {
503
+ if (await this.promptStore.hasPrompted(RigHomeDirectoryMigrationPromptId))
504
+ return;
437
505
  return {
506
+ promptId: RigHomeDirectoryMigrationPromptId,
438
507
  status: "manual",
439
508
  legacyDir,
440
509
  currentDir,
@@ -447,6 +516,7 @@ class RigDirectoryMigrationService {
447
516
  await mkdir2(this.paths.homeDir, { recursive: true });
448
517
  await rename(legacyDir, currentDir);
449
518
  return {
519
+ promptId: RigHomeDirectoryMigrationPromptId,
450
520
  status: "migrated",
451
521
  legacyDir,
452
522
  currentDir,
@@ -482,7 +552,14 @@ class RigDirectoryMigrationService {
482
552
  }
483
553
  async hasOnlyGeneratedCurrentEntries(currentDir) {
484
554
  const entries = await this.visibleEntries(currentDir);
485
- return entries.every((entry) => ["rig.json", "runtime", "tools", "update-check.json", "cron"].includes(entry));
555
+ return entries.every((entry) => [
556
+ "rig.json",
557
+ "runtime",
558
+ "tools",
559
+ "update-check.json",
560
+ "cron",
561
+ "migration-prompts.json"
562
+ ].includes(entry));
486
563
  }
487
564
  async rewriteMigratedConfig() {
488
565
  const configPath = this.paths.configPath;
@@ -14824,6 +14901,11 @@ class RigConfigStore {
14824
14901
  migrationResult() {
14825
14902
  return this.migration;
14826
14903
  }
14904
+ async acknowledgeMigrationPrompt() {
14905
+ if (this.migration?.status !== "manual")
14906
+ return;
14907
+ await new RigMigrationPromptStore(this.paths).markPrompted(this.migration.promptId);
14908
+ }
14827
14909
  async ensure() {
14828
14910
  this.migration = await new RigDirectoryMigrationService(this.paths).migrateIfNeeded();
14829
14911
  await mkdir3(this.paths.rigDir, { recursive: true });
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  ToolRunner
3
- } from "./cli-113n7c3t.js";
3
+ } from "./cli-eavzwv49.js";
4
4
  import {
5
5
  RigConfigStore
6
- } from "./cli-nk194xv0.js";
6
+ } from "./cli-043bae8s.js";
7
7
  import {
8
8
  RigError
9
9
  } from "./cli-1c7te5cg.js";
10
10
  import {
11
11
  RigPaths
12
- } from "./cli-13q90bjr.js";
12
+ } from "./cli-32dzwg3p.js";
13
13
 
14
14
  // src/tools/cron.ts
15
15
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
@@ -48,12 +48,18 @@ class RigPaths {
48
48
  get cronDir() {
49
49
  return join(this.rigDir, "cron");
50
50
  }
51
+ get logsDir() {
52
+ return join(this.rigDir, ".logs");
53
+ }
51
54
  cronWorkerPath(name) {
52
55
  return join(this.cronDir, `${name}.ts`);
53
56
  }
54
57
  get updateCheckCachePath() {
55
58
  return join(this.rigDir, "update-check.json");
56
59
  }
60
+ get migrationPromptStatePath() {
61
+ return join(this.rigDir, "migration-prompts.json");
62
+ }
57
63
  get defaultBaseRegistryDir() {
58
64
  return "~/rig/tools";
59
65
  }
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  RigConfigStore
3
- } from "./cli-nk194xv0.js";
3
+ } from "./cli-043bae8s.js";
4
4
  import {
5
5
  RigError
6
6
  } from "./cli-1c7te5cg.js";
7
7
  import {
8
8
  RigPaths
9
- } from "./cli-13q90bjr.js";
9
+ } from "./cli-32dzwg3p.js";
10
10
 
11
11
  // src/registry/discover.ts
12
12
  import { existsSync, statSync } from "node:fs";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ToolDiscoveryService
3
- } from "./cli-1hm5dxfw.js";
3
+ } from "./cli-ahwyqf1f.js";
4
4
  import {
5
5
  exports_external
6
- } from "./cli-nk194xv0.js";
6
+ } from "./cli-043bae8s.js";
7
7
  import {
8
8
  RigError
9
9
  } from "./cli-1c7te5cg.js";
@@ -236,7 +236,7 @@ class RigCommandRunnerRuntime {
236
236
  }
237
237
  async run(options) {
238
238
  const target = this.commandTarget(options);
239
- const { ToolRunner } = await import("./run-thx15p83.js");
239
+ const { ToolRunner } = await import("./run-mvhmkkfe.js");
240
240
  const result = await new ToolRunner(this.options).run(target.tool, target.command, {
241
241
  ...this.options,
242
242
  args: options.args,