Skip to content

fix(hooks): record CodeBuddy skill usage from IDE payloads - #1545

Closed
huong8373tt-beep wants to merge 1 commit into
Tencent:mainfrom
huong8373tt-beep:fix/1516-codebuddy-tool-use
Closed

huong8373tt-beep wants to merge 1 commit into
Tencent:mainfrom
huong8373tt-beep:fix/1516-codebuddy-tool-use

Conversation

@huong8373tt-beep

Copy link
Copy Markdown
Contributor

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.

  • Recover the same-session workspace for CodeBuddy when the reported cwd has no TeamAI config.
  • Recognize CodeBuddy's use_skill tool and extract the skill from its command input.
  • Recognize anchored @command://name prompt mentions without counting pasted mid-sentence text.
  • Add regression coverage for the CodeBuddy payloads and real dispatcher scope recovery.

Validation

  • npx vitest run src/__tests__/skill-use.test.ts src/__tests__/hook-dispatch-scope.test.ts — 70 passed
  • npx tsc --noEmit — passed
  • npm run lint — passed
  • npm run build — passed
  • git diff --check — passed
  • Built CLI verification with an isolated HOME and real dist/index.js: CodeBuddy use_skill and @command://hello-skill both exited 0 and produced one usage record.

The focused hook-dispatch-cli.test.ts run still has pre-existing Windows/MSYS /tmp timeout failures; the new scope regression passes through the real dispatcher.

@github-actions

Copy link
Copy Markdown
  • [P2 non-blocking] src/hook-dispatch-cli.ts:472 — Recovery is skipped when a user-scope config exists. With both user and project configs, an extension-host cwd resolves to the user config, so !localConfig is false. The recorded project workspace is never recovered, leaving project-local skill usage unrecorded or attributed to the wrong scope. Add coverage for this configuration and recover the recorded project where appropriate.

  • [P3 nit] src/tools.ts:50 — The new use_skill entry is marked verified, but the PR description omits the tool version, date, and command required by the tool-evidence review rule. Add that record or use a weaker evidence label.

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 SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /skill prompts stop being counted. The prompt pattern now matches only @command://name, so the /name form main recognises is gone. A UserPromptSubmit with /hello-skill review this writes {"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.ts merges without a conflict but ends up with two exported recordedHookCwd. Main already has one from #1337 that does something else, and tsc fails with TS2393: Duplicate function implementation. Please rebase onto main, rename or merge the two functions, regenerate the tool-support pages (npx vitest run tool-support -u, since src/tools.ts changed) 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: the use_skill use 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_skill is marked verified in src/tools.ts without 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 as Skill. 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.

@SaulMoro

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Thanks for working on #1516. #1547 fixes the same issue and is ready, so we're merging it and closing this one. We appreciate the work here.

@SaulMoro SaulMoro closed this Oct 29, 2026
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.

[bug] CodeBuddy host: tool_use events & skill usage never recorded — 3 independent causes in hook dispatch (v0.28.1)

3 participants