Files
ghbot/.claude/helpers/graft-statusline.cjs
T
lezi-fun 9e47ab339e feat: sync ghbot-Nodeloc v1.2.0 capabilities into upstream
Merges all 33 commits from lza6/ghbot-Nodeloc (v1.0.0 through v1.2.0)
while keeping both sides' features in every conflicted file:

- EventRouter dispatch extracted from runReview.ts (7.1), with the
  runtime environment block preserved on the review-start comment
- Unified command ack messages (6.3) combined with the collapsed
  runtime environment block and bot signature on /recheck replies
- Status banner and collapsible unposted findings in review bodies (6.1)
- Centralized runtime directories behind GHBOT_RUNTIME_DIR (D-13);
  webhook knowledge cache now lives under tempRootDirectory()
- Production hardening for merge races, timeouts, webhook ops;
  atomic temp-file rename for R2 cache restores kept from upstream
- Webhook parity retained: triage events gated by WEBHOOK_TRIAGE_ENABLED,
  read-only command guidance, repository knowledge injection,
  runtime environment block on webhook chat replies
- Sanitization/secret redaction centralization, error-aware retry,
  duplicate merge prevention, in-process webhook retries, /metrics
- Infra: eslint/prettier gates with CI verify workflow, docs archives

typecheck, eslint, prettier format:check, and 164 tests all pass.
2026-08-24 11:47:28 +08:00

59 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
const path = require("path");
const fs = require("fs");
const { pathToFileURL } = require("url");
const { execFileSync } = require("child_process");
const dir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
const BAKED =
"C:\\Users\\Administrator.DESKTOP-EGNE9ND\\AppData\\Roaming\\npm\\node_modules\\@nanonets\\graft\\dist\\claude";
// The dist/claude dir of @nanonets/graft resolved from a base whose node_modules is searched.
function fromPkg(base) {
try {
const pkg = require.resolve("@nanonets/graft/package.json", { paths: [base] });
return path.join(path.dirname(pkg), "dist", "claude");
} catch {
return null;
}
}
// The global node_modules dir per npm (handles Homebrew/Windows/volta). Queried on demand.
function globalRoot() {
try {
const root = execFileSync("npm", ["root", "-g"], {
encoding: "utf8",
stdio: ["ignore", "pipe", "ignore"],
shell: process.platform === "win32"
}).trim();
return root || null;
} catch {
return null; /* npm unavailable */
}
}
function candidates() {
const out = [];
if (BAKED) out.push(BAKED);
const local = fromPkg(dir);
if (local) out.push(local);
const legacy = fromPkg(path.join(path.dirname(process.execPath), "..", "lib"));
if (legacy) out.push(legacy);
const gr = globalRoot();
if (gr) out.push(path.join(gr, "@nanonets", "graft", "dist", "claude"));
return out;
}
function entry(name) {
for (const d of candidates()) {
const f = path.join(d, name);
if (fs.existsSync(f)) return f;
}
return path.join(dir, "dist", "claude", name); // last-ditch; import will no-op if absent
}
import(pathToFileURL(entry("statusline.js")).href)
.then((m) => m.main())
.catch(() => {
/* graft unavailable — no-op */
});