-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 更新依赖注入核心能力,新增模块与功能,完善文档 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| name: Dix Maintainer | ||
| description: Use when working on dix core implementation, DI behavior changes, provider/inject debugging, trace diagnostics, or module-level README synchronization. | ||
| tools: [read, edit, search, execute, todo] | ||
| argument-hint: "描述你的目标(如修复 provider 解析、补测试、更新 trace 行为或同步 README)" | ||
| user-invocable: true | ||
| --- | ||
|
|
||
| 你是 `dix` 仓库的维护型工程代理,专注于 Go 依赖注入框架的实现与验证。 | ||
|
|
||
| ## 任务边界 | ||
|
|
||
| - 优先处理:`dixinternal/`、`dixtrace/`、`dixhttp/`、`dixcontext/`、`dixglobal/`。 | ||
| - 修改以“最小必要变更”为原则,保持公开 API 与现有行为兼容。 | ||
| - 若任务属于 PR 评审场景,遵循仓库中的 `pr-review-only.instructions.md`(仅评审,不直接改码)。 | ||
|
|
||
| ## 工作方式 | ||
|
|
||
| 1. 先定位受影响的包与调用链,再动手修改。 | ||
| 2. 优先补充或更新测试,尤其是 `*_test.go` 中的回归用例。 | ||
| 3. 代码改动后,至少执行相关测试;跨包改动时执行全量 `go test ./...`。 | ||
| 4. 若对外行为变化,提醒同步中英文 README 与模块文档。 | ||
|
|
||
| ## 输出要求 | ||
|
|
||
| - 清楚说明:改了什么、为什么改、如何验证。 | ||
| - 标注风险点与后续建议(如性能、兼容性、可观测性)。 | ||
| - 回答保持简洁、可执行,必要时给出下一步命令建议。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # dix 项目指引 | ||
|
|
||
| ## 适用范围 | ||
|
|
||
| - 本文件是仓库级 always-on 指引,适用于整个 `dix` 工作区。 | ||
| - 如存在更细分的 `*.instructions.md`,以细分规则作为补充,而非互相冲突。 | ||
|
|
||
| ## 技术栈与目标 | ||
|
|
||
| - 语言:Go(见 `go.mod`,当前 `go 1.24`)。 | ||
| - 项目类型:依赖注入框架(DI),核心能力包括 Provider 注册、依赖解析、循环检测、trace 诊断与可视化(`dixhttp`)。 | ||
| - 修改实现时优先保持公开 API 与行为兼容,避免无关重构。 | ||
|
|
||
| ## 首选开发命令 | ||
|
|
||
| - 测试:`task test` | ||
| - 静态检查:`task vet` | ||
| - Lint:`task lint` | ||
| - Web 示例:`task web-demo` | ||
|
|
||
| 如需直接使用 Go 命令: | ||
|
|
||
| - `go test ./...` | ||
| - `go vet ./...` | ||
|
|
||
| ## 架构边界(修改前先定位) | ||
|
|
||
| - `dix.go`:对外入口 API(创建容器、Provide/Inject 相关能力)。 | ||
| - `dixinternal/`:核心实现(provider、inject、cycle-check、diag、logger、option)。 | ||
| - `dixtrace/`:内存 trace 存储与查询。 | ||
| - `dixhttp/`:HTTP 可视化与 trace API。 | ||
| - `dixcontext/`:与 `context.Context` 集成。 | ||
| - `dixglobal/`:全局容器便捷封装。 | ||
|
|
||
| ## 项目特有约定 | ||
|
|
||
| - 错误优先通过 `TryProvide` / `TryInject` 路径返回,避免在新增逻辑中引入不必要 panic。 | ||
| - 涉及 trace/诊断行为时,注意与环境变量约定保持一致(如 `DIX_TRACE_DI`、`DIX_DIAG_FILE`、`DIX_TRACE_FILE`)。 | ||
| - 优先补充或复用现有测试文件(尤其 `dixinternal/*_test.go`、`dixtrace/*_test.go`、`dixhttp/server_runtime_test.go`)。 | ||
|
|
||
| ## 实施原则(对 AI 代理) | ||
|
|
||
| - 仅做与任务直接相关的最小改动,避免顺手大改。 | ||
| - 保持现有命名风格与目录组织,不随意移动包结构。 | ||
| - 新增行为时优先补测试,再改实现。 | ||
| - 变更对外行为时,同步更新 `README.md`/`README_zh.md` 与对应模块 README(如 `dixhttp/README*.md`)。 | ||
|
|
||
| ## 常见坑点 | ||
|
|
||
| - `task test` 当前默认覆盖 `dixinternal/...`,若改动到其他包需补充执行 `go test ./...` 进行全量验证。 | ||
| - 项目包含 `go.work`,处理示例工程时注意模块工作区上下文。 | ||
|
|
||
| ## 参考文件 | ||
|
|
||
| - `README.md` | ||
| - `README_zh.md` | ||
| - `Taskfile.yml` | ||
| - `dixinternal/dix.go` | ||
| - `dixinternal/provider.go` | ||
| - `dixinternal/diag_file.go` | ||
| - `dixtrace/trace.go` | ||
| - `dixhttp/server.go` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| name: Changelog 专项规范 | ||
| description: 仅用于维护 .version/changelog,保证 Unreleased 与版本文件结构稳定、分类一致、条目可追溯 | ||
| applyTo: ".version/changelog/*.md" | ||
| --- | ||
|
|
||
| # dix Changelog 维护规范 | ||
|
|
||
| 本规则仅适用于 `.version/changelog/*.md`。 | ||
|
|
||
| ## 结构约束 | ||
|
|
||
| - `Unreleased.md` 推荐分类:`新增` / `修复` / `变更` / `文档`。 | ||
| - 若某分类暂无内容,写"暂无"。 | ||
|
|
||
| ## 内容约束 | ||
|
|
||
| - 仅基于可见改动编写条目,不杜撰能力或影响。 | ||
| - 单条应简洁、可读、可追溯,尽量以动词开头。 | ||
| - 重复事项需合并去重,避免同义重复。 | ||
| - 不改写历史版本文件语义,不重排已发布版本。 | ||
|
|
||
| ## 落版约束(release) | ||
|
|
||
| - 版本号来源于 `.version/VERSION`。 | ||
| - 落版文件:`.version/changelog/<VERSION>.md`。 | ||
| - 文件头格式:`# [<VERSION>] - <YYYY-MM-DD>`。 | ||
| - 落版后需重建 `.version/changelog/Unreleased.md` 模板(四个分类)。 | ||
| - 落版后需同步更新 `.version/changelog/README.md` 索引。 | ||
|
|
||
| ## 协同建议 | ||
|
|
||
| - 建议通过 agent 提示词执行:`/changelog-maintenance draft|release`。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| name: 文档专项规范 | ||
| description: 适用于仓库文档写作与维护(README/docs/模块 README),确保中文技术文风、Mermaid 图示与文档导航一致 | ||
| applyTo: "**/*.md" | ||
| --- | ||
|
|
||
| # dix 文档专项规范 | ||
|
|
||
| 仅在“项目文档内容”场景生效(如 `README.md`、`README_zh.md`、`docs/**`、`dixhttp/README*.md`)。 | ||
|
|
||
| ## 基本要求 | ||
|
|
||
| - 默认使用中文技术文风,表达简洁、可执行、可复现。 | ||
| - 结构化写作:优先使用二级/三级标题与短列表,避免大段空泛描述。 | ||
| - 架构、流程、关系说明优先使用 Mermaid。 | ||
| - 仅描述仓库中已实现能力,不杜撰未落地特性。 | ||
|
|
||
| ## 导航与链接约束 | ||
|
|
||
| - 导航尽量保持树形自上而下,避免在低层文档大量回链上层形成网状互链。 | ||
| - 避免使用 `../` 父目录相对路径,优先使用仓库根相对路径或同目录直达路径。 | ||
| - 索引页避免堆叠“上级入口/相关专题”重复导航块。 | ||
|
|
||
| ## 内容组织建议 | ||
|
|
||
| - 明确区分“基础组件模块”(如中间件、配置、错误、trace)与“业务功能模块”说明。 | ||
| - 模块设计优先沉淀在模块分册,避免把所有设计细节堆到单一中心文档。 | ||
| - 若仅做措辞润色,不改变技术语义与行为结论。 | ||
|
|
||
| ## 变更联动 | ||
|
|
||
| - 对外行为、配置项或示例有变化时,同步更新 `README.md` 与 `README_zh.md`。 | ||
| - `dixhttp` 行为变化需同步更新 `dixhttp/README.md` 与 `dixhttp/README_zh.md`。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| description: "Use when handling pull request review, code review feedback, or PR comment resolution tasks. In review mode, provide analysis and comments only, and do not modify repository files directly." | ||
| name: "PR Review Read-Only Mode" | ||
| --- | ||
| # Pull Request Review: Read-Only Execution | ||
|
|
||
| - When the user asks to review a pull request, review comments, or code diffs, stay in **review-only mode**. | ||
| - Do **not** create, edit, rename, or delete repository files in this mode. | ||
| - Focus on: | ||
| - identifying issues and risks, | ||
| - suggesting concrete fixes, | ||
| - proposing patch snippets in chat only when explicitly requested. | ||
| - If the user explicitly switches from review to implementation (for example: "please apply the fixes now"), confirm intent once and then proceed with edits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| name: changelog-maintenance | ||
| description: 维护 .version/changelog(更新 Unreleased 或执行版本落版) | ||
| argument-hint: "模式:draft(更新 Unreleased)或 release(按 .version/VERSION 落版)" | ||
| agent: agent | ||
| --- | ||
|
|
||
| 你是本仓库的 Changelog 维护助手。 | ||
|
|
||
| ## 目标 | ||
|
|
||
| - `draft` 模式:根据当前改动更新 `.version/changelog/Unreleased.md`。 | ||
| - `release` 模式:将 `Unreleased.md` 落版为 `.version/VERSION` 对应版本文件,并重建空模板。 | ||
|
|
||
| ## 必读上下文 | ||
|
|
||
| 在开始前先读取并遵循: | ||
|
|
||
| - `.github/copilot-instructions.md` | ||
| - `.version/changelog/README.md` | ||
| - `.version/changelog/Unreleased.md` | ||
| - `.version/VERSION` | ||
| - 当前工作区 diff(如可获取) | ||
|
|
||
| ## 执行规则 | ||
|
|
||
| 1. 只基于可见改动生成条目,不杜撰。 | ||
| 2. 分类使用:`新增` / `修复` / `变更` / `文档`。 | ||
| 3. 语言使用中文技术文风,单条简洁,避免重复。 | ||
| 4. 不改写历史版本块语义与顺序。 | ||
|
|
||
| ## 模式细则 | ||
|
|
||
| ### draft | ||
|
|
||
| - 仅更新 `.version/changelog/Unreleased.md`。 | ||
| - 若缺少分类小节则补齐;无内容的小节写"暂无"。 | ||
| - 直接基于当前工作区改动与提交语义生成草稿,不依赖本地脚本输出。 | ||
|
|
||
| ### release | ||
|
|
||
| - 读取 `.version/VERSION` 作为目标版本号(当前为 `v2.0.0`)。 | ||
| - 将 `Unreleased.md` 内容迁移到新版本文件:`.version/changelog/<VERSION>.md`。 | ||
| - 版本文件标题格式:`# [<VERSION>] - <YYYY-MM-DD>`。 | ||
| - 重建 `.version/changelog/Unreleased.md` 空模板(四个分类且初始值为"暂无")。 | ||
| - 同步更新 `.version/changelog/README.md` 中的版本索引。 | ||
|
|
||
| ## 输出要求 | ||
|
|
||
| - 直接给出对 `.version/changelog/` 相关文件的修改(补丁或已应用结果)。 | ||
| - 末尾附一段简短自检: | ||
| - 是否仅改动允许范围; | ||
| - 是否完成分类与去重; | ||
| - 是否保持历史版本不变。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Changelog 索引 | ||
|
|
||
| 本目录保存项目变更记录,采用"一个版本一个文件"的方式维护。 | ||
|
|
||
| ## 文件约定 | ||
|
|
||
| - `Unreleased.md`:当前开发中变更(待发布)。 | ||
| - `vX.Y.Z.md`:已发布版本变更(例如 `v2.0.0.md`)。 | ||
|
|
||
| ## 当前版本文件 | ||
|
|
||
| - [`Unreleased.md`](Unreleased.md) | ||
| - [`v2.0.0.md`](v2.0.0.md) | ||
|
|
||
| ## 维护约定 | ||
|
|
||
| - 分类保持:`新增` / `修复` / `变更` / `文档`。 | ||
| - 发布时将 `Unreleased.md` 内容迁移到新版本文件,并重建空模板。 | ||
| - 历史版本文件只做勘误,不改写语义与顺序。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # [Unreleased] | ||
|
|
||
| > 推荐维护方式: | ||
| > | ||
| > - 建议通过 agent 提示词执行:`/changelog-maintenance draft|release` | ||
|
|
||
| ## 新增 | ||
|
|
||
| 暂无 | ||
|
|
||
| ## 修复 | ||
|
|
||
| 暂无 | ||
|
|
||
| ## 变更 | ||
|
|
||
| 暂无 | ||
|
|
||
| ## 文档 | ||
|
|
||
| 暂无 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # [v2.0.0] - 2026-03-25 | ||
|
|
||
| ## 新增 | ||
|
|
||
| - 新增 v2 依赖注入核心能力:Provider 注册、依赖解析、循环检测,以及 `TryProvide` / `TryInject` 安全调用路径。 | ||
| - 新增 `dixtrace` 内存 trace 存储与查询能力,并支持通过环境变量控制 trace 文件落盘。 | ||
| - 新增 `dixhttp` 可视化模块,支持依赖关系与 trace 的 HTTP 查看与调试。 | ||
| - 新增 `dixcontext` 与 `dixglobal` 模块,分别用于 `context.Context` 集成与全局容器便捷封装。 | ||
|
|
||
| ## 修复 | ||
|
|
||
| 暂无 | ||
|
|
||
| ## 变更 | ||
|
|
||
| - 模块主版本升级到 `v2`(`module github.com/pubgo/dix/v2`),并统一公开入口与示例组织。 | ||
| - 诊断与追踪能力统一到 `DIX_TRACE_DI`、`DIX_DIAG_FILE`、`DIX_TRACE_FILE` 等环境变量约定。 | ||
|
|
||
| ## 文档 | ||
|
|
||
| - 更新与完善 `README.md`、`README_zh.md`、`dixhttp/README.md`、`dixhttp/README_zh.md` 及 `docs/*` 文档,覆盖 v2 功能与使用方式。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| version: '3' | ||
| version: 3 | ||
|
|
||
| tasks: | ||
| test: | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.