Skip to content

Commit 2df935b

Browse files
feat: round out phase 5 of chat migration.
1 parent 872ac13 commit 2df935b

13 files changed

Lines changed: 1263 additions & 1129 deletions

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,18 @@ in the same UI.
7272
## BYOT Guide
7373

7474
- GitHub PAT setup and usage: [docs/byot.md](docs/byot.md)
75+
- OpenRouter key setup for AI chat: [docs/openrouter-byok.md](docs/openrouter-byok.md)
7576

7677
## Fine-Grained PAT Quick Setup
7778

78-
For PR/BYOT and AI chat flows, use a fine-grained GitHub PAT and follow the
79-
existing setup guide:
79+
For PR/BYOT flows, use a fine-grained GitHub PAT and follow the setup guide:
8080

8181
- Full setup and behavior: [docs/byot.md](docs/byot.md)
8282
- Repository permissions screenshot: [docs/media/byot-repo-perms.png](docs/media/byot-repo-perms.png)
83-
- Models permission screenshot: [docs/media/byot-model-perms.png](docs/media/byot-model-perms.png)
83+
84+
For AI chat, connect an OpenRouter key from the chat drawer:
85+
86+
- OpenRouter setup and limits: [docs/openrouter-byok.md](docs/openrouter-byok.md)
8487

8588
## License
8689

docs/ai-chat-context-and-payload-strategy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Potential ideas:
177177

178178
Current strategy has focused Playwright coverage for the chat drawer behavior and context policy assertions in:
179179

180-
- playwright/github-byot-ai.spec.ts
180+
- playwright/chat/ai-chat.spec.ts
181181

182182
## Scope note
183183

docs/byot.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BYOT Setup for GitHub in @knighted/develop
22

3-
This guide explains how to create and use a fine-grained GitHub Personal Access Token (PAT) for the BYOT flow in `@knighted/develop`.
3+
This guide explains how to create and use a fine-grained GitHub Personal Access Token (PAT) for repository and pull-request workflows in `@knighted/develop`.
44

55
## What BYOT does in the app
66

@@ -11,7 +11,9 @@ BYOT controls are available by default. The token is used to:
1111
- let you choose which repository to work with
1212
- use PR context features (Open PR / Push Commit flows)
1313

14-
The same token is also used for GitHub Models requests in AI chat flows.
14+
AI chat no longer uses the GitHub PAT. Chat uses a separate OpenRouter API key.
15+
16+
- OpenRouter key setup for chat: [docs/openrouter-byok.md](docs/openrouter-byok.md)
1517

1618
## Privacy and storage behavior
1719

@@ -24,21 +26,15 @@ The same token is also used for GitHub Models requests in AI chat flows.
2426
Create a fine-grained PAT in GitHub settings and grant the permissions below.
2527

2628
- Repository permissions screenshot: [docs/media/byot-repo-perms.png](docs/media/byot-repo-perms.png)
27-
- Models permission screenshot: [docs/media/byot-model-perms.png](docs/media/byot-model-perms.png)
2829

2930
<img src="media/byot-repo-perms.png" alt="Repository PAT permissions" width="560" />
30-
<img src="media/byot-model-perms.png" alt="Models PAT permission" width="560" />
3131

3232
### Repository permissions
3333

3434
- Contents: Read and write
3535
- Pull requests: Read and write
3636
- Metadata: Read-only (required)
3737

38-
### Account permissions
39-
40-
- Models: Read-only
41-
4238
### Repository access scope
4339

4440
Use either of these scopes depending on your needs:
@@ -55,7 +51,7 @@ Use either of these scopes depending on your needs:
5551
3. Paste token into the BYOT input and click add.
5652
4. Verify repository list loads.
5753
5. Select your target repository.
58-
6. Use AI chat as needed after connecting your token.
54+
6. Use PR and repository workflows after connecting your token.
5955

6056
## Screenshots
6157

docs/localstorage-state.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ This document is the source of truth for what `@knighted/develop` stores in `loc
88

99
1. `knighted:develop:github-pat`
1010
- GitHub personal access token used for API calls.
11-
2. `knighted-develop:render-mode`
11+
2. `knighted:develop:openrouter-key`
12+
- OpenRouter API key used by AI chat requests.
13+
3. `knighted-develop:render-mode`
1214
- Last selected render mode (`dom` or `react`).
13-
3. Theme/UI preference keys managed by layout theme modules.
15+
4. Theme/UI preference keys managed by layout theme modules.
1416

1517
## Not Allowed In localStorage
1618

docs/openrouter-byok.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# OpenRouter BYOK Setup for AI Chat in @knighted/develop
2+
3+
This guide explains how to create and use an OpenRouter API key for AI chat in `@knighted/develop`.
4+
5+
## What this key does
6+
7+
The OpenRouter key is used only for AI chat requests and model catalog requests in the chat drawer.
8+
9+
- It enables chat completions against `https://openrouter.ai/api/v1/chat/completions`.
10+
- It enables loading model options from `https://openrouter.ai/api/v1/models`.
11+
12+
The key is independent from the GitHub PAT used by PR and repository workflows.
13+
14+
## Free model limits
15+
16+
OpenRouter free models still require an API key.
17+
18+
- Free models have no per-token charge.
19+
- Accounts without purchased credits are currently limited to 50 requests per day.
20+
- Accounts that have purchased at least $10 in credits are currently limited to 1000 requests per day.
21+
22+
## Privacy and storage behavior
23+
24+
- Your OpenRouter key is stored only in your browser `localStorage`.
25+
- The key is sent only to OpenRouter endpoints used by chat.
26+
- The key is never sent to GitHub endpoints.
27+
- You can remove it any time from the chat drawer key controls.
28+
29+
## Create and connect an OpenRouter key
30+
31+
1. Open https://openrouter.ai/keys and create an API key.
32+
2. Open the Chat drawer in `@knighted/develop`.
33+
3. Paste the key into the `OpenRouter API key` input.
34+
4. Click `Save OpenRouter API key`.
35+
5. Send a test prompt and confirm the assistant response appears.
36+
37+
## Related docs
38+
39+
- GitHub PAT setup for PR/repository workflows: [docs/byot.md](docs/byot.md)
40+
- Local storage keys: [docs/localstorage-state.md](docs/localstorage-state.md)

docs/openrouter-migration-plan.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Chat no longer depends on a selected repository. Local-mode users can chat to up
4343
editor tab with no GitHub connection at all. A selected repository remains useful context
4444
when one is connected, but it is never a precondition.
4545

46-
## Implementation status (updated 2026-09-06)
46+
## Implementation status (updated 2026-09-07)
4747

4848
### Done
4949

@@ -67,20 +67,21 @@ when one is connected, but it is never a precondition.
6767
- Tests and checks completed for the implemented behaviors:
6868
- Focused Playwright coverage added for intent gating, tab-context sending, and apply behavior.
6969
- Lint checks are passing.
70-
71-
### Remaining
72-
73-
- Phase 4 model catalog work is not yet implemented in runtime code:
74-
- No live `/api/v1/models` fetch integration yet.
75-
- Free vs paid grouping in the model picker is still pending.
76-
- Tool-support filtering from live model metadata is still pending.
77-
- Phase 5 remains partial:
78-
- Chat tests still live inside `playwright/github-byot-ai.spec.ts` rather than a split chat spec path.
79-
- Dedicated OpenRouter usage docs listed below are not fully completed.
80-
- Live production verification still pending for exhaustion states:
81-
- 402 out-of-credits behavior.
82-
- 429 rate-limit behavior.
83-
- Optional one-time migration notice behavior is still pending.
70+
- Chat test coverage is split into `playwright/chat/ai-chat.spec.ts`, with PR/BYOT
71+
coverage retained in `playwright/github-byot-ai.spec.ts`.
72+
- OpenRouter migration docs are in place (`docs/openrouter-byok.md`) and cross-linked
73+
from README/BYOT docs.
74+
- Phase 4 completed in runtime code:
75+
- Live `/api/v1/models` catalog fetch is wired in `src/modules/chat/api/models.js`.
76+
- Model picker groups models into Free and Paid sections.
77+
- Model catalog entries are filtered to tool-capable models.
78+
79+
### Remaining (non-blocking)
80+
81+
- Optional follow-up coverage:
82+
- Explicit targeted specs for 402/429 status messaging and catalog-fetch degradation.
83+
- Optional UX follow-up:
84+
- One-time migration notice on first load after upgrade.
8485

8586
### Correction to a common assumption
8687

0 commit comments

Comments
 (0)