vitest plugin: shape validator for event inputs and hook results (M5)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Start by reading packages/core/src/hook-placeholders.ts, the existing hook-type generator, and the Vitest plugin entry point where claudeCodeMod and hook calls are handled. Check the current dependencies for TypeScript compiler API or type-to-schema tools, then decide where the pinned type base belongs. Done means generated schemas validate event inputs and hook results, both required regression tests fail as specified, self tests pass, and the README, deviation list, and changeset are updated.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
The kit accepts any event input and any hook result. The real engine validates both. A test can therefore fire session.start without cwd, or session.compact with empty messages, and pass under Vitest while claude plugin test and Claude Code reject the call. The kit's own conformance suite cannot catch this, because it only compares outcomes for inputs that are valid in the first place.
Proposal
Validate event inputs and hook returns at run time against the types of a pinned Claude Code version.
claudeCodeMod({
mod: "./src/hooks/register.ts",
claudeCodeVersion: "2.1.332", // shapes of this version
types: "./claude-code.d.ts", // or a file made by /plugin-types
});
Pipeline
| Step | What |
|---|---|
| Type base | A claude-code.d.ts of the pinned version, produced by Claude Code's /plugin-types; never maintained by hand |
| Generator | A script turns the .d.ts into one schema per event at build time |
| Validator in the kit | Checks the test's input to on(...)/$.<ns>.<event>() and the return value of every hook |
| Options | claudeCodeVersion (version of the bundled base), types (path that overrides the bundled base) |
Required regression tests
session.startwithoutcwdfails in Vitest.session.compactwith emptymessagesfails in Vitest.
Design points
- Where the type base lives. Open point: bundled in the package or in
@kwitsch/claude-code-plugin-core. The core package already carries the hook-type allow-list (packages/core/src/hook-placeholders.ts) and a hook-type generator, so shared data may belong there; a bundled copy keeps the vitest plugin free of a second consumer. Decide first. - Generator input. A
.d.tsis TypeScript; reading it needs the TypeScript compiler API or a type-to-schema tool. Check what is already a dependency before adding one. - Error wording. The conformance suite compares messages with the real engine. Capture the engine's wording for a rejected input (
claude plugin testwith a bad input) and match it, or document the difference in the deviation list. - Both directions. Input of the test to
on(...)and return of the hook. The hook-return check must not break{ deny },{ value }or thenextchain. - Version coupling. The bundled base names the Claude Code version it came from. README and changelog state it; a new base is at least a minor. The compatibility table in the README gains the base version.
- Drift. Depends on the nightly drift job in #34, which compares against
claude@latestand opens an issue with the diff ofclaude-code.d.ts.
Scope
- Generator script and a committed, generated type base (with the version it came from).
- Validator in
src/testing/, options inclaudeCodeMod, README section, deviation list update. - Self tests for the generator and the validator; the two regression tests above.
- Changeset: minor (0.2.0 together with the sandbox check).
- Independent of the sandbox check (#32); both can run in parallel.
Acceptance
- The two regression tests fail in Vitest as described.
- The generated schemas come from a committed
claude-code.d.ts, not from hand-written types.
Relations
- Originating PR: #31
- Ngôn ngữ chính
- TypeScript
- Star
- 0
- Fork
- 0
- Merge trung bình
- 29 phút
- Pull request đã merge (30 ngày)
- 138
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của kwitsch/claude-code-plugin-tooling
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
kwitsch/claude-code-plugin-tooling#219 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
kwitsch/claude-code-plugin-tooling#210 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
kwitsch/claude-code-plugin-tooling#212 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
kwitsch/claude-code-plugin-tooling#209 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
kwitsch/claude-code-plugin-tooling#208 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của kwitsch/claude-code-plugin-tooling
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
makecindy/cindy#15342 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
no-repo-link tool-submission
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Priyanshu-byte-coder/devtrack#4067 ·
Maintainer thường phản hồi trong vòng 1 ngày