Skip to content

Port the shared skill library (lib.sh, agent.sh, signing.sh, gates.py) to Go #321

Open
0 of 10 issues completed
Open

Description

@tbhb-agent

Outcome

Move the shared skill library (lib.sh, agent.sh, signing.sh,
gates.py) into Go packages behind agentrepo subcommands, behind
one permanent thin launcher.

The area's own non-owner shell fallbacks are removed by the last
child. The owner-path shell (agent.sh, signing.sh, lib.sh) is
deleted by two cutover issues under #588, which this epic does not
wait on. The transaction skill scripts (#322 to #327) are ported by
their own issues, which depend on this epic, so the exec-only wrapper
state is not part of this outcome.

Part of #588. Phase 1 (internal/config and agentrepo config) is
already merged.

Done when

  • Every child below and every existing child listed is closed.
  • The three suites in tests/skills/source/lib/ are deleted or
    cut to cases that need a real shell, and the retirement ledger
    accounts for every Bats case.
  • The intentional behavior changes (gate locale, note continuity,
    a missing or too-old binary stopping the already-ported
    subcommands) are listed.
  • Machine-only settings are still read from machine configuration
    only.
  • The Go tests pass on macOS, Linux and Windows.
  • The minimum supported version is raised, with the warning
    period evidenced.
  • The leak scans come back clean for this epic's own text and
    posts.
  • A closing comment checks every item above against evidence.

Children

Build order follows this list; the generator child goes first. The
two-digit identifiers are stable references used in the child bodies.
Child 07 was withdrawn and its script moved to #331, so the numbering
skips it.

Existing children that stay under this epic:

Out of scope

The two cutover issues filed directly under #588: the first deletes
lib.sh and its generated copies, the second deletes agent.sh,
signing.sh and their generated copies. Each needs the owner's
exact-head review, and this epic does not wait on them.

The transaction ports (#322 to #327), and the watch-checks script,
which #331 owns.

Owner

tbhb-dev/devtools

Activity

  1. added
    change:featPR adds or changes a feature (Conventional Commit type feat)
    on Oct 20, 2026
  2. tbhb-agent commented on Oct 21, 2026

    @tbhb-agent
    ContributorAuthor

    The operator's P0 is moving all shared skill logic to Go, leaving only short wrappers that exec a binary, and replacing the corresponding bats coverage. I will send this as a sequence of reviewable PRs, starting with configuration only.

    1. Configuration (this PR). Add internal/skillconfig with separate machine Machine(key, fallback) and repository Repository(key, fallback) lookups. Machine lookup preserves explicit empty environment values, then reads the XDG devtools per-repository file (using the main checkout name across worktrees), then devtools.conf, then the fallback. Repository lookup validates the entire .agents/agent-skills.conf, accepts only the existing behavior-key allowlist, and refuses duplicates, unknown keys and non-regular/symlink files. Reviewer, delegation checker, GitHub login and sign-off identity never come from a repository file. Expose agentrepo config machine KEY [DEFAULT] and agentrepo config repository KEY [DEFAULT]; replace dt_conf and dt_repo_conf bodies with calls to those commands. Table-driven Go tests and old/new parity fixtures precede deleting the migrated bats assertions. Generate skills, measure tokens and install APM output, then run lint and test.
    2. Harness and workflow context. Add internal/harness APIs for harness/session detection and repository/worktree context, preserving environment precedence and path fallbacks. Expose agentrepo harness detect, agentrepo harness session, and context plumbing needed by remaining scripts. Move the matching bats cases after parity checks.
    3. Gate execution and cache. Add internal/gates APIs to fingerprint inputs, look up/store successful passes, and run gates with streamed output and preserved statuses. Expose agentrepo gates run and cache plumbing; replace gates.py and gate shell logic. Fold in Skills export LC_ALL=C into the repository gates they run, breaking UTF-8 tools such as Ansible #379: repository gates run in the caller's locale, with UTF-8 fallback when absent; C locale is scoped to internal text processing. Compare cache invalidation, command changes, dirty trees, failures and locale using the same fixtures.
    4. Review snapshots and stamps. Extend internal/review (reuse its existing process-group deadline runner) and add internal/stamp: gather immutable inputs, build prompts, parse verdicts, validate freshness and atomically record bound stamps. Expose agentrepo review snapshot|execute and agentrepo stamp verify plumbing while per-workflow review entry points remain in transition. Fold in commit.sh's second review drops the operator note the first review was given #380: snapshot the operator note, pass the same note to both reviews and bind its digest; changed or removed notes invalidate approval. Verify timeout/tree killing never stamps, moved inputs, policy authority and refusal/status parity before removing shell implementations.
    5. Confirmation and unattended policy. Add internal/confirmation with explicit operator flag -> session preapproval -> machine-selected delegation checker, preserving 0/1/75 and separate unattended delegation-only authorization. Expose agentrepo confirmation resolve and agentrepo delegation check, plus bounded-round/reporting plumbing for agent.sh. Fold in the touched merge-policy diagnostics from devtools can't merge itself through agent-merge-pr: no agent-skills.conf, and the error hides why #378: safe fail() messages reach stderr, identifying empty keys rather than printing only an exception type. Repository merge policy itself remains explicit repository data.
    6. Quota and GitHub identity. Add internal/ghquota for command execution, quota/reset diagnostics and identity checks without retrying writes or adding polling. Expose agentrepo github run|identity for remaining scripts. Preserve REST/GraphQL accounting and 76 on quota exhaustion using fake gh fixtures.
    7. Signing integration and shared-library retirement. Reuse internal/signing and its existing machine-only configuration, adding the skill-facing probe/ensure APIs and agentrepo signing probe|ensure adapters for signing.sh. Preserve signing failures and partial-success reporting with fake tools plus real disposable SSH fixtures. Remove shared shell logic once every behavior has Go coverage; wrappers only set arguments/environment and exec one command. Coordinate subsequent transaction ports Move the commit and agent-commit scripts into agentrepo commit #322–Move the fix-prose and write-prose-fix scripts into agentrepo prose #327 with these APIs; do not introduce agentstore or agentcontext.

    For every PR, run old and new implementations on the same hermetic fixtures before removing the corresponding shell. Compare exit code, stdout, stderr, files written and refusals; use fake git/gh for failure producers and real scratch repositories/worktrees where filesystem and Git behavior matter. Keep the old configuration implementation as a frozen test fixture for repeatable phase-1 parity. Most tests exercise Go APIs in process; a small command/wrapper suite verifies wiring. Retain bats cases only for behavior not migrated yet, then delete each suite when its last behavior moves. Run platform-appropriate Go tests on Linux, macOS and Windows; shell parity runs where bash/awk are available. Each PR refreshes generated skills, tokens and lock output and passes mise run lint and mise run test.

    Phase 1 will reference #321 without closing it. No merge or CI wait in this run.

  3. removed
    change:featPR adds or changes a feature (Conventional Commit type feat)
    on Oct 22, 2026
  4. changed the issue type fromtoon Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Work type

    Planned

    Priority

    Intangible

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions