Skip to content

claude_code_agent: project_key regex keeps "." but Claude Code replaces it — watcher tails a directory the CLI never writes to #132

Description

@apakkhalin-sudo

Env: OpenCompany 0.1.1 (npm @zeenie-ai/opencompany), Windows 11, Claude Code CLI 2.1.261, isolated CLAUDE_CONFIG_DIR.

_PROJECT_KEY_RE preserves ., but Claude Code does not — it maps every character outside [a-zA-Z0-9-] to -, dots included.

https://github.com/zeenie-ai/OpenCompany/blob/main/server/services/cli_agent/session.py#L63

_PROJECT_KEY_RE = re.compile(r"[^a-zA-Z0-9.-]")   # keeps "."
...
project_key = _PROJECT_KEY_RE.sub("-", str(cwd))  # session.py:443

Any worktree path containing a dot therefore resolves to a directory Claude never writes to. The default layout has one — .opencompany:

cwd E:\Kae\.opencompany\workspaces\default\cc_test_1\wt_t_bd5e9c51
OpenCompany watches projects\E--Kae-.opencompany-workspaces-default-cc-test-1-wt-t-bd5e9c51
Claude actually writes projects\E--Kae--opencompany-workspaces-default-cc-test-1-wt-t-bd5e9c51

_await_first_jsonl then times out and the node fails with "claude may have failed to start or the CLAUDE_CONFIG_DIR is misconfigured", while the CLI has in fact started and answered normally. Confirmed by reading the session JSONL in the dashed directory: correct response, stop_reason: end_turn.

Fix: drop the dot from the class so it matches the CLI's own sanitizer.

_PROJECT_KEY_RE = re.compile(r"[^a-zA-Z0-9-]")

Worth adding a regression test with a dotted path segment — every default install hits this, since the data dir itself is .opencompany.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions