Skip to content

fix(init): quote cce binary path in SessionStart hook command - #146

Merged
fazleelahhee merged 6 commits into
mainfrom
fix/windows-hook-quoting-145
Jul 28, 2026
Merged

fix(init): quote cce binary path in SessionStart hook command#146
fazleelahhee merged 6 commits into
mainfrom
fix/windows-hook-quoting-145

Conversation

@rajkumarsakthivel

Copy link
Copy Markdown
Member

Summary

Fixes #145. On Windows, cce init writes an unquoted backslash path into .claude/settings.local.json:

"command": "C:\\Users\\fahmid\\.local\\bin\\cce.exe status --oneline"

Claude Code runs hook commands through bash (Git Bash on Windows), which interprets unquoted backslashes as escape characters. The path collapses to C:Usersfahmid.localbincce.exe and every session start fails with "command not found."

The fix reuses the existing _quote_hook_path helper from hook_installer.py (already used by the settings.json lifecycle hooks) to properly quote the path. This helper handles both POSIX (shlex.quote) and Windows (cmd-style double quotes).

One-line change. Existing projects need to re-run cce init --agent claude (or manually quote the path in settings.local.json) to pick up the fix.

On Windows, cce init writes an unquoted backslash path into
settings.local.json. Bash interprets unquoted backslashes as escape
characters, collapsing the path and producing "command not found" on
every session start.

Reuse the existing _quote_hook_path helper (already used by the
settings.json lifecycle hooks) to properly quote the path. This helper
handles both POSIX (shlex.quote) and Windows (cmd-style double quotes)
correctly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Windows session startup failures caused by an unquoted cce binary path written into .claude/settings.local.json by cce init, by reusing the existing cross-platform hook-path quoting helper.

Changes:

  • Import and reuse context_engine.memory.hook_installer._quote_hook_path when generating the SessionStart “cce status” hook command.
  • Quote the resolved cce binary path before appending status --oneline so Git Bash doesn’t treat backslashes as escapes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/context_engine/cli.py:429

  • The idempotency check uses marker "cce status", but the command uses an absolute binary path (now also quoted), so the substring "cce status" typically won’t be present (e.g. ".../cce" or "cce.exe"), causing cce init to append duplicate SessionStart hooks on subsequent runs (especially on Windows). Use a marker that matches the stable suffix of the hook command instead (e.g. "status --oneline").
    session_hooks = hooks.setdefault("SessionStart", [])
    if not _has_cce_hook(session_hooks, "cce status"):
        session_hooks.append({
            "matcher": "",
            "hooks": [{"type": "command", "command": f"{_quote_hook_path(Path(cce_cmd))} status --oneline"}],

@fazleelahhee
fazleelahhee merged commit 675636d into main Jul 28, 2026
21 checks passed
@fazleelahhee
fazleelahhee deleted the fix/windows-hook-quoting-145 branch July 28, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cce init writes an unquoted Windows path into settings.local.json, breaking the SessionStart hook

3 participants