Skip to content

fix(cline): support the Cline CLI's hook directory layout (#2711) - #2876

Open
benfrank241 wants to merge 1 commit into
mainfrom
fix/cline-cli-hooks
Open

fix(cline): support the Cline CLI's hook directory layout (#2711)#2876
benfrank241 wants to merge 1 commit into
mainfrom
fix/cline-cli-hooks

Conversation

@benfrank241

Copy link
Copy Markdown
Member

Fixes #2711.

Problem

The Cline CLI and the VS Code extension discover lifecycle hooks from different directories, but hindsight-cline install only wrote the extension's paths and told users to flip the extension's Settings toggle:

Client Hook discovery Enablement
VS Code extension ~/Documents/Cline/Rules/Hooks/ + .clinerules/hooks/ Settings → Features → Hooks toggle
CLI ~/.cline/hooks + <project>/.cline/hooks/ --hooks-dir / CLINE_HOOKS_DIRno toggle

So on the CLI the hooks landed in a directory the CLI never reads (.clinerules/hooks). They listed under /settings but never fired, and the bank stayed empty — while a manual invocation of the same script worked (it was run directly). The reporter also (correctly) found no enable toggle in the CLI, because the CLI doesn't have one.

Confirmed against Cline's own docs/cli/cli-reference.mdx (apps/cli/src/main.ts, apps/cli/src/commands/program.ts): CLI default ~/.cline/hooks, --hooks-dir, CLINE_HOOKS_DIR; .clinerules/hooks is extension-only.

Fix

Add a --cli install/uninstall mode that targets the CLI's directories:

  • project (default): <project>/.cline/hooks/
  • --global: ~/.cline/hooks

and prints CLI-appropriate guidance — no toggle, and how to point the CLI elsewhere via CLINE_HOOKS_DIR / cline --hooks-dir. The hook bundle is already self-contained (each script resolves its lib/ and settings.json relative to its own path), so it runs unchanged from the new location. Extension behaviour and messaging are unchanged when --cli is omitted.

hindsight-cline install --cli --api-url ... --api-token ...   # project .cline/hooks
hindsight-cline install --cli --global ...                    # ~/.cline/hooks

Tests

  • get_hooks_dir returns the correct path for all four combinations (extension/CLI × project/global).
  • End-to-end --cli install writes .cline/hooks (+ lib/ + settings.json) and does not write the extension .clinerules/hooks path; --cli --global writes ~/.cline/hooks; --cli uninstall removes them.
  • Existing extension-path tests unchanged. 40 tests pass; lint/format clean.

README updated with the --cli flag, a per-client directory table, and the no-toggle CLI setup.

Reported by @mmarras, who did the legwork confirming the hook script itself works when invoked manually.

The Cline CLI and the VS Code extension discover lifecycle hooks from
different directories, but the installer only wrote the extension's paths
(`.clinerules/hooks/` / `~/Documents/Cline/Rules/Hooks/`) and told users to
flip the extension's Settings → Features → Hooks toggle. On the CLI the hooks
therefore landed where the CLI never looks, so they listed under /settings but
never fired and the memory bank stayed empty — while a manual invocation of
the same script worked, because it was run directly.

Add a `--cli` install/uninstall mode that targets the CLI's directories —
`~/.cline/hooks` (with `--global`) or `<project>/.cline/hooks` — and prints
CLI-appropriate guidance (no toggle; point elsewhere with CLINE_HOOKS_DIR /
`cline --hooks-dir`). The hook bundle is already self-contained (each script
resolves its `lib/` and `settings.json` relative to its own path), so it works
unchanged from the new location. The extension paths and messaging are
unchanged when `--cli` is omitted.

Tests cover both client layouts for get_hooks_dir and end-to-end install/
uninstall via `--cli` (into `.cline/hooks` and `~/.cline/hooks`), asserting the
extension path is not written in CLI mode. README documents the CLI flag, the
per-client directory table, and the no-toggle setup.
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.

cline CLI integration

1 participant