Files
carbon-lang/scripts/jj_prek.sh
T
Richard Smith 77790e44a6 Refactor and extend tool usage skills (#7338)
Split out the `prek` tool usage instructions into a separate skill. This
should make the agent more likely to realize the skill is relevant to a
particular task and consult it. Extend the skill to include instructions
for using `prek` in a jj workspace, and add a helper script for that
situation.

Add a `jj` skill, with the main purpose being to instruct the agent to
use `jj` not `git`, and to use `--no-pager` when running it.

Extend the `bazel` tool description slightly to more strongly encourage
agents to read and follow it.

Assisted-by: Gemini via Antigravity
2026-06-11 17:18:16 +00:00

23 lines
802 B
Bash
Executable File

#!/usr/bin/env bash
#
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# Runs prek within a jj repository that is backed by a git repository, including
# the case where the repository is a non-colocated jj workspace.
set -eu
# Find the .git directory, and map `@` to a git commit.
export GIT_DIR="$(jj git root --ignore-working-copy)"
HEAD="$(jj show --no-patch --ignore-working-copy -r @ --template 'commit_id')"
# Create a git index file describing `@`.
export GIT_INDEX_FILE="$(mktemp)"
trap 'rm -f "$GIT_INDEX_FILE"' EXIT
git read-tree "$HEAD"
# Run prek with the `.git` directory and index we built earlier.
prek run --from-ref trunk --to-ref "$HEAD"