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
2 changes: 1 addition & 1 deletion hooks/env_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PLUGIN_ROOT = Path(__file__).resolve().parents[1] # hooks/ 的上级 = 插件根(不依赖宿主环境变量)
sys.path.insert(0, str(PLUGIN_ROOT / "scripts"))

from detect_lang import (
from detect_lang import ( # ensure_user_path/load_user_config 实际定义:scripts/paths.py、scripts/user_config.py
LANG_COMMANDS,
REGISTRY,
detect_languages,
Expand Down
2 changes: 1 addition & 1 deletion hooks/post_tool_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
PLUGIN_ROOT = Path(__file__).resolve().parents[1] # hooks/ 的上级 = 插件根
sys.path.insert(0, str(PLUGIN_ROOT / "scripts"))

from detect_lang import (
from detect_lang import ( # ensure_user_path/load_user_config 实际定义:scripts/paths.py、scripts/user_config.py
LANG_COMMANDS,
detect_language,
ensure_user_path,
Expand Down
2 changes: 1 addition & 1 deletion hooks/pre_tool_git_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
sys.path.insert(0, str(PLUGIN_ROOT / "scripts"))
sys.path.insert(0, str(PLUGIN_ROOT / "hooks"))

from detect_lang import ensure_user_path, load_user_config
from detect_lang import ensure_user_path, load_user_config # # ensure_user_path/load_user_config 实际定义:scripts/paths.py、scripts/user_config.py
from gate_lib import (
check_commit_safety,
format_safety_report,
Expand Down
2 changes: 1 addition & 1 deletion hooks/user_prompt_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# 必须静默(子串匹配曾把它们当提交意图跑全仓 lint)。
import re as _re

from detect_lang import (
from detect_lang import ( # # ensure_user_path/load_user_config 实际定义:scripts/paths.py、scripts/user_config.py
detect_languages,
ensure_user_path,
find_project_root,
Expand Down
30 changes: 15 additions & 15 deletions openspec/changes/archive/2026-09-22-add-detect-lang-splits/tasks.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
## 1. New files

- [ ] 1.1 Create `scripts/paths.py` with `ensure_user_path(from_login_shell=False)` plus its internal static-dir and node-availability helpers, copied verbatim from `scripts/detect_lang.py`.
- [ ] 1.2 Create `scripts/user_config.py` with `load_user_config`, `load_project_overrides`, `get_overrides`, copied verbatim from `scripts/detect_lang.py`.
- [x] 1.1 Create `scripts/paths.py` with `ensure_user_path(from_login_shell=False)` plus its internal static-dir and node-availability helpers, copied verbatim from `scripts/detect_lang.py`.
- [x] 1.2 Create `scripts/user_config.py` with `load_user_config`, `load_project_overrides`, `get_overrides`, copied verbatim from `scripts/detect_lang.py`.

## 2. detect_lang.py refactor

- [ ] 2.1 Delete the implementation bodies of `ensure_user_path` and configuration helpers from `scripts/detect_lang.py`.
- [ ] 2.2 Replace them with re-exports (`from paths import ensure_user_path`, `from user_config import load_user_config, load_project_overrides, get_overrides`) and add `__all__` enumerating all externally imported symbols (existing + new re-exports).
- [x] 2.1 Delete the implementation bodies of `ensure_user_path` and configuration helpers from `scripts/detect_lang.py`.
- [x] 2.2 Replace them with re-exports (`from paths import ensure_user_path`, `from user_config import load_user_config, load_project_overrides, get_overrides`) and add `__all__` enumerating all externally imported symbols (existing + new re-exports).

## 3. Hooks annotation

- [ ] 3.1 In each of `hooks/env_check.py`, `hooks/pre_tool_git_guard.py`, `hooks/post_tool_lint.py`, `hooks/user_prompt_validator.py`, append an inline comment to the existing `from detect_lang import ...` line noting the source file (`paths.py` or `user_config.py`).
- [x] 3.1 In each of `hooks/env_check.py`, `hooks/pre_tool_git_guard.py`, `hooks/post_tool_lint.py`, `hooks/user_prompt_validator.py`, append an inline comment to the existing `from detect_lang import ...` line noting the source file (`paths.py` or `user_config.py`).

## 4. Validation

- [ ] 4.1 Run `python3 tests/run_all.py` — all hook simulation, language-registry, unit, CVE, edges, and field-regression subsets must pass.
- [ ] 4.2 Run `python3 -m unittest discover -s tests -p 'test_*.py' -v` — `test_plugin_manifests.py` and `test_skill_vendor.py` must pass (pre-existing baseline).
- [ ] 4.3 Run `git diff --check` — must be clean.
- [ ] 4.4 Run `openspec validate --all --strict` — must pass (3 pre-existing specs + new `language-gate-commands`).
- [ ] 4.5 Run `ruff check scripts/paths.py scripts/user_config.py scripts/detect_lang.py hooks/` — zero lint issues.
- [x] 4.1 Run `python3 tests/run_all.py` — all hook simulation, language-registry, unit, CVE, edges, and field-regression subsets must pass.
- [x] 4.2 Run `python3 -m unittest discover -s tests -p 'test_*.py' -v` — `test_plugin_manifests.py` and `test_skill_vendor.py` must pass (pre-existing baseline).
- [x] 4.3 Run `git diff --check` — must be clean.
- [x] 4.4 Run `openspec validate --all --strict` — must pass (3 pre-existing specs + new `language-gate-commands`).
- [x] 4.5 Run `ruff check scripts/paths.py scripts/user_config.py scripts/detect_lang.py hooks/` — zero lint issues.

## 5. Graph evidence

- [ ] 5.1 Rebuild `code-review-graph` and verify the cross-community edge count between `hooks-gate` and `scripts-scan` drops to ≤4 (was 19).
- [x] 5.1 Rebuild `code-review-graph` and verify the cross-community edge count between `hooks-gate` and `scripts-scan` drops to ≤4 (was 19).

## 6. Release

- [ ] 6.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.0 → 0.6.1.
- [ ] 6.2 Commit plugin repo change, push `main` + tag `v0.6.1`.
- [ ] 6.3 In `full-stack-plugins` market repo, sync catalog `codeguard` to `0.6.1` and regenerate three marketplace manifests; commit and push.
- [ ] 6.4 `openspec archive add-detect-lang-splits` after all tasks above are checked.
- [x] 6.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.0 → 0.6.1.
- [x] 6.2 Commit plugin repo change, push `main` + tag `v0.6.1`.
- [x] 6.3 In `full-stack-plugins` market repo, sync catalog `codeguard` to `0.6.1` and regenerate three marketplace manifests; commit and push.
- [x] 6.4 `openspec archive add-detect-lang-splits` after all tasks above are checked.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
## 1. Document

- [ ] 1.1 Create `hooks/__protocol__.md` with the 6 sections (protocol table / three-host compatibility / fail-open / new-hook checklist / change policy / spec mapping).
- [ ] 1.2 Verify every documented exit code / JSON schema matches the actual implementation in `hooks/*.py` (post_tool_lint.py:226 etc.) — record the matching line numbers.
- [x] 1.1 Create `hooks/__protocol__.md` with the 6 sections (protocol table / three-host compatibility / fail-open / new-hook checklist / change policy / spec mapping).
- [x] 1.2 Verify every documented exit code / JSON schema matches the actual implementation in `hooks/*.py` (post_tool_lint.py:226 etc.) — record the matching line numbers.

## 2. tests/run_all.py annotation

- [ ] 2.1 Add a one-line reference to `hooks/__protocol__.md` in the top-of-file docstring of `tests/run_all.py`..
- [x] 2.1 Add a one-line reference to `hooks/__protocol__.md` in the top-of-file docstring of `tests/run_all.py`..

## 3. Validation

- [ ] 3.1 `python3 -m unittest discover -s tests -p 'test_*.py' -v` — both tests pass.
- [ ] 3.2 `python3 tests/run_all.py` — full 141 / 0 / 0 must hold (hooks/manifests/vendored skills).
- [ ] 3.3 `git diff --check` — clean.
- [ ] 3.4 `openspec validate --all --strict` — pass (3 pre-existing + new `hook-protocol`).
- [ ] 3.5 `grep -c 'exit code\|additionalContext' hooks/__protocol__.md` ≥ 5 (sanity that document has substance).
- [x] 3.1 `python3 -m unittest discover -s tests -p 'test_*.py' -v` — both tests pass.
- [x] 3.2 `python3 tests/run_all.py` — full 141 / 0 / 0 must hold (hooks/manifests/vendored skills).
- [x] 3.3 `git diff --check` — clean.
- [x] 3.4 `openspec validate --all --strict` — pass (3 pre-existing + new `hook-protocol`).
- [x] 3.5 `grep -c 'exit code\|additionalContext' hooks/__protocol__.md` ≥ 5 (sanity that document has substance).

## 4. Release

- [ ] 4.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.2 → 0.6.3.
- [ ] 4.2 Fix in-repo `.agents/plugins/marketplace.json` ref/icon to `v0.6.3`.
- [ ] 4.3 Open PR, wait for vendor-check, merge.
- [ ] 4.4 Push tag `v0.6.3`.
- [ ] 4.5 Sync market repo catalog + README codeguard row to `0.6.3` and push.
- [ ] 4.6 `openspec archive add-host-protocol-cheatsheet` after all tasks above are checked.
- [x] 4.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.2 → 0.6.3.
- [x] 4.2 Fix in-repo `.agents/plugins/marketplace.json` ref/icon to `v0.6.3`.
- [x] 4.3 Open PR, wait for vendor-check, merge.
- [x] 4.4 Push tag `v0.6.3`.
- [x] 4.5 Sync market repo catalog + README codeguard row to `0.6.3` and push.
- [x] 4.6 `openspec archive add-host-protocol-cheatsheet` after all tasks above are checked.
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
## 1. Validator

- [ ] 1.1 Create `scripts/validate_languages_json.py` with the 11-rule set per design.md.
- [ ] 1.2 `python3 scripts/validate_languages_json.py` on current registry must exit 0 (baseline).
- [ ] 1.3 Document CLI flags + exit codes in the script's top docstring.
- [x] 1.1 Create `scripts/validate_languages_json.py` with the 11-rule set per design.md.
- [x] 1.2 `python3 scripts/validate_languages_json.py` on current registry must exit 0 (baseline).
- [x] 1.3 Document CLI flags + exit codes in the script's top docstring.

## 2. Unit tests

- [ ] 2.1 Create `tests/test_validate_languages_json.py` with the 10-test matrix per design.md.
- [ ] 2.2 All tests must pass with the current registry as the baseline fixture.
- [x] 2.1 Create `tests/test_validate_languages_json.py` with the 10-test matrix per design.md.
- [x] 2.2 All tests must pass with the current registry as the baseline fixture.

## 3. CI wiring

- [ ] 3.1 Edit `.github/workflows/skills-check.yml` to add two new steps (validator + unit tests) after the existing unittest discovery.
- [x] 3.1 Edit `.github/workflows/skills-check.yml` to add two new steps (validator + unit tests) after the existing unittest discovery.

## 4. Validation

- [ ] 4.1 `python3 -m unittest discover -s tests -p 'test_*.py' -v` — all pass (existing + new).
- [ ] 4.2 `python3 tests/run_all.py` — full 141 / 0 / 0 must hold.
- [ ] 4.3 `git diff --check` — clean.
- [ ] 4.4 `openspec validate --all --strict` — pass (5 pre-existing + new `languages-registry-contract`).
- [ ] 4.5 `ruff check scripts/validate_languages_json.py tests/test_validate_languages_json.py` — zero new errors.
- [x] 4.1 `python3 -m unittest discover -s tests -p 'test_*.py' -v` — all pass (existing + new).
- [x] 4.2 `python3 tests/run_all.py` — full 141 / 0 / 0 must hold.
- [x] 4.3 `git diff --check` — clean.
- [x] 4.4 `openspec validate --all --strict` — pass (5 pre-existing + new `languages-registry-contract`).
- [x] 4.5 `ruff check scripts/validate_languages_json.py tests/test_validate_languages_json.py` — zero new errors.

## 5. Release

- [ ] 5.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.3 → 0.6.4.
- [ ] 5.2 Fix in-repo `.agents/plugins/marketplace.json` ref/icon to `v0.6.4`.
- [ ] 5.3 Open PR, wait for vendor-check, merge.
- [ ] 5.4 Push tag `v0.6.4`.
- [ ] 5.5 Sync market repo catalog + README codeguard row to `0.6.4` and push.
- [ ] 5.6 `openspec archive add-languages-schema-validator` after all tasks above are checked.
- [x] 5.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.3 → 0.6.4.
- [x] 5.2 Fix in-repo `.agents/plugins/marketplace.json` ref/icon to `v0.6.4`.
- [x] 5.3 Open PR, wait for vendor-check, merge.
- [x] 5.4 Push tag `v0.6.4`.
- [x] 5.5 Sync market repo catalog + README codeguard row to `0.6.4` and push.
- [x] 5.6 `openspec archive add-languages-schema-validator` after all tasks above are checked.
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
## 1. Registry migration

- [ ] 1.1 In `scripts/languages.json`, add `"linter_config_files": [".pre-commit-config.yaml", "checkstyle.xml", "pmd.xml"]` to the `java` entry.
- [ ] 1.2 Same for `rust`, `typescript`, `python` (copy from current `hooks/env_check.py::LINTER_CONFIG_FILES`).
- [ ] 1.3 All other language entries already default to `[]` via validation; explicitly verify no regression.
- [x] 1.1 In `scripts/languages.json`, add `"linter_config_files": [".pre-commit-config.yaml", "checkstyle.xml", "pmd.xml"]` to the `java` entry.
- [x] 1.2 Same for `rust`, `typescript`, `python` (copy from current `hooks/env_check.py::LINTER_CONFIG_FILES`).
- [x] 1.3 All other language entries already default to `[]` via validation; explicitly verify no regression.

## 2. env_check refactor

- [ ] 2.1 In `hooks/env_check.py`, delete the `LINTER_CONFIG_FILES` constant (lines 23-30).
- [ ] 2.2 Add `REGISTRY` to the `from detect_lang import ...` block.
- [ ] 2.3 Rewrite `detect_linter_config` to iterate over `REGISTRY.items()` and read each entry's `linter_config_files`.
- [ ] 2.4 Verify `python3 tests/run_all.py` env_check subset passes (still 5/5 of the existing checks).
- [x] 2.1 In `hooks/env_check.py`, delete the `LINTER_CONFIG_FILES` constant (lines 23-30).
- [x] 2.2 Add `REGISTRY` to the `from detect_lang import ...` block.
- [x] 2.3 Rewrite `detect_linter_config` to iterate over `REGISTRY.items()` and read each entry's `linter_config_files`.
- [x] 2.4 Verify `python3 tests/run_all.py` env_check subset passes (still 5/5 of the existing checks).

## 3. Validator rule

- [ ] 3.1 Add `_check_linter_config_files` to `scripts/validate_languages_json.py` and wire it into `check()`.
- [ ] 3.2 Add 2 unittest cases to `tests/test_validate_languages_json.py`:
- [x] 3.1 Add `_check_linter_config_files` to `scripts/validate_languages_json.py` and wire it into `check()`.
- [x] 3.2 Add 2 unittest cases to `tests/test_validate_languages_json.py`:
- `test_linter_config_files_must_be_list_of_str`
- `test_linter_config_files_can_be_empty`

## 4. Validation

- [ ] 4.1 `python3 scripts/validate_languages_json.py` — exit 0.
- [ ] 4.2 `python3 -m unittest discover -s tests -p 'test_*.py' -v` — pass.
- [ ] 4.3 `python3 tests/run_all.py` — 141 / 0 / 0.
- [ ] 4.4 `git diff --check` — clean.
- [ ] 4.5 `openspec validate --all --strict` — pass.
- [x] 4.1 `python3 scripts/validate_languages_json.py` — exit 0.
- [x] 4.2 `python3 -m unittest discover -s tests -p 'test_*.py' -v` — pass.
- [x] 4.3 `python3 tests/run_all.py` — 141 / 0 / 0.
- [x] 4.4 `git diff --check` — clean.
- [x] 4.5 `openspec validate --all --strict` — pass.

## 5. Release

- [ ] 5.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.4 → 0.6.5.
- [ ] 5.2 Fix in-repo `.agents/plugins/marketplace.json` ref/icon to `v0.6.5`.
- [ ] 5.3 Open PR, wait for vendor-check, merge.
- [ ] 5.4 Tag v0.6.5 (use the `--force-with-lease` workflow if origin tag v0.6.4 is stale).
- [ ] 5.5 Sync market repo catalog + README codeguard row to `0.6.5` and push.
- [ ] 5.6 `openspec archive add-linter-config-from-registry`.
- [x] 5.1 `node scripts/bump-plugin.mjs codeguard patch` — bump 0.6.4 → 0.6.5.
- [x] 5.2 Fix in-repo `.agents/plugins/marketplace.json` ref/icon to `v0.6.5`.
- [x] 5.3 Open PR, wait for vendor-check, merge.
- [x] 5.4 Tag v0.6.5 (use the `--force-with-lease` workflow if origin tag v0.6.4 is stale).
- [x] 5.5 Sync market repo catalog + README codeguard row to `0.6.5` and push.
- [x] 5.6 `openspec archive add-linter-config-from-registry`.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
## 1. Test refactor

- [ ] 1.1 In `tests/test_plugin_manifests.py`, rename `test_each_released_manifest_points_to_the_68_skill_bundle` to `test_each_released_manifest_points_to_the_lock_union_plus_local_skills`.
- [ ] 1.2 Replace `self.assertEqual(68, expected)` with the three-source union assertion: `on_disk == lock_union | local`.
- [x] 1.1 In `tests/test_plugin_manifests.py`, rename `test_each_released_manifest_points_to_the_68_skill_bundle` to `test_each_released_manifest_points_to_the_lock_union_plus_local_skills`.
- [x] 1.2 Replace `self.assertEqual(68, expected)` with the three-source union assertion: `on_disk == lock_union | local`.

## 2. Validation

- [ ] 2.1 Run `python3 -m unittest discover -s tests -p 'test_*.py' -v` — both `test_plugin_manifests.py` and `test_skill_vendor.py` pass.
- [ ] 2.2 Run `git diff --check` — must be clean.
- [ ] 2.3 Run `openspec validate --all --strict` — must pass (3 pre-existing + `language-gate-commands` + new `plugin-manifest-contracts`).
- [x] 2.1 Run `python3 -m unittest discover -s tests -p 'test_*.py' -v` — both `test_plugin_manifests.py` and `test_skill_vendor.py` pass.
- [x] 2.2 Run `git diff --check` — must be clean.
- [x] 2.3 Run `openspec validate --all --strict` — must pass (3 pre-existing + `language-gate-commands` + new `plugin-manifest-contracts`).

## 3. Release

- [ ] 3.1 Commit as part of the same release commit as HIGH 1 (single `release: v0.6.1` covers both changes).
- [ ] 3.2 After archive of `add-detect-lang-splits`, archive `add-manifest-bundle-dynamic` together with it (single release flow).
- [x] 3.1 Commit as part of the same release commit as HIGH 1 (single `release: v0.6.1` covers both changes).
- [x] 3.2 After archive of `add-detect-lang-splits`, archive `add-manifest-bundle-dynamic` together with it (single release flow).
Loading
Loading