@synkro-sh/cli 1.2.0 → 1.2.2
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 +29 -27
- package/dist/bootstrap.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -114,7 +114,7 @@ function installCCHooks(settingsPath, config) {
|
|
|
114
114
|
{
|
|
115
115
|
type: "command",
|
|
116
116
|
command: config.bashJudgeScriptPath,
|
|
117
|
-
timeout:
|
|
117
|
+
timeout: 15
|
|
118
118
|
}
|
|
119
119
|
],
|
|
120
120
|
[SYNKRO_MARKER]: true
|
|
@@ -513,7 +513,7 @@ if [ "$SYNKRO_INFERENCE_TIER" = "free" ] && command -v claude >/dev/null 2>&1; t
|
|
|
513
513
|
V_INNER=$(printf '%s' "$CC_RESP" | tr '\\n' ' ' | grep -oE '<synkro-verdict>[^<]*</synkro-verdict>' | tail -1 | sed -E 's|^<synkro-verdict>||; s|</synkro-verdict>$||')
|
|
514
514
|
if [ -z "$V_INNER" ] || ! echo "$V_INNER" | jq -e '.severity' >/dev/null 2>&1; then
|
|
515
515
|
synkro_log "bashGuard $CMD_SHORT \u2192 error (no verdict)"
|
|
516
|
-
|
|
516
|
+
jq -n --arg m "[synkro] bashGuard \u2192 error (no verdict)" '{systemMessage: $m}'
|
|
517
517
|
exit 0
|
|
518
518
|
fi
|
|
519
519
|
VERDICT="$V_INNER"
|
|
@@ -540,7 +540,7 @@ fi
|
|
|
540
540
|
|
|
541
541
|
if [ -z "$VERDICT" ]; then
|
|
542
542
|
synkro_log "bashGuard $CMD_SHORT \u2192 error (timeout)"
|
|
543
|
-
|
|
543
|
+
jq -n --arg m "[synkro] bashGuard \u2192 error (timeout)" '{systemMessage: $m}'
|
|
544
544
|
exit 0
|
|
545
545
|
fi
|
|
546
546
|
|
|
@@ -621,9 +621,9 @@ case "$SEVERITY" in
|
|
|
621
621
|
}'
|
|
622
622
|
;;
|
|
623
623
|
*)
|
|
624
|
-
# low / medium / anything else \u2192
|
|
624
|
+
# low / medium / anything else \u2192 allow
|
|
625
625
|
synkro_log "bashGuard $CMD_SHORT \u2192 pass"
|
|
626
|
-
|
|
626
|
+
jq -n --arg m "[synkro] bashGuard \u2192 pass" '{systemMessage: $m}'
|
|
627
627
|
;;
|
|
628
628
|
esac
|
|
629
629
|
|
|
@@ -854,6 +854,21 @@ refresh_jwt() {
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
|
|
857
|
+
# Resolve tier (cached 60 min) \u2014 server is canonical via /cli/me; fallback free.
|
|
858
|
+
TIER_CACHE_FILE="$HOME/.synkro/.tier-cache-\${SYNKRO_USER_ID:-default}"
|
|
859
|
+
SYNKRO_INFERENCE_TIER=""
|
|
860
|
+
if find "$TIER_CACHE_FILE" -mmin -60 2>/dev/null | grep -q .; then
|
|
861
|
+
SYNKRO_INFERENCE_TIER=$(cat "$TIER_CACHE_FILE" 2>/dev/null)
|
|
862
|
+
fi
|
|
863
|
+
if [ -z "$SYNKRO_INFERENCE_TIER" ]; then
|
|
864
|
+
ME_RESP=$(curl -sS "\${GATEWAY_URL}/api/v1/cli/me" -H "Authorization: Bearer $JWT" --max-time 2 2>/dev/null || echo "")
|
|
865
|
+
if [ -n "$ME_RESP" ]; then
|
|
866
|
+
SYNKRO_INFERENCE_TIER=$(echo "$ME_RESP" | jq -r '.tier // empty' 2>/dev/null)
|
|
867
|
+
[ -n "$SYNKRO_INFERENCE_TIER" ] && printf '%s' "$SYNKRO_INFERENCE_TIER" > "$TIER_CACHE_FILE" 2>/dev/null || true
|
|
868
|
+
fi
|
|
869
|
+
fi
|
|
870
|
+
SYNKRO_INFERENCE_TIER="\${SYNKRO_INFERENCE_TIER:-free}"
|
|
871
|
+
|
|
857
872
|
if [ "$SYNKRO_INFERENCE_TIER" = "free" ] && command -v claude >/dev/null 2>&1; then
|
|
858
873
|
# \u2500\u2500\u2500 FREE TIER: grade via the persistent claude daemon (Python helper).
|
|
859
874
|
ORG_RULES=$(printf '%s' "$PROPOSED" | head -c 8000 \\
|
|
@@ -962,13 +977,13 @@ fi
|
|
|
962
977
|
|
|
963
978
|
if [ -z "$RESP" ]; then
|
|
964
979
|
synkro_log "editGuard $FILE_SHORT \u2192 error (timeout)"
|
|
965
|
-
|
|
980
|
+
jq -n --arg m "[synkro] editGuard $FILE_SHORT \u2192 error (timeout)" '{systemMessage: $m}'
|
|
966
981
|
exit 0
|
|
967
982
|
fi
|
|
968
983
|
|
|
969
984
|
if ! echo "$RESP" | jq -e 'type == "object"' >/dev/null 2>&1; then
|
|
970
985
|
synkro_log "editGuard $FILE_SHORT \u2192 error (bad response)"
|
|
971
|
-
|
|
986
|
+
jq -n --arg m "[synkro] editGuard $FILE_SHORT \u2192 error (bad response)" '{systemMessage: $m}'
|
|
972
987
|
exit 0
|
|
973
988
|
fi
|
|
974
989
|
|
|
@@ -976,11 +991,13 @@ DECISION=$(echo "$RESP" | jq -r '.hookSpecificOutput.permissionDecision // "allo
|
|
|
976
991
|
if [ "$DECISION" = "deny" ]; then
|
|
977
992
|
DENY_REASON=$(echo "$RESP" | jq -r '.hookSpecificOutput.permissionDecisionReason // ""' 2>/dev/null)
|
|
978
993
|
synkro_log "editGuard $FILE_SHORT \u2192 BLOCKED: $DENY_REASON"
|
|
994
|
+
echo "$RESP"
|
|
979
995
|
else
|
|
980
996
|
synkro_log "editGuard $FILE_SHORT \u2192 pass"
|
|
997
|
+
RESP_WITH_MSG=$(echo "$RESP" | jq --arg m "[synkro] editGuard $FILE_SHORT \u2192 pass" '. + {systemMessage: $m}')
|
|
998
|
+
echo "$RESP_WITH_MSG"
|
|
981
999
|
fi
|
|
982
1000
|
|
|
983
|
-
echo "$RESP"
|
|
984
1001
|
exit 0
|
|
985
1002
|
`;
|
|
986
1003
|
CC_EDIT_CAPTURE_SCRIPT = `#!/bin/bash
|
|
@@ -1193,12 +1210,7 @@ fi
|
|
|
1193
1210
|
|
|
1194
1211
|
if [ -z "$RESP" ] || ! echo "$RESP" | jq -e 'type == "object"' >/dev/null 2>&1; then
|
|
1195
1212
|
synkro_log "editScan $BASENAME \u2192 error (no response)"
|
|
1196
|
-
|
|
1197
|
-
SYS_MSG="[synkro] afterFileEdit \u2192 scanned \${BASENAME} (grader unavailable)"
|
|
1198
|
-
jq -n --arg sys_msg "$SYS_MSG" '{ systemMessage: $sys_msg }'
|
|
1199
|
-
exit 0
|
|
1200
|
-
fi
|
|
1201
|
-
echo '{}'
|
|
1213
|
+
jq -n --arg m "[synkro] editScan $BASENAME \u2192 error (no response)" '{systemMessage: $m}'
|
|
1202
1214
|
exit 0
|
|
1203
1215
|
fi
|
|
1204
1216
|
|
|
@@ -1209,7 +1221,7 @@ REASON=$(echo "$RESP" | jq -r '.reason // ""' 2>/dev/null)
|
|
|
1209
1221
|
|
|
1210
1222
|
if [ "$OK" = "false" ] && [ -n "$REASON" ]; then
|
|
1211
1223
|
synkro_log "editScan $BASENAME \u2192 FAIL ($CATEGORY): $REASON"
|
|
1212
|
-
SYS_MSG="[synkro]
|
|
1224
|
+
SYS_MSG="[synkro] editScan $BASENAME \u2192 FAIL: \${REASON}"
|
|
1213
1225
|
ADDITIONAL_CTX="Synkro post-edit grader flagged \${BASENAME} (severity: \${SEVERITY}, category: \${CATEGORY}). Re-edit the file applying the retry guidance: \${REASON}"
|
|
1214
1226
|
jq -n \\
|
|
1215
1227
|
--arg sys_msg "$SYS_MSG" \\
|
|
@@ -1225,14 +1237,7 @@ if [ "$OK" = "false" ] && [ -n "$REASON" ]; then
|
|
|
1225
1237
|
fi
|
|
1226
1238
|
|
|
1227
1239
|
synkro_log "editScan $BASENAME \u2192 pass"
|
|
1228
|
-
|
|
1229
|
-
if [ "\${SYNKRO_VERBOSE:-0}" = "1" ]; then
|
|
1230
|
-
SYS_MSG="[synkro] afterFileEdit \u2192 no issues in \${BASENAME}"
|
|
1231
|
-
jq -n --arg sys_msg "$SYS_MSG" '{ systemMessage: $sys_msg }'
|
|
1232
|
-
exit 0
|
|
1233
|
-
fi
|
|
1234
|
-
|
|
1235
|
-
echo '{}'
|
|
1240
|
+
jq -n --arg m "[synkro] editScan $BASENAME \u2192 pass" '{systemMessage: $m}'
|
|
1236
1241
|
exit 0
|
|
1237
1242
|
`;
|
|
1238
1243
|
CC_STOP_SUMMARY_SCRIPT = `#!/bin/bash
|
|
@@ -2213,8 +2218,6 @@ function writeConfigEnv(opts) {
|
|
|
2213
2218
|
const safeOrgId = sanitizeConfigValue(opts.orgId);
|
|
2214
2219
|
const safeEmail = sanitizeConfigValue(opts.email);
|
|
2215
2220
|
const safeTier = sanitizeConfigValue(opts.tier ?? "pro", 32);
|
|
2216
|
-
const tierEnv = process.env.SYNKRO_INFERENCE_TIER;
|
|
2217
|
-
const safeInferenceTier = tierEnv === "fast" ? "fast" : "free";
|
|
2218
2221
|
const lines = [
|
|
2219
2222
|
"# Synkro CLI config (managed by synkro install)",
|
|
2220
2223
|
"# JWT auth \u2014 the hook scripts read SYNKRO_CREDENTIALS_PATH at runtime",
|
|
@@ -2222,12 +2225,11 @@ function writeConfigEnv(opts) {
|
|
|
2222
2225
|
`SYNKRO_GATEWAY_URL=${shellQuoteSingle(safeGateway)}`,
|
|
2223
2226
|
`SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
|
|
2224
2227
|
`SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
|
|
2225
|
-
`SYNKRO_VERSION=${shellQuoteSingle("1.2.
|
|
2228
|
+
`SYNKRO_VERSION=${shellQuoteSingle("1.2.2")}`
|
|
2226
2229
|
];
|
|
2227
2230
|
if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
|
|
2228
2231
|
if (safeOrgId) lines.push(`SYNKRO_ORG_ID=${shellQuoteSingle(safeOrgId)}`);
|
|
2229
2232
|
if (safeEmail) lines.push(`SYNKRO_EMAIL=${shellQuoteSingle(safeEmail)}`);
|
|
2230
|
-
lines.push(`SYNKRO_INFERENCE_TIER=${shellQuoteSingle(safeInferenceTier)}`);
|
|
2231
2233
|
lines.push("");
|
|
2232
2234
|
writeFileSync4(CONFIG_PATH, lines.join("\n"), "utf-8");
|
|
2233
2235
|
chmodSync(CONFIG_PATH, 384);
|