@legioncodeinc/rflectr 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/.markdown-link-check.json +7 -0
  2. package/AGENTS.md +169 -0
  3. package/LICENSE +661 -0
  4. package/README.md +612 -0
  5. package/assets/733630021_1421561133353555_3999689754075308337_n.jpg +0 -0
  6. package/assets/github-home-image.png +0 -0
  7. package/assets/og-image.jpg +0 -0
  8. package/assets/og-image.png +0 -0
  9. package/assets/og-image.psd +0 -0
  10. package/assets/rflectr-no-bg.png +0 -0
  11. package/assets/vertex-models.example.json +14 -0
  12. package/dist/cli.js +15708 -0
  13. package/library/README.md +39 -0
  14. package/library/issues/README.md +46 -0
  15. package/library/issues/backlog/README.md +26 -0
  16. package/library/issues/completed/README.md +13 -0
  17. package/library/issues/in-work/README.md +13 -0
  18. package/library/knowledge/README.md +34 -0
  19. package/library/knowledge/private/README.md +40 -0
  20. package/library/knowledge/private/ai/README.md +8 -0
  21. package/library/knowledge/private/ai/model-discovery-classification.md +81 -0
  22. package/library/knowledge/private/ai/translation-layer.md +88 -0
  23. package/library/knowledge/private/architecture/README.md +10 -0
  24. package/library/knowledge/private/architecture/launch-flow-claude.md +93 -0
  25. package/library/knowledge/private/architecture/system-overview.md +108 -0
  26. package/library/knowledge/private/auth/README.md +9 -0
  27. package/library/knowledge/private/auth/oauth-device-flows.md +95 -0
  28. package/library/knowledge/private/data/README.md +8 -0
  29. package/library/knowledge/private/data/preferences-config.md +87 -0
  30. package/library/knowledge/private/data/provider-registry.md +126 -0
  31. package/library/knowledge/private/infrastructure/README.md +7 -0
  32. package/library/knowledge/private/infrastructure/server-gateway.md +87 -0
  33. package/library/knowledge/private/integrations/README.md +8 -0
  34. package/library/knowledge/private/integrations/harnesses.md +87 -0
  35. package/library/knowledge/private/integrations/local-proxy.md +82 -0
  36. package/library/knowledge/private/security/README.md +9 -0
  37. package/library/knowledge/private/security/credential-storage.md +129 -0
  38. package/library/knowledge/private/standards/documentation-framework.md +154 -0
  39. package/library/knowledge/public/README.md +49 -0
  40. package/library/knowledge/public/faqs/README.md +7 -0
  41. package/library/knowledge/public/faqs/troubleshooting.md +92 -0
  42. package/library/knowledge/public/guides/README.md +13 -0
  43. package/library/knowledge/public/guides/ai-agents.md +273 -0
  44. package/library/knowledge/public/guides/api-server.md +108 -0
  45. package/library/knowledge/public/guides/claude-desktop.md +382 -0
  46. package/library/knowledge/public/guides/codex.md +296 -0
  47. package/library/knowledge/public/guides/gemini-cli.md +105 -0
  48. package/library/knowledge/public/guides/model-compatibility.md +80 -0
  49. package/library/knowledge/public/guides/providers.md +90 -0
  50. package/library/knowledge/public/overview/README.md +7 -0
  51. package/library/knowledge/public/overview/what-is-rflectr.md +71 -0
  52. package/library/notes/README.md +21 -0
  53. package/library/requirements/README.md +51 -0
  54. package/library/requirements/backlog/README.md +30 -0
  55. package/library/requirements/completed/README.md +14 -0
  56. package/library/requirements/completed/prd-001-cli-core-launch-orchestration/prd-001-cli-core-launch-orchestration-index.md +205 -0
  57. package/library/requirements/completed/prd-001-cli-core-launch-orchestration/qa/.gitkeep +0 -0
  58. package/library/requirements/completed/prd-002-provider-registry/qa/.gitkeep +0 -0
  59. package/library/requirements/completed/prd-003-model-discovery-classification/qa/.gitkeep +0 -0
  60. package/library/requirements/completed/prd-004-translation-layer/qa/.gitkeep +0 -0
  61. package/library/requirements/completed/prd-005-local-proxy-catalog-routing/qa/.gitkeep +0 -0
  62. package/library/requirements/completed/prd-007-oauth-device-flows/qa/.gitkeep +0 -0
  63. package/library/requirements/completed/prd-011-claude-desktop-integration/qa/.gitkeep +0 -0
  64. package/library/requirements/in-work/README.md +19 -0
  65. package/library/requirements/reports/README.md +31 -0
  66. package/package.json +84 -0
  67. package/scripts/refresh-models-dev-cache.mjs +34 -0
  68. package/test-proxy.ts +19 -0
  69. package/test-split.js +1 -0
@@ -0,0 +1,129 @@
1
+ # Credential Storage & Environment Isolation
2
+
3
+ > Category: Security | Version: 1.0 | Date: June 2026 | Status: Active
4
+
5
+ Where secrets live, how they're resolved at launch, and the exact environment contract handed to each child process. This is the security-critical surface of `rflectr`. Read [`../architecture/system-overview.md`](../architecture/system-overview.md) first.
6
+
7
+ **Related:**
8
+ - [`../auth/oauth-device-flows.md`](../auth/oauth-device-flows.md)
9
+ - [`../data/provider-registry.md`](../data/provider-registry.md)
10
+ - [`../architecture/launch-flow-claude.md`](../architecture/launch-flow-claude.md)
11
+ - Source: `src/env.ts`, `src/key-setup.ts`, `src/constants.ts`
12
+
13
+ ---
14
+
15
+ ## Where secrets live
16
+
17
+ Secrets are **never** written to `providers.json` or `config.json`. Those files hold only an `authRef` pointer. The actual secret lives in one of three places, resolved in priority order by `resolveProviderCredential(providerId, authRef)` (`src/env.ts`):
18
+
19
+ 1. **Env var** — `RFLECTR_KEY_<PROVIDER_ID_UPPER>` (highest priority), or whatever `env:VAR_NAME` the `authRef` names (e.g. `env:OPENCODE_API_KEY`).
20
+ 2. **OS keyring** — via `@napi-rs/keyring`, service `rflectr`. Accounts:
21
+ - `provider:<id>` — an API key.
22
+ - `oauth:provider:<id>` — a JSON `StoredOAuthCredential` (see [`../auth/oauth-device-flows.md`](../auth/oauth-device-flows.md)).
23
+ - `global:opencode` — the shared OpenCode Zen/Go key.
24
+ 3. **Legacy keyring entries** — `rflectr` / `opencode-starter` accounts, auto-migrated on first successful read.
25
+
26
+ `@napi-rs/keyring` is an `optionalDependency` loaded via dynamic `import()`, so a missing native binary degrades gracefully rather than crashing. `classifyKeyringError(err)` turns native failures into human messages ("Secret Service daemon is not running", "keychain access was denied or the keychain is locked", "native keyring module not available", …).
27
+
28
+ ```mermaid
29
+ flowchart TD
30
+ need["launch needs a key for provider X"] --> env{"RFLECTR_KEY_X or env:VAR set?"}
31
+ env -->|yes| use["use it"]
32
+ env -->|no| ref{"authRef kind"}
33
+ ref -->|keyring:provider:X| kr["read keyring account"]
34
+ ref -->|keyring:oauth:provider:X| oauth["read + refresh OAuth credential"]
35
+ ref -->|keyring:global:opencode| zen["readGlobalOpencodeCredential() chain"]
36
+ kr --> use
37
+ oauth --> use
38
+ zen --> use
39
+ ```
40
+
41
+ ### The OpenCode Zen/Go fallback chain
42
+
43
+ `readGlobalOpencodeCredential()` tries, in order: `OPENCODE_API_KEY` env var → keyring `global:opencode` → legacy keyring `rflectr` → oldest legacy service `opencode-starter`. On a successful legacy read, `migrateGlobalOpencodeCredential()` rewrites it to `global:opencode` using a **read → write → verify → delete** protocol (the old entry is only deleted after the new one verifies).
44
+
45
+ ---
46
+
47
+ ## Child process environment
48
+
49
+ `buildChildEnv(baseUrl, model, apiKey, proxyPort?, contextWindow?, enableGatewayDiscovery?)` (`src/env.ts`) builds the env for the launched host. It is the security boundary: the parent shell is never mutated (except `OPENCODE_API_KEY` during interactive key setup).
50
+
51
+ **Removed** — every var in `CONFLICTING_ENV_VARS` (`src/constants.ts`), so stale cloud config can't leak into the child:
52
+
53
+ ```
54
+ CLAUDE_CODE_USE_VERTEX, ANTHROPIC_VERTEX_PROJECT_ID, ANTHROPIC_VERTEX_BASE_URL,
55
+ CLOUD_ML_REGION, ANTHROPIC_BEDROCK_BASE_URL, ANTHROPIC_AWS_BASE_URL,
56
+ ANTHROPIC_AWS_API_KEY, ANTHROPIC_AWS_WORKSPACE_ID, ANTHROPIC_FOUNDRY_API_KEY,
57
+ ANTHROPIC_FOUNDRY_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY,
58
+ ANTHROPIC_BASE_URL, ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL,
59
+ ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL
60
+ ```
61
+
62
+ **Set:**
63
+
64
+ | Var | Value |
65
+ |---|---|
66
+ | `ANTHROPIC_BASE_URL` | `http://127.0.0.1:<proxyPort>` when a proxy is used, else `baseUrl` (which must **not** end in `/v1`) |
67
+ | `ANTHROPIC_API_KEY` | the provider key, or the proxy token when proxying |
68
+ | `ANTHROPIC_MODEL` | `claudeCodeClientModelId(stripOneMContextSuffix(model), contextWindow)` |
69
+ | `CLAUDE_CODE_MAX_CONTEXT_TOKENS` | `resolveContextWindow(bareModel, contextWindow)` |
70
+ | `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY` | `1` when `enableGatewayDiscovery` (switch-menu mode) |
71
+ | `ENABLE_TOOL_SEARCH` | `true` — defer MCP tools like native Claude Code (`applyClaudeCodeThirdPartyCompat`) |
72
+ | `CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT` | `0` — keep the full system prompt on proxy routes |
73
+
74
+ On the **anthropic direct-passthrough** path, the single-model launch additionally sets `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1` to strip beta headers on the direct hop. On proxy routes the betas stay enabled so tool search works through the local proxy.
75
+
76
+ `detectConflicts()` reports which of these vars were present (shown in `--dry-run` and warnings) so a user can see what was scrubbed.
77
+
78
+ ---
79
+
80
+ ## Interactive key setup
81
+
82
+ `resolveOrCollectApiKey(simulate?, trace?)` (`src/key-setup.ts`) is called for the OpenCode Zen/Go key. On startup it silently calls the credential-store read first — if a key is found, no prompt appears. Otherwise it prompts for paste and offers platform-specific save options. In every case `process.env['OPENCODE_API_KEY']` is set immediately so the key is live for the current session regardless of save choice.
83
+
84
+ | Platform | Options |
85
+ |---|---|
86
+ | **macOS** | Keychain only · Keychain + `~/.zshrc` autoload · shell profile (plaintext) · session only |
87
+ | **Windows** | Credential Manager · `setx` user env var (plaintext) · session only |
88
+ | **Linux desktop** | Secret Service (GNOME Keyring / KWallet) · shell profile (plaintext) · session only |
89
+ | **Linux headless** | shell profile · session only (with a note explaining why secure storage is unavailable) |
90
+
91
+ Notes:
92
+
93
+ - The macOS autoload line uses the `security` CLI directly so the shell can source it: `export OPENCODE_API_KEY="$(security find-generic-password -s rflectr -a rflectr -w 2>/dev/null)"`.
94
+ - `setx` is invoked with piped stdio to suppress its "SUCCESS" stdout.
95
+ - Secret Service availability is probed with a test `getPassword()` (`isSecretServiceAvailable()`); if the daemon isn't running the option is hidden.
96
+ - `detectShellProfile()` chooses the right profile file per platform/shell (`~/.zshrc`, `~/.bash_profile`, `~/.bashrc`, `~/.profile`).
97
+
98
+ ---
99
+
100
+ ## Trust boundaries
101
+
102
+ ```mermaid
103
+ flowchart TD
104
+ subgraph trusted["Trusted — rflectr process"]
105
+ keyring["OS keyring"]
106
+ registry["providers.json (no secrets)"]
107
+ env["buildChildEnv()"]
108
+ end
109
+ subgraph child["Child host (Claude Code / Codex / Gemini)"]
110
+ proc["host process"]
111
+ end
112
+ subgraph net["Network"]
113
+ prov["upstream provider"]
114
+ end
115
+ keyring -->|resolved at launch| env
116
+ env -->|"scrubbed env + proxy token"| proc
117
+ proc -->|"127.0.0.1 only"| localproxy["local proxy"]
118
+ localproxy -->|"provider key (never to child)"| prov
119
+ ```
120
+
121
+ Key properties:
122
+
123
+ - The **provider's real key never reaches the child** when proxying — the child gets a random proxy token; the proxy holds the real key and calls upstream.
124
+ - The proxy binds `127.0.0.1` only, on a random port, and validates the token, so other local processes can't use it.
125
+ - Secrets are keyring-backed by default; plaintext options (`setx`, shell profile) are opt-in and clearly labelled.
126
+
127
+ ### Server-mode caveat
128
+
129
+ The `server` command can bind in network mode and asks for a server password (`isAuthorized`, `sanitizeCredential` in `src/server/auth.ts`). When exposed beyond localhost, that password is the only gate — see [`../infrastructure/server-gateway.md`](../infrastructure/server-gateway.md).
@@ -0,0 +1,154 @@
1
+ # Documentation Framework
2
+
3
+ > Category: Standards | Version: 1.0 | Date: (fill in on init) | Status: Canonical
4
+
5
+ The single source of truth for how documentation is written in this repository. Every document — feature PRDs, issue PRDs, QA reports, architecture docs, API references, guides — must conform to the standards defined here. If a document type is not covered, add a new section to this file rather than inventing a local convention.
6
+
7
+ ---
8
+
9
+ ## 1. Document Types
10
+
11
+ | Type | Purpose | Location | Primary audience |
12
+ |---|---|---|---|
13
+ | **Issue IRD** | Implementation plan for a specific GitHub issue | `library/requirements/issues/issue-<###>-<title>/ird-issue-<###>-<title>.md` | Implementation engineer |
14
+ | **Feature PRD** | Planned feature spec (forward or retroactive) | `library/requirements/features/feature-<###>-<title>/prd-feature-<###>-<title>.md` (or `prd-feature-<###>-<title>-ck-<clickupId>.md` if from ClickUp) | Implementation engineer |
15
+ | **QA Report (tied)** | Audit of an implementation against its plan | The plan's own `reports/<date>-qa-report.md` subfolder | Team lead, author of the feature |
16
+ | **QA Report (standalone)** | Audit not tied to a single plan | `library/qa/<domain>/<date>-qa-report.md` | Team lead, audit reviewer |
17
+ | **Architecture Doc** | System design, data flows, component relationships | `library/knowledge-base/architecture/` | Senior engineers, architects |
18
+ | **API Reference** | Endpoint-by-endpoint documentation with schemas | `library/knowledge-base/api/` | Frontend devs, API consumers |
19
+ | **How-to Guide** | Runbooks for setup, testing, deploying, adding features | `library/knowledge-base/how-to-guides/` | New engineers, DevOps |
20
+ | **Integration Doc** | Third-party service configuration and error handling | `library/knowledge-base/integrations/` | DevOps, engineers wiring services |
21
+ | **UX/UI Standard** | Visual design language — tokens, components, patterns | `library/knowledge-base/design/` | Designers, frontend devs |
22
+ | **Feature Doc** | Completed feature reference (post-ship) | `library/knowledge-base/features/` | Any engineer joining the project |
23
+ | **Spec** | Feature-level handoff spec for a UI flow | `library/knowledge-base/specs/` | Frontend engineers |
24
+ | **Product Brief** | Product vision, scope, roadmap | `library/knowledge-base/product/` | Team, stakeholders |
25
+ | **Standards Doc** | Rules for writing documentation itself | `library/knowledge-base/standards/` | All contributors |
26
+ | **Release Notes** | What changed in each release | `library/knowledge-base/releases/` | All team members |
27
+
28
+ ---
29
+
30
+ ## 2. Universal Document Header
31
+
32
+ Every markdown file under `library/knowledge-base/` starts with:
33
+
34
+ ```markdown
35
+ # <Document Title>
36
+
37
+ > Category: <Type> | Version: <X.Y> | Date: <Month YYYY> | Status: <Active | Draft | Archived>
38
+
39
+ <One-sentence description of what this document covers and who should read it.>
40
+
41
+ **Related:**
42
+ - [Link to related doc]
43
+ - [Link to source code: `src/path/to/file.ts`]
44
+ ```
45
+
46
+ - **Version** — starts at `1.0`; patch bumps (`1.0` → `1.1`) for additions, minor bumps (`1.x` → `2.0`) for reorganizations.
47
+ - **Date** — current month/year on the last meaningful edit.
48
+ - **Status** values:
49
+ - `Active` — current, should be kept up to date
50
+ - `Draft` — work in progress, not authoritative
51
+ - `Archived` — historical, no longer maintained
52
+ - `Canonical` — (for standards docs only) highest authority; overrides ad-hoc conventions
53
+
54
+ Requirements-type docs (issue IRDs, feature PRDs, QA reports) use a different header format documented in their respective guides.
55
+
56
+ ---
57
+
58
+ ## 3. Filename Conventions
59
+
60
+ | Document type | Folder + filename pattern | Example |
61
+ |---|---|---|
62
+ | Issue IRD | `issue-<###>-<title>/ird-issue-<###>-<title>.md` (with sibling `reports/`) | `issue-046-stale-cached-responses/ird-issue-046-stale-cached-responses.md` |
63
+ | Feature PRD | `feature-<###>-<title>/prd-feature-<###>-<title>.md` (with sibling `reports/`) | `feature-007-user-profile-export/prd-feature-007-user-profile-export.md` |
64
+ | Feature PRD (from ClickUp) | `feature-<###>-<title>/prd-feature-<###>-<title>-ck-<clickupId>.md` | `feature-007-user-profile-export/prd-feature-007-user-profile-export-ck-86c8wq2k1.md` |
65
+ | QA report (tied to plan) | `<plan-folder>/reports/<date>-qa-report.md` | `feature-007-user-profile-export/reports/2026-04-26-qa-report.md` |
66
+ | QA report (standalone) | `library/qa/<domain>/<date>-qa-report.md` | `library/qa/auth/2026-04-26-qa-report.md` |
67
+ | Knowledge-base | `<domain>/<kebab-slug>.md` (no numeric prefix) | `architecture/authentication-flow.md` |
68
+
69
+ **Numbering rules:**
70
+ - `<###>` is **3-digit zero-padded** (`006`, `046`, `093`, `100`). 4+ digit natural width.
71
+ - Issue numbers follow the GitHub issue number.
72
+ - Feature numbers are repo-local sequential; take `max + 1` from existing folders (open + `completed/`).
73
+ - Titles are lowercase kebab-case, ≤60 chars.
74
+ - The optional ClickUp suffix `-ck-<clickupId>` goes on the **main file only**, never on the folder name.
75
+
76
+ ---
77
+
78
+ ## 4. Folder Location Rules
79
+
80
+ | Folder | Meaning |
81
+ |---|---|
82
+ | `library/requirements/features/feature-<###>-<title>/` | Feature work in progress. |
83
+ | `library/requirements/features/completed/feature-<###>-<title>/` | Feature has shipped. Move the entire folder (PRD + `reports/`). |
84
+ | `library/requirements/issues/issue-<###>-<title>/` | Issue work in progress (GitHub issue OPEN). |
85
+ | `library/requirements/issues/completed/issue-<###>-<title>/` | Issue has been resolved (GitHub issue CLOSED). Move the entire folder (IRD + `reports/`). Symmetric to features. |
86
+ | `<plan-folder>/reports/` | QA reports tied to that specific feature/issue. Travel with the folder when it moves. |
87
+ | `library/qa/<domain>/` | Standalone QA reports — broad audits not tied to a single plan. |
88
+
89
+ Move folders when status changes. Never edit lifecycle state in frontmatter alone.
90
+
91
+ ---
92
+
93
+ ## 5. Writing Rules (all doc types)
94
+
95
+ 1. **Ground every claim in code.** Quote source with file path + line range; never paraphrase signatures.
96
+ 2. **One topic per document.** Split if a doc exceeds ~500 lines.
97
+ 3. **Progressive disclosure.** Open with "why this exists" and "who should read it"; deep details below.
98
+ 4. **Link out, don't duplicate.** If another doc covers a subtopic, link to it.
99
+ 5. **Diagrams use mermaid.** Prefer `flowchart TD` or `sequenceDiagram`. No explicit colors.
100
+ 6. **No time-sensitive language.** Avoid "currently", "recently", "as of". Use explicit dates.
101
+ 7. **No personal opinions.** Docs describe decisions and rationale, not preferences.
102
+
103
+ ---
104
+
105
+ ## 6. Cross-Linking Conventions
106
+
107
+ - Use relative paths: `[title](../relative/path.md)`.
108
+ - Link to code with file paths (and line numbers where useful): `` `src/routes/users.ts:42-80` ``.
109
+ - PRDs and IRDs link to their related issues, features, and QA reports in a **Related** section at the end.
110
+ - Knowledge-base docs link to the PRDs that drove them (when applicable) and to source code.
111
+
112
+ ---
113
+
114
+ ## 7. Diagram Rules
115
+
116
+ - Mermaid preferred (renders everywhere GitHub does).
117
+ - Use `flowchart TD` (top-down) for process flows; `sequenceDiagram` for temporal flows; `erDiagram` for data models.
118
+ - Node IDs: no spaces (use `camelCase` or `under_scores`).
119
+ - No explicit colors (breaks dark mode).
120
+ - No `click` events.
121
+ - Quote labels containing parentheses, brackets, or colons.
122
+
123
+ ---
124
+
125
+ ## 8. Versioning + Dates
126
+
127
+ - **Versioning** is per-document, not repo-wide. Bump on meaningful content change.
128
+ - **Dates** use the current month/year (from the system clock), not arbitrary timestamps.
129
+ - Each document optionally ends with a **Changelog** section listing version bumps.
130
+
131
+ ---
132
+
133
+ ## 9. Ownership
134
+
135
+ - Requirements docs (issue IRDs, feature PRDs) are owned by the implementation author. QA reports are owned by `quality-guardian`.
136
+ - Knowledge-base docs are owned by the team collectively — anyone may edit with a PR.
137
+ - Standards docs (this file included) require team consensus before changing.
138
+
139
+ ---
140
+
141
+ ## 10. Bootstrap — After `initialize`
142
+
143
+ When `library-guardian initialize` seeds a repo:
144
+
145
+ 1. Replace the placeholder "(fill in on init)" in the header above with the current month/year.
146
+ 2. Replace any project-name placeholders in the seeded README files with your repo's actual name.
147
+ 3. Edit any section of this framework that doesn't match your team's conventions — then commit.
148
+ 4. Start using the agent: ingest issues, plan features, document architecture.
149
+
150
+ ---
151
+
152
+ ## Changelog
153
+
154
+ - v1.0 — Initial template seeded by `library-guardian`. Customize per repo.
@@ -0,0 +1,49 @@
1
+ ---
2
+ ai_description: |
3
+ This folder contains customer-facing / end-user documentation.
4
+ Approved sub-folders: overview/, guides/, faqs/, and any domain
5
+ folder explicitly designated public by the team.
6
+ Do NOT file internal engineering docs, ADRs, pricing strategy, or
7
+ security-sensitive material here.
8
+ Write path: library/knowledge/public/<domain>/<kebab-slug>.md.
9
+ All files here may eventually be surfaced in the public help center
10
+ (Phase 2). Mark each doc with the standard knowledge-base header:
11
+ Category / Version / Date / Status.
12
+ human_description: |
13
+ Customer-facing documentation. Content here may be published externally.
14
+ - overview/: what this product is, glossary, elevator pitch
15
+ - guides/: how-to guides written for users, not developers
16
+ - faqs/: frequently asked questions
17
+ Only add content here that you are comfortable sharing publicly.
18
+ Internal notes, pricing strategy, and architecture docs belong in
19
+ knowledge/private/ instead.
20
+ ---
21
+
22
+ # Knowledge — Public
23
+
24
+ Customer-facing documentation for **rflectr** by [Legion Code Inc.](https://github.com/legioncodeinc) Anything in this folder may eventually be published to the help center.
25
+
26
+ ## Documentation map
27
+
28
+ **Start here:** [What is rflectr?](overview/what-is-rflectr.md)
29
+
30
+ | Section | Docs |
31
+ |---|---|
32
+ | [Overview](overview/) | [What is rflectr?](overview/what-is-rflectr.md) |
33
+ | [Guides](guides/) | [Providers](guides/providers.md) · [Claude Desktop](guides/claude-desktop.md) · [Codex](guides/codex.md) · [Gemini CLI](guides/gemini-cli.md) · [API Server](guides/api-server.md) · [AI Agents](guides/ai-agents.md) · [Model Compatibility](guides/model-compatibility.md) |
34
+ | [FAQs](faqs/) | [Troubleshooting](faqs/troubleshooting.md) |
35
+
36
+ ## Approved sub-folders
37
+
38
+ | Folder | Contents |
39
+ |---|---|
40
+ | `overview/` | What this product is, glossary, elevator pitch, high-level FAQs |
41
+ | `guides/` | Step-by-step user guides (written for customers, not developers) |
42
+ | `faqs/` | Frequently asked questions from customers |
43
+
44
+ ## What does NOT belong here
45
+
46
+ - Internal architecture docs or ADRs
47
+ - Pricing strategy or competitive analysis
48
+ - Engineering standards
49
+ - Anything you would not want a customer to read
@@ -0,0 +1,7 @@
1
+ # FAQs
2
+
3
+ Common questions and fixes.
4
+
5
+ | Doc | Covers |
6
+ |---|---|
7
+ | [troubleshooting.md](troubleshooting.md) | Launch issues with `rflectr claude` — the "Not logged in" prompt, placeholder keys, cloud-builtin providers, and `--trace`. |
@@ -0,0 +1,92 @@
1
+ # Troubleshooting
2
+
3
+ > Category: FAQ | Version: 1.0 | Date: June 2026 | Status: Active
4
+
5
+ Common issues when launching **Claude Code** through `rflectr claude`. For Claude Desktop gateway issues, see the [Claude Desktop guide](../guides/claude-desktop.md). For agent/headless issues, see [AI Agents & automation](../guides/ai-agents.md).
6
+
7
+ ---
8
+
9
+ ## "Not logged in · Please run /login" after picking a model
10
+
11
+ **What you see:** Claude Code starts and shows the right model in the status bar (e.g. `moonshotai/kimi-k2.6`), but sending a message returns `Not logged in · Please run /login`.
12
+
13
+ **Common cause — you chose "No" on the API key prompt.** When Claude Code detects an `ANTHROPIC_API_KEY` in the session (rflectr sets this for your chosen provider), it may ask:
14
+
15
+ ```text
16
+ Detected a custom API key in your environment
17
+ Do you want to use this API key?
18
+ 1. Yes
19
+ 2. No (recommended)
20
+ ```
21
+
22
+ If you pick **No**, Claude Code remembers that and refuses to use the key. rflectr is routing through your provider correctly — Claude Code is blocking the key you rejected. This is **not** a rflectr bug and doesn't mean your provider is misconfigured.
23
+
24
+ **Fix — approve the key in Claude Code's config.** Claude Code stores your answer in `~/.claude.json` under `customApiKeyResponses`.
25
+
26
+ 1. Quit Claude Code.
27
+ 2. Open `~/.claude.json`.
28
+ 3. Find the key suffix shown in the prompt (the last part of the masked key, e.g. `iFYB03v8xy4E-xJEYpN8`).
29
+ 4. Move that suffix from `rejected` to `approved`:
30
+
31
+ ```json
32
+ "customApiKeyResponses": {
33
+ "approved": ["anything", "iFYB03v8xy4E-xJEYpN8"],
34
+ "rejected": []
35
+ }
36
+ ```
37
+
38
+ 5. Save and run `rflectr claude` again.
39
+
40
+ > 💡 **Easier next time:** choose **Yes** when the prompt appears — Claude Code remembers approved keys and won't ask again.
41
+
42
+ **If you use Claude Max / Pro elsewhere:** you may also have a real Anthropic key in your shell (`~/.zshrc`, etc.). That's fine for other tools. rflectr replaces `ANTHROPIC_API_KEY` in the Claude Code child process with your **provider** key (OpenCode, Nvidia, Groq, …). Pick **Yes** when launching through rflectr.
43
+
44
+ ---
45
+
46
+ ## Provider works in `rflectr models` but not in `providers list`
47
+
48
+ Zen and Go are **cloud builtins** — they appear when you have an OpenCode API key, even if they aren't saved in `~/.rflectr/providers.json`. `rflectr providers list` shows them tagged `· cloud builtin`. Imported BYOK providers (Anthropic, Nvidia, Groq, …) come from the registry file.
49
+
50
+ ---
51
+
52
+ ## OpenCode import saved placeholder API keys
53
+
54
+ If you ran `rflectr providers import` on an older build and see refresh failures for Anthropic (`anything`) or Vertex (`a`), those came from **OpenCode's config**, not Claude Desktop.
55
+
56
+ **Current behavior:** import validates keys before saving to the keychain:
57
+
58
+ - Placeholders like `anything`, `a`, `ollama` → **not saved** (models still imported).
59
+ - Real keys → probed against the provider API before save.
60
+ - Vertex / Bedrock / Azure → key not saved (gcloud / AWS auth).
61
+
62
+ **To clean up an old placeholder:** re-run import (choose **Use imported** for each provider), or remove the provider and import again:
63
+
64
+ ```bash
65
+ rflectr providers import
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Use `--trace` for proxy / API errors
71
+
72
+ If a model fails mid-session (not the login prompt above):
73
+
74
+ ```bash
75
+ rflectr claude --trace
76
+ ```
77
+
78
+ After exit, rflectr prints errors from `~/.rflectr/logs/claude-debug.log` (secrets redacted in the summary). The proxy also logs to `~/.rflectr/logs/proxy-debug.log` when `--trace` is set.
79
+
80
+ ---
81
+
82
+ ## Still stuck?
83
+
84
+ 1. `rflectr providers list` — confirm the provider is there and enabled.
85
+ 2. `rflectr claude --dry-run` — preview provider, model, and endpoint without launching.
86
+ 3. Open a GitHub issue with the provider name, model id, and (redacted) error text.
87
+
88
+ ---
89
+
90
+ ## Related guides
91
+
92
+ - [Claude Desktop](../guides/claude-desktop.md) · [Codex](../guides/codex.md) · [AI Agents](../guides/ai-agents.md) · [Providers](../guides/providers.md)
@@ -0,0 +1,13 @@
1
+ # Guides
2
+
3
+ Step-by-step guides for each rflectr surface. New here? Read [What is rflectr?](../overview/what-is-rflectr.md) first.
4
+
5
+ | Guide | Use it to… |
6
+ |---|---|
7
+ | [providers.md](providers.md) | See every provider, its base URL, and gotchas; add or import providers. |
8
+ | [claude-desktop.md](claude-desktop.md) | Point Claude Desktop (Cowork + Code) at a local rflectr gateway, and revert cleanly. |
9
+ | [codex.md](codex.md) | Run the OpenAI Codex CLI or desktop app on any registry model. |
10
+ | [gemini-cli.md](gemini-cli.md) | Run the Google Gemini CLI on any registry model (experimental). |
11
+ | [api-server.md](api-server.md) | Run the local Anthropic/OpenAI-compatible gateway (`rflectr server`). |
12
+ | [ai-agents.md](ai-agents.md) | Drive rflectr from scripts, CI, and agents with boot flags and clean stdout. |
13
+ | [model-compatibility.md](model-compatibility.md) | Understand why a model is hidden, and how to change that. |