/** * Raw git query helpers for the git plugin — reusable functions that * shell out to git and return trimmed raw data (or `null` on any * failure). Exposed so downstream plugins can compose per-directory * scans without re-implementing the shell invocations, and so the * predicates in this plugin stay thin pattern-matching wrappers * around the helpers. * * Each helper: * * - takes `(ctx, cwd?)`; `cwd` defaults to `ctx.cwd`, letting * callers iterate over per-subpackage git dirs (common in * multi-package workspace contexts like `cr --all`). * - returns the raw data on success, `null` on any failure * (non-zero exit, spawn error, exception thrown inside * `ctx.exec`). Callers layer their own "what does null mean" * policy — predicates apply `onUnknown`; custom logic can * inspect the null directly. * - relies on the evaluator's per-tool_call `exec` memoization * (`(cmd, args, cwd)` tuple) so multiple helpers reading the * same repo state don't re-fork git. * * ## Consumer note * * The helpers return **raw query results** and are INTENTIONALLY free * of the `onUnknown` / pattern-matching layer. That layer lives in * `predicates.ts`. If you want predicate-style semantics, call the * matching `when.*` handler (also re-exported from the plugin index) * rather than the helper. * * ## Branch caveat * * {@link getBranch} intentionally DOES NOT consult `walkerState.branch` * — the walker-state short-circuit is a predicate-layer concern (see * the `branch` predicate's JSDoc for the three-way tracker * discrimination). Downstream plugins iterating per-directory usually * care about the on-disk branch at each directory, not the * walker-tracked branch of the current bash chain at `ctx.cwd`; the * helper therefore always shells out. */ import type { PredicateContext } from "../../schema.ts"; /** * `git branch --show-current` at `cwd` (default: `ctx.cwd`). Returns * the current branch name, or `null` when the command fails OR stdout * is empty (detached HEAD). * * Does NOT consult `ctx.walkerState.branch` — see file header * "Branch caveat" for why. Predicates that need the walker-state * short-circuit should use the `branch` predicate handler instead. */ export declare function getBranch(ctx: PredicateContext, cwd?: string): Promise; /** * `git rev-parse --abbrev-ref @{upstream}` at `cwd` (default: * `ctx.cwd`). Returns the tracking branch name (e.g. `origin/main`), * or `null` when no upstream is configured or the command fails. */ export declare function getUpstream(ctx: PredicateContext, cwd?: string): Promise; /** * `git rev-list --count ..HEAD` at `cwd` (default: `ctx.cwd`). * Returns the number of commits HEAD is ahead of `wrt`, or `null` * when the command fails (e.g. `wrt` doesn't resolve, detached HEAD, * not a repo). * * `wrt` defaults to `@{upstream}`. Pass a specific ref like * `"origin/main"` when the upstream configuration isn't guaranteed. */ export declare function getCommitsAhead(ctx: PredicateContext, wrt?: string, cwd?: string): Promise; /** * `git diff --cached --quiet` at `cwd` (default: `ctx.cwd`). Exit * code discrimination: * * - `0` → no staged changes → returns `false` * - `1` → staged changes exist → returns `true` * - anything else (spawn error, weird exit) → returns `null` */ export declare function getStagedChanges(ctx: PredicateContext, cwd?: string): Promise; /** * `git status --porcelain` at `cwd` (default: `ctx.cwd`). Returns * `true` when the working tree is clean (empty output), `false` * when dirty, `null` on any command failure. */ export declare function getWorkingTreeClean(ctx: PredicateContext, cwd?: string): Promise; /** * `git config --get remote.origin.url` at `cwd` (default: `ctx.cwd`). * Returns the origin URL string, or `null` when no origin is * configured or the command fails. */ export declare function getRemoteUrl(ctx: PredicateContext, cwd?: string): Promise; //# sourceMappingURL=git-ops.d.ts.map