Strip a leading U+FEFF from text before prepending a UTF-8/UTF-16 BOM so
round-tripping content that already carries a BOM character emits exactly
one BOM. Also clarifies the changeset that new files default to UTF-8.
- Drop the dead 'encoding = pre.encoding' initial value that was only
read if deriveNewContentsFromChunks threw, and that code path
returns before encoding is ever used.
- Inline pre.text into the read line so we don't bind a 'pre' local
just to destructure it once.
Main moved the Patch namespace out of packages/opencode/src/patch/index.ts
into patch/patch.ts and switched tool imports to the new
@opencode-ai/shared/filesystem and ../../src/tool barrels. Reapply the
encoding-aware read/write changes on top of the refactored patch.ts, and
update the integration test imports to match the new module layout.
Replace granular submodule imports with their parent barrel index
across snapshot diff source and related test files. This covers
util/log, util/filesystem, config/config, provider/provider,
tool/registry, tool/truncate, and the filesystem shared package.
Increase paste-summary trigger from 3 lines/150 chars to 5 lines/800
chars to reduce unnecessary summarization on small pastes. Add a branded
reauthentication hint when GitHub Copilot returns 403. Guard against
empty agent list during org switch in the model auto-update effect and
reformat multi-line ternary for readability. Relocate inline comment on
mercury exclusion in reasoning effort variants.
Per review: CJK and legacy single-byte encodings already passed the old
control-char heuristic (their bytes are all >= 0x80, never NUL), so the
full Encoding.detect pass in isBinaryFile was solving a non-problem for
them. The only realistic regression in the old heuristic is UTF-16 with
BOM, where the second byte of every ASCII character is 0x00 and fires
the NUL-byte early-return.
Replace the detect call with a 2-byte BOM check via a new
Encoding.hasUtf16Bom helper. Also reword the move/add inline markers in
patch/index.ts to note that Encoding.write handles mkdir.
Replaces the number-prefixed question-picker block with a full-width tinted
row: icon + suggestion text on the left, clickable action buttons on the
right. Removes keyboard shortcuts and the esc-dismiss hint -- dismissal
already happens automatically server-side when the user sends a new prompt.
Previously, the non-blocking inline SuggestBar never showed up because the
Suggest component used an early-return if/else that ran once at mount
(when no pending request existed yet) and never re-evaluated when the
suggestion arrived. Users saw 'Suggesting next step...' forever with no
way to accept or dismiss, which felt like the suggestion was blocking
the session again. Switching to <Switch>/<Match> so the branch updates
when the request lands makes the bar appear and be interactive.
Parallel bun test subprocesses can race between isPortInUse() and
listen(), causing the loser to crash with EADDRINUSE. Treat that error
as 'another instance owns the port' (same semantics as the isPortInUse
branch above) so the auto-connect test stops flaking in CI.
Extract inline Opus 4.7 adaptive effort logic into anthropicAdaptiveEfforts
helper, extend smallOptions to recognize Kilo Gateway alongside OpenRouter,
fix LSP test file path from lsp/index.ts to lsp/lsp.ts, and update xhigh
variant assertion to include display: "summarized".
Swap manual save-and-restore of Config.get for bun:test spyOn/mock.restore
across session-list and recall test suites, ensuring proper mock teardown
and consistent namespace imports.
Alphabetically sort import statements in the SDK codegen output and
reposition type declarations (EventInstallationUpdated,
EventSessionTurnOpen, SessionStatus, Todo, etc.) to match updated
code generation ordering. In the server instance router, assign the
chained route builder to a `full` variable before passing it to
`registerKiloRoutes` for clarity.
Moves the 'Run review?' suggestion picker out of the footer bar above the
prompt and into the conversation itself, at the position of the suggest
tool call. Frees up vertical space for reading while scrolling and
matches where the VS Code extension shows the same picker. Clicking an
option still accepts, digit keys 1/2 fast-accept when the prompt isn't
focused, and Esc dismisses. Blocking suggestions keep the above-prompt
overlay.
When every compaction round still overflowed the model context, SessionPrompt.runLoop would keep calling compaction forever and report the turn as completed. Cap attempts at three per turn and surface exhaustion as a ContextOverflowError on the assistant message with TurnClose reason=error.
Bump @opentelemetry/core, sdk-trace-base, sdk-trace-node, and
resources from 1.30.x to 2.6.1 and semantic-conventions from 1.28.0
to 1.40.0 in kilo-telemetry. Migrate to the new v2 API surface:
replace `new Resource()` with `resourceFromAttributes()`, rename
`parentSpanId` to `parentSpanContext`, and rename
`instrumentationLibrary` to `instrumentationScope` in span types and
tests. Alphabetically sort dependency entries in the opencode
package.json.
Remove synchronous Env.get/Env.all calls in provider, tool registry,
and model-cache modules, replacing them with effect-yielded env
lookups or direct process.env reads where appropriate. Thread resolved
env through patchCustomLoaderResult and kiloCustomLoaders dependency
type. Drop unused paste-summary import from prompt component, fix
createResource action call in session list dialog, add bell toggle KV
signal, and rewrite config-gitignore test to use proper Effect layers
instead of mocked AppRuntime. Update remaining import paths and test
module mocks to align with barrel re-exports.
Migrate all deep import paths across source and test files to
reference barrel index modules instead of direct file paths. This
covers config, provider, storage, util, tool, lsp, project, and
installation modules. Also moves provider promise helpers out of the
namespace block, switches Clipboard to namespace import style, fixes a
duplicate Filesystem import, removes the deleted paste-summary test,
and corrects snapshot cache typing and indentation.
Remove the standalone `packages/util` and `packages/server` workspace
packages, migrating all imports across app, kilo-ui, opencode, and ui
to use `@opencode-ai/shared/util/*` paths instead. Also fix the
VITE_KILO_CHANNEL env variable name in the type declaration and add a
null guard in the titlebar channel badge rendering.
- Encoding.detect: lowercase-compare UTF-32 rejection so jschardet's
uppercase 'UTF-32'/'UTF-32BE'/'UTF-32LE' labels no longer slip through
(iconv-lite happens to have utf-32 codecs that would then be accepted).
- Encoding.read: drop redundant Buffer.from wrap around readFile's
already-Buffer return value.
- EncodedIO: switch to Effect.tryPromise so I/O failures surface as
typed errors that .pipe(Effect.catch(...)) can recover from; the
apply_patch delete branch relies on this to translate read errors
into 'apply_patch verification failed'.
- Shrink kilocode_change blocks in edit.ts, write.ts, apply_patch.ts,
patch/index.ts, and read.ts to per-line inline markers where each
block was only wrapping 1-3 changed lines.
- Collapse the 'if (exists) { let contentOld; let encoding; ... }'
blocks in edit.ts and write.ts into a single ternary + destructure
that keeps all three lines self-contained and each independently
annotated.
- Remove the unused 'latin1' sample and fix the 'providEncoded' typo
in the encoding integration test file.
- Strengthen the apply_patch Shift_JIS test to assert exact bytes
instead of the weak 'does not contain these two UTF-8 bytes' check.
- Drop the stray .kilo/ and .kilocode/ lockfiles that were re-added
by an upstream 'wip' commit.
- Wire Readable.from through a named `stream` variable so the `lines`
helper can destroy it in the finally block, matching the previous
createReadStream pattern.
- Restore the 'Create parent directories', 'Handle file move', 'Regular
update', 'Read original file content', and 'For delete, we need to read
the current content' comments that were dropped when switching to
Encoding.write / Encoding.read. The explicit fs.mkdir calls are no
longer needed because Encoding.write mkdirs recursively, but the intent
comments still apply.
iconv-lite's utf-8 codec strips any leading BOM on decode and never emits
one on encode, so files that started with EF BB BF would lose their BOM
after an edit. Track UTF-8-with-BOM as a distinct synthetic encoding label
and re-prepend the BOM bytes on write so the round-trip keeps the file
byte-identical (modulo any actual edits).
- Restore the streaming createInterface loop in the `lines` helper so the
diff against main stays small; decode bytes with iconv-lite up front and
feed the resulting text through Readable.from.
- Drop 'new file' kilocode_change markers from files under kilocode/
directories (those paths are exempt from the annotation check).
- Tighten the changeset copy to sound like a user-facing release note.
Exercise Read/Write/Edit/ApplyPatch tools directly against files in
UTF-8, UTF-16 LE/BE (with BOM), Shift_JIS, EUC-JP, GB2312, Big5, EUC-KR,
Windows-1251, and KOI8-R to verify the tools decode input correctly and
round-trip bytes back to the original encoding. Also ensure UTF-16
BOMs survive the write pipeline.
Drop manual BOM parsing, UTF-32, and UTF-16-without-BOM detection: rely on
TextDecoder + jschardet + iconv-lite which already handle BOM round-tripping
for UTF-16 LE/BE. Move the encoding helpers and Effect wrappers into
packages/opencode/src/kilocode/ so shared tool files only carry targeted
kilocode_change markers.
Mark new plan follow-up sessions busy as soon as the tab opens so the UI
shows work is still in progress while the handover summary is generated.
Clear the temporary busy state if that pre-loop handover phase is aborted
or fails before the normal prompt loop takes over.