sprag-cli 3.101.0 → 3.101.1
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/package.json +1 -1
- package/src/codex/delegation.js +3 -1
- package/src/route-inject.js +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.101.
|
|
3
|
+
"version": "3.101.1",
|
|
4
4
|
"description": "Model-delegation router for Claude Code and Codex: lookups, checks and test runs go to cheaper models, documents go in as compact Markdown, and a live statusline shows spend and savings.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/codex/delegation.js
CHANGED
|
@@ -6,7 +6,7 @@ import { userDataDir } from '../paths.js';
|
|
|
6
6
|
import { writeViaTmp } from '../state-file.js';
|
|
7
7
|
import { codexUserDir, codexProviderName } from '../agent.js';
|
|
8
8
|
import { categorize, ESCALATE_RE, EDIT_RE } from '../route-scan.js';
|
|
9
|
-
import { looksPasted, isSystemPrompt, isOpinionQuestion } from '../route-inject.js';
|
|
9
|
+
import { looksPasted, isSystemPrompt, isOpinionQuestion, looksLikeContextOrSpec } from '../route-inject.js';
|
|
10
10
|
import { newRouteId, recordCodexDelegation } from './ledger.js';
|
|
11
11
|
import { readCodexTailLines } from './parser.js';
|
|
12
12
|
import { loadConfig } from '../config.js';
|
|
@@ -229,6 +229,8 @@ export function codexPromptCategory(text) {
|
|
|
229
229
|
// Same two gates as the Claude Code hint (routeMatch): a harness message is
|
|
230
230
|
// not a request, and an opinion question is judgement rather than a lookup.
|
|
231
231
|
if (isSystemPrompt(prompt) || isOpinionQuestion(prompt)) return null;
|
|
232
|
+
// The #16 gates: a reply, feedback, an outward action, an edit or a long spec.
|
|
233
|
+
if (looksLikeContextOrSpec(prompt)) return null;
|
|
232
234
|
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;
|
|
233
235
|
const category = categorize(prompt, null);
|
|
234
236
|
if (!category || (category.id === 'paste' && !looksPasted(prompt))) return null;
|
package/src/route-inject.js
CHANGED
|
@@ -86,6 +86,43 @@ export function isOpinionQuestion(text) {
|
|
|
86
86
|
/** Shortest text worth classifying; below this a prompt is an ack, not a task. */
|
|
87
87
|
const MIN_LEN = 8;
|
|
88
88
|
|
|
89
|
+
// Gates added after the #16 calibration experiment (600 labelled prompts, of
|
|
90
|
+
// which the rule hint had marked 47 test prompts for T2 and 43 of them needed
|
|
91
|
+
// the main model). Each targets a shape of those misfires; tuned on the
|
|
92
|
+
// calibration split only.
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A reply to the previous turn rather than a new task: an ack or a pointer
|
|
96
|
+
* ("응 블렌더로…", "그래 네가 돌려봐", "아니면 …", "아,, 뭐야 이게", "A로 더
|
|
97
|
+
* 다듬어서"). What it continues lives in the conversation, which the hook does
|
|
98
|
+
* not see, so a keyword in it says nothing about the work.
|
|
99
|
+
*/
|
|
100
|
+
const CONTINUATION_RE = /^(?:응|네|넵|그래|그럼|그러면|아니|아+\s*[,.~]|오케이|ok(?=[\s,.!]|$)|좋아|좋네|이건|이거|그건|그거|저건|저거|[A-Za-z]\s*로\s)/i;
|
|
101
|
+
/** Feedback on what the model just made ("…가 아니야", "…게 아니라 …"). */
|
|
102
|
+
const FEEDBACK_RE = /(?:가|이|게)\s*아니(?:야|라|고|에요|잖)/;
|
|
103
|
+
/** The user says they will check, or that checking is needed: a statement, not a request. */
|
|
104
|
+
const SELF_CHECK_RE = /확인(?:할게|해\s*볼게|하겠|해볼께|할께)|확인이?\s*필요/;
|
|
105
|
+
/**
|
|
106
|
+
* Outward actions that ESCALATE_RE does not list: uploading, posting, sending,
|
|
107
|
+
* deleting, paying. A plain `git push` stays with the run category, as before.
|
|
108
|
+
*/
|
|
109
|
+
const OUTWARD_RE = /업로드|게시해|게시하|발송|올려\s*(?:줘|주|줄)|보내\s*(?:줘|주|줄)|삭제|지워\s*(?:줘|주)|결제/;
|
|
110
|
+
/** Edit asks EDIT_RE misses: change, remove, set up, add, polish, generate. */
|
|
111
|
+
const EDIT_MORE_RE = /변경해|변경하|바꾸고|없애|빼\s*(?:줘|주|고|자)|[셋세]팅하자|설정하자|구성해|구성하|추가해|다듬|넣고|처리해\s*(?:줘|주)|만들어\s*(?:줘|주|봐)|생성해|적용해|적용하자/;
|
|
112
|
+
/**
|
|
113
|
+
* Above this length a request that is not a paste is a written spec: several
|
|
114
|
+
* asks and conditions in one turn. None of the long prompts the hint marked in
|
|
115
|
+
* the calibration split were a lookup or a command.
|
|
116
|
+
*/
|
|
117
|
+
const SPEC_LEN = 100;
|
|
118
|
+
|
|
119
|
+
/** True when one of the #16 gates says the request is not the light work its keywords suggest. */
|
|
120
|
+
export function looksLikeContextOrSpec(text) {
|
|
121
|
+
const t = String(text || '').trim();
|
|
122
|
+
return CONTINUATION_RE.test(t) || FEEDBACK_RE.test(t) || SELF_CHECK_RE.test(t)
|
|
123
|
+
|| OUTWARD_RE.test(t) || EDIT_MORE_RE.test(t) || (t.length > SPEC_LEN && !looksPasted(t));
|
|
124
|
+
}
|
|
125
|
+
|
|
89
126
|
/**
|
|
90
127
|
* A question that asks for an explanation ("어떻게 쓰이는거지?", "뭐야", "how
|
|
91
128
|
* does it work"). "왜" is not here: ESCALATE_RE already routes it to the top
|
|
@@ -199,6 +236,8 @@ export function routeMatch(text, { rules, sessionRank = null, root, env = proces
|
|
|
199
236
|
// "…하는게 좋은가?" asks what the model thinks. The answer is judgement, and a
|
|
200
237
|
// hint to hand it to a cheaper model is wrong however light the keywords look.
|
|
201
238
|
if (isOpinionQuestion(t)) return null;
|
|
239
|
+
// A reply, feedback, an outward action, an edit or a long spec (#16).
|
|
240
|
+
if (looksLikeContextOrSpec(t)) return null;
|
|
202
241
|
|
|
203
242
|
const scored = categorizeScored(t, null);
|
|
204
243
|
if (!scored) return null;
|