Skip to content

refactor(vigutils): migrate shared scripts into vig-utils package entrypoints - #218

Merged
c-vigo merged 10 commits into
devfrom
feature/217-reorganize-scripts-vig-utils
Mar 7, 2026
Merged

c-vigo merged 10 commits into
devfrom
feature/217-reorganize-scripts-vig-utils

Conversation

@c-vigo

@c-vigo c-vigo commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Description

Reorganize the scripts/ directory by migrating all shared utilities into packages/vig-utils/ as proper Python modules with CLI entry points. After this change, scripts/ contains only project-specific container build tooling, while all downstream-shared scripts are importable, testable, and callable by command name via vig-utils entry points.

This resolves the root cause of pre-commit hooks failing in deployed workspaces (#161) — callers no longer reference loose script paths that don't exist downstream; they invoke vig-utils entry points installed via uv pip install.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

Python scripts migrated into vig-utils modules with entry points:

  • scripts/check-agent-identity.py → vig_utils.check_agent_identity (entry point: check-agent-identity)
  • assets/workspace/.devcontainer/scripts/gh_issues.py → vig_utils.gh_issues (entry point: gh-issues)
  • assets/workspace/.devcontainer/scripts/check-pr-agent-fingerprints.py → vig_utils.check_pr_agent_fingerprints (entry point: check-pr-agent-fingerprints)
  • assets/workspace/.devcontainer/scripts/prepare-commit-msg-strip-trailers.py → vig_utils.prepare_commit_msg_strip_trailers (entry point: prepare-commit-msg-strip-trailers)

Shell scripts bundled as package data with wrapper entry points:

  • scripts/check-skill-names.sh → vig_utils/shell/check-skill-names.sh (entry point: check-skill-names)
  • scripts/derive-branch-summary.sh → vig_utils/shell/derive-branch-summary.sh (entry point: derive-branch-summary)
  • scripts/resolve-branch.sh → vig_utils/shell/resolve-branch.sh (entry point: resolve-branch)
  • assets/workspace/.devcontainer/scripts/setup-labels.sh → vig_utils/shell/setup-labels.sh (entry point: setup-labels)

Consolidation & cleanup:

  • vig_utils/utils.py — agent fingerprint helpers (is_agent_commit, is_agent_pr, load_agent_blocklist, agent_display_name) consolidated from duplicated logic in check_agent_identity.py and check_pr_agent_fingerprints.py
  • scripts/utils.py shim removed (superseded by vig_utils.utils)
  • Legacy script copies in assets/workspace/.devcontainer/scripts/ removed
  • Superseded BATS tests (tests/bats/skill-naming.bats) removed — coverage migrated to test_shell_entrypoints.py

Caller updates:

  • justfile.gh, justfile.worktree, assets/workspace/.devcontainer/justfile.gh, assets/workspace/.devcontainer/justfile.worktree — switched from script paths to entry point commands
  • .pre-commit-config.yaml — hooks use entry point commands
  • scripts/manifest.toml — sync entries updated (no more script-path copies)
  • .github/CODEOWNERS, .github/label-taxonomy.toml — paths updated

Tests added:

  • test_shell_entrypoints.py — 156 lines covering all 4 shell wrapper entry points
  • test_check_agent_identity.py — 162 lines
  • test_check_pr_agent_fingerprints.py — 102 lines
  • test_prepare_commit_msg_strip_trailers.py — 107 lines
  • test_utils.py — 498 lines (shared helpers)
  • test_gh_issues.py — migrated from tests/ to packages/vig-utils/tests/

Changelog Entry

Changed

  • Migrate shared scripts into vig-utils package entrypoints (#217, #161, #179)
    • Shell scripts (check-skill-names.sh, derive-branch-summary.sh, resolve-branch.sh, setup-labels.sh) bundled inside vig_utils.shell and exposed as vig-<name> CLI entrypoints
    • Python scripts (gh_issues.py, check-agent-identity.py, check-pr-agent-fingerprints.py, prepare-commit-msg-strip-trailers.py) migrated into vig-utils modules with entrypoints
    • Agent fingerprint helpers consolidated into shared vig_utils.utils module
    • Callers (justfiles, pre-commit hooks, CI workflows) switched from direct script paths to vig-utils entrypoints

Removed

  • Legacy standalone script copies (#217)
    • Removed scripts/check-agent-identity.py, scripts/check-skill-names.sh, scripts/derive-branch-summary.sh, scripts/resolve-branch.sh — now in vig-utils
    • Removed assets/workspace/.devcontainer/scripts/gh_issues.py, check-pr-agent-fingerprints.py, prepare-commit-msg-strip-trailers.py — now in vig-utils
    • Removed scripts/utils.py shim — superseded by vig_utils.utils

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

Deployed to smoke test repository and verified:

  • All vig-utils entry points are callable by command name
  • just gh-issues works end-to-end
  • just precommit hooks pass
  • Justfile recipes using migrated scripts work correctly

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Regarding #185 (make container scripts callable via PATH): This PR effectively resolves #185 through a different mechanism than originally proposed. Instead of adding a scripts directory to PATH, shared scripts are now callable by command name via vig-utils package entry points (uv pip install -e packages/vig-utils). The remaining files in scripts/ are all project-specific build tooling — there are no "deploy-only" scripts left to reorganize.

Refs: #217, #161, #179, #185

@c-vigo
c-vigo force-pushed the feature/217-reorganize-scripts-vig-utils branch from 58057ac to 1814b28 Compare March 7, 2026 07:07
@c-vigo

c-vigo commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

Force-push notice: Rebased onto updated dev (which now includes PR #229) and dropped 6 commits by gerchowl that were merged into this branch by mistake:

The 7 issue-#217 commits are unchanged in content, rebased onto the new dev base. No functional changes.

@gerchowl gerchowl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed: package structure, migrated modules, caller updates, manifest sync, and test coverage. All clean.

Added 4 minor test improvements:

  • CI=true env var path coverage (check_agent_identity)
  • setup-labels entry point availability test
  • Invalid TOML error propagation test (load_blocklist)
  • Stronger assertion on contains_agent_fingerprint call args

gerchowl and others added 2 commits March 7, 2026 16:56
- Add CI=true env var path test for check_agent_identity
- Add setup-labels entry point availability test
- Add invalid TOML error propagation test for load_blocklist
- Strengthen assertion on contains_agent_fingerprint call args

Refs: #217
@c-vigo
c-vigo merged commit 4d4b923 into dev Mar 7, 2026
12 checks passed
@c-vigo
c-vigo deleted the feature/217-reorganize-scripts-vig-utils branch March 7, 2026 21:05
c-vigo added a commit that referenced this pull request Mar 9, 2026
## Description

Fix the inverted `IN_CONTAINER` guard in workspace githooks that
silently allowed host commits through.

Issue #238 describes three defects (A, B, C) from #163. After analysing
the current codebase, **defects A and B were already resolved** by the
`vig-utils` migration (#218):

- **A (wrong `project_root`):** The old
`Path(__file__).resolve().parent.parent` was replaced by
`find_repo_root()` which traverses up from `cwd` looking for `.github/`.
- **B (missing `vig_utils` dependency):** The scripts now live inside
`vig-utils` and are invoked as entry points — no external import needed.

**Defect C** was the only remaining bug: all three workspace githooks
used `= "false"` to check `IN_CONTAINER`, but outside the devcontainer
the variable is typically **unset** (empty string), not the literal
`"false"`. The guard never triggered, so host commits were not blocked.
Changed to `!= "true"` to fail closed.

## Type of Change

- [ ] `feat` -- New feature
- [x] `fix` -- Bug fix
- [ ] `docs` -- Documentation only
- [ ] `chore` -- Maintenance task (deps, config, etc.)
- [ ] `refactor` -- Code restructuring (no behavior change)
- [ ] `test` -- Adding or updating tests
- [ ] `ci` -- CI/CD pipeline changes
- [ ] `build` -- Build system or dependency changes
- [ ] `revert` -- Reverts a previous commit
- [ ] `style` -- Code style (formatting, whitespace)

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

- `assets/workspace/.githooks/pre-commit` — changed `= "false"` to `!=
"true"`
- `assets/workspace/.githooks/prepare-commit-msg` — changed `= "false"`
to `!= "true"`
- `assets/workspace/.githooks/commit-msg` — changed `= "false"` to `!=
"true"`
- `tests/bats/githooks.bats` — new BATS test suite (12 tests: 3 hooks ×
4 scenarios: unset, empty, "false", "true")
- `CHANGELOG.md` — added entry under `### Fixed`

## Changelog Entry

### Fixed

- **IN_CONTAINER guard never triggers on host**
([#238](#238))
- Workspace githooks used `= "false"` but `IN_CONTAINER` is unset (not
`"false"`) outside the devcontainer
- Changed to `!= "true"` in `pre-commit`, `prepare-commit-msg`, and
`commit-msg` hooks to fail closed

## Testing

- [ ] Tests pass locally (`just test`)
- [x] Manual testing performed (describe below)

### Manual Testing Details

BATS test suite `tests/bats/githooks.bats` — 12 tests, all pass:

```
ok 1 pre-commit blocks when IN_CONTAINER is unset
ok 2 pre-commit blocks when IN_CONTAINER is empty
ok 3 pre-commit blocks when IN_CONTAINER is false
ok 4 pre-commit does not show guard message when IN_CONTAINER is true
ok 5 prepare-commit-msg blocks when IN_CONTAINER is unset
ok 6 prepare-commit-msg blocks when IN_CONTAINER is empty
ok 7 prepare-commit-msg blocks when IN_CONTAINER is false
ok 8 prepare-commit-msg does not show guard message when IN_CONTAINER is true
ok 9 commit-msg blocks when IN_CONTAINER is unset
ok 10 commit-msg blocks when IN_CONTAINER is empty
ok 11 commit-msg blocks when IN_CONTAINER is false
ok 12 commit-msg does not show guard message when IN_CONTAINER is true
```

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly (edit
`docs/templates/`, then run `just docs`)
- [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
pasted the entry above)
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published

## Additional Notes

The implementation plan with full triage analysis is posted as a
[comment on issue
#238](#238 (comment)).

Refs: #238
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