Skip to content

fix(base): fire the preflight hook on the namespaced /base:refact command - #28

Open
eastagiletracker wants to merge 1 commit into
refactco:mainfrom
eastagiletracker:agile-board/preflight-hook-namespaced-command
Open

fix(base): fire the preflight hook on the namespaced /base:refact command#28
eastagiletracker wants to merge 1 commit into
refactco:mainfrom
eastagiletracker:agile-board/preflight-hook-namespaced-command

Conversation

@eastagiletracker

Copy link
Copy Markdown

This PR proposes fixing the base pack's preflight-refact-config.mjs hook so it fires on the namespaced /base:refact command instead of only the bare /refact form. We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/383. You can sign in with your GitHub ID to claim ownership of the project.

What was wrong

plugins/base/hooks/preflight-refact-config.mjs runs on every UserPromptSubmit (registered in plugins/base/hooks/hooks.json) and is supposed to add the ".refact-os.json was not found" note before a refact action. Its prompt test was /(^|\s)\/refact(\s|$)/, which was written before the command became namespaced. The shipped command is /base:refact (plugins/base/commands/refact.md, and the README wording throughout), and "/base:refact config" contains no /refact substring — so the test never matched the real command name and the note never reached the agent. The repo-root contributor guide states the intended behaviour directly: "the preflight-refact-config.mjs hook warns when it is missing before a /base:refact action". The hook has not been touched since the initial 7-pack restructure, so the rename to /base:refact left it behind.

Reproduction on main at a9cce32, from a directory with no .refact-os.json:

$ printf '{"prompt":"/base:refact config"}' | node plugins/base/hooks/preflight-refact-config.mjs
                       # nothing — the guardrail is silent
$ printf '{"prompt":"/refact config"}'      | node plugins/base/hooks/preflight-refact-config.mjs
Note: `.refact-os.json` was not found in this project. ... Run `/refact config` ...

The change

The prompt test becomes /(^|\s)\/(?:[\w-]+:)?refact(?=\s|$)/: an optional <plugin>: prefix is allowed, so /base:refact … matches and the bare /refact … form keeps working for anyone whose install resolves the short name — backward compatible, nothing that matched before stops matching. The boundary is a lookahead rather than a consuming (\s|$), so /refactor and /base:refactor still do not match. The note text now names /base:refact config, and the file's header comment is updated to the current command name.

Verification, all replayable from the checkout (the repo ships no test runner, as the contributor guide notes, so these are direct invocations of the hook):

$ printf '{"prompt":"/base:refact config"}'          | node plugins/base/hooks/preflight-refact-config.mjs
Note: `.refact-os.json` was not found ... Run `/base:refact config` ...
$ printf '{"prompt":"/base:refact"}'                 | node plugins/base/hooks/preflight-refact-config.mjs   # note
$ printf '{"prompt":"please run /base:refact sync asana now"}' | node ...                                    # note
$ printf '{"prompt":"/refact config"}'               | node ...                                              # note (unchanged behaviour)
$ printf '{"prompt":"/refactor this"}'               | node ...                                              # silent
$ printf '{"prompt":"/base:refactor"}'               | node ...                                              # silent
$ printf '{"prompt":"just talking about refact"}'    | node ...                                              # silent

Positive control: with a .refact-os.json present in the resolved project directory, /base:refact config stays silent and the hook still exits 0, so it never blocks a session. I also ran the repo's whole static check set before and after the change — node --check on all 45 .mjs files, bash -n on the shell hooks and scripts, and a JSON parse of every manifest, 66 checks — with an identical result set: no new failures.

Per the contributor guide's release rule ("bump the changed plugin's version in both its plugin.json and marketplace.json and the top-level marketplace version") this bumps base to 1.8.1 and the marketplace to 2.12.2, and adds a docs/change-log.md entry in the existing style. Note that the catalog entry for base in the marketplace manifest still read 1.7.0 while the base pack's own plugin.json read 1.8.0, so /plugin marketplace update refact-os was advertising the older version and /plugin update base@refact-os had nothing to offer; both now read 1.8.1. Heads-up on merge order: #25 and #26 also edit marketplace.json (the wordpress entry plus the top-level version), so whichever lands second will want a trivial version reconcile.

How this was managed

This work was tracked as a single story on a live board imported from this repository's own issues and pull requests (27 stories from your 27 PRs, plus the labels): the story is https://eastagiletracker.com/projects/383/stories/259908 and the board is https://eastagiletracker.com/projects/383.

board

If you'd rather not receive contributions like this, reply no-more-prs on this pull request and we won't open any further ones on your repositories.


Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com

…mand

The UserPromptSubmit hook preflight-refact-config.mjs tested the prompt
against a bare `/refact`, but the command ships namespaced as
`/base:refact`. The test never matched the real command name, so the
missing-`.refact-os.json` note never reached the agent — the behaviour
CLAUDE.md describes ("the preflight-refact-config.mjs hook warns when it
is missing before a /base:refact action") was unreachable.

The prompt test now allows an optional `<plugin>:` prefix, so
`/base:refact …` and the bare `/refact …` form both fire; `/refactor`
still does not match (lookahead instead of a consuming boundary). The
note now names `/base:refact config`.

base 1.8.1, marketplace 2.12.2. The catalog entry for base still read
1.7.0 after the 1.8.0 bump, so it is realigned in the same edit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant