diff options
| author | John Pham <john.pham@vercel.com> | 2026-05-21 10:17:47 -0700 |
|---|---|---|
| committer | John Pham <john.pham@vercel.com> | 2026-05-21 10:17:47 -0700 |
| commit | 9e50dda5bd410bf77915c630b2b8e2a44697c5b2 (patch) | |
| tree | da74e4fbb1e333f22c15b52c0164a8bce684d370 | |
| parent | 3296353bb7fff11269fff02e717350f05b721331 (diff) | |
fix: support user-owned vercel optimize scope checksjohnphamous/vercel-optimize-data-gap-reporting
8 files changed, 191 insertions, 16 deletions
diff --git a/packages/vercel-optimize-tests/test/collect-framework-preflight.test.mjs b/packages/vercel-optimize-tests/test/collect-framework-preflight.test.mjs index 4fddab9..acf3e23 100644 --- a/packages/vercel-optimize-tests/test/collect-framework-preflight.test.mjs +++ b/packages/vercel-optimize-tests/test/collect-framework-preflight.test.mjs @@ -243,6 +243,115 @@ process.exit(66); } }); +test('collect-signals: user-owned projects use username scope without teamId query params', async () => { + const scratch = await mkdtemp(join(tmpdir(), 'vo-user-scope-')); + const bin = join(scratch, 'bin'); + try { + await mkdir(bin, { recursive: true }); + await mkdir(join(scratch, '.vercel'), { recursive: true }); + await writeFile(join(scratch, 'package.json'), JSON.stringify({ + dependencies: { next: '^15.3.0' }, + }), 'utf-8'); + await writeFile(join(scratch, '.vercel', 'project.json'), JSON.stringify({ + projectId: 'prj_user', + orgId: 'usr_personal', + }), 'utf-8'); + const fakeVercel = join(bin, 'vercel'); + await writeFile(fakeVercel, `#!/usr/bin/env node +const args = process.argv.slice(2); +function json(value, code = 0) { + process.stdout.write(JSON.stringify(value, null, 2) + '\\n'); + process.exit(code); +} +function requireScope(expected) { + const i = args.indexOf('--scope'); + if (i === -1 || args[i + 1] !== expected || args.includes('usr_personal')) { + process.stderr.write('missing expected scope ' + expected + ': ' + args.join(' ') + '\\n'); + process.exit(67); + } +} +if (args[0] === '--version') { + process.stdout.write('54.1.0\\n'); + process.exit(0); +} +if (args[0] === 'whoami' && args[1] === '--format') { + json({ + user: { id: 'usr_personal', username: 'personal-user', billing: { plan: 'pro' } }, + }); +} +if (args[0] === 'whoami') { + process.stdout.write('personal-user\\n'); + process.exit(0); +} +if (args[0] === 'metrics' && args[1] === 'schema') { + requireScope('personal-user'); + json({ error: { code: 'OPLUS_REQUIRED', message: 'Observability Plus is not enabled' } }, 1); +} +if (args[0] === 'api') { + const path = args[1]; + if (path.startsWith('/v1/observability/manage/configuration/projects')) { + process.stderr.write('unexpected team Observability configuration probe for user-owned project\\n'); + process.exit(68); + } + if (path.startsWith('/v9/projects/prj_user?teamId=')) { + process.stderr.write('unexpected user project teamId query: ' + path + '\\n'); + process.exit(69); + } + if (path === '/v9/projects/prj_user') { + json({ id: 'prj_user', name: 'personal-site' }); + } + if (path === '/v2/user') { + json({ user: { username: 'personal-user', billing: { plan: 'pro' } } }); + } +} +if (args[0] === 'contract') { + requireScope('personal-user'); + json({ context: 'personal-user', commitments: [], totalCommitments: 0 }); +} +if (args[0] === 'usage') { + requireScope('personal-user'); + json({ + context: 'personal-user', + groupBy: { + dimension: 'project', + data: [{ + projectId: 'prj_user', + name: 'personal-site', + services: [{ name: 'Function Invocations', billedCost: 4 }], + totals: { billedCost: 4 }, + }], + }, + services: [{ name: 'Function Invocations', billedCost: 4 }], + totals: { billedCost: 4 }, + }); +} +process.stderr.write('unexpected vercel call: ' + args.join(' ') + '\\n'); +process.exit(66); +`, 'utf-8'); + await chmod(fakeVercel, 0o755); + + const { stdout, stderr } = await exec('node', [COLLECT, '--continue-without-observability'], { + cwd: scratch, + env: { ...process.env, PATH: `${bin}:${process.env.PATH}` }, + maxBuffer: 8 * 1024 * 1024, + }); + const out = JSON.parse(stdout); + assert.equal(out.commandScope.cliScope, 'personal-user'); + assert.equal(out.commandScope.source, 'whoami-user'); + assert.equal(out.usageScope, 'project'); + assert.equal(out.usageError, null); + assert.equal(out.usage.project.projectId, 'prj_user'); + assert.equal(out.project.id, 'prj_user'); + assert.equal(out.plan.plan, 'pro'); + assert.match(out.observabilityPlusPreflight.detail, /user-owned project/); + assert.doesNotMatch(stderr, /unexpected vercel call/); + assert.doesNotMatch(stderr, /missing expected scope/); + assert.doesNotMatch(stderr, /teamId query/); + } finally { + await rm(scratch, { recursive: true, force: true }); + } +}); + test('collect-signals: missing orgId stops before scoped Vercel calls', async () => { const scratch = await mkdtemp(join(tmpdir(), 'vo-missing-scope-')); const bin = join(scratch, 'bin'); diff --git a/packages/vercel-optimize-tests/test/deep-dive.test.mjs b/packages/vercel-optimize-tests/test/deep-dive.test.mjs index 6d58771..b9aeee6 100644 --- a/packages/vercel-optimize-tests/test/deep-dive.test.mjs +++ b/packages/vercel-optimize-tests/test/deep-dive.test.mjs @@ -355,3 +355,51 @@ test('deep-dive runner stops when cwd scope differs from collected signals', asy await rm(scratch, { recursive: true, force: true }); } }); + +test('deep-dive runner stops when commandScope account differs from cwd link', async () => { + const scratch = await mkdtemp(join(tmpdir(), 'vo-deep-dive-command-scope-mismatch-')); + try { + await mkdir(join(scratch, '.vercel'), { recursive: true }); + await writeFile(join(scratch, '.vercel', 'project.json'), JSON.stringify({ + projectId: 'prj_scope', + orgId: 'team_other', + }), 'utf-8'); + await writeFile(join(scratch, 'merged.json'), JSON.stringify({ + schemaVersion: '1.2', + projectId: 'prj_scope', + commandScope: { + ok: true, + cliScope: 'team-scope', + source: 'team-api', + teamId: 'team_scope', + }, + metrics: {}, + }), 'utf-8'); + await writeFile(join(scratch, 'gate.json'), JSON.stringify({ + toLaunch: [{ kind: 'route_errors', scope: 'route', route: '/api/fail', priority: 10 }], + platform: [], + }), 'utf-8'); + + let err; + try { + await exec('node', [ + SCRIPT, + join(scratch, 'merged.json'), + join(scratch, 'gate.json'), + '--cwd', + scratch, + ], { + maxBuffer: 8 * 1024 * 1024, + }); + } catch (e) { + err = e; + } + + assert.ok(err, 'deep-dive should stop when persisted commandScope targets another account'); + assert.equal(err.code, 2); + assert.equal(err.stdout, ''); + assert.match(err.stderr, /different Vercel scope than commandScope/); + } finally { + await rm(scratch, { recursive: true, force: true }); + } +}); diff --git a/packages/vercel-optimize-tests/test/fixtures/real-cli-output/README.md b/packages/vercel-optimize-tests/test/fixtures/real-cli-output/README.md index 6675b9f..226ee86 100644 --- a/packages/vercel-optimize-tests/test/fixtures/real-cli-output/README.md +++ b/packages/vercel-optimize-tests/test/fixtures/real-cli-output/README.md @@ -9,7 +9,7 @@ Sanitized from Vercel CLI v53.4.0 output against a fixture project. Identifiers, - **Status filter**: field is `http_status` (not `status`). Both `http_status eq '500'` and `http_status ge 500` work. - **Group by**: dimensions are documented in error response `allowedValues[]`. Available for `vercel.request.count` include `route`, `http_status`, `cache_result`, `request_path`, etc. - **External API group-by**: `origin_hostname` (not `hostname`). -- **Project API**: `vercel api /v9/projects/<id>` returns 404 unless scoped to the team that owns the project. Pass `?teamId=<orgId>` from `.vercel/repo.json`. +- **Project API**: `vercel api /v9/projects/<id>` returns 404 unless scoped to the team that owns the project. Pass `?teamId=<orgId>` for team-owned projects from `.vercel/repo.json`; omit it for user-owned `usr_...` projects. - **Project schema**: `resourceConfig.fluid` is the Fluid Compute flag. Bot Protection state is `security.botIdEnabled` (top-level boolean) and `security.managedRules.bot_filter.active` (challenge action). Top-level `framework` is `"nextjs"` (NOT `"next"`). - **Contract**: shape is `{context, commitments, totalCommitments}`. On this team `commitments=[]`. Plan-from-commitments is unreliable — fall back to "uncertain". - **Usage**: returns `Error: Costs not found (404)` on teams without the Costs feature enabled. The skill must degrade gracefully. diff --git a/skills/vercel-optimize/SKILL.md b/skills/vercel-optimize/SKILL.md index cd01a3c..8265bbd 100644 --- a/skills/vercel-optimize/SKILL.md +++ b/skills/vercel-optimize/SKILL.md @@ -74,7 +74,7 @@ node scripts/merge-signals.mjs "$RUN_DIR/vercel-signals.json" "$RUN_DIR/codebase Collection details, schemas, metric IDs, and degradation behavior live in [references/data-collection.md](references/data-collection.md). The metric registry is [lib/queries.mjs](lib/queries.mjs); keep all queries on the shared 14-day window. -`collect-signals.mjs` resolves the linked project team to `commandScope.cliScope`; downstream scripts reuse that scope for every Vercel CLI command that accepts `--scope`. Do not run `vercel usage`, `vercel metrics`, or `vercel contract` manually without the same scope; unscoped usage can report the user's personal organization while route metrics come from the team project. +`collect-signals.mjs` resolves the linked project owner to `commandScope.cliScope`; downstream scripts reuse that scope for every Vercel CLI command that accepts `--scope`. Do not run `vercel usage`, `vercel metrics`, or `vercel contract` manually without the same scope; unscoped usage can report the user's personal organization while route metrics come from the team project. If project or scope resolution is ambiguous, stop and ask the user which Vercel project and team/personal scope they want audited. Do not infer the intended scope from the current `vercel whoami` team, and do not proceed with metrics, usage, or contract collection until the link or `VERCEL_PROJECT_ID` + `VERCEL_ORG_ID` identifies the intended account. @@ -89,7 +89,7 @@ jq '{frameworkSupportBlocker, observabilityPlus, observabilityPlusUsable, observ Required actions: - `frameworkSupportBlocker === "unsupported_framework"`: use the unsupported-framework prompt above. -- `PROJECT_SCOPE_UNRESOLVED` or `SCOPE_UNRESOLVED`: stop and ask which Vercel team/personal scope owns the project. Rerun after `vercel link --yes --project <project-name-or-id> --team <team-slug>` or after setting both `VERCEL_PROJECT_ID` and `VERCEL_ORG_ID`. +- `PROJECT_SCOPE_UNRESOLVED` or `SCOPE_UNRESOLVED`: stop and ask which Vercel team/personal scope owns the project. For team projects, rerun after `vercel link --yes --project <project-name-or-id> --team <team-slug>`; for personal projects, rerun after linking under the intended user account or after setting both `VERCEL_PROJECT_ID` and `VERCEL_ORG_ID`. - `observabilityPlusBlocker === null`: continue. - `no_traffic`: tell the user route metrics are sparse; continue only if they accept limited output. - `payment_required` or `no_oplus_probe`: render [references/observability-plus.md](references/observability-plus.md) verbatim and ask. diff --git a/skills/vercel-optimize/lib/vercel.mjs b/skills/vercel-optimize/lib/vercel.mjs index e27eab5..6c5eddc 100644 --- a/skills/vercel-optimize/lib/vercel.mjs +++ b/skills/vercel-optimize/lib/vercel.mjs @@ -104,7 +104,7 @@ export async function resolveCommandScope(project = {}) { source: 'missing-org-scope', required: true, error: 'PROJECT_SCOPE_UNRESOLVED', - detail: 'The project was resolved without an org/team owner, so the collector cannot prove which Vercel scope to query.', + detail: 'The project was resolved without an owner account, so the collector cannot prove which Vercel scope to query.', }; } @@ -293,6 +293,15 @@ export async function checkObservabilityPlusConfiguration({ orgId, projectId } = detail: 'No team ID was available for the Observability Plus configuration preflight.', }; } + if (String(orgId).startsWith('usr_')) { + return { + ok: false, + source: 'observability-configuration-api', + access: null, + blocker: 'unknown', + detail: 'The Observability Plus team configuration preflight is not available for a user-owned project; falling back to the scoped metrics probe.', + }; + } const qs = `?teamId=${encodeURIComponent(orgId)}`; const r = await runVercelJson(['api', `/v1/observability/manage/configuration/projects${qs}`]); return classifyObservabilityPlusConfiguration(r, { projectId }); @@ -390,9 +399,12 @@ export async function queryMetric(metricId, opts = {}) { ); } -// `vercel api /v9/projects/<id>` 404s when project's team ≠ user's currentTeam — always pass `?teamId=<orgId>`. +// Team-owned projects need `?teamId=<orgId>` to avoid current-team drift. User- +// owned projects use the authenticated user context and should not pass teamId. export async function getProjectConfig(projectId, orgId) { - const qs = orgId ? `?teamId=${encodeURIComponent(orgId)}` : ''; + const qs = orgId && !String(orgId).startsWith('usr_') + ? `?teamId=${encodeURIComponent(orgId)}` + : ''; const r = await runVercelJson(['api', `/v9/projects/${projectId}${qs}`]); return r.ok ? r.data : { error: r.code, stderr: r.stderr }; } diff --git a/skills/vercel-optimize/references/data-collection.md b/skills/vercel-optimize/references/data-collection.md index 5936a84..a40eca0 100644 --- a/skills/vercel-optimize/references/data-collection.md +++ b/skills/vercel-optimize/references/data-collection.md @@ -49,7 +49,7 @@ The merged `signals.json` has this top-level shape: "observabilityPlusBlocker": null | "no_oplus_probe" | "project_disabled" | "payment_required" | "forbidden" | "daily_quota_exceeded" | "project_not_found" | "not_linked" | "all_failed_other" | "no_traffic", "observabilityPlusBlockerDetail": "...", "plan": { "plan": "hobby" | "pro" | "enterprise" | "uncertain", "reason": "..." }, - "project": { /* /v9/projects/:id response, scoped to orgId via ?teamId */ }, + "project": { /* /v9/projects/:id response; team-owned projects include ?teamId */ }, "contract": { "context": "...", "commitments": [], "totalCommitments": 0 }, "usage": { /* vercel usage --format json --breakdown daily, or null */ }, "usageError": null | "USAGE_UNAVAILABLE" | "USAGE_CONTEXT_MISMATCH" | "NOT_COLLECTED_OBSERVABILITY_BLOCKED" | "NOT_COLLECTED_UNSUPPORTED_FRAMEWORK" | "EXIT_<n>" | "UNKNOWN", @@ -62,7 +62,7 @@ The merged `signals.json` has this top-level shape: All metric queries use the same `timeWindow` constant (`14d`) — defined as `TIME_WINDOW` in [lib/queries.mjs](../lib/queries.mjs) and covered by the repo test suite. Mixing windows silently produces incompatible rollups; never pin a per-query `since`. -All Vercel CLI commands that accept scope must use `commandScope.cliScope` (`--scope <team-slug-or-username>`). Linked project files often contain a raw `team_...` ID, but several CLI subcommands silently fall back to the current team when `--scope` receives that ID. `collect-signals.mjs` resolves raw team IDs to slugs before running `vercel metrics`, `vercel usage`, or `vercel contract`; `deep-dive.mjs` reuses the same scope for follow-up metric queries. If the project link lacks an org/team owner or the CLI-safe scope cannot be resolved, stop and ask the user which Vercel project and team/personal scope they want audited. Do not infer scope from the current `vercel whoami` team. +All Vercel CLI commands that accept scope must use `commandScope.cliScope` (`--scope <team-slug-or-username>`). Linked project files often contain raw `team_...` or `usr_...` IDs, but several CLI subcommands silently fall back to the current team when `--scope` receives a raw account ID. `collect-signals.mjs` resolves raw team IDs to slugs and raw user IDs to usernames before running `vercel metrics`, `vercel usage`, or `vercel contract`; `deep-dive.mjs` reuses the same scope for follow-up metric queries. If the project link lacks an owner account or the CLI-safe scope cannot be resolved, stop and ask the user which Vercel project and team/personal scope they want audited. Do not infer scope from the current `vercel whoami` team. Downstream consumers reference `signals.<field>` paths verbatim. Bumping `schemaVersion` is required when any consumed path is renamed or removed. @@ -72,12 +72,12 @@ Downstream consumers reference `signals.<field>` paths verbatim. Bumping `schema |---|---|---|---| | Auth | `vercel whoami` | Everything | Exit with "run `vercel login`" | | CLI version | `vercel --version` | Everything | Exit with "upgrade to v53+" — v53 is the skill's compatibility floor | -| Project ID + Org ID | `.vercel/repo.json` (newer) or `.vercel/project.json` (legacy) → `VERCEL_PROJECT_ID` + `VERCEL_ORG_ID` → argv | Everything | Exit with "run `vercel link` or pass projectId". Multi-project `repo.json` or project ID without org/team scope is ambiguous; ask the user to clarify the intended project/account | +| Project ID + Org ID | `.vercel/repo.json` (newer) or `.vercel/project.json` (legacy) → `VERCEL_PROJECT_ID` + `VERCEL_ORG_ID` → argv | Everything | Exit with "run `vercel link` or pass projectId". Multi-project `repo.json` or project ID without owner account scope is ambiguous; ask the user to clarify the intended project/account | | Framework support | local `package.json` via `detectStack()` + `classifyFrameworkSupport()` | Code-backed route recommendations | Stop before metric fan-out on unsupported frameworks unless the user chooses `--continue-unsupported-framework` | -| CLI command scope | `vercel whoami --format json`, then `vercel api /v2/teams/:orgId` when a linked `team_...` ID must be converted to a slug | Keeps `vercel metrics`, `vercel usage`, and `vercel contract` on the linked project's account instead of the user's current/personal scope | `PROJECT_SCOPE_UNRESOLVED` or `SCOPE_UNRESOLVED`; stop and ask the user to clarify the intended project/account, then `vercel switch <team>` or re-link with `vercel link --yes --project <project> --team <team-slug>` | -| Observability Plus configuration | Vercel CLI/API probe plus one metric access check | All `metrics.*` signals | Stop early when the team lacks Observability Plus or this project is disabled | +| CLI command scope | `vercel whoami --format json`, then `vercel api /v2/teams/:orgId` when a linked `team_...` ID must be converted to a slug | Keeps `vercel metrics`, `vercel usage`, and `vercel contract` on the linked project's account instead of the user's current/personal scope | `PROJECT_SCOPE_UNRESOLVED` or `SCOPE_UNRESOLVED`; stop and ask the user to clarify the intended project/account, then re-link under the intended team or personal account | +| Observability Plus configuration | Vercel CLI/API probe plus one metric access check; user-owned projects skip the team configuration endpoint and rely on the scoped metrics probe | All `metrics.*` signals | Stop early when the account lacks Observability Plus or this project is disabled | | Observability Plus metrics access | One canary `vercel metrics vercel.request.count --since 14d --limit 1`, then full fan-out only if it succeeds | All `metrics.*` signals | Set `observabilityPlusUsable=false` with blocker detail; emit a minimal blocker document before slower project config / usage collection unless `--continue-without-observability` is passed | -| Project config | `vercel api /v9/projects/:id?teamId=<orgId>` | Fluid Compute, BotID, Speed Insights, security flags | `{error: "..."}` placeholder; gates that need it skip | +| Project config | `vercel api /v9/projects/:id?teamId=<orgId>` for team-owned projects; omit `teamId` for `usr_...` user-owned projects | Fluid Compute, BotID, Speed Insights, security flags | `{error: "..."}` placeholder; gates that need it skip | | Plan tier | `vercel api /v2/teams/:orgId` (or `/v2/user` for user-owned projects) → `billing.plan`, then scoped `vercel contract --format json` fallback → `inferPlan()` | Cost-context framing only | `plan="uncertain"`; cost magnitudes still computed from `usage.services[].billedCost` | | Billing usage | Scoped `vercel usage --format json --from <14d> --to <today>` with best-effort project grouping when supported by the installed CLI | Cost magnitude framing, billing-driven candidates | `null` + `usageError` set when queried and unavailable; `NOT_COLLECTED_*` when a preflight stop happened before billing collection | | Stack | local `package.json` + dir scan | Version-aware citation filtering, scanner gating | "unknown" framework → all framework-specific citations filtered | @@ -114,7 +114,7 @@ Downstream consumers reference `signals.<field>` paths verbatim. Bumping `schema | Code | Meaning | Skill behavior | |---|---|---| | `unsupported_framework` | Detected framework cannot reliably map Vercel route metrics back to source files | Stop before metric fan-out; ask whether to continue with a limited platform/scanner audit | -| `PROJECT_SCOPE_UNRESOLVED` | The project was found without an org/team owner, or `.vercel/repo.json` contains multiple linked projects | Stop before `vercel metrics`, `vercel usage`, or `vercel contract`; ask the user which Vercel project and team/personal scope to audit | +| `PROJECT_SCOPE_UNRESOLVED` | The project was found without an owner account, or `.vercel/repo.json` contains multiple linked projects | Stop before `vercel metrics`, `vercel usage`, or `vercel contract`; ask the user which Vercel project and team/personal scope to audit | | `SCOPE_UNRESOLVED` | The linked project belongs to a specific team/user, but the collector could not resolve a CLI-safe `--scope` value | Stop before `vercel metrics`, `vercel usage`, or `vercel contract`; ask the user to switch/re-link with the correct team | | `no_oplus_probe` | Observability Plus not enabled on team | Stop before full metric fan-out; ask whether to enable Observability Plus or run scanner-only | | `project_disabled` | Observability Plus enabled for team but disabled for project | Stop before full metric fan-out; ask the user to enable Observability Plus for this project or continue scanner-only | @@ -176,7 +176,7 @@ Array of `{id, description}` entries — NOT an object. Many metric IDs in earli Status filtering uses `http_status` (not `status`). Both `http_status eq '500'` and `http_status ge 500` work. -### `vercel api /v9/projects/<id>?teamId=<orgId>` +### `vercel api /v9/projects/<id>` / `?teamId=<orgId>` Top-level keys relevant to the skill (real, verified): - `framework` (string, e.g. `"nextjs"`) @@ -188,7 +188,7 @@ Top-level keys relevant to the skill (real, verified): - `webAnalytics` (`{id}`) — installed but `features.webAnalytics` says enabled state - `nodeVersion` (e.g. `"22.x"`) -Calling without `?teamId=` returns 404 when the project belongs to a team other than the user's `currentTeam`. +Calling without `?teamId=` returns 404 when the project belongs to a team other than the user's `currentTeam`. For user-owned projects (`orgId` starts with `usr_`), omit `teamId` and let the CLI use the authenticated user context. ### `vercel contract --format json` diff --git a/skills/vercel-optimize/scripts/collect-signals.mjs b/skills/vercel-optimize/scripts/collect-signals.mjs index 433b1b6..f5ae245 100755 --- a/skills/vercel-optimize/scripts/collect-signals.mjs +++ b/skills/vercel-optimize/scripts/collect-signals.mjs @@ -76,7 +76,7 @@ async function main() { log(`project link resolved (source=${project.source}; teamScope=${project.orgId ? 'yes' : 'no'})`); if (!project.orgId) { - throw new Error('PROJECT_SCOPE_UNRESOLVED: the project was resolved without an org/team owner. Ask the user which Vercel team or personal scope owns the project, then rerun from a linked app directory or set VERCEL_PROJECT_ID with VERCEL_ORG_ID for that scope.'); + throw new Error('PROJECT_SCOPE_UNRESOLVED: the project was resolved without an owner account. Ask the user which Vercel team or personal scope owns the project, then rerun from a linked app directory or set VERCEL_PROJECT_ID with VERCEL_ORG_ID for that scope.'); } log('checking framework support…'); diff --git a/skills/vercel-optimize/scripts/deep-dive.mjs b/skills/vercel-optimize/scripts/deep-dive.mjs index 6363fc3..497d32a 100755 --- a/skills/vercel-optimize/scripts/deep-dive.mjs +++ b/skills/vercel-optimize/scripts/deep-dive.mjs @@ -73,6 +73,12 @@ async function main() { console.error(' Re-run collect-signals.mjs with the current skill so deep-dive queries use the same team as the broad pass.'); process.exit(2); } + const commandAccountId = commandScope.teamId ?? commandScope.userId ?? null; + if (commandAccountId && link.orgId && link.orgId !== commandAccountId) { + console.error('[deep-dive] FATAL: cwd .vercel/ links the project to a different Vercel scope than commandScope.'); + console.error(' Re-run with --cwd <dir-linked-to-the-collected-project>, or rerun collect-signals.mjs from the intended app directory.'); + process.exit(2); + } const scope = commandScope.cliScope || undefined; log(`command scope resolved (source=${commandScope.source}; scoped=${scope ? 'yes' : 'no'})`); |
