fix(cli): publish the resolved dev org under every org env alias - #1624
fix(cli): publish the resolved dev org under every org env alias#1624VihaanAgarwal wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughChangesThe dev command now publishes a resolved organization ID through multiple Dev organization environment propagation
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli/test/cmd/dev/org-id.test.ts (1)
62-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover preservation for every alias independently.
This test only pre-populates
AGENTUITY_ORG_ID; it does not verify preservation ofAGENTUITY_ORGIDorAGENTUITY_CLOUD_ORG_ID. Add table-driven cases for all three aliases so a regression in one alias cannot pass unnoticed.🤖 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 `@packages/cli/test/cmd/dev/org-id.test.ts` around lines 62 - 70, Expand the test around applyDevOrgEnv to use table-driven cases that independently pre-populate AGENTUITY_ORGID, AGENTUITY_ORG_ID, and AGENTUITY_CLOUD_ORG_ID, then assert each existing alias value is preserved while unset aliases receive org_project.
🤖 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.
Nitpick comments:
In `@packages/cli/test/cmd/dev/org-id.test.ts`:
- Around line 62-70: Expand the test around applyDevOrgEnv to use table-driven
cases that independently pre-populate AGENTUITY_ORGID, AGENTUITY_ORG_ID, and
AGENTUITY_CLOUD_ORG_ID, then assert each existing alias value is preserved while
unset aliases receive org_project.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ae1d1cca-8f42-4da6-9697-73bc4b2840ae
📒 Files selected for processing (2)
packages/cli/src/cmd/dev/index.tspackages/cli/test/cmd/dev/org-id.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (18)
- GitHub Check: Native install (macOS)
- GitHub Check: Linux distro install smoke
- GitHub Check: Native install (Linux)
- GitHub Check: Bun version checks
- GitHub Check: Installer scenarios
- GitHub Check: Windows WSL CLI Smoke Test
- GitHub Check: Build
- GitHub Check: Pack & Upload
- GitHub Check: Service Client Smoke Tests
- GitHub Check: Queue CLI Tests (node)
- GitHub Check: Package Installation & Usage Test (node)
- GitHub Check: Queue CLI Tests (bun)
- GitHub Check: Postgres SSL Integration Test
- GitHub Check: Package Installation & Usage Test (bun)
- GitHub Check: Testing Apps (local tests)
- GitHub Check: Framework Demo Tests
- GitHub Check: Migrate Chain (v1 → v2 → v3)
- GitHub Check: OSV Scanner PR
⚠️ CI failures not shown inline (2)
GitHub Actions: Gitleaks Scan / 0_Gitleaks Secret Scan.txt: fix(cli): publish the resolved dev org under every org env alias
Conclusion: failure
##[group]Run gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7
env:
GITHUB_***REDACTED***
GITLEAKS_LICENSE:
##[endgroup]
(node:2418) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:2418) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
[agentuity] is an organization. License key is required.
##[error]🛑 missing gitleaks license. Go grab one at gitleaks.io and store it as a GitHub Secret named GITLEAKS_LICENSE. For more info about the recent breaking update, see [here](https://github.com/gitleaks/gitleaks-action#-announcement).
GitHub Actions: Gitleaks Scan / Gitleaks Secret Scan: fix(cli): publish the resolved dev org under every org env alias
Conclusion: failure
##[group]Run gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7
env:
GITHUB_***REDACTED***
GITLEAKS_LICENSE:
##[endgroup]
(node:2418) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:2418) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
[agentuity] is an organization. License key is required.
##[error]🛑 missing gitleaks license. Go grab one at gitleaks.io and store it as a GitHub Secret named GITLEAKS_LICENSE. For more info about the recent breaking update, see [here](https://github.com/gitleaks/gitleaks-action#-announcement).
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Run
bun run formatusing Biome with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5
Files:
packages/cli/test/cmd/dev/org-id.test.tspackages/cli/src/cmd/dev/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript in strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
packages/cli/test/cmd/dev/org-id.test.tspackages/cli/src/cmd/dev/index.ts
**/packages/*/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/packages/*/test/**/*.{ts,tsx}: Place tests intest/folder parallel tosrc/directory, never insidesrc/or under__tests__/
Import from../src/in test files
Use@agentuity/test-utilsfor shared mocks in tests
Files:
packages/cli/test/cmd/dev/org-id.test.ts
packages/cli/src/cmd/**/index.ts
📄 CodeRabbit inference engine (packages/cli/AGENTS.md)
packages/cli/src/cmd/**/index.ts: Each command must be a directory insrc/cmd/with anindex.tsentry point
Always define interfaces for command options using Zod schemas; never useanyfor type safety
Files:
packages/cli/src/cmd/dev/index.ts
packages/cli/src/**/*.ts
📄 CodeRabbit inference engine (packages/cli/AGENTS.md)
packages/cli/src/**/*.ts: Usetui.*helpers for formatted output (header,info,success,warning,error,table,progress)
Usectx.loggerfor logging;logger.fatal()logs and exits with code 1
Useawait readFile(p, 'utf-8')andawait writeFile(p, content)fromnode:fs/promisesfor file I/O
ImportpathExistsfromnode-compat/fsfor file existence checks instead of using Node's built-in
Do not use Bun globals (Bun.file,Bun.spawn,Bun.color,Bun.stringWidth, etc.) in production source code;tsconfig.jsontype checking enforces this
Imports must use explicit.tsextensions for relative paths (e.g.,from './foo.ts', notfrom './foo'); TypeScript'srewriteRelativeImportExtensionswill rewrite them to.jsin output
Always checkisJSONMode()for machine-readable output in command handlers
UserequireAuth(ctx)oroptionalAuth(ctx)for authenticated commands
Files:
packages/cli/src/cmd/dev/index.ts
🧠 Learnings (3)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
packages/cli/test/cmd/dev/org-id.test.tspackages/cli/src/cmd/dev/index.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.
Applied to files:
packages/cli/test/cmd/dev/org-id.test.ts
📚 Learning: 2026-02-17T14:23:15.448Z
Learnt from: potofpie
Repo: agentuity/sdk PR: 974
File: packages/cli/src/cmd/git/account/list.ts:39-40
Timestamp: 2026-02-17T14:23:15.448Z
Learning: In the Agentuity CLI framework (packages/cli), when a subcommand declares requires: { auth: true }, the framework will automatically call requireAuth() before invoking the handler. Do not call requireAuth(ctx) manually inside command handlers. This applies to all TypeScript command files under packages/cli/src, including paths like packages/cli/src/cmd/git/account/list.ts.
Applied to files:
packages/cli/src/cmd/dev/index.ts
🔇 Additional comments (3)
packages/cli/src/cmd/dev/index.ts (2)
71-88: LGTM!
196-203: LGTM!packages/cli/test/cmd/dev/org-id.test.ts (1)
2-2: LGTM!
What broke
The org id travels under three env var names (
AGENTUITY_ORGID,AGENTUITY_ORG_ID,AGENTUITY_CLOUD_ORG_ID) and consumers read different subsets: pi reads all of them, coder-tui readsAGENTUITY_ORGIDandAGENTUITY_CLOUD_ORG_ID, and the docs point apps atAGENTUITY_CLOUD_ORG_ID.agentuity devinjects onlyAGENTUITY_ORGID, so an app reading either of the other names never sees the org thatdevresolved, and a stale inheritedAGENTUITY_ORG_IDfrom the developer's shell wins silently. That is the remaining bug from #1611 after the project-first resolution landed in #1508.Fix
Extract the injection into
applyDevOrgEnv, which publishes the resolved org under all three aliases, keeping the existing guard per name: a value the developer already set (non-blank) is never overwritten, matching the current behavior forAGENTUITY_ORGID. The pi org switcher already writes all the aliases when switching orgs, so this bringsdevin line with that precedent.The issue also suggests warning when an inherited alias disagrees with the resolved org. Left that out to keep this to one concern; happy to follow up if wanted.
Tests
Added
applyDevOrgEnvcases totest/cmd/dev/org-id.test.ts: all aliases published, developer-set aliases preserved individually, blank aliases overwritten, no-op without a resolved org.bun test test/in packages/cli: 775 pass (the one failure, upgrade version mismatch, is present on clean main). Format, lint, typecheck, build all green.Fixes #1611
Summary by CodeRabbit