Skip to content

fix(hooks): honor --dry-run for inject (#900) - #949

Open
ydflow wants to merge 1 commit into
Tencent:mainfrom
ydflow:fix/hooks-inject-dry-run
Open

ydflow wants to merge 1 commit into
Tencent:mainfrom
ydflow:fix/hooks-inject-dry-run

Conversation

@ydflow

@ydflow ydflow commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

teamai hooks inject --dry-run previously performed a real injection. Forward the preview flag through config loading and shared reconciliation, and report a preview rather than installation.

The patch is rebased onto main 6c5949f, including #958. A preview skips the new Codex trust pass in finally, so it cannot change hook trust or persist the trust fingerprint. Real injection still trusts written hooks, including when reconciliation reports failure or throws after writing hooks. Silent output and error propagation are preserved.

The bilingual usage guides and changelog describe the preview. Skill usage text is left unchanged, following the updated AGENTS.md guidance.

Type of Change

  • Bug fix

Test Plan

Local Windows, Node 24.19.0:

  • Typecheck (npx tsc --noEmit), lint, build, and git diff --check pass.
  • npx vitest run src/__tests__/hooks-cmd.test.ts -t hooksInject: 18 passed. Covers preview/silent/error paths plus the existing normal and failure-path Codex trust cases. Four preview cases fail if the new finally trust call is left unconditional.
  • npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/hooks-inject-dry-run.test.ts: 1 passed against the built CLI. With isolated HOME and a fake Codex JSON-RPC app-server, a fresh preview preserves settings/config/manifest state; normal injection writes the fixture hook and actually performs a trust batch-write; a second preview preserves the installed files, trust fingerprint, and fake app-server state/call history.
  • New-head CI: all six Linux/macOS Node 20/22/24 lint/test jobs, build, and fork-safe E2E pass (85 E2E files passed, 3 skipped; an existing project-hook isolation case passed on its configured retry). CodeCC and Codex PR Review also pass. Credentialed GitHub-provider E2E is skipped by fork policy. No clean full Windows suite or real Codex-service validation is claimed; the fake app-server makes no model or remote API calls.

Related Issues and Coordination

Refs #900 (hooks inject).

#969 is still open at this update. Its guard currently refuses hooks inject. If #969 lands first, this PR must move hooks inject from NO_DRY_RUN_PREVIEW into DRY_RUN_PREVIEW; if this PR lands first, #969 needs that classification change. The current main has no guard file, so this patch does not copy another open PR's implementation.

Shared-State Review

Config migrations are previewed by autoDetectInit. Reconciliation resolves and reports hooks without writing tool settings, managed manifests, or Git hooks under dry-run. The Codex trust pass is the additional writer introduced by #958: it can change Codex trust and save codexTrustFingerprint, so this command skips that pass only for previews. Normal injection and its trust failure handling remain on the upstream path.

Cross-PR integration check (2026-10-04)

In a separate unpublished worktree, combined #969 at 07e512f with this PR and the other preview fix (#949/#951). With the guard's original refusal classifications, all three built-CLI preview cases fail with exit 1. Moving hooks inject and update into DRY_RUN_PREVIEW and removing their NO_DRY_RUN_PREVIEW entries makes both classification tests and all three CLI E2E cases pass. This verifies the required merge-order adjustment; the classification patch belongs to whichever change lands second.

@jeff-r2026 jeff-r2026 self-assigned this Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

No findings.

The PR description includes sufficient testing for this runtime behavior change, including a representative real-CLI end-to-end dry-run verification. I did not run or build the PR, per instructions.

@ydflow
ydflow force-pushed the fix/hooks-inject-dry-run branch from 58d5a88 to f2351bf Compare October 3, 2026 02:19
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

No findings.

The PR description documents sufficient testing for this runtime behavior change, including a representative built-CLI end-to-end dry-run verification. I did not run, build, or install anything from the PR, as instructed.

1 similar comment
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

No findings.

The PR description documents sufficient testing for this runtime behavior change, including a representative built-CLI end-to-end dry-run verification. I did not run, build, or install anything from the PR, as instructed.

@jeff-r2026

Copy link
Copy Markdown
Collaborator

This branch has merge conflicts with main. Please rebase onto the latest main and resolve the conflicts so review can continue.

@SaulMoro

SaulMoro commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Heads-up from #900: #969 adds a --dry-run guard. A command that is not on the allowlist in src/dry-run-guard.ts exits 1 under --dry-run (teamai <cmd> has no --dry-run preview, nothing was run), and a test fails on any command that isn't classified.

hooks inject is currently listed in NO_DRY_RUN_PREVIEW as "no preview until #949 lands", so after both PRs merge your preview is refused before it runs.

@ydflow
ydflow force-pushed the fix/hooks-inject-dry-run branch from f2351bf to 0d539c8 Compare October 4, 2026 02:10
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

No findings.

The PR description documents sufficient testing for this runtime behavior change, including a representative built-CLI end-to-end dry-run verification. I did not run, build, or install anything from the PR, as instructed.

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.

3 participants