flavor-code 1.4.2 → 1.4.3
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 -1
- package/README.zh-CN.md +53 -1
- package/dist/agent/loop.d.ts +1 -0
- package/dist/{app-4CUS3GEJ.js → app-TVY2HM5L.js} +891 -604
- package/dist/apply-WOW3QU5I.js +51 -0
- package/dist/broker-cli-X5H46FZV.js +15 -0
- package/dist/check-CSKTV4O2.js +16 -0
- package/dist/chunk-3563SW4X.js +10513 -0
- package/dist/chunk-36IDJRLQ.js +630 -0
- package/dist/chunk-3UX2CGDW.js +1955 -0
- package/dist/chunk-4TMLXZVZ.js +75 -0
- package/dist/{chunk-7YFHRORG.js → chunk-5BDKRA6U.js} +412 -172
- package/dist/chunk-6F66UXBI.js +48 -0
- package/dist/{chunk-KMBDK4SN.js → chunk-6URQ7FIF.js} +24 -88
- package/dist/chunk-7Y64WNBB.js +8930 -0
- package/dist/chunk-AA4QNKTF.js +501 -0
- package/dist/chunk-BDX777JR.js +11 -0
- package/dist/chunk-CVP5OUHD.js +103 -0
- package/dist/chunk-EWD7FWTH.js +14547 -0
- package/dist/{chunk-N5MXHJKD.js → chunk-GTFP2R5I.js} +1 -1
- package/dist/{chunk-W2TIY6JY.js → chunk-IKGT4MDT.js} +2028 -516
- package/dist/chunk-IQEEFDEE.js +389 -0
- package/dist/chunk-IU3UBETC.js +30 -0
- package/dist/chunk-JQM2L2YM.js +1003 -0
- package/dist/chunk-KRWWCVXA.js +74 -0
- package/dist/chunk-OKHV7CTB.js +482 -0
- package/dist/chunk-ONRY3C2L.js +196 -0
- package/dist/chunk-PULWAH6E.js +474 -0
- package/dist/chunk-PZ5NKRVA.js +85 -0
- package/dist/chunk-QACFKPZP.js +43704 -0
- package/dist/chunk-RBAZLFKB.js +1022 -0
- package/dist/chunk-RV3EXUXM.js +30 -0
- package/dist/chunk-TIEOVQW6.js +61 -0
- package/dist/chunk-WLZUAVVU.js +15 -0
- package/dist/chunk-X442CJJH.js +114 -0
- package/dist/chunk-X6U6BO5D.js +2130 -0
- package/dist/{chunk-RAYH6K2H.js → chunk-Y7EH4NVO.js} +1 -1
- package/dist/{chunk-S32JRDZK.js → chunk-ZKKVSR37.js} +6 -1
- package/dist/{claude-ink-VQU3C5UL.js → claude-ink-F554I3GJ.js} +9 -4
- package/dist/cli-MAWCV2YR.js +163 -0
- package/dist/cli-main.js +3805 -473
- package/dist/cli.js +50 -4
- package/dist/config/load.d.ts +8 -0
- package/dist/config/protected-file.d.ts +2 -0
- package/dist/config/schema.d.ts +14 -0
- package/dist/context/global-instructions.d.ts +12 -0
- package/dist/context/manager.d.ts +4 -0
- package/dist/desktop/main.js +4943 -1562
- package/dist/desktop/preload.cjs +30 -0
- package/dist/desktop-renderer/assets/index-BWklSoOO.css +1 -0
- package/dist/desktop-renderer/assets/index-CjC0Ibiq.js +153 -0
- package/dist/desktop-renderer/assets/{interactive-terminal-ouQQ3brz.js → interactive-terminal-IjIT3Xoa.js} +1 -1
- package/dist/desktop-renderer/index.html +2 -2
- package/dist/doctor-SEL32R7M.js +20 -0
- package/dist/harness/local.d.ts +1 -0
- package/dist/load-RHWXNUCS.js +25 -0
- package/dist/log-ATFIPRNU.js +19 -0
- package/dist/manager-IYBNNKUP.js +191 -0
- package/dist/models/anthropic.d.ts +3 -0
- package/dist/node-LOIXT44J.js +879 -0
- package/dist/plugin-worker-entry.js +1 -1
- package/dist/production-TQROFEPV.js +46 -0
- package/dist/production.d.ts +28 -1
- package/dist/project-3QXE22TG.js +11 -0
- package/dist/react-M6JGXSJZ.js +7 -0
- package/dist/recorder-FAGJJH3N.js +11 -0
- package/dist/sdk/index.js +30 -8
- package/dist/server-2KLKPHPL.js +11 -0
- package/dist/session/store.d.ts +1 -0
- package/dist/store-MZZERW7K.js +18 -0
- package/dist/ui/commands.d.ts +11 -3
- package/dist/ui/session.d.ts +2 -1
- package/dist/usage-summary-G5FBOJLK.js +13 -0
- package/dist/write-stream-CGD57URC.js +77 -0
- package/package.json +1 -1
- package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +649 -1
- package/dist/chunk-B23V72YR.js +0 -170
- package/dist/chunk-QKND3FX7.js +0 -26103
- package/dist/desktop-renderer/assets/index-Bk6FYhyh.css +0 -1
- package/dist/desktop-renderer/assets/index-CPXrzFgv.js +0 -154
- package/dist/load-UPOG3XQR.js +0 -19
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as createFlavorRequire } from "node:module"; const require = createFlavorRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/version.ts
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
var cached;
|
|
9
|
+
function packageVersion() {
|
|
10
|
+
if (cached !== void 0) return cached;
|
|
11
|
+
let directory = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
for (; ; ) {
|
|
13
|
+
try {
|
|
14
|
+
const manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
|
|
15
|
+
if (typeof manifest.version === "string" && manifest.version.length > 0) {
|
|
16
|
+
cached = manifest.version;
|
|
17
|
+
return cached;
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
const parent = dirname(directory);
|
|
22
|
+
if (parent === directory) break;
|
|
23
|
+
directory = parent;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("package.json with a version field was not found");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
packageVersion
|
|
30
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as createFlavorRequire } from "node:module"; const require = createFlavorRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/intl.ts
|
|
5
|
+
var graphemeSegmenter;
|
|
6
|
+
function getGraphemeSegmenter() {
|
|
7
|
+
return graphemeSegmenter ??= new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
8
|
+
}
|
|
9
|
+
function detectSystemLocale() {
|
|
10
|
+
try {
|
|
11
|
+
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
|
|
12
|
+
if (locale && locale.length >= 2) return locale;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
for (const key of ["LANG", "LC_ALL", "LC_MESSAGES"]) {
|
|
16
|
+
const raw = process.env[key];
|
|
17
|
+
if (!raw || raw === "C" || raw === "POSIX") continue;
|
|
18
|
+
const match = raw.match(/^([a-z]{2})_([A-Z]{2})(?:[.@].*)?$/);
|
|
19
|
+
if (match) return `${match[1]}-${match[2]}`;
|
|
20
|
+
}
|
|
21
|
+
return "zh-CN";
|
|
22
|
+
}
|
|
23
|
+
function resolveLanguage(explicit) {
|
|
24
|
+
if (explicit !== void 0) return explicit;
|
|
25
|
+
return detectSystemLocale();
|
|
26
|
+
}
|
|
27
|
+
function languageInstruction(language) {
|
|
28
|
+
const label = LANG_LABELS.get(language) ?? language;
|
|
29
|
+
return `Always respond in ${label}. Do NOT reply in any other language unless the user explicitly asks for it.`;
|
|
30
|
+
}
|
|
31
|
+
var LANG_LABELS = /* @__PURE__ */ new Map([
|
|
32
|
+
["zh-CN", "Simplified Chinese (zh-CN)"],
|
|
33
|
+
["zh-TW", "Traditional Chinese (zh-TW)"],
|
|
34
|
+
["zh-HK", "Traditional Chinese (zh-HK)"],
|
|
35
|
+
["ja-JP", "Japanese (ja-JP)"],
|
|
36
|
+
["ko-KR", "Korean (ko-KR)"],
|
|
37
|
+
["en-US", "English (en-US)"],
|
|
38
|
+
["en-GB", "English (en-GB)"],
|
|
39
|
+
["fr-FR", "French (fr-FR)"],
|
|
40
|
+
["de-DE", "German (de-DE)"],
|
|
41
|
+
["es-ES", "Spanish (es-ES)"],
|
|
42
|
+
["pt-BR", "Portuguese (pt-BR)"],
|
|
43
|
+
["ru-RU", "Russian (ru-RU)"],
|
|
44
|
+
["ar-SA", "Arabic (ar-SA)"],
|
|
45
|
+
["vi-VN", "Vietnamese (vi-VN)"],
|
|
46
|
+
["th-TH", "Thai (th-TH)"],
|
|
47
|
+
["id-ID", "Indonesian (id-ID)"]
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
// src/utils/envUtils.ts
|
|
51
|
+
function isEnvTruthy(value) {
|
|
52
|
+
if (typeof value === "boolean") return value;
|
|
53
|
+
return value === "1" || value?.toLowerCase() === "true" || value?.toLowerCase() === "yes";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
isEnvTruthy,
|
|
58
|
+
getGraphemeSegmenter,
|
|
59
|
+
resolveLanguage,
|
|
60
|
+
languageInstruction
|
|
61
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as createFlavorRequire } from "node:module"; const require = createFlavorRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/redact.ts
|
|
5
|
+
function redactErrorText(text) {
|
|
6
|
+
return text.replace(/\bsk-[A-Za-z0-9_-]+\b/g, "[redacted]").replace(/(authorization|api[_ -]?key|token)\s*[:=]\s*\S+/gi, "$1=[redacted]");
|
|
7
|
+
}
|
|
8
|
+
function redactSecrets(input, secrets) {
|
|
9
|
+
return secrets.reduce((text, secret) => text.replaceAll(secret, "[redacted]"), input);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
redactErrorText,
|
|
14
|
+
redactSecrets
|
|
15
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as createFlavorRequire } from "node:module"; const require = createFlavorRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/usage-summary.ts
|
|
5
|
+
function asNumber(value) {
|
|
6
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
7
|
+
}
|
|
8
|
+
function parseUsageEntries(raw) {
|
|
9
|
+
const entries = [];
|
|
10
|
+
for (const line of raw.split("\n")) {
|
|
11
|
+
const trimmed = line.trim();
|
|
12
|
+
if (trimmed.length === 0) continue;
|
|
13
|
+
let parsed;
|
|
14
|
+
try {
|
|
15
|
+
parsed = JSON.parse(trimmed);
|
|
16
|
+
} catch {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (parsed.event !== "flavor-usage") continue;
|
|
20
|
+
if (typeof parsed.provider !== "string" || typeof parsed.model !== "string") continue;
|
|
21
|
+
entries.push({
|
|
22
|
+
event: "flavor-usage",
|
|
23
|
+
sessionId: typeof parsed.sessionId === "string" ? parsed.sessionId : void 0,
|
|
24
|
+
provider: parsed.provider,
|
|
25
|
+
model: parsed.model,
|
|
26
|
+
inputTokens: asNumber(parsed.inputTokens),
|
|
27
|
+
cacheReadTokens: asNumber(parsed.cacheReadTokens),
|
|
28
|
+
cacheCreationTokens: asNumber(parsed.cacheCreationTokens),
|
|
29
|
+
totalInputTokens: asNumber(parsed.totalInputTokens),
|
|
30
|
+
cacheHitRatio: asNumber(parsed.cacheHitRatio)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return entries;
|
|
34
|
+
}
|
|
35
|
+
function summarizeUsage(entries) {
|
|
36
|
+
const groups = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const key = `${entry.provider}:${entry.model}`;
|
|
39
|
+
let stats = groups.get(key);
|
|
40
|
+
if (stats === void 0) {
|
|
41
|
+
stats = {
|
|
42
|
+
provider: entry.provider,
|
|
43
|
+
model: entry.model,
|
|
44
|
+
requests: 0,
|
|
45
|
+
inputTokens: 0,
|
|
46
|
+
cacheReadTokens: 0,
|
|
47
|
+
cacheCreationTokens: 0,
|
|
48
|
+
totalInputTokens: 0,
|
|
49
|
+
minHitRatio: Number.POSITIVE_INFINITY,
|
|
50
|
+
averageHitRatio: 0
|
|
51
|
+
};
|
|
52
|
+
groups.set(key, stats);
|
|
53
|
+
}
|
|
54
|
+
stats.requests += 1;
|
|
55
|
+
stats.inputTokens += entry.inputTokens;
|
|
56
|
+
stats.cacheReadTokens += entry.cacheReadTokens;
|
|
57
|
+
stats.cacheCreationTokens += entry.cacheCreationTokens;
|
|
58
|
+
stats.totalInputTokens += entry.totalInputTokens;
|
|
59
|
+
stats.minHitRatio = Math.min(stats.minHitRatio, entry.cacheHitRatio);
|
|
60
|
+
stats.averageHitRatio += entry.cacheHitRatio;
|
|
61
|
+
}
|
|
62
|
+
const byModel = [...groups.values()].map((stats) => ({
|
|
63
|
+
...stats,
|
|
64
|
+
minHitRatio: Number.isFinite(stats.minHitRatio) ? stats.minHitRatio : 0,
|
|
65
|
+
averageHitRatio: stats.requests > 0 ? stats.averageHitRatio / stats.requests : 0
|
|
66
|
+
})).sort((left, right) => right.totalInputTokens - left.totalInputTokens);
|
|
67
|
+
const totalInputTokens = entries.reduce((sum, entry) => sum + entry.totalInputTokens, 0);
|
|
68
|
+
const totalCacheReadTokens = entries.reduce((sum, entry) => sum + entry.cacheReadTokens, 0);
|
|
69
|
+
return {
|
|
70
|
+
requests: entries.length,
|
|
71
|
+
sessionId: entries.length > 0 ? entries[entries.length - 1]?.sessionId : void 0,
|
|
72
|
+
byModel,
|
|
73
|
+
totalInputTokens,
|
|
74
|
+
totalCacheReadTokens,
|
|
75
|
+
cacheShare: totalInputTokens > 0 ? totalCacheReadTokens / totalInputTokens : 0
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function formatTokens(value) {
|
|
79
|
+
if (value < 1e3) return String(value);
|
|
80
|
+
return `${(value / 1e3).toFixed(1)}k`;
|
|
81
|
+
}
|
|
82
|
+
function formatUsageSummary(summary) {
|
|
83
|
+
if (summary.requests === 0) return "No usage recorded in this session yet.";
|
|
84
|
+
const sessionLabel = summary.sessionId ?? "unknown";
|
|
85
|
+
const header = `Usage for session ${sessionLabel} (${summary.requests} request${summary.requests === 1 ? "" : "s"}):`;
|
|
86
|
+
const columns = summary.byModel.map((stats) => [
|
|
87
|
+
stats.provider,
|
|
88
|
+
stats.model,
|
|
89
|
+
String(stats.requests),
|
|
90
|
+
`${stats.minHitRatio.toFixed(2)}\u2192${stats.averageHitRatio.toFixed(2)}`,
|
|
91
|
+
formatTokens(stats.inputTokens),
|
|
92
|
+
formatTokens(stats.cacheReadTokens),
|
|
93
|
+
formatTokens(stats.cacheCreationTokens)
|
|
94
|
+
]);
|
|
95
|
+
const titles = ["provider", "model", "reqs", "hit(min\u2192avg)", "input", "cacheRead", "cacheWrite"];
|
|
96
|
+
const widths = titles.map(
|
|
97
|
+
(title, index) => Math.max(title.length, ...columns.map((row) => row[index]?.length ?? 0))
|
|
98
|
+
);
|
|
99
|
+
const render = (row, indent) => indent + row.map((cell, index) => cell.padEnd(widths[index] ?? cell.length)).join(" ").trimEnd();
|
|
100
|
+
const table = [render(titles, " "), ...columns.map((row) => render(row, " "))].join("\n");
|
|
101
|
+
const cachePercent = (summary.cacheShare * 100).toFixed(1);
|
|
102
|
+
const total = `Total input tokens: ${formatTokens(summary.totalInputTokens)} (cache read ${formatTokens(summary.totalCacheReadTokens)}, ${cachePercent}%)`;
|
|
103
|
+
return `${header}
|
|
104
|
+
|
|
105
|
+
${table}
|
|
106
|
+
|
|
107
|
+
${total}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
parseUsageEntries,
|
|
112
|
+
summarizeUsage,
|
|
113
|
+
formatUsageSummary
|
|
114
|
+
};
|