The shell.env and experimental.session.compacting hooks dereferenced
output.env and output.prompt unconditionally. When OpenCode invokes a
hook without an output object, this threw TypeError: undefined is not an
object and aborted compaction entirely.
- shell.env: early-return when output is undefined
- experimental.session.compacting: guard the output.prompt/output.context
branches so a missing output no-ops instead of throwing
Add regression tests for both hooks covering the undefined-output case.
Fixes#3934
Cover byte identity without neighbors, ECC's decision unchanged in every mode, the anchored and clear-leader listing rule, Claude user, plugin and project discovery, the CLI snapshot round trip, the launch and hook surfaces, and a fixture on the shipped registry. Require the new module in the npm pack surface.
Exercise the real hook with isolated runtime directories. Verify that raw
cell content stays out of persisted metrics and is not executed, notebook
paths remain inert metadata, and traversal session IDs cannot select a
bridge file. Preserve the hook's pass-through input contract.
The focused notebook and bridge suites pass all 36 cases. Targeted
statement/line, branch and function coverage is 91.9%, 85.18% and 100%.
Changed-file ESLint and diff checks pass.
Resolve both sides of the source_doc containment check with
fs.realpathSync.native (falling back to fs.realpathSync). With the JS
realpath, a repo root reached through a Windows 8.3 short name stays in
short form while an in-repo symlink whose target uses the long-path form
resolves to the long form, so a legitimate in-repo doc was reported as
"resolves outside repository root". Escapes outside the repo are still
rejected.
Adds a cross-platform regression test that models differing JS and
native realpath results: in-repo docs are accepted through a short-form
root and an outside target is still rejected. It fails on the previous
implementation.
Not required for the #3882 Windows CI fix; kept as a separate commit so
it can be taken or dropped on its own.
A registered v1 project has CONTEXT.md but no context.json; init wrote
an empty history over that CONTEXT.md. Stop and point to /ck:migrate
while CONTEXT.md is still there, and only start fresh when neither file
exists. A context whose sessions array holds a null entry passed the
guard, then renderContextMd threw after context.json was rewritten; now
every session entry must be an object before anything is written.
Rebind the skill triggers manifest to the new registry digest.
Refs #3922
With both spellings of a folder registered, list marked both rows as
the current project while save and resume use only the exact one. Pass
the key findProject() selects to renderListTable(), which compares it
exactly again. Rebind the skill triggers manifest to the new registry
digest.
Refs #3924
A context.json that parses but has no sessions array (for example a
JSON array at the root) passed the guard, and init wrote an empty
context over it. Require a sessions array before reusing the context.
Rebind the skill triggers manifest to the new registry digest.
Refs #3922
When a registered project's context.json exists but cannot be parsed,
loadContext() returns null and init wrote a fresh context over the file,
destroying history that could still be recovered by hand. Stop with a
message and leave the files alone instead.
Tests: forgetting a project renamed by init leaves no context directory
behind, and init over an unreadable context.json exits 1 without
touching it. Rebind the skill triggers manifest to the new registry
digest.
Refs #3922
Windows paths are case-insensitive, so C:/Work/App and c:\work\app name
the same folder. Add samePath(), which lowercases resolved paths on
win32 only, and use it for the registry lookup, the list marker and the
resume cd hint. The SessionStart hook now uses findProject() instead of
indexing the registry with a key that may be undefined.
Tests: the Git Bash registration is found from PowerShell and from a
lower-case path (init, save, list, resume with the saved session,
SessionStart); resume and forget act on the exact registration when
both spellings exist; SessionStart ignores a registration that does not
match. Rebind the skill triggers manifest to the new registry digest.
Refs #3924
projects.json is keyed by PWD or process.cwd(), and lookups compared
that string exactly. On Windows, Git Bash passes C:/... and PowerShell
gives C:\..., so a folder registered from one shell was unknown in the
other and init registered it a second time. Match registrations by
exact key first, then by resolved path, in save, init, resume, list and
the SessionStart hook, and rebind the skill triggers manifest to the
new registry digest.
Fixes#3924
save.mjs --init wrote a new context with sessions: [] and a fresh
createdAt over the existing one, so running /ck:init again in a
registered folder deleted its session history. Carry both over from the
registered context, keep its context directory when the name changes,
and update only the project details. Rebind the skill triggers manifest
to the new registry digest.
Fixes#3922
DESTRUCTIVE_SQL matched only DROP TABLE, DELETE FROM and TRUNCATE.
`psql -c "DROP DATABASE prod"`, `DROP SCHEMA public CASCADE` and
`ALTER TABLE users DROP COLUMN email` went to the routine gate instead
of the destructive gate, even though each loses at least as much data
as DROP TABLE.
Add DROP DATABASE, DROP SCHEMA and an ALTER TABLE ... DROP COLUMN arm
to the phrase check. The DROP COLUMN arm stops at `;` so it never
matches across two statements. It requires the COLUMN keyword so
ALTER COLUMN ... DROP DEFAULT / DROP NOT NULL stay passive. Existing
literal and quote stripping keeps SQL strings, commit messages and
echo mentions passive.
Update the gateguard trigger list (en, ja-JP, zh-CN) and rebind the
skill-triggers registry digest for the SKILL.md body edit. Skill
descriptions and triggers are unchanged.