-
Notifications
You must be signed in to change notification settings - Fork 0
feat: byot. #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: byot. #21
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # BYOT Setup for GitHub in @knighted/develop | ||
|
|
||
| This guide explains how to create and use a fine-grained GitHub Personal Access Token (PAT) for the BYOT flow in `@knighted/develop`. | ||
|
|
||
| ## What BYOT does in the app | ||
|
|
||
| When the AI/BYOT feature is enabled, the token is used to: | ||
|
|
||
| - authenticate GitHub API requests | ||
| - load repositories where you have write access | ||
| - let you choose which repository to work with | ||
|
|
||
| As additional AI/PR features roll out, the same token is also used for model and repository operations that require the configured permissions. | ||
|
|
||
| ## Privacy and storage behavior | ||
|
|
||
| - Your token is stored only in your browser `localStorage`. | ||
| - The token is never sent to any service except the GitHub endpoints required by the feature. | ||
| - You can remove it at any time using the delete button in the BYOT controls. | ||
|
|
||
| ## Enable the BYOT feature | ||
|
|
||
| Use one of these options: | ||
|
|
||
| 1. Add `?feature-ai=true` to the app URL. | ||
| 2. Set `localStorage` key `knighted:develop:feature:ai-assistant` to `true`. | ||
|
|
||
| ## Create a fine-grained PAT | ||
|
|
||
| Create a fine-grained PAT in GitHub settings and grant the permissions below. | ||
|
|
||
| - Repository permissions screenshot: [docs/media/byot-repo-perms.png](docs/media/byot-repo-perms.png) | ||
| - Models permission screenshot: [docs/media/byot-model-perms.png](docs/media/byot-model-perms.png) | ||
|
|
||
| <img src="media/byot-repo-perms.png" alt="Repository PAT permissions" width="560" /> | ||
| <img src="media/byot-model-perms.png" alt="Models PAT permission" width="560" /> | ||
|
|
||
| ### Repository permissions | ||
|
|
||
| - Contents: Read and write | ||
| - Pull requests: Read and write | ||
| - Metadata: Read-only (required) | ||
|
|
||
| ### Account permissions | ||
|
|
||
| - Models: Read-only | ||
|
|
||
| ### Repository access scope | ||
|
|
||
| Use either of these scopes depending on your needs: | ||
|
|
||
| - Only select repositories | ||
| - All repositories | ||
|
|
||
| `@knighted/develop` will only show repositories where your token has write access. | ||
|
|
||
| ## Recommended setup flow | ||
|
|
||
| 1. Create token with the permissions above. | ||
| 2. Open `@knighted/develop` with `?feature-ai=true`. | ||
| 3. Paste token into the BYOT input and click add. | ||
| 4. Verify repository list loads. | ||
| 5. Select your target repository. | ||
|
|
||
| ## Screenshots | ||
|
|
||
| The screenshots above show the recommended repository and account permission settings. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| const aiFeatureStorageKey = 'knighted:develop:feature:ai-assistant' | ||
| const aiFeatureQueryKey = 'feature-ai' | ||
|
|
||
| const parseBooleanLikeValue = value => { | ||
| if (typeof value !== 'string') { | ||
| return null | ||
| } | ||
|
|
||
| const normalized = value.trim().toLowerCase() | ||
|
|
||
| if (['1', 'true', 'on', 'yes', 'enabled'].includes(normalized)) { | ||
| return true | ||
| } | ||
|
|
||
| if (['0', 'false', 'off', 'no', 'disabled'].includes(normalized)) { | ||
| return false | ||
| } | ||
|
|
||
| return null | ||
| } | ||
|
|
||
| const readBooleanFromLocalStorage = key => { | ||
| try { | ||
| const storedValue = localStorage.getItem(key) | ||
| return parseBooleanLikeValue(storedValue) | ||
| } catch { | ||
| return null | ||
| } | ||
| } | ||
|
|
||
| const readBooleanFromQueryParam = key => { | ||
| if (typeof window === 'undefined') { | ||
| return null | ||
| } | ||
|
|
||
| const params = new URLSearchParams(window.location.search) | ||
| if (!params.has(key)) { | ||
| return null | ||
| } | ||
|
|
||
| return parseBooleanLikeValue(params.get(key)) | ||
| } | ||
|
|
||
| export const isAiAssistantFeatureEnabled = () => { | ||
| const queryValue = readBooleanFromQueryParam(aiFeatureQueryKey) | ||
| if (queryValue !== null) { | ||
| return queryValue | ||
| } | ||
|
|
||
| const localStorageValue = readBooleanFromLocalStorage(aiFeatureStorageKey) | ||
| if (localStorageValue !== null) { | ||
| return localStorageValue | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| export const setAiAssistantFeatureEnabled = isEnabled => { | ||
| try { | ||
| localStorage.setItem(aiFeatureStorageKey, isEnabled ? 'true' : 'false') | ||
| } catch { | ||
| /* noop */ | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.