@forge-orbit/orrery-integrations 0.0.0-stage → 0.1.2

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 (100) hide show
  1. package/README.md +127 -2
  2. package/bin/orrery-integrations.mjs +19 -0
  3. package/bundles/antigravity/README.md +124 -0
  4. package/bundles/antigravity/assets/logo.svg +13 -0
  5. package/bundles/antigravity/hooks.json +56 -0
  6. package/bundles/antigravity/mcp_config.json +14 -0
  7. package/bundles/antigravity/plugin.json +21 -0
  8. package/bundles/antigravity/scripts/credentials.mjs +267 -0
  9. package/bundles/antigravity/scripts/hook-runtime.mjs +294 -0
  10. package/bundles/antigravity/scripts/inbox-wait.mjs +237 -0
  11. package/bundles/antigravity/scripts/mcp-stdio.mjs +100 -0
  12. package/bundles/antigravity/scripts/report-hook.mjs +102 -0
  13. package/bundles/claude-code/.claude-plugin/plugin.json +13 -0
  14. package/bundles/claude-code/.mcp.json +9 -0
  15. package/bundles/claude-code/README.md +61 -0
  16. package/bundles/claude-code/hooks/hooks.json +75 -0
  17. package/bundles/claude-code/scripts/credentials.mjs +267 -0
  18. package/bundles/claude-code/scripts/hook-runtime.mjs +294 -0
  19. package/bundles/claude-code/scripts/inbox-wait.mjs +237 -0
  20. package/bundles/claude-code/scripts/mcp-stdio.mjs +100 -0
  21. package/bundles/claude-code/scripts/report-hook.mjs +89 -0
  22. package/bundles/codex/.codex-plugin/plugin.json +15 -0
  23. package/bundles/codex/.mcp.json +19 -0
  24. package/bundles/codex/README.md +65 -0
  25. package/bundles/codex/hooks/hooks.json +75 -0
  26. package/bundles/codex/scripts/credentials.mjs +267 -0
  27. package/bundles/codex/scripts/hook-runtime.mjs +294 -0
  28. package/bundles/codex/scripts/inbox-wait.mjs +237 -0
  29. package/bundles/codex/scripts/mcp-stdio.mjs +100 -0
  30. package/bundles/codex/scripts/report-hook.mjs +112 -0
  31. package/bundles/cursor/.cursor-plugin/plugin.json +16 -0
  32. package/bundles/cursor/README.md +78 -0
  33. package/bundles/cursor/assets/logo.svg +11 -0
  34. package/bundles/cursor/hooks/hooks.json +49 -0
  35. package/bundles/cursor/mcp.json +9 -0
  36. package/bundles/cursor/scripts/credentials.mjs +267 -0
  37. package/bundles/cursor/scripts/hook-runtime.mjs +294 -0
  38. package/bundles/cursor/scripts/inbox-wait.mjs +237 -0
  39. package/bundles/cursor/scripts/mcp-stdio.mjs +100 -0
  40. package/bundles/cursor/scripts/report-hook.mjs +137 -0
  41. package/bundles/devin/.devin-plugin/plugin.json +15 -0
  42. package/bundles/devin/.mcp.json +9 -0
  43. package/bundles/devin/README.md +109 -0
  44. package/bundles/devin/assets/logo.svg +14 -0
  45. package/bundles/devin/hooks.json +72 -0
  46. package/bundles/devin/scripts/credentials.mjs +267 -0
  47. package/bundles/devin/scripts/hook-runtime.mjs +294 -0
  48. package/bundles/devin/scripts/inbox-wait.mjs +237 -0
  49. package/bundles/devin/scripts/mcp-stdio.mjs +100 -0
  50. package/bundles/devin/scripts/report-hook.mjs +88 -0
  51. package/bundles/devin-cloud/.devin-plugin/plugin.json +15 -0
  52. package/bundles/devin-cloud/.mcp.json +10 -0
  53. package/bundles/devin-cloud/README.md +91 -0
  54. package/bundles/devin-cloud/assets/logo.svg +14 -0
  55. package/bundles/devin-cloud/skills/orrery-workflow/SKILL.md +71 -0
  56. package/bundles/gemini-cli/README.md +80 -0
  57. package/bundles/gemini-cli/assets/logo.svg +13 -0
  58. package/bundles/gemini-cli/gemini-extension.json +46 -0
  59. package/bundles/gemini-cli/hooks/hooks.json +93 -0
  60. package/bundles/gemini-cli/scripts/credentials.mjs +267 -0
  61. package/bundles/gemini-cli/scripts/hook-runtime.mjs +294 -0
  62. package/bundles/gemini-cli/scripts/inbox-wait.mjs +237 -0
  63. package/bundles/gemini-cli/scripts/mcp-stdio.mjs +100 -0
  64. package/bundles/gemini-cli/scripts/report-hook.mjs +108 -0
  65. package/bundles/hermes/README.md +136 -0
  66. package/bundles/hermes/__init__.py +107 -0
  67. package/bundles/hermes/credentials.py +400 -0
  68. package/bundles/hermes/hooks.py +455 -0
  69. package/bundles/hermes/plugin.yaml +16 -0
  70. package/bundles/hermes/pyproject.toml +23 -0
  71. package/bundles/hermes/setup_cli.py +261 -0
  72. package/bundles/hermes/version.py +3 -0
  73. package/bundles/hermes/wait_tool.py +352 -0
  74. package/bundles/opencode/README.md +202 -0
  75. package/bundles/opencode/package.json +34 -0
  76. package/bundles/opencode/src/index.d.ts +201 -0
  77. package/bundles/opencode/src/index.mjs +666 -0
  78. package/bundles/opencode/src/shared/credentials.mjs +267 -0
  79. package/bundles/opencode/src/shared/hook-runtime.mjs +294 -0
  80. package/bundles/opencode/src/shared/inbox-wait.mjs +237 -0
  81. package/bundles/pi/README.md +154 -0
  82. package/bundles/pi/package.json +26 -0
  83. package/bundles/pi/src/index.d.ts +179 -0
  84. package/bundles/pi/src/index.mjs +419 -0
  85. package/bundles/pi/src/shared/credentials.mjs +267 -0
  86. package/bundles/pi/src/shared/hook-runtime.mjs +294 -0
  87. package/bundles/pi/src/shared/inbox-wait.mjs +237 -0
  88. package/package.json +34 -4
  89. package/src/args.mjs +266 -0
  90. package/src/cli.mjs +392 -0
  91. package/src/credential-flags.mjs +48 -0
  92. package/src/credentials-store.mjs +255 -0
  93. package/src/harnesses.mjs +852 -0
  94. package/src/ids.mjs +13 -0
  95. package/src/shared/credentials.mjs +267 -0
  96. package/src/shared/hook-runtime.mjs +294 -0
  97. package/src/shared/inbox-wait.mjs +237 -0
  98. package/src/tui.mjs +563 -0
  99. package/src/verify-mcp.mjs +127 -0
  100. package/src/version.mjs +15 -0
package/README.md CHANGED
@@ -1,3 +1,128 @@
1
- # Temporary Holding Version
1
+ # `@forge-orbit/orrery-integrations`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Interactive installer for Orrery Integrations. It detects installed Harnesses,
4
+ installs the selected Orrery Integration through each Harness's native CLI, writes
5
+ an ADR 0001 Credential Source, and verifies `/mcp` connectivity.
6
+
7
+ The installer is the only package in this repository with a runtime dependency
8
+ (`@clack/prompts`). Every installed Integration remains zero-dependency on
9
+ Node 22+, and root `pnpm test` still runs with no `node_modules`.
10
+
11
+ ## Quick start
12
+
13
+ ```sh
14
+ npx @forge-orbit/orrery-integrations
15
+ # or:
16
+ npx --package @forge-orbit/orrery-integrations orrery-install
17
+ ```
18
+
19
+ The TUI pre-selects every Harness it detects on `PATH`, then lets you choose
20
+ Harnesses, reuse or enter `ORRERY_URL` plus a masked API key, and runs each
21
+ native install. It prints per-Harness follow-up steps and warns when ambient
22
+ `ORRERY_*` variables override `config.json`.
23
+
24
+ ## Non-interactive
25
+
26
+ ```sh
27
+ # Every detected Harness, key from an environment variable:
28
+ npx @forge-orbit/orrery-integrations \
29
+ --all-detected \
30
+ --url https://orrery.example.com \
31
+ --key-env ORRERY_API_KEY \
32
+ --yes
33
+
34
+ # Explicit Harnesses with a key on stdin:
35
+ printf '%s\n' "$ORRERY_API_KEY" | npx @forge-orbit/orrery-integrations \
36
+ --harness claude-code,codex \
37
+ --url https://orrery.example.com \
38
+ --key-stdin \
39
+ --yes
40
+
41
+ # Inspect without changing anything:
42
+ npx @forge-orbit/orrery-integrations --list
43
+ npx @forge-orbit/orrery-integrations --list --json
44
+ npx @forge-orbit/orrery-integrations --harness pi --dry-run
45
+ ```
46
+
47
+ Raw `--key <secret>` is intentionally unsupported: a secret on argv leaks into
48
+ `ps` output and shell history. Use `--key-stdin`, `--key-env`, or `--key-file`.
49
+
50
+ ## Flags
51
+
52
+ | Flag | Meaning |
53
+ | --- | --- |
54
+ | `--harness <list>` | Comma-separated or repeatable IDs: `claude-code`, `codex`, `cursor`, `devin`, `devin-cloud`, `gemini-cli`, `antigravity`, `pi`, `opencode`, `hermes`. |
55
+ | `--all-detected` | Select every Harness detected on `PATH`. |
56
+ | `--url <url>` | Orrery base URL. Reverse-proxy subpaths are preserved. |
57
+ | `--key-file <path>` | Reuse an existing key file; the installer verifies readability but never prints its contents. |
58
+ | `--key-env <VAR>` | Read the key from an environment variable, then write a `0600` key file. |
59
+ | `--key-stdin` | Read the key from stdin, then write a `0600` key file. |
60
+ | `--config-file <path>` | Override the ADR 0001 `config.json` path. |
61
+ | `--source <bundled\|remote>` | Use a staged/checked-out bundle or each Harness's native remote package. |
62
+ | `--verify` / `--no-verify` | Verify `/mcp` after setup (default: verify). |
63
+ | `--dry-run` | Print planned file writes and install commands; mutate nothing. |
64
+ | `--yes` | Skip the interactive confirmation. |
65
+ | `--list` | Show detected Harnesses and credential status. |
66
+ | `--json` | Emit secret-free machine-readable output; requires `--list`, `--harness`, or `--all-detected`. |
67
+ | `--help`, `--version` | Usage or installed version. |
68
+
69
+ ## Credentials
70
+
71
+ The installer writes the standard local Credential Source:
72
+
73
+ ```text
74
+ ~/.config/orrery/config.json # { "version": 1, "url", "apiKeyFile" }
75
+ ~/.config/orrery/agent.key # 0600, or %APPDATA%\orrery on Windows
76
+ ```
77
+
78
+ `ORRERY_CONFIG_FILE`, `$XDG_CONFIG_HOME`, and `%APPDATA%\orrery` are honoured
79
+ exactly as ADR 0001 specifies. Raw keys are never written inside `config.json`
80
+ and never appear in stdout, stderr, or `--json` output.
81
+
82
+ If any `ORRERY_URL`, `ORRERY_API_KEY`, `ORRERY_AGENT_KEY`,
83
+ `ORRERY_API_KEY_FILE`, or `ORRERY_AGENT_KEY_FILE` variable is non-empty, the
84
+ installer warns that the environment Credential Source overrides `config.json`.
85
+ It never combines the two sources.
86
+
87
+ ## Integration installs
88
+
89
+ | Harness | Native install |
90
+ | --- | --- |
91
+ | Claude Code | `claude plugin marketplace add forge-orbit/orrery-integrations` then `claude plugin install orrery@forge-orbit` |
92
+ | Codex CLI | `codex plugin marketplace add forge-orbit/orrery-integrations` then `codex plugin add orrery@forge-orbit` |
93
+ | Cursor | Manual Customize/Marketplace install of `forge-orbit/orrery-integrations` → `orrery@forge-orbit` |
94
+ | Devin | `devin plugins install --local <bundle>` or the repository subdirectory |
95
+ | Devin Cloud | Repository subdirectory or the Customize Connect sheet for `${ORRERY_URL}/mcp` |
96
+ | Gemini CLI | `gemini extensions install <bundle> --consent --skip-settings` |
97
+ | Antigravity | `agy plugin install <bundle>` |
98
+ | Pi | `pi install <bundle>` or `npm:@forge-orbit/pi-orrery` |
99
+ | OpenCode V2 | Add `<bundle>` to the `plugins` array in `opencode.json`, or use `opencode plugin add @forge-orbit/opencode-orrery` |
100
+ | Hermes | `hermes plugins install <bundle> --enable` |
101
+
102
+ Cursor has no supported non-interactive plugin install, so the installer
103
+ surfaces the exact Marketplace steps instead of editing Cursor internals.
104
+ OpenCode's local directory install uses the documented `opencode.json`
105
+ `plugins` entry rather than a CLI form it does not support.
106
+
107
+ ## How it fits the monorepo
108
+
109
+ - `src/shared/{credentials,inbox-wait,hook-runtime}.mjs` are copied verbatim
110
+ from the repository's `shared/` core by `pnpm sync:shared`. The installer
111
+ reuses the canonical resolver, `/mcp` caller, and redaction helper.
112
+ - `@clack/prompts` is loaded lazily only for a real interactive terminal. In a
113
+ zero-install checkout or non-TTY run, a `node:readline/promises` fallback is
114
+ used.
115
+ - `npm pack` / `npm publish` run `prepack`, which stages each Integration
116
+ directly into `bundles/<id>/` with `node ../../scripts/package-release.mjs
117
+ --out ./bundles --bundles-only`. `bundles/` is gitignored.
118
+ - Root `pnpm test` includes `packages/*/src/**/*.test.mjs` and needs no install.
119
+
120
+ ## Development
121
+
122
+ ```sh
123
+ pnpm test
124
+ pnpm package:installer # stage packages/installer/bundles/
125
+ npm pack --dry-run # from packages/installer after staging
126
+ ```
127
+
128
+ MIT — see the [repository license](https://github.com/forge-orbit/orrery-integrations/blob/main/LICENSE).
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ // Thin executable entrypoint for `npx @forge-orbit/orrery-integrations`.
3
+ import { runCli } from "../src/cli.mjs";
4
+ import { redact } from "../src/shared/hook-runtime.mjs";
5
+
6
+ // A piped consumer such as `... --list | head` may close stdout early.
7
+ for (const stream of [process.stdout, process.stderr]) {
8
+ stream.on("error", (error) => {
9
+ if (error?.code === "EPIPE") process.exit(0);
10
+ throw error;
11
+ });
12
+ }
13
+
14
+ try {
15
+ process.exitCode = await runCli(process.argv.slice(2));
16
+ } catch (error) {
17
+ process.stderr.write(`orrery-integrations: ${redact(error?.message ?? "unexpected failure")}\n`);
18
+ process.exitCode = 1;
19
+ }
@@ -0,0 +1,124 @@
1
+ # Orrery Plugin for Google Antigravity
2
+
3
+ Bundles Orrery run-lifecycle reporting hooks and the static `/mcp` server configuration into an
4
+ installable Antigravity plugin. One install serves the **Antigravity App**, the **Antigravity CLI**
5
+ (`agy`), and the **Antigravity IDE**: a user-scope install lands in
6
+ `~/.gemini/config/plugins/orrery/` and is synced across all three surfaces.
7
+
8
+ ## Install
9
+
10
+ Requires Node.js 22 or later.
11
+
12
+ 1. Configure a **Credential Source**. Either export the variables in the environment Antigravity
13
+ inherits:
14
+
15
+ ```sh
16
+ export ORRERY_URL="https://orrery.example.com"
17
+ export ORRERY_API_KEY="orr_ak_..."
18
+ # or: export ORRERY_API_KEY_FILE="$HOME/.config/orrery/agent.key"
19
+ ```
20
+
21
+ …or, with no `ORRERY_*` credential variable set, create a local Orrery config file at
22
+ `$XDG_CONFIG_HOME/orrery/config.json` (or `~/.config/orrery/config.json`, or
23
+ `%APPDATA%\orrery\config.json` on Windows; override with `ORRERY_CONFIG_FILE`):
24
+
25
+ ```json
26
+ {
27
+ "version": 1,
28
+ "url": "https://orrery.example.com",
29
+ "apiKeyFile": "agent.key"
30
+ }
31
+ ```
32
+
33
+ A relative `apiKeyFile` resolves against the config file's directory and a leading `~/`
34
+ expands to your home directory. Raw inline keys in `config.json` are rejected: keep the
35
+ key in a separate restricted file.
36
+
37
+ The two sources are never mixed. Setting any `ORRERY_*` credential variable disables the
38
+ config file completely, so an environment URL can never borrow a key from disk.
39
+ Unconfigured hooks are silent exit-`0` no-ops; the MCP transport returns an actionable error.
40
+
41
+ The `config.json` Credential Source is the recommended setup for the Antigravity App and IDE,
42
+ which are GUI applications and frequently launch without inheriting your shell profile.
43
+
44
+ 2. Validate and install the plugin:
45
+
46
+ ```sh
47
+ agy plugin validate --strict ./harnesses/antigravity
48
+ agy plugin install ./harnesses/antigravity
49
+ agy plugin list
50
+ ```
51
+
52
+ Antigravity also installs directly from a GitHub repository root, so a standalone checkout of
53
+ this plugin directory works too. This monorepo places the plugin in a subdirectory, so use the
54
+ local path above until it is published to the Antigravity Partner Marketplace
55
+ (`agy plugin install orrery@antigravity-plugins-partners`).
56
+
57
+ 3. Review the bundled hooks under **Customizations > Installed** in the App, or `/plugin` in the CLI.
58
+
59
+ ## What's Included
60
+
61
+ - **Lifecycle hooks** (`hooks.json` -> `scripts/report-hook.mjs`), declared in the named hook group
62
+ `orrery` at the plugin root. Antigravity runs hook commands with `cwd` set to the plugin root, so
63
+ the commands use relative paths (`node ./scripts/report-hook.mjs`).
64
+
65
+ | Antigravity event | Orrery event |
66
+ | --- | --- |
67
+ | `SessionStart` | `run_started` |
68
+ | `PreInvocation` | `run_started` |
69
+ | `PostInvocation` | `run_heartbeat` |
70
+ | `PreToolUse` | `run_heartbeat` |
71
+ | `PostToolUse` | `run_heartbeat` |
72
+ | `Stop` (`fullyIdle: true`) | `run_ended` |
73
+ | `Stop` (`fullyIdle` absent or `false`) | `run_heartbeat` |
74
+
75
+ Antigravity has no `SessionEnd` event, so a fully idle `Stop` is the end-of-run signal. Because
76
+ Orrery never revives an explicitly ended run on a heartbeat, `PreInvocation` maps to `run_started`
77
+ so turn 2 and later revive the same run cleanly.
78
+
79
+ - **Orrery MCP** (`mcp_config.json`) runs the bundled Node.js transport and connects to the
80
+ configured Orrery instance. `orrery_wait_for_input` is marked `eager`, so the agent can call it
81
+ directly instead of paying an extra lazy schema-discovery turn.
82
+ - **Inbox replies** use `orrery_wait_for_input` to wait inside the running harness after
83
+ `ask_for_input`. The tool checks for the answer and renews the matching lease when needed.
84
+ - **Shared runtime** (`scripts/credentials.mjs`, `scripts/mcp-stdio.mjs`,
85
+ `scripts/hook-runtime.mjs`): synced verbatim from the repository's `shared/` directory and
86
+ verified byte-for-byte by `npm test`.
87
+
88
+ ## Hook stdout contract
89
+
90
+ Antigravity hooks are synchronous and must exit `0` with a JSON object on stdout. The stdout mode is
91
+ declared per event in `hooks.json` and is emitted even when stdin is empty, truncated, or malformed,
92
+ and even when Orrery is unreachable or unconfigured:
93
+
94
+ | Event | Flag | stdout |
95
+ | --- | --- | --- |
96
+ | `PreToolUse` | `--stdout=decision-allow` | `{"decision":"allow"}` |
97
+ | `SessionStart`, `PreInvocation`, `PostInvocation`, `PostToolUse`, `Stop` | `--stdout=empty-json` | `{}` |
98
+
99
+ Each handler declares `timeout: 5` seconds and the shared runtime aborts the POST after 2000 ms, so
100
+ Orrery reporting never stalls the agent loop.
101
+
102
+ ## Privacy
103
+
104
+ Only an allowlist of metadata is read: `conversationId`, `modelName`, `hookEventName`, and
105
+ `fullyIdle`. Antigravity's `lastUserInput`, `transcriptPath`, `artifactDirectoryPath`,
106
+ `toolCall.args`, and `error` are never read, logged, or transmitted.
107
+
108
+ ## Remote Agents
109
+
110
+ Local `stdio` plugins do not run inside `agy --remote-agent`. Remote Agents require a
111
+ Marketplace-published hosted HTTPS MCP server authenticated with OAuth or user-prompted
112
+ `variables`. Use the local App, CLI, or IDE surfaces for this Bridge Integration.
113
+
114
+ ## Environment Variables
115
+
116
+ | Variable | Description |
117
+ | --- | --- |
118
+ | `ORRERY_URL` | Base URL of your Orrery server (e.g. `https://orrery.example.com`). No implicit default. |
119
+ | `ORRERY_API_KEY` | Agent API key secret (also accepts `ORRERY_AGENT_KEY`). |
120
+ | `ORRERY_API_KEY_FILE` | Path to a local file containing the API key (also accepts `ORRERY_AGENT_KEY_FILE`). |
121
+ | `ORRERY_CONFIG_FILE` | Path to the local Orrery config file; used only when no credential variable above is set. |
122
+ | `ORRERY_HOOK_TIMEOUT_MS` | Optional POST timeout in ms (default `2000`). |
123
+ | `ORRERY_HOOK_DEBUG` | Set to any non-off value to log redacted failures to stderr. |
124
+ | `ORRERY_HOOK_TRACE` | Optional local file path for redacted JSONL hook trace lines. |
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128" role="img" aria-labelledby="orrery-logo-title orrery-logo-desc">
2
+ <title id="orrery-logo-title">Orrery</title>
3
+ <desc id="orrery-logo-desc">Three concentric orbits around a central sun, with one planet on each orbit.</desc>
4
+ <g fill="none" stroke="#6366F1" stroke-width="4">
5
+ <circle cx="64" cy="64" r="14"/>
6
+ <circle cx="64" cy="64" r="30"/>
7
+ <circle cx="64" cy="64" r="46"/>
8
+ </g>
9
+ <circle cx="64" cy="64" r="7" fill="#F59E0B"/>
10
+ <circle cx="54.1" cy="54.1" r="4" fill="#14B8A6"/>
11
+ <circle cx="94" cy="64" r="5" fill="#0EA5E9"/>
12
+ <circle cx="96.5" cy="96.5" r="6" fill="#A855F7"/>
13
+ </svg>
@@ -0,0 +1,56 @@
1
+ {
2
+ "orrery": {
3
+ "SessionStart": [
4
+ {
5
+ "type": "command",
6
+ "command": "node ./scripts/report-hook.mjs --stdout=empty-json",
7
+ "timeout": 5
8
+ }
9
+ ],
10
+ "PreInvocation": [
11
+ {
12
+ "type": "command",
13
+ "command": "node ./scripts/report-hook.mjs --stdout=empty-json",
14
+ "timeout": 5
15
+ }
16
+ ],
17
+ "PostInvocation": [
18
+ {
19
+ "type": "command",
20
+ "command": "node ./scripts/report-hook.mjs --stdout=empty-json",
21
+ "timeout": 5
22
+ }
23
+ ],
24
+ "PreToolUse": [
25
+ {
26
+ "matcher": "*",
27
+ "hooks": [
28
+ {
29
+ "type": "command",
30
+ "command": "node ./scripts/report-hook.mjs --stdout=decision-allow",
31
+ "timeout": 5
32
+ }
33
+ ]
34
+ }
35
+ ],
36
+ "PostToolUse": [
37
+ {
38
+ "matcher": "*",
39
+ "hooks": [
40
+ {
41
+ "type": "command",
42
+ "command": "node ./scripts/report-hook.mjs --stdout=empty-json",
43
+ "timeout": 5
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "Stop": [
49
+ {
50
+ "type": "command",
51
+ "command": "node ./scripts/report-hook.mjs --stdout=empty-json",
52
+ "timeout": 5
53
+ }
54
+ ]
55
+ }
56
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "orrery": {
4
+ "command": "node",
5
+ "args": ["${PLUGIN_ROOT}/scripts/mcp-stdio.mjs"],
6
+ "timeoutSeconds": 180,
7
+ "tools": {
8
+ "orrery_wait_for_input": {
9
+ "eager": true
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
+ "name": "orrery",
4
+ "displayName": "Orrery",
5
+ "version": "0.1.2",
6
+ "description": "Connect Google Antigravity to Orrery: automatic run lifecycle reporting through hooks, plus Orrery's static /mcp project tools.",
7
+ "logo": "assets/logo.svg",
8
+ "suggestedPrompts": [
9
+ "List my assigned Orrery issues and start work on the next one",
10
+ "Report this Antigravity session's run lifecycle to Orrery",
11
+ "Wait for my reply in the Orrery inbox before you continue"
12
+ ],
13
+ "author": {
14
+ "name": "Forge Orbit",
15
+ "url": "https://github.com/forge-orbit"
16
+ },
17
+ "homepage": "https://github.com/forge-orbit/orrery",
18
+ "repository": "https://github.com/forge-orbit/orrery-integrations",
19
+ "license": "MIT",
20
+ "keywords": ["orrery", "mcp", "project-management", "runs", "hooks"]
21
+ }
@@ -0,0 +1,267 @@
1
+ // Canonical Credential Source resolution for every Orrery Bridge Integration.
2
+ //
3
+ // Exactly one origin supplies connection details (ADR 0001): the process
4
+ // environment, or a local Orrery config file that references a separate secret
5
+ // key file. Values from the two origins are never combined, and there is no
6
+ // implicit `http://localhost:8080` default, so an API key is never transmitted
7
+ // to an unintended target.
8
+ //
9
+ // Zero dependencies on Node 22+. Synced verbatim into every Bridge
10
+ // Integration's `scripts/` directory by `node scripts/sync-shared.mjs`.
11
+ import { readFile as readFilePromise } from "node:fs/promises";
12
+ import { posix, win32 } from "node:path";
13
+
14
+ /** Environment variables whose presence selects the env Credential Source. */
15
+ export const CREDENTIAL_ENV_VARS = Object.freeze([
16
+ "ORRERY_URL",
17
+ "ORRERY_API_KEY",
18
+ "ORRERY_AGENT_KEY",
19
+ "ORRERY_API_KEY_FILE",
20
+ "ORRERY_AGENT_KEY_FILE",
21
+ ]);
22
+
23
+ /** Config-file fields that would place a raw secret inside `config.json`. */
24
+ const INLINE_KEY_FIELDS = Object.freeze([
25
+ "apiKey",
26
+ "agentKey",
27
+ "key",
28
+ "token",
29
+ "secret",
30
+ "password",
31
+ ]);
32
+
33
+ const TRUTHY_OFF = new Set(["0", "false", "off", "no"]);
34
+
35
+ export class CredentialError extends Error {
36
+ constructor(code, message) {
37
+ super(message);
38
+ this.name = "CredentialError";
39
+ this.code = code;
40
+ }
41
+ }
42
+
43
+ /** A non-blank trimmed string, or null. */
44
+ export function trimmed(value) {
45
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : null;
46
+ }
47
+
48
+ /** True when an opt-in diagnostic switch such as ORRERY_HOOK_DEBUG is enabled. */
49
+ export function flagEnabled(value) {
50
+ const raw = trimmed(value);
51
+ return raw !== null && !TRUTHY_OFF.has(raw.toLowerCase());
52
+ }
53
+
54
+ function paths(platform) {
55
+ return platform === "win32" ? win32 : posix;
56
+ }
57
+
58
+ export function homeDirectory(env, platform) {
59
+ if (platform === "win32") return trimmed(env.USERPROFILE) ?? trimmed(env.HOME);
60
+ return trimmed(env.HOME);
61
+ }
62
+
63
+ /** Expand a leading `~/` (or `~\` on Windows) to the platform home directory. */
64
+ export function expandTilde(value, env, platform) {
65
+ const raw = trimmed(value);
66
+ if (raw === null) return null;
67
+ const home = homeDirectory(env, platform);
68
+ if (home === null) return raw;
69
+ if (raw === "~") return home;
70
+ const prefixed = platform === "win32" ? /^[~][\\/]/ : /^[~]\//;
71
+ return prefixed.test(raw) ? paths(platform).join(home, raw.slice(2)) : raw;
72
+ }
73
+
74
+ /**
75
+ * The Orrery config file location: `ORRERY_CONFIG_FILE`, then
76
+ * `$XDG_CONFIG_HOME/orrery/config.json`, then `%APPDATA%\orrery\config.json`
77
+ * on Windows or `~/.config/orrery/config.json` on POSIX.
78
+ */
79
+ export function configFilePath(env, platform) {
80
+ const explicit = expandTilde(env.ORRERY_CONFIG_FILE, env, platform);
81
+ if (explicit !== null) return explicit;
82
+ const path = paths(platform);
83
+ const xdg = expandTilde(env.XDG_CONFIG_HOME, env, platform);
84
+ if (xdg !== null) return path.join(xdg, "orrery", "config.json");
85
+ if (platform === "win32") {
86
+ const appData = trimmed(env.APPDATA);
87
+ return appData === null ? null : path.join(appData, "orrery", "config.json");
88
+ }
89
+ const home = homeDirectory(env, platform);
90
+ return home === null ? null : path.join(home, ".config", "orrery", "config.json");
91
+ }
92
+
93
+ /** A strict http(s) base URL with no userinfo, query, or fragment; else null. */
94
+ export function parseBaseUrl(value) {
95
+ const raw = trimmed(value);
96
+ if (raw === null || !URL.canParse(raw)) return null;
97
+ const url = new URL(raw);
98
+ if (url.protocol !== "http:" && url.protocol !== "https:") return null;
99
+ if (url.username !== "" || url.password !== "" || url.search !== "" || url.hash !== "") return null;
100
+ return url;
101
+ }
102
+
103
+ /** Append `suffix` to a base URL while preserving a reverse-proxy subpath. */
104
+ export function withPath(base, suffix) {
105
+ const url = new URL(base instanceof URL ? base.href : base);
106
+ url.pathname = url.pathname.replace(/\/+$/, "") + suffix;
107
+ return url;
108
+ }
109
+
110
+ /** Resolve `apiKeyFile` against the config file's directory, never the cwd. */
111
+ export function resolveKeyFile(value, configPath, env, platform) {
112
+ const expanded = expandTilde(value, env, platform);
113
+ if (expanded === null) return null;
114
+ const path = paths(platform);
115
+ return path.isAbsolute(expanded) ? expanded : path.resolve(path.dirname(configPath), expanded);
116
+ }
117
+
118
+ export function parseConfig(text, configPath, env, platform) {
119
+ let parsed;
120
+ try {
121
+ parsed = JSON.parse(text);
122
+ } catch {
123
+ throw new CredentialError("config-invalid", `${configPath} is not valid JSON.`);
124
+ }
125
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
126
+ throw new CredentialError("config-invalid", `${configPath} must contain a JSON object.`);
127
+ }
128
+
129
+ const inline = INLINE_KEY_FIELDS.find(
130
+ (field) => Object.hasOwn(parsed, field) && parsed[field] !== null && parsed[field] !== undefined,
131
+ );
132
+ if (inline !== undefined) {
133
+ throw new CredentialError(
134
+ "config-inline-key",
135
+ `${configPath} must not carry an inline "${inline}". Store the key in a restricted file and reference it with "apiKeyFile".`,
136
+ );
137
+ }
138
+ if (parsed.version !== 1) {
139
+ throw new CredentialError("config-invalid", `${configPath} must declare "version": 1.`);
140
+ }
141
+ const url = parseBaseUrl(parsed.url);
142
+ if (url === null) {
143
+ throw new CredentialError(
144
+ "config-invalid",
145
+ `${configPath} must declare an http(s) "url" with no userinfo, query, or fragment.`,
146
+ );
147
+ }
148
+ const keyFile = resolveKeyFile(parsed.apiKeyFile, configPath, env, platform);
149
+ if (keyFile === null) {
150
+ throw new CredentialError("config-invalid", `${configPath} must declare "apiKeyFile".`);
151
+ }
152
+ return { url, keyFile };
153
+ }
154
+
155
+ /** True when any supported credential variable is non-empty after trimming. */
156
+ export function usesEnvCredentialSource(env) {
157
+ return CREDENTIAL_ENV_VARS.some((name) => trimmed(env[name]) !== null);
158
+ }
159
+
160
+ /** The env-only key file path, or null when neither variable names one. */
161
+ function envKeyFilePath(env, platform) {
162
+ return expandTilde(
163
+ trimmed(env.ORRERY_API_KEY_FILE) ?? trimmed(env.ORRERY_AGENT_KEY_FILE),
164
+ env,
165
+ platform,
166
+ );
167
+ }
168
+
169
+ /**
170
+ * The env-only key. Never falls back to the config file.
171
+ *
172
+ * With `strict`, a configured key file that cannot be read or is empty raises
173
+ * `key-unreadable`, matching how a `config.json` key file is treated. Without
174
+ * it, every failure is null, for callers that only need a best-effort answer.
175
+ */
176
+ async function loadEnvKey(env, platform, readFile, { strict }) {
177
+ const inline = trimmed(env.ORRERY_API_KEY) ?? trimmed(env.ORRERY_AGENT_KEY);
178
+ if (inline !== null) return inline;
179
+ const file = envKeyFilePath(env, platform);
180
+ if (file === null) return null;
181
+ let text;
182
+ try {
183
+ text = await readFile(file, "utf8");
184
+ } catch {
185
+ if (strict) throw new CredentialError("key-unreadable", `Could not read the Orrery key file ${file}.`);
186
+ return null;
187
+ }
188
+ const key = trimmed(text);
189
+ if (key === null && strict) {
190
+ throw new CredentialError("key-unreadable", `The Orrery key file ${file} is empty.`);
191
+ }
192
+ return key;
193
+ }
194
+
195
+ /** The env-only key, or null. Never falls back to the config file. */
196
+ export async function readEnvKey(env, platform = process.platform, readFile = readFilePromise) {
197
+ return loadEnvKey(env, platform, readFile, { strict: false });
198
+ }
199
+
200
+ function unconfiguredMessage(configPath) {
201
+ const where = configPath === null
202
+ ? "the local Orrery config file"
203
+ : `the local Orrery config file ${configPath}`;
204
+ return (
205
+ "Orrery is not configured. Set ORRERY_URL and ORRERY_API_KEY (or ORRERY_API_KEY_FILE) " +
206
+ `in the environment, or create ${where} with { "version": 1, "url", "apiKeyFile" }.`
207
+ );
208
+ }
209
+
210
+ /**
211
+ * Resolve `{ source, url, key }` from exactly one Credential Source.
212
+ * Throws `CredentialError` for every unconfigured, incomplete, or invalid case.
213
+ */
214
+ export async function resolveCredentials(options = {}) {
215
+ const env = options.env ?? process.env;
216
+ const platform = options.platform ?? process.platform;
217
+ const readFile = options.readFile ?? readFilePromise;
218
+ const configPath = configFilePath(env, platform);
219
+
220
+ if (usesEnvCredentialSource(env)) {
221
+ const rawUrl = trimmed(env.ORRERY_URL);
222
+ const url = parseBaseUrl(rawUrl);
223
+ if (rawUrl !== null && url === null) {
224
+ throw new CredentialError("env-invalid-url", "ORRERY_URL must be an HTTP or HTTPS base URL.");
225
+ }
226
+ const key = await loadEnvKey(env, platform, readFile, { strict: true });
227
+ if (url === null || key === null) {
228
+ const missing = url === null && key === null
229
+ ? "Set ORRERY_URL and ORRERY_API_KEY (or ORRERY_API_KEY_FILE) for Orrery."
230
+ : url === null
231
+ ? "Set ORRERY_URL for Orrery."
232
+ : "Set ORRERY_API_KEY or ORRERY_API_KEY_FILE for Orrery.";
233
+ throw new CredentialError(
234
+ "env-incomplete",
235
+ `${missing} The environment Credential Source is never combined with ${configPath ?? "the local Orrery config file"}; ` +
236
+ "unset every ORRERY_* credential variable to load credentials from disk instead.",
237
+ );
238
+ }
239
+ return { source: "env", url, key };
240
+ }
241
+
242
+ if (configPath === null) throw new CredentialError("unconfigured", unconfiguredMessage(configPath));
243
+ let text;
244
+ try {
245
+ text = await readFile(configPath, "utf8");
246
+ } catch {
247
+ throw new CredentialError("unconfigured", unconfiguredMessage(configPath));
248
+ }
249
+
250
+ const config = parseConfig(text, configPath, env, platform);
251
+ let key;
252
+ try {
253
+ key = trimmed(await readFile(config.keyFile, "utf8"));
254
+ } catch {
255
+ throw new CredentialError(
256
+ "key-unreadable",
257
+ `Could not read the Orrery key file ${config.keyFile} referenced by ${configPath}.`,
258
+ );
259
+ }
260
+ if (key === null) {
261
+ throw new CredentialError(
262
+ "key-unreadable",
263
+ `The Orrery key file ${config.keyFile} referenced by ${configPath} is empty.`,
264
+ );
265
+ }
266
+ return { source: "config", url: config.url, key, configPath, keyFile: config.keyFile };
267
+ }