@synkro-sh/cli 1.4.21 → 1.4.23
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 +188 -230
- package/dist/bootstrap.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -512,8 +512,10 @@ synkro_load_config() {
|
|
|
512
512
|
SYNKRO_CAPTURE_DEPTH=$(echo "$resp" | jq -r '.capture_depth // "local_only"' 2>/dev/null)
|
|
513
513
|
SYNKRO_TIER=$(echo "$resp" | jq -r '.tier // "standard"' 2>/dev/null)
|
|
514
514
|
SYNKRO_RULES=$(echo "$resp" | jq -c '[.rules[]? | select(.hook_stage == "pre" or .hook_stage == "both" or .hook_stage == null) | {rule_id,text,severity,category,mode}]' 2>/dev/null || echo "[]")
|
|
515
|
-
# Cache the values
|
|
516
|
-
printf 'SYNKRO_CAPTURE_DEPTH="%s"\\nSYNKRO_TIER="%s"\\n' "$SYNKRO_CAPTURE_DEPTH" "$SYNKRO_TIER"
|
|
515
|
+
# Cache the values (SYNKRO_RULES uses single quotes to avoid expansion issues with JSON)
|
|
516
|
+
{ printf 'SYNKRO_CAPTURE_DEPTH="%s"\\nSYNKRO_TIER="%s"\\n' "$SYNKRO_CAPTURE_DEPTH" "$SYNKRO_TIER"
|
|
517
|
+
printf "SYNKRO_RULES='%s'\\n" "$SYNKRO_RULES"
|
|
518
|
+
} > "$cache" 2>/dev/null || true
|
|
517
519
|
}
|
|
518
520
|
|
|
519
521
|
# Decide routing: "local" (grade on device) or "cloud" (POST to server)
|
|
@@ -2580,80 +2582,36 @@ var init_setupGithub = __esm({
|
|
|
2580
2582
|
});
|
|
2581
2583
|
|
|
2582
2584
|
// cli/installer/promptFetcher.ts
|
|
2583
|
-
import { existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync6, mkdirSync as mkdirSync6 } from "fs";
|
|
2584
|
-
import { homedir as homedir5 } from "os";
|
|
2585
|
-
import { join as join6 } from "path";
|
|
2586
|
-
function readCache() {
|
|
2587
|
-
if (!existsSync8(CACHE_PATH)) return null;
|
|
2588
|
-
try {
|
|
2589
|
-
return JSON.parse(readFileSync6(CACHE_PATH, "utf-8"));
|
|
2590
|
-
} catch {
|
|
2591
|
-
return null;
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
function writeCache(entry) {
|
|
2595
|
-
mkdirSync6(join6(homedir5(), ".synkro", "prompts"), { recursive: true });
|
|
2596
|
-
writeFileSync6(CACHE_PATH, JSON.stringify(entry, null, 2), "utf-8");
|
|
2597
|
-
}
|
|
2598
|
-
function isCacheFresh(cache) {
|
|
2599
|
-
const ageMs = Date.now() - cache.fetched_at;
|
|
2600
|
-
const ttlMs = cache.ttl_hours * 60 * 60 * 1e3;
|
|
2601
|
-
return ageMs < ttlMs;
|
|
2602
|
-
}
|
|
2603
2585
|
async function fetchJudgePrompts(opts) {
|
|
2604
|
-
|
|
2605
|
-
const cache = readCache();
|
|
2606
|
-
if (cache && isCacheFresh(cache)) {
|
|
2607
|
-
return mapResponse(cache);
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
const url = `${opts.gatewayUrl.replace(/\/$/, "")}/api/v1/cli/judge-prompts`;
|
|
2586
|
+
const url = `${opts.gatewayUrl.replace(/\/$/, "")}/api/v1/hook/config`;
|
|
2611
2587
|
const resp = await fetch(url, {
|
|
2612
2588
|
method: "GET",
|
|
2613
2589
|
headers: {
|
|
2614
2590
|
"Authorization": `Bearer ${opts.jwt}`,
|
|
2615
2591
|
"User-Agent": "synkro-cli/1.0"
|
|
2616
|
-
}
|
|
2592
|
+
},
|
|
2593
|
+
signal: AbortSignal.timeout(5e3)
|
|
2617
2594
|
});
|
|
2618
2595
|
if (!resp.ok) {
|
|
2619
|
-
|
|
2596
|
+
return { version: "unknown" };
|
|
2620
2597
|
}
|
|
2621
2598
|
const data = await resp.json();
|
|
2622
|
-
|
|
2623
|
-
throw new Error("Gateway returned empty edit_write_prompt");
|
|
2624
|
-
}
|
|
2625
|
-
writeCache({ ...data, fetched_at: Date.now() });
|
|
2626
|
-
return mapResponse(data);
|
|
2627
|
-
}
|
|
2628
|
-
function mapResponse(data) {
|
|
2629
|
-
return {
|
|
2630
|
-
editWritePrompt: data.edit_write_prompt,
|
|
2631
|
-
editAutofixAgentPrompt: data.edit_autofix_agent_prompt,
|
|
2632
|
-
editPrecheckAgentPrompt: data.edit_precheck_agent_prompt,
|
|
2633
|
-
graderPrimerBash: data.grader_primer_bash,
|
|
2634
|
-
graderPrimerEdit: data.grader_primer_edit,
|
|
2635
|
-
classificationPrompt: data.classification_prompt,
|
|
2636
|
-
intentClassifyPrompt: data.intent_classify_prompt,
|
|
2637
|
-
remediateIntentClassifyPrompt: data.remediate_intent_classify_prompt,
|
|
2638
|
-
version: data.version
|
|
2639
|
-
};
|
|
2599
|
+
return { version: data.prompts?.version ?? "unknown" };
|
|
2640
2600
|
}
|
|
2641
|
-
var CACHE_PATH;
|
|
2642
2601
|
var init_promptFetcher = __esm({
|
|
2643
2602
|
"cli/installer/promptFetcher.ts"() {
|
|
2644
2603
|
"use strict";
|
|
2645
|
-
CACHE_PATH = join6(homedir5(), ".synkro", "prompts", "judge-prompts.json");
|
|
2646
2604
|
}
|
|
2647
2605
|
});
|
|
2648
2606
|
|
|
2649
2607
|
// cli/local-cc/settings.ts
|
|
2650
|
-
import { existsSync as
|
|
2651
|
-
import { homedir as
|
|
2652
|
-
import { join as
|
|
2608
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "fs";
|
|
2609
|
+
import { homedir as homedir5 } from "os";
|
|
2610
|
+
import { join as join6 } from "path";
|
|
2653
2611
|
function isLocalCCEnabled() {
|
|
2654
|
-
if (!
|
|
2612
|
+
if (!existsSync8(CONFIG_PATH2)) return false;
|
|
2655
2613
|
try {
|
|
2656
|
-
const content =
|
|
2614
|
+
const content = readFileSync6(CONFIG_PATH2, "utf-8");
|
|
2657
2615
|
const match = content.match(/^SYNKRO_LOCAL_INFERENCE='([^']*)'/m);
|
|
2658
2616
|
return match?.[1] === "yes";
|
|
2659
2617
|
} catch {
|
|
@@ -2664,7 +2622,7 @@ var CONFIG_PATH2;
|
|
|
2664
2622
|
var init_settings = __esm({
|
|
2665
2623
|
"cli/local-cc/settings.ts"() {
|
|
2666
2624
|
"use strict";
|
|
2667
|
-
CONFIG_PATH2 =
|
|
2625
|
+
CONFIG_PATH2 = join6(homedir5(), ".synkro", "config.env");
|
|
2668
2626
|
}
|
|
2669
2627
|
});
|
|
2670
2628
|
|
|
@@ -2818,17 +2776,17 @@ await mcp.connect(new StdioServerTransport());
|
|
|
2818
2776
|
});
|
|
2819
2777
|
|
|
2820
2778
|
// cli/local-cc/install.ts
|
|
2821
|
-
import { existsSync as
|
|
2822
|
-
import { join as
|
|
2823
|
-
import { homedir as
|
|
2779
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync6, writeFileSync as writeFileSync6, readFileSync as readFileSync7, chmodSync, copyFileSync, renameSync as renameSync4, unlinkSync as unlinkSync4, openSync, fsyncSync, closeSync } from "fs";
|
|
2780
|
+
import { join as join7 } from "path";
|
|
2781
|
+
import { homedir as homedir6 } from "os";
|
|
2824
2782
|
import { spawnSync } from "child_process";
|
|
2825
2783
|
function writePluginFiles() {
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2784
|
+
mkdirSync6(SESSION_DIR, { recursive: true });
|
|
2785
|
+
mkdirSync6(PLUGIN_SETTINGS_DIR, { recursive: true });
|
|
2786
|
+
writeFileSync6(PLUGIN_PATH, CHANNEL_PLUGIN_SOURCE, "utf-8");
|
|
2829
2787
|
chmodSync(PLUGIN_PATH, 493);
|
|
2830
|
-
|
|
2831
|
-
|
|
2788
|
+
writeFileSync6(PLUGIN_PKG_PATH, PLUGIN_PACKAGE_JSON, "utf-8");
|
|
2789
|
+
writeFileSync6(
|
|
2832
2790
|
PLUGIN_SETTINGS_PATH,
|
|
2833
2791
|
JSON.stringify({
|
|
2834
2792
|
fastMode: true,
|
|
@@ -2840,7 +2798,7 @@ function writePluginFiles() {
|
|
|
2840
2798
|
}, null, 2) + "\n",
|
|
2841
2799
|
"utf-8"
|
|
2842
2800
|
);
|
|
2843
|
-
|
|
2801
|
+
writeFileSync6(RUN_SCRIPT_PATH, RUN_SCRIPT_SOURCE, "utf-8");
|
|
2844
2802
|
chmodSync(RUN_SCRIPT_PATH, 493);
|
|
2845
2803
|
}
|
|
2846
2804
|
function runBunInstall() {
|
|
@@ -2856,10 +2814,10 @@ function runBunInstall() {
|
|
|
2856
2814
|
}
|
|
2857
2815
|
}
|
|
2858
2816
|
function safelyMutateClaudeJson(mutator) {
|
|
2859
|
-
if (!
|
|
2817
|
+
if (!existsSync9(CLAUDE_JSON_PATH)) {
|
|
2860
2818
|
return;
|
|
2861
2819
|
}
|
|
2862
|
-
const originalText =
|
|
2820
|
+
const originalText = readFileSync7(CLAUDE_JSON_PATH, "utf-8");
|
|
2863
2821
|
let parsed;
|
|
2864
2822
|
try {
|
|
2865
2823
|
parsed = JSON.parse(originalText);
|
|
@@ -2891,7 +2849,7 @@ function safelyMutateClaudeJson(mutator) {
|
|
|
2891
2849
|
copyFileSync(CLAUDE_JSON_PATH, CLAUDE_JSON_BACKUP_PATH);
|
|
2892
2850
|
const tmpPath = `${CLAUDE_JSON_PATH}.synkro-tmp.${process.pid}`;
|
|
2893
2851
|
try {
|
|
2894
|
-
|
|
2852
|
+
writeFileSync6(tmpPath, newText, "utf-8");
|
|
2895
2853
|
const fd = openSync(tmpPath, "r");
|
|
2896
2854
|
try {
|
|
2897
2855
|
fsyncSync(fd);
|
|
@@ -2923,7 +2881,7 @@ function writeProjectMcpJson() {
|
|
|
2923
2881
|
}
|
|
2924
2882
|
}
|
|
2925
2883
|
};
|
|
2926
|
-
|
|
2884
|
+
writeFileSync6(PROJECT_MCP_PATH, JSON.stringify(mcp, null, 2) + "\n", "utf-8");
|
|
2927
2885
|
}
|
|
2928
2886
|
function patchClaudeJson() {
|
|
2929
2887
|
safelyMutateClaudeJson((parsed) => {
|
|
@@ -2996,15 +2954,15 @@ var init_install = __esm({
|
|
|
2996
2954
|
"cli/local-cc/install.ts"() {
|
|
2997
2955
|
"use strict";
|
|
2998
2956
|
init_channelSource();
|
|
2999
|
-
CLAUDE_JSON_BACKUP_PATH =
|
|
3000
|
-
SESSION_DIR =
|
|
3001
|
-
PLUGIN_PATH =
|
|
3002
|
-
PLUGIN_PKG_PATH =
|
|
3003
|
-
PLUGIN_SETTINGS_DIR =
|
|
3004
|
-
PLUGIN_SETTINGS_PATH =
|
|
3005
|
-
PROJECT_MCP_PATH =
|
|
3006
|
-
CLAUDE_JSON_PATH =
|
|
3007
|
-
RUN_SCRIPT_PATH =
|
|
2957
|
+
CLAUDE_JSON_BACKUP_PATH = join7(homedir6(), ".claude.json.synkro-bak");
|
|
2958
|
+
SESSION_DIR = join7(homedir6(), ".synkro", "cc_sessions");
|
|
2959
|
+
PLUGIN_PATH = join7(SESSION_DIR, "synkro-channel.ts");
|
|
2960
|
+
PLUGIN_PKG_PATH = join7(SESSION_DIR, "package.json");
|
|
2961
|
+
PLUGIN_SETTINGS_DIR = join7(SESSION_DIR, ".claude");
|
|
2962
|
+
PLUGIN_SETTINGS_PATH = join7(PLUGIN_SETTINGS_DIR, "settings.json");
|
|
2963
|
+
PROJECT_MCP_PATH = join7(SESSION_DIR, ".mcp.json");
|
|
2964
|
+
CLAUDE_JSON_PATH = join7(homedir6(), ".claude.json");
|
|
2965
|
+
RUN_SCRIPT_PATH = join7(SESSION_DIR, "run-claude.sh");
|
|
3008
2966
|
TMUX_SESSION_NAME = "synkro-local-cc";
|
|
3009
2967
|
RUN_SCRIPT_SOURCE = `#!/usr/bin/env bash
|
|
3010
2968
|
# Auto-generated by \`synkro install\`. Do not edit.
|
|
@@ -3056,8 +3014,8 @@ done
|
|
|
3056
3014
|
|
|
3057
3015
|
// cli/local-cc/pueue.ts
|
|
3058
3016
|
import { execFileSync, spawnSync as spawnSync2, spawn } from "child_process";
|
|
3059
|
-
import { homedir as
|
|
3060
|
-
import { join as
|
|
3017
|
+
import { homedir as homedir7 } from "os";
|
|
3018
|
+
import { join as join8 } from "path";
|
|
3061
3019
|
import { connect } from "net";
|
|
3062
3020
|
function pueueAvailable() {
|
|
3063
3021
|
const r = spawnSync2("pueue", ["--version"], { encoding: "utf-8" });
|
|
@@ -3112,7 +3070,7 @@ function startTask(opts = {}) {
|
|
|
3112
3070
|
if (existing) {
|
|
3113
3071
|
spawnSync2("pueue", ["remove", String(existing.id)], { encoding: "utf-8" });
|
|
3114
3072
|
}
|
|
3115
|
-
const runScript =
|
|
3073
|
+
const runScript = join8(cwd, "run-claude.sh");
|
|
3116
3074
|
const args2 = [
|
|
3117
3075
|
"add",
|
|
3118
3076
|
"--label",
|
|
@@ -3230,7 +3188,7 @@ var init_pueue = __esm({
|
|
|
3230
3188
|
"use strict";
|
|
3231
3189
|
TASK_LABEL = "synkro-local-cc";
|
|
3232
3190
|
TMUX_SESSION = "synkro-local-cc";
|
|
3233
|
-
SESSION_DIR2 =
|
|
3191
|
+
SESSION_DIR2 = join8(homedir7(), ".synkro", "cc_sessions");
|
|
3234
3192
|
PueueError = class extends Error {
|
|
3235
3193
|
constructor(message, cause) {
|
|
3236
3194
|
super(message);
|
|
@@ -3243,14 +3201,14 @@ var init_pueue = __esm({
|
|
|
3243
3201
|
});
|
|
3244
3202
|
|
|
3245
3203
|
// cli/local-cc/prompts.ts
|
|
3246
|
-
import { readFileSync as
|
|
3247
|
-
import { homedir as
|
|
3248
|
-
import { join as
|
|
3204
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
3205
|
+
import { homedir as homedir8 } from "os";
|
|
3206
|
+
import { join as join9 } from "path";
|
|
3249
3207
|
async function fetchPrimers() {
|
|
3250
3208
|
let jwt2 = "";
|
|
3251
3209
|
let gatewayUrl = "";
|
|
3252
3210
|
try {
|
|
3253
|
-
const creds = JSON.parse(
|
|
3211
|
+
const creds = JSON.parse(readFileSync8(CREDS_PATH, "utf-8"));
|
|
3254
3212
|
jwt2 = creds.access_token || "";
|
|
3255
3213
|
gatewayUrl = creds.gateway_url || "https://api.synkro.sh";
|
|
3256
3214
|
} catch {
|
|
@@ -3287,7 +3245,7 @@ var CREDS_PATH, CHANNEL_REPLY_INSTRUCTIONS;
|
|
|
3287
3245
|
var init_prompts = __esm({
|
|
3288
3246
|
"cli/local-cc/prompts.ts"() {
|
|
3289
3247
|
"use strict";
|
|
3290
|
-
CREDS_PATH =
|
|
3248
|
+
CREDS_PATH = join9(homedir8(), ".synkro", "credentials.json");
|
|
3291
3249
|
CHANNEL_REPLY_INSTRUCTIONS = `
|
|
3292
3250
|
DELIVERY METHOD \u2014 MANDATORY, OVERRIDES ALL OTHER OUTPUT RULES:
|
|
3293
3251
|
You are running inside a Synkro MCP channel. Do NOT output your verdict as text.
|
|
@@ -3299,9 +3257,9 @@ Any text output is silently discarded. Only the reply tool call is captured.`;
|
|
|
3299
3257
|
});
|
|
3300
3258
|
|
|
3301
3259
|
// cli/local-cc/turnLog.ts
|
|
3302
|
-
import { appendFileSync, existsSync as
|
|
3303
|
-
import { dirname as dirname5, join as
|
|
3304
|
-
import { homedir as
|
|
3260
|
+
import { appendFileSync, existsSync as existsSync10, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync9, readSync, closeSync as closeSync2, statSync, watchFile, unwatchFile } from "fs";
|
|
3261
|
+
import { dirname as dirname5, join as join10 } from "path";
|
|
3262
|
+
import { homedir as homedir9 } from "os";
|
|
3305
3263
|
function truncate(s, max = PREVIEW_MAX) {
|
|
3306
3264
|
if (s.length <= max) return s;
|
|
3307
3265
|
return s.slice(0, max) + "\u2026 [+" + (s.length - max) + " chars]";
|
|
@@ -3321,7 +3279,7 @@ function extractSeverity(result) {
|
|
|
3321
3279
|
}
|
|
3322
3280
|
function appendTurn(args2) {
|
|
3323
3281
|
try {
|
|
3324
|
-
|
|
3282
|
+
mkdirSync7(dirname5(TURN_LOG_PATH), { recursive: true });
|
|
3325
3283
|
const entry = {
|
|
3326
3284
|
ts: new Date(args2.startedAt).toISOString(),
|
|
3327
3285
|
role: args2.role,
|
|
@@ -3337,11 +3295,11 @@ function appendTurn(args2) {
|
|
|
3337
3295
|
}
|
|
3338
3296
|
}
|
|
3339
3297
|
function readRecentTurns(n = 20) {
|
|
3340
|
-
if (!
|
|
3298
|
+
if (!existsSync10(TURN_LOG_PATH)) return [];
|
|
3341
3299
|
try {
|
|
3342
3300
|
const size = statSync(TURN_LOG_PATH).size;
|
|
3343
3301
|
if (size === 0) return [];
|
|
3344
|
-
const text =
|
|
3302
|
+
const text = readFileSync9(TURN_LOG_PATH, "utf-8");
|
|
3345
3303
|
const lines = text.split("\n").filter(Boolean);
|
|
3346
3304
|
const lastN = lines.slice(-n).reverse();
|
|
3347
3305
|
return lastN.map((line) => {
|
|
@@ -3357,8 +3315,8 @@ function readRecentTurns(n = 20) {
|
|
|
3357
3315
|
}
|
|
3358
3316
|
function followTurns(onEntry) {
|
|
3359
3317
|
try {
|
|
3360
|
-
|
|
3361
|
-
if (!
|
|
3318
|
+
mkdirSync7(dirname5(TURN_LOG_PATH), { recursive: true });
|
|
3319
|
+
if (!existsSync10(TURN_LOG_PATH)) {
|
|
3362
3320
|
appendFileSync(TURN_LOG_PATH, "", "utf-8");
|
|
3363
3321
|
}
|
|
3364
3322
|
} catch {
|
|
@@ -3420,7 +3378,7 @@ var TURN_LOG_PATH, PREVIEW_MAX;
|
|
|
3420
3378
|
var init_turnLog = __esm({
|
|
3421
3379
|
"cli/local-cc/turnLog.ts"() {
|
|
3422
3380
|
"use strict";
|
|
3423
|
-
TURN_LOG_PATH =
|
|
3381
|
+
TURN_LOG_PATH = join10(homedir9(), ".synkro", "cc_sessions", "turns.log");
|
|
3424
3382
|
PREVIEW_MAX = 400;
|
|
3425
3383
|
}
|
|
3426
3384
|
});
|
|
@@ -3526,9 +3484,9 @@ __export(install_exports, {
|
|
|
3526
3484
|
installCommand: () => installCommand,
|
|
3527
3485
|
parseArgs: () => parseArgs
|
|
3528
3486
|
});
|
|
3529
|
-
import { existsSync as
|
|
3530
|
-
import { homedir as
|
|
3531
|
-
import { join as
|
|
3487
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync8, writeFileSync as writeFileSync7, chmodSync as chmodSync2, readFileSync as readFileSync10, readdirSync } from "fs";
|
|
3488
|
+
import { homedir as homedir10 } from "os";
|
|
3489
|
+
import { join as join11 } from "path";
|
|
3532
3490
|
import { execSync as execSync5 } from "child_process";
|
|
3533
3491
|
import { createInterface as createInterface3 } from "readline";
|
|
3534
3492
|
function sanitizeGatewayCandidate(raw) {
|
|
@@ -3565,36 +3523,36 @@ async function promptTranscriptConsent() {
|
|
|
3565
3523
|
});
|
|
3566
3524
|
}
|
|
3567
3525
|
function ensureSynkroDir() {
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3526
|
+
mkdirSync8(SYNKRO_DIR2, { recursive: true });
|
|
3527
|
+
mkdirSync8(HOOKS_DIR, { recursive: true });
|
|
3528
|
+
mkdirSync8(BIN_DIR, { recursive: true });
|
|
3529
|
+
mkdirSync8(OFFSETS_DIR, { recursive: true });
|
|
3572
3530
|
}
|
|
3573
3531
|
function writeHookScripts() {
|
|
3574
|
-
const bashScriptPath =
|
|
3575
|
-
const bashFollowupScriptPath =
|
|
3576
|
-
const editCaptureScriptPath =
|
|
3577
|
-
const editPrecheckScriptPath =
|
|
3578
|
-
const stopSummaryScriptPath =
|
|
3579
|
-
const sessionStartScriptPath =
|
|
3580
|
-
const transcriptSyncScriptPath =
|
|
3581
|
-
const commonScriptPath =
|
|
3582
|
-
const cursorBashJudgePath =
|
|
3583
|
-
const cursorEditPrecheckPath =
|
|
3584
|
-
const cursorEditCapturePath =
|
|
3585
|
-
const cursorBashFollowupPath =
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3532
|
+
const bashScriptPath = join11(HOOKS_DIR, "cc-bash-judge.sh");
|
|
3533
|
+
const bashFollowupScriptPath = join11(HOOKS_DIR, "cc-bash-followup.sh");
|
|
3534
|
+
const editCaptureScriptPath = join11(HOOKS_DIR, "cc-edit-capture.sh");
|
|
3535
|
+
const editPrecheckScriptPath = join11(HOOKS_DIR, "cc-edit-precheck.sh");
|
|
3536
|
+
const stopSummaryScriptPath = join11(HOOKS_DIR, "cc-stop-summary.sh");
|
|
3537
|
+
const sessionStartScriptPath = join11(HOOKS_DIR, "cc-session-start.sh");
|
|
3538
|
+
const transcriptSyncScriptPath = join11(HOOKS_DIR, "cc-transcript-sync.sh");
|
|
3539
|
+
const commonScriptPath = join11(HOOKS_DIR, "_synkro-common.sh");
|
|
3540
|
+
const cursorBashJudgePath = join11(HOOKS_DIR, "cursor-bash-judge.sh");
|
|
3541
|
+
const cursorEditPrecheckPath = join11(HOOKS_DIR, "cursor-edit-precheck.sh");
|
|
3542
|
+
const cursorEditCapturePath = join11(HOOKS_DIR, "cursor-edit-capture.sh");
|
|
3543
|
+
const cursorBashFollowupPath = join11(HOOKS_DIR, "cursor-bash-followup.sh");
|
|
3544
|
+
writeFileSync7(bashScriptPath, CC_BASH_JUDGE_SCRIPT, "utf-8");
|
|
3545
|
+
writeFileSync7(bashFollowupScriptPath, CC_BASH_FOLLOWUP_SCRIPT, "utf-8");
|
|
3546
|
+
writeFileSync7(editCaptureScriptPath, CC_EDIT_CAPTURE_SCRIPT, "utf-8");
|
|
3547
|
+
writeFileSync7(editPrecheckScriptPath, CC_EDIT_PRECHECK_SCRIPT, "utf-8");
|
|
3548
|
+
writeFileSync7(stopSummaryScriptPath, CC_STOP_SUMMARY_SCRIPT, "utf-8");
|
|
3549
|
+
writeFileSync7(sessionStartScriptPath, CC_SESSION_START_SCRIPT, "utf-8");
|
|
3550
|
+
writeFileSync7(transcriptSyncScriptPath, CC_TRANSCRIPT_SYNC_SCRIPT, "utf-8");
|
|
3551
|
+
writeFileSync7(commonScriptPath, SYNKRO_COMMON_SCRIPT, "utf-8");
|
|
3552
|
+
writeFileSync7(cursorBashJudgePath, CURSOR_BASH_JUDGE_SCRIPT, "utf-8");
|
|
3553
|
+
writeFileSync7(cursorEditPrecheckPath, CURSOR_EDIT_PRECHECK_SCRIPT, "utf-8");
|
|
3554
|
+
writeFileSync7(cursorEditCapturePath, CURSOR_EDIT_CAPTURE_SCRIPT, "utf-8");
|
|
3555
|
+
writeFileSync7(cursorBashFollowupPath, CURSOR_BASH_FOLLOWUP_SCRIPT, "utf-8");
|
|
3598
3556
|
chmodSync2(bashScriptPath, 493);
|
|
3599
3557
|
chmodSync2(bashFollowupScriptPath, 493);
|
|
3600
3558
|
chmodSync2(editCaptureScriptPath, 493);
|
|
@@ -3630,11 +3588,11 @@ function shellQuoteSingle(value) {
|
|
|
3630
3588
|
}
|
|
3631
3589
|
function resolveSynkroBundle() {
|
|
3632
3590
|
const scriptPath = process.argv[1];
|
|
3633
|
-
if (scriptPath &&
|
|
3591
|
+
if (scriptPath && existsSync11(scriptPath)) return scriptPath;
|
|
3634
3592
|
return null;
|
|
3635
3593
|
}
|
|
3636
3594
|
function writeConfigEnv(opts) {
|
|
3637
|
-
const credsPath =
|
|
3595
|
+
const credsPath = join11(SYNKRO_DIR2, "credentials.json");
|
|
3638
3596
|
const safeGateway = sanitizeConfigValue(opts.gatewayUrl);
|
|
3639
3597
|
const safeUserId = sanitizeConfigValue(opts.userId);
|
|
3640
3598
|
const safeOrgId = sanitizeConfigValue(opts.orgId);
|
|
@@ -3650,7 +3608,7 @@ function writeConfigEnv(opts) {
|
|
|
3650
3608
|
`SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
|
|
3651
3609
|
`SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
|
|
3652
3610
|
`SYNKRO_INFERENCE=${shellQuoteSingle(safeInference)}`,
|
|
3653
|
-
`SYNKRO_VERSION=${shellQuoteSingle("1.4.
|
|
3611
|
+
`SYNKRO_VERSION=${shellQuoteSingle("1.4.23")}`
|
|
3654
3612
|
];
|
|
3655
3613
|
if (safeSynkroBin) lines.push(`SYNKRO_CLI_BIN=${shellQuoteSingle(safeSynkroBin)}`);
|
|
3656
3614
|
if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
|
|
@@ -3661,12 +3619,12 @@ function writeConfigEnv(opts) {
|
|
|
3661
3619
|
}
|
|
3662
3620
|
lines.push(`SYNKRO_LOCAL_INFERENCE=${shellQuoteSingle(opts.localInference ? "yes" : "no")}`);
|
|
3663
3621
|
lines.push("");
|
|
3664
|
-
|
|
3622
|
+
writeFileSync7(CONFIG_PATH3, lines.join("\n"), "utf-8");
|
|
3665
3623
|
chmodSync2(CONFIG_PATH3, 384);
|
|
3666
3624
|
}
|
|
3667
3625
|
function updateLocalInferenceFlag(enabled) {
|
|
3668
|
-
if (!
|
|
3669
|
-
let content =
|
|
3626
|
+
if (!existsSync11(CONFIG_PATH3)) return;
|
|
3627
|
+
let content = readFileSync10(CONFIG_PATH3, "utf-8");
|
|
3670
3628
|
const flag = enabled ? "yes" : "no";
|
|
3671
3629
|
if (content.includes("SYNKRO_LOCAL_INFERENCE=")) {
|
|
3672
3630
|
content = content.replace(/^SYNKRO_LOCAL_INFERENCE='[^']*'/m, `SYNKRO_LOCAL_INFERENCE='${flag}'`);
|
|
@@ -3675,7 +3633,7 @@ function updateLocalInferenceFlag(enabled) {
|
|
|
3675
3633
|
SYNKRO_LOCAL_INFERENCE='${flag}'
|
|
3676
3634
|
`;
|
|
3677
3635
|
}
|
|
3678
|
-
|
|
3636
|
+
writeFileSync7(CONFIG_PATH3, content, "utf-8");
|
|
3679
3637
|
}
|
|
3680
3638
|
function collectLocalMetadata() {
|
|
3681
3639
|
const meta = { platform: process.platform };
|
|
@@ -3695,16 +3653,16 @@ function collectLocalMetadata() {
|
|
|
3695
3653
|
meta.cc_version = execSync5("claude --version", { encoding: "utf-8", timeout: 5e3 }).trim().split("\n")[0];
|
|
3696
3654
|
} catch {
|
|
3697
3655
|
}
|
|
3698
|
-
const claudeDir =
|
|
3656
|
+
const claudeDir = join11(homedir10(), ".claude");
|
|
3699
3657
|
try {
|
|
3700
|
-
const settings = JSON.parse(
|
|
3658
|
+
const settings = JSON.parse(readFileSync10(join11(claudeDir, "settings.json"), "utf-8"));
|
|
3701
3659
|
const plugins = Object.keys(settings.enabledPlugins ?? {}).filter((k) => settings.enabledPlugins[k]);
|
|
3702
3660
|
if (plugins.length) meta.enabled_plugins = plugins;
|
|
3703
3661
|
if (settings.permissions?.defaultMode) meta.permissions_mode = settings.permissions.defaultMode;
|
|
3704
3662
|
} catch {
|
|
3705
3663
|
}
|
|
3706
3664
|
try {
|
|
3707
|
-
const mcpCache = JSON.parse(
|
|
3665
|
+
const mcpCache = JSON.parse(readFileSync10(join11(claudeDir, "mcp-needs-auth-cache.json"), "utf-8"));
|
|
3708
3666
|
const mcpNames = Object.keys(mcpCache);
|
|
3709
3667
|
if (mcpNames.length) meta.mcp_servers = mcpNames;
|
|
3710
3668
|
} catch {
|
|
@@ -3716,10 +3674,10 @@ function collectLocalMetadata() {
|
|
|
3716
3674
|
} catch {
|
|
3717
3675
|
}
|
|
3718
3676
|
try {
|
|
3719
|
-
const sessionsDir =
|
|
3677
|
+
const sessionsDir = join11(claudeDir, "sessions");
|
|
3720
3678
|
const files = readdirSync(sessionsDir).filter((f) => f.endsWith(".json")).slice(-5);
|
|
3721
3679
|
for (const f of files) {
|
|
3722
|
-
const s = JSON.parse(
|
|
3680
|
+
const s = JSON.parse(readFileSync10(join11(sessionsDir, f), "utf-8"));
|
|
3723
3681
|
if (s.version) {
|
|
3724
3682
|
meta.cc_version = meta.cc_version || s.version;
|
|
3725
3683
|
break;
|
|
@@ -3775,19 +3733,19 @@ function assertGatewayAllowed(gatewayUrl) {
|
|
|
3775
3733
|
}
|
|
3776
3734
|
function isAlreadyInstalled() {
|
|
3777
3735
|
const requiredScripts = [
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3736
|
+
join11(HOOKS_DIR, "cc-bash-judge.sh"),
|
|
3737
|
+
join11(HOOKS_DIR, "cc-bash-followup.sh"),
|
|
3738
|
+
join11(HOOKS_DIR, "cc-edit-precheck.sh"),
|
|
3739
|
+
join11(HOOKS_DIR, "cc-edit-capture.sh"),
|
|
3740
|
+
join11(HOOKS_DIR, "cc-stop-summary.sh"),
|
|
3741
|
+
join11(HOOKS_DIR, "cc-session-start.sh")
|
|
3784
3742
|
];
|
|
3785
|
-
if (!requiredScripts.every((p) =>
|
|
3786
|
-
if (!
|
|
3787
|
-
const settingsPath =
|
|
3788
|
-
if (!
|
|
3743
|
+
if (!requiredScripts.every((p) => existsSync11(p))) return false;
|
|
3744
|
+
if (!existsSync11(CONFIG_PATH3)) return false;
|
|
3745
|
+
const settingsPath = join11(homedir10(), ".claude", "settings.json");
|
|
3746
|
+
if (!existsSync11(settingsPath)) return false;
|
|
3789
3747
|
try {
|
|
3790
|
-
const settings = JSON.parse(
|
|
3748
|
+
const settings = JSON.parse(readFileSync10(settingsPath, "utf-8"));
|
|
3791
3749
|
const hooks = settings?.hooks;
|
|
3792
3750
|
if (!hooks || typeof hooks !== "object") return false;
|
|
3793
3751
|
const hasManaged = (kind) => Array.isArray(hooks[kind]) && hooks[kind].some((entry) => entry?.__synkro_managed__ === true);
|
|
@@ -3918,9 +3876,9 @@ async function installCommand(opts = {}) {
|
|
|
3918
3876
|
console.log(` ${scripts.transcriptSyncScript}
|
|
3919
3877
|
`);
|
|
3920
3878
|
for (const mode of ["edit", "bash"]) {
|
|
3921
|
-
const pidFile =
|
|
3879
|
+
const pidFile = join11(SYNKRO_DIR2, "daemon", mode, "daemon.pid");
|
|
3922
3880
|
try {
|
|
3923
|
-
const pid = parseInt(
|
|
3881
|
+
const pid = parseInt(readFileSync10(pidFile, "utf-8").trim(), 10);
|
|
3924
3882
|
if (pid > 0) {
|
|
3925
3883
|
process.kill(pid, "SIGTERM");
|
|
3926
3884
|
console.log(`Stopped stale ${mode} grader daemon (pid ${pid})`);
|
|
@@ -4012,7 +3970,7 @@ async function installCommand(opts = {}) {
|
|
|
4012
3970
|
else console.warn(" \u26A0 Could not resolve synkro bundle path; hooks will fall back to PATH lookup of `synkro`.");
|
|
4013
3971
|
try {
|
|
4014
3972
|
const prompts = await fetchJudgePrompts({ gatewayUrl, jwt: token });
|
|
4015
|
-
console.log(` prompts: ${prompts.version} (
|
|
3973
|
+
console.log(` prompts: ${prompts.version} (live)`);
|
|
4016
3974
|
} catch (err) {
|
|
4017
3975
|
console.warn(` \u26A0 Could not cache judge prompts: ${err.message}`);
|
|
4018
3976
|
}
|
|
@@ -4092,17 +4050,17 @@ function detectGitRepo2() {
|
|
|
4092
4050
|
function getClaudeProjectsFolder() {
|
|
4093
4051
|
const cwd = process.cwd();
|
|
4094
4052
|
const sanitized = "-" + cwd.replace(/\//g, "-");
|
|
4095
|
-
const projectsDir =
|
|
4096
|
-
return
|
|
4053
|
+
const projectsDir = join11(homedir10(), ".claude", "projects", sanitized);
|
|
4054
|
+
return existsSync11(projectsDir) ? projectsDir : null;
|
|
4097
4055
|
}
|
|
4098
4056
|
function extractSessionInsights(projectsDir) {
|
|
4099
4057
|
const insights = [];
|
|
4100
4058
|
const files = readdirSync(projectsDir).filter((f) => f.endsWith(".jsonl"));
|
|
4101
4059
|
for (const file of files) {
|
|
4102
4060
|
const sessionId = file.replace(".jsonl", "");
|
|
4103
|
-
const filePath =
|
|
4061
|
+
const filePath = join11(projectsDir, file);
|
|
4104
4062
|
try {
|
|
4105
|
-
const content =
|
|
4063
|
+
const content = readFileSync10(filePath, "utf-8");
|
|
4106
4064
|
const lines = content.split("\n").filter(Boolean);
|
|
4107
4065
|
for (let i = 0; i < lines.length; i++) {
|
|
4108
4066
|
try {
|
|
@@ -4178,7 +4136,7 @@ function extractTextContent(content) {
|
|
|
4178
4136
|
return "";
|
|
4179
4137
|
}
|
|
4180
4138
|
function parseTranscriptFile(filePath) {
|
|
4181
|
-
const content =
|
|
4139
|
+
const content = readFileSync10(filePath, "utf-8");
|
|
4182
4140
|
const lines = content.split("\n").filter(Boolean);
|
|
4183
4141
|
const messages = [];
|
|
4184
4142
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -4229,7 +4187,7 @@ async function syncTranscriptsBulk(gatewayUrl, token, repo) {
|
|
|
4229
4187
|
const sessions = [];
|
|
4230
4188
|
for (const file of batch) {
|
|
4231
4189
|
const sessionId = file.replace(".jsonl", "");
|
|
4232
|
-
const filePath =
|
|
4190
|
+
const filePath = join11(projectsDir, file);
|
|
4233
4191
|
try {
|
|
4234
4192
|
const allMessages = parseTranscriptFile(filePath);
|
|
4235
4193
|
const messages = allMessages.length > maxMessagesPerSession ? allMessages.slice(-maxMessagesPerSession) : allMessages;
|
|
@@ -4258,11 +4216,11 @@ async function syncTranscriptsBulk(gatewayUrl, token, repo) {
|
|
|
4258
4216
|
}
|
|
4259
4217
|
for (const file of batch) {
|
|
4260
4218
|
const sessionId = file.replace(".jsonl", "");
|
|
4261
|
-
const filePath =
|
|
4219
|
+
const filePath = join11(projectsDir, file);
|
|
4262
4220
|
try {
|
|
4263
|
-
const content =
|
|
4221
|
+
const content = readFileSync10(filePath, "utf-8");
|
|
4264
4222
|
const lineCount = content.split("\n").filter(Boolean).length;
|
|
4265
|
-
|
|
4223
|
+
writeFileSync7(join11(OFFSETS_DIR, sessionId), String(lineCount), "utf-8");
|
|
4266
4224
|
} catch {
|
|
4267
4225
|
}
|
|
4268
4226
|
}
|
|
@@ -4287,11 +4245,11 @@ var init_install2 = __esm({
|
|
|
4287
4245
|
init_install();
|
|
4288
4246
|
init_pueue();
|
|
4289
4247
|
init_client();
|
|
4290
|
-
SYNKRO_DIR2 =
|
|
4291
|
-
HOOKS_DIR =
|
|
4292
|
-
BIN_DIR =
|
|
4293
|
-
CONFIG_PATH3 =
|
|
4294
|
-
OFFSETS_DIR =
|
|
4248
|
+
SYNKRO_DIR2 = join11(homedir10(), ".synkro");
|
|
4249
|
+
HOOKS_DIR = join11(SYNKRO_DIR2, "hooks");
|
|
4250
|
+
BIN_DIR = join11(SYNKRO_DIR2, "bin");
|
|
4251
|
+
CONFIG_PATH3 = join11(SYNKRO_DIR2, "config.env");
|
|
4252
|
+
OFFSETS_DIR = join11(SYNKRO_DIR2, ".transcript-offsets");
|
|
4295
4253
|
}
|
|
4296
4254
|
});
|
|
4297
4255
|
|
|
@@ -4367,13 +4325,13 @@ var status_exports = {};
|
|
|
4367
4325
|
__export(status_exports, {
|
|
4368
4326
|
statusCommand: () => statusCommand
|
|
4369
4327
|
});
|
|
4370
|
-
import { existsSync as
|
|
4371
|
-
import { homedir as
|
|
4372
|
-
import { join as
|
|
4328
|
+
import { existsSync as existsSync12, readFileSync as readFileSync11 } from "fs";
|
|
4329
|
+
import { homedir as homedir11 } from "os";
|
|
4330
|
+
import { join as join12 } from "path";
|
|
4373
4331
|
function readConfigEnv() {
|
|
4374
|
-
if (!
|
|
4332
|
+
if (!existsSync12(CONFIG_PATH4)) return {};
|
|
4375
4333
|
const out = {};
|
|
4376
|
-
const raw =
|
|
4334
|
+
const raw = readFileSync11(CONFIG_PATH4, "utf-8");
|
|
4377
4335
|
for (const line of raw.split("\n")) {
|
|
4378
4336
|
const trimmed = line.trim();
|
|
4379
4337
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -4455,29 +4413,29 @@ async function statusCommand() {
|
|
|
4455
4413
|
}
|
|
4456
4414
|
}
|
|
4457
4415
|
console.log();
|
|
4458
|
-
const bashScript =
|
|
4459
|
-
const bashFollowupScript =
|
|
4460
|
-
const editPrecheckScript =
|
|
4461
|
-
const editCaptureScript =
|
|
4462
|
-
const stopSummaryScript =
|
|
4463
|
-
const sessionStartScript =
|
|
4464
|
-
const cursorBashJudgeScript =
|
|
4465
|
-
const cursorEditPrecheckScript =
|
|
4466
|
-
const cursorEditCaptureScript =
|
|
4467
|
-
const cursorBashFollowupScript =
|
|
4468
|
-
const commonScript =
|
|
4416
|
+
const bashScript = join12(SYNKRO_DIR3, "hooks", "cc-bash-judge.sh");
|
|
4417
|
+
const bashFollowupScript = join12(SYNKRO_DIR3, "hooks", "cc-bash-followup.sh");
|
|
4418
|
+
const editPrecheckScript = join12(SYNKRO_DIR3, "hooks", "cc-edit-precheck.sh");
|
|
4419
|
+
const editCaptureScript = join12(SYNKRO_DIR3, "hooks", "cc-edit-capture.sh");
|
|
4420
|
+
const stopSummaryScript = join12(SYNKRO_DIR3, "hooks", "cc-stop-summary.sh");
|
|
4421
|
+
const sessionStartScript = join12(SYNKRO_DIR3, "hooks", "cc-session-start.sh");
|
|
4422
|
+
const cursorBashJudgeScript = join12(SYNKRO_DIR3, "hooks", "cursor-bash-judge.sh");
|
|
4423
|
+
const cursorEditPrecheckScript = join12(SYNKRO_DIR3, "hooks", "cursor-edit-precheck.sh");
|
|
4424
|
+
const cursorEditCaptureScript = join12(SYNKRO_DIR3, "hooks", "cursor-edit-capture.sh");
|
|
4425
|
+
const cursorBashFollowupScript = join12(SYNKRO_DIR3, "hooks", "cursor-bash-followup.sh");
|
|
4426
|
+
const commonScript = join12(SYNKRO_DIR3, "hooks", "_synkro-common.sh");
|
|
4469
4427
|
console.log("Hook scripts:");
|
|
4470
|
-
console.log(` ${
|
|
4471
|
-
console.log(` ${
|
|
4472
|
-
console.log(` ${
|
|
4473
|
-
console.log(` ${
|
|
4474
|
-
console.log(` ${
|
|
4475
|
-
console.log(` ${
|
|
4476
|
-
console.log(` ${
|
|
4477
|
-
console.log(` ${
|
|
4478
|
-
console.log(` ${
|
|
4479
|
-
console.log(` ${
|
|
4480
|
-
console.log(` ${
|
|
4428
|
+
console.log(` ${existsSync12(bashScript) ? "\u2713" : "\u2717"} ${bashScript}`);
|
|
4429
|
+
console.log(` ${existsSync12(bashFollowupScript) ? "\u2713" : "\u2717"} ${bashFollowupScript}`);
|
|
4430
|
+
console.log(` ${existsSync12(editPrecheckScript) ? "\u2713" : "\u2717"} ${editPrecheckScript}`);
|
|
4431
|
+
console.log(` ${existsSync12(editCaptureScript) ? "\u2713" : "\u2717"} ${editCaptureScript}`);
|
|
4432
|
+
console.log(` ${existsSync12(stopSummaryScript) ? "\u2713" : "\u2717"} ${stopSummaryScript}`);
|
|
4433
|
+
console.log(` ${existsSync12(sessionStartScript) ? "\u2713" : "\u2717"} ${sessionStartScript}`);
|
|
4434
|
+
console.log(` ${existsSync12(commonScript) ? "\u2713" : "\u2717"} ${commonScript}`);
|
|
4435
|
+
console.log(` ${existsSync12(cursorBashJudgeScript) ? "\u2713" : "\u2717"} ${cursorBashJudgeScript}`);
|
|
4436
|
+
console.log(` ${existsSync12(cursorEditPrecheckScript) ? "\u2713" : "\u2717"} ${cursorEditPrecheckScript}`);
|
|
4437
|
+
console.log(` ${existsSync12(cursorEditCaptureScript) ? "\u2713" : "\u2717"} ${cursorEditCaptureScript}`);
|
|
4438
|
+
console.log(` ${existsSync12(cursorBashFollowupScript) ? "\u2713" : "\u2717"} ${cursorBashFollowupScript}`);
|
|
4481
4439
|
console.log();
|
|
4482
4440
|
const mcp = inspectMcpConfig();
|
|
4483
4441
|
console.log("Guardrails MCP server (Claude Code):");
|
|
@@ -4498,8 +4456,8 @@ var init_status = __esm({
|
|
|
4498
4456
|
init_ccHookConfig();
|
|
4499
4457
|
init_cursorHookConfig();
|
|
4500
4458
|
init_mcpConfig();
|
|
4501
|
-
SYNKRO_DIR3 =
|
|
4502
|
-
CONFIG_PATH4 =
|
|
4459
|
+
SYNKRO_DIR3 = join12(homedir11(), ".synkro");
|
|
4460
|
+
CONFIG_PATH4 = join12(SYNKRO_DIR3, "config.env");
|
|
4503
4461
|
}
|
|
4504
4462
|
});
|
|
4505
4463
|
|
|
@@ -4588,13 +4546,13 @@ var config_exports = {};
|
|
|
4588
4546
|
__export(config_exports, {
|
|
4589
4547
|
configCommand: () => configCommand
|
|
4590
4548
|
});
|
|
4591
|
-
import { readFileSync as
|
|
4592
|
-
import { join as
|
|
4593
|
-
import { homedir as
|
|
4549
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync8, existsSync as existsSync13 } from "fs";
|
|
4550
|
+
import { join as join13 } from "path";
|
|
4551
|
+
import { homedir as homedir12 } from "os";
|
|
4594
4552
|
function readConfigEnv2() {
|
|
4595
|
-
if (!
|
|
4553
|
+
if (!existsSync13(CONFIG_PATH5)) return {};
|
|
4596
4554
|
const out = {};
|
|
4597
|
-
for (const line of
|
|
4555
|
+
for (const line of readFileSync12(CONFIG_PATH5, "utf-8").split("\n")) {
|
|
4598
4556
|
const t = line.trim();
|
|
4599
4557
|
if (!t || t.startsWith("#")) continue;
|
|
4600
4558
|
const eq = t.indexOf("=");
|
|
@@ -4603,11 +4561,11 @@ function readConfigEnv2() {
|
|
|
4603
4561
|
return out;
|
|
4604
4562
|
}
|
|
4605
4563
|
function updateConfigValue(key, value) {
|
|
4606
|
-
if (!
|
|
4564
|
+
if (!existsSync13(CONFIG_PATH5)) {
|
|
4607
4565
|
console.error("No config found. Run `synkro install` first.");
|
|
4608
4566
|
process.exit(1);
|
|
4609
4567
|
}
|
|
4610
|
-
const lines =
|
|
4568
|
+
const lines = readFileSync12(CONFIG_PATH5, "utf-8").split("\n");
|
|
4611
4569
|
const pattern = new RegExp(`^${key}=`);
|
|
4612
4570
|
let found = false;
|
|
4613
4571
|
const updated = lines.map((line) => {
|
|
@@ -4618,7 +4576,7 @@ function updateConfigValue(key, value) {
|
|
|
4618
4576
|
return line;
|
|
4619
4577
|
});
|
|
4620
4578
|
if (!found) updated.splice(updated.length - 1, 0, `${key}='${value}'`);
|
|
4621
|
-
|
|
4579
|
+
writeFileSync8(CONFIG_PATH5, updated.join("\n"), "utf-8");
|
|
4622
4580
|
}
|
|
4623
4581
|
async function configCommand(args2) {
|
|
4624
4582
|
if (args2.length === 0) {
|
|
@@ -4674,8 +4632,8 @@ var init_config = __esm({
|
|
|
4674
4632
|
"cli/commands/config.ts"() {
|
|
4675
4633
|
"use strict";
|
|
4676
4634
|
init_stub();
|
|
4677
|
-
SYNKRO_DIR4 =
|
|
4678
|
-
CONFIG_PATH5 =
|
|
4635
|
+
SYNKRO_DIR4 = join13(homedir12(), ".synkro");
|
|
4636
|
+
CONFIG_PATH5 = join13(SYNKRO_DIR4, "config.env");
|
|
4679
4637
|
}
|
|
4680
4638
|
});
|
|
4681
4639
|
|
|
@@ -4685,8 +4643,8 @@ __export(scanPr_exports, {
|
|
|
4685
4643
|
scanPrCommand: () => scanPrCommand
|
|
4686
4644
|
});
|
|
4687
4645
|
import { execSync as execSync6, spawn as spawn2 } from "child_process";
|
|
4688
|
-
import { readFileSync as
|
|
4689
|
-
import { join as
|
|
4646
|
+
import { readFileSync as readFileSync13, existsSync as existsSync14 } from "fs";
|
|
4647
|
+
import { join as join14 } from "path";
|
|
4690
4648
|
function parseMatchSpec(condition) {
|
|
4691
4649
|
if (!condition.startsWith("match_spec:")) return null;
|
|
4692
4650
|
try {
|
|
@@ -5165,10 +5123,10 @@ function shouldFail(findings, threshold) {
|
|
|
5165
5123
|
return findings.some((f) => order.indexOf(f.severity) >= thresholdIdx);
|
|
5166
5124
|
}
|
|
5167
5125
|
function readRepoDeps() {
|
|
5168
|
-
const pkgPath =
|
|
5169
|
-
if (!
|
|
5126
|
+
const pkgPath = join14(process.cwd(), "package.json");
|
|
5127
|
+
if (!existsSync14(pkgPath)) return {};
|
|
5170
5128
|
try {
|
|
5171
|
-
const pkg = JSON.parse(
|
|
5129
|
+
const pkg = JSON.parse(readFileSync13(pkgPath, "utf-8"));
|
|
5172
5130
|
return { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
5173
5131
|
} catch {
|
|
5174
5132
|
return {};
|
|
@@ -5430,9 +5388,9 @@ var disconnect_exports = {};
|
|
|
5430
5388
|
__export(disconnect_exports, {
|
|
5431
5389
|
disconnectCommand: () => disconnectCommand
|
|
5432
5390
|
});
|
|
5433
|
-
import { existsSync as
|
|
5434
|
-
import { homedir as
|
|
5435
|
-
import { join as
|
|
5391
|
+
import { existsSync as existsSync15, rmSync } from "fs";
|
|
5392
|
+
import { homedir as homedir13 } from "os";
|
|
5393
|
+
import { join as join15 } from "path";
|
|
5436
5394
|
function tearDownLocalCC() {
|
|
5437
5395
|
let hadTask = false;
|
|
5438
5396
|
try {
|
|
@@ -5465,13 +5423,13 @@ function disconnectCommand(args2 = []) {
|
|
|
5465
5423
|
console.log(`${mcpRemoved ? "\u2713" : "\xB7"} MCP guardrails server: ${mcpRemoved ? "removed entry from ~/.claude.json" : "no Synkro MCP entry found"}`);
|
|
5466
5424
|
}
|
|
5467
5425
|
if (purge) {
|
|
5468
|
-
if (
|
|
5426
|
+
if (existsSync15(SYNKRO_DIR5)) {
|
|
5469
5427
|
rmSync(SYNKRO_DIR5, { recursive: true, force: true });
|
|
5470
5428
|
console.log(`\u2713 Removed ${SYNKRO_DIR5}`);
|
|
5471
5429
|
} else {
|
|
5472
5430
|
console.log(`\xB7 ${SYNKRO_DIR5} already gone, nothing to remove`);
|
|
5473
5431
|
}
|
|
5474
|
-
} else if (
|
|
5432
|
+
} else if (existsSync15(SYNKRO_DIR5)) {
|
|
5475
5433
|
console.log(`Config preserved at ${SYNKRO_DIR5}. Run with --purge to remove.`);
|
|
5476
5434
|
}
|
|
5477
5435
|
console.log("\nSynkro disconnected.");
|
|
@@ -5486,7 +5444,7 @@ var init_disconnect = __esm({
|
|
|
5486
5444
|
init_mcpConfig();
|
|
5487
5445
|
init_pueue();
|
|
5488
5446
|
init_install();
|
|
5489
|
-
SYNKRO_DIR5 =
|
|
5447
|
+
SYNKRO_DIR5 = join15(homedir13(), ".synkro");
|
|
5490
5448
|
}
|
|
5491
5449
|
});
|
|
5492
5450
|
|
|
@@ -5533,9 +5491,9 @@ __export(localCc_exports, {
|
|
|
5533
5491
|
localCcCommand: () => localCcCommand
|
|
5534
5492
|
});
|
|
5535
5493
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
5536
|
-
import { homedir as
|
|
5537
|
-
import { join as
|
|
5538
|
-
import { existsSync as
|
|
5494
|
+
import { homedir as homedir14 } from "os";
|
|
5495
|
+
import { join as join16 } from "path";
|
|
5496
|
+
import { existsSync as existsSync16, readFileSync as readFileSync14, writeFileSync as writeFileSync9 } from "fs";
|
|
5539
5497
|
function printHelp() {
|
|
5540
5498
|
console.log(`synkro local-cc \u2014 manage the local Claude Code inference session
|
|
5541
5499
|
|
|
@@ -5625,15 +5583,15 @@ TROUBLESHOOTING
|
|
|
5625
5583
|
`);
|
|
5626
5584
|
}
|
|
5627
5585
|
function readGatewayUrl() {
|
|
5628
|
-
if (
|
|
5629
|
-
const m =
|
|
5586
|
+
if (existsSync16(CONFIG_PATH6)) {
|
|
5587
|
+
const m = readFileSync14(CONFIG_PATH6, "utf-8").match(/^SYNKRO_GATEWAY_URL='([^']*)'/m);
|
|
5630
5588
|
if (m) return m[1];
|
|
5631
5589
|
}
|
|
5632
5590
|
return "https://api.synkro.sh";
|
|
5633
5591
|
}
|
|
5634
5592
|
function updateLocalInferenceFlag2(enabled) {
|
|
5635
|
-
if (!
|
|
5636
|
-
let content =
|
|
5593
|
+
if (!existsSync16(CONFIG_PATH6)) return;
|
|
5594
|
+
let content = readFileSync14(CONFIG_PATH6, "utf-8");
|
|
5637
5595
|
const flag = enabled ? "yes" : "no";
|
|
5638
5596
|
if (content.includes("SYNKRO_LOCAL_INFERENCE=")) {
|
|
5639
5597
|
content = content.replace(/^SYNKRO_LOCAL_INFERENCE='[^']*'/m, `SYNKRO_LOCAL_INFERENCE='${flag}'`);
|
|
@@ -5642,7 +5600,7 @@ function updateLocalInferenceFlag2(enabled) {
|
|
|
5642
5600
|
SYNKRO_LOCAL_INFERENCE='${flag}'
|
|
5643
5601
|
`;
|
|
5644
5602
|
}
|
|
5645
|
-
|
|
5603
|
+
writeFileSync9(CONFIG_PATH6, content, "utf-8");
|
|
5646
5604
|
}
|
|
5647
5605
|
async function setServerGradingProvider(provider) {
|
|
5648
5606
|
await ensureValidToken();
|
|
@@ -5917,7 +5875,7 @@ var init_localCc = __esm({
|
|
|
5917
5875
|
init_settings();
|
|
5918
5876
|
init_client();
|
|
5919
5877
|
init_stub();
|
|
5920
|
-
CONFIG_PATH6 =
|
|
5878
|
+
CONFIG_PATH6 = join16(homedir14(), ".synkro", "config.env");
|
|
5921
5879
|
}
|
|
5922
5880
|
});
|
|
5923
5881
|
|
|
@@ -5969,15 +5927,15 @@ var init_grade = __esm({
|
|
|
5969
5927
|
});
|
|
5970
5928
|
|
|
5971
5929
|
// cli/bootstrap.js
|
|
5972
|
-
import { readFileSync as
|
|
5930
|
+
import { readFileSync as readFileSync15, existsSync as existsSync17 } from "fs";
|
|
5973
5931
|
import { resolve } from "path";
|
|
5974
5932
|
var envCandidates = [
|
|
5975
5933
|
resolve(process.cwd(), ".env"),
|
|
5976
5934
|
resolve(process.env.HOME ?? "", ".synkro", "config.env")
|
|
5977
5935
|
];
|
|
5978
5936
|
for (const envPath of envCandidates) {
|
|
5979
|
-
if (!
|
|
5980
|
-
const envContent =
|
|
5937
|
+
if (!existsSync17(envPath)) continue;
|
|
5938
|
+
const envContent = readFileSync15(envPath, "utf-8");
|
|
5981
5939
|
for (const line of envContent.split("\n")) {
|
|
5982
5940
|
const trimmed = line.trim();
|
|
5983
5941
|
if (!trimmed || trimmed.startsWith("#")) continue;
|