Skip to content

consolidate: collapse onenv-api into the onenv CLI (0.7.0) - #1

Closed
doublej wants to merge 3 commits into
mainfrom
worktree-consolidate
Closed

consolidate: collapse onenv-api into the onenv CLI (0.7.0)#1
doublej wants to merge 3 commits into
mainfrom
worktree-consolidate

Conversation

@doublej

@doublej doublej commented May 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Delete the onenv-api Express server outright — a consumer audit (no running processes, no launchctl/LaunchAgent entries, no references across ~/Documents/development or ~/.config) turned up zero callers.
  • Port the AppleScript permission dialog from the api into the CLI as an opt-in ONENV_CONFIRM_MUTATIONS=1 guard for set / edit / unset / import. Off by default; deny / timeout raises PERMISSION_DENIED; non-macOS errors with PERMISSION_UNSUPPORTED.
  • Rewrite the primer to drop the <api> section and add a <permission> section (XML, Markdown, JSON renderers).
  • Strip api references from README.md, INSTALL.md, CLAUDE.md, AGENTS.md, docs/CLAUDE-onenv.md, the docs landing page, the docs guides, the CI workflow, and the project .atlas.
  • Bump to 0.7.0 with a CHANGELOG entry.

Net: +245 / −2309 across 42 files. just check clean, 48/48 tests pass (was 45 + 3 new for the permission gate).

Test plan

  • just check — biome, tsc --noEmit, vitest (48 passing), loc-check
  • bun build --target node install.ts — compiles
  • node dist/cli.js --version0.7.0
  • onenv prime in JSON / XML / Markdown formats — no onenv-api, x-onenv-token, /v1/, AGENT_API_TOKEN, or :4317
  • Manual smoke (recommended before merge):
    • ONENV_CONFIRM_MUTATIONS=1 onenv set _test_ TMP_KEY — Allow → key set; Deny → PERMISSION_DENIED
    • onenv unset _test_ TMP_KEY cleanup
    • bun run install.ts — confirm the wizard no longer prompts for AGENT_API_TOKEN and that the linked onenv binary still works

Summary by CodeRabbit

  • New Features

    • Added optional macOS confirmation dialog for write operations, gated by ONENV_CONFIRM_MUTATIONS environment variable
    • Simplified architecture: single unified CLI replacing the previous separate API component
  • Removals

    • Removed HTTP API component; all functionality now available through the single CLI
  • Documentation

    • Updated installation, configuration, and deployment guides to reflect the simplified single-CLI architecture
    • Clarified service account setup and token caching behavior

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@doublej has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 10 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 21613fd3-9b9a-4e35-9023-5def64a5d2e8

📥 Commits

Reviewing files that changed from the base of the PR and between 5243999 and ba88c10.

⛔ Files ignored due to path filters (1)
  • onenv-api/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (43)
  • .atlas
  • .github/workflows/ci.yml
  • AGENTS.md
  • INSTALL.md
  • README.md
  • docs/CLAUDE-onenv.md
  • docs/examples/onenv-api.plist
  • docs/guides/agent-api.md
  • docs/guides/ci-and-deploys.md
  • docs/guides/running-commands.md
  • docs/guides/service-account-setup.md
  • docs/src/routes/+page.svelte
  • install.ts
  • onenv-api/.env.example
  • onenv-api/README.md
  • onenv-api/biome.json
  • onenv-api/package.json
  • onenv-api/src/index.ts
  • onenv-api/src/lib/config.test.ts
  • onenv-api/src/lib/config.ts
  • onenv-api/src/lib/logging.ts
  • onenv-api/src/lib/manager-service.ts
  • onenv-api/src/lib/onenv-client.test.ts
  • onenv-api/src/lib/onenv-client.ts
  • onenv-api/src/lib/op-token.ts
  • onenv-api/src/lib/permission.ts
  • onenv-api/src/lib/rate-limit.ts
  • onenv-api/src/lib/state-store.ts
  • onenv-api/src/server.ts
  • onenv-api/tsconfig.json
  • onenv-manager/CHANGELOG.md
  • onenv-manager/package.json
  • onenv-manager/src/commands/edit.ts
  • onenv-manager/src/commands/import.ts
  • onenv-manager/src/commands/prime-data-api.ts
  • onenv-manager/src/commands/prime-data.ts
  • onenv-manager/src/commands/prime-md.ts
  • onenv-manager/src/commands/prime-xml.ts
  • onenv-manager/src/commands/prime.ts
  • onenv-manager/src/commands/set.ts
  • onenv-manager/src/commands/unset.ts
  • onenv-manager/src/lib/permission.test.ts
  • onenv-manager/src/lib/permission.ts
📝 Walkthrough

Walkthrough

The PR consolidates onenv from a two-component system (HTTP API + CLI manager) into a single CLI binary, removing the onenv-api server entirely. Mutation permission gating is ported to the CLI via an optional macOS AppleScript confirmation dialog gated by ONENV_CONFIRM_MUTATIONS=1. The primer data structure swaps the API section for a permission section, and all documentation is updated to reflect the single-binary architecture.

Changes

Consolidate to single CLI with macOS mutation confirmation

Layer / File(s) Summary
macOS mutation confirmation (confirmMutation)
onenv-manager/src/lib/permission.ts, onenv-manager/src/lib/permission.test.ts, onenv-manager/src/cli.ts
New confirmMutation() function gates set/edit/unset/import commands behind an optional AppleScript approval dialog on macOS, controlled by ONENV_CONFIRM_MUTATIONS=1. Dialog shows mutation details (action, namespace, keys) and timeouts after PERMISSION_TIMEOUT_MS (default 120s). CLI imports and calls confirmMutation before each mutation; tests verify no-op when disabled and error handling on non-macOS platforms.
Primer data: replace API section with permission section
onenv-manager/src/commands/prime-data.ts, onenv-manager/src/commands/prime-md.ts, onenv-manager/src/commands/prime-xml.ts, onenv-manager/src/commands/prime.ts
PrimerData interface replaces api: ApiSection with permission: PermissionSection, exposing confirm-on-write trigger/timeout environment variables, gated commands list, and error code. Markdown and XML renderers updated to output permission metadata instead of API documentation. PrimeFormat type reordered (cosmetic).
Remove onenv-api component and CI integration
.github/workflows/ci.yml, install.ts, onenv-api/biome.json
CI workflow removes the separate onenv-api job (which ran biome/tsc/tests); onenv-manager job remains as the only CI target. install.ts eliminates the API path constant and configureEnv() function; installer now only installs/builds onenv-manager. onenv-api biome config deleted.
Documentation: single-CLI architecture and permission gating
.atlas, CHANGELOG.md, README.md, INSTALL.md, AGENTS.md, CLAUDE.md, docs/CLAUDE-onenv.md, docs/guides/*, docs/examples/onenv-api.plist, docs/src/routes/+page.svelte, install.ts
Workspace description, changelog, and all user docs (README, INSTALL, guides, AGENTS, CLAUDE, marketing website) updated to: describe onenv as a single 1Password-backed CLI, remove HTTP API references and endpoints, explain ONENV_CONFIRM_MUTATIONS opt-in behavior and macOS AppleScript dialog, clarify OP_SERVICE_ACCOUNT_TOKEN resolution/caching at ~/.config/onenv-manager/op-token, document disabled-key state file location, and remove plist example for the removed HTTP service.
Package version update to 0.7.0
onenv-manager/package.json
Version bumped from 0.5.0 to 0.7.0.

Sequence Diagram

sequenceDiagram
  participant User
  participant CLI as onenv CLI
  participant ConfirmMutation as confirmMutation()
  participant osascript as osascript
  User->>CLI: onenv set namespace key value
  CLI->>ConfirmMutation: confirmMutation(action, namespace, details)
  ConfirmMutation->>ConfirmMutation: check ONENV_CONFIRM_MUTATIONS env
  alt ONENV_CONFIRM_MUTATIONS=1 and macOS
    ConfirmMutation->>osascript: execute AppleScript dialog
    osascript->>User: show approval prompt with timeout
    alt user approves before timeout
      User-->>osascript: allow
      osascript-->>ConfirmMutation: stdout=allowed
      ConfirmMutation-->>CLI: resolve
    else user denies or timeout
      User-->>osascript: deny/no response
      osascript-->>ConfirmMutation: stdout=denied/timeout
      ConfirmMutation-->>CLI: reject CliError(PERMISSION_DENIED)
      CLI-->>User: error
    end
  else ONENV_CONFIRM_MUTATIONS not set or non-macOS
    alt non-macOS
      ConfirmMutation-->>CLI: reject CliError(PERMISSION_UNSUPPORTED)
    else disabled (env not set or ≠ "1")
      ConfirmMutation-->>CLI: resolve (no-op)
    end
  end
  alt confirmed or disabled
    CLI->>CLI: perform mutation (set value in 1Password)
    CLI-->>User: success
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A rabbit's ode to consolidation

One CLI to replace them all,
No HTTP paths, just a cozy stall,
With AppleScript guards at every gate,
The single binary seals its fate—
API gone, but permission stays true,
A cleaner path, less code to pursue! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: consolidating the separate onenv-api Express server into a single onenv CLI while bumping the version to 0.7.0.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-consolidate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
onenv-manager/src/lib/permission.test.ts (1)

29-35: ⚡ Quick win

Assert the exact permission contract here.

On darwin this test exits without asserting anything, and elsewhere it only checks CliError, so a regression from PERMISSION_UNSUPPORTED to any other CLI failure would still pass. Please pin the specific error code/message here and add a mocked macOS allow/deny test so the new branch is covered on any CI host.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@onenv-manager/src/lib/permission.test.ts` around lines 29 - 35, The test
currently only checks for any CliError and short-circuits on darwin; update it
to assert the exact permission contract by expecting the thrown CliError to have
the specific code/message 'PERMISSION_UNSUPPORTED' (e.g., check error.code or
error.message) when process.platform !== 'darwin'. Additionally add two
darwin-specific tests that force process.platform to 'darwin' (or mock the
platform check) and mock the macOS permission prompt/flow used by
confirmMutation to simulate an allow and a deny: assert that the allow branch
resolves (or returns the expected success) and the deny branch rejects with the
exact permission error (or specific deny code/message). Reference
confirmMutation and CliError so the tests locate and assert the precise error
contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/guides/service-account-setup.md`:
- Around line 18-20: The fenced code block containing the environment variable
example (OP_SERVICE_ACCOUNT_TOKEN=ops_eyJ...) is missing a language identifier;
update that markdown code fence to include a shell language tag (e.g., ```bash
or ```shell) so the block reads as a bash/shell snippet and satisfies markdown
linting and syntax highlighting requirements.
- Around line 26-28: The fenced code block containing the
OP_SERVICE_ACCOUNT_TOKEN example is missing a language identifier; update the
triple-backtick fence for that block to include a shell/bash identifier (e.g.,
change ``` to ```bash) so the snippet is highlighted correctly and passes
markdown linting—locate the fenced block that shows
OP_SERVICE_ACCOUNT_TOKEN=op://Personal/<item-id>/credential and add the language
token after the opening backticks.

---

Nitpick comments:
In `@onenv-manager/src/lib/permission.test.ts`:
- Around line 29-35: The test currently only checks for any CliError and
short-circuits on darwin; update it to assert the exact permission contract by
expecting the thrown CliError to have the specific code/message
'PERMISSION_UNSUPPORTED' (e.g., check error.code or error.message) when
process.platform !== 'darwin'. Additionally add two darwin-specific tests that
force process.platform to 'darwin' (or mock the platform check) and mock the
macOS permission prompt/flow used by confirmMutation to simulate an allow and a
deny: assert that the allow branch resolves (or returns the expected success)
and the deny branch rejects with the exact permission error (or specific deny
code/message). Reference confirmMutation and CliError so the tests locate and
assert the precise error contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: df2f0f59-bf7a-421b-ab7d-00ba15e1f9b8

📥 Commits

Reviewing files that changed from the base of the PR and between 31bec9b and 5243999.

⛔ Files ignored due to path filters (1)
  • onenv-api/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (41)
  • .atlas
  • .github/workflows/ci.yml
  • AGENTS.md
  • CHANGELOG.md
  • CLAUDE.md
  • INSTALL.md
  • README.md
  • docs/CLAUDE-onenv.md
  • docs/examples/onenv-api.plist
  • docs/guides/agent-api.md
  • docs/guides/ci-and-deploys.md
  • docs/guides/running-commands.md
  • docs/guides/service-account-setup.md
  • docs/src/routes/+page.svelte
  • install.ts
  • onenv-api/.env.example
  • onenv-api/README.md
  • onenv-api/biome.json
  • onenv-api/package.json
  • onenv-api/src/index.ts
  • onenv-api/src/lib/config.test.ts
  • onenv-api/src/lib/config.ts
  • onenv-api/src/lib/logging.ts
  • onenv-api/src/lib/manager-service.ts
  • onenv-api/src/lib/onenv-client.test.ts
  • onenv-api/src/lib/onenv-client.ts
  • onenv-api/src/lib/op-token.ts
  • onenv-api/src/lib/permission.ts
  • onenv-api/src/lib/rate-limit.ts
  • onenv-api/src/lib/state-store.ts
  • onenv-api/src/server.ts
  • onenv-api/tsconfig.json
  • onenv-manager/package.json
  • onenv-manager/src/cli.ts
  • onenv-manager/src/commands/prime-data-api.ts
  • onenv-manager/src/commands/prime-data.ts
  • onenv-manager/src/commands/prime-md.ts
  • onenv-manager/src/commands/prime-xml.ts
  • onenv-manager/src/commands/prime.ts
  • onenv-manager/src/lib/permission.test.ts
  • onenv-manager/src/lib/permission.ts
💤 Files with no reviewable changes (23)
  • onenv-api/src/lib/config.test.ts
  • docs/guides/agent-api.md
  • docs/examples/onenv-api.plist
  • onenv-api/src/lib/logging.ts
  • onenv-api/tsconfig.json
  • onenv-api/package.json
  • docs/guides/running-commands.md
  • onenv-api/src/lib/op-token.ts
  • onenv-api/.env.example
  • onenv-api/biome.json
  • onenv-api/src/lib/state-store.ts
  • onenv-api/src/lib/onenv-client.test.ts
  • onenv-api/src/index.ts
  • onenv-api/src/lib/config.ts
  • onenv-api/src/lib/permission.ts
  • .github/workflows/ci.yml
  • onenv-api/src/lib/rate-limit.ts
  • onenv-api/src/lib/manager-service.ts
  • onenv-api/src/server.ts
  • onenv-api/src/lib/onenv-client.ts
  • docs/guides/ci-and-deploys.md
  • onenv-api/README.md
  • onenv-manager/src/commands/prime-data-api.ts

Comment on lines 18 to 20
```
OP_SERVICE_ACCOUNT_TOKEN=ops_eyJ...
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add language identifier to fenced code block.

The code block should specify bash or shell as the language identifier for proper syntax highlighting and to comply with markdown linting rules.

📝 Proposed fix
-```
+```bash
 OP_SERVICE_ACCOUNT_TOKEN=ops_eyJ...
</details>

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.22.1)</summary>

[warning] 18-18: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @docs/guides/service-account-setup.md around lines 18 - 20, The fenced code
block containing the environment variable example
(OP_SERVICE_ACCOUNT_TOKEN=ops_eyJ...) is missing a language identifier; update
that markdown code fence to include a shell language tag (e.g., ```bash or

linting and syntax highlighting requirements.

Comment thread docs/guides/service-account-setup.md
doublej added 3 commits May 22, 2026 00:52
When ONENV_CONFIRM_MUTATIONS=1 is set, every mutating CLI path —
set, edit, unset, import — calls confirmMutation() before touching
1Password. On macOS this pops an osascript Allow/Deny dialog naming
the action, namespace, and key(s). Deny → throws PERMISSION_DENIED.
Non-macOS with the env set → throws PERMISSION_UNSUPPORTED so the
guard fails loud rather than silently no-op'ing.

Default off. Off-path zero cost: confirmMutation returns immediately
when the env var isn't '1'.

Ported from the soon-to-be-deleted onenv-api withPermission() wrapper,
with the wiring point moved from HTTP handlers into the CLI command
files so a single guard covers all entry points.
Audit turned up zero callers of the api (no running process, no
launchctl entries, no references anywhere in ~/Documents/development
or ~/.config). The CLI is the agent surface, and the permission
brokering the api uniquely offered is now an opt-in CLI mode
(ONENV_CONFIRM_MUTATIONS, previous commit).

Deletes onenv-api/ entirely. Strips api references from README,
INSTALL, CLAUDE.md, AGENTS.md, docs/CLAUDE-onenv.md, the docs landing
page and guides, the CI workflow, and .atlas. Removes the
docs/examples/onenv-api.plist LaunchAgent template and the
docs/guides/agent-api.md guide. install.ts simplifies to single-
package setup (no more api token prompt).

Primer drops the <api> section and adds <permission>: prime-data.ts
swaps the ApiSection field for PermissionSection, prime-md.ts and
prime-xml.ts renderers updated, prime-data-api.ts removed. The
strict-export injection warning added in 0.6.0 is preserved.

Net delete heavy.
Adds a 0.7.0 entry covering the ONENV_CONFIRM_MUTATIONS gate and the
onenv-api removal. Notes the removal as breaking for anyone who was
running the api — switch to invoking the CLI directly with the env
var set if you want mutation prompts.
@doublej
doublej force-pushed the worktree-consolidate branch from 5243999 to ba88c10 Compare May 21, 2026 22:55
doublej added a commit that referenced this pull request May 22, 2026
Deletes the Express HTTP server outright and ports its valuable bit
(the macOS AppleScript permission dialog) into the CLI as an opt-in
ONENV_CONFIRM_MUTATIONS=1 guard for set / edit / unset / import.
Off by default; deny / timeout raises PERMISSION_DENIED; non-macOS
errors with PERMISSION_UNSUPPORTED.

Picks up the non-doc changes from PR #1 (worktree-consolidate). The
docs on main were already api-free from earlier today, so this
just lands the code half.

- delete onenv-api/ (whole subtree)
- delete onenv-manager/src/commands/prime-data-api.ts
- add onenv-manager/src/lib/permission.{ts,test.ts}
- wire confirmMutation into set / edit / unset / import
- drop the <api> section from the primer (xml, md, json); add a
  <permission> section
- install.ts: drop the API_TOKEN prompt, the api install/build/start
  steps, and the agent-api outro
- CI: drop the api job
- .atlas: refresh description

Keeps the 90-day-expires fix from main (worktree-consolidate predated it).
89 tests pass (was 86 + 3 new permission tests).
@doublej

doublej commented May 22, 2026

Copy link
Copy Markdown
Owner Author

Superseded — collapse landed on main as 83479b0 (api removal + permission gate) and d28f2ae (source moved to repo root); both shipped in v0.7.0 with extra polish (mermaid README, audit-doc scrub, release harness). See https://github.com/doublej/onenv/releases/tag/v0.7.0.

@doublej doublej closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant