fix(cline): support the Cline CLI's hook directory layout (#2711) - #2876
Open
benfrank241 wants to merge 1 commit into
Open
fix(cline): support the Cline CLI's hook directory layout (#2711)#2876benfrank241 wants to merge 1 commit into
benfrank241 wants to merge 1 commit into
Conversation
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.
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.
Fixes #2711.
Problem
The Cline CLI and the VS Code extension discover lifecycle hooks from different directories, but
hindsight-cline installonly wrote the extension's paths and told users to flip the extension's Settings toggle:~/Documents/Cline/Rules/Hooks/+.clinerules/hooks/~/.cline/hooks+<project>/.cline/hooks/--hooks-dir/CLINE_HOOKS_DIR— no toggleSo on the CLI the hooks landed in a directory the CLI never reads (
.clinerules/hooks). They listed under/settingsbut 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/hooksis extension-only.Fix
Add a
--cliinstall/uninstall mode that targets the CLI's directories:<project>/.cline/hooks/--global:~/.cline/hooksand 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 itslib/andsettings.jsonrelative to its own path), so it runs unchanged from the new location. Extension behaviour and messaging are unchanged when--cliis omitted.Tests
get_hooks_dirreturns the correct path for all four combinations (extension/CLI × project/global).--cliinstall writes.cline/hooks(+lib/+settings.json) and does not write the extension.clinerules/hookspath;--cli --globalwrites~/.cline/hooks;--cliuninstall removes them.README updated with the
--cliflag, 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.