Skip to content

fix: update hooks.json to Claude Code plugin format (v0.6.1)#82

Merged
wey-gu merged 1 commit into
nowledge-co:mainfrom
jiangnan-ten:fix/hooks-json-format-v0.6.1
Feb 28, 2026
Merged

fix: update hooks.json to Claude Code plugin format (v0.6.1)#82
wey-gu merged 1 commit into
nowledge-co:mainfrom
jiangnan-ten:fix/hooks-json-format-v0.6.1

Conversation

@jiangnan-ten

@jiangnan-ten jiangnan-ten commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

问题描述

当前 nowledge-mem-claude-code-plugin/hooks/hooks.json 的格式不符合 Claude Code 插件系统规范,导致插件加载时报错:

Failed to load hooks from .../hooks/hooks.json: [
  {
    "expected": "record",
    "code": "invalid_type",
    "path": ["hooks"],
    "message": "Invalid input: expected record, received undefined"
  }
]

根本原因

根据 Claude Code 官方文档,插件的 hooks.json 必须使用顶层 "hooks" 包裹键:

For plugin hooks.json, wrap these in {"hooks": {...}}

当前格式直接将事件名(SessionStart)放在顶层,这是用户 settings.json 的格式,不是插件格式。

修复内容

  • ✅ 添加顶层 "hooks" 键包裹所有事件配置
  • ✅ 添加 "description" 字段说明 hooks 用途
  • ✅ 更新版本号到 0.6.1
  • ✅ 更新 CHANGELOG.md 记录修复详情
  • ✅ 保持内部逻辑完全不变

兼容性

  • 向后兼容:新格式在 Claude Code 2.1.45+ 都支持
  • 无功能变更:只是格式调整,hooks 的实际行为完全相同
  • 用户影响:已安装用户需要重新安装插件以获取修复

测试

在 Claude Code 2.1.62 上测试通过:

  1. 插件加载无报错
  2. SessionStart hooks 正常触发
  3. Working Memory 成功注入会话上下文

参考

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Resolved validation error with hooks configuration format
  • Documentation

    • Updated changelog documenting structural improvements to hooks configuration for enhanced compatibility with Claude Code 2.1.51+
    • Added support for description field in hook documentation
  • Chores

    • Bumped plugin version to 0.6.1

- Add top-level 'hooks' wrapper key as required by Claude Code plugin spec
- Add description field explaining hook purpose
- Update version to 0.6.1
- Update CHANGELOG.md with fix details

Fixes validation error: 'expected record, received undefined'

This change aligns with the official plugin hooks format documented in
Claude Code's plugin-dev/skills/hook-development guide, which requires
plugin hooks.json to use wrapper format with top-level 'hooks' key.

Resolves hook loading failures in Claude Code 2.1.51+.
@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR updates the Claude Code plugin from version 0.6.0 to 0.6.1, restructuring hooks.json to include a top-level "hooks" wrapper key and description field, updating the version number in plugin.json, and documenting changes in the CHANGELOG.

Changes

Cohort / File(s) Summary
Version & Documentation Updates
plugin.json, CHANGELOG.md
Version bumped from 0.6.0 to 0.6.1; changelog entry added documenting hooks.json format changes including top-level wrapper, description field, validation fixes, and Claude Code 2.1.51+ compatibility.
Hooks Configuration
hooks/hooks.json
Root JSON restructured from bare SessionStart array to object with description and nested hooks container; existing SessionStart hooks preserved under hooks["SessionStart"] key with identical entries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A wrapper so gentle now holds all our hooks,
With descriptions and structure, a fresh JSON look!
Version bumped kindly from point-six-oh to one,
The plugins now organized—our work here is done! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating hooks.json to the correct Claude Code plugin format and bumping to v0.6.1, which directly addresses the root cause of the plugin loading error.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@nowledge-mem-claude-code-plugin/CHANGELOG.md`:
- Line 8: The changelog entry header "## [0.6.1] - 2026-02-28" uses a future
date; update that header (the "## [0.6.1] - 2026-02-28" line) to either use
today's date "2026-02-27" or remove the date and mark it as "Unreleased" so
release chronology remains correct.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1211f98 and 0b036e8.

📒 Files selected for processing (3)
  • nowledge-mem-claude-code-plugin/CHANGELOG.md
  • nowledge-mem-claude-code-plugin/hooks/hooks.json
  • nowledge-mem-claude-code-plugin/plugin.json

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.1] - 2026-02-28

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Use a non-future release date (or keep it unreleased until cut).

Line 8 is dated 2026-02-28, which is in the future relative to this PR date (2026-02-27). This can confuse release chronology.

🛠️ Suggested adjustment
-## [0.6.1] - 2026-02-28
+## [0.6.1] - 2026-02-27
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## [0.6.1] - 2026-02-28
## [0.6.1] - 2026-02-27
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@nowledge-mem-claude-code-plugin/CHANGELOG.md` at line 8, The changelog entry
header "## [0.6.1] - 2026-02-28" uses a future date; update that header (the "##
[0.6.1] - 2026-02-28" line) to either use today's date "2026-02-27" or remove
the date and mark it as "Unreleased" so release chronology remains correct.

@wey-gu

wey-gu commented Feb 28, 2026

Copy link
Copy Markdown
Member

THANKS SO MUCH for the contribution!!!

@wey-gu wey-gu merged commit c1d923e into nowledge-co:main Feb 28, 2026
1 check passed
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.

2 participants