Repository navigation
fix(hooks): record CodeBuddy skill usage from IDE payloads - #1545
huong8373tt-beep wants to merge 1 commit into
Conversation
The description documents sufficient testing: the built real-CLI run records successful exits and usage output. No missing-e2e blocker. I only read the diff; I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@huong8373tt-beep Thanks for taking #1516. With the built CLI at 7c7aee17 and an isolated HOME, feeding the dispatcher CodeBuddy payloads works when the member has only a project-scope config. A SessionStart with the real workspace, then a use_skill with the extension-host cwd, writes the usage record in that project, and the tool-use event carries the project cwd. Main records neither. use_skill only counts a skill installed on disk, the same check as other tools, and an anchored @command://name counts while a mid-sentence one doesn't. tsc, lint and the two changed test files pass, and the four new tests fail on main. What blocks approval:
- [P1 blocking] CodeBuddy
/skillprompts stop being counted. The prompt pattern now matches only@command://name, so the/nameform main recognises is gone. A UserPromptSubmit with/hello-skill review thiswrites{"skill":"hello-skill",…,"tool":"codebuddy"}on main and nothing on this branch. The CodeBuddy CLI (2.177.1) passes the user's original prompt text to the prompt hook and has no@command://form, so CLI members lose their counts. We read the CLI side from its package and didn't run a live CodeBuddy session. Matching both,^(?:/|@command://)name, keeps the CLI and the IDE. - [P1 blocking] The branch conflicts with main, and the part that merges cleanly doesn't compile. GitHub reports it as conflicting, so CI and e2e haven't run at this head.
src/dashboard-collector.tsmerges without a conflict but ends up with two exportedrecordedHookCwd. Main already has one from #1337 that does something else, and tsc fails withTS2393: Duplicate function implementation. Please rebase onto main, rename or merge the two functions, regenerate the tool-support pages (npx vitest run tool-support -u, sincesrc/tools.tschanged) and get CI green. - [P2 non-blocking on its own; we hold approval for an important item in scope] No recovery for members with both a user-scope and a project-scope config. The CI review raises this, and it reproduces. The extension-host cwd
/resolves to the user config, so recovery never runs: theuse_skilluse isn't recorded, and the tool-use event goes to the user scope with cwd/. Members who installed teamai at user scope and then joined a project are a common case. Recovery should also apply when the cwd resolves only to the user scope and the session's SessionStart recorded a project workspace.
Non-blocking:
- [P3 nit]
use_skillis markedverifiedinsrc/tools.tswithout a recorded run (tool version, date, command) in the PR. Its fixture says it comes from the CodeBuddy CLI, but the CLI reports this tool to hooks asSkill. If it comes from the IDE plugin, say so and give the plugin version. - [P3 nit] The body's real-CLI line has no commands or output. Pasting the run, with the payloads you fed, would make it checkable.
We didn't run Windows, and e2e can't run until the branch merges cleanly. The CI review raised the user-plus-project case (it reproduces, above) and the verified label (we agree). It judged the record sufficient. We'd still like the commands in the body, and it ran no code, so it couldn't see the /skill regression or the build break on merge.
Summary
Fixes #1516. CodeBuddy's VSCode host can send an extension-host
cwd, so config-dependent post-tool handlers were filtered out even though SessionStart had already recorded the real workspace. Its actual skill invocation/prompt shapes were also missing from the descriptor.use_skilltool and extract the skill from itscommandinput.@command://nameprompt mentions without counting pasted mid-sentence text.Validation
npx vitest run src/__tests__/skill-use.test.ts src/__tests__/hook-dispatch-scope.test.ts— 70 passednpx tsc --noEmit— passednpm run lint— passednpm run build— passedgit diff --check— passeddist/index.js: CodeBuddyuse_skilland@command://hello-skillboth exited 0 and produced one usage record.The focused
hook-dispatch-cli.test.tsrun still has pre-existing Windows/MSYS/tmptimeout failures; the new scope regression passes through the real dispatcher.