Repository navigation
feat(jetbrains): add Rules settings page; pin CLI to v7.4.13 #12437
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
af33ede
feat(jetbrains): add Rules settings page with instruction files and C…
kirillk c7c7d77
fix(jetbrains): pin CLI to v7.4.13 to repair cloud session history im…
kirillk d016a09
Merge branch 'main' into feat/jetbrains-rules-settings
kirillk 3d5ee24
fix(jetbrains): address rules settings PR review
kirillk 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/kilo-jetbrains": minor | ||
| --- | ||
|
|
||
| Add Rules settings for instruction files and Claude Code compatibility. | ||
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
85 changes: 85 additions & 0 deletions
85
...brains/frontend/src/main/kotlin/ai/kilocode/client/settings/base/SettingsContentEditor.kt
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,85 @@ | ||
| package ai.kilocode.client.settings.base | ||
|
|
||
| import ai.kilocode.client.session.ui.style.SessionUiStyle | ||
| import com.intellij.openapi.editor.EditorFactory | ||
| import com.intellij.openapi.fileTypes.FileType | ||
| import com.intellij.openapi.fileTypes.FileTypeManager | ||
| import com.intellij.openapi.fileTypes.PlainTextFileType | ||
| import com.intellij.openapi.fileTypes.UnknownFileType | ||
| import com.intellij.openapi.project.ProjectManager | ||
| import com.intellij.ui.EditorTextField | ||
| import com.intellij.ui.components.JBScrollPane | ||
| import com.intellij.util.ui.JBUI | ||
| import javax.swing.ScrollPaneConstants | ||
|
|
||
| /** | ||
| * Shared code-editor primitives for settings dialogs (skill content, instruction files). | ||
| * | ||
| * Keeps the tuned [EditorTextField] configuration, scroll chrome, and content-aware file-type | ||
| * detection in one place so pages don't each hand-roll their own editor. | ||
| */ | ||
| internal class SettingsContentField( | ||
| content: String, | ||
| fileType: FileType, | ||
| editable: Boolean, | ||
| ) : EditorTextField( | ||
| EditorFactory.getInstance().createDocument(content), | ||
| ProjectManager.getInstance().defaultProject, | ||
| fileType, | ||
| !editable, | ||
| false, | ||
| ) { | ||
| init { | ||
| border = JBUI.Borders.empty() | ||
| setOneLineMode(false) | ||
| addSettingsProvider { ed -> | ||
| ed.setBorder(JBUI.Borders.empty()) | ||
| ed.scrollPane.border = JBUI.Borders.empty() | ||
| ed.scrollPane.viewportBorder = JBUI.Borders.empty() | ||
| ed.settings.isUseSoftWraps = true | ||
| ed.settings.isPaintSoftWraps = false | ||
| ed.settings.isAdditionalPageAtBottom = false | ||
| ed.scrollPane.horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER | ||
| ed.scrollPane.verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED | ||
| } | ||
| } | ||
| } | ||
|
|
||
| internal fun settingsContentScroll(field: SettingsContentField) = JBScrollPane(field).apply { | ||
| viewportBorder = JBUI.Borders.empty( | ||
| JBUI.scale(SessionUiStyle.View.Prompt.SHELL_VERTICAL_PADDING), | ||
| JBUI.scale(SessionUiStyle.View.Prompt.SHELL_HORIZONTAL_PADDING), | ||
| JBUI.scale(SessionUiStyle.View.Prompt.SHELL_VERTICAL_PADDING), | ||
| JBUI.scale(SessionUiStyle.View.Prompt.SHELL_HORIZONTAL_PADDING), | ||
| ) | ||
| horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER | ||
| verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED | ||
| preferredSize = JBUI.size(720, 520) | ||
| } | ||
|
|
||
| /** | ||
| * Resolve a [FileType] for editor highlighting. Content syntax wins over the file name so | ||
| * extension-less locations still highlight correctly; unknown types fall back to plain text. | ||
| */ | ||
| internal fun settingsEditorFileType(name: String, content: String? = null): FileType { | ||
| val syntax = content?.syntaxName() | ||
| val fileName = syntax ?: name.substringAfterLast('/').substringAfterLast('\\').ifBlank { "file.txt" } | ||
| val type = FileTypeManager.getInstance().getFileTypeByFileName(fileName) | ||
| if (type == UnknownFileType.INSTANCE) return PlainTextFileType.INSTANCE | ||
| return type | ||
| } | ||
|
|
||
| private fun String.syntaxName(): String? { | ||
| val text = trimStart() | ||
| if (text.isBlank()) return null | ||
| if (text.looksHtml()) return "index.html" | ||
| if (text.looksMarkdown()) return "content.md" | ||
| return null | ||
| } | ||
|
|
||
| private fun String.looksHtml() = contains(Regex("^\\s*(<!doctype\\s+html|<html\\b|<body\\b|</?(h[1-6]|p|pre|code|ul|ol|li|blockquote|br)\\b)", RegexOption.IGNORE_CASE)) | ||
|
|
||
| private fun String.looksMarkdown() = lineSequence().any { line -> | ||
| line.matches(Regex("\\s{0,3}(#{1,6}\\s+.+|[-*+]\\s+.+|\\d+\\.\\s+.+|```.*|>\\s+.+)")) || | ||
| line.contains(Regex("(`[^`]+`|\\[[^]]+][(][^)]+[)])")) | ||
| } |
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
Oops, something went wrong.
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.