Repository navigation
Conversation
…ending the block
The generated OpenCode adapter is an auto-loaded module, so it is installed as a
managed block rather than a whole-file write. When the file on disk carried
content but none of our markers, the upsert appended the block anyway, even
though the block's own header tells readers to "remove the markers to take
ownership".
The appended prelude redeclares module-level names the user's own module also
declares -- `import { spawn }`, `const BIN`, `function augment` -- and both
sides declare a default export once the block itself carries one, so the result
cannot be parsed at all:
SyntaxError: Identifier 'spawn' has already been declared
The client then drops the whole extension with only a load warning to show for
it. A hand-port around DeusData#2204 is therefore not a durable end state.
Probe block ownership before writing. A marker-less file that carries content is
left alone and reported in both the real run and the dry run, instead of being
turned into an unparseable hybrid. An absent, empty, whitespace-only, or
already-ours file still installs or refreshes exactly as before.
Refs DeusData#2204
Signed-off-by: Cristian Castillo <c.a.c.m997@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The generated OpenCode adapter (
~/.config/opencode/plugins/cbm-augment.ts) is an auto-loaded module, so it is installed as a managed block rather than a whole-file write. That is deliberate: the directory is auto-loaded, so a user may legitimately keep their own module there.But when the file on disk carried content and none of our markers, the install appended our block to it anyway — even though the block's own header tells readers to "remove the markers to take ownership". That contradicts the promise and produces a file the client cannot parse.
Reproduction
install -yagainst 0.11.0, in an isolatedHOME, starting from the hand-port shape described in #2204:After the run the managed block sits after that content, so module-level names are declared twice:
OpenCode's loader then drops the whole extension and the only trace is a load warning. Once the block itself carries
export default(#2089), the same append turns into a duplicate default export instead. So a hand-port is not a durable end state — which is why #2385 matters — but the installer should not manufacture the broken file in the meantime.Change
cbm_text_managed_block_status()— a read-only ownership probe:0writable (absent, whitespace-only, or already ours),1the file carries content but none of our markers,-1unsafe state or I/O failure.install_generated_client_extension()probes before writing:--dry-run. The probe runs before generation so the preview names the refusal instead of promising a write the run will not make (the same honesty rule install on 0.9.1-rc.1 removes existing Claude Code hooks instead of installing them #1387 established for hook scripts).cbm_text_upsert_managed_block()and its other callers (instruction documents, where appending to a user's file is the intent) are untouched — the new semantics are scoped to the auto-loaded module case.If you would rather the run fail loudly than skip, that is a small change to the same call site; I picked "leave alone and say so" because it matches the ownership wording in the generated header.
Verification
End-to-end in isolated
HOMEs on the built binary:SyntaxErrorTests:
scripts/test.sh --suites config_text_edit— 23 passed, including the newconfig_text_managed_block_status_reports_foreign_module(absent / empty / whitespace / ours / foreign / unbalanced markers / malformed markers).scripts/test.sh --suites cli— 361 passed, 1 failed, and the newcli_extension_leaves_user_owned_module_untouched_issue2204is the+1over the baseline: it seeds a user-owned module, runs the dry run, and asserts both the warning and that the file is byte-identical afterwards (modelled on the existingcli_dry_run_predicts_refused_hook_script_issue1387).The single failure is pre-existing and unrelated. Same machine, same suite, same test:
mainat0ca6e7d(no changes)In both trees the failing test is
cli_registry_installs_gitlab_and_devin_lifecycle_contextwith the identical diagnosticplan=1 clean_plan=1 installed=0 cleaned=1 gitlab=1 devin=1 uninstall=0— it touches neither the OpenCode adapter nor the managed-block writer. Flagging it here so a redtest-unixjob is not read as fallout from this change.clang-format 20.1.8(CI's pinned version) reports no changes to any touched file.Refs #2204. The template side — registering the 2.x hooks in
setup— is #2385 and is deliberately not touched here. Happy to fold this into #2385 instead if you would rather keep the OpenCode changes on one branch.