sprag-cli 3.106.0 → 3.107.0
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/README.ko.md +2 -0
- package/README.md +2 -0
- package/bin/cli.js +38 -3
- package/package.json +2 -2
- package/src/brief.js +20 -2
- package/src/caps-cache.js +12 -2
- package/src/codex/delegation.js +24 -8
- package/src/codex/route-scan.js +2 -1
- package/src/commands/brief.js +45 -3
- package/src/commands/doc2md.js +7 -0
- package/src/commands/route-scan.js +15 -0
- package/src/commands/routing.js +57 -2
- package/src/commands/secrets.js +107 -0
- package/src/compact-window.js +2 -1
- package/src/ctx-window-cache.js +14 -0
- package/src/delegation-guard.js +74 -5
- package/src/doc2md.cjs +38 -0
- package/src/formatters/statusline.js +26 -3
- package/src/grade-counts.js +85 -0
- package/src/harness.js +7 -6
- package/src/installer.js +2 -0
- package/src/judgement-prompt.js +145 -0
- package/src/model-rules.js +44 -3
- package/src/permission-secrets.js +239 -0
- package/src/preset-ratchet.js +2 -1
- package/src/private-file.js +20 -0
- package/src/redact.js +189 -0
- package/src/relax-offer.js +51 -0
- package/src/route-follow.js +42 -0
- package/src/route-inject.js +133 -4
- package/src/route-scan.js +25 -1
- package/src/routing-switch.js +105 -0
- package/src/session-effort.js +71 -0
- package/src/team-prompts.js +4 -83
package/README.ko.md
CHANGED
|
@@ -239,6 +239,8 @@ Codex에는 기본 훅과 `AGENTS.md` 하네스, 범위별 래칫 규칙, 한국
|
|
|
239
239
|
| `sprag route-scan` | 내 기록에서 위임 후보 찾기 (LLM 호출 0회) |
|
|
240
240
|
| `sprag route-scan savings` | 라우팅 절감 원장 조회 |
|
|
241
241
|
| `sprag routing on\|off` | 모델 위임(룰과 힌트와 후보 안내) 켜기와 끄기 |
|
|
242
|
+
| `sprag routing relax [off]` | 가장 바쁜 사용량 창이 초기화될 때까지 위임 범위를 넓히거나(그 뒤에는 자동으로 돌아옵니다) 일찍 끝냅니다. `sprag routing status`에 `relax: off` 또는 `relax: until HH:MM`이 나옵니다 |
|
|
243
|
+
| `sprag secrets [fix]` | Claude Code 설정 파일의 승인 목록에서 비밀 값이 든 항목을 찾아 보여 주고(값은 출력하지 않습니다), `fix` 로 원본을 백업한 뒤 지웁니다. `sprag secrets off` 는 세션 시작 알림을 끕니다 |
|
|
242
244
|
| `sprag harness check` | 🅷 하네스 점수 확인 |
|
|
243
245
|
| `sprag doc2md <파일>` | 문서 한 건을 Markdown 으로 변환 |
|
|
244
246
|
|
package/README.md
CHANGED
|
@@ -300,6 +300,8 @@ The ratchet presets, model-routing presets and delegation agents in `presets/` a
|
|
|
300
300
|
| `sprag route-scan` | Find delegation candidates in your own history (0 LLM calls) |
|
|
301
301
|
| `sprag route-scan savings` | The routing-savings ledger |
|
|
302
302
|
| `sprag routing on\|off` | Turn model delegation (rules, hints, candidates) on or off |
|
|
303
|
+
| `sprag routing relax [off]` | Widen delegation until the busiest usage window resets (it switches back by itself), or end that early. `sprag routing status` shows `relax: off` or `relax: until HH:MM` |
|
|
304
|
+
| `sprag secrets [fix]` | List approval-list entries in Claude Code settings files that hold secrets (values are never shown), or remove them after backing up the original. `sprag secrets off` silences the session start notice |
|
|
303
305
|
| `sprag harness check` | Current 🅷 harness score |
|
|
304
306
|
| `sprag doc2md <file>` | Convert one document to Markdown |
|
|
305
307
|
|
package/bin/cli.js
CHANGED
|
@@ -132,7 +132,7 @@ function columnsFromArgs({ useEnv = true } = {}) {
|
|
|
132
132
|
const KNOWN_SUBCOMMANDS = new Set([
|
|
133
133
|
'last', 'brief', 'history', 'handoff', 'install', 'uninstall', 'mode', 'korean', 'cohesion',
|
|
134
134
|
'doc2md', 'delegate', 'proof', 'harness', 'route-scan', 'compact-window', 'update-check', 'upgrade',
|
|
135
|
-
'seed', 'litellm-budget', 'oauth-budget', 'profile-map', 'feedback', 'saved', 'cowork', 'team', 'presets', 'routing',
|
|
135
|
+
'seed', 'litellm-budget', 'oauth-budget', 'profile-map', 'feedback', 'saved', 'cowork', 'team', 'presets', 'routing', 'secrets',
|
|
136
136
|
]);
|
|
137
137
|
|
|
138
138
|
// Flags each entry path reads, collected from the hasFlag/getArg/numArg calls in
|
|
@@ -227,10 +227,11 @@ Usage:
|
|
|
227
227
|
sprag mode [keywords] statusline preferences (icon/text, en/ko, window, ttl)
|
|
228
228
|
sprag seed register the bundled starter rules, one answer at a time
|
|
229
229
|
sprag presets [status|sync|show] centrally published presets: source, fetch now, effective list
|
|
230
|
+
sprag secrets [fix] find (and remove) secrets saved in Claude Code approval lists
|
|
230
231
|
sprag cowork [sync|on|off|exclude <dir>|include <dir>] copy the ratchet rules into Cowork tab folders
|
|
231
232
|
sprag korean on|off|status Korean writing guidance + write-time check
|
|
232
233
|
sprag cohesion on|off|status English sentence-connection guidance
|
|
233
|
-
sprag routing on|off|status model delegation master switch (rules, hints, candidates)
|
|
234
|
+
sprag routing on|off|status|relax [off]|effort-hint on|off model delegation master switch (rules, hints, candidates); relax widens it until the usage window resets
|
|
234
235
|
sprag doc2md on|off|<file> convert documents to Markdown before the model reads them
|
|
235
236
|
sprag delegate on|off|status add bounds and context to Task/Agent delegation prompts
|
|
236
237
|
sprag proof [--json] replayed delegation cases behind the tier rules (https://sprag.io/proof/)
|
|
@@ -413,9 +414,14 @@ async function main() {
|
|
|
413
414
|
|
|
414
415
|
// Subcommand: routing — master switch for model delegation (ratchet-model.md
|
|
415
416
|
// rules, prompt hints, route-scan candidates).
|
|
416
|
-
// sprag routing on | off | status
|
|
417
|
+
// sprag routing on | off | status | relax [off]
|
|
417
418
|
if (args[0] === 'routing') return (await import('../src/commands/routing.js')).run({ args, hasFlag });
|
|
418
419
|
|
|
420
|
+
// Subcommand: secrets — find (and remove) secrets that "don't ask again" saved
|
|
421
|
+
// in the permission lists of Claude Code settings files.
|
|
422
|
+
// sprag secrets | secrets fix [--yes] | secrets off | on
|
|
423
|
+
if (args[0] === 'secrets') return (await import('../src/commands/secrets.js')).run({ args, hasFlag });
|
|
424
|
+
|
|
419
425
|
// Subcommand: doc2md — convert pptx/xlsx/pdf/docx to Markdown before the
|
|
420
426
|
// model reads them, so an unreadable binary never enters the context window.
|
|
421
427
|
// sprag doc2md on | off | <file> | --clean
|
|
@@ -721,6 +727,11 @@ async function main() {
|
|
|
721
727
|
// not change their minds when the analysis window empties.
|
|
722
728
|
const effort = extractEffort(stdinJson);
|
|
723
729
|
const ultra = ultraChipFor(stdinJson);
|
|
730
|
+
|
|
731
|
+
try {
|
|
732
|
+
const sid = extractSessionId(stdinJson);
|
|
733
|
+
if (sid && effort) (await import('../src/session-effort.js')).recordSessionEffort(sid, effort);
|
|
734
|
+
} catch (e) { debug('session-effort:record', e); }
|
|
724
735
|
// Recorded here too: a fresh session can render before it has any request
|
|
725
736
|
// in the analysis window, and its first prompt is briefed from this.
|
|
726
737
|
const ctxLive = extractContextUsage(stdinJson);
|
|
@@ -796,6 +807,15 @@ async function main() {
|
|
|
796
807
|
// handed a transcript path asks; every other caller gets no ultra chip.
|
|
797
808
|
const effort = extractEffort(stdinJson);
|
|
798
809
|
const ultra = isStatusline ? ultraChipFor(stdinJson) : null;
|
|
810
|
+
// The prompt hook gets no effort in its payload; it reads back what this render saw.
|
|
811
|
+
if (isStatusline && effort) {
|
|
812
|
+
try {
|
|
813
|
+
const sid = extractSessionId(stdinJson);
|
|
814
|
+
if (sid) (await import('../src/session-effort.js')).recordSessionEffort(sid, effort);
|
|
815
|
+
} catch (e) {
|
|
816
|
+
debug('session-effort:record', e);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
799
819
|
const ctxLive = extractContextUsage(stdinJson);
|
|
800
820
|
// The prompt-submit briefing has no payload field for the window, so it reads
|
|
801
821
|
// back what this render was told (see src/ctx-window-cache.js).
|
|
@@ -1030,6 +1050,19 @@ async function main() {
|
|
|
1030
1050
|
} catch (e) {
|
|
1031
1051
|
debug('effort-raise-ledger:totals', e);
|
|
1032
1052
|
}
|
|
1053
|
+
// What the delegation grade did (judgement delegations raised to Opus) and
|
|
1054
|
+
// whether a relax window is open. Both are lookups, and the relax deadline stays out of
|
|
1055
|
+
// the data while routing is off, since it does nothing then.
|
|
1056
|
+
let gradeActions = null;
|
|
1057
|
+
let relaxUntilNow = null;
|
|
1058
|
+
try {
|
|
1059
|
+
const { gradeActionTotals } = await import('../src/grade-counts.js');
|
|
1060
|
+
gradeActions = gradeActionTotals();
|
|
1061
|
+
const { routingEnabled, isRelaxed, relaxUntil } = await import('../src/routing-switch.js');
|
|
1062
|
+
if (routingEnabled() && isRelaxed()) relaxUntilNow = relaxUntil();
|
|
1063
|
+
} catch (e) {
|
|
1064
|
+
debug('grade-counts:totals', e);
|
|
1065
|
+
}
|
|
1033
1066
|
// 'auto' unless the user pinned a bucket. Read here rather than in the
|
|
1034
1067
|
// statusline branch below because the table and JSON formatters want the
|
|
1035
1068
|
// same answer.
|
|
@@ -1109,6 +1142,8 @@ async function main() {
|
|
|
1109
1142
|
// Statusline-only; left undefined elsewhere so --format json keeps its shape.
|
|
1110
1143
|
routeScanAt: isStatusline ? routeScanAt : undefined,
|
|
1111
1144
|
effortRaises: isStatusline ? effortRaises : undefined,
|
|
1145
|
+
gradeActions: isStatusline ? gradeActions : undefined,
|
|
1146
|
+
relaxUntil: isStatusline ? relaxUntilNow : undefined,
|
|
1112
1147
|
sessionDelegation,
|
|
1113
1148
|
ruleStats,
|
|
1114
1149
|
ttlBucket,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.107.0",
|
|
4
4
|
"description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"release:notes": "node scripts/release-notes.mjs",
|
|
24
24
|
"site:docs": "node scripts/build-site-docs.mjs",
|
|
25
25
|
"site:serve": "node scripts/serve-site.mjs",
|
|
26
|
-
"test": "node
|
|
26
|
+
"test": "node scripts/test.mjs",
|
|
27
27
|
"test:mods": "claude plugin test mod/sprag-doc2md && claude plugin test mod/sprag-delegation-meter && claude plugin test mod/sprag-statusline",
|
|
28
28
|
"version": "node scripts/sync-site-version.mjs"
|
|
29
29
|
},
|
package/src/brief.js
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, openSync, readSync, closeSync } from 'node:fs';
|
|
29
29
|
import { join } from 'node:path';
|
|
30
30
|
import { userDataDir } from './paths.js';
|
|
31
|
-
import { resolveModelId, isOneMillionModel, effectiveWindow } from './compact-window.js';
|
|
32
|
-
import { liveWindowFor, liveModelFor } from './ctx-window-cache.js';
|
|
31
|
+
import { resolveModelId, isOneMillionModel, effectiveWindow, canonicalModelId } from './compact-window.js';
|
|
32
|
+
import { liveWindowFor, liveModelFor, liveWindowsByModel } from './ctx-window-cache.js';
|
|
33
33
|
import { routingEnabled } from './routing-switch.js';
|
|
34
34
|
|
|
35
35
|
// Context tiers as a fraction of the session's context window. Tier 1 warns
|
|
@@ -100,6 +100,24 @@ export function ctxWindowFor(observedMax = 0, root = process.cwd(), { liveWindow
|
|
|
100
100
|
try {
|
|
101
101
|
const { model } = resolveModelId(root);
|
|
102
102
|
if (!reported && isOneMillionModel(model)) modelWindow = window = 1_000_000;
|
|
103
|
+
// No report for this session yet and no `[1m]` in the id: a model Claude
|
|
104
|
+
// Code runs at 1M by default (Opus 5.5 as `opus`) read as 200k until its
|
|
105
|
+
// biggest request passed 250k, so the 80% briefing fired at ~160k (#14).
|
|
106
|
+
// The window another session's statusline reported for the same model is
|
|
107
|
+
// the best evidence there is; the observed-size guess stays the last resort.
|
|
108
|
+
else if (!reported) {
|
|
109
|
+
// A bare alias (`opus`) names whichever version Claude Code resolves it
|
|
110
|
+
// to today, and the statusline records the full id, so an alias matches
|
|
111
|
+
// the newest report of its family.
|
|
112
|
+
const key = canonicalModelId(model);
|
|
113
|
+
const alias = key && /^(opus|sonnet|haiku|fable|mythos)$/.test(key) ? key : null;
|
|
114
|
+
const same = (id) => {
|
|
115
|
+
const c = canonicalModelId(id);
|
|
116
|
+
return c === key || (alias !== null && (c === `claude-${alias}` || (c || '').startsWith(`claude-${alias}-`)));
|
|
117
|
+
};
|
|
118
|
+
const seen = key ? liveWindowsByModel().find((e) => same(e.model)) : null;
|
|
119
|
+
if (seen) modelWindow = window = Math.max(seen.size, modelWindow);
|
|
120
|
+
}
|
|
103
121
|
const cap = effectiveWindow(root).value;
|
|
104
122
|
if (cap !== null && cap < window) {
|
|
105
123
|
window = cap;
|
package/src/caps-cache.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { readFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
13
13
|
import { join } from 'node:path';
|
|
14
14
|
import { userDataDir } from './paths.js';
|
|
15
|
-
import { writeViaTmp } from './state-file.js';
|
|
15
|
+
import { writeViaTmp, runHousekeeping, sweepStaleTmp } from './state-file.js';
|
|
16
16
|
|
|
17
17
|
const CACHE_PATH = join(userDataDir(), 'last-caps.json');
|
|
18
18
|
|
|
@@ -42,10 +42,18 @@ export function persistSnapshot(snapshot) {
|
|
|
42
42
|
// tmp + rename: the statusline reads this every tick and must never see a
|
|
43
43
|
// half-written file.
|
|
44
44
|
const tmp = `${CACHE_PATH}.${process.pid}.tmp`;
|
|
45
|
-
writeViaTmp(tmp, CACHE_PATH, JSON.stringify(payload) + '\n');
|
|
45
|
+
writeViaTmp(tmp, CACHE_PATH, JSON.stringify(payload) + '\n'); // removes tmp itself when the write or rename fails
|
|
46
46
|
} catch {
|
|
47
47
|
// best-effort cache, never blocks the statusline
|
|
48
48
|
}
|
|
49
|
+
// A killed statusline leaves `last-caps.json.<pid>.tmp` behind (hundreds had
|
|
50
|
+
// piled up). This runs on every render, so the sweep is limited to once a day.
|
|
51
|
+
try {
|
|
52
|
+
const dir = userDataDir();
|
|
53
|
+
runHousekeeping(dir, { 'stale-tmp': () => sweepStaleTmp(dir) });
|
|
54
|
+
} catch {
|
|
55
|
+
// clean-up never blocks the statusline
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
/**
|
|
@@ -113,6 +121,7 @@ function modelFamily(text) {
|
|
|
113
121
|
* @param {{caps?: object|null}|null} [opts.snapshot] defaults to the recent snapshot
|
|
114
122
|
* @param {string|null} [opts.sessionModel] model id or display name of the session
|
|
115
123
|
* @returns {{ level: 'normal'|'high'|'critical', pct: number, key: string,
|
|
124
|
+
* resetsAt: number|null (epoch seconds, when the busiest window resets),
|
|
116
125
|
* source: 'subscription'|'litellm' }|null}
|
|
117
126
|
* null when there is no fresh snapshot or no window with a usable percentage
|
|
118
127
|
*/
|
|
@@ -134,6 +143,7 @@ export function capPressure({ snapshot = loadRecentSnapshot(), sessionModel } =
|
|
|
134
143
|
level,
|
|
135
144
|
pct: top.usedPct,
|
|
136
145
|
key: top.key,
|
|
146
|
+
resetsAt: typeof top.resetsAt === 'number' && Number.isFinite(top.resetsAt) && top.resetsAt > 0 ? top.resetsAt : null,
|
|
137
147
|
source: top.key === 'litellm_budget' ? 'litellm' : 'subscription',
|
|
138
148
|
};
|
|
139
149
|
}
|
package/src/codex/delegation.js
CHANGED
|
@@ -5,7 +5,8 @@ import { parse } from 'smol-toml';
|
|
|
5
5
|
import { userDataDir } from '../paths.js';
|
|
6
6
|
import { writeViaTmp } from '../state-file.js';
|
|
7
7
|
import { codexUserDir, codexProviderName } from '../agent.js';
|
|
8
|
-
import { categorize, ESCALATE_RE, EDIT_RE } from '../route-scan.js';
|
|
8
|
+
import { categorize, ESCALATE_RE, JUDGE_RE, EDIT_RE } from '../route-scan.js';
|
|
9
|
+
import { delegationGrade, normalizeDelegationGrade, gradeKeepsRule } from '../routing-switch.js';
|
|
9
10
|
import { looksPasted, isSystemPrompt, isOpinionQuestion, looksLikeContextOrSpec } from '../route-inject.js';
|
|
10
11
|
import { newRouteId, recordCodexDelegation } from './ledger.js';
|
|
11
12
|
import { readCodexTailLines } from './parser.js';
|
|
@@ -223,22 +224,32 @@ export function removeCodexModelRule(index, { dir = userDataDir() } = {}) {
|
|
|
223
224
|
* The category a prompt can be routed under at runtime, or null. The route
|
|
224
225
|
* scan counts episodes with this same gate, so a rule it proposes is one the
|
|
225
226
|
* prompt hook can actually match.
|
|
227
|
+
*
|
|
228
|
+
* The gate follows the delegation grade like the Claude Code hint does:
|
|
229
|
+
* at grade 'quality' a JUDGE_RE request (audit, recommendation, absence check,
|
|
230
|
+
* research) is kept off the delegation path too.
|
|
231
|
+
*
|
|
232
|
+
* Not ported: the recommendation to move a Sonnet session up to Opus
|
|
233
|
+
* (escalationNotice in route-inject.js). Codex names its models differently
|
|
234
|
+
* and the Lab measurement behind the advice was run on Claude models, so there
|
|
235
|
+
* is nothing to say there yet.
|
|
226
236
|
*/
|
|
227
|
-
export function codexPromptCategory(text) {
|
|
237
|
+
export function codexPromptCategory(text, { grade = delegationGrade() } = {}) {
|
|
228
238
|
const prompt = typeof text === 'string' ? text.trim() : '';
|
|
229
239
|
// Same two gates as the Claude Code hint (routeMatch): a harness message is
|
|
230
240
|
// not a request, and an opinion question is judgement rather than a lookup.
|
|
231
241
|
if (isSystemPrompt(prompt) || isOpinionQuestion(prompt)) return null;
|
|
232
242
|
// The #16 gates: a reply, feedback, an outward action, an edit or a long spec.
|
|
233
243
|
if (looksLikeContextOrSpec(prompt)) return null;
|
|
244
|
+
if ((normalizeDelegationGrade(grade) ?? 'quality') === 'quality' && JUDGE_RE.test(prompt)) return null;
|
|
234
245
|
if (prompt.length < 8 || ESCALATE_RE.test(prompt) || EDIT_RE.test(prompt) || /\b(?:implement|modify|fix|delete|push|commit)\b/i.test(prompt)) return null;
|
|
235
246
|
const category = categorize(prompt, null);
|
|
236
247
|
if (!category || (category.id === 'paste' && !looksPasted(prompt))) return null;
|
|
237
248
|
return category;
|
|
238
249
|
}
|
|
239
250
|
|
|
240
|
-
export function matchCodexModelRule(text, { model, root, provider = codexProviderName(), rules = loadCodexModelRules() } = {}) {
|
|
241
|
-
const category = codexPromptCategory(text);
|
|
251
|
+
export function matchCodexModelRule(text, { model, root, provider = codexProviderName(), rules = loadCodexModelRules(), grade } = {}) {
|
|
252
|
+
const category = codexPromptCategory(text, { grade });
|
|
242
253
|
if (!category) return null;
|
|
243
254
|
const usable = rules.filter((r) => r?.status === 'active' && r.category === category.id && r.from === model &&
|
|
244
255
|
(!r.provider || r.provider === provider) &&
|
|
@@ -250,9 +261,12 @@ export function matchCodexModelRule(text, { model, root, provider = codexProvide
|
|
|
250
261
|
function matchingRoutes(text, opts) {
|
|
251
262
|
const own = matchCodexModelRule(text, { ...opts, rules: opts.rules ?? loadCodexModelRules({ dir: opts.dir }) });
|
|
252
263
|
if (own) return [own];
|
|
253
|
-
const category = codexPromptCategory(text);
|
|
264
|
+
const category = codexPromptCategory(text, { grade: opts.grade });
|
|
254
265
|
if (!category) return [];
|
|
255
|
-
|
|
266
|
+
// Grade 'quality' drops the T2 policies of every category but paste, read
|
|
267
|
+
// and translate, as the Claude Code hint does (gradeKeepsRule).
|
|
268
|
+
const grade = normalizeDelegationGrade(opts.grade) ?? delegationGrade();
|
|
269
|
+
return sharedCodexModelRules(opts).filter((r) => r.category === category.id && gradeKeepsRule(grade, r))
|
|
256
270
|
.sort((a, b) => SHARED_RULE_TIERS.indexOf(a.tier) - SHARED_RULE_TIERS.indexOf(b.tier));
|
|
257
271
|
}
|
|
258
272
|
|
|
@@ -338,7 +352,9 @@ export function codexRouteHint(payload, opts = {}) {
|
|
|
338
352
|
// user's real config by accident.
|
|
339
353
|
const cfg = opts.cfg ?? {};
|
|
340
354
|
const provider = payload?.model_provider || codexProviderName();
|
|
341
|
-
|
|
355
|
+
// The grade comes from that same config, so the gate and the config the hook
|
|
356
|
+
// loaded cannot disagree; a caller may still pass `grade` itself.
|
|
357
|
+
const routes = matchingRoutes(payload?.prompt, { cfg, provider, grade: delegationGrade(cfg), ...opts, model: payload?.model,
|
|
342
358
|
root: opts.root || payload?.cwd, start: payload?.cwd });
|
|
343
359
|
const rule = routes[0];
|
|
344
360
|
if (!rule) return null;
|
|
@@ -414,7 +430,7 @@ export function codexDelegationTool(payload, { cfg = {}, root = payload?.cwd ||
|
|
|
414
430
|
let rules = given;
|
|
415
431
|
if (!rules) { try { rules = loadCodexModelRules({ dir }); } catch { rules = []; } }
|
|
416
432
|
const provider = payload.model_provider || codexProviderName({ home });
|
|
417
|
-
const routes = explicit ? [] : matchingRoutes(input.message, { model: payload.model, provider, root, start: payload.cwd, rules, cfg, dir, home });
|
|
433
|
+
const routes = explicit ? [] : matchingRoutes(input.message, { model: payload.model, provider, root, start: payload.cwd, rules, cfg, dir, home, grade: delegationGrade(cfg) });
|
|
418
434
|
// Only the caller can choose a shared policy's tier. A shared match without a
|
|
419
435
|
// model goes back to the caller with the mapped choices instead of a guessed
|
|
420
436
|
// downgrade, or a default target that ignores the tier.
|
package/src/codex/route-scan.js
CHANGED
|
@@ -12,6 +12,7 @@ import { codexPromptCategory, loadCodexModelRules, sharedCodexModelRules, codexS
|
|
|
12
12
|
import { codexRunCost, codexPriceBook, isDirectOpenAI, readCodexPrices } from './cache-policy.js';
|
|
13
13
|
import { OPENAI_PRICES_CHECKED_AT } from '../openai-prices.js';
|
|
14
14
|
import { refreshCodexLedger } from './ledger.js';
|
|
15
|
+
import { safeExcerpt } from '../redact.js';
|
|
15
16
|
|
|
16
17
|
/*
|
|
17
18
|
* Codex route-scan: recurring easy turns become delegation-rule candidates.
|
|
@@ -172,7 +173,7 @@ export async function runCodexRouteScan({ days = 14, now = Date.now(), home, dir
|
|
|
172
173
|
.sort((a, b) => b.count - a.count || b.lastSeen - a.lastSeen)
|
|
173
174
|
.slice(0, MAX_CANDIDATES)
|
|
174
175
|
.map((g, i) => ({ id: i + 1, signature: g.signature, category: g.category, label: g.label, labelEn: g.labelEn,
|
|
175
|
-
from: g.from, provider: g.provider, projectRoot: g.projectRoot, count: g.count, tiers: g.tiers, example: g.example
|
|
176
|
+
from: g.from, provider: g.provider, projectRoot: g.projectRoot, count: g.count, tiers: g.tiers, example: safeExcerpt(g.example, 160), // masked before the cut, so no half-token survives
|
|
176
177
|
lastSeen: g.lastSeen || null, suggestedScope: 'project', ...pickTarget(g, { prices, known, home }) }));
|
|
177
178
|
const priceCheckedAt = prices?.checkedAt ?? ([...groups.values()].some((g) => isDirectOpenAI(g.provider, { home })) ? OPENAI_PRICES_CHECKED_AT : null);
|
|
178
179
|
const data = { version: 1, scannedAt: new Date(now).toISOString(), days, dataBytes, totalEpisodes: episodes.length,
|
package/src/commands/brief.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { readStdinJson } from '../stdin-payload.js';
|
|
19
19
|
import { debug } from '../debug.js';
|
|
20
|
-
import { routingEnabled } from '../routing-switch.js';
|
|
20
|
+
import { routingEnabled, delegationGrade, isRelaxed } from '../routing-switch.js';
|
|
21
21
|
|
|
22
22
|
export async function run({ hasFlag }) {
|
|
23
23
|
if (hasFlag('--hook-tool')) {
|
|
@@ -67,7 +67,7 @@ export async function run({ hasFlag }) {
|
|
|
67
67
|
} catch (e) { debug('brief:routing-off', e); }
|
|
68
68
|
}
|
|
69
69
|
if (routingOn) try {
|
|
70
|
-
const { routeHint, routeMatch, matchCaps, sessionModelRank, hintTarget, hintLabel } = await import('../route-inject.js');
|
|
70
|
+
const { routeHint, routeMatch, matchCaps, sessionModelRank, hintTarget, hintLabel, escalationNotice } = await import('../route-inject.js');
|
|
71
71
|
// The payload names the session but not its model, so the rank comes from
|
|
72
72
|
// the transcript: without it a Sonnet session is told to delegate to
|
|
73
73
|
// Sonnet, which saves nothing.
|
|
@@ -79,7 +79,8 @@ export async function run({ hasFlag }) {
|
|
|
79
79
|
// differ. Claude Code sends `cwd` for that reason and the PreToolUse hook
|
|
80
80
|
// already reads it (src/delegation-guard.js). A payload without the field
|
|
81
81
|
// leaves root undefined, which is the behaviour this had before.
|
|
82
|
-
const
|
|
82
|
+
const grade = delegationGrade();
|
|
83
|
+
const match = routeMatch(ctx.prompt, { sessionRank, root: ctx.cwd, grade });
|
|
83
84
|
// How near the usage limit is, from the statusline snapshot. Read only when
|
|
84
85
|
// a hint will be written, and only the file: no network in a prompt hook.
|
|
85
86
|
let pressure = null;
|
|
@@ -88,10 +89,51 @@ export async function run({ hasFlag }) {
|
|
|
88
89
|
const { capPressure } = await import('../caps-cache.js');
|
|
89
90
|
const { getSessionModel } = await import('../parser.js');
|
|
90
91
|
pressure = capPressure({ sessionModel: getSessionModel(ctx.transcript_path) });
|
|
92
|
+
// High usage while delegation is not widened: the hint offers
|
|
93
|
+
// `sprag routing relax` once per limit window instead of the plain
|
|
94
|
+
// pressure line. Relaxed, or already offered for this window, the
|
|
95
|
+
// plain line stays.
|
|
96
|
+
if (pressure && (pressure.level === 'high' || pressure.level === 'critical') && (match.t2 || match.t1 || match.t1h) && !isRelaxed()) {
|
|
97
|
+
const { claimRelaxOffer } = await import('../relax-offer.js');
|
|
98
|
+
if (claimRelaxOffer(pressure.resetsAt)) pressure = { ...pressure, offer: true };
|
|
99
|
+
}
|
|
91
100
|
} catch (e) { debug('brief:cap-pressure', e); }
|
|
92
101
|
}
|
|
93
102
|
const hint = routeHint(ctx.prompt, { sessionRank, root: ctx.cwd, match, pressure });
|
|
94
103
|
if (hint) parts.push(hint);
|
|
104
|
+
// A request that ends in a judgement gets no delegation hint (routeMatch is
|
|
105
|
+
// null for it). In a session below Opus it gets the recommendation to move
|
|
106
|
+
// up instead; the grade decides which requests count (escalationNotice).
|
|
107
|
+
// Once per session: the second judgement request of a session gets no
|
|
108
|
+
// line, since the first one already said it (claimEscalationNotice).
|
|
109
|
+
let escalationSaid = false;
|
|
110
|
+
if (!match) {
|
|
111
|
+
try {
|
|
112
|
+
const notice = escalationNotice(ctx.prompt, { sessionRank, grade });
|
|
113
|
+
if (notice) {
|
|
114
|
+
const { claimEscalationNotice } = await import('../route-follow.js');
|
|
115
|
+
if (claimEscalationNotice(ctx.session_id)) { parts.push(notice); escalationSaid = true; }
|
|
116
|
+
}
|
|
117
|
+
} catch (e) { debug('brief:escalation-notice', e); }
|
|
118
|
+
}
|
|
119
|
+
// A main session at effort low or medium gets the effort line for the same
|
|
120
|
+
// kind of request. The model line goes first: when the Sonnet session was
|
|
121
|
+
// just told to move up to Opus, this turn carries that line alone (the
|
|
122
|
+
// effort claim stays free for a later turn).
|
|
123
|
+
if (!match && !escalationSaid) {
|
|
124
|
+
try {
|
|
125
|
+
const { effortHintEnabled } = await import('../routing-switch.js');
|
|
126
|
+
if (effortHintEnabled()) {
|
|
127
|
+
const { effortNotice } = await import('../route-inject.js');
|
|
128
|
+
const { readSessionEffort } = await import('../session-effort.js');
|
|
129
|
+
const notice = effortNotice(ctx.prompt, { sessionEffort: readSessionEffort(ctx.session_id), grade });
|
|
130
|
+
if (notice) {
|
|
131
|
+
const { claimEffortNotice } = await import('../route-follow.js');
|
|
132
|
+
if (claimEffortNotice(ctx.session_id)) parts.push(notice);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} catch (e) { debug('brief:effort-notice', e); }
|
|
136
|
+
}
|
|
95
137
|
// Remember that this turn carried a delegation hint, so the PostToolUse
|
|
96
138
|
// hook can nudge when the model looks things up itself instead. The
|
|
97
139
|
// unreachable-only notice tells the model NOT to delegate, so it starts
|
package/src/commands/doc2md.js
CHANGED
|
@@ -55,6 +55,13 @@ export async function run({ args, hasFlag }) {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
if (out) console.log(out);
|
|
58
|
+
// After the answer is out: a converted copy keeps the document's whole text,
|
|
59
|
+
// so copies untouched for 30 days are removed, at most once a day.
|
|
60
|
+
try {
|
|
61
|
+
const { runHousekeeping } = await import('../state-file.js');
|
|
62
|
+
const { userDataDir } = await import('../paths.js');
|
|
63
|
+
runHousekeeping(userDataDir(), { 'doc2md-cache': () => doc2md.pruneCache() });
|
|
64
|
+
} catch { /* clean-up is best effort and never touches the Read */ }
|
|
58
65
|
return;
|
|
59
66
|
}
|
|
60
67
|
|
|
@@ -390,6 +390,19 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
390
390
|
if (doc2mdHookRegistered()) doc2mdBlock = require('../doc2md.cjs').sessionNote(lang);
|
|
391
391
|
} catch (e) { debug('route-scan:doc2md-note', e); /* the note is optional */ }
|
|
392
392
|
|
|
393
|
+
// Secrets that "don't ask again" saved in an approval list. One line per
|
|
394
|
+
// settings file, once per modification time (see permission-secrets.js);
|
|
395
|
+
// `sprag secrets off` switches it off.
|
|
396
|
+
let secretsBlock = null;
|
|
397
|
+
try {
|
|
398
|
+
const { loadConfig } = await import('../config.js');
|
|
399
|
+
if (loadConfig().secretScan !== false) {
|
|
400
|
+
const { secretsNotice } = await import('../permission-secrets.js');
|
|
401
|
+
const { findProjectRoot } = await import('../harness.js');
|
|
402
|
+
secretsBlock = secretsNotice({ root: findProjectRoot(hookCtx.cwd || process.cwd()), lang });
|
|
403
|
+
}
|
|
404
|
+
} catch (e) { debug('route-scan:secrets-notice', e); /* the notice is optional */ }
|
|
405
|
+
|
|
393
406
|
// Starter rules that the user has not answered yet (bundled presets, both
|
|
394
407
|
// model-fitting and ratchet). A fresh install has an empty model ratchet
|
|
395
408
|
// and an empty ratchet.md, so without this the tool delegates nothing
|
|
@@ -430,6 +443,7 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
430
443
|
} catch (e) { debug('route-scan:monthly-reset', e); /* the offer is optional */ }
|
|
431
444
|
|
|
432
445
|
if (open.length === 0 && reviewRules.length === 0) {
|
|
446
|
+
if (secretsBlock) console.log(secretsBlock);
|
|
433
447
|
if (teamBlock) console.log(teamBlock);
|
|
434
448
|
if (updateBlock) console.log(updateBlock);
|
|
435
449
|
if (monthlyResetBlock) console.log(monthlyResetBlock);
|
|
@@ -440,6 +454,7 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
440
454
|
if (cohesionBlock) console.log(cohesionBlock);
|
|
441
455
|
return; // nothing else to inject
|
|
442
456
|
}
|
|
457
|
+
if (secretsBlock) console.log(secretsBlock);
|
|
443
458
|
if (teamBlock) console.log(teamBlock);
|
|
444
459
|
if (updateBlock) console.log(updateBlock);
|
|
445
460
|
if (monthlyResetBlock) console.log(monthlyResetBlock);
|
package/src/commands/routing.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* sprag routing # status
|
|
5
5
|
* sprag routing on|off # turn every delegation path on or off
|
|
6
|
+
* sprag routing relax [off] # widen delegation until the busiest usage window resets, or end that early
|
|
7
|
+
* sprag routing effort-hint on|off # the effort line for low/medium sessions on judgement requests
|
|
6
8
|
*
|
|
7
9
|
* Off removes the delegation rules from ratchet-model.md and the preset
|
|
8
10
|
* ratchet, the per-prompt route hint, and the route-scan candidate and
|
|
@@ -13,7 +15,21 @@ export async function run({ args }) {
|
|
|
13
15
|
const sub = args[1];
|
|
14
16
|
const { userLanguage } = await import('../config.js');
|
|
15
17
|
const ko = userLanguage() === 'ko';
|
|
16
|
-
const { routingEnabled, setRoutingEnabled } = await import('../routing-switch.js');
|
|
18
|
+
const { routingEnabled, setRoutingEnabled, isRelaxed, relaxUntil, setRelaxUntil, relaxClock, effortHintEnabled, setEffortHint } = await import('../routing-switch.js');
|
|
19
|
+
|
|
20
|
+
// The reset of the busiest usage window in the statusline snapshot, in epoch
|
|
21
|
+
// ms; five hours from now when the snapshot is missing, stale or has no reset.
|
|
22
|
+
const relaxDeadline = async () => {
|
|
23
|
+
const fallback = Date.now() + 5 * 60 * 60 * 1000;
|
|
24
|
+
try {
|
|
25
|
+
const { capPressure } = await import('../caps-cache.js');
|
|
26
|
+
const p = capPressure();
|
|
27
|
+
const ms = p && p.resetsAt ? p.resetsAt * 1000 : null;
|
|
28
|
+
return ms !== null && ms > Date.now() ? ms : fallback;
|
|
29
|
+
} catch {
|
|
30
|
+
return fallback;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
17
33
|
|
|
18
34
|
const rules = async () => (await import('../model-rules.js')).loadModelRules().rules.length;
|
|
19
35
|
// Re-render the files that carry delegation text so the change shows without
|
|
@@ -53,12 +69,51 @@ export async function run({ args }) {
|
|
|
53
69
|
return;
|
|
54
70
|
}
|
|
55
71
|
|
|
72
|
+
if (sub === 'relax') {
|
|
73
|
+
const want = args[2];
|
|
74
|
+
if (want !== undefined && want !== 'off') {
|
|
75
|
+
console.error('Usage: sprag routing relax [off]');
|
|
76
|
+
process.exitCode = 2;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (want === 'off') {
|
|
80
|
+
setRelaxUntil(null);
|
|
81
|
+
await resync();
|
|
82
|
+
console.log(ko ? '✓ 위임 범위를 원래대로 돌렸습니다.' : '✓ Delegation is back to its usual range.');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const until = await relaxDeadline();
|
|
86
|
+
setRelaxUntil(until);
|
|
87
|
+
await resync();
|
|
88
|
+
const clock = relaxClock(until);
|
|
89
|
+
console.log(ko
|
|
90
|
+
? `이번 한도 창이 끝나는 ${clock}까지 위임을 넓힙니다. 그 뒤에는 자동으로 돌아옵니다.`
|
|
91
|
+
: `Delegation is widened until ${clock}, when this limit window ends. It switches back by itself after that.`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (sub === 'effort-hint') {
|
|
96
|
+
const want = args[2];
|
|
97
|
+
if (want !== 'on' && want !== 'off') {
|
|
98
|
+
console.error('Usage: sprag routing effort-hint on|off');
|
|
99
|
+
process.exitCode = 2;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setEffortHint(want === 'on');
|
|
103
|
+
console.log(want === 'on'
|
|
104
|
+
? (ko ? '✓ effort 안내를 켰습니다. 판단형 요청에서 세션 effort가 low나 medium이면 한 번 안내합니다.' : '✓ Effort hint is on. A low or medium effort session is told once on a judgement request.')
|
|
105
|
+
: (ko ? '✓ effort 안내를 껐습니다.' : '✓ Effort hint is off.'));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
56
109
|
if (sub === undefined || sub === 'status') {
|
|
57
110
|
const on = routingEnabled();
|
|
58
111
|
const n = await rules().catch(() => 0);
|
|
59
112
|
let agentsOn = true;
|
|
60
113
|
try { agentsOn = (await import('../delegation-agents.js')).delegationAgentStatus().enabled; } catch { /* default on */ }
|
|
61
114
|
console.log(`routing: ${on ? 'on' : 'off'}`);
|
|
115
|
+
console.log(isRelaxed() ? `relax: until ${relaxClock(relaxUntil())}` : 'relax: off');
|
|
116
|
+
console.log(`effort hint: ${effortHintEnabled() ? 'on' : 'off'}`);
|
|
62
117
|
console.log(ko ? `등록된 룰: ${n}건` : `registered rules: ${n}`);
|
|
63
118
|
console.log(`delegate agents: ${agentsOn ? 'on' : 'off'}`);
|
|
64
119
|
console.log(ko
|
|
@@ -67,6 +122,6 @@ export async function run({ args }) {
|
|
|
67
122
|
return;
|
|
68
123
|
}
|
|
69
124
|
|
|
70
|
-
console.log('Usage: sprag routing on|off|status');
|
|
125
|
+
console.log('Usage: sprag routing on|off|status|relax [off]|effort-hint on|off');
|
|
71
126
|
process.exitCode = 1;
|
|
72
127
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subcommand: secrets — secrets that "don't ask again" left in approval lists.
|
|
3
|
+
*
|
|
4
|
+
* sprag secrets list the settings entries that look like secrets (values are never printed)
|
|
5
|
+
* sprag secrets fix [--yes] delete the flagged allow/ask entries after saving the original
|
|
6
|
+
* sprag secrets off | on stop (or resume) the session start notice
|
|
7
|
+
*
|
|
8
|
+
* See src/permission-secrets.js for what is read and why an entry is deleted
|
|
9
|
+
* rather than repaired.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export async function run({ args, hasFlag }) {
|
|
13
|
+
const { userLanguage, loadConfig, saveConfig } = await import('../config.js');
|
|
14
|
+
const ko = userLanguage() === 'ko';
|
|
15
|
+
const ps = await import('../permission-secrets.js');
|
|
16
|
+
const { homedir } = await import('node:os');
|
|
17
|
+
const { findProjectRoot } = await import('../harness.js');
|
|
18
|
+
const sub = args[1];
|
|
19
|
+
const home = homedir();
|
|
20
|
+
const t = (koText, enText) => (ko ? koText : enText);
|
|
21
|
+
const shown = (p) => (p.startsWith(home) ? `~${p.slice(home.length)}` : p);
|
|
22
|
+
|
|
23
|
+
if (sub === 'off' || sub === 'on') {
|
|
24
|
+
const cfg = loadConfig();
|
|
25
|
+
if (sub === 'off') cfg.secretScan = false;
|
|
26
|
+
else delete cfg.secretScan;
|
|
27
|
+
saveConfig(cfg);
|
|
28
|
+
console.log(sub === 'off'
|
|
29
|
+
? t('세션 시작 때 승인 목록의 비밀 값을 알리지 않습니다. 다시 켜기: sprag secrets on', 'The session start notice about secrets in approval lists is off. Turn it back on with: sprag secrets on')
|
|
30
|
+
: t('세션 시작 때 승인 목록의 비밀 값을 알립니다.', 'The session start notice about secrets in approval lists is on.'));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (sub !== undefined && sub !== 'fix') {
|
|
34
|
+
console.error(t('사용법: sprag secrets, sprag secrets fix [--yes], sprag secrets off, sprag secrets on', 'Usage: sprag secrets, sprag secrets fix [--yes], sprag secrets off, sprag secrets on'));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const root = findProjectRoot(process.cwd());
|
|
39
|
+
const found = ps.scanPermissionSecrets({ home, root }).filter((f) => f.entries.length);
|
|
40
|
+
|
|
41
|
+
if (sub === 'fix') {
|
|
42
|
+
if (!found.length) {
|
|
43
|
+
console.log(t('승인 목록에서 비밀 값으로 보이는 항목을 찾지 못했습니다.', 'No approval list entry looks like a secret.'));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const removable = found.map((f) => ({ ...f, n: f.entries.filter((e) => e.list !== 'deny').length })).filter((f) => f.n > 0);
|
|
47
|
+
if (!removable.length) {
|
|
48
|
+
console.log(t('걸린 항목이 모두 deny 목록에 있어 지우지 않았습니다. deny 는 차단 규칙입니다.', 'Every flagged entry is in a deny list, so nothing was removed. deny entries block commands.'));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
printFindings(removable, { t, shown, ko });
|
|
52
|
+
if (!hasFlag('--yes')) {
|
|
53
|
+
const { canPrompt, confirm } = await import('../prompt.js');
|
|
54
|
+
if (!canPrompt()) {
|
|
55
|
+
console.log(t('대화형 터미널이 아니어서 아무것도 지우지 않았습니다. 지우려면 sprag secrets fix --yes 를 실행하십시오.',
|
|
56
|
+
'This is not an interactive terminal, so nothing was removed. Run sprag secrets fix --yes to remove them.'));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const ok = await confirm(t(`위 allow/ask 항목 ${removable.reduce((a, f) => a + f.n, 0)}개를 지울까요? 원본은 먼저 백업합니다.`,
|
|
60
|
+
`Remove these ${removable.reduce((a, f) => a + f.n, 0)} allow/ask entries? The original is backed up first.`), { defaultValue: false });
|
|
61
|
+
if (!ok) { console.log(t('취소했습니다.', 'Cancelled.')); return; }
|
|
62
|
+
}
|
|
63
|
+
const now = new Date();
|
|
64
|
+
let total = 0;
|
|
65
|
+
for (const f of removable) {
|
|
66
|
+
const r = ps.fixSettingsFile(f.path, { now });
|
|
67
|
+
if (r.error) {
|
|
68
|
+
console.error(t(`${shown(f.path)}: 쓰지 못했습니다 (${r.error}). 원본 백업: ${shown(r.backup)}`, `${shown(f.path)}: could not write (${r.error}). Backup: ${shown(r.backup)}`));
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
total += r.removed;
|
|
73
|
+
console.log(t(`${shown(f.path)}: ${r.removed}개 지웠습니다. 원본 백업: ${shown(r.backup)} (소유자만 읽을 수 있음)`,
|
|
74
|
+
`${shown(f.path)}: removed ${r.removed}. Original saved to ${shown(r.backup)} (owner-only).`));
|
|
75
|
+
}
|
|
76
|
+
console.log(t(`총 ${total}개를 지웠습니다. 이미 노출됐을 수 있는 값은 발급처에서 회전하십시오.`,
|
|
77
|
+
`Removed ${total} in total. Rotate any value that may already have been exposed, at the service that issued it.`));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!found.length) {
|
|
82
|
+
console.log(t('승인 목록에서 비밀 값으로 보이는 항목을 찾지 못했습니다.', 'No approval list entry looks like a secret.'));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
printFindings(found, { t, shown, ko });
|
|
86
|
+
console.log(t('지우려면: sprag secrets fix. 이미 노출됐을 수 있는 값은 발급처에서 회전하십시오.',
|
|
87
|
+
'To remove them: sprag secrets fix. Rotate any value that may already have been exposed, at the service that issued it.'));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function printFindings(files, { t, shown }) {
|
|
91
|
+
for (const f of files) {
|
|
92
|
+
console.log(t(`${shown(f.path)}: 비밀 값으로 보이는 항목 ${f.entries.length}개`, `${shown(f.path)}: ${f.entries.length} entries look like secrets`));
|
|
93
|
+
for (const e of f.entries) {
|
|
94
|
+
console.log(` ${e.list} #${e.index} [${e.kinds.join(', ')}] ${e.preview}`);
|
|
95
|
+
}
|
|
96
|
+
if (f.git?.tracked) {
|
|
97
|
+
console.log(t(
|
|
98
|
+
' 경고: 이 파일은 git이 추적하고 있습니다. 이미 커밋됐다면 값이 기록에 남아 있으니 파일을 고쳐도 소용없고, 발급처에서 값을 회전해야 합니다.',
|
|
99
|
+
' Warning: git tracks this file. If it was ever committed, the value is in history, so editing the file is not enough: rotate it at the service that issued it.',
|
|
100
|
+
));
|
|
101
|
+
} else if (f.git && f.git.ignored === false) {
|
|
102
|
+
console.log(t(' 이 파일은 git이 추적하지는 않지만 무시 목록에도 없어 다음 커밋에 들어갈 수 있습니다.', ' git does not track this file yet, but it is not ignored either, so the next commit can pick it up.'));
|
|
103
|
+
} else if (f.git?.ignored) {
|
|
104
|
+
console.log(t(' 이 파일은 git 무시 목록에 있습니다.', ' git ignores this file.'));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|