@synkro-sh/cli 1.4.9 → 1.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bootstrap.js CHANGED
@@ -4432,31 +4432,38 @@ var init_pueue = __esm({
4432
4432
  });
4433
4433
 
4434
4434
  // cli/local-cc/prompts.ts
4435
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
4435
+ import { readFileSync as readFileSync9 } from "fs";
4436
4436
  import { homedir as homedir9 } from "os";
4437
4437
  import { join as join10 } from "path";
4438
- function loadCachedPrompts() {
4439
- if (_cached) return _cached;
4440
- if (!existsSync11(CACHE_PATH2)) {
4441
- throw new Error("Prompts cache not found. Run `synkro install` or `synkro update` first.");
4442
- }
4438
+ async function fetchPrimers() {
4439
+ let jwt2 = "";
4440
+ let gatewayUrl = "";
4443
4441
  try {
4444
- _cached = JSON.parse(readFileSync9(CACHE_PATH2, "utf-8"));
4445
- return _cached;
4442
+ const creds = JSON.parse(readFileSync9(CREDS_PATH, "utf-8"));
4443
+ jwt2 = creds.access_token || "";
4444
+ gatewayUrl = creds.gateway_url || "https://api.synkro.sh";
4446
4445
  } catch {
4447
- throw new Error("Prompts cache is corrupted. Run `synkro update` to refresh.");
4446
+ throw new Error("No credentials found. Run `synkro install` first.");
4448
4447
  }
4448
+ if (!jwt2) throw new Error("No access token. Run `synkro install` first.");
4449
+ const resp = await fetch(`${gatewayUrl}/api/v1/cli/judge-prompts`, {
4450
+ headers: { Authorization: `Bearer ${jwt2}` },
4451
+ signal: AbortSignal.timeout(5e3)
4452
+ });
4453
+ if (!resp.ok) throw new Error(`Failed to fetch prompts: ${resp.status}`);
4454
+ return resp.json();
4449
4455
  }
4450
- function getPrimer(role) {
4451
- const cache = loadCachedPrompts();
4452
- const primer = role === "grade-edit" ? cache.grader_primer_edit : cache.grader_primer_bash;
4456
+ async function getPrimer(role) {
4457
+ const prompts = await fetchPrimers();
4458
+ const primer = role === "grade-edit" ? prompts.grader_primer_edit : prompts.grader_primer_bash;
4453
4459
  if (!primer) {
4454
- throw new Error(`No cached primer for role "${role}". Run \`synkro update\` to refresh prompts.`);
4460
+ throw new Error(`No primer for role "${role}" returned from API.`);
4455
4461
  }
4456
4462
  return primer;
4457
4463
  }
4458
- function buildChannelContent(role, payload) {
4459
- return `${getPrimer(role)}
4464
+ async function buildChannelContent(role, payload) {
4465
+ const primer = await getPrimer(role);
4466
+ return `${primer}
4460
4467
 
4461
4468
  ${CHANNEL_REPLY_INSTRUCTIONS}
4462
4469
 
@@ -4465,12 +4472,11 @@ PAYLOAD (the input to evaluate):
4465
4472
 
4466
4473
  ${payload}`;
4467
4474
  }
4468
- var CACHE_PATH2, _cached, CHANNEL_REPLY_INSTRUCTIONS;
4475
+ var CREDS_PATH, CHANNEL_REPLY_INSTRUCTIONS;
4469
4476
  var init_prompts = __esm({
4470
4477
  "cli/local-cc/prompts.ts"() {
4471
4478
  "use strict";
4472
- CACHE_PATH2 = join10(homedir9(), ".synkro", "prompts", "judge-prompts.json");
4473
- _cached = null;
4479
+ CREDS_PATH = join10(homedir9(), ".synkro", "credentials.json");
4474
4480
  CHANNEL_REPLY_INSTRUCTIONS = `
4475
4481
  DELIVERY METHOD \u2014 MANDATORY, OVERRIDES ALL OTHER OUTPUT RULES:
4476
4482
  You are running inside a Synkro MCP channel. Do NOT output your verdict as text.
@@ -4482,7 +4488,7 @@ Any text output is silently discarded. Only the reply tool call is captured.`;
4482
4488
  });
4483
4489
 
4484
4490
  // cli/local-cc/turnLog.ts
4485
- import { appendFileSync, existsSync as existsSync12, mkdirSync as mkdirSync8, openSync as openSync2, readFileSync as readFileSync10, readSync, closeSync as closeSync2, statSync, watchFile, unwatchFile } from "fs";
4491
+ import { appendFileSync, existsSync as existsSync11, mkdirSync as mkdirSync8, openSync as openSync2, readFileSync as readFileSync10, readSync, closeSync as closeSync2, statSync, watchFile, unwatchFile } from "fs";
4486
4492
  import { dirname as dirname5, join as join11 } from "path";
4487
4493
  import { homedir as homedir10 } from "os";
4488
4494
  function truncate(s, max = PREVIEW_MAX) {
@@ -4520,7 +4526,7 @@ function appendTurn(args2) {
4520
4526
  }
4521
4527
  }
4522
4528
  function readRecentTurns(n = 20) {
4523
- if (!existsSync12(TURN_LOG_PATH)) return [];
4529
+ if (!existsSync11(TURN_LOG_PATH)) return [];
4524
4530
  try {
4525
4531
  const size = statSync(TURN_LOG_PATH).size;
4526
4532
  if (size === 0) return [];
@@ -4541,7 +4547,7 @@ function readRecentTurns(n = 20) {
4541
4547
  function followTurns(onEntry) {
4542
4548
  try {
4543
4549
  mkdirSync8(dirname5(TURN_LOG_PATH), { recursive: true });
4544
- if (!existsSync12(TURN_LOG_PATH)) {
4550
+ if (!existsSync11(TURN_LOG_PATH)) {
4545
4551
  appendFileSync(TURN_LOG_PATH, "", "utf-8");
4546
4552
  }
4547
4553
  } catch {
@@ -4612,7 +4618,7 @@ var init_turnLog = __esm({
4612
4618
  import { request as httpRequest } from "http";
4613
4619
  import { connect as connect2 } from "net";
4614
4620
  async function submitToChannel(role, payload, opts = {}) {
4615
- const content = buildChannelContent(role, payload);
4621
+ const content = await buildChannelContent(role, payload);
4616
4622
  const body = JSON.stringify({ role, content });
4617
4623
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
4618
4624
  const startedAt = Date.now();
@@ -4709,7 +4715,7 @@ __export(install_exports, {
4709
4715
  installCommand: () => installCommand,
4710
4716
  parseArgs: () => parseArgs
4711
4717
  });
4712
- import { existsSync as existsSync13, mkdirSync as mkdirSync9, writeFileSync as writeFileSync8, chmodSync as chmodSync2, readFileSync as readFileSync11, readdirSync } from "fs";
4718
+ import { existsSync as existsSync12, mkdirSync as mkdirSync9, writeFileSync as writeFileSync8, chmodSync as chmodSync2, readFileSync as readFileSync11, readdirSync } from "fs";
4713
4719
  import { homedir as homedir11 } from "os";
4714
4720
  import { join as join12 } from "path";
4715
4721
  import { execSync as execSync5 } from "child_process";
@@ -4813,7 +4819,7 @@ function shellQuoteSingle(value) {
4813
4819
  }
4814
4820
  function resolveSynkroBundle() {
4815
4821
  const scriptPath = process.argv[1];
4816
- if (scriptPath && existsSync13(scriptPath)) return scriptPath;
4822
+ if (scriptPath && existsSync12(scriptPath)) return scriptPath;
4817
4823
  return null;
4818
4824
  }
4819
4825
  function writeConfigEnv(opts) {
@@ -4833,7 +4839,7 @@ function writeConfigEnv(opts) {
4833
4839
  `SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
4834
4840
  `SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
4835
4841
  `SYNKRO_INFERENCE=${shellQuoteSingle(safeInference)}`,
4836
- `SYNKRO_VERSION=${shellQuoteSingle("1.4.9")}`
4842
+ `SYNKRO_VERSION=${shellQuoteSingle("1.4.10")}`
4837
4843
  ];
4838
4844
  if (safeSynkroBin) lines.push(`SYNKRO_CLI_BIN=${shellQuoteSingle(safeSynkroBin)}`);
4839
4845
  if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
@@ -4848,7 +4854,7 @@ function writeConfigEnv(opts) {
4848
4854
  chmodSync2(CONFIG_PATH3, 384);
4849
4855
  }
4850
4856
  function updateLocalInferenceFlag(enabled) {
4851
- if (!existsSync13(CONFIG_PATH3)) return;
4857
+ if (!existsSync12(CONFIG_PATH3)) return;
4852
4858
  let content = readFileSync11(CONFIG_PATH3, "utf-8");
4853
4859
  const flag = enabled ? "yes" : "no";
4854
4860
  if (content.includes("SYNKRO_LOCAL_INFERENCE=")) {
@@ -4965,10 +4971,10 @@ function isAlreadyInstalled() {
4965
4971
  join12(HOOKS_DIR, "cc-stop-summary.sh"),
4966
4972
  join12(HOOKS_DIR, "cc-session-start.sh")
4967
4973
  ];
4968
- if (!requiredScripts.every((p) => existsSync13(p))) return false;
4969
- if (!existsSync13(CONFIG_PATH3)) return false;
4974
+ if (!requiredScripts.every((p) => existsSync12(p))) return false;
4975
+ if (!existsSync12(CONFIG_PATH3)) return false;
4970
4976
  const settingsPath = join12(homedir11(), ".claude", "settings.json");
4971
- if (!existsSync13(settingsPath)) return false;
4977
+ if (!existsSync12(settingsPath)) return false;
4972
4978
  try {
4973
4979
  const settings = JSON.parse(readFileSync11(settingsPath, "utf-8"));
4974
4980
  const hooks = settings?.hooks;
@@ -5267,7 +5273,7 @@ function getClaudeProjectsFolder() {
5267
5273
  const cwd = process.cwd();
5268
5274
  const sanitized = "-" + cwd.replace(/\//g, "-");
5269
5275
  const projectsDir = join12(homedir11(), ".claude", "projects", sanitized);
5270
- return existsSync13(projectsDir) ? projectsDir : null;
5276
+ return existsSync12(projectsDir) ? projectsDir : null;
5271
5277
  }
5272
5278
  function extractSessionInsights(projectsDir) {
5273
5279
  const insights = [];
@@ -5541,11 +5547,11 @@ var status_exports = {};
5541
5547
  __export(status_exports, {
5542
5548
  statusCommand: () => statusCommand
5543
5549
  });
5544
- import { existsSync as existsSync14, readFileSync as readFileSync12 } from "fs";
5550
+ import { existsSync as existsSync13, readFileSync as readFileSync12 } from "fs";
5545
5551
  import { homedir as homedir12 } from "os";
5546
5552
  import { join as join13 } from "path";
5547
5553
  function readConfigEnv() {
5548
- if (!existsSync14(CONFIG_PATH4)) return {};
5554
+ if (!existsSync13(CONFIG_PATH4)) return {};
5549
5555
  const out = {};
5550
5556
  const raw = readFileSync12(CONFIG_PATH4, "utf-8");
5551
5557
  for (const line of raw.split("\n")) {
@@ -5641,17 +5647,17 @@ async function statusCommand() {
5641
5647
  const cursorBashFollowupScript = join13(SYNKRO_DIR3, "hooks", "cursor-bash-followup.sh");
5642
5648
  const commonScript = join13(SYNKRO_DIR3, "hooks", "_synkro-common.sh");
5643
5649
  console.log("Hook scripts:");
5644
- console.log(` ${existsSync14(bashScript) ? "\u2713" : "\u2717"} ${bashScript}`);
5645
- console.log(` ${existsSync14(bashFollowupScript) ? "\u2713" : "\u2717"} ${bashFollowupScript}`);
5646
- console.log(` ${existsSync14(editPrecheckScript) ? "\u2713" : "\u2717"} ${editPrecheckScript}`);
5647
- console.log(` ${existsSync14(editCaptureScript) ? "\u2713" : "\u2717"} ${editCaptureScript}`);
5648
- console.log(` ${existsSync14(stopSummaryScript) ? "\u2713" : "\u2717"} ${stopSummaryScript}`);
5649
- console.log(` ${existsSync14(sessionStartScript) ? "\u2713" : "\u2717"} ${sessionStartScript}`);
5650
- console.log(` ${existsSync14(commonScript) ? "\u2713" : "\u2717"} ${commonScript}`);
5651
- console.log(` ${existsSync14(cursorBashJudgeScript) ? "\u2713" : "\u2717"} ${cursorBashJudgeScript}`);
5652
- console.log(` ${existsSync14(cursorEditPrecheckScript) ? "\u2713" : "\u2717"} ${cursorEditPrecheckScript}`);
5653
- console.log(` ${existsSync14(cursorEditCaptureScript) ? "\u2713" : "\u2717"} ${cursorEditCaptureScript}`);
5654
- console.log(` ${existsSync14(cursorBashFollowupScript) ? "\u2713" : "\u2717"} ${cursorBashFollowupScript}`);
5650
+ console.log(` ${existsSync13(bashScript) ? "\u2713" : "\u2717"} ${bashScript}`);
5651
+ console.log(` ${existsSync13(bashFollowupScript) ? "\u2713" : "\u2717"} ${bashFollowupScript}`);
5652
+ console.log(` ${existsSync13(editPrecheckScript) ? "\u2713" : "\u2717"} ${editPrecheckScript}`);
5653
+ console.log(` ${existsSync13(editCaptureScript) ? "\u2713" : "\u2717"} ${editCaptureScript}`);
5654
+ console.log(` ${existsSync13(stopSummaryScript) ? "\u2713" : "\u2717"} ${stopSummaryScript}`);
5655
+ console.log(` ${existsSync13(sessionStartScript) ? "\u2713" : "\u2717"} ${sessionStartScript}`);
5656
+ console.log(` ${existsSync13(commonScript) ? "\u2713" : "\u2717"} ${commonScript}`);
5657
+ console.log(` ${existsSync13(cursorBashJudgeScript) ? "\u2713" : "\u2717"} ${cursorBashJudgeScript}`);
5658
+ console.log(` ${existsSync13(cursorEditPrecheckScript) ? "\u2713" : "\u2717"} ${cursorEditPrecheckScript}`);
5659
+ console.log(` ${existsSync13(cursorEditCaptureScript) ? "\u2713" : "\u2717"} ${cursorEditCaptureScript}`);
5660
+ console.log(` ${existsSync13(cursorBashFollowupScript) ? "\u2713" : "\u2717"} ${cursorBashFollowupScript}`);
5655
5661
  console.log();
5656
5662
  const mcp = inspectMcpConfig();
5657
5663
  console.log("Guardrails MCP server (Claude Code):");
@@ -5762,11 +5768,11 @@ var config_exports = {};
5762
5768
  __export(config_exports, {
5763
5769
  configCommand: () => configCommand
5764
5770
  });
5765
- import { readFileSync as readFileSync13, writeFileSync as writeFileSync9, existsSync as existsSync15 } from "fs";
5771
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync9, existsSync as existsSync14 } from "fs";
5766
5772
  import { join as join14 } from "path";
5767
5773
  import { homedir as homedir13 } from "os";
5768
5774
  function readConfigEnv2() {
5769
- if (!existsSync15(CONFIG_PATH5)) return {};
5775
+ if (!existsSync14(CONFIG_PATH5)) return {};
5770
5776
  const out = {};
5771
5777
  for (const line of readFileSync13(CONFIG_PATH5, "utf-8").split("\n")) {
5772
5778
  const t = line.trim();
@@ -5777,7 +5783,7 @@ function readConfigEnv2() {
5777
5783
  return out;
5778
5784
  }
5779
5785
  function updateConfigValue(key, value) {
5780
- if (!existsSync15(CONFIG_PATH5)) {
5786
+ if (!existsSync14(CONFIG_PATH5)) {
5781
5787
  console.error("No config found. Run `synkro install` first.");
5782
5788
  process.exit(1);
5783
5789
  }
@@ -5859,7 +5865,7 @@ __export(scanPr_exports, {
5859
5865
  scanPrCommand: () => scanPrCommand
5860
5866
  });
5861
5867
  import { execSync as execSync6, spawn as spawn2 } from "child_process";
5862
- import { readFileSync as readFileSync14, existsSync as existsSync16 } from "fs";
5868
+ import { readFileSync as readFileSync14, existsSync as existsSync15 } from "fs";
5863
5869
  import { join as join15 } from "path";
5864
5870
  function parseMatchSpec(condition) {
5865
5871
  if (!condition.startsWith("match_spec:")) return null;
@@ -6340,7 +6346,7 @@ function shouldFail(findings, threshold) {
6340
6346
  }
6341
6347
  function readRepoDeps() {
6342
6348
  const pkgPath = join15(process.cwd(), "package.json");
6343
- if (!existsSync16(pkgPath)) return {};
6349
+ if (!existsSync15(pkgPath)) return {};
6344
6350
  try {
6345
6351
  const pkg = JSON.parse(readFileSync14(pkgPath, "utf-8"));
6346
6352
  return { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
@@ -6604,7 +6610,7 @@ var disconnect_exports = {};
6604
6610
  __export(disconnect_exports, {
6605
6611
  disconnectCommand: () => disconnectCommand
6606
6612
  });
6607
- import { existsSync as existsSync17, rmSync } from "fs";
6613
+ import { existsSync as existsSync16, rmSync } from "fs";
6608
6614
  import { homedir as homedir14 } from "os";
6609
6615
  import { join as join16 } from "path";
6610
6616
  function tearDownLocalCC() {
@@ -6639,13 +6645,13 @@ function disconnectCommand(args2 = []) {
6639
6645
  console.log(`${mcpRemoved ? "\u2713" : "\xB7"} MCP guardrails server: ${mcpRemoved ? "removed entry from ~/.claude.json" : "no Synkro MCP entry found"}`);
6640
6646
  }
6641
6647
  if (purge) {
6642
- if (existsSync17(SYNKRO_DIR5)) {
6648
+ if (existsSync16(SYNKRO_DIR5)) {
6643
6649
  rmSync(SYNKRO_DIR5, { recursive: true, force: true });
6644
6650
  console.log(`\u2713 Removed ${SYNKRO_DIR5}`);
6645
6651
  } else {
6646
6652
  console.log(`\xB7 ${SYNKRO_DIR5} already gone, nothing to remove`);
6647
6653
  }
6648
- } else if (existsSync17(SYNKRO_DIR5)) {
6654
+ } else if (existsSync16(SYNKRO_DIR5)) {
6649
6655
  console.log(`Config preserved at ${SYNKRO_DIR5}. Run with --purge to remove.`);
6650
6656
  }
6651
6657
  console.log("\nSynkro disconnected.");
@@ -6709,7 +6715,7 @@ __export(localCc_exports, {
6709
6715
  import { spawnSync as spawnSync3 } from "child_process";
6710
6716
  import { homedir as homedir15 } from "os";
6711
6717
  import { join as join17 } from "path";
6712
- import { existsSync as existsSync18, readFileSync as readFileSync15, writeFileSync as writeFileSync10 } from "fs";
6718
+ import { existsSync as existsSync17, readFileSync as readFileSync15, writeFileSync as writeFileSync10 } from "fs";
6713
6719
  function printHelp() {
6714
6720
  console.log(`synkro local-cc \u2014 manage the local Claude Code inference session
6715
6721
 
@@ -6799,14 +6805,14 @@ TROUBLESHOOTING
6799
6805
  `);
6800
6806
  }
6801
6807
  function readGatewayUrl() {
6802
- if (existsSync18(CONFIG_PATH6)) {
6808
+ if (existsSync17(CONFIG_PATH6)) {
6803
6809
  const m = readFileSync15(CONFIG_PATH6, "utf-8").match(/^SYNKRO_GATEWAY_URL='([^']*)'/m);
6804
6810
  if (m) return m[1];
6805
6811
  }
6806
6812
  return "https://api.synkro.sh";
6807
6813
  }
6808
6814
  function updateLocalInferenceFlag2(enabled) {
6809
- if (!existsSync18(CONFIG_PATH6)) return;
6815
+ if (!existsSync17(CONFIG_PATH6)) return;
6810
6816
  let content = readFileSync15(CONFIG_PATH6, "utf-8");
6811
6817
  const flag = enabled ? "yes" : "no";
6812
6818
  if (content.includes("SYNKRO_LOCAL_INFERENCE=")) {
@@ -7143,14 +7149,14 @@ var init_grade = __esm({
7143
7149
  });
7144
7150
 
7145
7151
  // cli/bootstrap.js
7146
- import { readFileSync as readFileSync16, existsSync as existsSync19 } from "fs";
7152
+ import { readFileSync as readFileSync16, existsSync as existsSync18 } from "fs";
7147
7153
  import { resolve } from "path";
7148
7154
  var envCandidates = [
7149
7155
  resolve(process.cwd(), ".env"),
7150
7156
  resolve(process.env.HOME ?? "", ".synkro", "config.env")
7151
7157
  ];
7152
7158
  for (const envPath of envCandidates) {
7153
- if (!existsSync19(envPath)) continue;
7159
+ if (!existsSync18(envPath)) continue;
7154
7160
  const envContent = readFileSync16(envPath, "utf-8");
7155
7161
  for (const line of envContent.split("\n")) {
7156
7162
  const trimmed = line.trim();