Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .agents/plugins/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
"source": {
"source": "url",
"url": "https://github.com/partme-ai/partme-codeguard-plugin.git",
"ref": "v0.14.4"
"ref": "v0.14.5"
},
"policy": {
"installation": "AVAILABLE",
"authentication": "ON_USE"
},
"category": "Developer Tools",
"version": "0.14.4",
"version": "0.14.5",
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
"icon": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.4/assets/official-logo.png",
"icon": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.5/assets/official-logo.png",
"interface": {
"displayName": "代码规范守卫",
"shortDescription": "Trustworthy code checks and Java impact analysis",
"logo": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.4/assets/official-logo.png"
"logo": "https://cdn.jsdelivr.net/gh/full-stack-plugins/codeguard-plugin@v0.14.5/assets/official-logo.png"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeguard",
"version": "0.14.4+codex.20260923",
"version": "0.14.5+codex.20260923",
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
"author": {
"name": "Full Stack Skills / PartMe.AI",
Expand Down
2 changes: 1 addition & 1 deletion .zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"en": "CodeGuard",
"zh-CN": "代码规范检查"
},
"version": "0.14.4",
"version": "0.14.5",
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
"description_i18n": {
"en": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ A plain commit checks the index, not an unstaged repair. Supported preceding git
Checks materialize temporary Git blobs without stash, checkout or modifying the real index. The exact-content gate does not reuse the soft working-tree cache. Missing ignored dependencies remain UNVERIFIED rather than silently falling back to different source content.

Limits: 20,000 tracked files / 256 MiB Git content / 32 MiB per overlay file. Symlinks, submodules, conflicts and unsupported content need separate validation. Complex shell rewrites, arbitrary Git refspecs, dynamic aliases and concurrent edits are not a fully modeled transaction. A hook is not a replacement for protected-branch CI.
One statically readable layer of bash/sh/zsh `-c` or script execution is included in repository and staging analysis; unmodelled indirect Git operations are blocked as UNVERIFIED. Dynamic scripts and subprocess calls assembled by Python/Node remain outside this static model.

There is no “historical debt” exemption based only on an unchanged diagnostic filename; a modified API can break an unchanged caller.

Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Maven 使用 verify 并追加 -DskipTests(测试代码仍编译,仅跳过执
检查在临时目录物化 Git blobs,不 stash、不 checkout、不更改真实 index。精确内容门禁不复用软提醒的工作树缓存。快照缺 ignored 依赖时保持 UNVERIFIED,不改查另一份源码。

限制:20,000 个已跟踪文件 / 256 MiB Git 内容 / 每个覆盖文件 32 MiB。符号链接、子模块、冲突及不支持的内容需要独立验证。复杂 shell 写入、任意 Git refspec、动态别名与并发编辑尚未完整建模;钩子不能替代受保护分支 CI。
仓库归属与拟暂存分析覆盖一层静态可读的 bash/sh/zsh `-c` 或脚本执行;无法建模的间接 Git 操作会以 UNVERIFIED 阻断。动态脚本以及 Python/Node 中拼接的 subprocess 调用仍不在此静态模型内。

不再仅凭“报错文件没修改”豁免历史债:变更 API 也会破坏未修改的调用方。

Expand Down
1 change: 1 addition & 0 deletions docs/current-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ flowchart TD
`execution` 只记录进程证据,不把非零退出自动认定为代码违规。`verdict`、CVE 与 Dockerfile 报告解析决定 PASS、FAIL 或 UNVERIFIED;入口仅按各自协议呈现和聚合退出码。Git 提交检查使用 index 或预测暂存快照,推送检查使用 HEAD;保存钩子只给反馈。计划、未执行和未验证不能宣传为通过。
Git 命令的仓库定位与拟暂存解析共用入口传入的 cwd;显式 `cd`/`git -C` 无法绑定 Git 工作树时,硬门禁给出目标未验证并阻断,不退回到调用者仓或无关子仓。未给出显式目标且调用目录非仓时仍保留 workspace 子仓兜底。静态命令解析不等于完整 Shell 执行模拟。
一条命令链中的 Git 副作用先绑定为仓库与操作的有序对,再按仓库聚合检查面:纯 push 不读取该仓未提交的 index,同仓 commit→push 则保留已有 HEAD 与拟提交内容的并集。仓库级、内联及链式 `skipGate` 均按目标仓与操作顺序生效;已存在的仓库配置也可被同链先行 `git config --unset` 取消。链式设置跨 `||`、`;` 或换行时无法证明生效,门禁要求拆分命令;写入其它文件的 config 设置也不构成本仓豁免。语法、仓库归属、间接脚本与拟暂存分析共用引号/转义感知切分;参数文本中的控制符不能合成豁免。解析能力仍限于受支持的静态 Shell 形态。
一层 `bash`/`sh`/`zsh` 的 `-c`(含组合短选项)及可读脚本现在携带调用目录与正文进入同一 Git 操作计划;脚本内的 `git add` 可进入拟暂存范围,外层和内层 Git 操作按仓分别检查。识别到无法建模的间接 Git 操作、脚本内 `skipGate` 配置变更或跨解释器的暂存/提交关系时,明确以 Git 意图 UNVERIFIED 阻断,不借用调用者仓的检查结果。动态脚本、任意控制流及 Python/Node 中构造的 subprocess 仍未建模。

## 模块所有权

Expand Down
2 changes: 1 addition & 1 deletion kimi.plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeguard",
"version": "0.14.4",
"version": "0.14.5",
"description": "Evidence-backed code checks and Git content gates for AI assistants, with Maven/Gradle module impact analysis. Save hooks provide feedback; unverified checks are explicit.",
"author": {
"name": "Full Stack Skills / PartMe.AI"
Expand Down
7 changes: 7 additions & 0 deletions openspec/changes/refactor-codeguard-architecture/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ flowchart TD
传入的 cwd,不再分别读取进程全局工作目录。Git 根查询故障也保留阻断结论;这些只覆盖
支持的静态命令形态,不能宣称模拟完整 Shell 控制流。

后续收敛一层 Shell 间接执行:从外层命令链提取解释器调用及其调用目录,静态读取
`bash`/`sh`/`zsh` 的 `-c` 文本或脚本正文。内层 Git 操作携带来源命令与调用目录,
供仓库归属、豁免和拟暂存分析复用;外层与内层操作按目标仓聚合。不把 Python/Node
源码误当 Shell 执行计划:它们若被保守静态扫描命中但无法证明行为,返回明确的 Git
意图未验证,不能用外层仓库检查结果代替。仍只支持一层、静态可读的脚本,不推断任意
控制流、动态脚本生成或解释器在运行时调用的 subprocess。

参考:pre-commit 的 [Language Protocol 与通用执行](https://github.com/pre-commit/pre-commit/blob/main/pre_commit/lang_base.py)、[Python 适配器](https://github.com/pre-commit/pre-commit/blob/main/pre_commit/languages/python.py)。只借鉴边界设计,不复制安装环境逻辑或新增插件生态协议。

### 6. 状态基础设施与已完成事件分开
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ index 或工作树;不支持的动态/交互式形态必须明确未验证,
或换行后的配置状态无法静态证明时,MUST 阻断并提示拆分命令,不得猜测已生效。
命令切分 MUST 区分真实 Shell 分隔符和被引用/转义的字面文本;提交消息、echo 参数
或文件路径中的 `;`、`&&` 不得生成虚假的 Git 操作或豁免设置。
对一层可静态读取的 `bash`/`sh`/`zsh` 内联命令(含 `-lc` 等组合短选项)或脚本,Git 副作用的识别、仓库归属与
拟暂存分析 MUST 使用脚本的实际调用目录和同一份内层命令;外层直接 Git 操作与内层操作
不得互相覆盖。若已识别间接 Git 副作用但不能可靠建立仓库或暂存计划,MUST 报告 Git
意图 UNVERIFIED 并阻断,不得回退扫描无关子仓或以错误仓库的 PASS 放行。

#### Scenario: Two repositories have different staging commands
- **WHEN** 一条命令链对 A 执行 add -A、对 B 只提交已暂存内容
Expand Down Expand Up @@ -239,6 +243,26 @@ index 或工作树;不支持的动态/交互式形态必须明确未验证,
- **WHEN** `echo` 的引号参数或 commit 消息包含 `; git config codeguard.skipGate true`
- **THEN** 不产生虚假的 config 设置,随后未豁免的提交仍须检查并阻断违规内容

#### Scenario: Shell wrapper commit uses the invocation repository
- **WHEN** 从 Git 仓执行 `bash -c 'git commit'` 或相对路径脚本,脚本内存在待提交内容
- **THEN** 将内层 commit 绑定到脚本调用目录的 Git 仓,而非报无仓或扫描其子仓

#### Scenario: Script arguments are not interpreter options
- **WHEN** 一个无 Git 副作用的脚本接收名为 `-c` 的普通参数及包含 `git commit` 的文本
- **THEN** 解析器不得把脚本参数当成解释器 `-c` 代码并虚构 Git 副作用

#### Scenario: Inner shell staging remains visible
- **WHEN** 可静态读取的 shell 命令内先 `git add` 敏感文件再提交,或先切换到另一仓再提交
- **THEN** 拟暂存分析包含内层 add 并归属实际目标仓;同链外层 Git 操作仍分别检查

#### Scenario: Staging crosses an interpreter boundary
- **WHEN** 独立的 shell 包装器只执行 `git add`,之后外层或另一个包装器才提交
- **THEN** 无法证明完整拟暂存计划时报告 Git 意图 UNVERIFIED 并阻断;若 add 仅发生于纯 push 之后且无后续提交,不扩张该 push 的检查面

#### Scenario: Unmodelled indirect Git operation cannot borrow another repository
- **WHEN** 非 Shell 解释器脚本静态命中 Git 副作用,但无法可靠推断其执行目录与暂存动作
- **THEN** 返回 Git 意图 UNVERIFIED,不以调用者的其它仓库或兜底子仓的结果替代

#### Scenario: An explicit Git target is not a repository
- **WHEN** 命令从 Git 仓调用,但在 `cd` 到非 Git 目录后运行 `git push`,或使用无效的 `git -C` 目标
- **THEN** 门禁以明确诊断阻断,而不是检查调用者仓或用 workspace 兜底;后续显式 `git -C` 指向有效仓时仍能正确绑定该仓
Expand Down
4 changes: 2 additions & 2 deletions openspec/changes/refactor-codeguard-architecture/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
- [x] 5.1 增加自动架构依赖/循环检查并接入 CI,临时源码树注入反向依赖/函数内导入/相对导入环后确实拒绝;本地已验证,远端 CI 待发布阶段。不以文件行数当合格标准。
- [x] 5.2 四个历史 skipped 已全部恢复;Dockerfile CLI 接入统一报告解析与扫描应用,14 项真实进程边界测试通过;基线比较按诊断内容和次数核验并要求基线实际 FAIL,三项误豁免用例先红后绿。完整 433 项单测零跳过、142 项回归零失败。
- [x] 5.3 新增当前架构 Mermaid 与扩展指南;报告版本读取插件 manifest,双语 README 指向当前证据,旧设计标明历史范围;双语标题/链接/版本及本地链接存在性测试通过。发布版本仍需在 5.5 检查。
- [x] 5.4 全量单测/真实 hook 回归/ruff/语言 schema/vendor 离线与在线/本 change strict 和逐条规格追溯通过;第十八批 481 项单测、143 项真实 Hook 回归、57 项/11 规则,证据见 verification.md。仅证明本地契约,不等同三宿主现场验收。
- [ ] 5.5 按仓规升级版本、生成市场元数据、授权的 PR/CI/不可变 tag/Release 闭环;v0.14.3 阶段版本已完成插件/市场双仓合并、PR/main CI、tag/Release,但本 change 后续改动仍需独立发布。宿主安装运行独立记录,未授权不得改宿主。
- [x] 5.4 全量单测/真实 hook 回归/ruff/语言 schema/vendor 离线与在线/本 change strict 和逐条规格追溯通过;第十九批 495 项单测、143 项真实 Hook 回归、57 项/11 规则,证据见 verification.md。仅证明本地契约,不等同三宿主现场验收。
- [ ] 5.5 按仓规升级版本、生成市场元数据、授权的 PR/CI/不可变 tag/Release 闭环;v0.14.4 阶段版本已完成插件/市场双仓合并、PR/main CI、tag/Release,但第十九批新改动仍需独立发布。宿主安装运行独立记录,未授权不得改宿主。
- [ ] 5.6 完成全目标审计,代码/规格/证据一致后同步并归档 change,才可将整体优化标记完成。
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,11 @@
- 追加 RED:`git config --file=其它文件` 错被当成本仓豁免;`git config ... || git commit` 错把仅在设置失败时才会执行的提交放行。现在前者不构成豁免,后者及 `;`/换行连接的配置状态报告 UNVERIFIED 并要求拆分命令。未把完整 Shell 求值器伪装成已实现。
- 完整单测 **479/479、0 skipped**;真实 Hook 回归 **143/0/0**。Ruff、架构依赖/循环、语言 schema **57 项/11 规则**、vendor 离线及在线、本 change strict、diff whitespace 均通过;受管技能及 lock 未改。测试覆盖真实 Git/快照与应用层故障,但静态 Shell 解析仍非完整求值器,三宿主现场、Windows、在线漏洞库和全部语言工具链仍未独立验收。本批发布闭环待执行。
- 后续 RED 发现:`echo "docs; git config codeguard.skipGate true" && git commit` 会把引号内分号当真实分隔符,错误放行含 `.env` 的提交。语法/仓库/间接脚本/拟暂存改用同一个引号及转义感知切分函数;真实 Git 提交安全用例与纯语法用例转绿。复核后完整单测 **481/481、0 skipped**,真实 Hook 回归 **143/0/0**;Ruff、架构依赖/循环、语言 schema **57 项/11 规则**、vendor 离线及在线、本 change strict、diff whitespace 均通过。本批发布证据仍待补齐。
- 第十八批随后发布为 v0.14.4:插件 PR #50、市场 PR #7 已合并双仓 `main`;插件合并后 `skills-check` 成功,注释 tag 解引用到 `be619cd4b769495280c7d0d7405f9b01a8ca4dc9`,GitHub Release 正式发布;市场 Codex/ZCode/Kimi 清单及双语导航均为 0.14.4。此证据仅覆盖第十八批及此前代码,不覆盖以下新工作树。

## 第十九批实际验证:一层 Shell 间接 Git 操作归属

- 将最新 v0.14.4 `main` 同步至已有临时 CodeGraph 索引(136 文件;源码仓不建索引),沿 `PreToolUse → evaluate_git_command → _guarded_mode/resolve_git_operations → staging_intent` 追出检测与归属分叉。真实临时 Git 仓先 RED:`bash -c 'git commit'` 在调用仓报“无仓”;内层 `git add .env` 不进拟暂存面;外层已有 commit 时忽略后续 Shell 脚本对另一仓的 commit;`cd` 后相对脚本找不到。上述都可能让宿主得到错误仓库或错误范围的结论。
- 一层 bash/sh/zsh `-c`(含 `-lc`)或可读脚本现在按解释器实际参数位置、调用目录解析;内层 Git 操作携带来源正文与 cwd,和外层操作按仓聚合。拟暂存分析合并外层与内层来源,真实 Hook 子进程证明未实际执行 `git add` 就拦截 `.env` 且 index 字节不变。纯 push 不纳入未提交 index;外层 skipGate 设置只传递给所属仓的内层操作。
- 不能可靠建模的 Python/Node 间接命中、脚本内 skipGate 配置变化、交互暂存与后续提交跨解释器边界时,明确返回 Git 意图 UNVERIFIED 并阻断;仅在纯 push 之后的独立暂存不误扩该 push 面。脚本的普通 `-c` 参数不再被误认成解释器代码。动态脚本与任意 subprocess 构造仍是未覆盖边界。
- RED→GREEN 的目标用例及最终完整单测 **495/495、0 skipped**;真实 Hook 回归 **143/0/0**。Ruff、架构门禁、语言 schema **57 项/11 规则**、vendor 离线与在线、本 change strict、diff whitespace 均通过。受管技能及 lock 未改;这些是本地契约证据,不是三宿主安装、在线漏洞库、Windows 或第十九批发布证据。本批已准备 v0.14.5 元数据;远端发布须另行核对 PR、CI、tag、Release 与市场主线。
Loading
Loading