Skip to content

feat(cli): add interactive PowerContext config init - #1367

Open
happy-v587 wants to merge 10 commits into
oceanbase:masterfrom
happy-v587:docs/issue-1333-full-capability-runtime
Open

feat(cli): add interactive PowerContext config init#1367
happy-v587 wants to merge 10 commits into
oceanbase:masterfrom
happy-v587:docs/issue-1333-full-capability-runtime

Conversation

@happy-v587

Copy link
Copy Markdown
Contributor

Closes #1333

Rationale for this change

The existing server can run in a minimal mode, but users had to manually combine inference, vector search, scheduler, Dashboard, Scope ID, database, and Coding Agent settings. This change provides one guided command for a complete local setup without changing the default server behavior.

What changes are included in this PR?

  • Add powercontext config init with a short interactive setup for Scope ID, API protocol, Base URL, API key, Generation model, Embedding model, and dimension.
  • Derive internal provider adapters and environment variable names from stable API protocol choices.
  • Generate a protected 0600 .env containing full-capability Server, Dashboard, Scope, inference, database, scheduler, and integration settings.
  • Print setup and launch commands for Codex, Claude Code, DeepSeek Harness, OpenCode, and Pi using the same Scope ID.
  • Keep config show and config validate, update the environment example, and add the bilingual full-capability Quick Start guide.
  • Preserve the default minimal powercontext server run behavior.

Are there any user-facing changes?

Yes. Users can run powercontext config init --output .env to create a complete local configuration. The generated file is local and ignored by Git; API keys are hidden during interactive input and redacted by config show. This introduces the new config init workflow and does not alter the default server startup contract.

How was this change tested?

  • uv run pytest -q tests/test_config_cli.py tests/test_cli.py tests/test_server.py — 60 passed.
  • make check — passed.
  • make docs-test — passed.
  • make build — passed.
  • Manual CLI matrix: default, Advanced, OpenAI Responses, Anthropic with independent Embedding, Custom adapter, overwrite protection, and real TTY fuzzy selection.
  • Manual runtime validation with a local OpenAI-compatible stub: Generation and Embedding requests were received, ready reported ready, Source ingestion returned HTTP 202, and flush returned HTTP 200 with the Source processed.
  • Isolated setup validation: Codex, Claude Code, DeepSeek Harness, and Pi setup completed successfully. OpenCode setup and the existing OpenCode Host E2E test exceeded the timeout on the locally installed OpenCode 1.18.23 and returned Unexpected server error; this remains an environment-specific limitation and is not caused by config init.
  • Full regression: 714 passed, 9 skipped, 1 failed at tests/e2e/test_opencode_plugin_host.py.

AI usage statement

Built and validated with OpenAI Codex (GPT-5). The agent inspected the repository, implemented the CLI and documentation changes, ran automated and manual tests, and recorded the OpenCode environment limitation above.

@happy-v587
happy-v587 marked this pull request as ready for review August 26, 2026 09:13
@happy-v587

Copy link
Copy Markdown
Contributor Author

@AlexStocks PTAL

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found three issues in the new configuration flow.

Comment thread src/powercontext/cli/config.py Outdated
Comment thread src/powercontext/cli/env_file.py Outdated
Comment thread docs/en/docs/how-to/full-capability-runtime.md
- Redact credential container variables (e.g. OTEL_EXPORTER_OTLP_HEADERS)
  and generator-recorded credential names in config show output
- Fix env_file parser to recognize # only at unquoted word boundaries,
  preserving values like TOKEN=abc#123
- Complete EN/ZH full-capability guides with doctor, Source-to-flush-to-Memory
  round trip, data-location and shutdown guidance, capability matrix, and
  FTS-only fallback explanation per issue oceanbase#1333 acceptance criteria
@happy-v587
happy-v587 force-pushed the docs/issue-1333-full-capability-runtime branch from b5849ea to 1b2ed2b Compare August 26, 2026 14:17

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found three remaining issues on the current head.

Comment thread src/powercontext/cli/config.py Outdated
Comment thread docs/en/docs/how-to/full-capability-runtime.md Outdated
Comment thread src/powercontext/cli/env_file.py Outdated
- Pass is_credential flag to _collect_provider_variable so custom
  credential names get hidden input even when not matching _is_secret_name
- Fix _strip_comment to handle backslash-escaped spaces outside quotes,
  using a sentinel approach to survive shlex.split processing
- Revise docs to use cursor-aware flush verification and vector search
  query for embedding confirmation instead of non-deterministic assertions
- Add regression tests for hide_input, escaped spaces, and backslash handling

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I found two remaining issues on the current head.

Comment thread docs/en/docs/how-to/full-capability-runtime.md Outdated
Comment thread src/powercontext/cli/env_file.py Outdated

@AsperforMias AsperforMias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two remaining issues on the current head.

Comment thread src/powercontext/cli/config.py Outdated
Comment thread src/powercontext/cli/config.py Outdated
- Ask whether each additional provider variable is a credential, hide its
  input during init, and record the name in credentials metadata so config
  show redacts it
- Add regression tests for the hidden prompt, show redaction round trip,
  and unmarked non-credential variables
- Add a regression test for config show on malformed managed markers
- Load the OpenCode host e2e plugin from the production install location
@Teingi

Teingi commented Aug 27, 2026

Copy link
Copy Markdown
Member

please resolve conflicts

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.

docs: add a full-capability runtime setup guide

3 participants