Skip to content

feat(configure): auto-detect project_id#14

Merged
tvt286 merged 1 commit intomainfrom
feat/configure-auto-detect-project
Apr 19, 2026
Merged

feat(configure): auto-detect project_id#14
tvt286 merged 1 commit intomainfrom
feat/configure-auto-detect-project

Conversation

@tvt286
Copy link
Copy Markdown
Contributor

@tvt286 tvt286 commented Apr 19, 2026

Summary

Follow-up to #13. When the user leaves the Project ID prompt blank, grn configure now calls vServer /v1/projects with the just-entered credentials and region's vServer endpoint, then saves the returned project_id.

Each user has exactly one project per region (confirmed), so the first result is unambiguous.

Flow

Client ID [****abcd]:
Client Secret [****wxyz]:
Default region name [HCM-3]:
Default output format [json]:
Project ID (leave blank to auto-detect) []: <press Enter>
Fetching project_id from HCM-3...
Auto-detected project_id: pro-e28d4501-59d8-4f47-9eb0-948c54f80592
Configuration saved successfully.

Failure handling

  • Bad credentials → warning, saves blank
  • Network error → warning, saves blank
  • No project → warning, saves blank

In all cases the wizard completes successfully; downstream tools (greenode-mcp-server) can still auto-detect at call time.

Changes

  • go/cmd/configure/detect_project.go: new helper — detectProjectID() and vserverEndpointForRegion()
  • go/cmd/configure/configure.go: invoke auto-detect when projectID is empty
  • README.md + docs/configuration.md: updated wizard output example
  • .changes/next-release/enhancement-configure-*.json: changelog fragment

Test plan

  • go vet + go build clean
  • Manual: run wizard with valid credentials → project_id auto-populated
  • Manual: run wizard with bad credentials → warning, saves blank
  • Manual: run wizard with explicit project_id entered → auto-detect skipped
  • grn configure list shows the saved value

🤖 Generated with Claude Code

When the user leaves the Project ID prompt blank, the wizard now calls
vServer /v1/projects (using the just-entered credentials and region's
vServer endpoint) and saves the single returned project.

Each user is expected to have exactly one project per region, so using
the first result is unambiguous. If auto-detect fails (bad creds, no
network, no project), the wizard prints a warning and leaves the field
blank — downstream tools (greenode-mcp-server) can still fall back to
auto-detect at call time.

- `go/cmd/configure/detect_project.go`: lightweight /v1/projects fetch
  using the existing auth.TokenManager
- `go/cmd/configure/configure.go`: auto-invoke when projectID == ""
- Docs + README updated with the new prompt flow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tvt286 tvt286 merged commit 4e7ddd0 into main Apr 19, 2026
4 checks passed
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