@h-rig/product-entrypoint-plugin 0.0.6-alpha.145

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 ADDED
@@ -0,0 +1 @@
1
+ # @h-rig/product-entrypoint-plugin
@@ -0,0 +1,15 @@
1
+ export type RigProductCommandName = "launch" | "join" | "acp" | "models" | "mcp" | "update";
2
+ export type StandardProductCommandDescriptor = {
3
+ readonly command: RigProductCommandName;
4
+ readonly description: string;
5
+ readonly usage: string;
6
+ };
7
+ export declare const STANDARD_PRODUCT_COMMANDS: readonly StandardProductCommandDescriptor[];
8
+ export declare function standardProductCliCommandId(command: RigProductCommandName): string;
9
+ export declare function standardProductCliCommandMetadata(descriptor: StandardProductCommandDescriptor): {
10
+ id: string;
11
+ family: RigProductCommandName;
12
+ description: string;
13
+ usage: string;
14
+ projectRequired: boolean;
15
+ };
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // packages/product-entrypoint-plugin/src/metadata.ts
3
+ var STANDARD_PRODUCT_COMMANDS = [
4
+ { command: "launch", description: "Open the Rig Cockpit through the OMP collaboration substrate.", usage: "rig [launch] [args...]" },
5
+ { command: "join", description: "Join an encrypted Rig/OMP collaborative session.", usage: "rig join <link>" },
6
+ { command: "acp", description: "Start the Rig product in OMP ACP mode.", usage: "rig acp [args...]" },
7
+ { command: "models", description: "Delegate model management to the Rig product substrate.", usage: "rig models [args...]" },
8
+ { command: "mcp", description: "Delegate MCP management to the Rig product substrate.", usage: "rig mcp [args...]" },
9
+ { command: "update", description: "Delegate product update handling to the Rig product substrate.", usage: "rig update [args...]" }
10
+ ];
11
+ function standardProductCliCommandId(command) {
12
+ return `@rig/product-entrypoint-plugin:${command}`;
13
+ }
14
+ function standardProductCliCommandMetadata(descriptor) {
15
+ return {
16
+ id: standardProductCliCommandId(descriptor.command),
17
+ family: descriptor.command,
18
+ description: descriptor.description,
19
+ usage: descriptor.usage,
20
+ projectRequired: false
21
+ };
22
+ }
23
+ export {
24
+ standardProductCliCommandMetadata,
25
+ standardProductCliCommandId,
26
+ STANDARD_PRODUCT_COMMANDS
27
+ };
@@ -0,0 +1,3 @@
1
+ import { type RigPluginWithRuntime } from "@rig/core/config";
2
+ export declare function createStandardProductEntrypointPlugin(): RigPluginWithRuntime;
3
+ export declare const standardProductEntrypointPlugin: RigPluginWithRuntime;
@@ -0,0 +1,175 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
+
18
+ // packages/product-entrypoint-plugin/src/product-entrypoint.ts
19
+ var exports_product_entrypoint = {};
20
+ __export(exports_product_entrypoint, {
21
+ runRigOmpProductCommand: () => runRigOmpProductCommand
22
+ });
23
+ import { resolve } from "path";
24
+ import { runCli } from "@oh-my-pi/pi-coding-agent/cli";
25
+ import { parseArgs } from "@oh-my-pi/pi-coding-agent/cli/args";
26
+ import { resolveCliArgv } from "@oh-my-pi/pi-coding-agent/cli-commands";
27
+ import { prepareAcpTerminalAuthArgs } from "@oh-my-pi/pi-coding-agent/modes/acp/terminal-auth";
28
+ import { runRootCommand } from "@oh-my-pi/pi-coding-agent/main";
29
+ import { createAgentSession } from "@oh-my-pi/pi-coding-agent/sdk";
30
+ import { applyIdentityEnv, identityFilterFromEnv, reconcileRuns } from "@rig/client";
31
+ import rigExtension from "@rig/rig-extension";
32
+ import { resolveRigOmpConfigOverlayPath } from "@rig/runtime/control-plane/remote-config";
33
+ function withRigDefaultConfig(projectRoot, argv) {
34
+ return ["--config", resolveRigOmpConfigOverlayPath(projectRoot), ...argv];
35
+ }
36
+ function createRigAgentSession(options = {}) {
37
+ return createAgentSession({
38
+ ...options,
39
+ extensions: [(api) => rigExtension(api), ...options.extensions ?? []]
40
+ });
41
+ }
42
+ function productArgv(input) {
43
+ if (input.command === "launch" && input.args.length === 0)
44
+ return [];
45
+ if (input.command === "launch" && input.args[0]?.startsWith("-"))
46
+ return [...input.args];
47
+ return [input.command, ...input.args];
48
+ }
49
+ async function runRigOmpProductCommand(input) {
50
+ const projectRoot = resolve(input.projectRoot);
51
+ const previousProjectRoot = process.env.RIG_PROJECT_ROOT;
52
+ const previousCwd = process.cwd();
53
+ const restorePublicIdentityEnv = applyIdentityEnv(projectRoot);
54
+ process.env.RIG_PROJECT_ROOT = projectRoot;
55
+ process.chdir(projectRoot);
56
+ try {
57
+ const argv = productArgv(input);
58
+ if (argv[0]?.startsWith("__omp_worker_") || argv[0] === "--smoke-test") {
59
+ await runCli(argv);
60
+ return { ok: true, group: "product", command: input.command };
61
+ }
62
+ if (process.stdin.isTTY) {
63
+ const reconcile = await reconcileRuns({
64
+ workspaceRoot: projectRoot,
65
+ identityFilter: identityFilterFromEnv()
66
+ }).catch(() => ({ flipped: [], resumable: [] }));
67
+ globalThis.__RIG_RESUMABLE__ = reconcile.resumable;
68
+ }
69
+ const resolved = resolveCliArgv(argv);
70
+ if ("error" in resolved) {
71
+ process.stderr.write(`error: ${resolved.error}
72
+ `);
73
+ process.exitCode = 1;
74
+ return { ok: true, group: "product", command: input.command };
75
+ }
76
+ const [ompCommand, ...ompCommandArgs] = resolved.argv;
77
+ if (ompCommand === "launch") {
78
+ const args = withRigDefaultConfig(projectRoot, ompCommandArgs);
79
+ await runRootCommand(parseArgs(args), args, { createAgentSession: createRigAgentSession });
80
+ } else if (ompCommand === "acp") {
81
+ const { args: preparedArgs, terminalAuth } = prepareAcpTerminalAuthArgs(ompCommandArgs);
82
+ const args = withRigDefaultConfig(projectRoot, preparedArgs);
83
+ const parsed = parseArgs(args);
84
+ if (!terminalAuth)
85
+ parsed.mode = "acp";
86
+ await runRootCommand(parsed, args, { createAgentSession: createRigAgentSession });
87
+ } else if (ompCommand === "join") {
88
+ const link = ompCommandArgs[0]?.trim();
89
+ if (!link) {
90
+ process.stderr.write(`Usage: rig join <link>
91
+ `);
92
+ process.exitCode = 1;
93
+ return { ok: true, group: "product", command: input.command };
94
+ }
95
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
96
+ process.stderr.write(`rig join requires an interactive terminal
97
+ `);
98
+ process.exitCode = 1;
99
+ return { ok: true, group: "product", command: input.command };
100
+ }
101
+ const args = withRigDefaultConfig(projectRoot, []);
102
+ const parsed = parseArgs(args);
103
+ parsed.join = link;
104
+ await runRootCommand(parsed, args, { createAgentSession: createRigAgentSession });
105
+ } else {
106
+ await runCli(resolved.argv);
107
+ }
108
+ return { ok: true, group: "product", command: input.command };
109
+ } finally {
110
+ restorePublicIdentityEnv();
111
+ process.chdir(previousCwd);
112
+ if (previousProjectRoot === undefined) {
113
+ delete process.env.RIG_PROJECT_ROOT;
114
+ } else {
115
+ process.env.RIG_PROJECT_ROOT = previousProjectRoot;
116
+ }
117
+ }
118
+ }
119
+ var init_product_entrypoint = () => {};
120
+
121
+ // packages/product-entrypoint-plugin/src/plugin.ts
122
+ import { definePlugin } from "@rig/core/config";
123
+
124
+ // packages/product-entrypoint-plugin/src/metadata.ts
125
+ var STANDARD_PRODUCT_COMMANDS = [
126
+ { command: "launch", description: "Open the Rig Cockpit through the OMP collaboration substrate.", usage: "rig [launch] [args...]" },
127
+ { command: "join", description: "Join an encrypted Rig/OMP collaborative session.", usage: "rig join <link>" },
128
+ { command: "acp", description: "Start the Rig product in OMP ACP mode.", usage: "rig acp [args...]" },
129
+ { command: "models", description: "Delegate model management to the Rig product substrate.", usage: "rig models [args...]" },
130
+ { command: "mcp", description: "Delegate MCP management to the Rig product substrate.", usage: "rig mcp [args...]" },
131
+ { command: "update", description: "Delegate product update handling to the Rig product substrate.", usage: "rig update [args...]" }
132
+ ];
133
+ function standardProductCliCommandId(command) {
134
+ return `@rig/product-entrypoint-plugin:${command}`;
135
+ }
136
+ function standardProductCliCommandMetadata(descriptor) {
137
+ return {
138
+ id: standardProductCliCommandId(descriptor.command),
139
+ family: descriptor.command,
140
+ description: descriptor.description,
141
+ usage: descriptor.usage,
142
+ projectRequired: false
143
+ };
144
+ }
145
+
146
+ // packages/product-entrypoint-plugin/src/plugin.ts
147
+ function createStandardProductCliCommand(descriptor) {
148
+ return {
149
+ ...standardProductCliCommandMetadata(descriptor),
150
+ run: async (context, args) => {
151
+ const { runRigOmpProductCommand: runRigOmpProductCommand2 } = await Promise.resolve().then(() => (init_product_entrypoint(), exports_product_entrypoint));
152
+ return runRigOmpProductCommand2({
153
+ projectRoot: context.projectRoot,
154
+ command: descriptor.command,
155
+ args
156
+ });
157
+ }
158
+ };
159
+ }
160
+ function createStandardProductEntrypointPlugin() {
161
+ return definePlugin({
162
+ name: "@rig/product-entrypoint-plugin",
163
+ version: "0.1.0",
164
+ contributes: {
165
+ cliCommands: STANDARD_PRODUCT_COMMANDS.map(standardProductCliCommandMetadata)
166
+ }
167
+ }, {
168
+ cliCommands: STANDARD_PRODUCT_COMMANDS.map(createStandardProductCliCommand)
169
+ });
170
+ }
171
+ var standardProductEntrypointPlugin = createStandardProductEntrypointPlugin();
172
+ export {
173
+ standardProductEntrypointPlugin,
174
+ createStandardProductEntrypointPlugin
175
+ };
@@ -0,0 +1,11 @@
1
+ import type { RigProductCommandName } from "./metadata";
2
+ export type RunRigOmpProductCommandInput = {
3
+ readonly projectRoot: string;
4
+ readonly command: RigProductCommandName;
5
+ readonly args: readonly string[];
6
+ };
7
+ export declare function runRigOmpProductCommand(input: RunRigOmpProductCommandInput): Promise<{
8
+ ok: true;
9
+ group: string;
10
+ command: string;
11
+ }>;
@@ -0,0 +1,101 @@
1
+ // @bun
2
+ // packages/product-entrypoint-plugin/src/product-entrypoint.ts
3
+ import { resolve } from "path";
4
+ import { runCli } from "@oh-my-pi/pi-coding-agent/cli";
5
+ import { parseArgs } from "@oh-my-pi/pi-coding-agent/cli/args";
6
+ import { resolveCliArgv } from "@oh-my-pi/pi-coding-agent/cli-commands";
7
+ import { prepareAcpTerminalAuthArgs } from "@oh-my-pi/pi-coding-agent/modes/acp/terminal-auth";
8
+ import { runRootCommand } from "@oh-my-pi/pi-coding-agent/main";
9
+ import { createAgentSession } from "@oh-my-pi/pi-coding-agent/sdk";
10
+ import { applyIdentityEnv, identityFilterFromEnv, reconcileRuns } from "@rig/client";
11
+ import rigExtension from "@rig/rig-extension";
12
+ import { resolveRigOmpConfigOverlayPath } from "@rig/runtime/control-plane/remote-config";
13
+ function withRigDefaultConfig(projectRoot, argv) {
14
+ return ["--config", resolveRigOmpConfigOverlayPath(projectRoot), ...argv];
15
+ }
16
+ function createRigAgentSession(options = {}) {
17
+ return createAgentSession({
18
+ ...options,
19
+ extensions: [(api) => rigExtension(api), ...options.extensions ?? []]
20
+ });
21
+ }
22
+ function productArgv(input) {
23
+ if (input.command === "launch" && input.args.length === 0)
24
+ return [];
25
+ if (input.command === "launch" && input.args[0]?.startsWith("-"))
26
+ return [...input.args];
27
+ return [input.command, ...input.args];
28
+ }
29
+ async function runRigOmpProductCommand(input) {
30
+ const projectRoot = resolve(input.projectRoot);
31
+ const previousProjectRoot = process.env.RIG_PROJECT_ROOT;
32
+ const previousCwd = process.cwd();
33
+ const restorePublicIdentityEnv = applyIdentityEnv(projectRoot);
34
+ process.env.RIG_PROJECT_ROOT = projectRoot;
35
+ process.chdir(projectRoot);
36
+ try {
37
+ const argv = productArgv(input);
38
+ if (argv[0]?.startsWith("__omp_worker_") || argv[0] === "--smoke-test") {
39
+ await runCli(argv);
40
+ return { ok: true, group: "product", command: input.command };
41
+ }
42
+ if (process.stdin.isTTY) {
43
+ const reconcile = await reconcileRuns({
44
+ workspaceRoot: projectRoot,
45
+ identityFilter: identityFilterFromEnv()
46
+ }).catch(() => ({ flipped: [], resumable: [] }));
47
+ globalThis.__RIG_RESUMABLE__ = reconcile.resumable;
48
+ }
49
+ const resolved = resolveCliArgv(argv);
50
+ if ("error" in resolved) {
51
+ process.stderr.write(`error: ${resolved.error}
52
+ `);
53
+ process.exitCode = 1;
54
+ return { ok: true, group: "product", command: input.command };
55
+ }
56
+ const [ompCommand, ...ompCommandArgs] = resolved.argv;
57
+ if (ompCommand === "launch") {
58
+ const args = withRigDefaultConfig(projectRoot, ompCommandArgs);
59
+ await runRootCommand(parseArgs(args), args, { createAgentSession: createRigAgentSession });
60
+ } else if (ompCommand === "acp") {
61
+ const { args: preparedArgs, terminalAuth } = prepareAcpTerminalAuthArgs(ompCommandArgs);
62
+ const args = withRigDefaultConfig(projectRoot, preparedArgs);
63
+ const parsed = parseArgs(args);
64
+ if (!terminalAuth)
65
+ parsed.mode = "acp";
66
+ await runRootCommand(parsed, args, { createAgentSession: createRigAgentSession });
67
+ } else if (ompCommand === "join") {
68
+ const link = ompCommandArgs[0]?.trim();
69
+ if (!link) {
70
+ process.stderr.write(`Usage: rig join <link>
71
+ `);
72
+ process.exitCode = 1;
73
+ return { ok: true, group: "product", command: input.command };
74
+ }
75
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
76
+ process.stderr.write(`rig join requires an interactive terminal
77
+ `);
78
+ process.exitCode = 1;
79
+ return { ok: true, group: "product", command: input.command };
80
+ }
81
+ const args = withRigDefaultConfig(projectRoot, []);
82
+ const parsed = parseArgs(args);
83
+ parsed.join = link;
84
+ await runRootCommand(parsed, args, { createAgentSession: createRigAgentSession });
85
+ } else {
86
+ await runCli(resolved.argv);
87
+ }
88
+ return { ok: true, group: "product", command: input.command };
89
+ } finally {
90
+ restorePublicIdentityEnv();
91
+ process.chdir(previousCwd);
92
+ if (previousProjectRoot === undefined) {
93
+ delete process.env.RIG_PROJECT_ROOT;
94
+ } else {
95
+ process.env.RIG_PROJECT_ROOT = previousProjectRoot;
96
+ }
97
+ }
98
+ }
99
+ export {
100
+ runRigOmpProductCommand
101
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@h-rig/product-entrypoint-plugin",
3
+ "version": "0.0.6-alpha.145",
4
+ "type": "module",
5
+ "description": "Standard Rig product entrypoint plugin boundary for OMP-backed product commands.",
6
+ "license": "UNLICENSED",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/src/plugin.d.ts",
14
+ "import": "./dist/src/plugin.js"
15
+ },
16
+ "./metadata": {
17
+ "types": "./dist/src/metadata.d.ts",
18
+ "import": "./dist/src/metadata.js"
19
+ },
20
+ "./plugin": {
21
+ "types": "./dist/src/plugin.d.ts",
22
+ "import": "./dist/src/plugin.js"
23
+ },
24
+ "./product-entrypoint": {
25
+ "types": "./dist/src/product-entrypoint.d.ts",
26
+ "import": "./dist/src/product-entrypoint.js"
27
+ }
28
+ },
29
+ "engines": {
30
+ "bun": ">=1.3.11"
31
+ },
32
+ "dependencies": {
33
+ "@oh-my-pi/pi-coding-agent": "16.0.4",
34
+ "@rig/client": "npm:@h-rig/client@0.0.6-alpha.145",
35
+ "@rig/core": "npm:@h-rig/core@0.0.6-alpha.145",
36
+ "@rig/rig-extension": "npm:@h-rig/rig-extension@0.0.6-alpha.145",
37
+ "@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.145"
38
+ }
39
+ }