@delt/claude-jev-advisor 0.2.0 → 0.4.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.md +53 -26
- package/dist/cli.js +313 -126
- package/dist/context-hook.js +30 -17
- package/dist/rm-hook.js +986 -110
- package/dist/statusline.js +28 -15
- package/mod/.claude-plugin/plugin.json +2 -2
- package/mod/hooks/register.js +138 -16
- package/package.json +4 -3
package/dist/context-hook.js
CHANGED
|
@@ -13,6 +13,7 @@ var DEFAULT_CONFIG = {
|
|
|
13
13
|
lang: "ko",
|
|
14
14
|
keyFile: null,
|
|
15
15
|
display: "mod",
|
|
16
|
+
shortcut: null,
|
|
16
17
|
context: { enabled: true, minTokens: 25e4, compactMinTokens: 25e4, redRemainingPct: 20, unitDoneYes: 0.6, phaseDoneYes: 0.6 },
|
|
17
18
|
rm: { enabled: true, jev: true, throwawayYes: 0.8, maxDirFiles: 50 }
|
|
18
19
|
};
|
|
@@ -40,6 +41,7 @@ function normalizeConfig(raw) {
|
|
|
40
41
|
lang: typeof r.lang === "string" && LANGS.includes(r.lang) ? r.lang : DEFAULT_CONFIG.lang,
|
|
41
42
|
keyFile: typeof r.keyFile === "string" && r.keyFile !== "" ? r.keyFile : null,
|
|
42
43
|
display: typeof r.display === "string" && DISPLAYS.includes(r.display) ? r.display : DEFAULT_CONFIG.display,
|
|
44
|
+
shortcut: typeof r.shortcut === "string" && r.shortcut !== "" ? r.shortcut : null,
|
|
43
45
|
context: mergeSection(DEFAULT_CONFIG.context, r.version === CONFIG_VERSION ? r.context : withoutLegacyDefaults(r.context)),
|
|
44
46
|
rm: mergeSection(DEFAULT_CONFIG.rm, r.rm)
|
|
45
47
|
};
|
|
@@ -63,18 +65,20 @@ function readConfig(home) {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
// src/display/line.ts
|
|
66
|
-
var
|
|
68
|
+
var QUESTIONS = {
|
|
67
69
|
ko: {
|
|
68
|
-
clear: "\uC0C8\uB86D\uAC8C \uC2DC\uC791\uD558\uB294 \uAC74 \uC5B4\uB5A0\uC138\uC694?
|
|
69
|
-
compact: "\uC9C0\uAE08\uAE4C\uC9C0 \uC815\uB9AC\uD558\uACE0 \uC774\uC5B4\uAC00\uB294 \uAC74 \uC5B4\uB5A0\uC138\uC694?
|
|
70
|
-
compactLater: "\uC791\uC5C5\uC774 \uB05D\uB098\uBA74 \uC815\uB9AC\uD558\uACE0 \uC774\uC5B4\uAC00\uB294 \uAC74 \uC5B4\uB5A0\uC138\uC694?
|
|
70
|
+
clear: "\uC0C8\uB86D\uAC8C \uC2DC\uC791\uD558\uB294 \uAC74 \uC5B4\uB5A0\uC138\uC694?",
|
|
71
|
+
compact: "\uC9C0\uAE08\uAE4C\uC9C0 \uC815\uB9AC\uD558\uACE0 \uC774\uC5B4\uAC00\uB294 \uAC74 \uC5B4\uB5A0\uC138\uC694?",
|
|
72
|
+
compactLater: "\uC791\uC5C5\uC774 \uB05D\uB098\uBA74 \uC815\uB9AC\uD558\uACE0 \uC774\uC5B4\uAC00\uB294 \uAC74 \uC5B4\uB5A0\uC138\uC694?"
|
|
71
73
|
},
|
|
72
74
|
en: {
|
|
73
|
-
clear: "Start fresh?
|
|
74
|
-
compact: "Wrap up what you have and continue?
|
|
75
|
-
compactLater: "When this work is done, wrap up and continue?
|
|
75
|
+
clear: "Start fresh?",
|
|
76
|
+
compact: "Wrap up what you have and continue?",
|
|
77
|
+
compactLater: "When this work is done, wrap up and continue?"
|
|
76
78
|
}
|
|
77
79
|
};
|
|
80
|
+
var COMMANDS = { clear: "/clear", compact: "/compact", compactLater: "/compact" };
|
|
81
|
+
var phrase = (lang, advice) => `${QUESTIONS[lang][advice]} ${COMMANDS[advice]}`;
|
|
78
82
|
function formatSize(tokens) {
|
|
79
83
|
return `${Math.round(tokens / 1e3)}k`;
|
|
80
84
|
}
|
|
@@ -86,20 +90,29 @@ function adviceKind(size, judgment, config) {
|
|
|
86
90
|
if (judgment.clear) return "clear";
|
|
87
91
|
return size >= config.context.compactMinTokens ? "compact" : null;
|
|
88
92
|
}
|
|
89
|
-
function
|
|
93
|
+
function increaseSuffix(increase) {
|
|
94
|
+
if (increase === null || increase === void 0) return "";
|
|
95
|
+
const k = Math.round(increase / 1e3);
|
|
96
|
+
return k > 0 ? ` +${k}k` : "";
|
|
97
|
+
}
|
|
98
|
+
function redRemaining(size, threshold, config) {
|
|
99
|
+
if (threshold === null || threshold <= 0 || size < threshold * (1 - config.context.redRemainingPct / 100)) return null;
|
|
100
|
+
return remainingPct(size, threshold);
|
|
101
|
+
}
|
|
102
|
+
function adviceLine({ size, threshold, judgment, config, increase }) {
|
|
90
103
|
if (size === null) return "";
|
|
91
|
-
const k = formatSize(size)
|
|
92
|
-
const phrases = PHRASES[config.lang];
|
|
104
|
+
const k = `${formatSize(size)}${increaseSuffix(increase)}`;
|
|
93
105
|
const counted = size >= config.context.minTokens ? judgment : null;
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
const red = redRemaining(size, threshold, config);
|
|
107
|
+
if (red !== null) {
|
|
108
|
+
const head = `\u{1F534} ${k} ${red}%`;
|
|
96
109
|
if (!counted) return head;
|
|
97
|
-
if (counted.phase === "working") return `${head} \xB7 ${
|
|
98
|
-
return `${head} \xB7 ${counted.clear ?
|
|
110
|
+
if (counted.phase === "working") return `${head} \xB7 ${phrase(config.lang, "compactLater")}`;
|
|
111
|
+
return `${head} \xB7 ${phrase(config.lang, counted.clear ? "clear" : "compact")}`;
|
|
99
112
|
}
|
|
100
113
|
if (!counted) return k;
|
|
101
114
|
const kind = adviceKind(size, counted, config);
|
|
102
|
-
return kind ? `\u{1F7E1} ${k} ${
|
|
115
|
+
return kind ? `\u{1F7E1} ${k} ${phrase(config.lang, kind)}` : `\u{1F7E2} ${k}`;
|
|
103
116
|
}
|
|
104
117
|
|
|
105
118
|
// src/jev.ts
|
|
@@ -225,7 +238,7 @@ function appendLog(home, now, record, secrets = []) {
|
|
|
225
238
|
|
|
226
239
|
// src/context/judge.ts
|
|
227
240
|
var REPLY_EDGE_CHARS = 1500;
|
|
228
|
-
var
|
|
241
|
+
var QUESTIONS2 = {
|
|
229
242
|
unit_done: {
|
|
230
243
|
type: "noul",
|
|
231
244
|
instructions: "Has Claude finished or handed back the work the user asked for in `recent_requests`, so that `last_assistant_reply` is a natural break before the user's next instruction?",
|
|
@@ -259,7 +272,7 @@ ${text.slice(-edge)}`;
|
|
|
259
272
|
function jevRequest(requests, lastReply) {
|
|
260
273
|
return {
|
|
261
274
|
state: { recent_requests: requests, last_assistant_reply: cutReply(lastReply) },
|
|
262
|
-
questions: { unit_done:
|
|
275
|
+
questions: { unit_done: QUESTIONS2.unit_done, phase_done: QUESTIONS2.phase_done }
|
|
263
276
|
};
|
|
264
277
|
}
|
|
265
278
|
function judgmentFrom(answers, config) {
|