Files
gstack/bin/gstack-greptile-early
T
garrytanandcapy-ai[bot] 7c836376c3 feat(greptile-early): detect Greptile, ask once on public repos, open the early draft, wait for the review
bin/gstack-greptile-early backs /ship's early Greptile PR:
- detect: a root .greptile/ folder (which takes precedence), greptile.json,
  or a Greptile comment on the repo in the last 90 days; triggerOnDrafts from
  the effective root config; repo visibility; public-repo consent. It prints
  the signal, that /ship will push and open a draft now, the 10-minute wait
  cap and the absolute gstack-config command that turns it off.
- consent yes|no: the public-repo answer, remembered per repo in the
  project's state.
- open: opens the draft through gstack-post with a body saying /ship opened
  it early, and posts one @greptileai comment through gstack-post when the
  config does not set triggerOnDrafts: true. An open PR is left alone.
- wait: polls every 30 s for a completed Greptile check run, a Greptile
  review of the head commit or a summary naming it; each call returns within
  about 90 s and reports timeout 10 minutes after the PR opened.

gstack-config gains ship_greptile_early (default true, invalid values
rejected): on automatically whenever the repo uses Greptile, off per user.
The logic is in lib/greptile-early.ts behind an injectable runner, so its
fixture-repo tests run in the Windows lane; an end-to-end test drives the
real helper and gstack-post against a stub gh.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-10-07 20:27:14 +00:00

30 lines
1.2 KiB
TypeScript
Executable File

#!/usr/bin/env bun
/**
* gstack-greptile-early — /ship's early Greptile review (detect, consent, open, wait).
*
* gstack-greptile-early detect
* gstack-greptile-early consent yes|no
* gstack-greptile-early open --base <branch> --title-file <file> [--ready] [--confirm <token>]
* gstack-greptile-early wait <pr-number> --since <epoch-seconds>
*
* On by default when the repo uses Greptile; `gstack-config set
* ship_greptile_early false` turns it off. Logic: lib/greptile-early.ts.
*/
import * as path from "path";
import { spawnSync } from "child_process";
import { runGreptileEarly } from "../lib/greptile-early";
process.exitCode = runGreptileEarly(process.argv.slice(2), {
run(cmd, args, input) {
const r = spawnSync(cmd, args, { input: input ?? "", encoding: "utf8", timeout: 120_000, maxBuffer: 16 * 1024 * 1024 });
return { status: r.status ?? 1, stdout: r.stdout ?? "", stderr: r.stderr ?? (r.error ? String(r.error) : "") };
},
vars: process.env,
binDir: path.resolve(import.meta.dir),
bun: process.execPath,
now: () => Date.now(),
sleep: (ms) => Bun.sleepSync(ms),
out: (t) => process.stdout.write(t),
err: (t) => process.stderr.write(t),
});