-
Notifications
You must be signed in to change notification settings - Fork 24
feat(kiloclaw): add Kilo CLI recovery agent #1657
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 all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b9146cb
feat(kiloclaw): add kilo CLI run feature (spawn, poll, UI)
RSO 6733919
Fix dev-CLI
RSO 79f6c8b
refactor(kiloclaw): use DB run ID in CLI run URL instead of prompt qu…
RSO a57c708
Remove debug info
RSO 10c7248
feat(kiloclaw): add admin CLI Runs tab with search and pagination
RSO f9f7a88
feat(kiloclaw): use KiloClaw default model for Kilo CLI runs
RSO 1623df0
feat(kiloclaw): add system context prompt template for Kilo CLI runs
RSO 89cf011
refactor(kiloclaw): use shared constants in prompt template, improve …
RSO 7ae3a42
refactor(kiloclaw): rebrand CLI run as recovery tool
RSO 32bf6dd
fix(kiloclaw): wrap long output lines and auto-scroll on all updates
RSO e11c9bc
chore: remove migration 0060 before rebase
RSO 758740c
chore(db): regenerate migration 0060 for kiloclaw_cli_runs after rebase
RSO bd5ff8c
chore: fix migration numbering, type errors, and formatting after rebase
RSO c44f538
docs(kiloclaw): update changelog entry to match recovery branding
RSO ab76b66
fix(kiloclaw): set baseURL in kilo CLI config instead of deleting it
RSO d9cb83c
fix(kiloclaw): scope CLI run status to requested run ID and add GDPR …
RSO 4338e58
fix(kiloclaw): revert baseURL config patch — delete stale field inste…
RSO 8fd33f7
perf(kiloclaw): lazy-load CLI run output instead of fetching with list
RSO 678d47b
fix(kiloclaw): scope cancelKiloCliRun DB update to specific run ID
RSO afee4f9
Merge branch 'main' into RSO/mousy-rest
RSO 9fdc4c3
chore(db): remove migration 0061 before merge with main
RSO 320c404
Merge remote-tracking branch 'origin/main' into RSO/mousy-rest
RSO e29785d
chore(db): regenerate migration 0064 after merge with main
RSO d2f111e
fix(kilo-app): fix unsafe type access in useForceUpdate hook
RSO 991e9db
Undo unwanted change
RSO 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
|
|
@@ -15,11 +15,19 @@ | |
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
|
|
||
| const KILO_CONFIG_DIR = '/root/.config/kilo'; | ||
| const CONFIG_FILE = 'opencode.json'; | ||
| export const KILO_CONFIG_DIR = '/root/.config/kilo'; | ||
| export const CONFIG_FILE = 'opencode.json'; | ||
|
|
||
| /** The Kilo CLI uses `kilo/` as the provider prefix, but KiloClaw uses `kilocode/`. */ | ||
| export function toKiloModelId(kilocodeModelId: string): string { | ||
| if (kilocodeModelId.startsWith('kilocode/')) { | ||
| return 'kilo/' + kilocodeModelId.slice('kilocode/'.length); | ||
| } | ||
| return kilocodeModelId; | ||
| } | ||
|
|
||
| export type KiloCliConfigDeps = { | ||
| mkdirSync: (dir: string, opts: { recursive: boolean }) => void; | ||
Check failureCode scanning / CodeQL Insecure temporary file High
Insecure creation of file in
the os temp dir Error loading related location Loading Insecure creation of file in the os temp dir Error loading related location Loading Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. Insecure creation of file in the os temp dir. |
||
| writeFileSync: (path: string, data: string, opts: { mode: number }) => void; | ||
| readFileSync: (path: string, encoding: 'utf8') => string; | ||
| existsSync: (path: string) => boolean; | ||
|
|
@@ -49,33 +57,48 @@ | |
| // No provider block needed — the KiloAuthPlugin auto-registers the "kilo" | ||
| // provider when KILO_API_KEY is in the environment (set by bootstrap). | ||
| if (isFreshInstall && !deps.existsSync(configPath)) { | ||
| const config = { | ||
| const config: Record<string, unknown> = { | ||
| $schema: 'https://app.kilo.ai/config.json', | ||
| permission: { edit: 'allow', bash: 'allow' }, | ||
| }; | ||
| if (env.KILOCODE_DEFAULT_MODEL) { | ||
| config.model = toKiloModelId(env.KILOCODE_DEFAULT_MODEL); | ||
| } | ||
| deps.mkdirSync(configDir, { recursive: true }); | ||
| deps.writeFileSync(configPath, JSON.stringify(config, null, 2), { mode: 0o600 }); | ||
| console.log('[kilo-cli] Seeded config at ' + configPath); | ||
| } | ||
|
|
||
| // Patch config on every boot (if it exists). | ||
| // Only writes when a change is actually made to avoid silent no-op writes. | ||
| if (deps.existsSync(configPath) && env.KILOCODE_API_BASE_URL) { | ||
| if (deps.existsSync(configPath)) { | ||
| try { | ||
| // JSON structure is open-ended (user may add arbitrary keys), so we use `any` | ||
| // rather than a strict schema. The patch only touches provider.kilo.options.baseURL. | ||
| // rather than a strict schema. | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const config: any = JSON.parse(deps.readFileSync(configPath, 'utf8')); | ||
| let dirty = false; | ||
|
|
||
| // Remove any stale provider.kilo.options.baseURL from the config file. | ||
| // Setting baseURL in opencode.json is broken (the Kilo CLI ignores it | ||
| // in certain code paths). The correct mechanism is the KILO_API_URL env | ||
| // var, which bootstrap sets from KILOCODE_API_BASE_URL. Early deployments | ||
| // may still have the broken field, so we scrub it on every boot. | ||
| if (config.provider?.kilo?.options?.baseURL) { | ||
| delete config.provider.kilo.options.baseURL; | ||
| dirty = true; | ||
| } | ||
|
|
||
| // Override the kilo provider's base URL for local dev (e.g., ngrok tunnel). | ||
| // In production this env var is not set and the built-in default is used. | ||
| config.provider = config.provider || {}; | ||
| config.provider.kilo = config.provider.kilo || {}; | ||
| config.provider.kilo.options = config.provider.kilo.options || {}; | ||
| config.provider.kilo.options.baseURL = env.KILOCODE_API_BASE_URL; | ||
| console.log('[kilo-cli] Patched base URL: ' + env.KILOCODE_API_BASE_URL); | ||
| // Sync Kilo CLI's model with the user's KiloClaw default model. | ||
| // Updated on every boot so model changes in KiloClaw settings take effect. | ||
| const defaultModel = env.KILOCODE_DEFAULT_MODEL; | ||
| if (defaultModel) { | ||
| config.model = toKiloModelId(defaultModel); | ||
| dirty = true; | ||
| } | ||
|
|
||
| deps.writeFileSync(configPath, JSON.stringify(config, null, 2), { mode: 0o600 }); | ||
| if (dirty) { | ||
| deps.writeFileSync(configPath, JSON.stringify(config, null, 2), { mode: 0o600 }); | ||
| } | ||
| } catch (err) { | ||
| console.error('[kilo-cli] Failed to patch config (corrupt JSON?), skipping:', err); | ||
| } | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replaces the
providers.kilo.options.baseURLsetting in theopencode.jsonconfig, which doesn't work as expected.