@rendotdev/rig 0.0.21 → 0.0.23
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/README.md +13 -17
- package/dist/{cli-q030hfkh.js → cli-043bae8s.js} +61 -3
- package/dist/{cli-e36v1j7k.js → cli-32dzwg3p.js} +3 -0
- package/dist/{cli-5bhr3az0.js → cli-4e71j0m0.js} +13 -6
- package/dist/{cli-sthjxz5r.js → cli-85va7m21.js} +3 -3
- package/dist/{cli-1x1ej1qw.js → cli-ahwyqf1f.js} +2 -2
- package/dist/{cli-v3rc5c7e.js → cli-d9b8eefw.js} +3 -3
- package/dist/{cli-w0fx5mq7.js → cli-exxbjsry.js} +5 -5
- package/dist/{cli-7ydvyqk0.js → cli-zbp3334x.js} +1 -1
- package/dist/{config-2m5wjw5n.js → config-72dha2z0.js} +2 -2
- package/dist/{create-92py76p1.js → create-bvzszsyt.js} +4 -4
- package/dist/cron-n15qfj8m.js +18 -0
- package/dist/{dev-link-gz0bmj53.js → dev-link-znh4mch1.js} +1 -1
- package/dist/{discover-wx1p1gt4.js → discover-549nzamy.js} +3 -3
- package/dist/env-9kd3dqkx.js +190 -0
- package/dist/{help-aftsnsvm.js → help-24c9vwxh.js} +5 -5
- package/dist/{inspect-196evjrm.js → inspect-mb0n7sjg.js} +5 -5
- package/dist/list-jfcspwm7.js +13 -0
- package/dist/{paths-04fjw4rr.js → paths-4kzahz8f.js} +1 -1
- package/dist/{registry-ksty807w.js → registry-nvnbmws0.js} +2 -2
- package/dist/rig.js +54 -40
- package/dist/run-ngbemhx5.js +13 -0
- package/dist/{runtime-comment-ngjh6vxk.js → runtime-comment-gbermtjx.js} +7 -4
- package/dist/{sync-nhscv97a.js → sync-7x553cky.js} +33 -24
- package/dist/{typecheck-qeatn7d2.js → typecheck-6q579sqn.js} +4 -4
- package/dist/{update-check-qef8tgen.js → update-check-bqa9ejex.js} +1 -1
- package/package.json +1 -1
- package/dist/cron-ynhxww07.js +0 -18
- package/dist/list-v29rq1q1.js +0 -13
- package/dist/run-4dhw2n7j.js +0 -13
package/README.md
CHANGED
|
@@ -62,23 +62,19 @@ Do not implement anything yet. Ask the user which workflow they want to implemen
|
|
|
62
62
|
|
|
63
63
|
> Are you an AI agent looking for how to use rig? Assume the following:
|
|
64
64
|
|
|
65
|
-
The `rig` CLI is installed on this machine. It
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
- To add a registry, run `rig registry create [path]` (defaults to current directory).
|
|
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`.
|
|
65
|
+
The `rig` CLI is installed on this machine. It lets agents discover, run, and create local typed tools.
|
|
66
|
+
|
|
67
|
+
- Run `rig` (or `rig init`) to set up or sync rig. This also updates detected AGENTS.md and CLAUDE.md files with available rig tools.
|
|
68
|
+
- Run `rig create <tool>` when the user asks you to turn a repeatable workflow into a reusable tool.
|
|
69
|
+
- Run `rig edit <tool>` to print the tool file path for editing.
|
|
70
|
+
- Run `rig remove <tool>` to remove a local tool.
|
|
71
|
+
- Run `rig cron --help` to schedule and manage tool commands.
|
|
72
|
+
- Run `rig typecheck <tool>` to validate a tool's TypeScript and runtime types.
|
|
73
|
+
- Run `rig env <tool> KEY=VALUE` to configure tool secrets/settings; run `rig env <tool> remove KEY` to remove them.
|
|
74
|
+
- Run `rig list` to discover tools and available `rig run ...` commands.
|
|
75
|
+
- Run `rig help <tool>` or `rig help <tool>.<command>` for usage, inputs, and outputs.
|
|
76
|
+
- Run `rig run <tool>.<command> [args]` to execute a tool command.
|
|
77
|
+
- Run `rig --help` for other Rig CLI commands.
|
|
82
78
|
|
|
83
79
|
When rig runs, it keeps detected `AGENTS.md` and `CLAUDE.md` files updated with these instructions and the current `rig list` output.
|
|
84
80
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./cli-1c7te5cg.js";
|
|
4
4
|
import {
|
|
5
5
|
RigPaths
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-32dzwg3p.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./cli-b7jgjgy7.js";
|
|
@@ -445,12 +445,54 @@ ${JSON.stringify({
|
|
|
445
445
|
import { existsSync as existsSync3 } from "node:fs";
|
|
446
446
|
import { mkdir as mkdir2, readdir, readFile as readFile2, rename, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
447
447
|
import { join as join3 } from "node:path";
|
|
448
|
+
var RigHomeDirectoryMigrationPromptId = "v0.0.19-home-directory";
|
|
448
449
|
|
|
449
|
-
class
|
|
450
|
+
class RigMigrationPromptStore {
|
|
450
451
|
paths;
|
|
451
452
|
constructor(paths) {
|
|
452
453
|
this.paths = paths;
|
|
453
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
|
+
}
|
|
454
496
|
async migrateIfNeeded() {
|
|
455
497
|
const legacyDir = this.paths.legacyRigDir;
|
|
456
498
|
const currentDir = this.paths.rigDir;
|
|
@@ -458,7 +500,10 @@ class RigDirectoryMigrationService {
|
|
|
458
500
|
return;
|
|
459
501
|
const currentExists = existsSync3(currentDir);
|
|
460
502
|
if (currentExists && !await this.canReplaceCurrentDirectory(currentDir)) {
|
|
503
|
+
if (await this.promptStore.hasPrompted(RigHomeDirectoryMigrationPromptId))
|
|
504
|
+
return;
|
|
461
505
|
return {
|
|
506
|
+
promptId: RigHomeDirectoryMigrationPromptId,
|
|
462
507
|
status: "manual",
|
|
463
508
|
legacyDir,
|
|
464
509
|
currentDir,
|
|
@@ -471,6 +516,7 @@ class RigDirectoryMigrationService {
|
|
|
471
516
|
await mkdir2(this.paths.homeDir, { recursive: true });
|
|
472
517
|
await rename(legacyDir, currentDir);
|
|
473
518
|
return {
|
|
519
|
+
promptId: RigHomeDirectoryMigrationPromptId,
|
|
474
520
|
status: "migrated",
|
|
475
521
|
legacyDir,
|
|
476
522
|
currentDir,
|
|
@@ -506,7 +552,14 @@ class RigDirectoryMigrationService {
|
|
|
506
552
|
}
|
|
507
553
|
async hasOnlyGeneratedCurrentEntries(currentDir) {
|
|
508
554
|
const entries = await this.visibleEntries(currentDir);
|
|
509
|
-
return entries.every((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));
|
|
510
563
|
}
|
|
511
564
|
async rewriteMigratedConfig() {
|
|
512
565
|
const configPath = this.paths.configPath;
|
|
@@ -14848,6 +14901,11 @@ class RigConfigStore {
|
|
|
14848
14901
|
migrationResult() {
|
|
14849
14902
|
return this.migration;
|
|
14850
14903
|
}
|
|
14904
|
+
async acknowledgeMigrationPrompt() {
|
|
14905
|
+
if (this.migration?.status !== "manual")
|
|
14906
|
+
return;
|
|
14907
|
+
await new RigMigrationPromptStore(this.paths).markPrompted(this.migration.promptId);
|
|
14908
|
+
}
|
|
14851
14909
|
async ensure() {
|
|
14852
14910
|
this.migration = await new RigDirectoryMigrationService(this.paths).migrateIfNeeded();
|
|
14853
14911
|
await mkdir3(this.paths.rigDir, { recursive: true });
|
|
@@ -57,6 +57,9 @@ class RigPaths {
|
|
|
57
57
|
get updateCheckCachePath() {
|
|
58
58
|
return join(this.rigDir, "update-check.json");
|
|
59
59
|
}
|
|
60
|
+
get migrationPromptStatePath() {
|
|
61
|
+
return join(this.rigDir, "migration-prompts.json");
|
|
62
|
+
}
|
|
60
63
|
get defaultBaseRegistryDir() {
|
|
61
64
|
return "~/rig/tools";
|
|
62
65
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolDiscoveryService
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-ahwyqf1f.js";
|
|
4
4
|
import {
|
|
5
5
|
exports_external
|
|
6
|
-
} from "./cli-
|
|
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-
|
|
239
|
+
const { ToolRunner } = await import("./run-ngbemhx5.js");
|
|
240
240
|
const result = await new ToolRunner(this.options).run(target.tool, target.command, {
|
|
241
241
|
...this.options,
|
|
242
242
|
args: options.args,
|
|
@@ -502,7 +502,10 @@ class ToolLoader {
|
|
|
502
502
|
validateCommandName(name) {
|
|
503
503
|
this.validator.validateCommandName(name);
|
|
504
504
|
}
|
|
505
|
-
async
|
|
505
|
+
async loadDefinition(name) {
|
|
506
|
+
return this.loadDefinitionDiscovered(await this.discovery.find(name));
|
|
507
|
+
}
|
|
508
|
+
async loadDefinitionDiscovered(tool) {
|
|
506
509
|
const url = `${pathToFileURL(tool.toolPath).href}?rig=${Date.now()}`;
|
|
507
510
|
let moduleValue;
|
|
508
511
|
try {
|
|
@@ -516,8 +519,12 @@ class ToolLoader {
|
|
|
516
519
|
const moduleRecord = moduleValue;
|
|
517
520
|
const definitionValue = await this.evaluateModuleDefault(moduleRecord.default, tool.name);
|
|
518
521
|
const definition = this.validator.validateToolDefinition(definitionValue, tool.name);
|
|
519
|
-
|
|
520
|
-
|
|
522
|
+
return { name: definition.name, path: tool.toolPath, definition };
|
|
523
|
+
}
|
|
524
|
+
async loadDiscovered(tool) {
|
|
525
|
+
const loaded = await this.loadDefinitionDiscovered(tool);
|
|
526
|
+
const env = await this.envLoader.load(tool, loaded.definition);
|
|
527
|
+
return { ...loaded, env };
|
|
521
528
|
}
|
|
522
529
|
async evaluateModuleDefault(value, toolName) {
|
|
523
530
|
const awaitedValue = await Promise.resolve(value);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolRunner
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-d9b8eefw.js";
|
|
4
4
|
import {
|
|
5
5
|
RigConfigStore
|
|
6
|
-
} from "./cli-
|
|
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-
|
|
12
|
+
} from "./cli-32dzwg3p.js";
|
|
13
13
|
|
|
14
14
|
// src/tools/cron.ts
|
|
15
15
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RigConfigStore
|
|
3
|
-
} from "./cli-
|
|
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-
|
|
9
|
+
} from "./cli-32dzwg3p.js";
|
|
10
10
|
|
|
11
11
|
// src/registry/discover.ts
|
|
12
12
|
import { existsSync, statSync } from "node:fs";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SchemaRenderer
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-zbp3334x.js";
|
|
4
4
|
import {
|
|
5
5
|
CommandIds,
|
|
6
6
|
ToolLoader,
|
|
7
7
|
createRigToolKit
|
|
8
|
-
} from "./cli-
|
|
8
|
+
} from "./cli-4e71j0m0.js";
|
|
9
9
|
import {
|
|
10
10
|
RigError,
|
|
11
11
|
RigErrors
|
|
12
12
|
} from "./cli-1c7te5cg.js";
|
|
13
13
|
import {
|
|
14
14
|
RigPaths
|
|
15
|
-
} from "./cli-
|
|
15
|
+
} from "./cli-32dzwg3p.js";
|
|
16
16
|
import {
|
|
17
17
|
__commonJS,
|
|
18
18
|
__require,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SchemaRenderer
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-zbp3334x.js";
|
|
4
4
|
import {
|
|
5
5
|
CommandIds,
|
|
6
6
|
ToolLoader
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-4e71j0m0.js";
|
|
8
8
|
import {
|
|
9
9
|
ToolDiscoveryService
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-ahwyqf1f.js";
|
|
11
11
|
|
|
12
12
|
// src/tools/list.ts
|
|
13
13
|
class CommandRunExampleRenderer {
|
|
@@ -95,9 +95,9 @@ class ToolListPlainRenderer {
|
|
|
95
95
|
return `${tool.name} # ${this.formatter.description(tool.description)}`;
|
|
96
96
|
}
|
|
97
97
|
renderCommand(command) {
|
|
98
|
-
const
|
|
98
|
+
const runExample = this.formatter.example(command.runExample);
|
|
99
99
|
const description = this.formatter.description(command.description);
|
|
100
|
-
return ` ${
|
|
100
|
+
return ` ${runExample} # ${description}`;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolLoader
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-4e71j0m0.js";
|
|
4
4
|
import {
|
|
5
5
|
RigToolEntryFiles,
|
|
6
6
|
ToolDiscoveryService
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-ahwyqf1f.js";
|
|
8
8
|
import {
|
|
9
9
|
RigConfigStore
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-043bae8s.js";
|
|
11
11
|
import {
|
|
12
12
|
RigError
|
|
13
13
|
} from "./cli-1c7te5cg.js";
|
|
14
|
-
import"./cli-
|
|
14
|
+
import"./cli-32dzwg3p.js";
|
|
15
15
|
import"./cli-b7jgjgy7.js";
|
|
16
16
|
|
|
17
17
|
// src/tools/create.ts
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RigCronService,
|
|
3
|
+
RigCronWorker,
|
|
4
|
+
cronModuleUrl
|
|
5
|
+
} from "./cli-85va7m21.js";
|
|
6
|
+
import"./cli-d9b8eefw.js";
|
|
7
|
+
import"./cli-zbp3334x.js";
|
|
8
|
+
import"./cli-4e71j0m0.js";
|
|
9
|
+
import"./cli-ahwyqf1f.js";
|
|
10
|
+
import"./cli-043bae8s.js";
|
|
11
|
+
import"./cli-1c7te5cg.js";
|
|
12
|
+
import"./cli-32dzwg3p.js";
|
|
13
|
+
import"./cli-b7jgjgy7.js";
|
|
14
|
+
export {
|
|
15
|
+
cronModuleUrl,
|
|
16
|
+
RigCronWorker,
|
|
17
|
+
RigCronService
|
|
18
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RigToolEntryFiles,
|
|
3
3
|
ToolDiscoveryService
|
|
4
|
-
} from "./cli-
|
|
5
|
-
import"./cli-
|
|
4
|
+
} from "./cli-ahwyqf1f.js";
|
|
5
|
+
import"./cli-043bae8s.js";
|
|
6
6
|
import"./cli-1c7te5cg.js";
|
|
7
|
-
import"./cli-
|
|
7
|
+
import"./cli-32dzwg3p.js";
|
|
8
8
|
import"./cli-b7jgjgy7.js";
|
|
9
9
|
export {
|
|
10
10
|
ToolDiscoveryService,
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SchemaRenderer
|
|
3
|
+
} from "./cli-zbp3334x.js";
|
|
4
|
+
import {
|
|
5
|
+
ToolLoader
|
|
6
|
+
} from "./cli-4e71j0m0.js";
|
|
7
|
+
import"./cli-ahwyqf1f.js";
|
|
8
|
+
import"./cli-043bae8s.js";
|
|
9
|
+
import {
|
|
10
|
+
RigError
|
|
11
|
+
} from "./cli-1c7te5cg.js";
|
|
12
|
+
import"./cli-32dzwg3p.js";
|
|
13
|
+
import"./cli-b7jgjgy7.js";
|
|
14
|
+
|
|
15
|
+
// src/tools/env.ts
|
|
16
|
+
import { existsSync } from "node:fs";
|
|
17
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
class ToolEnvTarget {
|
|
20
|
+
tool;
|
|
21
|
+
constructor(tool) {
|
|
22
|
+
this.tool = tool;
|
|
23
|
+
}
|
|
24
|
+
static parse(value) {
|
|
25
|
+
if (value && !value.includes("."))
|
|
26
|
+
return new ToolEnvTarget(value);
|
|
27
|
+
throw new RigError("INPUT_ERROR", `Env target must use <tool>: ${value}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class EnvKeyParser {
|
|
32
|
+
parse(keys) {
|
|
33
|
+
if (keys.length === 0) {
|
|
34
|
+
throw new RigError("INPUT_ERROR", "Env remove expects at least one KEY.");
|
|
35
|
+
}
|
|
36
|
+
return keys.map((key) => this.parseOne(key));
|
|
37
|
+
}
|
|
38
|
+
parseOne(key) {
|
|
39
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
40
|
+
throw new RigError("INPUT_ERROR", `Env key must be a valid shell variable name: ${key}`);
|
|
41
|
+
}
|
|
42
|
+
return key;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class EnvAssignmentParser {
|
|
47
|
+
parse(assignments) {
|
|
48
|
+
return Object.fromEntries(assignments.map((assignment) => this.parseOne(assignment)));
|
|
49
|
+
}
|
|
50
|
+
parseOne(assignment) {
|
|
51
|
+
const separator = assignment.indexOf("=");
|
|
52
|
+
const key = assignment.slice(0, separator);
|
|
53
|
+
if (separator <= 0 || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
54
|
+
throw new RigError("INPUT_ERROR", `Env assignment must use KEY=VALUE: ${assignment}`);
|
|
55
|
+
}
|
|
56
|
+
return [key, assignment.slice(separator + 1)];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class DotEnvDocument {
|
|
61
|
+
parse(source, path) {
|
|
62
|
+
const values = {};
|
|
63
|
+
for (const [index, line] of source.split(/\r?\n/).entries()) {
|
|
64
|
+
const parsed = this.parseLine(line, path, index + 1);
|
|
65
|
+
if (parsed)
|
|
66
|
+
values[parsed.key] = parsed.value;
|
|
67
|
+
}
|
|
68
|
+
return values;
|
|
69
|
+
}
|
|
70
|
+
serialize(values) {
|
|
71
|
+
const lines = Object.entries(values).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, value]) => `${key}=${this.renderValue(value)}`);
|
|
72
|
+
return `${lines.join(`
|
|
73
|
+
`)}
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
parseLine(line, path, lineNumber) {
|
|
77
|
+
const trimmed = line.trim();
|
|
78
|
+
if (!trimmed || trimmed.startsWith("#"))
|
|
79
|
+
return;
|
|
80
|
+
const match = /^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/.exec(trimmed);
|
|
81
|
+
if (!match) {
|
|
82
|
+
throw new RigError("TOOL_INVALID", "Invalid .env line.", { path, line: lineNumber });
|
|
83
|
+
}
|
|
84
|
+
return { key: match[1], value: this.parseValue(match[2]) };
|
|
85
|
+
}
|
|
86
|
+
parseValue(value) {
|
|
87
|
+
const trimmed = value.trim();
|
|
88
|
+
if (trimmed.length < 2)
|
|
89
|
+
return trimmed;
|
|
90
|
+
if (trimmed[0] === '"' && trimmed.at(-1) === '"')
|
|
91
|
+
return JSON.parse(trimmed);
|
|
92
|
+
if (trimmed[0] === "'" && trimmed.at(-1) === "'")
|
|
93
|
+
return trimmed.slice(1, -1);
|
|
94
|
+
return trimmed;
|
|
95
|
+
}
|
|
96
|
+
renderValue(value) {
|
|
97
|
+
if (/^[A-Za-z0-9_./:=@%+,-]*$/.test(value))
|
|
98
|
+
return value;
|
|
99
|
+
return JSON.stringify(value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class EnvSchemaSummary {
|
|
104
|
+
entries(schema, values) {
|
|
105
|
+
const jsonSchema = SchemaRenderer.toJsonSchema(schema);
|
|
106
|
+
if (!this.isRecord(jsonSchema) || !this.isRecord(jsonSchema.properties))
|
|
107
|
+
return [];
|
|
108
|
+
const required = Array.isArray(jsonSchema.required) ? jsonSchema.required : [];
|
|
109
|
+
return Object.keys(jsonSchema.properties).toSorted().map((key) => ({
|
|
110
|
+
key,
|
|
111
|
+
required: required.includes(key),
|
|
112
|
+
set: values[key] !== undefined
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
isRecord(value) {
|
|
116
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
class ToolEnvService {
|
|
121
|
+
loader;
|
|
122
|
+
assignments = new EnvAssignmentParser;
|
|
123
|
+
keys = new EnvKeyParser;
|
|
124
|
+
document = new DotEnvDocument;
|
|
125
|
+
summary = new EnvSchemaSummary;
|
|
126
|
+
constructor(options = {}) {
|
|
127
|
+
this.loader = new ToolLoader(options);
|
|
128
|
+
}
|
|
129
|
+
async configure(targetValue, assignments = []) {
|
|
130
|
+
const target = ToolEnvTarget.parse(targetValue);
|
|
131
|
+
const loaded = await this.loader.loadDefinition(target.tool);
|
|
132
|
+
if (!loaded.definition.env) {
|
|
133
|
+
throw new RigError("TOOL_INVALID", `Tool ${target.tool} does not define an env schema.`, {
|
|
134
|
+
tool: target.tool
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const envPath = join(dirname(loaded.path), ".env");
|
|
138
|
+
const existing = await this.readEnv(envPath);
|
|
139
|
+
if (assignments.length === 0) {
|
|
140
|
+
return this.result(target, envPath, false, existing, loaded.definition.env, [], []);
|
|
141
|
+
}
|
|
142
|
+
if (assignments[0] === "remove") {
|
|
143
|
+
const keys = this.keys.parse(assignments.slice(1));
|
|
144
|
+
const nextValues2 = { ...existing };
|
|
145
|
+
const removedKeys = keys.filter((key) => (key in nextValues2));
|
|
146
|
+
for (const key of keys)
|
|
147
|
+
delete nextValues2[key];
|
|
148
|
+
this.validateEnv(target, envPath, loaded.definition.env, nextValues2);
|
|
149
|
+
if (removedKeys.length > 0)
|
|
150
|
+
await this.writeEnv(envPath, nextValues2);
|
|
151
|
+
return this.result(target, envPath, removedKeys.length > 0, nextValues2, loaded.definition.env, [], removedKeys);
|
|
152
|
+
}
|
|
153
|
+
const updates = this.assignments.parse(assignments);
|
|
154
|
+
const nextValues = { ...existing, ...updates };
|
|
155
|
+
this.validateEnv(target, envPath, loaded.definition.env, nextValues);
|
|
156
|
+
await this.writeEnv(envPath, nextValues);
|
|
157
|
+
return this.result(target, envPath, true, nextValues, loaded.definition.env, Object.keys(updates), []);
|
|
158
|
+
}
|
|
159
|
+
validateEnv(target, envPath, schema, values) {
|
|
160
|
+
const validation = schema.safeParse(values);
|
|
161
|
+
if (validation.success)
|
|
162
|
+
return;
|
|
163
|
+
throw new RigError("TOOL_INVALID", `Tool ${target.tool} env would be invalid.`, {
|
|
164
|
+
path: envPath,
|
|
165
|
+
errors: validation.error?.flatten()
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
result(target, envPath, updated, values, schema, updatedKeys, removedKeys) {
|
|
169
|
+
return {
|
|
170
|
+
tool: target.tool,
|
|
171
|
+
envPath,
|
|
172
|
+
updated,
|
|
173
|
+
entries: this.summary.entries(schema, values),
|
|
174
|
+
updatedKeys: updatedKeys.toSorted(),
|
|
175
|
+
removedKeys: removedKeys.toSorted()
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
async readEnv(path) {
|
|
179
|
+
if (!existsSync(path))
|
|
180
|
+
return {};
|
|
181
|
+
return this.document.parse(await readFile(path, "utf8"), path);
|
|
182
|
+
}
|
|
183
|
+
async writeEnv(path, values) {
|
|
184
|
+
await mkdir(dirname(path), { recursive: true });
|
|
185
|
+
await writeFile(path, this.document.serialize(values), "utf8");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
ToolEnvService
|
|
190
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SchemaRenderer
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-zbp3334x.js";
|
|
4
4
|
import {
|
|
5
5
|
CommandIds,
|
|
6
6
|
ToolLoader
|
|
7
|
-
} from "./cli-
|
|
8
|
-
import"./cli-
|
|
9
|
-
import"./cli-
|
|
7
|
+
} from "./cli-4e71j0m0.js";
|
|
8
|
+
import"./cli-ahwyqf1f.js";
|
|
9
|
+
import"./cli-043bae8s.js";
|
|
10
10
|
import {
|
|
11
11
|
RigError
|
|
12
12
|
} from "./cli-1c7te5cg.js";
|
|
13
|
-
import"./cli-
|
|
13
|
+
import"./cli-32dzwg3p.js";
|
|
14
14
|
import"./cli-b7jgjgy7.js";
|
|
15
15
|
|
|
16
16
|
// src/tools/help.ts
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SchemaRenderer
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-zbp3334x.js";
|
|
4
4
|
import {
|
|
5
5
|
CommandIds,
|
|
6
6
|
ToolLoader
|
|
7
|
-
} from "./cli-
|
|
8
|
-
import"./cli-
|
|
9
|
-
import"./cli-
|
|
7
|
+
} from "./cli-4e71j0m0.js";
|
|
8
|
+
import"./cli-ahwyqf1f.js";
|
|
9
|
+
import"./cli-043bae8s.js";
|
|
10
10
|
import {
|
|
11
11
|
RigError
|
|
12
12
|
} from "./cli-1c7te5cg.js";
|
|
13
|
-
import"./cli-
|
|
13
|
+
import"./cli-32dzwg3p.js";
|
|
14
14
|
import"./cli-b7jgjgy7.js";
|
|
15
15
|
|
|
16
16
|
// src/tools/inspect.ts
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ToolListService
|
|
3
|
+
} from "./cli-exxbjsry.js";
|
|
4
|
+
import"./cli-zbp3334x.js";
|
|
5
|
+
import"./cli-4e71j0m0.js";
|
|
6
|
+
import"./cli-ahwyqf1f.js";
|
|
7
|
+
import"./cli-043bae8s.js";
|
|
8
|
+
import"./cli-1c7te5cg.js";
|
|
9
|
+
import"./cli-32dzwg3p.js";
|
|
10
|
+
import"./cli-b7jgjgy7.js";
|
|
11
|
+
export {
|
|
12
|
+
ToolListService
|
|
13
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RigConfigStore
|
|
3
|
-
} from "./cli-
|
|
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-
|
|
9
|
+
} from "./cli-32dzwg3p.js";
|
|
10
10
|
import"./cli-b7jgjgy7.js";
|
|
11
11
|
|
|
12
12
|
// src/registry/registry.ts
|
package/dist/rig.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
RigCronWorker
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-85va7m21.js";
|
|
5
5
|
import {
|
|
6
6
|
RigLoggerFactory
|
|
7
|
-
} from "./cli-
|
|
8
|
-
import"./cli-
|
|
9
|
-
import"./cli-
|
|
10
|
-
import"./cli-
|
|
7
|
+
} from "./cli-d9b8eefw.js";
|
|
8
|
+
import"./cli-zbp3334x.js";
|
|
9
|
+
import"./cli-4e71j0m0.js";
|
|
10
|
+
import"./cli-ahwyqf1f.js";
|
|
11
11
|
import {
|
|
12
12
|
RigPackageRoot
|
|
13
|
-
} from "./cli-
|
|
13
|
+
} from "./cli-043bae8s.js";
|
|
14
14
|
import {
|
|
15
15
|
RigError,
|
|
16
16
|
RigErrors
|
|
17
17
|
} from "./cli-1c7te5cg.js";
|
|
18
|
-
import"./cli-
|
|
18
|
+
import"./cli-32dzwg3p.js";
|
|
19
19
|
import {
|
|
20
20
|
__require
|
|
21
21
|
} from "./cli-b7jgjgy7.js";
|
|
@@ -96,6 +96,7 @@ class CliApplication {
|
|
|
96
96
|
this.configureCreateCommand();
|
|
97
97
|
this.configureEditCommand();
|
|
98
98
|
this.configureRemoveCommand();
|
|
99
|
+
this.configureEnvCommand();
|
|
99
100
|
this.configureRunCommand();
|
|
100
101
|
this.configureCronCommands();
|
|
101
102
|
this.configureTypecheckCommand();
|
|
@@ -112,7 +113,7 @@ class CliApplication {
|
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
114
115
|
this.requestGeneratedSync();
|
|
115
|
-
const { ToolHelpService } = await import("./help-
|
|
116
|
+
const { ToolHelpService } = await import("./help-24c9vwxh.js");
|
|
116
117
|
console.log(await new ToolHelpService(this.pathOptions()).render(target));
|
|
117
118
|
});
|
|
118
119
|
}
|
|
@@ -129,37 +130,37 @@ class CliApplication {
|
|
|
129
130
|
configureConfigCommands() {
|
|
130
131
|
const configCommand = this.program.command("config").description("Manage Rig config.");
|
|
131
132
|
configCommand.command("show").description("Print config JSON.").action(async () => {
|
|
132
|
-
const { RigConfigStore } = await import("./config-
|
|
133
|
+
const { RigConfigStore } = await import("./config-72dha2z0.js");
|
|
133
134
|
const configStore = new RigConfigStore(this.pathOptions());
|
|
134
135
|
await configStore.ensure();
|
|
135
136
|
this.printJson(await configStore.read());
|
|
136
137
|
});
|
|
137
138
|
configCommand.command("path").description("Print absolute config path.").action(async () => {
|
|
138
|
-
const { RigPaths } = await import("./paths-
|
|
139
|
+
const { RigPaths } = await import("./paths-4kzahz8f.js");
|
|
139
140
|
console.log(new RigPaths(this.pathOptions()).configPath);
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
143
|
configureRegistryCommands() {
|
|
143
144
|
const registryCommand = this.program.command("registry").description("Manage tool registries.");
|
|
144
145
|
registryCommand.command("list").description("List registries as JSON.").action(async () => {
|
|
145
|
-
const { RegistryConfigService } = await import("./registry-
|
|
146
|
+
const { RegistryConfigService } = await import("./registry-nvnbmws0.js");
|
|
146
147
|
this.printJson(await new RegistryConfigService(this.pathOptions()).list());
|
|
147
148
|
});
|
|
148
149
|
registryCommand.command("create").argument("[path]").description("Add a custom registry. Defaults to the current directory.").action(async (pathValue) => {
|
|
149
150
|
this.requestGeneratedSync();
|
|
150
|
-
const { RegistryConfigService } = await import("./registry-
|
|
151
|
+
const { RegistryConfigService } = await import("./registry-nvnbmws0.js");
|
|
151
152
|
this.printJson(await new RegistryConfigService(this.pathOptions()).add(pathValue ?? process.cwd()));
|
|
152
153
|
});
|
|
153
154
|
registryCommand.command("remove").argument("<path>").description("Remove a custom registry.").action(async (pathValue) => {
|
|
154
155
|
this.requestGeneratedSync();
|
|
155
|
-
const { RegistryConfigService } = await import("./registry-
|
|
156
|
+
const { RegistryConfigService } = await import("./registry-nvnbmws0.js");
|
|
156
157
|
this.printJson(await new RegistryConfigService(this.pathOptions()).remove(pathValue));
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
configureListCommand() {
|
|
160
161
|
this.program.command("list").alias("ls").description("List discovered tools and commands.").option("--json", "Print full JSON metadata.").option("--plain", "Print a compact plain text command list.").option("--for-path <path>", "Only list tools from registries visible from a path.").action(async (commandOptions) => {
|
|
161
162
|
this.requestGeneratedSync();
|
|
162
|
-
const { ToolListService } = await import("./list-
|
|
163
|
+
const { ToolListService } = await import("./list-jfcspwm7.js");
|
|
163
164
|
const service = new ToolListService(this.pathOptions());
|
|
164
165
|
const data = await service.list({ visibleFromPath: commandOptions.forPath });
|
|
165
166
|
if (commandOptions.json)
|
|
@@ -171,7 +172,7 @@ class CliApplication {
|
|
|
171
172
|
configureInspectCommand() {
|
|
172
173
|
this.program.command("inspect").argument("<target>", "Tool name or command id (<tool>.<command>.)").description("Print tool or command metadata as JSON.").action(async (target) => {
|
|
173
174
|
this.requestGeneratedSync();
|
|
174
|
-
const { ToolInspector } = await import("./inspect-
|
|
175
|
+
const { ToolInspector } = await import("./inspect-mb0n7sjg.js");
|
|
175
176
|
this.printJson(await new ToolInspector(this.pathOptions()).inspect(target));
|
|
176
177
|
});
|
|
177
178
|
}
|
|
@@ -184,7 +185,7 @@ class CliApplication {
|
|
|
184
185
|
configureEditCommand() {
|
|
185
186
|
this.program.command("edit").argument("<tool>").description("Print the TypeScript file path for a tool.").action(async (name) => {
|
|
186
187
|
this.requestGeneratedSync();
|
|
187
|
-
const { ToolFileService } = await import("./create-
|
|
188
|
+
const { ToolFileService } = await import("./create-bvzszsyt.js");
|
|
188
189
|
const result = await new ToolFileService(this.pathOptions()).path(name);
|
|
189
190
|
console.log(result.toolPath);
|
|
190
191
|
});
|
|
@@ -192,12 +193,19 @@ class CliApplication {
|
|
|
192
193
|
configureRemoveCommand() {
|
|
193
194
|
this.program.command("remove").argument("<tool>").description("Remove a local tool directory.").action(async (name) => {
|
|
194
195
|
this.requestGeneratedSync();
|
|
195
|
-
const { ToolRemover } = await import("./create-
|
|
196
|
+
const { ToolRemover } = await import("./create-bvzszsyt.js");
|
|
196
197
|
const result = await new ToolRemover(this.pathOptions()).remove(name);
|
|
197
198
|
console.log(`Removed tool ${result.name}`);
|
|
198
199
|
console.log(`Tool directory: ${result.toolDir}`);
|
|
199
200
|
});
|
|
200
201
|
}
|
|
202
|
+
configureEnvCommand() {
|
|
203
|
+
this.program.command("env").argument("<tool>", "Tool name.").argument("[assignments...]", "Use KEY=VALUE to set values, or remove KEY [KEY...] to remove values.").description("Show, write, or remove tool .env values using its env schema.").action(async (target, assignments) => {
|
|
204
|
+
this.requestGeneratedSync();
|
|
205
|
+
const { ToolEnvService } = await import("./env-9kd3dqkx.js");
|
|
206
|
+
this.printJson(await new ToolEnvService(this.pathOptions()).configure(target, assignments));
|
|
207
|
+
});
|
|
208
|
+
}
|
|
201
209
|
configureRunCommand() {
|
|
202
210
|
this.program.command("run").argument("<command>", "Command id, formatted as <tool>.<command>.").argument("[args...]", "Command arguments.").description("Run a tool command.").option("--input <json>", "JSON input string.").option("--input-file <path>", "Read JSON input from a file.").option("--dry-run", "Validate input and show what would run without executing.").action(async (commandId, args, commandOptions) => {
|
|
203
211
|
this.requestGeneratedSync();
|
|
@@ -207,11 +215,11 @@ class CliApplication {
|
|
|
207
215
|
configureCronCommands() {
|
|
208
216
|
const cronCommand = this.program.command("cron").description("Manage scheduled Rig tool commands.");
|
|
209
217
|
cronCommand.command("list").description("List scheduled Rig tool commands as JSON.").action(async () => {
|
|
210
|
-
const { RigCronService } = await import("./cron-
|
|
218
|
+
const { RigCronService } = await import("./cron-n15qfj8m.js");
|
|
211
219
|
this.printJson(await new RigCronService(this.pathOptions()).list());
|
|
212
220
|
});
|
|
213
221
|
cronCommand.command("add").argument("<name>", "Unique job name, using letters, numbers, hyphens, or underscores.").argument("<command>", "Command id, formatted as <tool>.<command>.").argument("<schedule>", "Cron expression or nickname, such as @weekly.").description("Schedule a Rig tool command with fixed JSON input.").option("--input <json>", "JSON input string.").option("--input-file <path>", "Read JSON input from a file.").action(async (name, commandId, schedule, commandOptions) => {
|
|
214
|
-
const { cronModuleUrl, RigCronService } = await import("./cron-
|
|
222
|
+
const { cronModuleUrl, RigCronService } = await import("./cron-n15qfj8m.js");
|
|
215
223
|
const result = await new RigCronService(this.pathOptions()).add({
|
|
216
224
|
name,
|
|
217
225
|
command: commandId,
|
|
@@ -223,11 +231,11 @@ class CliApplication {
|
|
|
223
231
|
this.printJson(result);
|
|
224
232
|
});
|
|
225
233
|
cronCommand.command("remove").argument("<name>", "Cron job name.").description("Remove a scheduled Rig tool command.").action(async (name) => {
|
|
226
|
-
const { RigCronService } = await import("./cron-
|
|
234
|
+
const { RigCronService } = await import("./cron-n15qfj8m.js");
|
|
227
235
|
this.printJson(await new RigCronService(this.pathOptions()).remove(name));
|
|
228
236
|
});
|
|
229
237
|
cronCommand.command("run").argument("<name>", "Cron job name.").description("Run a scheduled Rig tool command now.").action(async (name) => {
|
|
230
|
-
const { RigCronService } = await import("./cron-
|
|
238
|
+
const { RigCronService } = await import("./cron-n15qfj8m.js");
|
|
231
239
|
const result = await new RigCronService(this.pathOptions()).run(name);
|
|
232
240
|
this.printJson(result.envelope);
|
|
233
241
|
process.exitCode = result.exitCode;
|
|
@@ -236,7 +244,7 @@ class CliApplication {
|
|
|
236
244
|
configureTypecheckCommand() {
|
|
237
245
|
this.program.command("typecheck").argument("[tool]").description("Type-check local tool files with the injected Rig tool runtime types.").action(async (tool) => {
|
|
238
246
|
this.requestGeneratedSync();
|
|
239
|
-
const { ToolTypecheckService } = await import("./typecheck-
|
|
247
|
+
const { ToolTypecheckService } = await import("./typecheck-6q579sqn.js");
|
|
240
248
|
const result = await new ToolTypecheckService(this.pathOptions()).typecheck(tool);
|
|
241
249
|
this.printJson(result);
|
|
242
250
|
process.exitCode = result.exitCode;
|
|
@@ -266,7 +274,7 @@ class CliApplication {
|
|
|
266
274
|
configureDevCommands() {
|
|
267
275
|
const devCommand = this.program.command("dev").description("Local development helpers.");
|
|
268
276
|
devCommand.command("link").description("Link this checkout as the local rig command for development.").option("--bin-dir <path>", "Directory where the rig shim should be written.").option("--force", "Overwrite an existing non-Rig shim.").action(async (commandOptions) => {
|
|
269
|
-
const { DevLinkService } = await import("./dev-link-
|
|
277
|
+
const { DevLinkService } = await import("./dev-link-znh4mch1.js");
|
|
270
278
|
const service = new DevLinkService(this.pathOptions());
|
|
271
279
|
const status = await service.link({
|
|
272
280
|
binDir: commandOptions.binDir,
|
|
@@ -275,7 +283,7 @@ class CliApplication {
|
|
|
275
283
|
console.log(service.renderLinkResult(status));
|
|
276
284
|
});
|
|
277
285
|
devCommand.command("unlink").description("Remove the local rig development shim.").option("--bin-dir <path>", "Directory where the rig shim was written.").option("--force", "Remove even if the file is not a Rig dev shim.").action(async (commandOptions) => {
|
|
278
|
-
const { DevLinkService } = await import("./dev-link-
|
|
286
|
+
const { DevLinkService } = await import("./dev-link-znh4mch1.js");
|
|
279
287
|
const service = new DevLinkService(this.pathOptions());
|
|
280
288
|
const status = await service.unlink({
|
|
281
289
|
binDir: commandOptions.binDir,
|
|
@@ -284,12 +292,12 @@ class CliApplication {
|
|
|
284
292
|
console.log(service.renderUnlinkResult(status));
|
|
285
293
|
});
|
|
286
294
|
devCommand.command("status").description("Show local rig development shim status as JSON.").option("--bin-dir <path>", "Directory where the rig shim should be checked.").action(async (commandOptions) => {
|
|
287
|
-
const { DevLinkService } = await import("./dev-link-
|
|
295
|
+
const { DevLinkService } = await import("./dev-link-znh4mch1.js");
|
|
288
296
|
this.printJson(await new DevLinkService(this.pathOptions()).status(commandOptions));
|
|
289
297
|
});
|
|
290
298
|
}
|
|
291
299
|
async runToolCommand(commandId, args, commandOptions) {
|
|
292
|
-
const { ToolRunner } = await import("./run-
|
|
300
|
+
const { ToolRunner } = await import("./run-ngbemhx5.js");
|
|
293
301
|
const commandTarget = this.commandTarget(commandId);
|
|
294
302
|
const result = await new ToolRunner(this.pathOptions()).run(commandTarget.tool, commandTarget.command, {
|
|
295
303
|
...this.pathOptions(),
|
|
@@ -303,9 +311,9 @@ class CliApplication {
|
|
|
303
311
|
}
|
|
304
312
|
async showDefaultStatus() {
|
|
305
313
|
const [{ RigConfigStore }, { RigPaths }, { ToolDiscoveryService }] = await Promise.all([
|
|
306
|
-
import("./config-
|
|
307
|
-
import("./paths-
|
|
308
|
-
import("./discover-
|
|
314
|
+
import("./config-72dha2z0.js"),
|
|
315
|
+
import("./paths-4kzahz8f.js"),
|
|
316
|
+
import("./discover-549nzamy.js")
|
|
309
317
|
]);
|
|
310
318
|
const options = this.pathOptions();
|
|
311
319
|
const paths = new RigPaths(options);
|
|
@@ -315,7 +323,9 @@ class CliApplication {
|
|
|
315
323
|
const registries = configStore.registryEntries(config);
|
|
316
324
|
const currentVersion = this.version();
|
|
317
325
|
new RigLoggerFactory(options).app("cli").info({ version: currentVersion, tools: tools.length }, "Default status rendered.");
|
|
318
|
-
this.printMigrationNotice(configStore.migrationResult())
|
|
326
|
+
if (this.printMigrationNotice(configStore.migrationResult())) {
|
|
327
|
+
await configStore.acknowledgeMigrationPrompt();
|
|
328
|
+
}
|
|
319
329
|
console.log(`Rig is ready.
|
|
320
330
|
`);
|
|
321
331
|
console.log(`Version: ${currentVersion}`);
|
|
@@ -330,7 +340,7 @@ Run "rig doctor" if you want to verify your setup.`);
|
|
|
330
340
|
await this.printUpdateNotice(currentVersion);
|
|
331
341
|
}
|
|
332
342
|
async createTool(name) {
|
|
333
|
-
const { ToolCreator } = await import("./create-
|
|
343
|
+
const { ToolCreator } = await import("./create-bvzszsyt.js");
|
|
334
344
|
const result = await new ToolCreator(this.pathOptions()).create(name);
|
|
335
345
|
console.log(`Created tool ${result.name}`);
|
|
336
346
|
console.log(`
|
|
@@ -350,15 +360,17 @@ Try:`);
|
|
|
350
360
|
}
|
|
351
361
|
async doctor() {
|
|
352
362
|
const [{ RigConfigStore }, { RigPaths }, { ToolDiscoveryService }] = await Promise.all([
|
|
353
|
-
import("./config-
|
|
354
|
-
import("./paths-
|
|
355
|
-
import("./discover-
|
|
363
|
+
import("./config-72dha2z0.js"),
|
|
364
|
+
import("./paths-4kzahz8f.js"),
|
|
365
|
+
import("./discover-549nzamy.js")
|
|
356
366
|
]);
|
|
357
367
|
const options = this.pathOptions();
|
|
358
368
|
const paths = new RigPaths(options);
|
|
359
369
|
const configStore = new RigConfigStore(options);
|
|
360
370
|
const config = await configStore.ensure();
|
|
361
|
-
this.printMigrationNotice(configStore.migrationResult())
|
|
371
|
+
if (this.printMigrationNotice(configStore.migrationResult())) {
|
|
372
|
+
await configStore.acknowledgeMigrationPrompt();
|
|
373
|
+
}
|
|
362
374
|
const registries = configStore.registryEntries(config);
|
|
363
375
|
const tools = await new ToolDiscoveryService(options).discover();
|
|
364
376
|
new RigLoggerFactory(options).app("doctor").info({ registries: registries.length, tools: tools.length }, "Doctor check completed.");
|
|
@@ -377,7 +389,7 @@ Status: OK`);
|
|
|
377
389
|
}
|
|
378
390
|
printMigrationNotice(migration) {
|
|
379
391
|
if (!migration)
|
|
380
|
-
return;
|
|
392
|
+
return false;
|
|
381
393
|
if (migration.status === "migrated") {
|
|
382
394
|
console.log("Rig moved its home folder:");
|
|
383
395
|
console.log(` From: ${migration.legacyDir}`);
|
|
@@ -385,18 +397,20 @@ Status: OK`);
|
|
|
385
397
|
if (migration.configUpdated)
|
|
386
398
|
console.log(" Updated base registry: ~/rig/tools");
|
|
387
399
|
console.log("");
|
|
388
|
-
return;
|
|
400
|
+
return false;
|
|
389
401
|
}
|
|
390
402
|
console.log("Rig home folder migration needs your attention:");
|
|
391
403
|
console.log(` Old folder: ${migration.legacyDir}`);
|
|
392
404
|
console.log(` New folder: ${migration.currentDir}`);
|
|
393
405
|
console.log(` Reason: ${migration.reason}`);
|
|
394
406
|
console.log("Move the files you want to keep into the new folder, then remove the old folder.");
|
|
407
|
+
console.log("This migration prompt is versioned; Rig will not show it again after this run.");
|
|
395
408
|
console.log("");
|
|
409
|
+
return true;
|
|
396
410
|
}
|
|
397
411
|
async printUpdateNotice(currentVersion) {
|
|
398
412
|
await this.ignoreSyncErrors(async () => {
|
|
399
|
-
const { NpmUpdateCheckService } = await import("./update-check-
|
|
413
|
+
const { NpmUpdateCheckService } = await import("./update-check-bqa9ejex.js");
|
|
400
414
|
const notice = await new NpmUpdateCheckService(this.pathOptions()).check(currentVersion);
|
|
401
415
|
if (notice)
|
|
402
416
|
console.log(`
|
|
@@ -408,13 +422,13 @@ ${notice.message}`);
|
|
|
408
422
|
}
|
|
409
423
|
async syncGeneratedFiles() {
|
|
410
424
|
await this.ignoreSyncErrors(async () => {
|
|
411
|
-
const { ToolRuntimeCommentSyncService } = await import("./runtime-comment-
|
|
425
|
+
const { ToolRuntimeCommentSyncService } = await import("./runtime-comment-gbermtjx.js");
|
|
412
426
|
await new ToolRuntimeCommentSyncService(this.pathOptions()).sync();
|
|
413
427
|
});
|
|
414
428
|
if (process.env.RIG_AGENT_SYNC === "0")
|
|
415
429
|
return;
|
|
416
430
|
await this.ignoreSyncErrors(async () => {
|
|
417
|
-
const { AgentInstructionSyncService } = await import("./sync-
|
|
431
|
+
const { AgentInstructionSyncService } = await import("./sync-7x553cky.js");
|
|
418
432
|
await new AgentInstructionSyncService(this.pathOptions()).sync();
|
|
419
433
|
});
|
|
420
434
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ToolRunner
|
|
3
|
+
} from "./cli-d9b8eefw.js";
|
|
4
|
+
import"./cli-zbp3334x.js";
|
|
5
|
+
import"./cli-4e71j0m0.js";
|
|
6
|
+
import"./cli-ahwyqf1f.js";
|
|
7
|
+
import"./cli-043bae8s.js";
|
|
8
|
+
import"./cli-1c7te5cg.js";
|
|
9
|
+
import"./cli-32dzwg3p.js";
|
|
10
|
+
import"./cli-b7jgjgy7.js";
|
|
11
|
+
export {
|
|
12
|
+
ToolRunner
|
|
13
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolDiscoveryService
|
|
3
|
-
} from "./cli-
|
|
4
|
-
import"./cli-
|
|
3
|
+
} from "./cli-ahwyqf1f.js";
|
|
4
|
+
import"./cli-043bae8s.js";
|
|
5
5
|
import"./cli-1c7te5cg.js";
|
|
6
|
-
import"./cli-
|
|
6
|
+
import"./cli-32dzwg3p.js";
|
|
7
7
|
import"./cli-b7jgjgy7.js";
|
|
8
8
|
|
|
9
9
|
// src/tools/runtime-comment.ts
|
|
@@ -18,11 +18,14 @@ Rig tool runtime:
|
|
|
18
18
|
- \`rig.defineTool(definition)\` defines the tool.
|
|
19
19
|
- \`rig.defineCommand(definition)\` defines one command with \`{ description, input, output, run }\`.
|
|
20
20
|
- Use \`rig.z.object({ ... })\` for input/output schemas.
|
|
21
|
+
- Tools run under Bun with fallback auto-install enabled, so tool files can import npm packages; add explicit package versions when reproducibility matters.
|
|
21
22
|
- \`rig.run({ command: "tool.command", input })\` runs another registered Rig command and returns its data.
|
|
22
23
|
- \`rig.$\` runs a Bun Shell tagged template command with escaped interpolations. Docs: https://bun.com/docs/runtime/shell
|
|
23
24
|
- \`rig.args()\` builds argv arrays with \`.raw()\`, \`.flag()\`, \`.value()\`, \`.values()\`, and \`.toArray()\`.
|
|
24
25
|
- \`rig.paths.home()\`, \`rig.paths.resolve(cwd, path)\`, \`rig.paths.ensureParent(path)\`, and \`rig.paths.size(path)\` cover common path work.
|
|
25
|
-
- Add \`env: rig.z.object({ KEY: rig.z.string() })\` to validate
|
|
26
|
+
- Add \`env: rig.z.object({ KEY: rig.z.string() })\` to validate local secrets or settings and receive parsed values on \`context.env\`.
|
|
27
|
+
- Run \`rig env <tool> KEY=VALUE\` to write the tool \`.env\` file; run \`rig env <tool> remove KEY\` to remove a value.
|
|
28
|
+
- To add another registry for tool files, run \`rig registry create [path]\` (defaults to current directory).
|
|
26
29
|
|
|
27
30
|
Tool logging and key-value state:
|
|
28
31
|
- Use \`context.log.info(...)\`, \`context.log.warn(...)\`, or another Pino-style method for structured logs with a default \`tool:<tool>.<command>\` prefix.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolListService
|
|
3
|
-
} from "./cli-
|
|
4
|
-
import"./cli-
|
|
5
|
-
import"./cli-
|
|
6
|
-
import"./cli-
|
|
7
|
-
import"./cli-
|
|
3
|
+
} from "./cli-exxbjsry.js";
|
|
4
|
+
import"./cli-zbp3334x.js";
|
|
5
|
+
import"./cli-4e71j0m0.js";
|
|
6
|
+
import"./cli-ahwyqf1f.js";
|
|
7
|
+
import"./cli-043bae8s.js";
|
|
8
8
|
import"./cli-1c7te5cg.js";
|
|
9
9
|
import {
|
|
10
10
|
RigPaths
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-32dzwg3p.js";
|
|
12
12
|
import"./cli-b7jgjgy7.js";
|
|
13
13
|
|
|
14
14
|
// src/agents/sync.ts
|
|
@@ -17,28 +17,25 @@ import { readFile, realpath, stat, writeFile } from "node:fs/promises";
|
|
|
17
17
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
18
18
|
|
|
19
19
|
// src/agents/instructions.ts
|
|
20
|
-
var RigAgentInstructions = `The \`rig\` CLI is installed on this machine. It
|
|
20
|
+
var RigAgentInstructions = `The \`rig\` CLI is installed on this machine. It lets agents discover, run, and create local typed tools.
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- To add a registry, run \`rig registry create [path]\` (defaults to current directory).
|
|
34
|
-
- 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.
|
|
35
|
-
- Use \`context.kv.set(key, value)\` and \`context.kv.get(key)\` for lightweight JSON state in \`kv.sqlite\` beside the tool entry file.
|
|
36
|
-
- 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\`.
|
|
22
|
+
- Run \`rig\` (or \`rig init\`) to set up or sync rig. This also updates detected AGENTS.md and CLAUDE.md files with available rig tools.
|
|
23
|
+
- Run \`rig create <tool>\` when the user asks you to turn a repeatable workflow into a reusable tool.
|
|
24
|
+
- Run \`rig edit <tool>\` to print the tool file path for editing.
|
|
25
|
+
- Run \`rig remove <tool>\` to remove a local tool.
|
|
26
|
+
- Run \`rig cron --help\` to schedule and manage tool commands.
|
|
27
|
+
- Run \`rig typecheck <tool>\` to validate a tool's TypeScript and runtime types.
|
|
28
|
+
- Run \`rig env <tool> KEY=VALUE\` to configure tool secrets/settings; run \`rig env <tool> remove KEY\` to remove them.
|
|
29
|
+
- Run \`rig list\` to discover tools and available \`rig run ...\` commands.
|
|
30
|
+
- Run \`rig help <tool>\` or \`rig help <tool>.<command>\` for usage, inputs, and outputs.
|
|
31
|
+
- Run \`rig run <tool>.<command> [args]\` to execute a tool command.
|
|
32
|
+
- Run \`rig --help\` for other Rig CLI commands.
|
|
37
33
|
`;
|
|
38
34
|
|
|
39
35
|
// src/agents/sync.ts
|
|
40
36
|
var StartMarker = "<!-- rig:agent-instructions:start -->";
|
|
41
37
|
var EndMarker = "<!-- rig:agent-instructions:end -->";
|
|
38
|
+
var IgnoreMarker = "<!-- rig:ignore -->";
|
|
42
39
|
var AgentInstructionSyncLocations = {
|
|
43
40
|
projectFiles: ["AGENTS.md", "CLAUDE.md"],
|
|
44
41
|
projectClaudeDirectories: [".claude"],
|
|
@@ -92,6 +89,7 @@ class AgentInstructionSyncService {
|
|
|
92
89
|
}
|
|
93
90
|
renderBlock(toolList) {
|
|
94
91
|
return `${StartMarker}
|
|
92
|
+
|
|
95
93
|
## Rig local tools
|
|
96
94
|
|
|
97
95
|
${RigAgentInstructions}
|
|
@@ -100,6 +98,7 @@ ${RigAgentInstructions}
|
|
|
100
98
|
\`\`\`text
|
|
101
99
|
${toolList}
|
|
102
100
|
\`\`\`
|
|
101
|
+
|
|
103
102
|
${EndMarker}`;
|
|
104
103
|
}
|
|
105
104
|
async renderToolList(target) {
|
|
@@ -107,12 +106,15 @@ ${EndMarker}`;
|
|
|
107
106
|
return this.listService.renderPlain(await this.listService.list(options));
|
|
108
107
|
}
|
|
109
108
|
async addExistingFile(targets, path, scope) {
|
|
110
|
-
if (await this.isFile(path))
|
|
109
|
+
if (await this.isFile(path) && !await this.isIgnored(path)) {
|
|
111
110
|
await this.setTarget(targets, path, true, scope);
|
|
111
|
+
}
|
|
112
112
|
}
|
|
113
113
|
async addClaudeDirectoryTarget(targets, directory, scope) {
|
|
114
114
|
const path = join(directory, "CLAUDE.md");
|
|
115
115
|
const fileExists = await this.isFile(path);
|
|
116
|
+
if (fileExists && await this.isIgnored(path))
|
|
117
|
+
return;
|
|
116
118
|
const directoryExists = fileExists ? false : await this.isDirectory(directory);
|
|
117
119
|
if (fileExists || directoryExists)
|
|
118
120
|
await this.setTarget(targets, path, fileExists, scope);
|
|
@@ -162,7 +164,7 @@ ${EndMarker}`;
|
|
|
162
164
|
async setTarget(targets, path, existed, scope) {
|
|
163
165
|
const key = existed ? await this.realPath(path) : path;
|
|
164
166
|
const current = targets.get(key);
|
|
165
|
-
const nextScope = current?.scope === "
|
|
167
|
+
const nextScope = current?.scope === "all" || scope === "all" ? "all" : "visible";
|
|
166
168
|
if (!current || path < current.path)
|
|
167
169
|
targets.set(key, { path, existed, scope: nextScope });
|
|
168
170
|
else
|
|
@@ -209,6 +211,13 @@ ${EndMarker}`;
|
|
|
209
211
|
escapeRegExp(value) {
|
|
210
212
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
211
213
|
}
|
|
214
|
+
async isIgnored(path) {
|
|
215
|
+
try {
|
|
216
|
+
return (await this.readText(path)).includes(IgnoreMarker);
|
|
217
|
+
} catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
212
221
|
async realPath(path) {
|
|
213
222
|
try {
|
|
214
223
|
return await realpath(path);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolLoader
|
|
3
|
-
} from "./cli-
|
|
3
|
+
} from "./cli-4e71j0m0.js";
|
|
4
4
|
import {
|
|
5
5
|
ToolDiscoveryService
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-ahwyqf1f.js";
|
|
7
7
|
import {
|
|
8
8
|
RigConfigStore,
|
|
9
9
|
RigPackageRoot
|
|
10
|
-
} from "./cli-
|
|
10
|
+
} from "./cli-043bae8s.js";
|
|
11
11
|
import {
|
|
12
12
|
RigError
|
|
13
13
|
} from "./cli-1c7te5cg.js";
|
|
14
14
|
import {
|
|
15
15
|
RigPaths
|
|
16
|
-
} from "./cli-
|
|
16
|
+
} from "./cli-32dzwg3p.js";
|
|
17
17
|
import {
|
|
18
18
|
__commonJS,
|
|
19
19
|
__require,
|
package/package.json
CHANGED
package/dist/cron-ynhxww07.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RigCronService,
|
|
3
|
-
RigCronWorker,
|
|
4
|
-
cronModuleUrl
|
|
5
|
-
} from "./cli-sthjxz5r.js";
|
|
6
|
-
import"./cli-v3rc5c7e.js";
|
|
7
|
-
import"./cli-7ydvyqk0.js";
|
|
8
|
-
import"./cli-5bhr3az0.js";
|
|
9
|
-
import"./cli-1x1ej1qw.js";
|
|
10
|
-
import"./cli-q030hfkh.js";
|
|
11
|
-
import"./cli-1c7te5cg.js";
|
|
12
|
-
import"./cli-e36v1j7k.js";
|
|
13
|
-
import"./cli-b7jgjgy7.js";
|
|
14
|
-
export {
|
|
15
|
-
cronModuleUrl,
|
|
16
|
-
RigCronWorker,
|
|
17
|
-
RigCronService
|
|
18
|
-
};
|
package/dist/list-v29rq1q1.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ToolListService
|
|
3
|
-
} from "./cli-w0fx5mq7.js";
|
|
4
|
-
import"./cli-7ydvyqk0.js";
|
|
5
|
-
import"./cli-5bhr3az0.js";
|
|
6
|
-
import"./cli-1x1ej1qw.js";
|
|
7
|
-
import"./cli-q030hfkh.js";
|
|
8
|
-
import"./cli-1c7te5cg.js";
|
|
9
|
-
import"./cli-e36v1j7k.js";
|
|
10
|
-
import"./cli-b7jgjgy7.js";
|
|
11
|
-
export {
|
|
12
|
-
ToolListService
|
|
13
|
-
};
|
package/dist/run-4dhw2n7j.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ToolRunner
|
|
3
|
-
} from "./cli-v3rc5c7e.js";
|
|
4
|
-
import"./cli-7ydvyqk0.js";
|
|
5
|
-
import"./cli-5bhr3az0.js";
|
|
6
|
-
import"./cli-1x1ej1qw.js";
|
|
7
|
-
import"./cli-q030hfkh.js";
|
|
8
|
-
import"./cli-1c7te5cg.js";
|
|
9
|
-
import"./cli-e36v1j7k.js";
|
|
10
|
-
import"./cli-b7jgjgy7.js";
|
|
11
|
-
export {
|
|
12
|
-
ToolRunner
|
|
13
|
-
};
|